mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-04 22:17:53 +00:00
Re-add activity check
Causes false disables otherwise.
This commit is contained in:
parent
3adc7ca22a
commit
c553312fd5
@ -7,6 +7,7 @@ import android.app.PendingIntent;
|
|||||||
import android.content.ComponentName;
|
import android.content.ComponentName;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@ -61,23 +62,35 @@ public class MonitorService extends AccessibilityService {
|
|||||||
event.getPackageName().toString(),
|
event.getPackageName().toString(),
|
||||||
event.getClassName().toString()
|
event.getClassName().toString()
|
||||||
);
|
);
|
||||||
Logger.dh("MonitorService: CurrentActivity: " + event.getPackageName());
|
ActivityInfo activityInfo = tryGetActivity(componentName);
|
||||||
|
boolean isActivity = activityInfo != null;
|
||||||
|
if (isActivity) {
|
||||||
|
Logger.dh("MonitorService: CurrentActivity: " + event.getPackageName());
|
||||||
|
|
||||||
String mPackage = componentName.getPackageName();
|
String mPackage = componentName.getPackageName();
|
||||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
|
||||||
if (Utils.autoToggleEnabled(getApplicationContext())) {
|
if (Utils.autoToggleEnabled(getApplicationContext())) {
|
||||||
Set<String> setBlackList = prefs.getStringSet("auto_blacklist", null);
|
Set<String> setBlackList = prefs.getStringSet("auto_blacklist", null);
|
||||||
|
|
||||||
if (setBlackList != null) {
|
if (setBlackList != null) {
|
||||||
disableroot = setBlackList.contains(mPackage);
|
disableroot = setBlackList.contains(mPackage);
|
||||||
ForceRoot(!disableroot);
|
ForceRoot(!disableroot);
|
||||||
String appFriendly = getAppName(mPackage);
|
String appFriendly = getAppName(mPackage);
|
||||||
ShowNotification(disableroot, appFriendly);
|
ShowNotification(disableroot, appFriendly);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ActivityInfo tryGetActivity(ComponentName componentName) {
|
||||||
|
try {
|
||||||
|
return getPackageManager().getActivityInfo(componentName, 0);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private String getAppName(String packageName) {
|
private String getAppName(String packageName) {
|
||||||
PackageManager pkManager = getPackageManager();
|
PackageManager pkManager = getPackageManager();
|
||||||
ApplicationInfo appInfo;
|
ApplicationInfo appInfo;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user