Several bug fixes

Fix #57
This commit is contained in:
topjohnwu 2017-01-31 03:39:24 +08:00
parent ed7920d61e
commit 0efb4da0ee
4 changed files with 192 additions and 181 deletions

View File

@ -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'

View File

@ -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 {
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();

View File

@ -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
} }
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);

View File

@ -1,11 +1,17 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginTop="?attr/actionBarSize" android:layout_marginTop="?attr/actionBarSize"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<android.support.v7.widget.CardView <android.support.v7.widget.CardView
android:id="@+id/install_info_card" android:id="@+id/install_info_card"
android:layout_width="match_parent" android:layout_width="match_parent"
@ -210,4 +216,7 @@
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
</ScrollView>