Initial commit

This commit is contained in:
2025-05-13 19:24:51 +02:00
commit a950f49678
10604 changed files with 932663 additions and 0 deletions

View File

@@ -0,0 +1,324 @@
package com.google.android.gms.ads.identifier;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.RemoteException;
import android.os.SystemClock;
import android.util.Log;
import com.baidu.cloud.media.player.BDCloudMediaPlayer;
import com.google.android.gms.common.BlockingServiceConnection;
import com.google.android.gms.common.GoogleApiAvailabilityLight;
import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import com.google.android.gms.common.GooglePlayServicesUtilLight;
import com.google.android.gms.common.internal.Preconditions;
import com.google.android.gms.common.stats.ConnectionTracker;
import com.google.android.gms.internal.ads_identifier.zze;
import com.google.android.gms.internal.ads_identifier.zzf;
import java.io.IOException;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
/* loaded from: classes.dex */
public class AdvertisingIdClient {
private final Context mContext;
private BlockingServiceConnection zze;
private zze zzf;
private boolean zzg;
private final Object zzh;
private zza zzi;
private final boolean zzj;
private final long zzk;
public static final class Info {
private final String zzq;
private final boolean zzr;
public Info(String str, boolean z) {
this.zzq = str;
this.zzr = z;
}
public final String getId() {
return this.zzq;
}
public final boolean isLimitAdTrackingEnabled() {
return this.zzr;
}
public final String toString() {
String str = this.zzq;
boolean z = this.zzr;
StringBuilder sb = new StringBuilder(String.valueOf(str).length() + 7);
sb.append("{");
sb.append(str);
sb.append("}");
sb.append(z);
return sb.toString();
}
}
static class zza extends Thread {
private WeakReference<AdvertisingIdClient> a;
private long b;
CountDownLatch c = new CountDownLatch(1);
boolean d = false;
public zza(AdvertisingIdClient advertisingIdClient, long j) {
this.a = new WeakReference<>(advertisingIdClient);
this.b = j;
start();
}
private final void a() {
AdvertisingIdClient advertisingIdClient = this.a.get();
if (advertisingIdClient != null) {
advertisingIdClient.finish();
this.d = true;
}
}
@Override // java.lang.Thread, java.lang.Runnable
public final void run() {
try {
if (this.c.await(this.b, TimeUnit.MILLISECONDS)) {
return;
}
a();
} catch (InterruptedException unused) {
a();
}
}
}
public AdvertisingIdClient(Context context) {
this(context, 30000L, false, false);
}
private AdvertisingIdClient(Context context, long j, boolean z, boolean z2) {
Context applicationContext;
this.zzh = new Object();
Preconditions.a(context);
if (z && (applicationContext = context.getApplicationContext()) != null) {
context = applicationContext;
}
this.mContext = context;
this.zzg = false;
this.zzk = j;
this.zzj = z2;
}
public static Info getAdvertisingIdInfo(Context context) throws IOException, IllegalStateException, GooglePlayServicesNotAvailableException, GooglePlayServicesRepairableException {
zzb zzbVar = new zzb(context);
boolean a = zzbVar.a("gads:ad_id_app_context:enabled", false);
float a2 = zzbVar.a("gads:ad_id_app_context:ping_ratio", 0.0f);
String a3 = zzbVar.a("gads:ad_id_use_shared_preference:experiment_id", "");
AdvertisingIdClient advertisingIdClient = new AdvertisingIdClient(context, -1L, a, zzbVar.a("gads:ad_id_use_persistent_service:enabled", false));
try {
long elapsedRealtime = SystemClock.elapsedRealtime();
advertisingIdClient.zza(false);
Info info = advertisingIdClient.getInfo();
advertisingIdClient.zza(info, a, a2, SystemClock.elapsedRealtime() - elapsedRealtime, a3, null);
return info;
} finally {
}
}
public static boolean getIsAdIdFakeForDebugLogging(Context context) throws IOException, GooglePlayServicesNotAvailableException, GooglePlayServicesRepairableException {
zzb zzbVar = new zzb(context);
AdvertisingIdClient advertisingIdClient = new AdvertisingIdClient(context, -1L, zzbVar.a("gads:ad_id_app_context:enabled", false), zzbVar.a("com.google.android.gms.ads.identifier.service.PERSISTENT_START", false));
try {
advertisingIdClient.zza(false);
return advertisingIdClient.zzb();
} finally {
advertisingIdClient.finish();
}
}
public static void setShouldSkipGmsCoreVersionCheck(boolean z) {
}
private static BlockingServiceConnection zza(Context context, boolean z) throws IOException, GooglePlayServicesNotAvailableException, GooglePlayServicesRepairableException {
try {
context.getPackageManager().getPackageInfo("com.android.vending", 0);
int a = GoogleApiAvailabilityLight.a().a(context, GooglePlayServicesUtilLight.GOOGLE_PLAY_SERVICES_VERSION_CODE);
if (a != 0 && a != 2) {
throw new IOException("Google Play services not available");
}
String str = z ? "com.google.android.gms.ads.identifier.service.PERSISTENT_START" : "com.google.android.gms.ads.identifier.service.START";
BlockingServiceConnection blockingServiceConnection = new BlockingServiceConnection();
Intent intent = new Intent(str);
intent.setPackage("com.google.android.gms");
try {
if (ConnectionTracker.a().a(context, intent, blockingServiceConnection, 1)) {
return blockingServiceConnection;
}
throw new IOException("Connection failure");
} catch (Throwable th) {
throw new IOException(th);
}
} catch (PackageManager.NameNotFoundException unused) {
throw new GooglePlayServicesNotAvailableException(9);
}
}
private static zze zza(Context context, BlockingServiceConnection blockingServiceConnection) throws IOException {
try {
return zzf.a(blockingServiceConnection.a(10000L, TimeUnit.MILLISECONDS));
} catch (InterruptedException unused) {
throw new IOException("Interrupted exception");
} catch (Throwable th) {
throw new IOException(th);
}
}
private final void zza() {
synchronized (this.zzh) {
if (this.zzi != null) {
this.zzi.c.countDown();
try {
this.zzi.join();
} catch (InterruptedException unused) {
}
}
if (this.zzk > 0) {
this.zzi = new zza(this, this.zzk);
}
}
}
private final void zza(boolean z) throws IOException, IllegalStateException, GooglePlayServicesNotAvailableException, GooglePlayServicesRepairableException {
Preconditions.c("Calling this from your main thread can lead to deadlock");
synchronized (this) {
if (this.zzg) {
finish();
}
this.zze = zza(this.mContext, this.zzj);
this.zzf = zza(this.mContext, this.zze);
this.zzg = true;
if (z) {
zza();
}
}
}
private final boolean zza(Info info, boolean z, float f, long j, String str, Throwable th) {
if (Math.random() > f) {
return false;
}
HashMap hashMap = new HashMap();
hashMap.put("app_context", z ? "1" : "0");
if (info != null) {
hashMap.put("limit_ad_tracking", info.isLimitAdTrackingEnabled() ? "1" : "0");
}
if (info != null && info.getId() != null) {
hashMap.put("ad_id_size", Integer.toString(info.getId().length()));
}
if (th != null) {
hashMap.put(BDCloudMediaPlayer.OnNativeInvokeListener.ARG_ERROR, th.getClass().getName());
}
if (str != null && !str.isEmpty()) {
hashMap.put("experiment_id", str);
}
hashMap.put("tag", "AdvertisingIdClient");
hashMap.put("time_spent", Long.toString(j));
new com.google.android.gms.ads.identifier.zza(this, hashMap).start();
return true;
}
private final boolean zzb() throws IOException {
boolean zzc;
Preconditions.c("Calling this from your main thread can lead to deadlock");
synchronized (this) {
if (!this.zzg) {
synchronized (this.zzh) {
if (this.zzi == null || !this.zzi.d) {
throw new IOException("AdvertisingIdClient is not connected.");
}
}
try {
zza(false);
if (!this.zzg) {
throw new IOException("AdvertisingIdClient cannot reconnect.");
}
} catch (Exception e) {
throw new IOException("AdvertisingIdClient cannot reconnect.", e);
}
}
Preconditions.a(this.zze);
Preconditions.a(this.zzf);
try {
zzc = this.zzf.zzc();
} catch (RemoteException e2) {
Log.i("AdvertisingIdClient", "GMS remote exception ", e2);
throw new IOException("Remote exception");
}
}
zza();
return zzc;
}
protected void finalize() throws Throwable {
finish();
super.finalize();
}
public final void finish() {
Preconditions.c("Calling this from your main thread can lead to deadlock");
synchronized (this) {
if (this.mContext == null || this.zze == null) {
return;
}
try {
if (this.zzg) {
ConnectionTracker.a().a(this.mContext, this.zze);
}
} catch (Throwable th) {
Log.i("AdvertisingIdClient", "AdvertisingIdClient unbindService failed.", th);
}
this.zzg = false;
this.zzf = null;
this.zze = null;
}
}
public Info getInfo() throws IOException {
Info info;
Preconditions.c("Calling this from your main thread can lead to deadlock");
synchronized (this) {
if (!this.zzg) {
synchronized (this.zzh) {
if (this.zzi == null || !this.zzi.d) {
throw new IOException("AdvertisingIdClient is not connected.");
}
}
try {
zza(false);
if (!this.zzg) {
throw new IOException("AdvertisingIdClient cannot reconnect.");
}
} catch (Exception e) {
throw new IOException("AdvertisingIdClient cannot reconnect.", e);
}
}
Preconditions.a(this.zze);
Preconditions.a(this.zzf);
try {
info = new Info(this.zzf.getId(), this.zzf.d(true));
} catch (RemoteException e2) {
Log.i("AdvertisingIdClient", "GMS remote exception ", e2);
throw new IOException("Remote exception");
}
}
zza();
return info;
}
public void start() throws IOException, IllegalStateException, GooglePlayServicesNotAvailableException, GooglePlayServicesRepairableException {
zza(true);
}
}

