diff options
author | Amith Yamasani <yamasani@google.com> | 2012-12-05 06:06:02 -0800 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2012-12-05 06:06:02 -0800 |
commit | 368ee53f25cdff7ea89293d2cc81e95816919369 (patch) | |
tree | af3fa58df3ab0124681e54f3c6bef26e13f56bc4 /core/java/android/appwidget/AppWidgetHost.java | |
parent | 6350cfb529b30af88a2bff42962ab111a0cf137b (diff) | |
parent | f663cad2248d5d38957f8e1408cd794c0de90202 (diff) | |
download | frameworks_base-368ee53f25cdff7ea89293d2cc81e95816919369.zip frameworks_base-368ee53f25cdff7ea89293d2cc81e95816919369.tar.gz frameworks_base-368ee53f25cdff7ea89293d2cc81e95816919369.tar.bz2 |
am f663cad2: am 6c58b155: Merge "Make 3rd party lockscreen widgets work on secondary users" into jb-mr1.1-dev
* commit 'f663cad2248d5d38957f8e1408cd794c0de90202':
Make 3rd party lockscreen widgets work on secondary users
Diffstat (limited to 'core/java/android/appwidget/AppWidgetHost.java')
-rw-r--r-- | core/java/android/appwidget/AppWidgetHost.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/core/java/android/appwidget/AppWidgetHost.java b/core/java/android/appwidget/AppWidgetHost.java index 6a99ccd..fa3bf4d 100644 --- a/core/java/android/appwidget/AppWidgetHost.java +++ b/core/java/android/appwidget/AppWidgetHost.java @@ -60,6 +60,7 @@ public class AppWidgetHost { public void updateAppWidget(int appWidgetId, RemoteViews views) { if (isLocalBinder() && views != null) { views = views.clone(); + views.setUser(mUser); } Message msg = mHandler.obtainMessage(HANDLE_UPDATE); msg.arg1 = appWidgetId; @@ -123,6 +124,8 @@ public class AppWidgetHost { Callbacks mCallbacks = new Callbacks(); final HashMap<Integer,AppWidgetHostView> mViews = new HashMap<Integer, AppWidgetHostView>(); private OnClickHandler mOnClickHandler; + // Optionally set by lockscreen + private UserHandle mUser; public AppWidgetHost(Context context, int hostId) { this(context, hostId, null, context.getMainLooper()); @@ -137,9 +140,15 @@ public class AppWidgetHost { mOnClickHandler = handler; mHandler = new UpdateHandler(looper); mDisplayMetrics = context.getResources().getDisplayMetrics(); + mUser = Process.myUserHandle(); bindService(); } + /** @hide */ + public void setUserId(int userId) { + mUser = new UserHandle(userId); + } + private static void bindService() { synchronized (sServiceLock) { if (sService == null) { @@ -179,6 +188,9 @@ public class AppWidgetHost { final int N = updatedIds.length; for (int i=0; i<N; i++) { + if (updatedViews.get(i) != null) { + updatedViews.get(i).setUser(new UserHandle(userId)); + } updateAppWidgetView(updatedIds[i], updatedViews.get(i)); } } @@ -350,6 +362,7 @@ public class AppWidgetHost { public final AppWidgetHostView createView(Context context, int appWidgetId, AppWidgetProviderInfo appWidget) { AppWidgetHostView view = onCreateView(context, appWidgetId, appWidget); + view.setUserId(mUser.getIdentifier()); view.setOnClickHandler(mOnClickHandler); view.setAppWidget(appWidgetId, appWidget); synchronized (mViews) { @@ -358,6 +371,9 @@ public class AppWidgetHost { RemoteViews views; try { views = sService.getAppWidgetViews(appWidgetId); + if (views != null) { + views.setUser(mUser); + } } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); } |