You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Refactor su database
This commit is contained in:
@@ -5,21 +5,18 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
|
||||
import com.topjohnwu.magisk.MagiskManager;
|
||||
import com.topjohnwu.magisk.database.SuDatabaseHelper;
|
||||
import com.topjohnwu.magisk.superuser.Policy;
|
||||
import com.topjohnwu.magisk.utils.Logger;
|
||||
import com.topjohnwu.magisk.utils.Utils;
|
||||
|
||||
public class PackageReceiver extends BroadcastReceiver {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
SuDatabaseHelper suDB = new SuDatabaseHelper(context);
|
||||
MagiskManager magiskManager = Utils.getMagiskManager(context);
|
||||
String pkg = intent.getData().getEncodedSchemeSpecificPart();
|
||||
Policy policy = suDB.getPolicy(pkg);
|
||||
Policy policy = magiskManager.suDB.getPolicy(pkg);
|
||||
if (policy == null)
|
||||
return;
|
||||
|
||||
MagiskManager magiskManager = Utils.getMagiskManager(context);
|
||||
magiskManager.initSUConfig();
|
||||
|
||||
switch (intent.getAction()) {
|
||||
@@ -29,12 +26,12 @@ public class PackageReceiver extends BroadcastReceiver {
|
||||
if (uid > 0) {
|
||||
policy.uid = uid % 100000;
|
||||
}
|
||||
suDB.updatePolicy(policy);
|
||||
magiskManager.suDB.updatePolicy(policy);
|
||||
return;
|
||||
case Intent.ACTION_PACKAGE_REMOVED:
|
||||
boolean isUpdate = intent.getBooleanExtra(Intent.EXTRA_REPLACING, false);
|
||||
if (!isUpdate || magiskManager.suReauth) {
|
||||
suDB.deletePolicy(policy);
|
||||
magiskManager.suDB.deletePolicy(policy);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user