View File

@@ -0,0 +1,80 @@
package com.google.android.gms.ads.identifier;
import android.net.Uri;
import android.util.Log;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Map;
/* loaded from: classes.dex */
final class zza extends Thread {
private final /* synthetic */ Map a;
zza(AdvertisingIdClient advertisingIdClient, Map map) {
this.a = map;
}
@Override // java.lang.Thread, java.lang.Runnable
public final void run() {
String message;
StringBuilder sb;
String str;
Exception exc;
new zzc();
Map map = this.a;
Uri.Builder buildUpon = Uri.parse("https://pagead2.googlesyndication.com/pagead/gen_204?id=gmob-apps").buildUpon();
for (String str2 : map.keySet()) {
buildUpon.appendQueryParameter(str2, (String) map.get(str2));
}
String uri = buildUpon.build().toString();
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(uri).openConnection();
try {
int responseCode = httpURLConnection.getResponseCode();
if (responseCode < 200 || responseCode >= 300) {
StringBuilder sb2 = new StringBuilder(String.valueOf(uri).length() + 65);
sb2.append("Received non-success response code ");
sb2.append(responseCode);
sb2.append(" from pinging URL: ");
sb2.append(uri);
Log.w("HttpUrlPinger", sb2.toString());
}
} finally {
httpURLConnection.disconnect();
}
} catch (IOException e) {
e = e;
message = e.getMessage();
sb = new StringBuilder(String.valueOf(uri).length() + 27 + String.valueOf(message).length());
str = "Error while pinging URL: ";
exc = e;
sb.append(str);
sb.append(uri);
sb.append(". ");
sb.append(message);
Log.w("HttpUrlPinger", sb.toString(), exc);
} catch (IndexOutOfBoundsException e2) {
message = e2.getMessage();
sb = new StringBuilder(String.valueOf(uri).length() + 32 + String.valueOf(message).length());
str = "Error while parsing ping URL: ";
exc = e2;
sb.append(str);
sb.append(uri);
sb.append(". ");
sb.append(message);
Log.w("HttpUrlPinger", sb.toString(), exc);
} catch (RuntimeException e3) {
e = e3;
message = e.getMessage();
sb = new StringBuilder(String.valueOf(uri).length() + 27 + String.valueOf(message).length());
str = "Error while pinging URL: ";
exc = e;
sb.append(str);
sb.append(uri);
sb.append(". ");
sb.append(message);
Log.w("HttpUrlPinger", sb.toString(), exc);
}
}
}

