From f61f11b87029d41521bedff56132a068a172190f Mon Sep 17 00:00:00 2001 From: Suprabh Shukla Date: Mon, 6 Feb 2017 15:25:29 -0800 Subject: [PATCH] Removing unknown sources from security settings The secure setting is deprecated starting from O. Removing it from the settings UI so the user cannot change it. The unknown sources can be managed at a more granular level by starting activity for intent MANAGE_EXTERNAL_SOURCES Test: Manually tested that the preference is removed and does not disturb the other settings on the page. Bug: 33947615 Change-Id: I8dc559d0e6aaaf5bad78fb6e04469d9ab647411d --- res/xml/security_settings_misc.xml | 6 -- .../android/settings/SecuritySettings.java | 83 +------------------ 2 files changed, 2 insertions(+), 87 deletions(-) diff --git a/res/xml/security_settings_misc.xml b/res/xml/security_settings_misc.xml index d724b740c24..aefbbd81a82 100644 --- a/res/xml/security_settings_misc.xml +++ b/res/xml/security_settings_misc.xml @@ -52,12 +52,6 @@ android:persistent="false" android:fragment="com.android.settings.DeviceAdminSettings"/> - - 0; - } - - private void setNonMarketAppsAllowed(boolean enabled) { - final UserManager um = (UserManager) getActivity().getSystemService(Context.USER_SERVICE); - if (um.hasUserRestriction(UserManager.DISALLOW_INSTALL_UNKNOWN_SOURCES)) { - return; - } - // Change the system setting - Settings.Global.putInt(getContentResolver(), Settings.Global.INSTALL_NON_MARKET_APPS, - enabled ? 1 : 0); - } - - private void warnAppInstallation() { - // TODO: DialogFragment? - mWarnInstallApps = new AlertDialog.Builder(getActivity()).setTitle( - getResources().getString(R.string.error_title)) - .setIcon(com.android.internal.R.drawable.ic_dialog_alert) - .setMessage(getResources().getString(R.string.install_all_warning)) - .setPositiveButton(android.R.string.yes, this) - .setNegativeButton(android.R.string.no, this) - .show(); - } - - @Override - public void onClick(DialogInterface dialog, int which) { - if (dialog == mWarnInstallApps) { - boolean turnOn = which == DialogInterface.BUTTON_POSITIVE; - setNonMarketAppsAllowed(turnOn); - if (mToggleAppInstallation != null) { - mToggleAppInstallation.setChecked(turnOn); - } - } - } - @Override public void onGearClick(GearPreference p) { if (KEY_UNLOCK_SET_OR_CHANGE.equals(p.getKey())) { @@ -644,14 +582,6 @@ public class SecuritySettings extends SettingsPreferenceFragment } } - @Override - public void onDestroy() { - super.onDestroy(); - if (mWarnInstallApps != null) { - mWarnInstallApps.dismiss(); - } - } - @Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); @@ -857,15 +787,6 @@ public class SecuritySettings extends SettingsPreferenceFragment Settings.System.putInt(getContentResolver(), Settings.System.TEXT_SHOW_PASSWORD, ((Boolean) value) ? 1 : 0); lockPatternUtils.setVisiblePasswordEnabled((Boolean) value, MY_USER_ID); - } else if (KEY_TOGGLE_INSTALL_APPLICATIONS.equals(key)) { - if ((Boolean) value) { - mToggleAppInstallation.setChecked(false); - warnAppInstallation(); - // Don't change Switch status until user makes choice in dialog, so return false. - result = false; - } else { - setNonMarketAppsAllowed(false); - } } return result; }