Add package verification to settings app

Adds a dialog/toggle in security settings to turn package verification on and
off.

Bug: 7082362
Change-Id: I9985437ae28e4a999992c91a7e88547495ccbda2
This commit is contained in:
rich cannings
2012-09-07 13:20:44 -07:00
parent d4b711e603
commit d5d60655a9
3 changed files with 25 additions and 0 deletions

View File

@@ -2385,6 +2385,10 @@
from unknown sources. You agree that you are solely responsible for any
damage to your phone or loss of data that may result from using
these apps.</string>
<!-- Applications settings screen, setting check box title. If checked, the system will send package verification requests to package verifiers on the device who will ultimately allow or reject the installation of applications. -->
<string name="verify_applications">App check</string>
<!-- Applications settings screen, setting check box summary. This is the summary for "App Check" checkbox. -->
<string name="verify_applications_summary">Disallow or warn before installation of apps that may cause harm</string>
<!-- Applications settings screen, setting check box title. If checked, applications show more settings options. -->
<string name="advanced_settings">Advanced settings</string>
<!-- Applications settings screen, setting check box summary. This is the summary for "Advanced settings" checkbox -->

View File

@@ -52,6 +52,12 @@
android:summaryOn="@string/install_unknown_applications"
android:persistent="false" />
<CheckBoxPreference
android:key="toggle_verify_applications"
android:title="@string/verify_applications"
android:summaryOff="@string/verify_applications_summary"
android:summaryOn="@string/verify_applications_summary"
android:persistent="false" />
</PreferenceCategory>
<PreferenceCategory android:title="@string/credentials_title"

View File

@@ -69,6 +69,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
private static final String KEY_SHOW_PASSWORD = "show_password";
private static final String KEY_RESET_CREDENTIALS = "reset_credentials";
private static final String KEY_TOGGLE_INSTALL_APPLICATIONS = "toggle_install_applications";
private static final String KEY_TOGGLE_VERIFY_APPLICATIONS = "toggle_verify_applications";
private static final String KEY_POWER_INSTANTLY_LOCKS = "power_button_instantly_locks";
DevicePolicyManager mDPM;
@@ -87,6 +88,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
private CheckBoxPreference mToggleAppInstallation;
private DialogInterface mWarnInstallApps;
private CheckBoxPreference mToggleVerifyApps;
private CheckBoxPreference mPowerButtonInstantlyLocks;
@Override
@@ -225,6 +227,11 @@ public class SecuritySettings extends SettingsPreferenceFragment
KEY_TOGGLE_INSTALL_APPLICATIONS);
mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
// Package verification
mToggleVerifyApps = (CheckBoxPreference) findPreference(
KEY_TOGGLE_VERIFY_APPLICATIONS);
mToggleVerifyApps.setChecked(isVerifyAppsEnabled());
return root;
}
@@ -239,6 +246,11 @@ public class SecuritySettings extends SettingsPreferenceFragment
enabled ? 1 : 0);
}
private boolean isVerifyAppsEnabled() {
return Settings.Global.getInt(getContentResolver(),
Settings.Global.PACKAGE_VERIFIER_ENABLE, 1) > 0;
}
private void warnAppInstallation() {
// TODO: DialogFragment?
mWarnInstallApps = new AlertDialog.Builder(getActivity()).setTitle(
@@ -420,6 +432,9 @@ public class SecuritySettings extends SettingsPreferenceFragment
} else {
setNonMarketAppsAllowed(false);
}
} else if (KEY_TOGGLE_VERIFY_APPLICATIONS.equals(key)) {
Settings.Global.putInt(getContentResolver(), Settings.Global.PACKAGE_VERIFIER_ENABLE,
mToggleVerifyApps.isChecked() ? 1 : 0);
} else {
// If we didn't handle it, let preferences handle it.
return super.onPreferenceTreeClick(preferenceScreen, preference);