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

Commit 23b066bf authored by Vaibhav Devmurari's avatar Vaibhav Devmurari
Browse files

Fix: Use internal PM asap for permission check

Wear SysUI may start before mSystemReady, so shift to using
PackageManagerInternal in the method call instead of
waiting for IMS system ready to be called.

Bug: 377782432
Test: manual
Flag: EXEMPT bugfix
Change-Id: Ife84164ece9734447327e3cf219fcc81c4e1563c
parent b6af45d6
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -193,7 +193,6 @@ public class InputManagerService extends IInputManager.Stub
    private DisplayManagerInternal mDisplayManagerInternal;

    private WindowManagerInternal mWindowManagerInternal;
    private PackageManagerInternal mPackageManagerInternal;

    private final File mDoubleTouchGestureEnableFile;

@@ -573,7 +572,6 @@ public class InputManagerService extends IInputManager.Stub

        mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
        mWindowManagerInternal = LocalServices.getService(WindowManagerInternal.class);
        mPackageManagerInternal = LocalServices.getService(PackageManagerInternal.class);

        mSettingsObserver.registerAndUpdate();

@@ -2939,10 +2937,11 @@ public class InputManagerService extends IInputManager.Stub
    private void enforceManageKeyGesturePermission() {
        // TODO(b/361567988): Use @EnforcePermission to enforce permission once flag guarding the
        //  permission is rolled out
        if (mSystemReady) {
        String systemUIPackage = mContext.getString(R.string.config_systemUi);
            int systemUIAppId = UserHandle.getAppId(mPackageManagerInternal
                    .getPackageUid(systemUIPackage, PackageManager.MATCH_SYSTEM_ONLY,
        PackageManagerInternal pm = LocalServices.getService(PackageManagerInternal.class);
        if (pm != null) {
            int systemUIAppId = UserHandle.getAppId(
                    pm.getPackageUid(systemUIPackage, PackageManager.MATCH_SYSTEM_ONLY,
                            UserHandle.USER_SYSTEM));
            if (UserHandle.getCallingAppId() == systemUIAppId) {
                return;