summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/res/res/layout/keyguard_multi_user_selector_widget.xml1
-rw-r--r--core/res/res/values/symbols.xml1
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java4
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardMultiUserAvatar.java10
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java28
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java27
6 files changed, 46 insertions, 25 deletions
diff --git a/core/res/res/layout/keyguard_multi_user_selector_widget.xml b/core/res/res/layout/keyguard_multi_user_selector_widget.xml
index c00089cf1478..ad9fdfee4849 100644
--- a/core/res/res/layout/keyguard_multi_user_selector_widget.xml
+++ b/core/res/res/layout/keyguard_multi_user_selector_widget.xml
@@ -20,6 +20,7 @@
<!-- This is a view that shows general status information in Keyguard. -->
<com.android.internal.policy.impl.keyguard.KeyguardWidgetFrame
xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/keyguard_multi_user_selector"
android:layout_width="match_parent"
android:layout_height="match_parent">
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 4c311a9119c8..b295a6ab784c 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -1299,6 +1299,7 @@
<java-symbol type="id" name="kg_widget_region" />
<java-symbol type="id" name="left_strip" />
<java-symbol type="id" name="right_strip" />
+ <java-symbol type="id" name="keyguard_multi_user_selector" />
<java-symbol type="integer" name="config_carDockRotation" />
<java-symbol type="integer" name="config_defaultUiModeType" />
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
index 8e7e07f7b9d6..117877d2085a 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java
@@ -820,4 +820,8 @@ public class KeyguardHostView extends KeyguardViewBase {
}
}
+ public void goToUserSwitcher() {
+ mAppWidgetContainer.setCurrentPage(getWidgetPosition(R.id.keyguard_multi_user_selector));
+ }
+
}
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMultiUserAvatar.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMultiUserAvatar.java
index c89785e68afb..a034f4c52977 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMultiUserAvatar.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardMultiUserAvatar.java
@@ -71,10 +71,6 @@ class KeyguardMultiUserAvatar extends FrameLayout {
public KeyguardMultiUserAvatar(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
-
- Resources res = context.getResources();
- mActiveTextColor = res.getColor(R.color.kg_multi_user_text_active);
- mInactiveTextColor = res.getColor(R.color.kg_multi_user_text_inactive);
}
public void setup(UserInfo user, KeyguardMultiUserSelectorView userSelector) {
@@ -84,8 +80,12 @@ class KeyguardMultiUserAvatar extends FrameLayout {
}
private void init() {
+ Resources res = mContext.getResources();
+ mActiveTextColor = res.getColor(R.color.kg_multi_user_text_active);
+ mInactiveTextColor = res.getColor(R.color.kg_multi_user_text_inactive);
+
mUserImage = (ImageView) findViewById(R.id.keyguard_user_avatar);
- mUserName = (TextView) findViewById(R.id.keyguard_user_name);
+ mUserName = (TextView) findViewById(R.id.keyguard_user_name);
mUserImage.setImageDrawable(Drawable.createFromPath(mUserInfo.iconPath));
mUserName.setText(mUserInfo.name);
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
index a3a9c5f56819..c4f761f8456c 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewManager.java
@@ -24,9 +24,11 @@ import android.content.res.Configuration;
import android.content.res.Resources;
import android.graphics.PixelFormat;
import android.os.IBinder;
+import android.os.Parcelable;
import android.os.SystemProperties;
import android.util.Log;
import android.util.Slog;
+import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -89,7 +91,7 @@ public class KeyguardViewManager {
boolean enableScreenRotation = shouldEnableScreenRotation();
- maybeCreateKeyguardLocked(enableScreenRotation);
+ maybeCreateKeyguardLocked(enableScreenRotation, false);
maybeEnableScreenRotation(enableScreenRotation);
// Disable common aspects of the system/status/navigation bars that are not appropriate or
@@ -120,13 +122,19 @@ public class KeyguardViewManager {
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
- maybeCreateKeyguardLocked(shouldEnableScreenRotation());
+ maybeCreateKeyguardLocked(shouldEnableScreenRotation(), false);
}
}
- private void maybeCreateKeyguardLocked(boolean enableScreenRotation) {
+ SparseArray<Parcelable> mStateContainer = new SparseArray<Parcelable>();
+
+ private void maybeCreateKeyguardLocked(boolean enableScreenRotation, boolean userSwitched) {
final boolean isActivity = (mContext instanceof Activity); // for test activity
+ if (mKeyguardHost != null) {
+ mKeyguardHost.saveHierarchyState(mStateContainer);
+ }
+
if (mKeyguardHost == null) {
if (DEBUG) Log.d(TAG, "keyguard host is null, creating it...");
@@ -161,11 +169,13 @@ public class KeyguardViewManager {
mWindowLayoutParams = lp;
mViewManager.addView(mKeyguardHost, lp);
}
- inflateKeyguardView();
+ inflateKeyguardView(userSwitched);
mViewManager.updateViewLayout(mKeyguardHost, mWindowLayoutParams);
+
+ mKeyguardHost.restoreHierarchyState(mStateContainer);
}
- private void inflateKeyguardView() {
+ private void inflateKeyguardView(boolean userSwitched) {
View v = mKeyguardHost.findViewById(R.id.keyguard_host_view);
if (v != null) {
mKeyguardHost.removeView(v);
@@ -179,6 +189,10 @@ public class KeyguardViewManager {
mKeyguardView.setLockPatternUtils(mLockPatternUtils);
mKeyguardView.setViewMediatorCallback(mViewMediatorCallback);
+ if (userSwitched) {
+ mKeyguardView.goToUserSwitcher();
+ }
+
if (mScreenOn) {
mKeyguardView.show();
}
@@ -219,11 +233,11 @@ public class KeyguardViewManager {
/**
* Reset the state of the view.
*/
- public synchronized void reset() {
+ public synchronized void reset(boolean userSwitched) {
if (DEBUG) Log.d(TAG, "reset()");
// User might have switched, check if we need to go back to keyguard
// TODO: It's preferable to stay and show the correct lockscreen or unlock if none
- maybeCreateKeyguardLocked(shouldEnableScreenRotation());
+ maybeCreateKeyguardLocked(shouldEnableScreenRotation(), userSwitched);
}
public synchronized void onScreenTurnedOff() {
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
index 59aed2432322..83324bc4e715 100644
--- a/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
+++ b/policy/src/com/android/internal/policy/impl/keyguard/KeyguardViewMediator.java
@@ -291,7 +291,7 @@ public class KeyguardViewMediator {
public void onUserSwitched(int userId) {
// Note that the mLockPatternUtils user has already been updated from setCurrentUser.
synchronized (KeyguardViewMediator.this) {
- resetStateLocked();
+ resetStateLocked(true);
}
// We should always go back to the locked state when a user
// switch happens. Is there a more direct way to do this?
@@ -351,7 +351,7 @@ public class KeyguardViewMediator {
+ "device isn't provisioned yet.");
doKeyguardLocked();
} else {
- resetStateLocked();
+ resetStateLocked(false);
}
}
}
@@ -364,7 +364,7 @@ public class KeyguardViewMediator {
+ "showing; need to show keyguard so user can enter sim pin");
doKeyguardLocked();
} else {
- resetStateLocked();
+ resetStateLocked(false);
}
}
break;
@@ -377,14 +377,14 @@ public class KeyguardViewMediator {
} else {
if (DEBUG) Log.d(TAG, "PERM_DISABLED, resetStateLocked to"
+ "show permanently disabled message in lockscreen.");
- resetStateLocked();
+ resetStateLocked(false);
}
}
break;
case READY:
synchronized (this) {
if (isShowing()) {
- resetStateLocked();
+ resetStateLocked(false);
}
}
break;
@@ -530,7 +530,7 @@ public class KeyguardViewMediator {
}
} else if (mShowing) {
notifyScreenOffLocked();
- resetStateLocked();
+ resetStateLocked(false);
} else if (why == WindowManagerPolicy.OFF_BECAUSE_OF_TIMEOUT
|| (why == WindowManagerPolicy.OFF_BECAUSE_OF_USER && !lockImmediately)) {
// if the screen turned off because of timeout or the user hit the power button
@@ -644,7 +644,7 @@ public class KeyguardViewMediator {
if (DEBUG) Log.d(TAG, "onKeyguardExitResult(false), resetting");
mExitSecureCallback.onKeyguardExitResult(false);
mExitSecureCallback = null;
- resetStateLocked();
+ resetStateLocked(false);
} else {
showLocked();
@@ -805,11 +805,12 @@ public class KeyguardViewMediator {
/**
* Send message to keyguard telling it to reset its state.
+ * @param userSwitched true if we're resetting state because user switched
* @see #handleReset()
*/
- private void resetStateLocked() {
+ private void resetStateLocked(boolean userSwitched) {
if (DEBUG) Log.d(TAG, "resetStateLocked");
- Message msg = mHandler.obtainMessage(RESET);
+ Message msg = mHandler.obtainMessage(RESET, userSwitched ? 1 : 0, 0);
mHandler.sendMessage(msg);
}
@@ -1046,7 +1047,7 @@ public class KeyguardViewMediator {
handleHide();
return ;
case RESET:
- handleReset();
+ handleReset(msg.arg1 != 0);
return ;
case VERIFY_UNLOCK:
handleVerifyUnlock();
@@ -1289,13 +1290,13 @@ public class KeyguardViewMediator {
}
/**
- * Handle message sent by {@link #resetStateLocked()}
+ * Handle message sent by {@link #resetStateLocked(boolean)}
* @see #RESET
*/
- private void handleReset() {
+ private void handleReset(boolean userSwitched) {
synchronized (KeyguardViewMediator.this) {
if (DEBUG) Log.d(TAG, "handleReset");
- mKeyguardViewManager.reset();
+ mKeyguardViewManager.reset(userSwitched);
}
}