正在查看: BetterTogether v3.0.0 应用的 LicenseClient.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: BetterTogether v3.0.0 应用的 LicenseClient.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.pairip.licensecheck;
import ag.wtfi.bDALIB;
import android.app.ActivityManager;
import android.app.PendingIntent;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.os.Bundle;
import android.os.DeadObjectException;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Parcel;
import android.os.RemoteException;
import android.util.Log;
import com.google.firebase.iid.YdH.laTObzJtIQ;
import com.pairip.licensecheck.ILicenseV2ResultListener;
import com.pairip.licensecheck.LicenseActivity;
import ek.bMsI.PYSJ;
public class LicenseClient implements ServiceConnection {
private static final int ERROR_INVALID_PACKAGE_NAME = 3;
private static final int FLAG_RPC_CALL = 0;
private static final int LICENSED = 0;
private static final int MAX_RETRIES = 3;
private static final int MILLIS_PER_SEC = 1000;
private static final int NOT_LICENSED = 2;
private static final String PAYLOAD_PAYWALL = "PAYWALL_INTENT";
private static final int RETRY_DELAY_MILLIS = 1000;
private static final String SERVICE_INTERFACE_CLASS_NAME = "com.android.vending.licensing.ILicensingService";
private static final String SERVICE_PACKAGE = "com.android.vending";
private static final String TAG = "LicenseClient";
private static final int TRANSACTION_CHECK_LICENSE_V2 = 2;
protected static Runnable exitAction = new Runnable() {
@Override
public void run() {
System.exit(0);
}
};
protected static LicenseCheckState licenseCheckState = LicenseCheckState.CHECK_REQUIRED;
protected static String licensePubKey = "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAjSlX0NtloZvLa5Bdx6zYmX4U2V/mJz1joq1nn/X7cULRNi5ZrQ6mUTu7rsFiCcU+hi9lJIsFDFTUH99HsLWRuk0sq87m7VyJurr2YQPOjJAcXamNoheWeuDofEJGij6wSorNVANhDvvKd54obVnEPA9puFIwRqrX/xK2p1/Nwl3phDVpCBS6+G5285XSBlxBm76rz1+DCezDVciuGuqInKrqm4O6A6kuVa99OOJFMQuQWGCqI6WFFe8FaQaMqH7B/IWnGXl5kXBHMGGOyQg4EYtMQA4Je0DBC4U5P4QtGP2Fypo1xvS/K32axcvH9hosiHQbqD7lhTrG17UIId3dswIDAQAB";
protected static String packageName = "com.bettertogether.us";
private static Bundle responsePayload;
private final Context context;
private final DelayedTaskExecutor delayedTaskExecutor = new DelayedTaskExecutor();
private int retryNum = 0;
public enum LicenseCheckState {
CHECK_REQUIRED,
OK
}
public LicenseClient(Context context) {
this.context = context;
}
public static String getLicensePubKey() {
return licensePubKey;
}
public void initializeLicenseCheck() {
int ordinal = licenseCheckState.ordinal();
if (ordinal == 0) {
connectToLicensingService();
} else {
if (ordinal != 1) {
return;
}
try {
ResponseValidator.validateResponse(responsePayload, packageName);
} catch (LicenseCheckException e) {
handleError(e);
}
}
}
public void connectToLicensingService() {
Log.d(TAG, "Connecting to the licensing service...");
try {
if (this.context.bindService(new Intent(SERVICE_INTERFACE_CLASS_NAME).setPackage(SERVICE_PACKAGE).setAction(SERVICE_INTERFACE_CLASS_NAME), this, 1)) {
return;
}
retryOrThrow(new LicenseCheckException(PYSJ.xqDBcNIluA));
} catch (SecurityException e) {
retryOrThrow(new LicenseCheckException("Not allowed to bind with the licensing service.", e));
}
}
@Override
public void onServiceConnected(ComponentName componentName, final IBinder licensingServiceBinder) {
Log.d(TAG, "Connected to the licensing service.");
if (licenseCheckState.equals(LicenseCheckState.OK)) {
return;
}
new Thread(new Runnable() {
@Override
public final void run() {
LicenseClient.this.lambda$onServiceConnected$0(licensingServiceBinder);
}
}).start();
}
public void lambda$onServiceConnected$0(IBinder iBinder) {
try {
checkLicenseInternal(iBinder);
} catch (LicenseCheckException e) {
handleError(e);
}
}
@Override
public void onServiceDisconnected(ComponentName componentName) {
Log.w(TAG, "Unexpectedly disconnected from the licensing service.");
retryOrThrow(new LicenseCheckException(laTObzJtIQ.PeRGDuBiO));
}
public void checkLicenseInternal(IBinder licensingServiceBinder) throws LicenseCheckException {
if (licensingServiceBinder == null) {
retryOrThrow(new LicenseCheckException("Received a null binder."));
return;
}
Log.d(TAG, "Sending request to licensing service...");
Parcel obtain = Parcel.obtain();
Parcel obtain2 = Parcel.obtain();
try {
try {
populateInputData(obtain, licensingServiceBinder);
if (!licensingServiceBinder.transact(2, obtain, obtain2, 0)) {
handleError(new LicenseCheckException("Licensing service could not process request."));
}
} catch (DeadObjectException e) {
retryOrThrow(new LicenseCheckException("Licensing service process died.", e));
} catch (RemoteException e2) {
handleError(new LicenseCheckException(bDALIB.FdMOmvfejfGqdr, e2));
}
} finally {
obtain.recycle();
obtain2.recycle();
Log.d(TAG, "Request to licensing service sent.");
}
}
private void populateInputData(Parcel inputData, IBinder licensingService) throws RemoteException {
inputData.writeInterfaceToken(licensingService.getInterfaceDescriptor());
inputData.writeString(packageName);
inputData.writeStrongBinder(createResultListener(this).asBinder());
inputData.writeInt(0);
}
private static ILicenseV2ResultListener createResultListener(LicenseClient client) {
return new ILicenseV2ResultListener.Stub() {
@Override
public void verifyLicense(int responseCode, Bundle responsePayload2) {
LicenseClient.this.processResponse(responseCode, responsePayload2);
}
};
}
private void retryOrThrow(LicenseCheckException error) {
int i = this.retryNum;
if (i < 3) {
this.retryNum = i + 1;
this.delayedTaskExecutor.schedule(new Runnable() {
@Override
public final void run() {
LicenseClient.this.connectToLicensingService();
}
}, 1000L);
Log.d(TAG, String.format("Retry #%d. License check failed with error '%s'. Next try in %ds...", Integer.valueOf(this.retryNum), error.getMessage(), 1L));
return;
}
handleError(error);
}
public void processResponse(int responseCode, Bundle responsePayload2) {
try {
if (responseCode == 3) {
throw new LicenseCheckException("Request package name invalid.");
}
if (responseCode != 0) {
if (responseCode == 2) {
startPaywallActivity((PendingIntent) responsePayload2.getParcelable(PAYLOAD_PAYWALL));
return;
}
throw new LicenseCheckException(String.format("Unexpected response code %d received.", Integer.valueOf(responseCode)));
}
ResponseValidator.validateResponse(responsePayload2, packageName);
Log.i(TAG, "License check succeeded.");
licenseCheckState = LicenseCheckState.OK;
responsePayload = responsePayload2;
} catch (LicenseCheckException e) {
handleError(e);
}
}
private void handleError(LicenseCheckException ex) {
Log.e(TAG, "Error while checking license: " + Log.getStackTraceString(ex));
if (licenseCheckState.equals(LicenseCheckState.OK)) {
return;
}
startErrorDialogActivity();
}
private void startPaywallActivity(PendingIntent paywallIntent) {
Intent createCloseAppIntentOrExitIfAppInBackground = createCloseAppIntentOrExitIfAppInBackground();
createCloseAppIntentOrExitIfAppInBackground.putExtra(LicenseActivity.PAYWALL_INTENT_ARG_NAME, paywallIntent);
createCloseAppIntentOrExitIfAppInBackground.putExtra(LicenseActivity.ACTIVITY_TYPE_ARG_NAME, LicenseActivity.ActivityType.PAYWALL);
this.context.startActivity(createCloseAppIntentOrExitIfAppInBackground);
}
private void startErrorDialogActivity() {
Intent createCloseAppIntentOrExitIfAppInBackground = createCloseAppIntentOrExitIfAppInBackground();
createCloseAppIntentOrExitIfAppInBackground.putExtra(LicenseActivity.ACTIVITY_TYPE_ARG_NAME, LicenseActivity.ActivityType.ERROR_DIALOG);
this.context.startActivity(createCloseAppIntentOrExitIfAppInBackground);
}
private Intent createCloseAppIntentOrExitIfAppInBackground() {
if (!isForeground()) {
exitAction.run();
}
Intent intent = new Intent(this.context, (Class<?>) LicenseActivity.class);
intent.addFlags(67108864);
intent.addFlags(32768);
intent.addFlags(268435456);
return intent;
}
private boolean isForeground() {
ActivityManager.RunningAppProcessInfo runningAppProcessInfo = new ActivityManager.RunningAppProcessInfo();
ActivityManager.getMyMemoryState(runningAppProcessInfo);
return runningAppProcessInfo.importance <= 100;
}
private static final class DelayedTaskExecutor {
private final Handler handler;
private DelayedTaskExecutor() {
this.handler = new Handler(Looper.getMainLooper());
}
public void schedule(Runnable task, long delayMillis) {
this.handler.postDelayed(task, delayMillis);
}
}
}