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

Commit 7f93e8f3 authored by Tom Chan's avatar Tom Chan
Browse files

Check permissions for WSM shell commands

Override handleShellCommand instead of onShellCommand because Binder.onShellCommand checks the necessary permissions of the caller before calling handleShellCommand.

Bug: 400445323, 345196167
Test: Tried running the commands from an app. It can no longer trigger the changes in WSM.
Flag: EXEMPT bugfix
Change-Id: I1fb7e1336ef42a0585227e5d825ac6c70333b7f0
parent 182c34af
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -38,9 +38,7 @@ import android.os.Build;
import android.os.ParcelFileDescriptor;
import android.os.PersistableBundle;
import android.os.RemoteCallback;
import android.os.ResultReceiver;
import android.os.SharedMemory;
import android.os.ShellCallback;
import android.os.UserHandle;
import android.provider.DeviceConfig;
import android.service.wearable.WearableSensingDataRequester;
@@ -54,7 +52,6 @@ import com.android.server.infra.AbstractMasterSystemService;
import com.android.server.infra.FrameworkResourcesServiceNameResolver;
import com.android.server.utils.quota.MultiRateLimiter;

import java.io.FileDescriptor;
import java.time.Duration;
import java.util.HashSet;
import java.util.Objects;
@@ -668,15 +665,18 @@ public class WearableSensingManagerService
        }

        @Override
        public void onShellCommand(
                FileDescriptor in,
                FileDescriptor out,
                FileDescriptor err,
                String[] args,
                ShellCallback callback,
                ResultReceiver resultReceiver) {
            new WearableSensingShellCommand(WearableSensingManagerService.this)
                    .exec(this, in, out, err, args, callback, resultReceiver);
        public int handleShellCommand(
                @NonNull ParcelFileDescriptor in,
                @NonNull ParcelFileDescriptor out,
                @NonNull ParcelFileDescriptor err,
                @NonNull String[] args) {
            return new WearableSensingShellCommand(WearableSensingManagerService.this)
                    .exec(
                            this,
                            in.getFileDescriptor(),
                            out.getFileDescriptor(),
                            err.getFileDescriptor(),
                            args);
        }

        @Nullable