summaryrefslogtreecommitdiffstats
path: root/src/com/android/settings/CryptKeeper.java
diff options
context:
space:
mode:
authorFyodor Kupolov <fkupolov@google.com>2014-12-08 16:13:11 -0800
committerFyodor Kupolov <fkupolov@google.com>2014-12-16 02:48:36 +0000
commit1b5cc427f06019936e40ee8e43ae931b8752eb11 (patch)
tree51efe9ffbd542b8f6ed18aa41204ca5d271a6493 /src/com/android/settings/CryptKeeper.java
parenta754c6ba05cf9d693a7d65342310ec05a6fd2ca0 (diff)
downloadpackages_apps_Settings-1b5cc427f06019936e40ee8e43ae931b8752eb11.zip
packages_apps_Settings-1b5cc427f06019936e40ee8e43ae931b8752eb11.tar.gz
packages_apps_Settings-1b5cc427f06019936e40ee8e43ae931b8752eb11.tar.bz2
Disable CryptKeeper activity for secondary users
For secondary users, disable CryptKeeper activity in a broadcast receiver of USER_INITIALIZE intent. This change has the following benefits for guest user switching: - The code will be executed earlier in the user switching flow, when the screen is frozen by WindowManager. - Initialization of CryptKeeperActivity is skipped Bug:18670536 Change-Id: I60300198b605c26ad15afe2c874d5f1be7da5087
Diffstat (limited to 'src/com/android/settings/CryptKeeper.java')
-rw-r--r--src/com/android/settings/CryptKeeper.java29
1 files changed, 24 insertions, 5 deletions
diff --git a/src/com/android/settings/CryptKeeper.java b/src/com/android/settings/CryptKeeper.java
index f08ed5a..08bdc42 100644
--- a/src/com/android/settings/CryptKeeper.java
+++ b/src/com/android/settings/CryptKeeper.java
@@ -17,7 +17,9 @@
package com.android.settings;
import android.app.Activity;
+import android.app.ActivityManager;
import android.app.StatusBarManager;
+import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -408,11 +410,7 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
// If we are not encrypted or encrypting, get out quickly.
final String state = SystemProperties.get("vold.decrypt");
if (!isDebugView() && ("".equals(state) || DECRYPT_STATE.equals(state))) {
- // Disable the crypt keeper.
- PackageManager pm = getPackageManager();
- ComponentName name = new ComponentName(this, CryptKeeper.class);
- pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
- PackageManager.DONT_KILL_APP);
+ disableCryptKeeperComponent(this);
// Typically CryptKeeper is launched as the home app. We didn't
// want to be running, so need to finish this activity. We can count
// on the activity manager re-launching the new home app upon finishing
@@ -1021,4 +1019,25 @@ public class CryptKeeper extends Activity implements TextView.OnEditorActionList
public void afterTextChanged(Editable s) {
return;
}
+
+ private static void disableCryptKeeperComponent(Context context) {
+ PackageManager pm = context.getPackageManager();
+ ComponentName name = new ComponentName(context, CryptKeeper.class);
+ Log.d(TAG, "Disabling component " + name);
+ pm.setComponentEnabledSetting(name, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
+ PackageManager.DONT_KILL_APP);
+ }
+
+ public static class UserInitBroadcastReceiver extends BroadcastReceiver {
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ final String intentAction = intent.getAction();
+ // Disable CryptKeeper activity if user is not primary
+ if (Intent.ACTION_USER_INITIALIZE.equals(intentAction)
+ && UserHandle.USER_OWNER != UserHandle.myUserId()) {
+ disableCryptKeeperComponent(context);
+ }
+ }
+ }
}