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
diff --git a/res/layout/convert_fbe.xml b/res/layout/convert_fbe.xml
new file mode 100644
index 0000000..4a9d7c0
--- /dev/null
+++ b/res/layout/convert_fbe.xml
@@ -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>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index aef3f78..2d2b9ac 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2010,6 +2010,18 @@
<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] -->
<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 -->
<string name="screen_timeout">Sleep</string>
<!-- Sound & display settings screen, setting option name to change screen timeout [CHAR LIMIT=30] -->
diff --git a/res/xml/development_prefs.xml b/res/xml/development_prefs.xml
index 8417e48..1770f13 100644
--- a/res/xml/development_prefs.xml
+++ b/res/xml/development_prefs.xml
@@ -67,6 +67,12 @@
android:entries="@array/night_mode_entries"
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
android:key="color_mode"
android:title="@string/picture_color_mode"
diff --git a/src/com/android/settings/DevelopmentSettings.java b/src/com/android/settings/DevelopmentSettings.java
index 756cac2..5d578eb 100644
--- a/src/com/android/settings/DevelopmentSettings.java
+++ b/src/com/android/settings/DevelopmentSettings.java
@@ -53,6 +53,7 @@
import android.os.StrictMode;
import android.os.SystemProperties;
import android.os.UserManager;
+import android.os.storage.IMountService;
import android.provider.SearchIndexableResource;
import android.provider.Settings;
import android.provider.Settings.Global;
@@ -175,6 +176,7 @@
private static final String TERMINAL_APP_PACKAGE = "com.android.terminal";
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_MOCK_LOCATION_APP = 1001;
@@ -407,6 +409,16 @@
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);
final UiModeManager uiManager = (UiModeManager) getSystemService(
Context.UI_MODE_SERVICE);
diff --git a/src/com/android/settings/applications/ConvertToFBE.java b/src/com/android/settings/applications/ConvertToFBE.java
new file mode 100644
index 0000000..e514942
--- /dev/null
+++ b/src/com/android/settings/applications/ConvertToFBE.java
@@ -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;
+ }
+}