diff --git a/res/values/strings.xml b/res/values/strings.xml
index ba3f3865fb5..42f4198454f 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2385,9 +2385,9 @@
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.
-
+
App check
-
+
Disallow or warn before installation of apps that may cause harm
Advanced settings
diff --git a/src/com/android/settings/SecuritySettings.java b/src/com/android/settings/SecuritySettings.java
index 248dcada2b5..e309c37a523 100644
--- a/src/com/android/settings/SecuritySettings.java
+++ b/src/com/android/settings/SecuritySettings.java
@@ -25,6 +25,9 @@ import android.app.admin.DevicePolicyManager;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
+import android.net.Uri;
import android.os.Bundle;
import android.os.UserHandle;
import android.os.Vibrator;
@@ -43,6 +46,7 @@ import com.android.internal.telephony.Phone;
import com.android.internal.widget.LockPatternUtils;
import java.util.ArrayList;
+import java.util.List;
/**
* Gesture lock pattern settings.
@@ -71,6 +75,7 @@ public class SecuritySettings extends SettingsPreferenceFragment
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";
+ private static final String PACKAGE_MIME_TYPE = "application/vnd.android.package-archive";
DevicePolicyManager mDPM;
@@ -228,9 +233,13 @@ public class SecuritySettings extends SettingsPreferenceFragment
mToggleAppInstallation.setChecked(isNonMarketAppsAllowed());
// Package verification
- mToggleVerifyApps = (CheckBoxPreference) findPreference(
- KEY_TOGGLE_VERIFY_APPLICATIONS);
- mToggleVerifyApps.setChecked(isVerifyAppsEnabled());
+ mToggleVerifyApps = (CheckBoxPreference) findPreference(KEY_TOGGLE_VERIFY_APPLICATIONS);
+ if (isVerifierInstalled()) {
+ mToggleVerifyApps.setChecked(isVerifyAppsEnabled());
+ } else {
+ mToggleVerifyApps.setChecked(false);
+ mToggleVerifyApps.setEnabled(false);
+ }
return root;
}
@@ -251,6 +260,15 @@ public class SecuritySettings extends SettingsPreferenceFragment
Settings.Global.PACKAGE_VERIFIER_ENABLE, 1) > 0;
}
+ private boolean isVerifierInstalled() {
+ final PackageManager pm = 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 receivers = pm.queryBroadcastReceivers(verification, 0);
+ return (receivers.size() > 0) ? true : false;
+ }
+
private void warnAppInstallation() {
// TODO: DialogFragment?
mWarnInstallApps = new AlertDialog.Builder(getActivity()).setTitle(