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

Commit dec018bb authored by Jeff Sharkey's avatar Jeff Sharkey
Browse files

Consistent dump() permission checking.

This change introduces new methods on DumpUtils that can check if the
caller has DUMP and/or PACKAGE_USAGE_STATS access.  It then moves all
existing dump() methods to use these checks so that we emit
consistent error messages.

Test: cts-tradefed run commandAndExit cts-dev -m CtsSecurityTestCases -t android.security.cts.ServicePermissionsTest
Bug: 32806790
Change-Id: Iaff6b9506818ee082b1e169c89ebe1001b3bfeca
parent 02026a86
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ import android.provider.Settings;
import android.provider.Settings.SettingNotFoundException;
import android.util.Slog;

import com.android.internal.util.DumpUtils;
import com.android.server.pm.PackageManagerService;

import java.io.FileDescriptor;
@@ -2084,7 +2085,7 @@ class BluetoothManagerService extends IBluetoothManager.Stub {

    @Override
    public void dump(FileDescriptor fd, PrintWriter writer, String[] args) {
        mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DUMP, TAG);
        if (!DumpUtils.checkDumpPermission(mContext, TAG, writer)) return;
        String errorMsg = null;

        boolean protoOut = (args.length > 0) && args[0].startsWith("--proto");