View File

@@ -0,0 +1,54 @@
package com.google.android.gms.ads.identifier;
import android.content.Context;
import android.content.SharedPreferences;
import android.util.Log;
import com.google.android.gms.common.GooglePlayServicesUtilLight;
/* loaded from: classes.dex */
public final class zzb {
private SharedPreferences a;
public zzb(Context context) {
try {
Context remoteContext = GooglePlayServicesUtilLight.getRemoteContext(context);
this.a = remoteContext == null ? null : remoteContext.getSharedPreferences("google_ads_flags", 0);
} catch (Throwable th) {
Log.w("GmscoreFlag", "Error while getting SharedPreferences ", th);
this.a = null;
}
}
final float a(String str, float f) {
try {
if (this.a == null) {
return 0.0f;
}
return this.a.getFloat(str, 0.0f);
} catch (Throwable th) {
Log.w("GmscoreFlag", "Error while reading from SharedPreferences ", th);
return 0.0f;
}
}
final String a(String str, String str2) {
try {
return this.a == null ? str2 : this.a.getString(str, str2);
} catch (Throwable th) {
Log.w("GmscoreFlag", "Error while reading from SharedPreferences ", th);
return str2;
}
}
public final boolean a(String str, boolean z) {
try {
if (this.a == null) {
return false;
}
return this.a.getBoolean(str, false);
} catch (Throwable th) {
Log.w("GmscoreFlag", "Error while reading from SharedPreferences ", th);
return false;
}
}
}

View File

@@ -0,0 +1,5 @@
package com.google.android.gms.ads.identifier;
/* loaded from: classes.dex */
public final class zzc {
}