Make Convert To File Encryption work
Actually call to recovery from ConvertToFBE Adding credential check Gray out Convert option when converted Change-Id: Ic98929ff49733d182b529012e58870156f40679a
This commit is contained in:
@@ -2009,14 +2009,17 @@
|
||||
|
||||
<!-- 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_enabled">Convert\u2026</string>
|
||||
<string name="convert_to_file_encryption_done">Already file encrypted</string>
|
||||
<!-- Title used on dialog with final prompt for converting to file encryption -->
|
||||
<string name="title_convert_fbe">Converting to file based encryption</string>
|
||||
<!-- Warning displayed on dialog with final prompt for converting to file encryption -->
|
||||
<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>
|
||||
Press \'Wipe and convert\u2026\' to continue.</string>
|
||||
<string name="button_convert_fbe">Wipe and convert\u2026</string>
|
||||
|
||||
<!-- Sound & display settings screen, setting option name to change screen timeout -->
|
||||
<string name="screen_timeout">Sleep</string>
|
||||
|
@@ -71,7 +71,7 @@
|
||||
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" />
|
||||
android:fragment="com.android.settings.applications.ConvertToFbe" />
|
||||
|
||||
<com.android.settings.ColorModePreference
|
||||
android:key="color_mode"
|
||||
|
@@ -59,7 +59,7 @@ public final class ChooseLockSettingsHelper {
|
||||
* @return true if one exists and we launched an activity to confirm it
|
||||
* @see Activity#onActivityResult(int, int, android.content.Intent)
|
||||
*/
|
||||
boolean launchConfirmationActivity(int request, CharSequence title) {
|
||||
public boolean launchConfirmationActivity(int request, CharSequence title) {
|
||||
return launchConfirmationActivity(request, title, null, null, false, false);
|
||||
}
|
||||
|
||||
|
@@ -409,11 +409,18 @@ public class DevelopmentSettings extends SettingsPreferenceFragment
|
||||
removePreferenceForProduction(hdcpChecking);
|
||||
}
|
||||
|
||||
PreferenceScreen convertFbePreference =
|
||||
(PreferenceScreen) findPreference(KEY_CONVERT_FBE);
|
||||
|
||||
try {
|
||||
IBinder service = ServiceManager.getService("mount");
|
||||
IMountService mountService = IMountService.Stub.asInterface(service);
|
||||
if (!mountService.isConvertibleToFBE()) {
|
||||
removePreference(KEY_CONVERT_FBE);
|
||||
} else if (mountService.isPerUserEncryptionEnabled()) {
|
||||
convertFbePreference.setEnabled(false);
|
||||
convertFbePreference.setSummary(getResources()
|
||||
.getString(R.string.convert_to_file_encryption_done));
|
||||
}
|
||||
} catch(RemoteException e) {
|
||||
removePreference(KEY_CONVERT_FBE);
|
||||
|
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
}
|
88
src/com/android/settings/applications/ConvertToFbe.java
Normal file
88
src/com/android/settings/applications/ConvertToFbe.java
Normal file
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.Activity;
|
||||
import android.app.Fragment;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.os.Bundle;
|
||||
import android.os.RecoverySystem;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
|
||||
import com.android.settings.ChooseLockSettingsHelper;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.R;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/* Class to prompt for conversion of userdata to file based encryption
|
||||
*/
|
||||
public class ConvertToFbe extends Fragment {
|
||||
static final String TAG = "ConvertToFBE";
|
||||
static final String CONVERT_FBE_EXTRA = "ConvertFBE";
|
||||
private static final int KEYGUARD_REQUEST = 55;
|
||||
|
||||
private boolean runKeyguardConfirmation(int request) {
|
||||
Resources res = getActivity().getResources();
|
||||
return new ChooseLockSettingsHelper(getActivity(), this)
|
||||
.launchConfirmationActivity(request,
|
||||
res.getText(R.string.convert_to_file_encryption));
|
||||
}
|
||||
|
||||
@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) {
|
||||
if(!runKeyguardConfirmation(KEYGUARD_REQUEST)) {
|
||||
convert();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return rootView;
|
||||
}
|
||||
|
||||
@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 credential, start the conversion
|
||||
// process
|
||||
if (resultCode == Activity.RESULT_OK) {
|
||||
convert();
|
||||
}
|
||||
}
|
||||
|
||||
private void convert() {
|
||||
Intent intent = new Intent(Intent.ACTION_MASTER_CLEAR);
|
||||
intent.addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
|
||||
intent.putExtra(Intent.EXTRA_REASON, "convert_fbe");
|
||||
getActivity().sendBroadcast(intent);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user