246 lines
9.3 KiB
Java
246 lines
9.3 KiB
Java
package com.google.android.gms.common;
|
|
|
|
import android.R;
|
|
import android.annotation.SuppressLint;
|
|
import android.annotation.TargetApi;
|
|
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.res.Resources;
|
|
import android.os.Looper;
|
|
import android.os.Message;
|
|
import android.util.Log;
|
|
import android.util.TypedValue;
|
|
import androidx.core.app.NotificationCompat;
|
|
import androidx.fragment.app.FragmentActivity;
|
|
import com.google.android.gms.base.R$drawable;
|
|
import com.google.android.gms.common.api.GoogleApiActivity;
|
|
import com.google.android.gms.common.internal.ConnectionErrorMessages;
|
|
import com.google.android.gms.common.internal.DialogRedirect;
|
|
import com.google.android.gms.common.internal.Preconditions;
|
|
import com.google.android.gms.common.util.DeviceProperties;
|
|
import com.google.android.gms.common.util.PlatformVersion;
|
|
import com.google.android.gms.internal.base.zal;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class GoogleApiAvailability extends GoogleApiAvailabilityLight {
|
|
private static final Object d = new Object();
|
|
private static final GoogleApiAvailability e = new GoogleApiAvailability();
|
|
private String c;
|
|
|
|
@SuppressLint({"HandlerLeak"})
|
|
private class zaa extends zal {
|
|
private final Context a;
|
|
|
|
public zaa(Context context) {
|
|
super(Looper.myLooper() == null ? Looper.getMainLooper() : Looper.myLooper());
|
|
this.a = context.getApplicationContext();
|
|
}
|
|
|
|
@Override // android.os.Handler
|
|
public final void handleMessage(Message message) {
|
|
int i = message.what;
|
|
if (i != 1) {
|
|
StringBuilder sb = new StringBuilder(50);
|
|
sb.append("Don't know how to handle this message: ");
|
|
sb.append(i);
|
|
Log.w("GoogleApiAvailability", sb.toString());
|
|
return;
|
|
}
|
|
int b = GoogleApiAvailability.this.b(this.a);
|
|
if (GoogleApiAvailability.this.b(b)) {
|
|
GoogleApiAvailability.this.b(this.a, b);
|
|
}
|
|
}
|
|
}
|
|
|
|
GoogleApiAvailability() {
|
|
}
|
|
|
|
public static GoogleApiAvailability a() {
|
|
return e;
|
|
}
|
|
|
|
public boolean b(Activity activity, int i, int i2, DialogInterface.OnCancelListener onCancelListener) {
|
|
Dialog a = a(activity, i, i2, onCancelListener);
|
|
if (a == null) {
|
|
return false;
|
|
}
|
|
a(activity, a, GooglePlayServicesUtil.GMS_ERROR_DIALOG, onCancelListener);
|
|
return true;
|
|
}
|
|
|
|
final void c(Context context) {
|
|
new zaa(context).sendEmptyMessageDelayed(1, 120000L);
|
|
}
|
|
|
|
public Dialog a(Activity activity, int i, int i2, DialogInterface.OnCancelListener onCancelListener) {
|
|
return a(activity, i, DialogRedirect.a(activity, a(activity, i, "d"), i2), onCancelListener);
|
|
}
|
|
|
|
public void b(Context context, int i) {
|
|
a(context, i, (String) null, a(context, i, 0, "n"));
|
|
}
|
|
|
|
private final String b() {
|
|
String str;
|
|
synchronized (d) {
|
|
str = this.c;
|
|
}
|
|
return str;
|
|
}
|
|
|
|
public final boolean a(Context context, ConnectionResult connectionResult, int i) {
|
|
PendingIntent a = a(context, connectionResult);
|
|
if (a == null) {
|
|
return false;
|
|
}
|
|
a(context, connectionResult.getErrorCode(), (String) null, GoogleApiActivity.a(context, a, i));
|
|
return true;
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.GoogleApiAvailabilityLight
|
|
public int b(Context context) {
|
|
return super.b(context);
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.GoogleApiAvailabilityLight
|
|
public int a(Context context, int i) {
|
|
return super.a(context, i);
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.GoogleApiAvailabilityLight
|
|
public final boolean b(int i) {
|
|
return super.b(i);
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.GoogleApiAvailabilityLight
|
|
public Intent a(Context context, int i, String str) {
|
|
return super.a(context, i, str);
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.GoogleApiAvailabilityLight
|
|
public PendingIntent a(Context context, int i, int i2) {
|
|
return super.a(context, i, i2);
|
|
}
|
|
|
|
public PendingIntent a(Context context, ConnectionResult connectionResult) {
|
|
if (connectionResult.hasResolution()) {
|
|
return connectionResult.getResolution();
|
|
}
|
|
return a(context, connectionResult.getErrorCode(), 0);
|
|
}
|
|
|
|
@Override // com.google.android.gms.common.GoogleApiAvailabilityLight
|
|
public final String a(int i) {
|
|
return super.a(i);
|
|
}
|
|
|
|
static Dialog a(Context context, int i, DialogRedirect dialogRedirect, DialogInterface.OnCancelListener onCancelListener) {
|
|
if (i == 0) {
|
|
return null;
|
|
}
|
|
TypedValue typedValue = new TypedValue();
|
|
context.getTheme().resolveAttribute(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(ConnectionErrorMessages.b(context, i));
|
|
if (onCancelListener != null) {
|
|
builder.setOnCancelListener(onCancelListener);
|
|
}
|
|
String a = ConnectionErrorMessages.a(context, i);
|
|
if (a != null) {
|
|
builder.setPositiveButton(a, dialogRedirect);
|
|
}
|
|
String e2 = ConnectionErrorMessages.e(context, i);
|
|
if (e2 != null) {
|
|
builder.setTitle(e2);
|
|
}
|
|
return builder.create();
|
|
}
|
|
|
|
static void a(Activity activity, Dialog dialog, String str, DialogInterface.OnCancelListener onCancelListener) {
|
|
if (activity instanceof FragmentActivity) {
|
|
SupportErrorDialogFragment.a(dialog, onCancelListener).a(((FragmentActivity) activity).getSupportFragmentManager(), str);
|
|
} else {
|
|
ErrorDialogFragment.a(dialog, onCancelListener).show(activity.getFragmentManager(), str);
|
|
}
|
|
}
|
|
|
|
@TargetApi(20)
|
|
private final void a(Context context, int i, String str, PendingIntent pendingIntent) {
|
|
int i2;
|
|
if (i == 18) {
|
|
c(context);
|
|
return;
|
|
}
|
|
if (pendingIntent == null) {
|
|
if (i == 6) {
|
|
Log.w("GoogleApiAvailability", "Missing resolution for ConnectionResult.RESOLUTION_REQUIRED. Call GoogleApiAvailability#showErrorNotification(Context, ConnectionResult) instead.");
|
|
return;
|
|
}
|
|
return;
|
|
}
|
|
String d2 = ConnectionErrorMessages.d(context, i);
|
|
String c = ConnectionErrorMessages.c(context, i);
|
|
Resources resources = context.getResources();
|
|
NotificationManager notificationManager = (NotificationManager) context.getSystemService("notification");
|
|
NotificationCompat.Builder builder = new NotificationCompat.Builder(context);
|
|
builder.b(true);
|
|
builder.a(true);
|
|
builder.b(d2);
|
|
NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle();
|
|
bigTextStyle.a(c);
|
|
builder.a(bigTextStyle);
|
|
if (DeviceProperties.b(context)) {
|
|
Preconditions.b(PlatformVersion.f());
|
|
builder.b(context.getApplicationInfo().icon);
|
|
builder.a(2);
|
|
if (DeviceProperties.c(context)) {
|
|
builder.a(R$drawable.common_full_open_on_phone, resources.getString(com.google.android.gms.base.R$string.common_open_on_phone), pendingIntent);
|
|
} else {
|
|
builder.a(pendingIntent);
|
|
}
|
|
} else {
|
|
builder.b(R.drawable.stat_sys_warning);
|
|
builder.c(resources.getString(com.google.android.gms.base.R$string.common_google_play_services_notification_ticker));
|
|
builder.a(System.currentTimeMillis());
|
|
builder.a(pendingIntent);
|
|
builder.a((CharSequence) c);
|
|
}
|
|
if (PlatformVersion.i()) {
|
|
Preconditions.b(PlatformVersion.i());
|
|
String b = b();
|
|
if (b == null) {
|
|
b = "com.google.android.gms.availability";
|
|
NotificationChannel notificationChannel = notificationManager.getNotificationChannel("com.google.android.gms.availability");
|
|
String b2 = ConnectionErrorMessages.b(context);
|
|
if (notificationChannel == null) {
|
|
notificationManager.createNotificationChannel(new NotificationChannel("com.google.android.gms.availability", b2, 4));
|
|
} else if (!b2.equals(notificationChannel.getName())) {
|
|
notificationChannel.setName(b2);
|
|
notificationManager.createNotificationChannel(notificationChannel);
|
|
}
|
|
}
|
|
builder.a(b);
|
|
}
|
|
Notification a = builder.a();
|
|
if (i == 1 || i == 2 || i == 3) {
|
|
i2 = 10436;
|
|
GooglePlayServicesUtilLight.sCanceledAvailabilityNotification.set(false);
|
|
} else {
|
|
i2 = 39789;
|
|
}
|
|
notificationManager.notify(i2, a);
|
|
}
|
|
}
|