package com.google.firebase.messaging;

import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.util.Log;
import org.json.JSONException;
import org.json.JSONObject;

/* JADX INFO: loaded from: classes2.dex */
public final /* synthetic */ class n implements w8.g {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final /* synthetic */ FirebaseMessaging f24222a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final /* synthetic */ String f24223b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final /* synthetic */ c0 f24224c;

    public /* synthetic */ n(FirebaseMessaging firebaseMessaging, String str, c0 c0Var) {
        this.f24222a = firebaseMessaging;
        this.f24223b = str;
        this.f24224c = c0Var;
    }

    @Override // w8.g
    public final w8.t a(Object obj) {
        String string;
        FirebaseMessaging firebaseMessaging = this.f24222a;
        String str = this.f24223b;
        c0 c0Var = this.f24224c;
        String str2 = (String) obj;
        d0 d0VarD = FirebaseMessaging.d(firebaseMessaging.f24122b);
        ua.g gVar = firebaseMessaging.f24121a;
        gVar.a();
        String strC = "[DEFAULT]".equals(gVar.f33402b) ? "" : gVar.c();
        String strA = firebaseMessaging.f24129i.a();
        synchronized (d0VarD) {
            long jCurrentTimeMillis = System.currentTimeMillis();
            int i10 = c0.f24160e;
            try {
                JSONObject jSONObject = new JSONObject();
                jSONObject.put("token", str2);
                jSONObject.put("appVersion", strA);
                jSONObject.put("timestamp", jCurrentTimeMillis);
                string = jSONObject.toString();
            } catch (JSONException e10) {
                e10.toString();
                string = null;
            }
            if (string != null) {
                SharedPreferences.Editor editorEdit = d0VarD.f24165a.edit();
                editorEdit.putString(strC + "|T|" + str + "|*", string);
                editorEdit.commit();
            }
        }
        if (c0Var == null || !str2.equals(c0Var.f24161a)) {
            ua.g gVar2 = firebaseMessaging.f24121a;
            gVar2.a();
            if ("[DEFAULT]".equals(gVar2.f33402b)) {
                if (Log.isLoggable("FirebaseMessaging", 3)) {
                    gVar2.a();
                }
                Intent intent = new Intent("com.google.firebase.messaging.NEW_TOKEN");
                intent.putExtra("token", str2);
                new j(firebaseMessaging.f24122b).b(intent);
            }
        }
        return w8.k.e(str2);
    }

    public final w8.t b() {
        FirebaseMessaging firebaseMessaging = this.f24222a;
        p pVar = firebaseMessaging.f24123c;
        w8.t tVarA = pVar.a(pVar.c(s.b(pVar.f24232a), "*", new Bundle()));
        n nVar = new n(firebaseMessaging, this.f24223b, this.f24224c);
        w8.t tVar = new w8.t();
        tVarA.f34251b.f(new w8.q(firebaseMessaging.f24127g, nVar, tVar));
        tVarA.m();
        return tVar;
    }
}
