From 75d8c0b8bc28f61658c62b870ae8705e0be191cb Mon Sep 17 00:00:00 2001 From: Nick Kralevich Date: Thu, 4 Sep 2014 15:07:18 -0700 Subject: AppWidgetServiceImpl: Use enforceCallingOrSelfPermission for checking DUMP Use enforceCallingOrSelfPermission() for throwing a security exception rather than creating the security exception ourselves. This has the advantage that the exception is in a well known format expected by the CTS test android.security.cts.ServicePermissionsTest#testDumpProtected Bug: 17165920 Change-Id: I7d3c2d2a0852a490fe1d553cd81d1efc79d2fec3 --- .../com/android/server/appwidget/AppWidgetServiceImpl.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'services/appwidget') diff --git a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java index 7f7e5c3..06c4cfd 100644 --- a/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java +++ b/services/appwidget/java/com/android/server/appwidget/AppWidgetServiceImpl.java @@ -440,12 +440,10 @@ class AppWidgetServiceImpl extends IAppWidgetService.Stub implements WidgetBacku @Override public void dump(FileDescriptor fd, PrintWriter pw, String[] args) { - if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DUMP) - != PackageManager.PERMISSION_GRANTED) { - throw new SecurityException("Permission Denial: can't dump from from pid=" - + Binder.getCallingPid() - + ", uid=" + Binder.getCallingUid()); - } + mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, + "Permission Denial: can't dump from from pid=" + + Binder.getCallingPid() + + ", uid=" + Binder.getCallingUid()); synchronized (mLock) { int N = mProviders.size(); -- cgit v1.1