Commit 0efb4da0 authored by topjohnwu's avatar topjohnwu

Several bug fixes

Fix #57
parent ed7920d6
...@@ -47,11 +47,11 @@ repositories { ...@@ -47,11 +47,11 @@ repositories {
dependencies { dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs') compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:recyclerview-v7:25.1.0' compile 'com.android.support:recyclerview-v7:25.1.1'
compile 'com.android.support:cardview-v7:25.1.0' compile 'com.android.support:cardview-v7:25.1.1'
compile 'com.android.support:design:25.1.0' compile 'com.android.support:design:25.1.1'
compile 'com.android.support:support-v4:25.1.0' compile 'com.android.support:support-v4:25.1.1'
compile 'com.android.support:support-v13:25.1.0' compile 'com.android.support:support-v13:25.1.1'
compile 'com.jakewharton:butterknife:8.5.1' compile 'com.jakewharton:butterknife:8.5.1'
compile 'com.google.code.gson:gson:2.8.0' compile 'com.google.code.gson:gson:2.8.0'
compile 'com.github.clans:fab:1.6.4' compile 'com.github.clans:fab:1.6.4'
......
...@@ -11,7 +11,6 @@ public class Policy { ...@@ -11,7 +11,6 @@ public class Policy {
public static final int DENY = 1; public static final int DENY = 1;
public static final int ALLOW = 2; public static final int ALLOW = 2;
public int uid, policy; public int uid, policy;
public long until; public long until;
public boolean logging = true, notification = true; public boolean logging = true, notification = true;
...@@ -22,6 +21,7 @@ public class Policy { ...@@ -22,6 +21,7 @@ public class Policy {
String[] pkgs = pm.getPackagesForUid(uid); String[] pkgs = pm.getPackagesForUid(uid);
if (pkgs != null && pkgs.length > 0) { if (pkgs != null && pkgs.length > 0) {
info = pm.getPackageInfo(pkgs[0], 0); info = pm.getPackageInfo(pkgs[0], 0);
this.uid = uid;
packageName = pkgs[0]; packageName = pkgs[0];
appName = info.applicationInfo.loadLabel(pm).toString(); appName = info.applicationInfo.loadLabel(pm).toString();
} else throw new PackageManager.NameNotFoundException(); } else throw new PackageManager.NameNotFoundException();
......
...@@ -87,11 +87,10 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand ...@@ -87,11 +87,10 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
switch (Global.Configs.suResponseType) { switch (Global.Configs.suResponseType) {
case AUTO_DENY: case AUTO_DENY:
event.trigger(); handleAction(Policy.DENY, 0);
return; return;
case AUTO_ALLOW: case AUTO_ALLOW:
policy.policy = Policy.ALLOW; handleAction(Policy.ALLOW, 0);
event.trigger(policy);
return; return;
case PROMPT: case PROMPT:
default: default:
...@@ -157,9 +156,12 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand ...@@ -157,9 +156,12 @@ public class SuRequestActivity extends AppCompatActivity implements CallbackHand
} }
void handleAction(int action) { void handleAction(int action) {
handleAction(action, timeoutList[timeout.getSelectedItemPosition()]);
}
void handleAction(int action, int time) {
policy.policy = action; policy.policy = action;
event.trigger(policy); event.trigger(policy);
int time = timeoutList[timeout.getSelectedItemPosition()];
if (time >= 0) { if (time >= 0) {
policy.until = time == 0 ? 0 : (System.currentTimeMillis() / 1000 + time * 60); policy.until = time == 0 ? 0 : (System.currentTimeMillis() / 1000 + time * 60);
new SuDatabaseHelper(this).addPolicy(policy); new SuDatabaseHelper(this).addPolicy(policy);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment