正在查看: Loan Locker v1.5 应用的 UserAppRemoveService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Loan Locker v1.5 应用的 UserAppRemoveService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.user.a4keygen.services;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.Service;
import android.app.admin.DevicePolicyManager;
import android.content.ComponentName;
import android.content.Intent;
import android.os.Build;
import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.util.Log;
import androidx.core.app.NotificationCompat;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.messaging.Constants;
import com.google.firebase.messaging.FirebaseMessaging;
import com.google.gson.JsonObject;
import com.user.a4keygen.DeviceAdminReceiver;
import com.user.a4keygen.DevicePolicyManagerGateway;
import com.user.a4keygen.DevicePolicyManagerGatewayImpl;
import com.user.a4keygen.constants.ServiceKeyValueConstant;
import com.user.a4keygen.constants.WebServiceUrlConstant;
import com.user.a4keygen.model.CommonResponseModel;
import com.user.a4keygen.network.ApiClient;
import com.user.a4keygen.network.ApiInterface;
import com.user.a4keygen.services.UserAppRemoveService;
import com.user.a4keygen.sharedprefrence.SharedPrefManager;
import com.user.a4keygen.util.Config;
import com.user.a4keygen.util.IconUtils;
import com.user.a4keygen.webutil.WebClientService;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class UserAppRemoveService extends Service {
private static final String CHANNEL_ID = "ForegroundTokenServiceChannel";
private static final int NOTIFICATION_ID = 1069;
private static final String TAG = "RemovalService";
private ComponentName adminComponent;
private FirebaseMessanging fireBaseMessanging;
private DevicePolicyManager mDevicePolicyManager;
private DevicePolicyManagerGateway mDevicePolicyManagerGateway;
@Override
public IBinder onBind(Intent intent) {
return null;
}
@Override
public void onCreate() {
super.onCreate();
Log.d(TAG, "Service created");
this.adminComponent = new ComponentName(this, (Class<?>) DeviceAdminReceiver.class);
this.mDevicePolicyManager = (DevicePolicyManager) getSystemService("device_policy");
this.mDevicePolicyManagerGateway = new DevicePolicyManagerGatewayImpl(this);
this.fireBaseMessanging = new FirebaseMessanging();
if (WebClientService.isActiveAdmin(this)) {
return;
}
Log.d(TAG, "Device Admin is not active!");
stopSelf();
}
@Override
public int onStartCommand(Intent intent, int i, int i2) {
createNotificationChannel();
startForeground(NOTIFICATION_ID, new NotificationCompat.Builder(this, CHANNEL_ID).setContentTitle(WebClientService.getWebServiceUrl().equals(WebServiceUrlConstant.GMM_WEB_SERVICE_URL) ? ServiceKeyValueConstant.REMOVE_USER_SERVICE : "Remove User").setSmallIcon(IconUtils.getAppIcon()).setPriority(1).build());
generateFcmToken();
return 2;
}
private void generateFcmToken() {
Log.d("FCM Token", SharedPrefManager.getInstance(getApplicationContext()).getDeviceToken());
FirebaseMessaging.getInstance().getToken().addOnCompleteListener(new OnCompleteListener<String>() {
public void onComplete(Task<String> task) {
if (!task.isSuccessful()) {
Log.w("TAG", "Fetching FCM registration token failed", task.getException());
UserAppRemoveService userAppRemoveService = UserAppRemoveService.this;
userAppRemoveService.removeApp(SharedPrefManager.getInstance(userAppRemoveService.getApplicationContext()).getUserId(), SharedPrefManager.getInstance(UserAppRemoveService.this.getApplicationContext()).getDeviceToken());
} else {
String str = (String) task.getResult();
Log.d("FCM Token", "Newly generated token: " + str);
SharedPrefManager.getInstance(UserAppRemoveService.this.getApplicationContext()).saveDeviceToken(str);
UserAppRemoveService.this.storeToken(str);
}
}
});
}
public void storeToken(String str) {
if (WebClientService.isNull(SharedPrefManager.getInstance(getApplicationContext()).getUserId())) {
return;
}
onSaveTokenOnRemote(str);
}
private void onSaveTokenOnRemote(String str) {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("id", SharedPrefManager.getInstance(getApplicationContext()).getUserId());
jsonObject.addProperty("token", str);
((ApiInterface) ApiClient.getInstance(this).getClient().create(ApiInterface.class)).tokenUpdate(jsonObject).enqueue(new AnonymousClass2(str));
}
class AnonymousClass2 implements Callback<CommonResponseModel> {
final String val$token;
AnonymousClass2(String str) {
this.val$token = str;
}
public void onResponse(Call<CommonResponseModel> call, Response<CommonResponseModel> response) {
if (response.isSuccessful()) {
if (!WebClientService.isNull(SharedPrefManager.getInstance(UserAppRemoveService.this.getApplicationContext()).getUserId()) && !WebClientService.isNull(this.val$token)) {
UserAppRemoveService userAppRemoveService = UserAppRemoveService.this;
userAppRemoveService.removeApp(SharedPrefManager.getInstance(userAppRemoveService.getApplicationContext()).getUserId(), SharedPrefManager.getInstance(UserAppRemoveService.this.getApplicationContext()).getDeviceToken());
} else {
UserAppRemoveService.this.startForegroundService(new Intent(UserAppRemoveService.this.getApplicationContext(), (Class<?>) ForegroundTokenService.class));
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public final void run() {
UserAppRemoveService.AnonymousClass2.this.m312x4a12bdaa();
}
}, 5000L);
}
}
}
public void m312x4a12bdaa() {
UserAppRemoveService userAppRemoveService = UserAppRemoveService.this;
userAppRemoveService.removeApp(SharedPrefManager.getInstance(userAppRemoveService.getApplicationContext()).getUserId(), SharedPrefManager.getInstance(UserAppRemoveService.this.getApplicationContext()).getDeviceToken());
}
public void onFailure(Call<CommonResponseModel> call, Throwable th) {
Log.d(UserAppRemoveService.TAG, "Token update failed");
}
}
public void removeApp(String str, String str2) {
ApiInterface apiInterface = (ApiInterface) ApiClient.getInstance(this).getClient().create(ApiInterface.class);
try {
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("body", "UniApp");
JsonObject jsonObject2 = new JsonObject();
jsonObject2.addProperty("to", str2);
jsonObject2.add(Constants.ScionAnalytics.MessageType.DATA_MESSAGE, jsonObject);
apiInterface.removeApp(str, jsonObject2).enqueue(new Callback<CommonResponseModel>() {
public void onResponse(Call<CommonResponseModel> call, Response<CommonResponseModel> response) {
if (response.isSuccessful() && response.body() != null) {
String status = ((CommonResponseModel) response.body()).getStatus();
Log.d(UserAppRemoveService.TAG, "onResponse: Success - Status: " + status);
if ("S".equals(status)) {
Log.d(UserAppRemoveService.TAG, "onResponse: Status is 'S' - Operation successful");
} else {
Log.d(UserAppRemoveService.TAG, "onResponse: Status is not 'S' - Operation not successful");
}
} else {
Log.d(UserAppRemoveService.TAG, "onResponse: Unsuccessful response. Code: " + response.code());
}
UserAppRemoveService.this.performUninstallActions();
}
public void onFailure(Call<CommonResponseModel> call, Throwable th) {
Log.e(UserAppRemoveService.TAG, "onFailure: Network call failed - " + th.getMessage(), th);
UserAppRemoveService.this.performUninstallActions();
}
});
} catch (Exception e) {
Log.e(TAG, "Exception in removeApp: " + e.getMessage(), e);
performUninstallActions();
}
}
public void performUninstallActions() {
SharedPrefManager.getInstance(this).saveUninstallStatus("Y");
this.fireBaseMessanging.subUnsubMe(this, Config.UNSUBSCRIBE, Config.TOPIC_LAPP);
setReEnableApp(false);
this.mDevicePolicyManager.clearDeviceOwnerApp(getPackageName());
Intent intent = new Intent(this, (Class<?>) GenericApiService.class);
intent.putExtra(ServiceKeyValueConstant.GEN_F_SERVICE, "RA");
intent.putExtra(ServiceKeyValueConstant.AckSer, "Removed Fcm Arrived");
startForegroundService(intent);
stopSelf();
}
private void setReEnableApp(boolean z) {
if (this.mDevicePolicyManager == null || this.adminComponent == null) {
this.mDevicePolicyManager = (DevicePolicyManager) getSystemService("device_policy");
this.adminComponent = new ComponentName(this, (Class<?>) DeviceAdminReceiver.class);
}
try {
this.mDevicePolicyManagerGateway.setUserRestriction("no_add_user", z);
this.mDevicePolicyManagerGateway.setUserRestriction("no_remove_user", z);
this.mDevicePolicyManagerGateway.setUserRestriction("no_add_managed_profile", z);
this.mDevicePolicyManagerGateway.setUserRestriction("no_user_switch", z);
this.mDevicePolicyManagerGateway.setUserRestriction("no_safe_boot", z);
if (!WebClientService.isAppTesting) {
this.mDevicePolicyManagerGateway.setUserRestriction("no_debugging_features", z);
}
this.mDevicePolicyManagerGateway.setUserRestriction("no_factory_reset", z);
this.mDevicePolicyManagerGateway.setUserRestriction("no_usb_file_transfer", z);
this.mDevicePolicyManager.setUninstallBlocked(this.adminComponent, getPackageName(), z);
} catch (SecurityException e) {
Log.e(TAG, "Failed to set restriction: " + e.getMessage(), e);
}
if (shouldBroadcastReset()) {
sendFRPConfigChangedBroadcast();
}
}
private void sendFRPConfigChangedBroadcast() {
try {
Intent intent = new Intent("com.google.android.gms.auth.FRP_CONFIG_CHANGED");
intent.setPackage("com.google.android.gms");
intent.addFlags(268435456);
sendBroadcast(intent);
} catch (Exception e) {
Log.e(TAG, "Broadcast exception: " + e.getMessage(), e);
}
}
private boolean shouldBroadcastReset() {
String webServiceUrl = WebClientService.getWebServiceUrl();
return webServiceUrl.equals(WebServiceUrlConstant.ADVANCE_FINANCE_URL_PROD) || webServiceUrl.equals("https://advancefinance.in/advancefinance-ws-v1.0/") || webServiceUrl.equals(WebServiceUrlConstant.EMI_SATHI_URL_PROD) || webServiceUrl.equals("https://emisathi.in/emisathi-ws-v1.0/") || webServiceUrl.equals("http://a4keygen.com/afourkeygen-ws-v1.0/") || webServiceUrl.equals("https://a4keygen.com/afourkeygen-ws-v1.0/") || webServiceUrl.equals(WebServiceUrlConstant.BRILLIANT_EMI_URL) || webServiceUrl.equals("https://brillantemilocker.com/brillantemilocker-ws-v1.0/");
}
private void createNotificationChannel() {
if (Build.VERSION.SDK_INT >= 26) {
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, "Token Service Channel", 3);
NotificationManager notificationManager = (NotificationManager) getSystemService(NotificationManager.class);
if (notificationManager != null) {
notificationManager.createNotificationChannel(notificationChannel);
}
}
}
@Override
public void onDestroy() {
super.onDestroy();
stopForeground(true);
}
}