summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2013-05-09 17:01:12 -0700
committerAmith Yamasani <yamasani@google.com>2013-05-09 17:07:08 -0700
commitecd5afe1ef4aa2a5d11ad4fa356fb6d5f461efb4 (patch)
tree66a1d61588c842837f1bc4b8d81675f3aa33d90f
parent2d4edcf2e1ef94ef83e02ec2ad075b3603282812 (diff)
parent069d7e9b81e17d31238e4d60420c3e31bb5e3b2f (diff)
downloadframeworks_base-ecd5afe1ef4aa2a5d11ad4fa356fb6d5f461efb4.zip
frameworks_base-ecd5afe1ef4aa2a5d11ad4fa356fb6d5f461efb4.tar.gz
frameworks_base-ecd5afe1ef4aa2a5d11ad4fa356fb6d5f461efb4.tar.bz2
resolved conflicts for merge of 069d7e9b to master
Change-Id: Ia8fd5de3d4cc275fd358132bcb2c198d1e7b6877
-rw-r--r--core/java/android/content/Intent.java3
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardCircleFramedDrawable.java15
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardMultiUserAvatar.java28
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java29
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java5
-rw-r--r--packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java15
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java6
-rw-r--r--policy/src/com/android/internal/policy/impl/keyguard/MultiUserAvatarCache.java42
-rw-r--r--services/java/com/android/server/pm/UserManagerService.java2
9 files changed, 137 insertions, 8 deletions
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 793736d..b2dfd8a 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -2566,8 +2566,7 @@ public class Intent implements Parcelable, Cloneable {
/**
* Broadcast sent to the system when a user's information changes. Carries an extra
* {@link #EXTRA_USER_HANDLE} to indicate which user's information changed.
- * This is only sent to registered receivers, not manifest receivers. It is sent to the user
- * whose information has changed.
+ * This is only sent to registered receivers, not manifest receivers. It is sent to all users.
* @hide
*/
public static final String ACTION_USER_INFO_CHANGED =
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardCircleFramedDrawable.java b/packages/Keyguard/src/com/android/keyguard/KeyguardCircleFramedDrawable.java
index ed3faea..63b61ad 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardCircleFramedDrawable.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardCircleFramedDrawable.java
@@ -100,6 +100,11 @@ class KeyguardCircleFramedDrawable extends Drawable {
mFramePath = new Path();
}
+ public void reset() {
+ mScale = 1f;
+ mPressed = false;
+ }
+
@Override
public void draw(Canvas canvas) {
// clear background
@@ -157,4 +162,14 @@ class KeyguardCircleFramedDrawable extends Drawable {
@Override
public void setColorFilter(ColorFilter cf) {
}
+
+ public boolean verifyParams(float iconSize, int frameColor, float stroke,
+ int frameShadowColor, float shadowRadius, int highlightColor) {
+ return mSize == iconSize
+ && mFrameColor == frameColor
+ && mStrokeWidth == stroke
+ && mFrameShadowColor == frameShadowColor
+ && mShadowRadius == shadowRadius
+ && mHighlightColor == highlightColor;
+ }
}
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardMultiUserAvatar.java b/packages/Keyguard/src/com/android/keyguard/KeyguardMultiUserAvatar.java
index 7ef5b26..afd68b4 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardMultiUserAvatar.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardMultiUserAvatar.java
@@ -130,8 +130,32 @@ class KeyguardMultiUserAvatar extends FrameLayout {
R.drawable.ic_contact_picture);
}
- mFramed = new KeyguardCircleFramedDrawable(icon, (int) mIconSize, mFrameColor, mStroke,
- mFrameShadowColor, mShadowRadius, mHighlightColor);
+ mFramed = (KeyguardCircleFramedDrawable)
+ KeyguardViewMediator.getAvatarCache().get(user.id);
+
+ // If we can't find it or the params don't match, create the drawable again
+ if (mFramed == null
+ || !mFramed.verifyParams(mIconSize, mFrameColor, mStroke, mFrameShadowColor,
+ mShadowRadius, mHighlightColor)) {
+ Bitmap icon = null;
+ try {
+ icon = BitmapFactory.decodeFile(rewriteIconPath(user.iconPath));
+ } catch (Exception e) {
+ if (DEBUG) Log.d(TAG, "failed to open profile icon " + user.iconPath, e);
+ }
+
+ if (icon == null) {
+ icon = BitmapFactory.decodeResource(mContext.getResources(),
+ com.android.internal.R.drawable.ic_contact_picture);
+ }
+
+ mFramed = new KeyguardCircleFramedDrawable(icon, (int) mIconSize, mFrameColor, mStroke,
+ mFrameShadowColor, mShadowRadius, mHighlightColor);
+ KeyguardViewMediator.getAvatarCache().put(user.id, mFramed);
+ }
+
+ mFramed.reset();
+
mUserImage.setImageDrawable(mFramed);
mUserName.setText(mUserInfo.name);
setOnClickListener(mUserSelector);
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 79d01dd..97039a8 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -89,6 +89,7 @@ public class KeyguardUpdateMonitor {
private static final int MSG_USER_SWITCH_COMPLETE = 314;
private static final int MSG_SET_CURRENT_CLIENT_ID = 315;
protected static final int MSG_SET_PLAYBACK_STATE = 316;
+ protected static final int MSG_USER_INFO_CHANGED = 317;
private static KeyguardUpdateMonitor sInstance;
@@ -176,6 +177,9 @@ public class KeyguardUpdateMonitor {
case MSG_SET_PLAYBACK_STATE:
handleSetPlaybackState(msg.arg1, msg.arg2, (Long) msg.obj);
break;
+ case MSG_USER_INFO_CHANGED:
+ handleUserInfoChanged(msg.arg1);
+ break;
}
}
};
@@ -278,6 +282,17 @@ public class KeyguardUpdateMonitor {
}
};
+ private final BroadcastReceiver mBroadcastAllReceiver = new BroadcastReceiver() {
+
+ public void onReceive(Context context, Intent intent) {
+ final String action = intent.getAction();
+ if (Intent.ACTION_USER_INFO_CHANGED.equals(action)) {
+ mHandler.sendMessage(mHandler.obtainMessage(MSG_USER_INFO_CHANGED,
+ intent.getIntExtra(Intent.EXTRA_USER_HANDLE, getSendingUserId()), 0));
+ }
+ }
+ };
+
/**
* When we receive a
* {@link com.android.internal.telephony.TelephonyIntents#ACTION_SIM_STATE_CHANGED} broadcast,
@@ -387,7 +402,6 @@ public class KeyguardUpdateMonitor {
return sInstance;
}
-
protected void handleSetGenerationId(int clientGeneration, boolean clearing, PendingIntent p) {
mDisplayClientState.clientGeneration = clientGeneration;
mDisplayClientState.clearing = clearing;
@@ -420,6 +434,15 @@ public class KeyguardUpdateMonitor {
}
}
+ private void handleUserInfoChanged(int userId) {
+ for (int i = 0; i < mCallbacks.size(); i++) {
+ KeyguardUpdateMonitorCallback cb = mCallbacks.get(i).get();
+ if (cb != null) {
+ cb.onUserInfoChanged(userId);
+ }
+ }
+ }
+
private KeyguardUpdateMonitor(Context context) {
mContext = context;
@@ -454,6 +477,10 @@ public class KeyguardUpdateMonitor {
bootCompleteFilter.addAction(Intent.ACTION_BOOT_COMPLETED);
context.registerReceiver(mBroadcastReceiver, bootCompleteFilter);
+ final IntentFilter userInfoFilter = new IntentFilter(Intent.ACTION_USER_INFO_CHANGED);
+ context.registerReceiverAsUser(mBroadcastAllReceiver, UserHandle.ALL, userInfoFilter,
+ null, null);
+
try {
ActivityManagerNative.getDefault().registerUserSwitchObserver(
new IUserSwitchObserver.Stub() {
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
index d3a582f..30b43f5 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardUpdateMonitorCallback.java
@@ -107,6 +107,11 @@ class KeyguardUpdateMonitorCallback {
void onUserRemoved(int userId) { }
/**
+ * Called when the user's info changed.
+ */
+ void onUserInfoChanged(int userId) { }
+
+ /**
* Called when boot completed.
*
* Note, this callback will only be received if boot complete occurs after registering with
diff --git a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java
index 78ff3a8..4ce0dcd 100644
--- a/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java
+++ b/packages/Keyguard/src/com/android/keyguard/KeyguardViewMediator.java
@@ -259,6 +259,11 @@ public class KeyguardViewMediator {
private final float mLockSoundVolume;
/**
+ * Cache of avatar drawables, for use by KeyguardMultiUserAvatar.
+ */
+ private static MultiUserAvatarCache sMultiUserAvatarCache = new MultiUserAvatarCache();
+
+ /**
* The callback used by the keyguard view to tell the {@link KeyguardViewMediator}
* various things.
*/
@@ -338,6 +343,12 @@ public class KeyguardViewMediator {
@Override
public void onUserRemoved(int userId) {
mLockPatternUtils.removeUser(userId);
+ sMultiUserAvatarCache.clear(userId);
+ }
+
+ @Override
+ public void onUserInfoChanged(int userId) {
+ sMultiUserAvatarCache.clear(userId);
}
@Override
@@ -1455,4 +1466,8 @@ public class KeyguardViewMediator {
return mSearchManager != null
&& mSearchManager.getAssistIntent(mContext, false, UserHandle.USER_CURRENT) != null;
}
+
+ public static MultiUserAvatarCache getAvatarCache() {
+ return sMultiUserAvatarCache;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
index d826282..df1eb67 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/QuickSettings.java
@@ -819,8 +819,10 @@ class QuickSettings {
if (ContactsContract.Intents.ACTION_PROFILE_CHANGED.equals(action) ||
Intent.ACTION_USER_INFO_CHANGED.equals(action)) {
try {
- final int userId = ActivityManagerNative.getDefault().getCurrentUser().id;
- if (getSendingUserId() == userId) {
+ final int currentUser = ActivityManagerNative.getDefault().getCurrentUser().id;
+ final int changedUser =
+ intent.getIntExtra(Intent.EXTRA_USER_HANDLE, getSendingUserId());
+ if (changedUser == currentUser) {
reloadUserInfo();
}
} catch (RemoteException e) {
diff --git a/policy/src/com/android/internal/policy/impl/keyguard/MultiUserAvatarCache.java b/policy/src/com/android/internal/policy/impl/keyguard/MultiUserAvatarCache.java
new file mode 100644
index 0000000..7969c7d
--- /dev/null
+++ b/policy/src/com/android/internal/policy/impl/keyguard/MultiUserAvatarCache.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2013 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.internal.policy.impl.keyguard;
+
+import android.graphics.drawable.Drawable;
+
+import java.util.HashMap;
+
+public class MultiUserAvatarCache {
+
+ private final HashMap<Integer, Drawable> mCache;
+
+ public MultiUserAvatarCache() {
+ mCache = new HashMap<Integer, Drawable>();
+ }
+
+ public void clear(int userId) {
+ mCache.remove(userId);
+ }
+
+ public Drawable get(int userId) {
+ return mCache.get(userId);
+ }
+
+ public void put(int userId, Drawable image) {
+ mCache.put(userId, image);
+ }
+}
diff --git a/services/java/com/android/server/pm/UserManagerService.java b/services/java/com/android/server/pm/UserManagerService.java
index 11c6dab..1323c93 100644
--- a/services/java/com/android/server/pm/UserManagerService.java
+++ b/services/java/com/android/server/pm/UserManagerService.java
@@ -296,7 +296,7 @@ public class UserManagerService extends IUserManager.Stub {
Intent changedIntent = new Intent(Intent.ACTION_USER_INFO_CHANGED);
changedIntent.putExtra(Intent.EXTRA_USER_HANDLE, userId);
changedIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
- mContext.sendBroadcastAsUser(changedIntent, new UserHandle(userId));
+ mContext.sendBroadcastAsUser(changedIntent, UserHandle.ALL);
}
@Override