- Added realracing3-community.apk (71.57 MB) - Removed 32-bit support (armeabi-v7a) - Only includes arm64-v8a libraries - Decompiled source code included - Added README-community.md with analysis
142 lines
7.0 KiB
Java
142 lines
7.0 KiB
Java
package com.android.installreferrer.api;
|
|
|
|
import android.content.ComponentName;
|
|
import android.content.Context;
|
|
import android.content.Intent;
|
|
import android.content.ServiceConnection;
|
|
import android.content.pm.PackageManager;
|
|
import android.content.pm.ResolveInfo;
|
|
import android.content.pm.ServiceInfo;
|
|
import android.os.Bundle;
|
|
import android.os.IBinder;
|
|
import android.os.RemoteException;
|
|
import com.android.installreferrer.commons.InstallReferrerCommons;
|
|
import com.google.android.finsky.externalreferrer.IGetInstallReferrerService;
|
|
import java.util.List;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class InstallReferrerClientImpl extends InstallReferrerClient {
|
|
public final Context mApplicationContext;
|
|
public int mClientState = 0;
|
|
public IGetInstallReferrerService mService;
|
|
public ServiceConnection mServiceConnection;
|
|
|
|
@Override // com.android.installreferrer.api.InstallReferrerClient
|
|
public boolean isReady() {
|
|
return (this.mClientState != 2 || this.mService == null || this.mServiceConnection == null) ? false : true;
|
|
}
|
|
|
|
public InstallReferrerClientImpl(Context context) {
|
|
this.mApplicationContext = context.getApplicationContext();
|
|
}
|
|
|
|
@Override // com.android.installreferrer.api.InstallReferrerClient
|
|
public void startConnection(InstallReferrerStateListener installReferrerStateListener) {
|
|
ServiceInfo serviceInfo;
|
|
if (isReady()) {
|
|
InstallReferrerCommons.logVerbose("InstallReferrerClient", "Service connection is valid. No need to re-initialize.");
|
|
installReferrerStateListener.onInstallReferrerSetupFinished(0);
|
|
return;
|
|
}
|
|
int i = this.mClientState;
|
|
if (i == 1) {
|
|
InstallReferrerCommons.logWarn("InstallReferrerClient", "Client is already in the process of connecting to the service.");
|
|
installReferrerStateListener.onInstallReferrerSetupFinished(3);
|
|
return;
|
|
}
|
|
if (i == 3) {
|
|
InstallReferrerCommons.logWarn("InstallReferrerClient", "Client was already closed and can't be reused. Please create another instance.");
|
|
installReferrerStateListener.onInstallReferrerSetupFinished(3);
|
|
return;
|
|
}
|
|
InstallReferrerCommons.logVerbose("InstallReferrerClient", "Starting install referrer service setup.");
|
|
this.mServiceConnection = new InstallReferrerServiceConnection(installReferrerStateListener);
|
|
Intent intent = new Intent("com.google.android.finsky.BIND_GET_INSTALL_REFERRER_SERVICE");
|
|
intent.setComponent(new ComponentName("com.android.vending", "com.google.android.finsky.externalreferrer.GetInstallReferrerService"));
|
|
List<ResolveInfo> queryIntentServices = this.mApplicationContext.getPackageManager().queryIntentServices(intent, 0);
|
|
if (queryIntentServices != null && !queryIntentServices.isEmpty() && (serviceInfo = queryIntentServices.get(0).serviceInfo) != null) {
|
|
String str = serviceInfo.packageName;
|
|
String str2 = serviceInfo.name;
|
|
if ("com.android.vending".equals(str) && str2 != null && isPlayStoreCompatible()) {
|
|
if (this.mApplicationContext.bindService(new Intent(intent), this.mServiceConnection, 1)) {
|
|
InstallReferrerCommons.logVerbose("InstallReferrerClient", "Service was bonded successfully.");
|
|
return;
|
|
}
|
|
InstallReferrerCommons.logWarn("InstallReferrerClient", "Connection to service is blocked.");
|
|
this.mClientState = 0;
|
|
installReferrerStateListener.onInstallReferrerSetupFinished(1);
|
|
return;
|
|
}
|
|
InstallReferrerCommons.logWarn("InstallReferrerClient", "Play Store missing or incompatible. Version 8.3.73 or later required.");
|
|
this.mClientState = 0;
|
|
installReferrerStateListener.onInstallReferrerSetupFinished(2);
|
|
return;
|
|
}
|
|
this.mClientState = 0;
|
|
InstallReferrerCommons.logVerbose("InstallReferrerClient", "Install Referrer service unavailable on device.");
|
|
installReferrerStateListener.onInstallReferrerSetupFinished(2);
|
|
}
|
|
|
|
@Override // com.android.installreferrer.api.InstallReferrerClient
|
|
public void endConnection() {
|
|
this.mClientState = 3;
|
|
if (this.mServiceConnection != null) {
|
|
InstallReferrerCommons.logVerbose("InstallReferrerClient", "Unbinding from service.");
|
|
this.mApplicationContext.unbindService(this.mServiceConnection);
|
|
this.mServiceConnection = null;
|
|
}
|
|
this.mService = null;
|
|
}
|
|
|
|
@Override // com.android.installreferrer.api.InstallReferrerClient
|
|
public ReferrerDetails getInstallReferrer() {
|
|
if (!isReady()) {
|
|
throw new IllegalStateException("Service not connected. Please start a connection before using the service.");
|
|
}
|
|
Bundle bundle = new Bundle();
|
|
bundle.putString("package_name", this.mApplicationContext.getPackageName());
|
|
try {
|
|
return new ReferrerDetails(this.mService.getInstallReferrer(bundle));
|
|
} catch (RemoteException e) {
|
|
InstallReferrerCommons.logWarn("InstallReferrerClient", "RemoteException getting install referrer information");
|
|
this.mClientState = 0;
|
|
throw e;
|
|
}
|
|
}
|
|
|
|
public final boolean isPlayStoreCompatible() {
|
|
try {
|
|
return this.mApplicationContext.getPackageManager().getPackageInfo("com.android.vending", 128).versionCode >= 80837300;
|
|
} catch (PackageManager.NameNotFoundException unused) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public final class InstallReferrerServiceConnection implements ServiceConnection {
|
|
public final InstallReferrerStateListener mListener;
|
|
|
|
public InstallReferrerServiceConnection(InstallReferrerStateListener installReferrerStateListener) {
|
|
if (installReferrerStateListener == null) {
|
|
throw new RuntimeException("Please specify a listener to know when setup is done.");
|
|
}
|
|
this.mListener = installReferrerStateListener;
|
|
}
|
|
|
|
@Override // android.content.ServiceConnection
|
|
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
|
|
InstallReferrerCommons.logVerbose("InstallReferrerClient", "Install Referrer service connected.");
|
|
InstallReferrerClientImpl.this.mService = IGetInstallReferrerService.Stub.asInterface(iBinder);
|
|
InstallReferrerClientImpl.this.mClientState = 2;
|
|
this.mListener.onInstallReferrerSetupFinished(0);
|
|
}
|
|
|
|
@Override // android.content.ServiceConnection
|
|
public void onServiceDisconnected(ComponentName componentName) {
|
|
InstallReferrerCommons.logWarn("InstallReferrerClient", "Install Referrer service disconnected.");
|
|
InstallReferrerClientImpl.this.mService = null;
|
|
InstallReferrerClientImpl.this.mClientState = 0;
|
|
this.mListener.onInstallReferrerServiceDisconnected();
|
|
}
|
|
}
|
|
}
|