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

Commit d6f2d2c4 authored by d34d's avatar d34d Committed by Clark Scheff
Browse files

Check for deprecated third party keyguard perm

Change-Id: I0f50bc8d92e879e587a33c46506c320ac94b2216
TICKET: CYNGNOS-1705
parent 4a54c554
Loading
Loading
Loading
Loading
+20 −5
Original line number Diff line number Diff line
@@ -153,6 +153,7 @@ import static android.view.WindowManagerPolicy.WindowManagerFuncs.LID_CLOSED;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVER_ABSENT;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_UNCOVERED;
import static android.view.WindowManagerPolicy.WindowManagerFuncs.CAMERA_LENS_COVERED;
import static org.cyanogenmod.platform.internal.Manifest.permission.THIRD_PARTY_KEYGUARD;

/**
 * WindowManagerPolicy implementation for the Android phone UI.  This
@@ -274,6 +275,9 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    // app shows again. If that doesn't happen for 30s we drop the gesture.
    private static final long PANIC_GESTURE_EXPIRATION = 30000;

    private static final String DEPRECATED_THIRD_PARTY_KEYGUARD_PERMISSION =
            "android.permission.THIRD_PARTY_KEYGUARD";

    /**
     * Keyguard stuff
     */
@@ -2306,8 +2310,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                outAppOp[0] = AppOpsManager.OP_SYSTEM_ALERT_WINDOW;
                break;
            case TYPE_KEYGUARD_PANEL:
                permission =
                        org.cyanogenmod.platform.internal.Manifest.permission.THIRD_PARTY_KEYGUARD;
                permission = THIRD_PARTY_KEYGUARD;
                break;
            default:
                permission = android.Manifest.permission.INTERNAL_SYSTEM_WINDOW;
@@ -2342,6 +2345,14 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                            return WindowManagerGlobal.ADD_OKAY;
                        }
                }
            } else if (permission == THIRD_PARTY_KEYGUARD) {
                // check if caller has the old permission and if so allow adding window
                if (mContext.checkCallingOrSelfPermission(
                        DEPRECATED_THIRD_PARTY_KEYGUARD_PERMISSION)
                        == PackageManager.PERMISSION_GRANTED) {
                    return WindowManagerGlobal.ADD_OKAY;
                }
                // fall through to the normal check below
            }

            if (mContext.checkCallingOrSelfPermission(permission)
@@ -2871,9 +2882,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {
                        "PhoneWindowManager");
                break;
            case TYPE_KEYGUARD_PANEL:
                mContext.enforceCallingOrSelfPermission(
                        org.cyanogenmod.platform.internal.Manifest.permission.THIRD_PARTY_KEYGUARD,
                // check deprecated perm first and if not granted enforce the new permission name
                if (mContext.checkCallingOrSelfPermission(
                        DEPRECATED_THIRD_PARTY_KEYGUARD_PERMISSION)
                        != PackageManager.PERMISSION_GRANTED) {
                    mContext.enforceCallingOrSelfPermission(THIRD_PARTY_KEYGUARD,
                            "PhoneWindowManager");
                }
                if (mKeyguardPanel != null) {
                    return WindowManagerGlobal.ADD_MULTIPLE_SINGLETON;
                }