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

Commit 1d48df59 authored by Eric Biggers's avatar Eric Biggers
Browse files

Remove FDE support from accessibility settings

With FDE (Full Disk Encryption), secure start-up (i.e. requiring a PIN /
pattern / password to boot the device) was incompatible with
accessibility services.  Thus, the accessibility settings would ask the
user to disable secure start-up when enabling an accessibility service.

Now that FDE support has been removed in favor of FBE (File Based
Encryption), this is no longer necessary.  Remove it.

Bug: 208476087
Change-Id: I5f6e512f223df63e1b4d1c181fc8b3fe683dcd5f
(cherry picked from commit b4060ef6)
Merged-In: I5f6e512f223df63e1b4d1c181fc8b3fe683dcd5f
parent 6167665b
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -42,14 +42,6 @@
                android:id="@+id/permissionDialog_title"
                style="@style/AccessibilityDialogTitle" />

            <TextView
                android:id="@+id/encryption_warning"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:padding="10dip"
                android:textAlignment="viewStart"
                android:textAppearance="?android:attr/textAppearanceMedium"/>

            <TextView
                android:id="@+id/permissionDialog_description"
                android:text="@string/accessibility_service_warning_description"
+0 −24
Original line number Diff line number Diff line
@@ -5708,30 +5708,6 @@
         can't verify user consent. [CHAR LIMIT=NONE] -->
    <string name="touch_filtered_warning">Because an app is obscuring a permission request, Settings
        can’t verify your response.</string>
    <!-- Warning that the device data will not be encrypted with password or PIN if
        enabling an accessibility service and there is a secure lock setup. [CHAR LIMIT=NONE] -->
    <string name="enable_service_encryption_warning">If you turn on <xliff:g id="service"
        example="TalkBack">%1$s</xliff:g>, your device won’t use your screen lock to enhance
        data encryption.</string>
    <!-- Warning that the device data will not be encrypted with password or PIN if
         choosing a secure lock and there is an enabled accessibility service. [CHAR LIMIT=NONE] -->
    <string name="secure_lock_encryption_warning">Because you\u2019ve turned on an accessibility service,
        your device won’t use your screen lock to enhance data encryption.</string>
    <!-- Message to the users to enter their pattern before enabling an accessibility service. [CHAR LIMIT=NONE] -->
    <string name="enable_service_pattern_reason">Because turning on <xliff:g id="service"
        example="TalkBack">%1$s</xliff:g> affects data encryption, you need to confirm your pattern.
    </string>
    <!-- Message to the users to enter their PIN before enabling an accessibility service. [CHAR LIMIT=NONE] -->
    <string name="enable_service_pin_reason">Because turning on <xliff:g id="service"
        example="TalkBack">%1$s</xliff:g> affects data encryption, you need to confirm your PIN.
    </string>
    <!-- Message to the users to enter their password before enabling an accessibility service. [CHAR LIMIT=NONE] -->
    <string name="enable_service_password_reason">Because turning on <xliff:g id="service"
        example="TalkBack">%1$s</xliff:g> affects data encryption, you need to confirm your password.
    </string>
    <!-- Warning that explains that accessibility services have a lot of access to user data [CHAR LIMIT=NONE] -->
    <string name="accessibility_service_warning"><xliff:g id="service"
