Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 75d8c0b8 authored by Nick Kralevich's avatar Nick Kralevich
Browse files

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
parent 191cbad9
Loading
Loading
Loading
Loading
+4 −6
Original line number Diff line number Diff line
@@ -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="
        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();