packages/apps/Superuser
リビジョン | 2ac2efe3c39c88f53d8dfffda91c34932a3731be (tree) |
---|---|
日時 | 2012-01-29 09:20:38 |
作者 | Steve Kondik <shade@chem...> |
コミッター | Steve Kondik |
superuser: Prompt user to enable root access
Change-Id: Ib1ec84d5c2a574d8d7c19ad85f95d2f3988e82da
@@ -265,4 +265,7 @@ | ||
265 | 265 | <!-- Do not translate any strings below, they are here to prevent build errors --> |
266 | 266 | <string name="before_secret_code">*#*#</string> |
267 | 267 | <string name="after_secret_code">#*#*</string> |
268 | + | |
269 | + <string name="root_disabled_title">Enable root access?</string> | |
270 | + <string name="root_disabled_summary">Root access is currently disabled for all applications by a system setting. Would you like to enable it?</string> | |
268 | 271 | </resources> |
@@ -6,14 +6,18 @@ import com.noshufou.android.su.util.Util; | ||
6 | 6 | import com.noshufou.android.su.widget.ChangeLog; |
7 | 7 | import com.noshufou.android.su.widget.PagerHeader; |
8 | 8 | |
9 | +import android.app.AlertDialog; | |
10 | +import android.app.Dialog; | |
9 | 11 | import android.content.ComponentName; |
10 | 12 | import android.content.Context; |
13 | +import android.content.DialogInterface; | |
11 | 14 | import android.content.Intent; |
12 | 15 | import android.content.SharedPreferences; |
13 | 16 | import android.graphics.drawable.TransitionDrawable; |
14 | 17 | import android.net.Uri; |
15 | 18 | import android.os.AsyncTask; |
16 | 19 | import android.os.Bundle; |
20 | +import android.os.SystemProperties; | |
17 | 21 | import android.preference.PreferenceManager; |
18 | 22 | import android.support.v4.app.Fragment; |
19 | 23 | import android.support.v4.app.FragmentActivity; |
@@ -30,7 +34,7 @@ import android.widget.ImageView; | ||
30 | 34 | |
31 | 35 | import java.util.ArrayList; |
32 | 36 | |
33 | -public class HomeActivity extends FragmentActivity { | |
37 | +public class HomeActivity extends FragmentActivity implements DialogInterface.OnClickListener { | |
34 | 38 | // private static final String TAG = "Su.HomeActivity"; |
35 | 39 | |
36 | 40 | private static final int MENU_ELITE = 0; |
@@ -46,6 +50,9 @@ public class HomeActivity extends FragmentActivity { | ||
46 | 50 | private ViewPager mPager; |
47 | 51 | private TransitionDrawable mTitleLogo; |
48 | 52 | |
53 | + private static final String CM_VERSION = SystemProperties.get("ro.cm.version", ""); | |
54 | + private static final String ROOT_ACCESS_PROPERTY = "persist.sys.root_access"; | |
55 | + | |
49 | 56 | @Override |
50 | 57 | protected void onCreate(Bundle savedInstanceState) { |
51 | 58 | super.onCreate(savedInstanceState); |
@@ -102,6 +109,31 @@ public class HomeActivity extends FragmentActivity { | ||
102 | 109 | if (cl.firstRun()) { |
103 | 110 | cl.getLogDialog().show(); |
104 | 111 | } |
112 | + | |
113 | + // Check for root enabled on CyanogenMod 9 | |
114 | + if (CM_VERSION.length() > 0) { | |
115 | + String root = SystemProperties.get(ROOT_ACCESS_PROPERTY, "1"); | |
116 | + // 0: off, 1: apps, 2: adb, 3: both | |
117 | + if ("0".equals(root) || "2".equals(root)) { | |
118 | + Dialog dialog = new AlertDialog.Builder(this).setMessage( | |
119 | + getResources().getString(R.string.root_disabled_summary)) | |
120 | + .setTitle(R.string.root_disabled_title) | |
121 | + .setIcon(android.R.drawable.ic_dialog_alert) | |
122 | + .setPositiveButton(android.R.string.yes, this) | |
123 | + .setNegativeButton(android.R.string.no, this) | |
124 | + .show(); | |
125 | + } | |
126 | + } | |
127 | + } | |
128 | + | |
129 | + @Override | |
130 | + public void onClick(DialogInterface dialog, int which) { | |
131 | + if (which == DialogInterface.BUTTON_POSITIVE) { | |
132 | + Intent settings = new Intent("android.settings.APPLICATION_DEVELOPMENT_SETTINGS"); | |
133 | + settings.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | |
134 | + startActivity(settings); | |
135 | + finish(); | |
136 | + } | |
105 | 137 | } |
106 | 138 | |
107 | 139 | @Override |