Loading core/java/android/appwidget/AppWidgetHost.java +16 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()); Loading @@ -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) { Loading Loading @@ -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)); } } Loading Loading @@ -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) { Loading @@ -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); } Loading core/java/android/appwidget/AppWidgetHostView.java +13 −4 Original line number Diff line number Diff line Loading @@ -31,7 +31,9 @@ import android.os.Build; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.os.Process; import android.os.SystemClock; import android.os.UserHandle; import android.util.AttributeSet; import android.util.Log; import android.util.SparseArray; Loading Loading @@ -85,6 +87,7 @@ public class AppWidgetHostView extends FrameLayout { Bitmap mOld; Paint mOldPaint = new Paint(); private OnClickHandler mOnClickHandler; private UserHandle mUser; /** * Create a host view. Uses default fade animations. Loading Loading @@ -112,12 +115,17 @@ public class AppWidgetHostView extends FrameLayout { public AppWidgetHostView(Context context, int animationIn, int animationOut) { super(context); mContext = context; mUser = Process.myUserHandle(); // We want to segregate the view ids within AppWidgets to prevent // problems when those ids collide with view ids in the AppWidgetHost. setIsRootNamespace(true); } /** @hide */ public void setUserId(int userId) { mUser = new UserHandle(userId); } /** * Pass the given handler to RemoteViews when updating this widget. Unless this * is done immediatly after construction, a call to {@link #updateAppWidget(RemoteViews)} Loading Loading @@ -465,7 +473,8 @@ public class AppWidgetHostView extends FrameLayout { try { // Return if cloned successfully, otherwise default return mContext.createPackageContext(packageName, Context.CONTEXT_RESTRICTED); return mContext.createPackageContextAsUser(packageName, Context.CONTEXT_RESTRICTED, mUser); } catch (NameNotFoundException e) { Log.e(TAG, "Package name " + packageName + " not found"); return mContext; Loading Loading @@ -539,8 +548,8 @@ public class AppWidgetHostView extends FrameLayout { try { if (mInfo != null) { Context theirContext = mContext.createPackageContext( mInfo.provider.getPackageName(), Context.CONTEXT_RESTRICTED); Context theirContext = mContext.createPackageContextAsUser( mInfo.provider.getPackageName(), Context.CONTEXT_RESTRICTED, mUser); mRemoteContext = theirContext; LayoutInflater inflater = (LayoutInflater) theirContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); Loading core/java/android/widget/RemoteViewsAdapter.java +1 −0 Original line number Diff line number Diff line Loading @@ -1001,6 +1001,7 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback long itemId = 0; try { remoteViews = factory.getViewAt(position); remoteViews.setUser(new UserHandle(mUserId)); itemId = factory.getItemId(position); } catch (RemoteException e) { Log.e(TAG, "Error in updateRemoteViews(" + position + "): " + e.getMessage()); Loading policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +1 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ public class KeyguardHostView extends KeyguardViewBase { mUserId = mLockPatternUtils.getCurrentUser(); mAppWidgetHost = new AppWidgetHost( context, APPWIDGET_HOST_ID, mOnClickHandler, Looper.myLooper()); mAppWidgetHost.setUserId(mUserId); cleanupAppWidgetIds(); mAppWidgetManager = AppWidgetManager.getInstance(mContext); Loading Loading
core/java/android/appwidget/AppWidgetHost.java +16 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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()); Loading @@ -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) { Loading Loading @@ -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)); } } Loading Loading @@ -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) { Loading @@ -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); } Loading
core/java/android/appwidget/AppWidgetHostView.java +13 −4 Original line number Diff line number Diff line Loading @@ -31,7 +31,9 @@ import android.os.Build; import android.os.Bundle; import android.os.Parcel; import android.os.Parcelable; import android.os.Process; import android.os.SystemClock; import android.os.UserHandle; import android.util.AttributeSet; import android.util.Log; import android.util.SparseArray; Loading Loading @@ -85,6 +87,7 @@ public class AppWidgetHostView extends FrameLayout { Bitmap mOld; Paint mOldPaint = new Paint(); private OnClickHandler mOnClickHandler; private UserHandle mUser; /** * Create a host view. Uses default fade animations. Loading Loading @@ -112,12 +115,17 @@ public class AppWidgetHostView extends FrameLayout { public AppWidgetHostView(Context context, int animationIn, int animationOut) { super(context); mContext = context; mUser = Process.myUserHandle(); // We want to segregate the view ids within AppWidgets to prevent // problems when those ids collide with view ids in the AppWidgetHost. setIsRootNamespace(true); } /** @hide */ public void setUserId(int userId) { mUser = new UserHandle(userId); } /** * Pass the given handler to RemoteViews when updating this widget. Unless this * is done immediatly after construction, a call to {@link #updateAppWidget(RemoteViews)} Loading Loading @@ -465,7 +473,8 @@ public class AppWidgetHostView extends FrameLayout { try { // Return if cloned successfully, otherwise default return mContext.createPackageContext(packageName, Context.CONTEXT_RESTRICTED); return mContext.createPackageContextAsUser(packageName, Context.CONTEXT_RESTRICTED, mUser); } catch (NameNotFoundException e) { Log.e(TAG, "Package name " + packageName + " not found"); return mContext; Loading Loading @@ -539,8 +548,8 @@ public class AppWidgetHostView extends FrameLayout { try { if (mInfo != null) { Context theirContext = mContext.createPackageContext( mInfo.provider.getPackageName(), Context.CONTEXT_RESTRICTED); Context theirContext = mContext.createPackageContextAsUser( mInfo.provider.getPackageName(), Context.CONTEXT_RESTRICTED, mUser); mRemoteContext = theirContext; LayoutInflater inflater = (LayoutInflater) theirContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); Loading
core/java/android/widget/RemoteViewsAdapter.java +1 −0 Original line number Diff line number Diff line Loading @@ -1001,6 +1001,7 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback long itemId = 0; try { remoteViews = factory.getViewAt(position); remoteViews.setUser(new UserHandle(mUserId)); itemId = factory.getItemId(position); } catch (RemoteException e) { Log.e(TAG, "Error in updateRemoteViews(" + position + "): " + e.getMessage()); Loading
policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +1 −0 Original line number Diff line number Diff line Loading @@ -133,6 +133,7 @@ public class KeyguardHostView extends KeyguardViewBase { mUserId = mLockPatternUtils.getCurrentUser(); mAppWidgetHost = new AppWidgetHost( context, APPWIDGET_HOST_ID, mOnClickHandler, Looper.myLooper()); mAppWidgetHost.setUserId(mUserId); cleanupAppWidgetIds(); mAppWidgetManager = AppWidgetManager.getInstance(mContext); Loading