Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32cf21c9 authored by rich cannings's avatar rich cannings Committed by Android Git Automerger
Browse files

am bfbdceff: Grey out App Check setting when no verifiers exist

* commit 'bfbdceff':
  Grey out App Check setting when no verifiers exist
parents e6195a12 bfbdceff
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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.</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. -->
    <!-- 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. [CHAR LIMIT=30] -->
    <string name="verify_applications">App check</string>
    <!-- Applications settings screen, setting check box summary. This is the summary for "App Check" checkbox. -->
    <!-- Applications settings screen, setting check box summary. This is the summary for "App Check" checkbox. [CHAR LIMIT=none] -->
    <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>
+21 −3
Original line number Diff line number Diff line
@@ -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 = (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<ResolveInfo> receivers = pm.queryBroadcastReceivers(verification, 0);
        return (receivers.size() > 0) ? true : false;
    }

    private void warnAppInstallation() {
        // TODO: DialogFragment?
        mWarnInstallApps = new AlertDialog.Builder(getActivity()).setTitle(