Guard against missing terminal app.
Bug: 8328852 Change-Id: Icbc8942729af5a525f55b8c90513ff724c6f90e0
This commit is contained in:
@@ -34,6 +34,7 @@ import android.content.DialogInterface.OnClickListener;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ApplicationInfo;
|
import android.content.pm.ApplicationInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.PackageManager.NameNotFoundException;
|
||||||
import android.content.pm.ResolveInfo;
|
import android.content.pm.ResolveInfo;
|
||||||
import android.hardware.usb.IUsbManager;
|
import android.hardware.usb.IUsbManager;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
@@ -211,16 +212,21 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
|
|
||||||
addPreferencesFromResource(R.xml.development_prefs);
|
addPreferencesFromResource(R.xml.development_prefs);
|
||||||
|
|
||||||
|
final PreferenceGroup debugDebuggingCategory = (PreferenceGroup)
|
||||||
|
findPreference(DEBUG_DEBUGGING_CATEGORY_KEY);
|
||||||
|
|
||||||
mEnableAdb = findAndInitCheckboxPref(ENABLE_ADB);
|
mEnableAdb = findAndInitCheckboxPref(ENABLE_ADB);
|
||||||
mClearAdbKeys = findPreference(CLEAR_ADB_KEYS);
|
mClearAdbKeys = findPreference(CLEAR_ADB_KEYS);
|
||||||
if (!SystemProperties.getBoolean("ro.adb.secure", false)) {
|
if (!SystemProperties.getBoolean("ro.adb.secure", false)) {
|
||||||
PreferenceGroup debugDebuggingCategory = (PreferenceGroup)
|
|
||||||
findPreference(DEBUG_DEBUGGING_CATEGORY_KEY);
|
|
||||||
if (debugDebuggingCategory != null) {
|
if (debugDebuggingCategory != null) {
|
||||||
debugDebuggingCategory.removePreference(mClearAdbKeys);
|
debugDebuggingCategory.removePreference(mClearAdbKeys);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mEnableTerminal = findAndInitCheckboxPref(ENABLE_TERMINAL);
|
mEnableTerminal = findAndInitCheckboxPref(ENABLE_TERMINAL);
|
||||||
|
if (!isPackageInstalled(getActivity(), TERMINAL_APP_PACKAGE)) {
|
||||||
|
debugDebuggingCategory.removePreference(mEnableTerminal);
|
||||||
|
mEnableTerminal = null;
|
||||||
|
}
|
||||||
|
|
||||||
mBugreport = findPreference(BUGREPORT);
|
mBugreport = findPreference(BUGREPORT);
|
||||||
mBugreportInPower = findAndInitCheckboxPref(BUGREPORT_IN_POWER_KEY);
|
mBugreportInPower = findAndInitCheckboxPref(BUGREPORT_IN_POWER_KEY);
|
||||||
@@ -242,8 +248,6 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
mWaitForDebugger = findAndInitCheckboxPref(WAIT_FOR_DEBUGGER_KEY);
|
mWaitForDebugger = findAndInitCheckboxPref(WAIT_FOR_DEBUGGER_KEY);
|
||||||
mVerifyAppsOverUsb = findAndInitCheckboxPref(VERIFY_APPS_OVER_USB_KEY);
|
mVerifyAppsOverUsb = findAndInitCheckboxPref(VERIFY_APPS_OVER_USB_KEY);
|
||||||
if (!showVerifierSetting()) {
|
if (!showVerifierSetting()) {
|
||||||
PreferenceGroup debugDebuggingCategory = (PreferenceGroup)
|
|
||||||
findPreference(DEBUG_DEBUGGING_CATEGORY_KEY);
|
|
||||||
if (debugDebuggingCategory != null) {
|
if (debugDebuggingCategory != null) {
|
||||||
debugDebuggingCategory.removePreference(mVerifyAppsOverUsb);
|
debugDebuggingCategory.removePreference(mVerifyAppsOverUsb);
|
||||||
} else {
|
} else {
|
||||||
@@ -408,9 +412,11 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
mHaveDebugSettings = false;
|
mHaveDebugSettings = false;
|
||||||
updateCheckBox(mEnableAdb, Settings.Global.getInt(cr,
|
updateCheckBox(mEnableAdb, Settings.Global.getInt(cr,
|
||||||
Settings.Global.ADB_ENABLED, 0) != 0);
|
Settings.Global.ADB_ENABLED, 0) != 0);
|
||||||
updateCheckBox(mEnableTerminal,
|
if (mEnableTerminal != null) {
|
||||||
context.getPackageManager().getApplicationEnabledSetting(TERMINAL_APP_PACKAGE)
|
updateCheckBox(mEnableTerminal,
|
||||||
== PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
|
context.getPackageManager().getApplicationEnabledSetting(TERMINAL_APP_PACKAGE)
|
||||||
|
== PackageManager.COMPONENT_ENABLED_STATE_ENABLED);
|
||||||
|
}
|
||||||
updateCheckBox(mBugreportInPower, Settings.Secure.getInt(cr,
|
updateCheckBox(mBugreportInPower, Settings.Secure.getInt(cr,
|
||||||
Settings.Secure.BUGREPORT_IN_POWER_MENU, 0) != 0);
|
Settings.Secure.BUGREPORT_IN_POWER_MENU, 0) != 0);
|
||||||
updateCheckBox(mKeepScreenOn, Settings.Global.getInt(cr,
|
updateCheckBox(mKeepScreenOn, Settings.Global.getInt(cr,
|
||||||
@@ -1298,4 +1304,12 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
throw new RuntimeException("Problem talking with PackageManager", e);
|
throw new RuntimeException("Problem talking with PackageManager", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isPackageInstalled(Context context, String packageName) {
|
||||||
|
try {
|
||||||
|
return context.getPackageManager().getPackageInfo(packageName, 0) != null;
|
||||||
|
} catch (NameNotFoundException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user