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

Commit 867d97d1 authored by Joey Rizzoli's avatar Joey Rizzoli Committed by Joey Rizzoli
Browse files

Revert "[2/2] settings: support setting a separate encryption password"



This reverts commit c585070f.

Separated encryption password implementation is currently not so well implemented
and it exposes some additional security issues

Change-Id: I0000476d3fae0ad067b741366efe62787213515b
Signed-off-by: default avatarJoey Rizzoli <joey@lineageos.org>
parent e97413de
Loading
Loading
Loading
Loading
+0 −9
Original line number Diff line number Diff line
@@ -1842,15 +1842,6 @@
            android:theme="@style/SetupWizardTheme.Light"
            android:windowSoftInputMode="stateVisible|adjustResize"/>

        <activity android:name="ChooseEncryptionPassword"
            android:exported="false"
            android:theme="@style/SetupWizardTheme.Light"
            android:windowSoftInputMode="stateVisible|adjustResize"/>

        <activity android:name="ReplaceEncryptionPassword"
            android:exported="false"
            android:theme="@style/SetupWizardTheme.Light"/>

        <activity android:name=".SetupEncryptionInterstitial"
            android:label="@string/encryption_interstitial_header"
            android:taskAffinity="com.android.wizard"
+0 −7
Original line number Diff line number Diff line
@@ -429,13 +429,6 @@
    <string name="heads_up_notifications_enabled_title">Heads-up</string>
    <string name="heads_up_notifications_enabled_summary">Display priority notifications in a small floating window</string>

    <!-- Encryption password -->
    <string name="crypt_keeper_change_password_title">Change encryption password</string>
    <string name="crypt_keeper_change_password_summary">Change the password used for device encryption</string>
    <string name="crypt_keeper_choose_your_password_header">Set encryption password</string>
    <string name="crypt_keeper_replace_password_title">Replace encryption password</string>
    <string name="crypt_keeper_replace_password_summary">Remove the separate encryption password</string>

    <!-- Tethering & portable hotspot other category -->
    <string name="tethering_other_category_text">Other</string>
    <!-- Wi-Fi tethering inactivity timeout -->
+1 −20
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
                  android:title="@string/security_settings_title">

    <PreferenceCategory
        android:key="encryption_category"
        android:key="security_category"
        android:title="@string/crypt_keeper_settings_title">

        <Preference
@@ -30,24 +30,5 @@

    </PreferenceCategory>

    <Preference
        android:key="crypt_keeper_change_password"
        android:title="@string/crypt_keeper_change_password_title"
        android:summary="@string/crypt_keeper_change_password_summary">

        <intent android:action="android.intent.action.MAIN"
            android:targetPackage="com.android.settings"
            android:targetClass="com.android.settings.ChooseEncryptionPassword" />
    </Preference>

    <Preference
        android:key="crypt_keeper_replace_password"
        android:title="@string/crypt_keeper_replace_password_title"
        android:summary="@string/crypt_keeper_replace_password_summary">

        <intent android:action="android.intent.action.MAIN"
            android:targetPackage="com.android.settings"
            android:targetClass="com.android.settings.ReplaceEncryptionPassword" />
    </Preference>

</PreferenceScreen>
+0 −671

File deleted.

Preview size limit exceeded, changes collapsed.

+0 −101
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The CyanogenMod Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.settings;

import com.android.internal.widget.LockPatternUtils;
import com.android.internal.widget.LockPatternUtils.RequestThrottledException;

import android.app.Activity;
import android.app.Fragment;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.storage.StorageManager;
import android.os.UserHandle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class ReplaceEncryptionPassword extends SettingsActivity {
    @Override
    public Intent getIntent() {
        Intent modIntent = new Intent(super.getIntent());
        modIntent.putExtra(EXTRA_SHOW_FRAGMENT, getFragmentClass().getName());
        return modIntent;
    }

    @Override
    protected boolean isValidFragment(String fragmentName) {
        if (ReplaceEncryptionPasswordFragment.class.getName().equals(fragmentName)) return true;
        return false;
    }

    /* package */ Class<? extends Fragment> getFragmentClass() {
        return ReplaceEncryptionPasswordFragment.class;
    }

    public static class ReplaceEncryptionPasswordFragment extends Fragment {
        private static final int KEYGUARD_REQUEST = 55;

        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            if (!(getActivity() instanceof ReplaceEncryptionPassword)) {
                throw new SecurityException("Fragment contained in wrong activity");
            }
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
            Resources res = getActivity().getResources();
            ChooseLockSettingsHelper helper = new ChooseLockSettingsHelper(getActivity(), this);

            helper.launchConfirmationActivity(KEYGUARD_REQUEST,
                    res.getText(R.string.unlock_set_unlock_password_title),
                    true);

            return null;
        }

        @Override
        public void onActivityResult(int requestCode, int resultCode, Intent data) {
            super.onActivityResult(requestCode, resultCode, data);

            if (requestCode != KEYGUARD_REQUEST) {
                return;
            }

            // If the user entered a valid keyguard trace, present the final
            // confirmation prompt; otherwise, go back to the initial state.
            if (resultCode == Activity.RESULT_OK && data != null) {
                LockPatternUtils utils = new LockPatternUtils(getActivity());
                int type = data.getIntExtra(ChooseLockSettingsHelper.EXTRA_KEY_TYPE, -1);
                String password = data.getStringExtra(ChooseLockSettingsHelper.EXTRA_KEY_PASSWORD);
                if (type == StorageManager.CRYPT_TYPE_PATTERN) {
                    byte size = data.getByteExtra("pattern_size",
                            LockPatternUtils.PATTERN_SIZE_DEFAULT);
                    utils.replaceSeparateEncryptionPasswordWithPattern(
                            utils.stringToPattern(password, size), size);
                } else {
                    utils.replaceSeparateEncryptionPassword(password);
                }
            }

            getActivity().finish();
        }
    }
}
Loading