+0 −22
Original line number Diff line number Diff line
@@ -23,7 +23,6 @@ import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.drawable.Drawable;
import android.os.storage.StorageManager;
import android.text.BidiFormatter;
import android.view.LayoutInflater;
import android.view.MotionEvent;
@@ -86,16 +85,6 @@ public class AccessibilityServiceWarning {
        return ad;
    }

    /**
     * Returns whether the device is encrypted with legacy full disk encryption. Newer devices
     * should be using File Based Encryption.
     *
     * @return true if device is encrypted
     */
    private static boolean isFullDiskEncrypted() {
        return StorageManager.isNonDefaultBlockEncrypted();
    }

    private static View createEnableDialogContentView(Context context,
            @NonNull AccessibilityServiceInfo info, View.OnClickListener listener,
            UninstallActionPerformer performer) {
@@ -105,17 +94,6 @@ public class AccessibilityServiceWarning {
        View content = inflater.inflate(R.layout.enable_accessibility_service_dialog_content,
                null);

        TextView encryptionWarningView = (TextView) content.findViewById(
                R.id.encryption_warning);
        if (isFullDiskEncrypted()) {
            String text = context.getString(R.string.enable_service_encryption_warning,
                    getServiceName(context, info));
            encryptionWarningView.setText(text);
            encryptionWarningView.setVisibility(View.VISIBLE);
        } else {
            encryptionWarningView.setVisibility(View.GONE);
        }

        final Drawable icon;
        if (info.getResolveInfo().getIconResource() == 0) {
            icon = ContextCompat.getDrawable(context, R.drawable.ic_accessibility_generic);
+4 −65
Original line number Diff line number Diff line
@@ -21,9 +21,7 @@ import static com.android.settings.accessibility.AccessibilityStatsLogUtils.logA
import static com.android.settings.accessibility.PreferredShortcuts.retrieveUserShortcutType;

import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.Activity;
import android.app.Dialog;
import android.app.admin.DevicePolicyManager;
import android.app.settings.SettingsEnums;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -38,9 +36,6 @@ import android.content.pm.ServiceInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.os.UserHandle;
import android.os.storage.StorageManager;
import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.Menu;
@@ -51,11 +46,9 @@ import android.widget.Switch;

import androidx.annotation.Nullable;

import com.android.internal.widget.LockPatternUtils;
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityUtil.UserShortcutType;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.password.ConfirmDeviceCredentialActivity;
import com.android.settingslib.accessibility.AccessibilityUtils;

import java.util.List;
@@ -66,8 +59,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
        ToggleFeaturePreferenceFragment {

    private static final String TAG = "ToggleAccessibilityServicePreferenceFragment";
    private static final int ACTIVITY_REQUEST_CONFIRM_CREDENTIAL_FOR_WEAKER_ENCRYPTION = 1;
    private LockPatternUtils mLockPatternUtils;
    private AtomicBoolean mIsDialogShown = new AtomicBoolean(/* initialValue= */ false);

    private static final String EMPTY_STRING = "";
@@ -106,7 +97,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mLockPatternUtils = new LockPatternUtils(getPrefContext());
    }

    @Override
@@ -243,33 +233,8 @@ public class ToggleAccessibilityServicePreferenceFragment extends
                .contains(mComponentName);
    }

    /**
     * Return whether the device is encrypted with legacy full disk encryption. Newer devices
     * should be using File Based Encryption.
     *
     * @return true if device is encrypted
     */
    private boolean isFullDiskEncrypted() {
        return StorageManager.isNonDefaultBlockEncrypted();
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (requestCode == ACTIVITY_REQUEST_CONFIRM_CREDENTIAL_FOR_WEAKER_ENCRYPTION) {
            if (resultCode == Activity.RESULT_OK) {
                handleConfirmServiceEnabled(/* confirmed= */ true);
                // The user confirmed that they accept weaker encryption when
                // enabling the accessibility service, so change encryption.
                // Since we came here asynchronously, check encryption again.
                if (isFullDiskEncrypted()) {
                    mLockPatternUtils.clearEncryptionPassword();
                    Settings.Global.putInt(getContentResolver(),
                            Settings.Global.REQUIRE_PASSWORD_TO_DECRYPT, 0);
                }
            } else {
                handleConfirmServiceEnabled(/* confirmed= */ false);
            }
        }
    }

    private void registerPackageRemoveReceiver() {
@@ -321,23 +286,6 @@ public class ToggleAccessibilityServicePreferenceFragment extends
        onPreferenceToggled(mPreferenceKey, confirmed);
    }

    private String createConfirmCredentialReasonMessage() {
        int resId = R.string.enable_service_password_reason;
        switch (mLockPatternUtils.getKeyguardStoredPasswordQuality(UserHandle.myUserId())) {
            case DevicePolicyManager.PASSWORD_QUALITY_SOMETHING: {
                resId = R.string.enable_service_pattern_reason;
            }
            break;
            case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC:
            case DevicePolicyManager.PASSWORD_QUALITY_NUMERIC_COMPLEX: {
                resId = R.string.enable_service_pin_reason;
            }
            break;
        }
        return getString(resId, getAccessibilityServiceInfo().getResolveInfo()
                .loadLabel(getPackageManager()));
    }

    @Override
    public void onSwitchChanged(Switch switchView, boolean isChecked) {
        if (isChecked != isAccessibilityServiceEnabled()) {
@@ -461,20 +409,11 @@ public class ToggleAccessibilityServicePreferenceFragment extends
    }

    private void onAllowButtonFromEnableToggleClicked() {
        if (isFullDiskEncrypted()) {
            final String title = createConfirmCredentialReasonMessage();
            final Intent intent = ConfirmDeviceCredentialActivity.createIntent(title, /* details= */
                    null);
            startActivityForResult(intent,
                    ACTIVITY_REQUEST_CONFIRM_CREDENTIAL_FOR_WEAKER_ENCRYPTION);
        } else {
        handleConfirmServiceEnabled(/* confirmed= */ true);
        if (isServiceSupportAccessibilityButton()) {
            mIsDialogShown.set(false);
            showPopupDialog(DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL);
        }
        }

        mDialog.dismiss();
    }

+0 −30
Original line number Diff line number Diff line
@@ -614,7 +614,6 @@ public class ChooseLockGeneric extends SettingsActivity {
                disableUnusablePreferences();
                updatePreferenceText();
                updateCurrentPreference();
                updatePreferenceSummaryIfNeeded();
            } else if (!isRecreatingActivity) {
                // Don't start the activity again if we are recreated for configuration change
                updateUnlockMethodAndFinish(quality, false, true /* chooseLockSkipped */);
@@ -715,13 +714,6 @@ public class ChooseLockGeneric extends SettingsActivity {
            }
        }

        private void setPreferenceSummary(ScreenLockType lock, @StringRes int summary) {
            Preference preference = findPreference(lock.preferenceKey);
            if (preference != null) {
                preference.setSummary(summary);
            }
        }

        private void updateCurrentPreference() {
            String currentKey = getKeyForCurrent();
            Preference preference = findPreference(currentKey);
@@ -764,28 +756,6 @@ public class ChooseLockGeneric extends SettingsActivity {
            }
        }

        private void updatePreferenceSummaryIfNeeded() {
            // On a default block encrypted device with accessibility, add a warning
            // that your data is not credential encrypted
            if (!StorageManager.isBlockEncrypted()) {
                return;
            }

            if (StorageManager.isNonDefaultBlockEncrypted()) {
                return;
            }

            if (AccessibilityManager.getInstance(getActivity()).getEnabledAccessibilityServiceList(
                    AccessibilityServiceInfo.FEEDBACK_ALL_MASK).isEmpty()) {
                return;
            }

            setPreferenceSummary(ScreenLockType.PATTERN, R.string.secure_lock_encryption_warning);
            setPreferenceSummary(ScreenLockType.PIN, R.string.secure_lock_encryption_warning);
            setPreferenceSummary(ScreenLockType.PASSWORD, R.string.secure_lock_encryption_warning);
            setPreferenceSummary(ScreenLockType.MANAGED, R.string.secure_lock_encryption_warning);
        }

        protected Intent getLockManagedPasswordIntent(LockscreenCredential password) {
            return mManagedPasswordProvider.createIntent(false, password);
        }