Loading core/java/android/appwidget/AppWidgetHost.java +28 −2 Original line number Diff line number Diff line Loading @@ -154,6 +154,15 @@ public class AppWidgetHost { * becomes visible, i.e. from onStart() in your Activity. */ public void startListening() { startListeningAsUser(UserHandle.myUserId()); } /** * Start receiving onAppWidgetChanged calls for your AppWidgets. Call this when your activity * becomes visible, i.e. from onStart() in your Activity. * @hide */ public void startListeningAsUser(int userId) { int[] updatedIds; ArrayList<RemoteViews> updatedViews = new ArrayList<RemoteViews>(); Loading @@ -161,7 +170,8 @@ public class AppWidgetHost { if (mPackageName == null) { mPackageName = mContext.getPackageName(); } updatedIds = sService.startListening(mCallbacks, mPackageName, mHostId, updatedViews); updatedIds = sService.startListeningAsUser( mCallbacks, mPackageName, mHostId, updatedViews, userId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); Loading @@ -179,11 +189,27 @@ public class AppWidgetHost { */ public void stopListening() { try { sService.stopListening(mHostId); sService.stopListeningAsUser(mHostId, UserHandle.myUserId()); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); } } /** * Stop receiving onAppWidgetChanged calls for your AppWidgets. Call this when your activity is * no longer visible, i.e. from onStop() in your Activity. * @hide */ public void stopListeningAsUser(int userId) { try { sService.stopListeningAsUser(mHostId, userId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); } // Also clear the views clearViews(); } /** Loading core/java/android/appwidget/AppWidgetManager.java +9 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.util.DisplayMetrics; import android.util.TypedValue; import android.widget.RemoteViews; Loading Loading @@ -749,11 +750,14 @@ public class AppWidgetManager { * @param intent The intent of the service which will be providing the data to the * RemoteViewsAdapter. * @param connection The callback interface to be notified when a connection is made or lost. * @param userHandle The user to bind to. * @hide */ public void bindRemoteViewsService(int appWidgetId, Intent intent, IBinder connection) { public void bindRemoteViewsService(int appWidgetId, Intent intent, IBinder connection, UserHandle userHandle) { try { sService.bindRemoteViewsService(appWidgetId, intent, connection); sService.bindRemoteViewsService(appWidgetId, intent, connection, userHandle.getIdentifier()); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); Loading @@ -769,11 +773,12 @@ public class AppWidgetManager { * @param appWidgetId The AppWidget instance for which to bind the RemoteViewsService. * @param intent The intent of the service which will be providing the data to the * RemoteViewsAdapter. * @param userHandle The user to unbind from. * @hide */ public void unbindRemoteViewsService(int appWidgetId, Intent intent) { public void unbindRemoteViewsService(int appWidgetId, Intent intent, UserHandle userHandle) { try { sService.unbindRemoteViewsService(appWidgetId, intent); sService.unbindRemoteViewsService(appWidgetId, intent, userHandle.getIdentifier()); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); Loading core/java/android/widget/RemoteViewsAdapter.java +28 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,9 @@ import android.os.HandlerThread; import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; import android.util.Log; import android.util.Pair; import android.view.LayoutInflater; Loading @@ -40,6 +42,7 @@ import android.widget.RemoteViews.OnClickHandler; import com.android.internal.widget.IRemoteViewsAdapterConnection; import com.android.internal.widget.IRemoteViewsFactory; import com.android.internal.widget.LockPatternUtils; /** * An adapter to a RemoteViewsService which fetches and caches RemoteViews Loading Loading @@ -106,6 +109,8 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback // construction (happens when we have a cached FixedSizeRemoteViewsCache). private boolean mDataReady = false; int mUserId; /** * An interface for the RemoteAdapter to notify other classes when adapters * are actually connected to/disconnected from their actual services. Loading Loading @@ -146,8 +151,16 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback public synchronized void bind(Context context, int appWidgetId, Intent intent) { if (!mIsConnecting) { try { RemoteViewsAdapter adapter; final AppWidgetManager mgr = AppWidgetManager.getInstance(context); mgr.bindRemoteViewsService(appWidgetId, intent, asBinder()); if (Process.myUid() == Process.SYSTEM_UID && (adapter = mAdapter.get()) != null) { mgr.bindRemoteViewsService(appWidgetId, intent, asBinder(), new UserHandle(adapter.mUserId)); } else { mgr.bindRemoteViewsService(appWidgetId, intent, asBinder(), Process.myUserHandle()); } mIsConnecting = true; } catch (Exception e) { Log.e("RemoteViewsAdapterServiceConnection", "bind(): " + e.getMessage()); Loading @@ -159,8 +172,15 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback public synchronized void unbind(Context context, int appWidgetId, Intent intent) { try { RemoteViewsAdapter adapter; final AppWidgetManager mgr = AppWidgetManager.getInstance(context); mgr.unbindRemoteViewsService(appWidgetId, intent); if (Process.myUid() == Process.SYSTEM_UID && (adapter = mAdapter.get()) != null) { mgr.unbindRemoteViewsService(appWidgetId, intent, new UserHandle(adapter.mUserId)); } else { mgr.unbindRemoteViewsService(appWidgetId, intent, Process.myUserHandle()); } mIsConnecting = false; } catch (Exception e) { Log.e("RemoteViewsAdapterServiceConnection", "unbind(): " + e.getMessage()); Loading Loading @@ -761,6 +781,12 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback } mRequestedViews = new RemoteViewsFrameLayoutRefSet(); if (Process.myUid() == Process.SYSTEM_UID) { mUserId = new LockPatternUtils(context).getCurrentUser(); } else { mUserId = UserHandle.myUserId(); } // Strip the previously injected app widget id from service intent if (intent.hasExtra(RemoteViews.EXTRA_REMOTEADAPTER_APPWIDGET_ID)) { intent.removeExtra(RemoteViews.EXTRA_REMOTEADAPTER_APPWIDGET_ID); Loading core/java/com/android/internal/appwidget/IAppWidgetService.aidl +5 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,10 @@ interface IAppWidgetService { // int[] startListening(IAppWidgetHost host, String packageName, int hostId, out List<RemoteViews> updatedViews); int[] startListeningAsUser(IAppWidgetHost host, String packageName, int hostId, out List<RemoteViews> updatedViews, int userId); void stopListening(int hostId); void stopListeningAsUser(int hostId, int userId); int allocateAppWidgetId(String packageName, int hostId); void deleteAppWidgetId(int appWidgetId); void deleteHost(int hostId); Loading @@ -56,8 +59,8 @@ interface IAppWidgetService { void bindAppWidgetId(int appWidgetId, in ComponentName provider, in Bundle options); boolean bindAppWidgetIdIfAllowed( in String packageName, int appWidgetId, in ComponentName provider, in Bundle options); void bindRemoteViewsService(int appWidgetId, in Intent intent, in IBinder connection); void unbindRemoteViewsService(int appWidgetId, in Intent intent); void bindRemoteViewsService(int appWidgetId, in Intent intent, in IBinder connection, int userId); void unbindRemoteViewsService(int appWidgetId, in Intent intent, int userId); int[] getAppWidgetIds(in ComponentName provider); } Loading policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +5 −2 Original line number Diff line number Diff line Loading @@ -101,6 +101,8 @@ public class KeyguardHostView extends KeyguardViewBase { private boolean mSafeModeEnabled; private boolean mUserSetupCompleted; // User for whom this host view was created private int mUserId; /*package*/ interface TransportCallback { void onListenerDetached(); Loading @@ -127,6 +129,7 @@ public class KeyguardHostView extends KeyguardViewBase { public KeyguardHostView(Context context, AttributeSet attrs) { super(context, attrs); mLockPatternUtils = new LockPatternUtils(context); mUserId = mLockPatternUtils.getCurrentUser(); mAppWidgetHost = new AppWidgetHost( context, APPWIDGET_HOST_ID, mOnClickHandler, Looper.myLooper()); cleanupAppWidgetIds(); Loading Loading @@ -338,14 +341,14 @@ public class KeyguardHostView extends KeyguardViewBase { @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); mAppWidgetHost.startListening(); mAppWidgetHost.startListeningAsUser(mUserId); KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallbacks); } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); mAppWidgetHost.stopListening(); mAppWidgetHost.stopListeningAsUser(mUserId); KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateMonitorCallbacks); } Loading Loading
core/java/android/appwidget/AppWidgetHost.java +28 −2 Original line number Diff line number Diff line Loading @@ -154,6 +154,15 @@ public class AppWidgetHost { * becomes visible, i.e. from onStart() in your Activity. */ public void startListening() { startListeningAsUser(UserHandle.myUserId()); } /** * Start receiving onAppWidgetChanged calls for your AppWidgets. Call this when your activity * becomes visible, i.e. from onStart() in your Activity. * @hide */ public void startListeningAsUser(int userId) { int[] updatedIds; ArrayList<RemoteViews> updatedViews = new ArrayList<RemoteViews>(); Loading @@ -161,7 +170,8 @@ public class AppWidgetHost { if (mPackageName == null) { mPackageName = mContext.getPackageName(); } updatedIds = sService.startListening(mCallbacks, mPackageName, mHostId, updatedViews); updatedIds = sService.startListeningAsUser( mCallbacks, mPackageName, mHostId, updatedViews, userId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); Loading @@ -179,11 +189,27 @@ public class AppWidgetHost { */ public void stopListening() { try { sService.stopListening(mHostId); sService.stopListeningAsUser(mHostId, UserHandle.myUserId()); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); } } /** * Stop receiving onAppWidgetChanged calls for your AppWidgets. Call this when your activity is * no longer visible, i.e. from onStop() in your Activity. * @hide */ public void stopListeningAsUser(int userId) { try { sService.stopListeningAsUser(mHostId, userId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); } // Also clear the views clearViews(); } /** Loading
core/java/android/appwidget/AppWidgetManager.java +9 −4 Original line number Diff line number Diff line Loading @@ -23,6 +23,7 @@ import android.os.Bundle; import android.os.IBinder; import android.os.RemoteException; import android.os.ServiceManager; import android.os.UserHandle; import android.util.DisplayMetrics; import android.util.TypedValue; import android.widget.RemoteViews; Loading Loading @@ -749,11 +750,14 @@ public class AppWidgetManager { * @param intent The intent of the service which will be providing the data to the * RemoteViewsAdapter. * @param connection The callback interface to be notified when a connection is made or lost. * @param userHandle The user to bind to. * @hide */ public void bindRemoteViewsService(int appWidgetId, Intent intent, IBinder connection) { public void bindRemoteViewsService(int appWidgetId, Intent intent, IBinder connection, UserHandle userHandle) { try { sService.bindRemoteViewsService(appWidgetId, intent, connection); sService.bindRemoteViewsService(appWidgetId, intent, connection, userHandle.getIdentifier()); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); Loading @@ -769,11 +773,12 @@ public class AppWidgetManager { * @param appWidgetId The AppWidget instance for which to bind the RemoteViewsService. * @param intent The intent of the service which will be providing the data to the * RemoteViewsAdapter. * @param userHandle The user to unbind from. * @hide */ public void unbindRemoteViewsService(int appWidgetId, Intent intent) { public void unbindRemoteViewsService(int appWidgetId, Intent intent, UserHandle userHandle) { try { sService.unbindRemoteViewsService(appWidgetId, intent); sService.unbindRemoteViewsService(appWidgetId, intent, userHandle.getIdentifier()); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); Loading
core/java/android/widget/RemoteViewsAdapter.java +28 −2 Original line number Diff line number Diff line Loading @@ -29,7 +29,9 @@ import android.os.HandlerThread; import android.os.IBinder; import android.os.Looper; import android.os.Message; import android.os.Process; import android.os.RemoteException; import android.os.UserHandle; import android.util.Log; import android.util.Pair; import android.view.LayoutInflater; Loading @@ -40,6 +42,7 @@ import android.widget.RemoteViews.OnClickHandler; import com.android.internal.widget.IRemoteViewsAdapterConnection; import com.android.internal.widget.IRemoteViewsFactory; import com.android.internal.widget.LockPatternUtils; /** * An adapter to a RemoteViewsService which fetches and caches RemoteViews Loading Loading @@ -106,6 +109,8 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback // construction (happens when we have a cached FixedSizeRemoteViewsCache). private boolean mDataReady = false; int mUserId; /** * An interface for the RemoteAdapter to notify other classes when adapters * are actually connected to/disconnected from their actual services. Loading Loading @@ -146,8 +151,16 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback public synchronized void bind(Context context, int appWidgetId, Intent intent) { if (!mIsConnecting) { try { RemoteViewsAdapter adapter; final AppWidgetManager mgr = AppWidgetManager.getInstance(context); mgr.bindRemoteViewsService(appWidgetId, intent, asBinder()); if (Process.myUid() == Process.SYSTEM_UID && (adapter = mAdapter.get()) != null) { mgr.bindRemoteViewsService(appWidgetId, intent, asBinder(), new UserHandle(adapter.mUserId)); } else { mgr.bindRemoteViewsService(appWidgetId, intent, asBinder(), Process.myUserHandle()); } mIsConnecting = true; } catch (Exception e) { Log.e("RemoteViewsAdapterServiceConnection", "bind(): " + e.getMessage()); Loading @@ -159,8 +172,15 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback public synchronized void unbind(Context context, int appWidgetId, Intent intent) { try { RemoteViewsAdapter adapter; final AppWidgetManager mgr = AppWidgetManager.getInstance(context); mgr.unbindRemoteViewsService(appWidgetId, intent); if (Process.myUid() == Process.SYSTEM_UID && (adapter = mAdapter.get()) != null) { mgr.unbindRemoteViewsService(appWidgetId, intent, new UserHandle(adapter.mUserId)); } else { mgr.unbindRemoteViewsService(appWidgetId, intent, Process.myUserHandle()); } mIsConnecting = false; } catch (Exception e) { Log.e("RemoteViewsAdapterServiceConnection", "unbind(): " + e.getMessage()); Loading Loading @@ -761,6 +781,12 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback } mRequestedViews = new RemoteViewsFrameLayoutRefSet(); if (Process.myUid() == Process.SYSTEM_UID) { mUserId = new LockPatternUtils(context).getCurrentUser(); } else { mUserId = UserHandle.myUserId(); } // Strip the previously injected app widget id from service intent if (intent.hasExtra(RemoteViews.EXTRA_REMOTEADAPTER_APPWIDGET_ID)) { intent.removeExtra(RemoteViews.EXTRA_REMOTEADAPTER_APPWIDGET_ID); Loading
core/java/com/android/internal/appwidget/IAppWidgetService.aidl +5 −2 Original line number Diff line number Diff line Loading @@ -32,7 +32,10 @@ interface IAppWidgetService { // int[] startListening(IAppWidgetHost host, String packageName, int hostId, out List<RemoteViews> updatedViews); int[] startListeningAsUser(IAppWidgetHost host, String packageName, int hostId, out List<RemoteViews> updatedViews, int userId); void stopListening(int hostId); void stopListeningAsUser(int hostId, int userId); int allocateAppWidgetId(String packageName, int hostId); void deleteAppWidgetId(int appWidgetId); void deleteHost(int hostId); Loading @@ -56,8 +59,8 @@ interface IAppWidgetService { void bindAppWidgetId(int appWidgetId, in ComponentName provider, in Bundle options); boolean bindAppWidgetIdIfAllowed( in String packageName, int appWidgetId, in ComponentName provider, in Bundle options); void bindRemoteViewsService(int appWidgetId, in Intent intent, in IBinder connection); void unbindRemoteViewsService(int appWidgetId, in Intent intent); void bindRemoteViewsService(int appWidgetId, in Intent intent, in IBinder connection, int userId); void unbindRemoteViewsService(int appWidgetId, in Intent intent, int userId); int[] getAppWidgetIds(in ComponentName provider); } Loading
policy/src/com/android/internal/policy/impl/keyguard/KeyguardHostView.java +5 −2 Original line number Diff line number Diff line Loading @@ -101,6 +101,8 @@ public class KeyguardHostView extends KeyguardViewBase { private boolean mSafeModeEnabled; private boolean mUserSetupCompleted; // User for whom this host view was created private int mUserId; /*package*/ interface TransportCallback { void onListenerDetached(); Loading @@ -127,6 +129,7 @@ public class KeyguardHostView extends KeyguardViewBase { public KeyguardHostView(Context context, AttributeSet attrs) { super(context, attrs); mLockPatternUtils = new LockPatternUtils(context); mUserId = mLockPatternUtils.getCurrentUser(); mAppWidgetHost = new AppWidgetHost( context, APPWIDGET_HOST_ID, mOnClickHandler, Looper.myLooper()); cleanupAppWidgetIds(); Loading Loading @@ -338,14 +341,14 @@ public class KeyguardHostView extends KeyguardViewBase { @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); mAppWidgetHost.startListening(); mAppWidgetHost.startListeningAsUser(mUserId); KeyguardUpdateMonitor.getInstance(mContext).registerCallback(mUpdateMonitorCallbacks); } @Override protected void onDetachedFromWindow() { super.onDetachedFromWindow(); mAppWidgetHost.stopListening(); mAppWidgetHost.stopListeningAsUser(mUserId); KeyguardUpdateMonitor.getInstance(mContext).removeCallback(mUpdateMonitorCallbacks); } Loading