diff options
Diffstat (limited to 'services/java/com/android/server/AppWidgetService.java')
-rw-r--r-- | services/java/com/android/server/AppWidgetService.java | 64 |
1 files changed, 55 insertions, 9 deletions
diff --git a/services/java/com/android/server/AppWidgetService.java b/services/java/com/android/server/AppWidgetService.java index 06d37dc..06aeb29 100644 --- a/services/java/com/android/server/AppWidgetService.java +++ b/services/java/com/android/server/AppWidgetService.java @@ -26,6 +26,8 @@ import android.content.IntentFilter; import android.content.pm.PackageManager; import android.os.Binder; import android.os.Bundle; +import android.os.Handler; +import android.os.HandlerThread; import android.os.IBinder; import android.os.RemoteException; import android.os.UserHandle; @@ -54,13 +56,19 @@ class AppWidgetService extends IAppWidgetService.Stub Locale mLocale; PackageManager mPackageManager; boolean mSafeMode; + private final Handler mSaveStateHandler; private final SparseArray<AppWidgetServiceImpl> mAppWidgetServices; AppWidgetService(Context context) { mContext = context; + + HandlerThread handlerThread = new HandlerThread("AppWidgetService -- Save state"); + handlerThread.start(); + mSaveStateHandler = new Handler(handlerThread.getLooper()); + mAppWidgetServices = new SparseArray<AppWidgetServiceImpl>(5); - AppWidgetServiceImpl primary = new AppWidgetServiceImpl(context, 0); + AppWidgetServiceImpl primary = new AppWidgetServiceImpl(context, 0, mSaveStateHandler); mAppWidgetServices.append(0, primary); } @@ -138,6 +146,11 @@ class AppWidgetService extends IAppWidgetService.Stub return getImplForUser(getCallingOrCurrentUserId()).allocateAppWidgetId( packageName, hostId); } + + @Override + public int[] getAppWidgetIdsForHost(int hostId) throws RemoteException { + return getImplForUser(getCallingOrCurrentUserId()).getAppWidgetIdsForHost(hostId); + } @Override public void deleteAppWidgetId(int appWidgetId) throws RemoteException { @@ -183,9 +196,14 @@ class AppWidgetService extends IAppWidgetService.Stub } @Override - public void bindRemoteViewsService(int appWidgetId, Intent intent, IBinder connection) - throws RemoteException { - getImplForUser(getCallingOrCurrentUserId()).bindRemoteViewsService( + public void bindRemoteViewsService(int appWidgetId, Intent intent, IBinder connection, + int userId) throws RemoteException { + if (Binder.getCallingPid() != android.os.Process.myPid() + && userId != UserHandle.getCallingUserId()) { + throw new SecurityException("Call from non-system process. Calling uid = " + + Binder.getCallingUid()); + } + getImplForUser(userId).bindRemoteViewsService( appWidgetId, intent, connection); } @@ -196,6 +214,17 @@ class AppWidgetService extends IAppWidgetService.Stub packageName, hostId, updatedViews); } + @Override + public int[] startListeningAsUser(IAppWidgetHost host, String packageName, int hostId, + List<RemoteViews> updatedViews, int userId) throws RemoteException { + if (Binder.getCallingPid() != android.os.Process.myPid() + && userId != UserHandle.getCallingUserId()) { + throw new SecurityException("Call from non-system process. Calling uid = " + + Binder.getCallingUid()); + } + return getImplForUser(userId).startListening(host, packageName, hostId, updatedViews); + } + public void onUserRemoved(int userId) { if (userId < 1) return; synchronized (mAppWidgetServices) { @@ -229,7 +258,7 @@ class AppWidgetService extends IAppWidgetService.Stub if (service == null) { Slog.i(TAG, "Unable to find AppWidgetServiceImpl for user " + userId + ", adding"); // TODO: Verify that it's a valid user - service = new AppWidgetServiceImpl(mContext, userId); + service = new AppWidgetServiceImpl(mContext, userId, mSaveStateHandler); service.systemReady(mSafeMode); // Assume that BOOT_COMPLETED was received, as this is a non-primary user. mAppWidgetServices.append(userId, service); @@ -268,8 +297,9 @@ class AppWidgetService extends IAppWidgetService.Stub } @Override - public List<AppWidgetProviderInfo> getInstalledProviders() throws RemoteException { - return getImplForUser(getCallingOrCurrentUserId()).getInstalledProviders(); + public List<AppWidgetProviderInfo> getInstalledProviders(int categoryFilter) + throws RemoteException { + return getImplForUser(getCallingOrCurrentUserId()).getInstalledProviders(categoryFilter); } @Override @@ -292,8 +322,24 @@ class AppWidgetService extends IAppWidgetService.Stub } @Override - public void unbindRemoteViewsService(int appWidgetId, Intent intent) throws RemoteException { - getImplForUser(getCallingOrCurrentUserId()).unbindRemoteViewsService( + public void stopListeningAsUser(int hostId, int userId) throws RemoteException { + if (Binder.getCallingPid() != android.os.Process.myPid() + && userId != UserHandle.getCallingUserId()) { + throw new SecurityException("Call from non-system process. Calling uid = " + + Binder.getCallingUid()); + } + getImplForUser(userId).stopListening(hostId); + } + + @Override + public void unbindRemoteViewsService(int appWidgetId, Intent intent, int userId) + throws RemoteException { + if (Binder.getCallingPid() != android.os.Process.myPid() + && userId != UserHandle.getCallingUserId()) { + throw new SecurityException("Call from non-system process. Calling uid = " + + Binder.getCallingUid()); + } + getImplForUser(userId).unbindRemoteViewsService( appWidgetId, intent); } |