Add developer option to convert from FDE to FBE

This set of changes adds the screen that offers this conversion,
and the plumbing so the option is only available on suitable
devices.

It does not implement the conversion mechanism.

Change-Id: I3c84dd40dfcb0e00dadbab54ba0e56e1ccb11ed8
This commit is contained in:
Paul Lawrence
2015-11-02 12:42:42 -08:00
parent 77c69c5a22
commit acbac8cdfe
5 changed files with 121 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2015 The Android Open Source 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.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:layout_marginBottom="12dp" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginEnd="12dp"
android:layout_marginTop="12dp"
android:textSize="18sp"
android:text="@string/convert_to_fbe_warning" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/button_convert_fbe"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginBottom="12dp"
android:text="@string/button_convert_fbe" />
</LinearLayout>
</LinearLayout>

View File

@@ -2010,6 +2010,18 @@
<string name="night_mode_yes">Always on</string> <string name="night_mode_yes">Always on</string>
<!-- Sound & display settings screen, theme setting value to automatically switch between a light- or dark-colored user interface [CHAR LIMIT=30] --> <!-- Sound & display settings screen, theme setting value to automatically switch between a light- or dark-colored user interface [CHAR LIMIT=30] -->
<string name="night_mode_auto">Automatic</string> <string name="night_mode_auto">Automatic</string>
<!-- Option to convert userdata to file encryption on Nexus M devices -->
<string name="convert_to_file_encryption">Convert to file encryption</string>
<string name="convert_to_file_encryption_enabled">Convert ...</string>
<string name="convert_to_file_encryption_done">Already file encrypted</string>
<string name="convert_to_fbe_warning">
Convert data partition to file based encryption.\n
!!Warning!! This will erase all your data.\n
This feature is alpha, and may not work correctly.\n
Press \'Wipe and convert...\' to continue.</string>
<string name="button_convert_fbe">Wipe and convert...</string>
<!-- Sound & display settings screen, setting option name to change screen timeout --> <!-- Sound & display settings screen, setting option name to change screen timeout -->
<string name="screen_timeout">Sleep</string> <string name="screen_timeout">Sleep</string>
<!-- Sound & display settings screen, setting option name to change screen timeout [CHAR LIMIT=30] --> <!-- Sound & display settings screen, setting option name to change screen timeout [CHAR LIMIT=30] -->

View File

@@ -67,6 +67,12 @@
android:entries="@array/night_mode_entries" android:entries="@array/night_mode_entries"
android:entryValues="@array/night_mode_values" /> android:entryValues="@array/night_mode_values" />
<PreferenceScreen
android:key="convert_to_file_encryption"
android:title="@string/convert_to_file_encryption"
android:summary="@string/convert_to_file_encryption_enabled"
android:fragment="com.android.settings.applications.ConvertToFBE" />
<com.android.settings.ColorModePreference <com.android.settings.ColorModePreference
android:key="color_mode" android:key="color_mode"
android:title="@string/picture_color_mode" android:title="@string/picture_color_mode"

View File

@@ -53,6 +53,7 @@ import android.os.ServiceManager;
import android.os.StrictMode; import android.os.StrictMode;
import android.os.SystemProperties; import android.os.SystemProperties;
import android.os.UserManager; import android.os.UserManager;
import android.os.storage.IMountService;
import android.provider.SearchIndexableResource; import android.provider.SearchIndexableResource;
import android.provider.Settings; import android.provider.Settings;
import android.provider.Settings.Global; import android.provider.Settings.Global;
@@ -175,6 +176,7 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
private static final String TERMINAL_APP_PACKAGE = "com.android.terminal"; private static final String TERMINAL_APP_PACKAGE = "com.android.terminal";
private static final String KEY_NIGHT_MODE = "night_mode"; private static final String KEY_NIGHT_MODE = "night_mode";
private static final String KEY_CONVERT_FBE = "convert_to_file_encryption";
private static final int RESULT_DEBUG_APP = 1000; private static final int RESULT_DEBUG_APP = 1000;
private static final int RESULT_MOCK_LOCATION_APP = 1001; private static final int RESULT_MOCK_LOCATION_APP = 1001;
@@ -407,6 +409,16 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
removePreferenceForProduction(hdcpChecking); removePreferenceForProduction(hdcpChecking);
} }
try {
IBinder service = ServiceManager.getService("mount");
IMountService mountService = IMountService.Stub.asInterface(service);
if (!mountService.isConvertibleToFBE()) {
removePreference(KEY_CONVERT_FBE);
}
} catch(RemoteException e) {
removePreference(KEY_CONVERT_FBE);
}
mNightModePreference = (DropDownPreference) findPreference(KEY_NIGHT_MODE); mNightModePreference = (DropDownPreference) findPreference(KEY_NIGHT_MODE);
final UiModeManager uiManager = (UiModeManager) getSystemService( final UiModeManager uiManager = (UiModeManager) getSystemService(
Context.UI_MODE_SERVICE); Context.UI_MODE_SERVICE);

View File

@@ -0,0 +1,45 @@
/*
* Copyright (C) 2015 The Android Open Source 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.applications;
import android.app.Fragment;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import com.android.settings.R;
/* Class to prompt for conversion of userdata to file based encryption
*/
public class ConvertToFBE extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.convert_fbe, null);
final Button button = (Button) rootView.findViewById(R.id.button_convert_fbe);
button.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Perform action on click
}
});
return rootView;
}
}