Shinigami ID v1.1.3版本的 MD5 值为:c381e85feac697f048c400ae89b7b92d
以下内容为反编译后的 x.java 源代码,内容仅作参考
package com.wonderpush.sdk;
import android.app.Activity;
import android.app.Application;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.SharedPreferences;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.location.Location;
import android.location.LocationManager;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import com.wonderpush.sdk.inappmessaging.InAppMessaging;
import com.wonderpush.sdk.inappmessaging.display.InAppMessagingDisplay;
import com.wonderpush.sdk.push.PushService;
import com.wonderpush.sdk.t;
import com.wonderpush.sdk.w;
import com.wonderpush.sdk.z;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Currency;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashSet;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
import java.util.TreeMap;
import java.util.UUID;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;
import org.json.JSONException;
import org.json.JSONObject;
import sa.j0;
import sa.n0;
import sa.o0;
import sa.p0;
import sa.r0;
import sa.s0;
public final class x {
public static boolean f4860a;
public static boolean f4861b;
public static InAppMessaging c;
public static InAppMessaging.c f4862d;
public static Context f4863e;
public static Application f4864f;
public static f0 f4866h;
public static t f4867i;
public static ib.j f4868j;
public static String f4869k;
public static String l;
public static String f4870m;
public static final Set<k> f4877t;
public static String f4878u;
public static AtomicReference<Location> v;
public static boolean f4879w;
public static final ScheduledExecutorService f4865g = Executors.newScheduledThreadPool(1, new c());
public static boolean f4871n = false;
public static boolean f4872o = false;
public static sa.k f4873p = new p0();
public static final Map<String, Runnable> f4874q = new TreeMap();
public static final Set<l> f4875r = new LinkedHashSet();
public static final Map<String, Runnable> f4876s = new TreeMap();
public class a implements Runnable {
public final Runnable f4880o;
public final String f4881p;
public a(Runnable runnable, String str) {
this.f4880o = runnable;
this.f4881p = str;
}
@Override
public final void run() {
if (x.o()) {
this.f4880o.run();
return;
}
?? r02 = x.f4874q;
synchronized (r02) {
String str = this.f4881p;
if (str == null) {
str = UUID.randomUUID().toString();
}
r02.put(str, this.f4880o);
}
}
}
public class b implements t.b {
}
public class c implements ThreadFactory {
public final ThreadGroup f4882o;
public final AtomicInteger f4883p = new AtomicInteger(1);
public c() {
SecurityManager securityManager = System.getSecurityManager();
this.f4882o = securityManager != null ? securityManager.getThreadGroup() : Thread.currentThread().getThreadGroup();
}
@Override
public final Thread newThread(Runnable runnable) {
ThreadGroup threadGroup = this.f4882o;
StringBuilder w10 = aa.p.w("WonderPush-");
w10.append(this.f4883p.getAndIncrement());
Thread thread = new Thread(threadGroup, runnable, w10.toString(), 0L);
if (thread.isDaemon()) {
thread.setDaemon(false);
}
if (thread.getPriority() != 4) {
thread.setPriority(4);
}
return thread;
}
}
public class d implements l {
@Override
public final void a(boolean z10) {
if (z10) {
?? r52 = x.f4874q;
synchronized (r52) {
ArrayList arrayList = new ArrayList(r52.values());
r52.clear();
Iterator it = arrayList.iterator();
while (it.hasNext()) {
x.C((Runnable) it.next(), 0L);
}
}
}
}
}
public class e implements k {
@Override
public final void a() {
if (x.t()) {
?? r02 = x.f4876s;
synchronized (r02) {
ArrayList arrayList = new ArrayList(r02.values());
r02.clear();
Iterator it = arrayList.iterator();
while (it.hasNext()) {
x.C((Runnable) it.next(), 0L);
}
}
}
}
}
public class f implements ib.f {
@Override
public final void a(ib.d dVar, Throwable th) {
boolean z10;
if (dVar == null) {
return;
}
JSONObject jSONObject = dVar.f7392a;
boolean optBoolean = jSONObject.optBoolean("disableJsonSync", false);
Long l = m.l;
synchronized (m.class) {
m.f4789p = optBoolean;
}
synchronized (m.class) {
z10 = m.f4789p;
}
if (!z10) {
m.l();
}
com.wonderpush.sdk.g.f4688g.c = jSONObject.optBoolean("disableApiClient", false);
n.c = jSONObject.optBoolean("disableMeasurementsApiClient", false);
z.f4892f = jSONObject.optLong("trackedEventsUncollapsedMaximumAgeMs", 7776000000L);
z.f4891e = jSONObject.optInt("trackedEventsUncollapsedMaximumCount", 10000);
z.f4889b = jSONObject.optInt("trackedEventsCollapsedLastBuiltinMaximumCount", 100);
z.c = jSONObject.optInt("trackedEventsCollapsedLastCustomMaximumCount", 1000);
z.f4890d = jSONObject.optInt("trackedEventsCollapsedOtherMaximumCount", 1000);
}
}
public class g extends BroadcastReceiver {
public final ib.f f4884a;
public g(ib.f fVar) {
this.f4884a = fVar;
}
@Override
public final void onReceive(Context context, Intent intent) {
String stringExtra = intent.getStringExtra("EXTRA_REMOTE_CONFIG");
if (stringExtra != null) {
this.f4884a.a(ib.d.b(stringExtra), null);
}
}
}
public class h implements l {
@Override
public final void a(boolean z10) {
if (z10) {
x.s();
}
}
}
public interface i {
void b(androidx.appcompat.widget.m mVar);
}
public enum j {
OPT_IN("optIn"),
OPT_OUT("optOut");
j(String str) {
}
}
public interface k {
void a();
}
public interface l {
void a(boolean z10);
}
static {
LinkedHashSet linkedHashSet = new LinkedHashSet();
f4877t = linkedHashSet;
b(new d());
e eVar = new e();
synchronized (linkedHashSet) {
linkedHashSet.add(eVar);
}
f4878u = null;
v = null;
}
public static void A(boolean z10) {
f();
C(new sa.m(), 0L);
String g10 = z.g();
if (z10) {
z.w("__wonderpush_gcm_registration_id", null);
androidx.fragment.app.f0 f0Var = new androidx.fragment.app.f0(10);
f0Var.f1284p = g10;
f0Var.f1285q = z.p("__wonderpush_gcm_registration_service");
f0Var.f1286r = z.h();
gb.a.b(f0Var);
} else {
PushService pushService = gb.a.c;
if (pushService == null) {
Log.e("WonderPush.Push", "Cannot refresh push subscription, no push service available");
} else {
pushService.a();
}
}
boolean m10 = z.m();
if (z10) {
z.C(!m10);
}
B();
}
public static void B() {
try {
f4873p.B();
} catch (Exception e10) {
Log.d("WonderPush", "Unexpected error while refreshing subscription status", e10);
}
}
public static void C(Runnable runnable, long j10) {
f4865g.schedule(runnable, j10, TimeUnit.MILLISECONDS);
}
public static void D(Runnable runnable, String str) {
C(new a(runnable, str), 0L);
}
public static boolean E(Activity activity, Intent intent) {
try {
return p.A(activity, intent);
} catch (Exception e10) {
Log.e("WonderPush", "Unexpected error while showing potential notification", e10);
return false;
}
}
public static void F() {
try {
f4873p.u();
} catch (Exception e10) {
Log.d("WonderPush", "Unexpected error while subscribing to notifications", e10);
}
}
public static void G() {
Set<k> set = f4877t;
synchronized (set) {
if (!f4871n) {
x("subscriptionStatusChanged called before SDK is initialized");
}
HashSet hashSet = new HashSet(set);
m();
Iterator it = hashSet.iterator();
while (it.hasNext()) {
try {
((k) it.next()).a();
} catch (Exception e10) {
Log.e("WonderPush", "Unexpected error while processing user consent changed listeners", e10);
}
}
}
}
public static void H(String str, JSONObject jSONObject, JSONObject jSONObject2, Runnable runnable) {
if (str.charAt(0) != '@') {
throw new IllegalArgumentException("This method must only be called for internal events, starting with an '@'");
}
a(str, jSONObject, jSONObject2, true, runnable);
}
public static void a(final String str, final JSONObject jSONObject, final JSONObject jSONObject2, final boolean z10, final Runnable runnable) {
if (!o()) {
x("Not tracking event without user consent. type=" + str + ", data=" + jSONObject + " custom=" + jSONObject2);
return;
}
final JSONObject i10 = i(str, jSONObject, jSONObject2);
z.a x = z.x(i10);
JSONObject jSONObject3 = null;
if (x != null) {
try {
jSONObject3 = x.a();
i10.put("occurrences", jSONObject3);
} catch (JSONException e10) {
y("Could not add occurrences to payload", e10);
}
}
Intent intent = new Intent("wonderpushEventTracked");
intent.putExtra("eventType", str);
if (jSONObject2 != null) {
intent.putExtra("customData", jSONObject2.toString());
}
if (jSONObject3 != null) {
intent.putExtra("occurrences", jSONObject3.toString());
}
a1.a.a(f()).c(intent);
f4868j.c(new sa.c0(new i() {
@Override
public final void b(androidx.appcompat.widget.m mVar) {
String str2 = str;
JSONObject jSONObject4 = jSONObject;
JSONObject jSONObject5 = jSONObject2;
JSONObject jSONObject6 = i10;
Runnable runnable2 = runnable;
final boolean z11 = z10;
if (mVar == null || mVar.j(str2)) {
final w.c cVar = new w.c();
cVar.k("body", jSONObject6.toString());
final e0 e0Var = new e0(cVar, runnable2, 0);
com.wonderpush.sdk.x.f4868j.c(new ib.f() {
@Override
public final void a(ib.d dVar, Throwable th) {
Runnable runnable3 = e0Var;
boolean z12 = z11;
w.c cVar2 = cVar;
if (dVar != null && dVar.f7392a.optBoolean("trackEventsForNonSubscribers")) {
runnable3.run();
return;
}
if (z12) {
com.wonderpush.sdk.x.C(new g0(runnable3), 0L);
return;
}
com.wonderpush.sdk.w wVar = new com.wonderpush.sdk.w(com.wonderpush.sdk.z.r(), 3, "/events/", cVar2, null);
if (com.wonderpush.sdk.z.c() != null) {
com.wonderpush.sdk.g.f4688g.e(wVar);
} else {
com.wonderpush.sdk.e.f4677e.e(wVar);
}
}
});
return;
}
com.wonderpush.sdk.x.x("Not tracking event forbidden by config. type=" + str2 + ", data=" + jSONObject4 + " custom=" + jSONObject5);
}
}, 0));
}
public static void b(l lVar) {
Set<l> set = f4875r;
synchronized (set) {
set.add(lVar);
}
}
public static void c(Boolean bool) {
if (bool == null) {
f4861b = false;
return;
}
Log.d("WonderPush", "OVERRIDE setLogging(" + bool + ")");
boolean booleanValue = bool.booleanValue();
if (!f4861b) {
f4860a = booleanValue;
}
f4861b = true;
}
public static void d(String str, JSONObject jSONObject) {
int i10 = 0;
if (str.charAt(0) != '@') {
throw new IllegalArgumentException("This method must only be called for internal events, starting with an '@'");
}
JSONObject jSONObject2 = null;
if (!o()) {
x("Not tracking event without user consent. type=" + str + ", data=" + jSONObject + " custom=" + ((Object) null));
return;
}
if (z.c() != null && z.n() == Boolean.TRUE) {
a(str, jSONObject, null, true, null);
return;
}
JSONObject i11 = i(str, jSONObject, null);
z.a x = z.x(i11);
if (x != null) {
try {
jSONObject2 = x.a();
i11.put("occurrences", jSONObject2);
} catch (JSONException e10) {
y("Could not add occurrences to payload", e10);
}
}
Intent intent = new Intent("wonderpushEventTracked");
intent.putExtra("eventType", str);
if (jSONObject2 != null) {
intent.putExtra("occurrences", jSONObject2.toString());
}
a1.a.a(f()).c(intent);
f4868j.c(new sa.c0(new z2.n(str, jSONObject, i11), i10));
}
public static boolean e(Context context, boolean z10) {
Boolean a10;
String b10;
String b11;
Boolean a11;
Boolean a12;
String b12;
Boolean a13;
String str;
Object obj;
Iterator it;
String str2 = null;
if (f4871n) {
r(context, null, null);
return true;
}
if (r0.f11995b == null) {
r0.f11995b = context;
r0.f11997e = context.getResources();
try {
Bundle bundle = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData;
r0.c = bundle;
if (bundle == null) {
r0.c = new Bundle();
}
} catch (PackageManager.NameNotFoundException e10) {
Log.e("WonderPush.Settings", "Failed to read application meta-data", e10);
}
try {
Resources resources = context.getResources();
int identifier = resources.getIdentifier("wonderpush_buildConfigPackage", "string", context.getPackageName());
str = identifier == 0 ? null : resources.getString(identifier);
if (TextUtils.isEmpty(str)) {
str = null;
} else {
try {
if (f4860a) {
Log.d("WonderPush.Settings", "wonderpush_buildConfigPackage resource: " + str);
}
} catch (Exception e11) {
e = e11;
Log.e("WonderPush.Settings", "Could not get a WonderPush configuration resource", e);
obj = r0.c.get("com.wonderpush.sdk.buildConfigPackage");
if (obj instanceof String) {
}
ArrayList arrayList = new ArrayList();
if (str == null) {
}
it = arrayList.iterator();
while (it.hasNext()) {
}
boolean z11 = r0.f11996d;
a10 = r0.a("WONDERPUSH_AUTO_INIT", "wonderpush_autoInit", "com.wonderpush.sdk.autoInit");
if (a10 == null) {
}
Boolean bool = a10;
b10 = r0.b("WONDERPUSH_CLIENT_ID", "wonderpush_clientId", "com.wonderpush.sdk.clientId");
b11 = r0.b("WONDERPUSH_CLIENT_SECRET", "wonderpush_clientSecret", "com.wonderpush.sdk.clientSecret");
a11 = r0.a("WONDERPUSH_LOGGING", "wonderpush_logging", "com.wonderpush.sdk.logging");
a12 = r0.a("WONDERPUSH_REQUIRES_USER_CONSENT", "wonderpush_requiresUserConsent", "com.wonderpush.sdk.requiresUserConsent");
b12 = r0.b("WONDERPUSH_INTEGRATOR", "wonderpush_integrator", "com.wonderpush.sdk.integrator");
a13 = r0.a("WONDERPUSH_GEOLOCATION", "wonderpush_geolocation", "com.wonderpush.sdk.geolocation");
if (a11 != null) {
}
if (a13 != null) {
}
if (a12 != null) {
}
if (b12 != null) {
}
if (f4863e == null) {
}
if (!z10) {
}
if (!f4871n) {
}
if (!f4871n) {
u("Initializing WonderPush using collected credentials");
r(context, b10, b11);
}
if (!f4871n) {
}
if (!s.e()) {
}
return f4871n;
}
}
} catch (Exception e12) {
e = e12;
str = null;
}
obj = r0.c.get("com.wonderpush.sdk.buildConfigPackage");
if (obj instanceof String) {
String str3 = (String) obj;
if (str3.length() > 0) {
if (f4860a) {
Log.d("WonderPush.Settings", "com.wonderpush.sdk.buildConfigPackage metadata: " + str3);
}
str = str3;
}
}
ArrayList arrayList2 = new ArrayList();
if (str == null) {
arrayList2.add(str);
} else {
arrayList2.add(context.getPackageName());
arrayList2.add(context.getApplicationContext().getClass().getPackage().getName());
}
it = arrayList2.iterator();
while (it.hasNext()) {
String str4 = ((String) it.next()) + ".BuildConfig";
try {
Class<?> loadClass = context.getClassLoader().loadClass(str4);
if (f4860a) {
Log.d("WonderPush.Settings", "Reading configuration from " + str4);
}
for (Field field : loadClass.getFields()) {
if (field.getName().startsWith("WONDERPUSH_")) {
try {
r0.f11994a.put(field.getName(), field.get(null));
} catch (Exception e13) {
Log.e("WonderPush.Settings", "Could not get BuildConfig field " + field.getName(), e13);
}
}
}
r0.f11996d = true;
break;
} catch (ClassNotFoundException unused) {
if (f4860a) {
Log.d("WonderPush.Settings", "No " + str4 + " class found. ProGuard may have removed it after finding no WONDERPUSH_* constants.");
}
}
}
}
boolean z112 = r0.f11996d;
a10 = r0.a("WONDERPUSH_AUTO_INIT", "wonderpush_autoInit", "com.wonderpush.sdk.autoInit");
if (a10 == null) {
a10 = Boolean.TRUE;
}
Boolean bool2 = a10;
b10 = r0.b("WONDERPUSH_CLIENT_ID", "wonderpush_clientId", "com.wonderpush.sdk.clientId");
b11 = r0.b("WONDERPUSH_CLIENT_SECRET", "wonderpush_clientSecret", "com.wonderpush.sdk.clientSecret");
a11 = r0.a("WONDERPUSH_LOGGING", "wonderpush_logging", "com.wonderpush.sdk.logging");
a12 = r0.a("WONDERPUSH_REQUIRES_USER_CONSENT", "wonderpush_requiresUserConsent", "com.wonderpush.sdk.requiresUserConsent");
b12 = r0.b("WONDERPUSH_INTEGRATOR", "wonderpush_integrator", "com.wonderpush.sdk.integrator");
a13 = r0.a("WONDERPUSH_GEOLOCATION", "wonderpush_geolocation", "com.wonderpush.sdk.geolocation");
if (a11 != null) {
if (!a11.booleanValue()) {
u("Applying configuration: logging: " + a11);
}
boolean booleanValue = a11.booleanValue();
if (!f4861b) {
f4860a = booleanValue;
}
if (a11.booleanValue()) {
u("Applying configuration: logging: " + a11);
}
}
if (a13 != null) {
u("Applying configuration: geolocation: " + a13);
if (a13.booleanValue()) {
v = null;
} else {
try {
v = new AtomicReference<>(null);
} catch (Exception e14) {
Log.d("WonderPush", "Unexpected error while setting geolocation", e14);
}
}
}
if (a12 != null) {
u("Applying configuration: requiresUserConsent: " + a12);
boolean booleanValue2 = a12.booleanValue();
try {
if (f4871n) {
boolean o4 = o();
f4872o = booleanValue2;
Log.w("WonderPush", "WonderPush.setRequiresUserConsent(" + booleanValue2 + ") called after WonderPush.initialize(). Although supported, a proper implementation typically only calls it before.");
boolean o10 = o();
if (o4 != o10) {
p(o10);
}
} else {
f4872o = booleanValue2;
}
} catch (Exception e15) {
Log.d("WonderPush", "Unexpected error while setting requires-user-consent", e15);
}
}
if (b12 != null) {
u("Applying configuration: integrator: " + b12);
f4878u = b12;
}
if (f4863e == null) {
f4863e = context.getApplicationContext();
}
if (!z10 && !bool2.booleanValue()) {
u("Skipping automatic initialization");
return false;
}
if (!f4871n) {
try {
Bundle bundle2 = context.getPackageManager().getApplicationInfo(context.getPackageName(), 128).metaData;
if (bundle2 == null) {
bundle2 = new Bundle();
}
str2 = bundle2.getString("wonderpushInitializerClass");
if (str2 != null) {
if (str2.startsWith(".")) {
str2 = context.getPackageName() + str2;
}
u("Initializing WonderPush using initializer class " + str2);
((n0) Class.forName(str2).asSubclass(n0.class).newInstance()).initialize();
}
} catch (PackageManager.NameNotFoundException e16) {
Log.e("WonderPush", "Failed to read application meta-data", e16);
} catch (ClassNotFoundException e17) {
Log.e("WonderPush", "Failed to load initializer class. Check your <meta-data android:name=\"wonderpushInitializerClass\" android:value=\"com.package.YourWonderPushInitializerImpl\"/> entry under <application> in your AndroidManifest.xml", e17);
} catch (IllegalAccessException e18) {
Log.e("WonderPush", "Failed to intantiate the initializer class " + str2 + ". Make sure it has a public default constructor with no argument.", e18);
} catch (InstantiationException e19) {
Log.e("WonderPush", "Failed to intantiate the initializer class " + str2 + ". Make sure it has a public default constructor with no argument.", e19);
} catch (NullPointerException e20) {
Log.e("WonderPush", "Failed to load initializer class", e20);
} catch (Exception e21) {
Log.e("WonderPush", "Unexpected error while ensuring SDK initialization", e21);
}
}
if (!f4871n && !TextUtils.isEmpty(b10) && !TextUtils.isEmpty(b11)) {
u("Initializing WonderPush using collected credentials");
r(context, b10, b11);
}
if (!f4871n) {
Log.e("WonderPush", "Could not initialize WonderPush using the initializer class, BuildConfig options or manifest <meta-data> options!");
if (!z112) {
Log.w("WonderPush", "No BuildConfig class found. You probably need to give the value of your gradle defaultConfig.applicationId as the a \"wonderpush_buildConfigPackage\" string resource or a \"com.wonderpush.sdk.buildConfigPackage\" manifest <meta-data>.");
}
}
if (!s.e()) {
s0.c();
}
return f4871n;
}
public static Context f() {
if (f4863e == null) {
Log.e("WonderPush", "Application context is null, did you call WonderPush.initialize()?");
}
return f4863e;
}
public static String g() {
try {
String p10 = z.p("__country");
if (p10 != null) {
return p10;
}
String country = Locale.getDefault().getCountry();
if (TextUtils.isEmpty(country)) {
return null;
}
return country.toUpperCase();
} catch (Exception e10) {
Log.d("WonderPush", "Unexpected error while getting country", e10);
return null;
}
}
public static String h() {
String str = null;
try {
String p10 = z.p("__currency");
if (p10 != null) {
return p10;
}
try {
Currency currency = Currency.getInstance(Locale.getDefault());
if (currency == null) {
return null;
}
p10 = currency.getCurrencyCode();
if (!TextUtils.isEmpty(p10)) {
str = p10.toUpperCase();
}
return str;
} catch (Exception unused) {
return p10;
}
} catch (Exception e10) {
Log.d("WonderPush", "Unexpected error while getting currency", e10);
return null;
}
}
public static JSONObject i(String str, JSONObject jSONObject, JSONObject jSONObject2) {
JSONObject jSONObject3 = new JSONObject();
if (jSONObject != null && jSONObject.length() > 0) {
Iterator<String> keys = jSONObject.keys();
while (keys.hasNext()) {
String next = keys.next();
try {
jSONObject3.putOpt(next, jSONObject.opt(next));
} catch (JSONException e10) {
y("Error building event object body", e10);
}
}
}
try {
jSONObject3.put("type", str);
if (jSONObject2 != null && jSONObject2.length() > 0) {
jSONObject3.put("custom", jSONObject2);
}
Location k10 = k();
if (k10 != null) {
JSONObject jSONObject4 = new JSONObject();
jSONObject4.put("lat", k10.getLatitude());
jSONObject4.put("lon", k10.getLongitude());
jSONObject3.put("location", jSONObject4);
}
if (!jSONObject3.has("actionDate")) {
jSONObject3.put("actionDate", sa.a0.f());
}
sa.u uVar = p.f4804b;
if (uVar != null) {
uVar.a(jSONObject3, "recentNotificationOpened");
}
} catch (JSONException e11) {
y("Error building event object body", e11);
}
return jSONObject3;
}
public static String j() {
Locale locale;
try {
String p10 = z.p("__locale");
if (p10 != null || (locale = Locale.getDefault()) == null) {
return p10;
}
String language = locale.getLanguage();
if (TextUtils.isEmpty(language)) {
return p10;
}
Locale locale2 = Locale.ENGLISH;
String lowerCase = language.toLowerCase(locale2);
String country = locale.getCountry();
if (TextUtils.isEmpty(country)) {
return lowerCase;
}
return lowerCase + "_" + country.toUpperCase(locale2);
} catch (Exception e10) {
Log.d("WonderPush", "Unexpected error while getting locale", e10);
return null;
}
}
public static Location k() {
Context f10 = f();
if (f10 == null) {
return null;
}
AtomicReference<Location> atomicReference = v;
if (atomicReference != null) {
return atomicReference.get();
}
LocationManager locationManager = (LocationManager) f10.getSystemService("location");
try {
Iterator<String> it = locationManager.getAllProviders().iterator();
Location location = null;
while (it.hasNext()) {
try {
Location lastKnownLocation = locationManager.getLastKnownLocation(it.next());
if (lastKnownLocation != null) {
if (lastKnownLocation.getAccuracy() > 0.0f) {
if (lastKnownLocation.getAccuracy() < 10000.0f) {
if (lastKnownLocation.getTime() >= System.currentTimeMillis() - 1800000) {
if (location != null) {
if (lastKnownLocation.getTime() >= location.getTime() - 120000 && lastKnownLocation.getAccuracy() <= location.getAccuracy()) {
}
}
location = lastKnownLocation;
}
}
}
}
} catch (SecurityException unused) {
}
}
return location;
} catch (SecurityException unused2) {
return null;
}
}
public static t l() {
if (f4867i == null) {
f4867i = new t(new b());
}
return f4867i;
}
public static j m() {
JSONObject optJSONObject;
m m10 = m.m();
if (m10 != null) {
try {
optJSONObject = m10.g().optJSONObject("preferences");
} catch (JSONException unused) {
}
} else {
optJSONObject = null;
}
String optString = optJSONObject != null ? optJSONObject.optString("subscriptionStatus") : null;
if (optString == null) {
return null;
}
j jVar = j.OPT_OUT;
if (optString.equals("optOut")) {
return jVar;
}
j jVar2 = j.OPT_IN;
if (optString.equals("optIn")) {
return jVar2;
}
return null;
}
public static String n() {
try {
String p10 = z.p("__time_zone");
return p10 == null ? TimeZone.getDefault().getID() : p10;
} catch (Exception e10) {
Log.d("WonderPush", "Unexpected error while getting timezone", e10);
return null;
}
}
public static boolean o() {
try {
if (f4872o) {
if (!z.e("__user_consent", false)) {
return false;
}
}
return true;
} catch (Exception e10) {
Log.d("WonderPush", "Unexpected error while testing user consent", e10);
return false;
}
}
public static void p(boolean z10) {
HashSet hashSet;
if (!f4871n) {
x("hasUserConsentChanged called before SDK is initialized");
}
u("User consent changed to " + z10);
f4873p.K();
if (z10) {
f4873p = new b0();
} else {
f4873p = new o0();
}
f4873p.k();
Set<l> set = f4875r;
synchronized (set) {
hashSet = new HashSet(set);
}
Iterator it = hashSet.iterator();
while (it.hasNext()) {
try {
((l) it.next()).a(z10);
} catch (Exception e10) {
Log.e("WonderPush", "Unexpected error while processing user consent changed listeners", e10);
}
}
}
public static void q(Context context) {
try {
e(context, false);
} catch (Exception e10) {
Log.e("WonderPush", "Unexpected error while initializing the SDK", e10);
}
}
public static void r(Context context, String str, String str2) {
Application application;
try {
u("initialize(" + context.getClass().getSimpleName() + ", " + str + ", <redacted clientSecret>)");
if (!f4871n || (str != null && str2 != null && (!str.equals(f4869k) || !str2.equals(l)))) {
f4871n = false;
f4863e = context.getApplicationContext();
f4869k = str;
l = str2;
f4870m = "https://api.wonderpush.com/v1";
f4868j = new ib.j(new ib.b(str), new ib.m(str, context), context);
gb.a.a(f());
z.f4888a = f().getApplicationContext();
hb.b.f6528d = z.o();
try {
s0.g();
} catch (Exception e10) {
Log.e("WonderPush", "Unexpected error while initializing WonderPushUserPreferences", e10);
}
SharedPreferences o4 = z.o();
c(!(o4 == null ? false : o4.contains("__override_set_logging")) ? null : Boolean.valueOf(z.e("__override_set_logging", false)));
Long l10 = m.l;
synchronized (m.class) {
m.f4789p = true;
}
com.wonderpush.sdk.g.f4688g.c = true;
n.c = true;
m.n();
Application application2 = (Application) context.getApplicationContext();
if (c == null) {
c = InAppMessaging.initialize(application2, new com.wonderpush.sdk.k(), new sa.f0());
}
InAppMessagingDisplay.initialize(application2, c, o7.g.B, o7.g.C);
f fVar = new f();
D(new androidx.activity.c(fVar, 23), null);
a1.a.a(context).b(new g(fVar), new IntentFilter("INTENT_REMOTE_CONFIG_UPDATED"));
String r10 = z.r();
u("initForNewUser(" + r10 + ")");
z.b(r10);
D(new j0(r10), "initForNewUser");
f4871n = true;
p(o());
if (!o()) {
b(new h());
}
if (context.getPackageManager().checkPermission("android.permission.INTERNET", context.getPackageName()) != 0) {
Log.w("WonderPush", "Missing INTERNET permission. Add <uses-permission android:name=\"android.permission.INTERNET\" /> under <manifest> in your AndroidManifest.xml");
}
if (v == null) {
if (context.getPackageManager().checkPermission("android.permission.ACCESS_COARSE_LOCATION", context.getPackageName()) != 0 && context.getPackageManager().checkPermission("android.permission.ACCESS_FINE_LOCATION", context.getPackageName()) != 0) {
Log.w("WonderPush", "Permissions ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION have not been declared or granted yet. Make sure you declare <uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" /> under <manifest> in your AndroidManifest.xml (you can add either or both), and call ActivityCompat.requestPermissions() to request the permission at runtime");
} else if (context.getPackageManager().checkPermission("android.permission.ACCESS_FINE_LOCATION", context.getPackageName()) != 0) {
Log.d("WonderPush", "Only ACCESS_COARSE_LOCATION permission is granted. For more precision, you should strongly consider adding <uses-permission android:name=\"android.permission.ACCESS_FINE_LOCATION\" /> under <manifest> in your AndroidManifest.xml");
}
}
}
Context applicationContext = context.getApplicationContext();
if (f4864f == null && (applicationContext instanceof Application)) {
f4864f = (Application) applicationContext;
if (!com.wonderpush.sdk.b.f4628b && (application = f4864f) != null) {
application.registerActivityLifecycleCallbacks(com.wonderpush.sdk.b.f4627a);
com.wonderpush.sdk.b.f4628b = true;
}
}
if (context instanceof Activity) {
Activity activity = (Activity) context;
com.wonderpush.sdk.b.c.put(activity, null);
if (o()) {
E(activity, activity.getIntent());
s();
}
}
A(false);
} catch (Exception e11) {
Log.e("WonderPush", "Unexpected error while initializing the SDK", e11);
}
}
public static void s() {
if (!o()) {
u("onInteraction ignored without user consent");
return;
}
long l10 = z.l("__last_interaction_date", 0L);
JSONObject k10 = z.k("__last_received_notification_info_json");
if (k10 == null) {
k10 = new JSONObject();
}
long optLong = k10.optLong("actionDate", Long.MAX_VALUE);
JSONObject k11 = z.k("__last_opened_notification_info_json");
if (k11 == null) {
k11 = new JSONObject();
}
long optLong2 = k11.optLong("actionDate", Long.MAX_VALUE);
long f10 = sa.a0.f();
long j10 = f10 - l10;
boolean z10 = j10 >= 1800000 || (optLong > l10 && j10 >= 900000);
if (z.l("__last_app_open_sent_date", 0L) == 0 && !f4879w) {
z10 = true;
}
if (z10) {
JSONObject jSONObject = new JSONObject();
if (optLong <= f10) {
try {
jSONObject.put("lastReceivedNotificationTime", f10 - optLong);
} catch (JSONException e10) {
w("Failed to fill @APP_OPEN previous notification information", e10);
}
}
p.f4804b = null;
if (f10 - optLong2 < 10000 && k11.length() > 0) {
String z11 = q5.e.z(k11, "notificationId", null);
String z12 = q5.e.z(k11, "campaignId", null);
String z13 = q5.e.z(k11, "viewId", null);
JSONObject optJSONObject = k11.optJSONObject("reporting");
sa.u uVar = new sa.u(z12, z11, z13, optJSONObject);
try {
uVar.a(jSONObject, "recentNotificationOpened");
} catch (JSONException e11) {
w("Failed to fill @APP_OPEN opened notification information", e11);
}
if (z12 != null || z11 != null || z13 != null || optJSONObject != null) {
p.f4804b = uVar;
}
}
try {
t l11 = l();
t.c c10 = l11.b() ? null : l11.c();
if (c10 != null) {
jSONObject.put("presence", c10.a());
}
} catch (InterruptedException e12) {
y("Could not start presence", e12);
} catch (JSONException e13) {
y("Could not serialize presence", e13);
}
if (!t()) {
d("@VISIT", jSONObject);
try {
jSONObject.put("doNotSynthesizeVisit", true);
} catch (JSONException e14) {
y("Could not add doNotSynthesizeVisit", e14);
}
}
H("@APP_OPEN", jSONObject, null, y2.a.f14195q);
f4879w = true;
z.v("__last_appopen_date", f10);
z.u("__last_appopen_info_json", jSONObject);
}
}
public static boolean t() {
return m() == j.OPT_IN;
}
public static void u(String str) {
if (f4860a) {
Log.d("WonderPush", str);
}
}
public static void v(String str, String str2) {
if (f4860a) {
Log.d(str, str2);
}
}
public static void w(String str, Throwable th) {
if (f4860a) {
Log.d("WonderPush", str, th);
}
}
public static void x(String str) {
if (f4860a) {
Log.e("WonderPush", str);
}
}
public static void y(String str, Throwable th) {
if (f4860a) {
Log.e("WonderPush", str, th);
}
}
public static synchronized void z(JSONObject jSONObject) {
synchronized (x.class) {
u("Synchronizing installation custom fields");
u("Received installation: " + jSONObject);
try {
m.m().i(jSONObject, false);
} catch (JSONException e10) {
Log.e("WonderPush", "Failed to receive custom from server", e10);
}
}
}
}