367 lines
16 KiB
Java
367 lines
16 KiB
Java
package com.google.android.gms.common;
|
|
|
|
import android.app.Activity;
|
|
import android.app.AlertDialog;
|
|
import android.app.Dialog;
|
|
import android.app.Notification;
|
|
import android.app.NotificationChannel;
|
|
import android.app.NotificationManager;
|
|
import android.app.PendingIntent;
|
|
import android.content.Context;
|
|
import android.content.DialogInterface;
|
|
import android.content.Intent;
|
|
import android.content.IntentFilter;
|
|
import android.content.pm.PackageItemInfo;
|
|
import android.content.res.Resources;
|
|
import android.util.Base64;
|
|
import android.util.TypedValue;
|
|
import android.widget.ProgressBar;
|
|
import androidx.fragment.app.Fragment;
|
|
import androidx.fragment.app.FragmentActivity;
|
|
import com.google.android.gms.common.api.GoogleApi;
|
|
import com.google.android.gms.common.api.GoogleApiActivity;
|
|
import com.google.android.gms.common.api.HasApiKey;
|
|
import com.google.android.gms.common.api.internal.ApiKey;
|
|
import com.google.android.gms.common.api.internal.GoogleApiManager;
|
|
import com.google.android.gms.common.api.internal.LifecycleFragment;
|
|
import com.google.android.gms.common.api.internal.zabw;
|
|
import com.google.android.gms.common.api.internal.zabx;
|
|
import com.google.android.gms.common.api.internal.zacc;
|
|
import com.google.android.gms.common.internal.Preconditions;
|
|
import com.google.android.gms.common.internal.zag;
|
|
import com.google.android.gms.common.util.DeviceProperties;
|
|
import com.google.android.gms.common.util.PlatformVersion;
|
|
import com.google.android.gms.common.wrappers.InstantApps;
|
|
import com.google.android.gms.internal.base.zal;
|
|
import com.google.android.gms.tasks.SuccessContinuation;
|
|
import com.google.android.gms.tasks.Task;
|
|
import com.google.android.gms.tasks.Tasks;
|
|
import com.kofax.mobile.sdk._internal.impl.extraction.kta.KtaJsonExactionHelper;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.util.ArrayList;
|
|
import java.util.Arrays;
|
|
import java.util.Map;
|
|
import o.rvM;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class GoogleApiAvailability extends GoogleApiAvailabilityLight {
|
|
public static final String GOOGLE_PLAY_SERVICES_PACKAGE = "com.google.android.gms";
|
|
public static final int GOOGLE_PLAY_SERVICES_VERSION_CODE;
|
|
private static byte e;
|
|
private static final Object zaa;
|
|
private static final GoogleApiAvailability zab;
|
|
private String zac;
|
|
|
|
static {
|
|
b();
|
|
zaa = new Object();
|
|
zab = new GoogleApiAvailability();
|
|
GOOGLE_PLAY_SERVICES_VERSION_CODE = GoogleApiAvailabilityLight.GOOGLE_PLAY_SERVICES_VERSION_CODE;
|
|
}
|
|
|
|
public static final Task<Map<ApiKey<?>, String>> zai(HasApiKey<?> hasApiKey, HasApiKey<?>... hasApiKeyArr) {
|
|
Preconditions.checkNotNull(hasApiKey, "Requested API must not be null.");
|
|
for (HasApiKey<?> hasApiKey2 : hasApiKeyArr) {
|
|
Preconditions.checkNotNull(hasApiKey2, "Requested API must not be null.");
|
|
}
|
|
ArrayList arrayList = new ArrayList(hasApiKeyArr.length + 1);
|
|
arrayList.add(hasApiKey);
|
|
arrayList.addAll(Arrays.asList(hasApiKeyArr));
|
|
return GoogleApiManager.zal().zao(arrayList);
|
|
}
|
|
|
|
public Task<Void> checkApiAvailability(GoogleApi<?> googleApi, GoogleApi<?>... googleApiArr) {
|
|
return zai(googleApi, googleApiArr).onSuccessTask(new SuccessContinuation() { // from class: com.google.android.gms.common.zab
|
|
@Override // com.google.android.gms.tasks.SuccessContinuation
|
|
public final Task then(Object obj) {
|
|
int i = GoogleApiAvailability.GOOGLE_PLAY_SERVICES_VERSION_CODE;
|
|
return Tasks.forResult(null);
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.GoogleApiAvailabilityLight
|
|
public int getClientVersion(Context context) {
|
|
return super.getClientVersion(context);
|
|
}
|
|
|
|
public Dialog getErrorDialog(Activity activity, int i, int i2) {
|
|
return getErrorDialog(activity, i, i2, (DialogInterface.OnCancelListener) null);
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.GoogleApiAvailabilityLight
|
|
public Intent getErrorResolutionIntent(Context context, int i, String str) {
|
|
return super.getErrorResolutionIntent(context, i, str);
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.GoogleApiAvailabilityLight
|
|
public PendingIntent getErrorResolutionPendingIntent(Context context, int i, int i2) {
|
|
return super.getErrorResolutionPendingIntent(context, i, i2);
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.GoogleApiAvailabilityLight
|
|
public final String getErrorString(int i) {
|
|
return super.getErrorString(i);
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.GoogleApiAvailabilityLight
|
|
public int isGooglePlayServicesAvailable(Context context) {
|
|
return super.isGooglePlayServicesAvailable(context);
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.GoogleApiAvailabilityLight
|
|
public final boolean isUserResolvableError(int i) {
|
|
return super.isUserResolvableError(i);
|
|
}
|
|
|
|
public Task<Void> makeGooglePlayServicesAvailable(Activity activity) {
|
|
int i = GOOGLE_PLAY_SERVICES_VERSION_CODE;
|
|
Preconditions.checkMainThread("makeGooglePlayServicesAvailable must be called from the main thread");
|
|
int isGooglePlayServicesAvailable = isGooglePlayServicesAvailable(activity, i);
|
|
if (isGooglePlayServicesAvailable == 0) {
|
|
return Tasks.forResult(null);
|
|
}
|
|
zacc zaa2 = zacc.zaa(activity);
|
|
zaa2.zah(new ConnectionResult(isGooglePlayServicesAvailable, null), 0);
|
|
return zaa2.zad();
|
|
}
|
|
|
|
public void setDefaultNotificationChannelId(Context context, String str) {
|
|
if (PlatformVersion.isAtLeastO()) {
|
|
Preconditions.checkNotNull(((NotificationManager) Preconditions.checkNotNull(context.getSystemService("notification"))).getNotificationChannel(str));
|
|
}
|
|
synchronized (zaa) {
|
|
this.zac = str;
|
|
}
|
|
}
|
|
|
|
public boolean showErrorDialogFragment(Activity activity, int i, int i2) {
|
|
return showErrorDialogFragment(activity, i, i2, null);
|
|
}
|
|
|
|
public void showErrorNotification(Context context, int i) {
|
|
zae(context, i, null, getErrorResolutionPendingIntent(context, i, 0, "n"));
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final Dialog zaa(Context context, int i, zag zagVar, DialogInterface.OnCancelListener onCancelListener) {
|
|
if (i == 0) {
|
|
return null;
|
|
}
|
|
TypedValue typedValue = new TypedValue();
|
|
context.getTheme().resolveAttribute(android.R.attr.alertDialogTheme, typedValue, true);
|
|
AlertDialog.Builder builder = "Theme.Dialog.Alert".equals(context.getResources().getResourceEntryName(typedValue.resourceId)) ? new AlertDialog.Builder(context, 5) : null;
|
|
if (builder == null) {
|
|
builder = new AlertDialog.Builder(context);
|
|
}
|
|
builder.setMessage(com.google.android.gms.common.internal.zac.zad(context, i));
|
|
if (onCancelListener != null) {
|
|
builder.setOnCancelListener(onCancelListener);
|
|
}
|
|
String zac = com.google.android.gms.common.internal.zac.zac(context, i);
|
|
if (zac != null) {
|
|
builder.setPositiveButton(zac, zagVar);
|
|
}
|
|
String zag = com.google.android.gms.common.internal.zac.zag(context, i);
|
|
if (zag != null) {
|
|
builder.setTitle(zag);
|
|
}
|
|
new Object[]{Integer.valueOf(i)};
|
|
new IllegalArgumentException();
|
|
return builder.create();
|
|
}
|
|
|
|
public final Dialog zab(Activity activity, DialogInterface.OnCancelListener onCancelListener) {
|
|
ProgressBar progressBar = new ProgressBar(activity, null, android.R.attr.progressBarStyleLarge);
|
|
progressBar.setIndeterminate(true);
|
|
progressBar.setVisibility(0);
|
|
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
|
builder.setView(progressBar);
|
|
builder.setMessage(com.google.android.gms.common.internal.zac.zad(activity, 18));
|
|
builder.setPositiveButton("", (DialogInterface.OnClickListener) null);
|
|
AlertDialog create = builder.create();
|
|
zad(activity, create, "GooglePlayServicesUpdatingDialog", onCancelListener);
|
|
return create;
|
|
}
|
|
|
|
public final zabx zac(Context context, zabw zabwVar) {
|
|
IntentFilter intentFilter = new IntentFilter("android.intent.action.PACKAGE_ADDED");
|
|
intentFilter.addDataScheme("package");
|
|
zabx zabxVar = new zabx(zabwVar);
|
|
context.registerReceiver(zabxVar, intentFilter);
|
|
zabxVar.zaa(context);
|
|
if (isUninstalledAppPossiblyUpdating(context, "com.google.android.gms")) {
|
|
return zabxVar;
|
|
}
|
|
zabwVar.zaa();
|
|
zabxVar.zab();
|
|
return null;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final void zad(Activity activity, Dialog dialog, String str, DialogInterface.OnCancelListener onCancelListener) {
|
|
if (!(activity instanceof FragmentActivity)) {
|
|
ErrorDialogFragment.newInstance(dialog, onCancelListener).show(activity.getFragmentManager(), str);
|
|
} else {
|
|
SupportErrorDialogFragment.newInstance(dialog, onCancelListener).show(((FragmentActivity) activity).getSupportFragmentManager(), str);
|
|
}
|
|
}
|
|
|
|
final void zae(Context context, int i, String str, PendingIntent pendingIntent) {
|
|
int i2;
|
|
String str2;
|
|
new Object[]{Integer.valueOf(i), null};
|
|
new IllegalArgumentException();
|
|
if (i == 18) {
|
|
zaf(context);
|
|
return;
|
|
}
|
|
if (pendingIntent == null) {
|
|
return;
|
|
}
|
|
String zaf = com.google.android.gms.common.internal.zac.zaf(context, i);
|
|
String zae = com.google.android.gms.common.internal.zac.zae(context, i);
|
|
Resources resources = context.getResources();
|
|
NotificationManager notificationManager = (NotificationManager) Preconditions.checkNotNull(context.getSystemService("notification"));
|
|
rvM.LWm d = new rvM.LWm(context).c(true).e(true).a(zaf).d(new rvM.HBt().e(zae));
|
|
if (DeviceProperties.isWearable(context)) {
|
|
Preconditions.checkState(PlatformVersion.isAtLeastKitKatWatch());
|
|
d.c(PackageItemInfo.class.getField("icon").getInt(context.getApplicationInfo())).a(2);
|
|
if (DeviceProperties.isWearableWithoutPlayStore(context)) {
|
|
int i3 = com.google.android.gms.base.R.drawable.common_full_open_on_phone;
|
|
String string = resources.getString(com.google.android.gms.base.R.string.common_open_on_phone);
|
|
if (string.startsWith(",*,)")) {
|
|
Object[] objArr = new Object[1];
|
|
c(string.substring(4), objArr);
|
|
string = ((String) objArr[0]).intern();
|
|
}
|
|
d.mN_(i3, string, pendingIntent);
|
|
} else {
|
|
d.mQ_(pendingIntent);
|
|
}
|
|
} else {
|
|
rvM.LWm c = d.c(android.R.drawable.stat_sys_warning);
|
|
String string2 = resources.getString(com.google.android.gms.base.R.string.common_google_play_services_notification_ticker);
|
|
if (string2.startsWith(",*,)")) {
|
|
Object[] objArr2 = new Object[1];
|
|
c(string2.substring(4), objArr2);
|
|
string2 = ((String) objArr2[0]).intern();
|
|
}
|
|
c.b(string2).c(System.currentTimeMillis()).mQ_(pendingIntent).d(zae);
|
|
}
|
|
if (PlatformVersion.isAtLeastO()) {
|
|
Preconditions.checkState(PlatformVersion.isAtLeastO());
|
|
synchronized (zaa) {
|
|
str2 = this.zac;
|
|
}
|
|
if (str2 == null) {
|
|
str2 = "com.google.android.gms.availability";
|
|
NotificationChannel notificationChannel = notificationManager.getNotificationChannel("com.google.android.gms.availability");
|
|
String zab2 = com.google.android.gms.common.internal.zac.zab(context);
|
|
if (notificationChannel == null) {
|
|
notificationManager.createNotificationChannel(new NotificationChannel("com.google.android.gms.availability", zab2, 4));
|
|
} else if (!zab2.contentEquals(notificationChannel.getName())) {
|
|
notificationChannel.setName(zab2);
|
|
notificationManager.createNotificationChannel(notificationChannel);
|
|
}
|
|
}
|
|
d.c(str2);
|
|
}
|
|
Notification mO_ = d.mO_();
|
|
if (i == 1 || i == 2 || i == 3) {
|
|
GooglePlayServicesUtilLight.sCanceledAvailabilityNotification.set(false);
|
|
i2 = 10436;
|
|
} else {
|
|
i2 = 39789;
|
|
}
|
|
notificationManager.notify(i2, mO_);
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: package-private */
|
|
public final void zaf(Context context) {
|
|
new zac(this, context).sendEmptyMessageDelayed(1, 120000L);
|
|
}
|
|
|
|
public final boolean zag(Activity activity, LifecycleFragment lifecycleFragment, int i, int i2, DialogInterface.OnCancelListener onCancelListener) {
|
|
Dialog zaa2 = zaa(activity, i, zag.zad(lifecycleFragment, getErrorResolutionIntent(activity, i, KtaJsonExactionHelper.OBJECT), 2), onCancelListener);
|
|
if (zaa2 == null) {
|
|
return false;
|
|
}
|
|
zad(activity, zaa2, GooglePlayServicesUtil.GMS_ERROR_DIALOG, onCancelListener);
|
|
return true;
|
|
}
|
|
|
|
public final boolean zah(Context context, ConnectionResult connectionResult, int i) {
|
|
PendingIntent errorResolutionPendingIntent;
|
|
if (InstantApps.isInstantApp(context) || (errorResolutionPendingIntent = getErrorResolutionPendingIntent(context, connectionResult)) == null) {
|
|
return false;
|
|
}
|
|
zae(context, connectionResult.getErrorCode(), null, zal.zaa(context, 0, GoogleApiActivity.zaa(context, errorResolutionPendingIntent, i, true), zal.zaa | 134217728));
|
|
return true;
|
|
}
|
|
|
|
public Dialog getErrorDialog(Activity activity, int i, int i2, DialogInterface.OnCancelListener onCancelListener) {
|
|
return zaa(activity, i, zag.zab(activity, getErrorResolutionIntent(activity, i, KtaJsonExactionHelper.OBJECT), i2), onCancelListener);
|
|
}
|
|
|
|
public PendingIntent getErrorResolutionPendingIntent(Context context, ConnectionResult connectionResult) {
|
|
if (connectionResult.hasResolution()) {
|
|
return connectionResult.getResolution();
|
|
}
|
|
return getErrorResolutionPendingIntent(context, connectionResult.getErrorCode(), 0);
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.GoogleApiAvailabilityLight
|
|
public int isGooglePlayServicesAvailable(Context context, int i) {
|
|
return super.isGooglePlayServicesAvailable(context, i);
|
|
}
|
|
|
|
public boolean showErrorDialogFragment(Activity activity, int i, int i2, DialogInterface.OnCancelListener onCancelListener) {
|
|
Dialog errorDialog = getErrorDialog(activity, i, i2, onCancelListener);
|
|
if (errorDialog == null) {
|
|
return false;
|
|
}
|
|
zad(activity, errorDialog, GooglePlayServicesUtil.GMS_ERROR_DIALOG, onCancelListener);
|
|
return true;
|
|
}
|
|
|
|
public Task<Void> checkApiAvailability(HasApiKey<?> hasApiKey, HasApiKey<?>... hasApiKeyArr) {
|
|
return zai(hasApiKey, hasApiKeyArr).onSuccessTask(new SuccessContinuation() { // from class: com.google.android.gms.common.zaa
|
|
@Override // com.google.android.gms.tasks.SuccessContinuation
|
|
public final Task then(Object obj) {
|
|
int i = GoogleApiAvailability.GOOGLE_PLAY_SERVICES_VERSION_CODE;
|
|
return Tasks.forResult(null);
|
|
}
|
|
});
|
|
}
|
|
|
|
public void showErrorNotification(Context context, ConnectionResult connectionResult) {
|
|
zae(context, connectionResult.getErrorCode(), null, getErrorResolutionPendingIntent(context, connectionResult));
|
|
}
|
|
|
|
public Dialog getErrorDialog(Fragment fragment, int i, int i2) {
|
|
return getErrorDialog(fragment, i, i2, (DialogInterface.OnCancelListener) null);
|
|
}
|
|
|
|
public Dialog getErrorDialog(Fragment fragment, int i, int i2, DialogInterface.OnCancelListener onCancelListener) {
|
|
return zaa(fragment.requireContext(), i, zag.zac(fragment, getErrorResolutionIntent(fragment.requireContext(), i, KtaJsonExactionHelper.OBJECT), i2), onCancelListener);
|
|
}
|
|
|
|
private void c(String str, Object[] objArr) {
|
|
byte[] decode = Base64.decode(str, 0);
|
|
byte[] bArr = new byte[decode.length];
|
|
for (int i = 0; i < decode.length; i++) {
|
|
bArr[i] = (byte) (decode[(decode.length - i) - 1] ^ e);
|
|
}
|
|
objArr[0] = new String(bArr, StandardCharsets.UTF_8);
|
|
}
|
|
|
|
static void b() {
|
|
e = (byte) 6;
|
|
}
|
|
|
|
public static GoogleApiAvailability getInstance() {
|
|
return zab;
|
|
}
|
|
}
|