You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Add Superuser management UI
This commit is contained in:
@@ -7,6 +7,11 @@ import android.database.Cursor;
|
||||
|
||||
|
||||
public class Policy {
|
||||
public static final int INTERACTIVE = 0;
|
||||
public static final int DENY = 1;
|
||||
public static final int ALLOW = 2;
|
||||
|
||||
|
||||
public int uid, policy;
|
||||
public long until;
|
||||
public boolean logging, notification;
|
||||
|
||||
@@ -57,19 +57,20 @@ public class SuDatabaseHelper extends SQLiteOpenHelper {
|
||||
}
|
||||
|
||||
public List<Policy> getPolicyList(PackageManager pm) {
|
||||
List<Policy> ret = new ArrayList<>();
|
||||
SQLiteDatabase db = getWritableDatabase();
|
||||
ArrayList<Policy> ret = new ArrayList<>();
|
||||
Policy policy;
|
||||
// Clear outdated policies
|
||||
db.delete(TABLE_NAME, "until > 0 and until < ?", new String[] { String.valueOf(System.currentTimeMillis()) });
|
||||
try (Cursor c = db.query(TABLE_NAME, null, null, null, null, null, null)) {
|
||||
try (Cursor c = db.query(TABLE_NAME, null, null, null, null, null, "app_name")) {
|
||||
while (c.moveToNext()) {
|
||||
policy = new Policy(c);
|
||||
// Package is uninstalled
|
||||
if (pm.getPackagesForUid(policy.uid) == null)
|
||||
if (pm.getPackagesForUid(policy.uid) == null) {
|
||||
deletePolicy(policy.uid);
|
||||
else
|
||||
} else {
|
||||
ret.add(policy);
|
||||
}
|
||||
}
|
||||
}
|
||||
db.close();
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.topjohnwu.magisk.superuser;
|
||||
|
||||
import android.content.ContentValues;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager;
|
||||
@@ -11,10 +10,7 @@ import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.os.CountDownTimer;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.ImageView;
|
||||
@@ -117,7 +113,7 @@ public class SuRequestActivity extends AppCompatActivity {
|
||||
policy.packageName = packageName;
|
||||
policy.appName = appName;
|
||||
policy.until = (timeout == 0) ? 0 : (System.currentTimeMillis() / 1000 + timeout * 60);
|
||||
policy.policy = action ? 2 : 1;
|
||||
policy.policy = action ? Policy.ALLOW : Policy.DENY;
|
||||
policy.logging = true;
|
||||
policy.notification = true;
|
||||
new SuDatabaseHelper(this).addPolicy(policy);
|
||||
|
||||
Reference in New Issue
Block a user