OSDN Git Service

superuser perm
authorKoushik Dutta <koushd@gmail.com>
Sun, 24 Feb 2013 10:58:08 +0000 (02:58 -0800)
committerKoushik Dutta <koushd@gmail.com>
Sun, 24 Feb 2013 10:58:08 +0000 (02:58 -0800)
Superuser/AndroidManifest.xml
Superuser/res/drawable-hdpi/ic_action_permission.png [new file with mode: 0644]
Superuser/res/drawable-mdpi/ic_action_permission.png [new file with mode: 0644]
Superuser/res/drawable-xhdpi/ic_action_permission.png [new file with mode: 0644]
Superuser/res/drawable/sulogo.png [new file with mode: 0644]
Superuser/res/layout-large/app_layout.xml [deleted file]
Superuser/res/layout/app_layout.xml
Superuser/res/values/strings.xml
Superuser/src/com/koushikdutta/superuser/MultitaskSuRequestActivity.java

index 1c1f7d8..e6daf76 100644 (file)
     <permission
         android:name="android.permission.REPORT_SUPERUSER"
         android:protectionLevel="signatureOrSystem" />
-    <permission android:name="android.permission.ACCESS_SUPERUSER" />
+    <permission
+        android:protectionLevel="dangerous"
+        android:name="android.permission.ACCESS_SUPERUSER"
+        android:description="@string/superuser_description_more"
+        android:logo="@drawable/ic_action_permission"
+        android:icon="@drawable/ic_action_permission"
+        android:label="@string/superuser_description" />
 
+    <uses-permission android:name="android.permission.ACCESS_SUPERUSER" />
+    
     <application
         android:name=".SuApplication"
         android:allowBackup="false"
diff --git a/Superuser/res/drawable-hdpi/ic_action_permission.png b/Superuser/res/drawable-hdpi/ic_action_permission.png
new file mode 100644 (file)
index 0000000..0d5a229
Binary files /dev/null and b/Superuser/res/drawable-hdpi/ic_action_permission.png differ
diff --git a/Superuser/res/drawable-mdpi/ic_action_permission.png b/Superuser/res/drawable-mdpi/ic_action_permission.png
new file mode 100644 (file)
index 0000000..3c227f9
Binary files /dev/null and b/Superuser/res/drawable-mdpi/ic_action_permission.png differ
diff --git a/Superuser/res/drawable-xhdpi/ic_action_permission.png b/Superuser/res/drawable-xhdpi/ic_action_permission.png
new file mode 100644 (file)
index 0000000..580166d
Binary files /dev/null and b/Superuser/res/drawable-xhdpi/ic_action_permission.png differ
diff --git a/Superuser/res/drawable/sulogo.png b/Superuser/res/drawable/sulogo.png
new file mode 100644 (file)
index 0000000..09cdd33
Binary files /dev/null and b/Superuser/res/drawable/sulogo.png differ
diff --git a/Superuser/res/layout-large/app_layout.xml b/Superuser/res/layout-large/app_layout.xml
deleted file mode 100644 (file)
index e1ebbdf..0000000
+++ /dev/null
@@ -1,12 +0,0 @@
-<merge xmlns:android="http://schemas.android.com/apk/res/android" >
-
-    <include
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        layout="@layout/app_info" />
-
-    <include
-        android:layout_width="fill_parent"
-        android:layout_height="wrap_content"
-        layout="@layout/app_icons" />
-</merge>
\ No newline at end of file
index 629a28d..4257992 100644 (file)
@@ -1,13 +1,24 @@
 <merge xmlns:android="http://schemas.android.com/apk/res/android" >
 
     <include
-        android:visibility="gone"
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
-        layout="@layout/app_info" />
+        layout="@layout/app_info"
+        android:visibility="gone" />
 
     <include
         android:layout_width="fill_parent"
         android:layout_height="wrap_content"
         layout="@layout/app_icons" />
+
+    <TextView
+        android:paddingBottom="4dp"
+        android:gravity="center"
+        android:id="@+id/developer_warning"
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:text="@string/developer_warning"
+        android:textColor="@color/holo_red_dark"
+        android:visibility="gone" />
+
 </merge>
\ No newline at end of file
index f7dbf89..34fa3da 100644 (file)
@@ -42,4 +42,7 @@
     <string name="toast">Toast</string>
     <string name="notification">Notification</string>
     <string name="none">None</string>
+    <string name="developer_warning">Developer Warning:\nandroid.permission.ACCESS_SUPERUSER\nnot declared in manifest.</string>
+    <string name="superuser_description">full permissions to all device features and storage</string>
+    <string name="superuser_description_more">Superuser grants full access to all device features and storage, including the secure and sensitive hardware elements of your device. This permission is potentially dangerous.</string>
 </resources>
\ No newline at end of file
index f7bc8d0..a146ef3 100644 (file)
@@ -9,6 +9,7 @@ import android.content.ContentValues;
 import android.content.Intent;
 import android.content.pm.PackageInfo;
 import android.content.pm.PackageManager;
+import android.content.pm.PermissionInfo;
 import android.content.res.Configuration;
 import android.net.LocalSocket;
 import android.net.LocalSocketAddress;
@@ -171,16 +172,27 @@ public class MultitaskSuRequestActivity extends FragmentActivity {
             }
         };
 
+        
+        boolean superuserDeclared = false;
         list.setAdapter(mAdapter);
         if (pkgs != null) {
             for (String pkg: pkgs) {
                 try {
-                    PackageInfo pi = pm.getPackageInfo(pkg, 0);
+                    PackageInfo pi = pm.getPackageInfo(pkg, PackageManager.GET_PERMISSIONS);
                     ((TextView)findViewById(R.id.request)).setText(getString(R.string.application_request, pi.applicationInfo.loadLabel(pm)));
                     mAdapter.add(pi);
                     ((TextView)findViewById(R.id.app_header)).setText(pi.applicationInfo.loadLabel(pm));
                     ((TextView)findViewById(R.id.package_header)).setText(pi.packageName);
                     
+                    if (pi.requestedPermissions != null) {
+                        for (String perm: pi.requestedPermissions) {
+                            if ("android.permission.ACCESS_SUPERUSER".equals(perm)) {
+                                superuserDeclared = true;
+                                break;
+                            }
+                        }
+                    }
+                    
                     // could display them all, but screw it...
                     // maybe a better ux for this later
                     break;
@@ -190,6 +202,10 @@ public class MultitaskSuRequestActivity extends FragmentActivity {
             }
         }
         
+        if (!superuserDeclared) {
+            findViewById(R.id.developer_warning).setVisibility(View.VISIBLE);
+        }
+        
         new Runnable() {
             public void run() {
                 mAllow.setText(getString(R.string.allow) + " (" + mTimeLeft + ")");