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:
@@ -1080,6 +1080,21 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
|
<!-- Pseudo-activity used to provide an intent-filter entry point to encryption settings -->
|
||||||
|
<activity android:name="Settings$CryptKeeperSettingsActivity"
|
||||||
|
android:theme="@android:style/Theme.Holo"
|
||||||
|
android:label="@string/crypt_keeper_encrypt_title">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.MAIN" />
|
||||||
|
<action android:name="android.app.action.START_ENCRYPTION" />
|
||||||
|
<category android:name="android.intent.category.DEFAULT" /> />
|
||||||
|
</intent-filter>
|
||||||
|
<meta-data android:name="com.android.settings.FRAGMENT_CLASS"
|
||||||
|
android:value="com.android.settings.CryptKeeperSettings" />
|
||||||
|
<meta-data android:name="com.android.settings.TOP_LEVEL_HEADER_ID"
|
||||||
|
android:resource="@id/security_settings" />
|
||||||
|
</activity>
|
||||||
|
|
||||||
<receiver android:name=".widget.SettingsAppWidgetProvider"
|
<receiver android:name=".widget.SettingsAppWidgetProvider"
|
||||||
android:label="@string/gadget_title"
|
android:label="@string/gadget_title"
|
||||||
android:exported="false"
|
android:exported="false"
|
||||||
|
@@ -19,6 +19,7 @@ package com.android.settings;
|
|||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.AlertDialog;
|
import android.app.AlertDialog;
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.BroadcastReceiver;
|
import android.content.BroadcastReceiver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
@@ -90,7 +91,6 @@ public class CryptKeeperSettings extends Fragment {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) {
|
||||||
mContentView = inflater.inflate(R.layout.crypt_keeper_settings, null);
|
mContentView = inflater.inflate(R.layout.crypt_keeper_settings, null);
|
||||||
@@ -117,6 +117,28 @@ public class CryptKeeperSettings extends Fragment {
|
|||||||
getActivity().unregisterReceiver(mIntentReceiver);
|
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}
|
* Keyguard validation is run using the standard {@link ConfirmLockPattern}
|
||||||
* component as a subactivity
|
* component as a subactivity
|
||||||
|
@@ -332,4 +332,5 @@ public class Settings extends PreferenceActivity implements ButtonBarHandler {
|
|||||||
public static class PowerUsageSummaryActivity extends Settings { }
|
public static class PowerUsageSummaryActivity extends Settings { }
|
||||||
public static class AccountSyncSettingsActivity extends Settings { }
|
public static class AccountSyncSettingsActivity extends Settings { }
|
||||||
public static class AccountSyncSettingsInAddAccountActivity extends Settings { }
|
public static class AccountSyncSettingsInAddAccountActivity extends Settings { }
|
||||||
|
public static class CryptKeeperSettingsActivity extends Settings { }
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user