Loading core/java/android/appwidget/AppWidgetHost.java +8 −9 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.annotation.Nullable; import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.IntentSender; import android.os.Binder; import android.os.Bundle; Loading Loading @@ -155,7 +154,7 @@ public class AppWidgetHost { int[] updatedIds; ArrayList<RemoteViews> updatedViews = new ArrayList<RemoteViews>(); try { updatedIds = sService.startListening(mCallbacks, mContext.getPackageName(), mHostId, updatedIds = sService.startListening(mCallbacks, mContext.getOpPackageName(), mHostId, updatedViews); } catch (RemoteException e) { Loading @@ -174,7 +173,7 @@ public class AppWidgetHost { */ public void stopListening() { try { sService.stopListening(mContext.getPackageName(), mHostId); sService.stopListening(mContext.getOpPackageName(), mHostId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); Loading @@ -192,7 +191,7 @@ public class AppWidgetHost { */ public int allocateAppWidgetId() { try { return sService.allocateAppWidgetId(mContext.getPackageName(), mHostId); return sService.allocateAppWidgetId(mContext.getOpPackageName(), mHostId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); Loading Loading @@ -222,7 +221,7 @@ public class AppWidgetHost { int appWidgetId, int intentFlags, int requestCode, @Nullable Bundle options) { try { IntentSender intentSender = sService.createAppWidgetConfigIntentSender( mContext.getPackageName(), appWidgetId, intentFlags); mContext.getOpPackageName(), appWidgetId, intentFlags); if (intentSender != null) { activity.startIntentSenderForResult(intentSender, requestCode, null, 0, 0, 0, options); Loading @@ -246,7 +245,7 @@ public class AppWidgetHost { if (sService == null) { bindService(); } return sService.getAppWidgetIdsForHost(mContext.getPackageName(), mHostId); return sService.getAppWidgetIdsForHost(mContext.getOpPackageName(), mHostId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); } Loading @@ -263,7 +262,7 @@ public class AppWidgetHost { synchronized (mViews) { mViews.remove(appWidgetId); try { sService.deleteAppWidgetId(mContext.getPackageName(), appWidgetId); sService.deleteAppWidgetId(mContext.getOpPackageName(), appWidgetId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); Loading @@ -281,7 +280,7 @@ public class AppWidgetHost { */ public void deleteHost() { try { sService.deleteHost(mContext.getPackageName(), mHostId); sService.deleteHost(mContext.getOpPackageName(), mHostId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); Loading Loading @@ -319,7 +318,7 @@ public class AppWidgetHost { } RemoteViews views; try { views = sService.getAppWidgetViews(mContext.getPackageName(), appWidgetId); views = sService.getAppWidgetViews(mContext.getOpPackageName(), appWidgetId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); } Loading core/java/android/appwidget/AppWidgetManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -441,7 +441,7 @@ public class AppWidgetManager { * @hide */ public AppWidgetManager(Context context, IAppWidgetService service) { mPackageName = context.getPackageName(); mPackageName = context.getOpPackageName(); mService = service; mDisplayMetrics = context.getResources().getDisplayMetrics(); } Loading core/java/android/widget/RemoteViewsAdapter.java +1 −1 Original line number Diff line number Diff line Loading @@ -157,7 +157,7 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback RemoteViewsAdapter adapter; final AppWidgetManager mgr = AppWidgetManager.getInstance(context); if ((adapter = mAdapter.get()) != null) { mgr.bindRemoteViewsService(context.getPackageName(), appWidgetId, mgr.bindRemoteViewsService(context.getOpPackageName(), appWidgetId, intent, asBinder()); } else { Slog.w(TAG, "bind: adapter was null"); Loading services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java +7 −20 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server.appwidget; import android.app.AlarmManager; import android.app.AppGlobals; import android.app.AppOpsManager; import android.app.PendingIntent; import android.app.admin.DevicePolicyManagerInternal; import android.app.admin.DevicePolicyManagerInternal.OnCrossProfileWidgetProvidersChangeListener; Loading Loading @@ -177,6 +178,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku private final IPackageManager mPackageManager; private final AlarmManager mAlarmManager; private final UserManager mUserManager; private final AppOpsManager mAppOpsManager; private final SecurityPolicy mSecurityPolicy; Loading @@ -195,6 +197,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku mPackageManager = AppGlobals.getPackageManager(); mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); mAppOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE); mSaveStateHandler = BackgroundThread.getHandler(); mCallbackHandler = new CallbackHandler(mContext.getMainLooper()); mBackupRestoreController = new BackupRestoreController(); Loading Loading @@ -890,6 +893,9 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku Slog.i(TAG, "bindRemoteViewsService() " + userId); } // Make sure the package runs under the caller uid. mSecurityPolicy.enforceCallFromPackage(callingPackage); synchronized (mLock) { ensureGroupStateLoadedLocked(userId); Loading Loading @@ -3039,26 +3045,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku } public void enforceCallFromPackage(String packageName) { if (!isCallFromPackage(packageName)) { throw new SecurityException("Package " + packageName + " not running under user " + UserHandle.getCallingUserId()); } } public boolean isCallFromPackage(String packageName) { // System and root call all from anywhere they want. final int callingUid = Binder.getCallingUid(); if (callingUid == Process.SYSTEM_UID || callingUid == 0 /* root */) { return true; } // Check if the package is present for the given profile. final int packageUid = getUidForPackage(packageName, UserHandle.getUserId(callingUid)); if (packageUid < 0) { return false; } // Check if the call for a package is coming from that package. return UserHandle.isSameApp(callingUid, packageUid); mAppOpsManager.checkPackage(Binder.getCallingUid(), packageName); } public boolean hasCallerBindPermissionOrBindWhiteListedLocked(String packageName) { Loading Loading
core/java/android/appwidget/AppWidgetHost.java +8 −9 Original line number Diff line number Diff line Loading @@ -24,7 +24,6 @@ import android.annotation.Nullable; import android.app.Activity; import android.content.ActivityNotFoundException; import android.content.Context; import android.content.Intent; import android.content.IntentSender; import android.os.Binder; import android.os.Bundle; Loading Loading @@ -155,7 +154,7 @@ public class AppWidgetHost { int[] updatedIds; ArrayList<RemoteViews> updatedViews = new ArrayList<RemoteViews>(); try { updatedIds = sService.startListening(mCallbacks, mContext.getPackageName(), mHostId, updatedIds = sService.startListening(mCallbacks, mContext.getOpPackageName(), mHostId, updatedViews); } catch (RemoteException e) { Loading @@ -174,7 +173,7 @@ public class AppWidgetHost { */ public void stopListening() { try { sService.stopListening(mContext.getPackageName(), mHostId); sService.stopListening(mContext.getOpPackageName(), mHostId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); Loading @@ -192,7 +191,7 @@ public class AppWidgetHost { */ public int allocateAppWidgetId() { try { return sService.allocateAppWidgetId(mContext.getPackageName(), mHostId); return sService.allocateAppWidgetId(mContext.getOpPackageName(), mHostId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); Loading Loading @@ -222,7 +221,7 @@ public class AppWidgetHost { int appWidgetId, int intentFlags, int requestCode, @Nullable Bundle options) { try { IntentSender intentSender = sService.createAppWidgetConfigIntentSender( mContext.getPackageName(), appWidgetId, intentFlags); mContext.getOpPackageName(), appWidgetId, intentFlags); if (intentSender != null) { activity.startIntentSenderForResult(intentSender, requestCode, null, 0, 0, 0, options); Loading @@ -246,7 +245,7 @@ public class AppWidgetHost { if (sService == null) { bindService(); } return sService.getAppWidgetIdsForHost(mContext.getPackageName(), mHostId); return sService.getAppWidgetIdsForHost(mContext.getOpPackageName(), mHostId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); } Loading @@ -263,7 +262,7 @@ public class AppWidgetHost { synchronized (mViews) { mViews.remove(appWidgetId); try { sService.deleteAppWidgetId(mContext.getPackageName(), appWidgetId); sService.deleteAppWidgetId(mContext.getOpPackageName(), appWidgetId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); Loading @@ -281,7 +280,7 @@ public class AppWidgetHost { */ public void deleteHost() { try { sService.deleteHost(mContext.getPackageName(), mHostId); sService.deleteHost(mContext.getOpPackageName(), mHostId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); Loading Loading @@ -319,7 +318,7 @@ public class AppWidgetHost { } RemoteViews views; try { views = sService.getAppWidgetViews(mContext.getPackageName(), appWidgetId); views = sService.getAppWidgetViews(mContext.getOpPackageName(), appWidgetId); } catch (RemoteException e) { throw new RuntimeException("system server dead?", e); } Loading
core/java/android/appwidget/AppWidgetManager.java +1 −1 Original line number Diff line number Diff line Loading @@ -441,7 +441,7 @@ public class AppWidgetManager { * @hide */ public AppWidgetManager(Context context, IAppWidgetService service) { mPackageName = context.getPackageName(); mPackageName = context.getOpPackageName(); mService = service; mDisplayMetrics = context.getResources().getDisplayMetrics(); } Loading
core/java/android/widget/RemoteViewsAdapter.java +1 −1 Original line number Diff line number Diff line Loading @@ -157,7 +157,7 @@ public class RemoteViewsAdapter extends BaseAdapter implements Handler.Callback RemoteViewsAdapter adapter; final AppWidgetManager mgr = AppWidgetManager.getInstance(context); if ((adapter = mAdapter.get()) != null) { mgr.bindRemoteViewsService(context.getPackageName(), appWidgetId, mgr.bindRemoteViewsService(context.getOpPackageName(), appWidgetId, intent, asBinder()); } else { Slog.w(TAG, "bind: adapter was null"); Loading
services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java +7 −20 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ package com.android.server.appwidget; import android.app.AlarmManager; import android.app.AppGlobals; import android.app.AppOpsManager; import android.app.PendingIntent; import android.app.admin.DevicePolicyManagerInternal; import android.app.admin.DevicePolicyManagerInternal.OnCrossProfileWidgetProvidersChangeListener; Loading Loading @@ -177,6 +178,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku private final IPackageManager mPackageManager; private final AlarmManager mAlarmManager; private final UserManager mUserManager; private final AppOpsManager mAppOpsManager; private final SecurityPolicy mSecurityPolicy; Loading @@ -195,6 +197,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku mPackageManager = AppGlobals.getPackageManager(); mAlarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE); mUserManager = (UserManager) mContext.getSystemService(Context.USER_SERVICE); mAppOpsManager = (AppOpsManager) mContext.getSystemService(Context.APP_OPS_SERVICE); mSaveStateHandler = BackgroundThread.getHandler(); mCallbackHandler = new CallbackHandler(mContext.getMainLooper()); mBackupRestoreController = new BackupRestoreController(); Loading Loading @@ -890,6 +893,9 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku Slog.i(TAG, "bindRemoteViewsService() " + userId); } // Make sure the package runs under the caller uid. mSecurityPolicy.enforceCallFromPackage(callingPackage); synchronized (mLock) { ensureGroupStateLoadedLocked(userId); Loading Loading @@ -3039,26 +3045,7 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku } public void enforceCallFromPackage(String packageName) { if (!isCallFromPackage(packageName)) { throw new SecurityException("Package " + packageName + " not running under user " + UserHandle.getCallingUserId()); } } public boolean isCallFromPackage(String packageName) { // System and root call all from anywhere they want. final int callingUid = Binder.getCallingUid(); if (callingUid == Process.SYSTEM_UID || callingUid == 0 /* root */) { return true; } // Check if the package is present for the given profile. final int packageUid = getUidForPackage(packageName, UserHandle.getUserId(callingUid)); if (packageUid < 0) { return false; } // Check if the call for a package is coming from that package. return UserHandle.isSameApp(callingUid, packageUid); mAppOpsManager.checkPackage(Binder.getCallingUid(), packageName); } public boolean hasCallerBindPermissionOrBindWhiteListedLocked(String packageName) { Loading