Android-x86
Fork

  • R/O
  • HTTP
  • SSH
  • HTTPS

packages-apps-Superuser: コミット

packages/apps/Superuser


コミットメタ情報

リビジョン7242fee9f24c9e2319f8db188f4434886fa8ff38 (tree)
日時2012-03-15 15:44:14
作者Steve Kondik <shade@chem...>
コミッターGerrit Code Review

ログメッセージ

Merge "superuser: Prompt user to enable root access" into ics

変更サマリ

差分

--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -265,4 +265,7 @@
265265 <!-- Do not translate any strings below, they are here to prevent build errors -->
266266 <string name="before_secret_code">*#*#</string>
267267 <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>
268271 </resources>
--- a/src/com/noshufou/android/su/HomeActivity.java
+++ b/src/com/noshufou/android/su/HomeActivity.java
@@ -6,14 +6,18 @@ import com.noshufou.android.su.util.Util;
66 import com.noshufou.android.su.widget.ChangeLog;
77 import com.noshufou.android.su.widget.PagerHeader;
88
9+import android.app.AlertDialog;
10+import android.app.Dialog;
911 import android.content.ComponentName;
1012 import android.content.Context;
13+import android.content.DialogInterface;
1114 import android.content.Intent;
1215 import android.content.SharedPreferences;
1316 import android.graphics.drawable.TransitionDrawable;
1417 import android.net.Uri;
1518 import android.os.AsyncTask;
1619 import android.os.Bundle;
20+import android.os.SystemProperties;
1721 import android.preference.PreferenceManager;
1822 import android.support.v4.app.Fragment;
1923 import android.support.v4.app.FragmentActivity;
@@ -30,7 +34,7 @@ import android.widget.ImageView;
3034
3135 import java.util.ArrayList;
3236
33-public class HomeActivity extends FragmentActivity {
37+public class HomeActivity extends FragmentActivity implements DialogInterface.OnClickListener {
3438 // private static final String TAG = "Su.HomeActivity";
3539
3640 private static final int MENU_ELITE = 0;
@@ -46,6 +50,9 @@ public class HomeActivity extends FragmentActivity {
4650 private ViewPager mPager;
4751 private TransitionDrawable mTitleLogo;
4852
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+
4956 @Override
5057 protected void onCreate(Bundle savedInstanceState) {
5158 super.onCreate(savedInstanceState);
@@ -102,6 +109,31 @@ public class HomeActivity extends FragmentActivity {
102109 if (cl.firstRun()) {
103110 cl.getLogDialog().show();
104111 }
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+ }
105137 }
106138
107139 @Override
旧リポジトリブラウザで表示