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

Commit dc1662c6 authored by Shashwat Razdan's avatar Shashwat Razdan
Browse files

Adding a permission based check in SmartspaceManagerService

Test: Added the permission to SysUI and checked that it is working
Bug: 182330864

Change-Id: I1a545d39bee3fec6423149f4f3146551c220fd30

Change-Id: I7ceafd9c530d4386e29cab96256e8aa3035d302d
parent cc82a02d
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.server.smartspace;
import static android.Manifest.permission.MANAGE_SMARTSPACE;
import static android.app.ActivityManagerInternal.ALLOW_NON_FULL;
import static android.content.Context.SMARTSPACE_SERVICE;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;

import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -161,11 +162,13 @@ public class SmartspaceManagerService extends
                Slog.d(TAG, "runForUserLocked:" + func + " from pid=" + Binder.getCallingPid()
                        + ", uid=" + Binder.getCallingUid());
            }
            if (!(mServiceNameResolver.isTemporary(userId)
            Context ctx = getContext();
            if (!(ctx.checkCallingPermission(MANAGE_SMARTSPACE) == PERMISSION_GRANTED
                    || mServiceNameResolver.isTemporary(userId)
                    || mActivityTaskManagerInternal.isCallerRecents(Binder.getCallingUid()))) {

                String msg = "Permission Denial: " + func + " from pid=" + Binder.getCallingPid()
                        + ", uid=" + Binder.getCallingUid();
                String msg = "Permission Denial: Cannot call " + func + " from pid="
                        + Binder.getCallingPid() + ", uid=" + Binder.getCallingUid();
                Slog.w(TAG, msg);
                throw new SecurityException(msg);
            }