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

Commit 7c5c2ac6 authored by Kun Liang's avatar Kun Liang Committed by Linux Build Service Account
Browse files

QuickBoot: Add wakeup check under QuickBoot mode

We only want QuickBoot application to wakeup screen in QuickBoot
mode. Add wakeup check to filter out other wakeup callers.

Change-Id: I765c698449ed0aca8d18d3ec93e00ce34bc33a68
parent 1f09c5a4
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import com.android.server.lights.LightsManager;
import com.android.server.Watchdog;

import android.Manifest;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
@@ -70,6 +71,7 @@ import android.view.WindowManagerPolicy;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import libcore.util.Objects;

@@ -928,6 +930,24 @@ public final class PowerManagerService extends SystemService
        }
    }

    private boolean isQuickBootCall() {

        ActivityManager activityManager = (ActivityManager) mContext
                .getSystemService(Context.ACTIVITY_SERVICE);

        List<ActivityManager.RunningAppProcessInfo> runningList = activityManager
                .getRunningAppProcesses();
        int callingPid = Binder.getCallingPid();
        for (ActivityManager.RunningAppProcessInfo processInfo : runningList) {
            if (processInfo.pid == callingPid) {
                String process = processInfo.processName;
                if ("com.qapp.quickboot".equals(process))
                    return true;
            }
        }
        return false;
    }

    // Called from native code.
    private void userActivityFromNative(long eventTime, int event, int flags) {
        userActivityInternal(eventTime, event, flags, Process.SYSTEM_UID);
@@ -2880,6 +2900,14 @@ public final class PowerManagerService extends SystemService
                throw new IllegalArgumentException("event time must not be in the future");
            }

            // check wakeup caller under QuickBoot mode
            if (SystemProperties.getInt("sys.quickboot.enable", 0) == 1) {
                if (!isQuickBootCall()) {
                    Slog.d(TAG, "ignore wakeup request under QuickBoot");
                    return;
                }
            }

            mContext.enforceCallingOrSelfPermission(
                    android.Manifest.permission.DEVICE_POWER, null);