Add start-encryption intent filter to settings
* Add intent-filter for "android.app.action.START_ENCRYPTION" * Add pseudo-activity to host intent-filter * Add code to settings page that exits quickly when encryption is not available or is already started. This can be tested using ApiDemos -> App -> Device Admin Bug: 3346770 Change-Id: Ie97459cf9e2a7b09b690bf085e64ef905466e77a
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.settings;
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Fragment;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
@@ -90,7 +91,6 @@ public class CryptKeeperSettings extends Fragment {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
|
||||
mContentView = inflater.inflate(R.layout.crypt_keeper_settings, null);
|
||||
@@ -117,6 +117,28 @@ public class CryptKeeperSettings extends Fragment {
|
||||
getActivity().unregisterReceiver(mIntentReceiver);
|
||||
}
|
||||
|
||||
/**
|
||||
* If encryption is already started, and this launched via a "start encryption" intent,
|
||||
* then exit immediately - it's already up and running, so there's no point in "starting" it.
|
||||
*/
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
Activity activity = getActivity();
|
||||
Intent intent = activity.getIntent();
|
||||
if (DevicePolicyManager.ACTION_START_ENCRYPTION.equals(intent.getAction())) {
|
||||
DevicePolicyManager dpm = (DevicePolicyManager)
|
||||
activity.getSystemService(Context.DEVICE_POLICY_SERVICE);
|
||||
if (dpm != null) {
|
||||
int status = dpm.getStorageEncryptionStatus();
|
||||
if (status != DevicePolicyManager.ENCRYPTION_STATUS_INACTIVE) {
|
||||
// There is nothing to do here, so simply finish() (which returns to caller)
|
||||
activity.finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Keyguard validation is run using the standard {@link ConfirmLockPattern}
|
||||
* component as a subactivity
|
||||
|
Reference in New Issue
Block a user