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

Commit 456ea906 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "QuickBoot: Add wakeup check under QuickBoot mode"

parents 2ea42e9f fc87bd5b
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -29,6 +29,7 @@ import com.android.server.display.DisplayManagerService;
import com.android.server.dreams.DreamManagerService;

import android.Manifest;
import android.app.ActivityManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
@@ -66,6 +67,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;

@@ -930,6 +932,24 @@ public final class PowerManagerService extends IPowerManager.Stub
        }
    }

    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;
    }

    @Override // Binder call
    public void userActivity(long eventTime, int event, int flags) {
        final long now = SystemClock.uptimeMillis();
@@ -1014,6 +1034,14 @@ public final class PowerManagerService extends IPowerManager.Stub
            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);

        final long ident = Binder.clearCallingIdentity();