Merge "Developer setting to skip Package Verification" into jb-mr1-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
4f64951cb8
@@ -2995,6 +2995,10 @@
|
|||||||
<string name="dev_settings_warning_title">Allow development settings?</string>
|
<string name="dev_settings_warning_title">Allow development settings?</string>
|
||||||
<!-- Warning text to user about the implications of enabling USB debugging -->
|
<!-- Warning text to user about the implications of enabling USB debugging -->
|
||||||
<string name="dev_settings_warning_message">These settings are intended for development use only. They can cause your device and the applications on it to break or misbehave.</string>
|
<string name="dev_settings_warning_message">These settings are intended for development use only. They can cause your device and the applications on it to break or misbehave.</string>
|
||||||
|
<!-- Title of checkbox setting to perform package verification on apps installed over USB/ADT/ADB [CHAR LIMIT=32] -->
|
||||||
|
<string name="verify_apps_over_usb_title">Verify apps over USB</string>
|
||||||
|
<!-- Summary of checkbox setting to perform package verification on apps installed over USB/ADT/ADB [CHAR LIMIT=NONE] -->
|
||||||
|
<string name="verify_apps_over_usb_summary">Check apps installed via ADB/ADT for harmful behavior.</string>
|
||||||
|
|
||||||
<!-- Title of checkbox setting that protects external storage. [CHAR LIMIT=32] -->
|
<!-- Title of checkbox setting that protects external storage. [CHAR LIMIT=32] -->
|
||||||
<string name="enforce_read_external_title" product="nosdcard">Protect USB storage</string>
|
<string name="enforce_read_external_title" product="nosdcard">Protect USB storage</string>
|
||||||
|
@@ -75,6 +75,11 @@
|
|||||||
android:title="@string/wait_for_debugger"
|
android:title="@string/wait_for_debugger"
|
||||||
android:summary="@string/wait_for_debugger_summary"/>
|
android:summary="@string/wait_for_debugger_summary"/>
|
||||||
|
|
||||||
|
<CheckBoxPreference
|
||||||
|
android:key="verify_apps_over_usb"
|
||||||
|
android:title="@string/verify_apps_over_usb_title"
|
||||||
|
android:summary="@string/verify_apps_over_usb_summary"/>
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:key="debug_input_category"
|
<PreferenceCategory android:key="debug_input_category"
|
||||||
|
@@ -37,7 +37,8 @@
|
|||||||
android:persistent="false"/>
|
android:persistent="false"/>
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory android:title="@string/device_admin_title"
|
<PreferenceCategory android:key="device_admin_category"
|
||||||
|
android:title="@string/device_admin_title"
|
||||||
android:persistent="false">
|
android:persistent="false">
|
||||||
|
|
||||||
<Preference android:title="@string/manage_device_admin"
|
<Preference android:title="@string/manage_device_admin"
|
||||||
|
@@ -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.ResolveInfo;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.BatteryManager;
|
import android.os.BatteryManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@@ -51,6 +52,7 @@ import android.preference.MultiCheckPreference;
|
|||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
import android.preference.Preference.OnPreferenceChangeListener;
|
import android.preference.Preference.OnPreferenceChangeListener;
|
||||||
import android.preference.PreferenceFragment;
|
import android.preference.PreferenceFragment;
|
||||||
|
import android.preference.PreferenceGroup;
|
||||||
import android.preference.PreferenceScreen;
|
import android.preference.PreferenceScreen;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -63,6 +65,7 @@ import android.widget.Switch;
|
|||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Displays preferences for application developers.
|
* Displays preferences for application developers.
|
||||||
@@ -83,6 +86,7 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
|
|
||||||
private static final String DEBUG_APP_KEY = "debug_app";
|
private static final String DEBUG_APP_KEY = "debug_app";
|
||||||
private static final String WAIT_FOR_DEBUGGER_KEY = "wait_for_debugger";
|
private static final String WAIT_FOR_DEBUGGER_KEY = "wait_for_debugger";
|
||||||
|
private static final String VERIFY_APPS_OVER_USB_KEY = "verify_apps_over_usb";
|
||||||
private static final String STRICT_MODE_KEY = "strict_mode";
|
private static final String STRICT_MODE_KEY = "strict_mode";
|
||||||
private static final String POINTER_LOCATION_KEY = "pointer_location";
|
private static final String POINTER_LOCATION_KEY = "pointer_location";
|
||||||
private static final String SHOW_TOUCHES_KEY = "show_touches";
|
private static final String SHOW_TOUCHES_KEY = "show_touches";
|
||||||
@@ -99,6 +103,7 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
private static final String TRANSITION_ANIMATION_SCALE_KEY = "transition_animation_scale";
|
private static final String TRANSITION_ANIMATION_SCALE_KEY = "transition_animation_scale";
|
||||||
private static final String ANIMATOR_DURATION_SCALE_KEY = "animator_duration_scale";
|
private static final String ANIMATOR_DURATION_SCALE_KEY = "animator_duration_scale";
|
||||||
private static final String OVERLAY_DISPLAY_DEVICES_KEY = "overlay_display_devices";
|
private static final String OVERLAY_DISPLAY_DEVICES_KEY = "overlay_display_devices";
|
||||||
|
private static final String DEBUG_DEBUGGING_CATEGORY_KEY = "debug_debugging_category";
|
||||||
|
|
||||||
private static final String ENABLE_TRACES_KEY = "enable_traces";
|
private static final String ENABLE_TRACES_KEY = "enable_traces";
|
||||||
|
|
||||||
@@ -110,6 +115,8 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
|
|
||||||
private static final String TAG_CONFIRM_ENFORCE = "confirm_enforce";
|
private static final String TAG_CONFIRM_ENFORCE = "confirm_enforce";
|
||||||
|
|
||||||
|
private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";
|
||||||
|
|
||||||
private static final int RESULT_DEBUG_APP = 1000;
|
private static final int RESULT_DEBUG_APP = 1000;
|
||||||
|
|
||||||
private IWindowManager mWindowManager;
|
private IWindowManager mWindowManager;
|
||||||
@@ -131,6 +138,7 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
private String mDebugApp;
|
private String mDebugApp;
|
||||||
private Preference mDebugAppPref;
|
private Preference mDebugAppPref;
|
||||||
private CheckBoxPreference mWaitForDebugger;
|
private CheckBoxPreference mWaitForDebugger;
|
||||||
|
private CheckBoxPreference mVerifyAppsOverUsb;
|
||||||
|
|
||||||
private CheckBoxPreference mStrictMode;
|
private CheckBoxPreference mStrictMode;
|
||||||
private CheckBoxPreference mPointerLocation;
|
private CheckBoxPreference mPointerLocation;
|
||||||
@@ -188,6 +196,16 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
mDebugAppPref = findPreference(DEBUG_APP_KEY);
|
mDebugAppPref = findPreference(DEBUG_APP_KEY);
|
||||||
mAllPrefs.add(mDebugAppPref);
|
mAllPrefs.add(mDebugAppPref);
|
||||||
mWaitForDebugger = findAndInitCheckboxPref(WAIT_FOR_DEBUGGER_KEY);
|
mWaitForDebugger = findAndInitCheckboxPref(WAIT_FOR_DEBUGGER_KEY);
|
||||||
|
mVerifyAppsOverUsb = findAndInitCheckboxPref(VERIFY_APPS_OVER_USB_KEY);
|
||||||
|
if (!showVerifierSetting()) {
|
||||||
|
PreferenceGroup debugDebuggingCategory = (PreferenceGroup)
|
||||||
|
findPreference(DEBUG_DEBUGGING_CATEGORY_KEY);
|
||||||
|
if (debugDebuggingCategory != null) {
|
||||||
|
debugDebuggingCategory.removePreference(mVerifyAppsOverUsb);
|
||||||
|
} else {
|
||||||
|
mVerifyAppsOverUsb.setEnabled(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
mStrictMode = findAndInitCheckboxPref(STRICT_MODE_KEY);
|
mStrictMode = findAndInitCheckboxPref(STRICT_MODE_KEY);
|
||||||
mPointerLocation = findAndInitCheckboxPref(POINTER_LOCATION_KEY);
|
mPointerLocation = findAndInitCheckboxPref(POINTER_LOCATION_KEY);
|
||||||
mShowTouches = findAndInitCheckboxPref(SHOW_TOUCHES_KEY);
|
mShowTouches = findAndInitCheckboxPref(SHOW_TOUCHES_KEY);
|
||||||
@@ -374,6 +392,7 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
updateImmediatelyDestroyActivitiesOptions();
|
updateImmediatelyDestroyActivitiesOptions();
|
||||||
updateAppProcessLimitOptions();
|
updateAppProcessLimitOptions();
|
||||||
updateShowAllANRsOptions();
|
updateShowAllANRsOptions();
|
||||||
|
updateVerifyAppsOverUsbOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void resetDangerousOptions() {
|
private void resetDangerousOptions() {
|
||||||
@@ -469,6 +488,42 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateVerifyAppsOverUsbOptions() {
|
||||||
|
updateCheckBox(mVerifyAppsOverUsb, Settings.Global.getInt(getActivity().getContentResolver(),
|
||||||
|
Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, 1) != 0);
|
||||||
|
mVerifyAppsOverUsb.setEnabled(enableVerifierSetting());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void writeVerifyAppsOverUsbOptions() {
|
||||||
|
Settings.Global.putInt(getActivity().getContentResolver(),
|
||||||
|
Settings.Global.PACKAGE_VERIFIER_INCLUDE_ADB, mVerifyAppsOverUsb.isChecked() ? 1 : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean enableVerifierSetting() {
|
||||||
|
final ContentResolver cr = getActivity().getContentResolver();
|
||||||
|
if (Settings.Global.getInt(cr, Settings.Global.ADB_ENABLED, 0) == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (Settings.Global.getInt(cr, Settings.Global.PACKAGE_VERIFIER_ENABLE, 1) == 0) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
final PackageManager pm = getActivity().getPackageManager();
|
||||||
|
final Intent verification = new Intent(Intent.ACTION_PACKAGE_NEEDS_VERIFICATION);
|
||||||
|
verification.setType(PACKAGE_MIME_TYPE);
|
||||||
|
verification.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
final List<ResolveInfo> receivers = pm.queryBroadcastReceivers(verification, 0);
|
||||||
|
if (receivers.size() == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean showVerifierSetting() {
|
||||||
|
return Settings.Global.getInt(getActivity().getContentResolver(),
|
||||||
|
Settings.Global.PACKAGE_VERIFIER_SETTING_VISIBLE, 1) > 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns the current state of the system property that controls
|
// Returns the current state of the system property that controls
|
||||||
// strictmode flashes. One of:
|
// strictmode flashes. One of:
|
||||||
// 0: not explicitly set one way or another
|
// 0: not explicitly set one way or another
|
||||||
@@ -874,6 +929,8 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
} else {
|
} else {
|
||||||
Settings.Global.putInt(getActivity().getContentResolver(),
|
Settings.Global.putInt(getActivity().getContentResolver(),
|
||||||
Settings.Global.ADB_ENABLED, 0);
|
Settings.Global.ADB_ENABLED, 0);
|
||||||
|
mVerifyAppsOverUsb.setEnabled(false);
|
||||||
|
mVerifyAppsOverUsb.setChecked(false);
|
||||||
}
|
}
|
||||||
} else if (preference == mBugreportInPower) {
|
} else if (preference == mBugreportInPower) {
|
||||||
Settings.Secure.putInt(getActivity().getContentResolver(),
|
Settings.Secure.putInt(getActivity().getContentResolver(),
|
||||||
@@ -898,6 +955,8 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
startActivityForResult(new Intent(getActivity(), AppPicker.class), RESULT_DEBUG_APP);
|
startActivityForResult(new Intent(getActivity(), AppPicker.class), RESULT_DEBUG_APP);
|
||||||
} else if (preference == mWaitForDebugger) {
|
} else if (preference == mWaitForDebugger) {
|
||||||
writeDebuggerOptions();
|
writeDebuggerOptions();
|
||||||
|
} else if (preference == mVerifyAppsOverUsb) {
|
||||||
|
writeVerifyAppsOverUsbOptions();
|
||||||
} else if (preference == mStrictMode) {
|
} else if (preference == mStrictMode) {
|
||||||
writeStrictModeVisualOptions();
|
writeStrictModeVisualOptions();
|
||||||
} else if (preference == mPointerLocation) {
|
} else if (preference == mPointerLocation) {
|
||||||
@@ -977,6 +1036,8 @@ public class DevelopmentSettings extends PreferenceFragment
|
|||||||
mDialogClicked = true;
|
mDialogClicked = true;
|
||||||
Settings.Global.putInt(getActivity().getContentResolver(),
|
Settings.Global.putInt(getActivity().getContentResolver(),
|
||||||
Settings.Global.ADB_ENABLED, 1);
|
Settings.Global.ADB_ENABLED, 1);
|
||||||
|
mVerifyAppsOverUsb.setEnabled(true);
|
||||||
|
updateVerifyAppsOverUsbOptions();
|
||||||
} else {
|
} else {
|
||||||
// Reset the toggle
|
// Reset the toggle
|
||||||
mEnableAdb.setChecked(false);
|
mEnableAdb.setChecked(false);
|
||||||
|
@@ -73,6 +73,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
private static final String KEY_VISIBLE_PATTERN = "visiblepattern";
|
private static final String KEY_VISIBLE_PATTERN = "visiblepattern";
|
||||||
private static final String KEY_TACTILE_FEEDBACK_ENABLED = "unlock_tactile_feedback";
|
private static final String KEY_TACTILE_FEEDBACK_ENABLED = "unlock_tactile_feedback";
|
||||||
private static final String KEY_SECURITY_CATEGORY = "security_category";
|
private static final String KEY_SECURITY_CATEGORY = "security_category";
|
||||||
|
private static final String KEY_DEVICE_ADMIN_CATEGORY = "device_admin_category";
|
||||||
private static final String KEY_LOCK_AFTER_TIMEOUT = "lock_after_timeout";
|
private static final String KEY_LOCK_AFTER_TIMEOUT = "lock_after_timeout";
|
||||||
private static final String KEY_OWNER_INFO_SETTINGS = "owner_info_settings";
|
private static final String KEY_OWNER_INFO_SETTINGS = "owner_info_settings";
|
||||||
private static final String EXTRA_NO_WIDGET = "com.android.settings.NO_WIDGET";
|
private static final String EXTRA_NO_WIDGET = "com.android.settings.NO_WIDGET";
|
||||||
@@ -299,8 +300,14 @@ public class SecuritySettings extends SettingsPreferenceFragment
|
|||||||
mToggleVerifyApps.setChecked(false);
|
mToggleVerifyApps.setChecked(false);
|
||||||
mToggleVerifyApps.setEnabled(false);
|
mToggleVerifyApps.setEnabled(false);
|
||||||
}
|
}
|
||||||
} else if (mToggleVerifyApps != null) {
|
} else {
|
||||||
mToggleVerifyApps.setEnabled(false);
|
PreferenceGroup deviceAdminCategory= (PreferenceGroup)
|
||||||
|
root.findPreference(KEY_DEVICE_ADMIN_CATEGORY);
|
||||||
|
if (deviceAdminCategory != null) {
|
||||||
|
deviceAdminCategory.removePreference(mToggleVerifyApps);
|
||||||
|
} else {
|
||||||
|
mToggleVerifyApps.setEnabled(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return root;
|
return root;
|
||||||
|
Reference in New Issue
Block a user