14
14
*/
15
15
public class RevokeActivity extends Activity {
16
16
17
+ static final List <String > WHITE_LIST_APPS = Arrays .asList (
18
+ "com.github.shadowsocks" ,
19
+ "com.tencent.mm" ,
20
+ "com.xdandroid.kill" ,
21
+ "me.piebridge.brevent"
22
+ );
23
+
24
+ static final List <String > WHITE_LIST_PERMISSIONS = Arrays .asList (
25
+ "android.permission.READ_EXTERNAL_STORAGE" ,
26
+ "android.permission.WRITE_EXTERNAL_STORAGE"
27
+ );
28
+
29
+ static final String [] BLACK_LIST_OPS = {
30
+ "WIFI_SCAN" ,
31
+ "WAKE_LOCK" ,
32
+ "RUN_IN_BACKGROUND" ,
33
+ "WRITE_SETTINGS" ,
34
+ "SYSTEM_ALERT_WINDOW"
35
+ };
36
+
17
37
@ Override
18
38
protected void onCreate (Bundle savedInstanceState ) {
19
39
super .onCreate (savedInstanceState );
@@ -33,7 +53,7 @@ protected void onCreate(Bundle savedInstanceState) {
33
53
String n = i .applicationInfo .packageName ;
34
54
try { setModeMethod .invoke (aom , 10 , uid , n , AppOpsManager .MODE_IGNORED ); } catch (Exception e ) { e .printStackTrace (); }
35
55
try { setModeMethod .invoke (aom , 40 , uid , n , AppOpsManager .MODE_IGNORED ); } catch (Exception e ) { e .printStackTrace (); }
36
- try { setModeMethod .invoke (aom , 63 , uid , n , AppOpsManager .MODE_IGNORED ); } catch (Exception e ) { e .printStackTrace (); }
56
+ try { setModeMethod .invoke (aom , 63 , uid , n , WHITE_LIST_APPS . contains ( n ) ? AppOpsManager . MODE_ALLOWED : AppOpsManager .MODE_IGNORED ); } catch (Exception e ) { e .printStackTrace (); }
37
57
if (i .applicationInfo .targetSdkVersion < Build .VERSION_CODES .M && i .requestedPermissions != null ) {
38
58
Arrays .stream (i .requestedPermissions )
39
59
.map (p -> {
@@ -43,8 +63,7 @@ protected void onCreate(Bundle savedInstanceState) {
43
63
.filter (pi -> (pi .protectionLevel & PermissionInfo .PROTECTION_MASK_BASE ) == PermissionInfo .PROTECTION_DANGEROUS )
44
64
.map (pi -> pi .name )
45
65
.filter (pn -> pn .startsWith ("android" ))
46
- .filter (pn -> !"android.permission.READ_EXTERNAL_STORAGE" .equals (pn ))
47
- .filter (pn -> !"android.permission.WRITE_EXTERNAL_STORAGE" .equals (pn ))
66
+ .filter (pn -> !WHITE_LIST_PERMISSIONS .contains (pn ))
48
67
.map (AppOpsManager ::permissionToOp )
49
68
.filter (op -> !TextUtils .isEmpty (op ))
50
69
.forEach (op -> {
0 commit comments