正在查看: Fix Locker v1.5 应用的 AppStatesService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Fix Locker v1.5 应用的 AppStatesService.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.user.a4keygen.feedback;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.util.Log;
import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import androidx.enterprise.feedback.KeyedAppStatesService;
import androidx.enterprise.feedback.ReceivedKeyedAppState;
import androidx.preference.PreferenceManager;
import com.user.a4keygen.R;
import com.user.a4keygen.common.Util;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
public class AppStatesService extends KeyedAppStatesService {
private static final String CHANNEL_ID = "KeyedAppStates";
private static final String CHANNEL_NAME = "Keyed App States";
static final String TAG = "KeyedAppStates";
private int nextNotificationId = 0;
private Map<String, Integer> idMapping = new HashMap();
public void onReceive(Collection<ReceivedKeyedAppState> collection, boolean z) {
if (PreferenceManager.getDefaultSharedPreferences(this).getBoolean(getString(R.string.app_feedback_notifications), false)) {
createNotificationChannel();
Iterator<ReceivedKeyedAppState> it = collection.iterator();
while (it.hasNext()) {
showNotification(it.next(), z);
}
}
}
private void showNotification(ReceivedKeyedAppState receivedKeyedAppState, boolean z) {
String str;
String str2 = receivedKeyedAppState.getTimestamp() + " " + receivedKeyedAppState.getPackageName() + ":" + receivedKeyedAppState.getKey() + "=" + receivedKeyedAppState.getData() + " (" + receivedKeyedAppState.getMessage() + ")" + (z ? " - SYNC REQUESTED" : "");
if (receivedKeyedAppState.getSeverity() == 2) {
Log.e("KeyedAppStates", str2);
} else {
Log.i("KeyedAppStates", str2);
}
if (receivedKeyedAppState.getSeverity() == 2) {
str = "ERROR";
} else {
str = receivedKeyedAppState.getSeverity() == 1 ? "INFO" : "UNKNOWN";
}
NotificationManagerCompat.from(this).notify(getIdForState(receivedKeyedAppState), new NotificationCompat.Builder(this, "KeyedAppStates").setSmallIcon(R.drawable.arrow_down).setContentTitle(receivedKeyedAppState.getPackageName() + ":" + receivedKeyedAppState.getKey() + " " + str).setContentText(receivedKeyedAppState.getTimestamp() + " " + receivedKeyedAppState.getData() + " (" + receivedKeyedAppState.getMessage() + ")" + (z ? "\nSYNC REQUESTED" : "")).build());
}
private void createNotificationChannel() {
if (Util.SDK_INT >= 26) {
((NotificationManager) getSystemService(NotificationManager.class)).createNotificationChannel(new NotificationChannel("KeyedAppStates", CHANNEL_NAME, 3));
}
}
private int getIdForState(ReceivedKeyedAppState receivedKeyedAppState) {
String str = receivedKeyedAppState.getPackageName() + ":" + receivedKeyedAppState.getKey();
if (!this.idMapping.containsKey(str)) {
Map<String, Integer> map = this.idMapping;
int i = this.nextNotificationId;
this.nextNotificationId = i + 1;
map.put(str, Integer.valueOf(i));
}
return this.idMapping.get(str).intValue();
}
}