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

Commit 6fdd3afd authored by Phil Weaver's avatar Phil Weaver Committed by Android (Google) Code Review
Browse files

Merge "Treat accessibility actions as user activity" into nyc-dev

parents 1169f652 da80d676
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -31388,6 +31388,7 @@ package android.os {
    field public static final int RELEASE_FLAG_WAIT_FOR_NO_PROXIMITY = 1; // 0x1
    field public static final deprecated int SCREEN_BRIGHT_WAKE_LOCK = 10; // 0xa
    field public static final deprecated int SCREEN_DIM_WAKE_LOCK = 6; // 0x6
    field public static final int USER_ACTIVITY_EVENT_ACCESSIBILITY = 3; // 0x3
    field public static final int USER_ACTIVITY_EVENT_BUTTON = 1; // 0x1
    field public static final int USER_ACTIVITY_EVENT_OTHER = 0; // 0x0
    field public static final int USER_ACTIVITY_EVENT_TOUCH = 2; // 0x2
+2 −2
Original line number Diff line number Diff line
@@ -477,10 +477,10 @@ public abstract class BatteryStats implements Parcelable {
         * also be bumped.
         */
        static final String[] USER_ACTIVITY_TYPES = {
            "other", "button", "touch"
            "other", "button", "touch", "accessibility"
        };
        
        public static final int NUM_USER_ACTIVITY_TYPES = 3;
        public static final int NUM_USER_ACTIVITY_TYPES = 4;

        public abstract void noteUserActivityLocked(int type);
        public abstract boolean hasUserActivity();
+7 −0
Original line number Diff line number Diff line
@@ -317,6 +317,13 @@ public final class PowerManager {
    @SystemApi
    public static final int USER_ACTIVITY_EVENT_TOUCH = 2;

    /**
     * User activity event type: Accessibility taking action on behalf of user.
     * @hide
     */
    @SystemApi
    public static final int USER_ACTIVITY_EVENT_ACCESSIBILITY = 3;

    /**
     * User activity flag: If already dimmed, extend the dim timeout
     * but do not brighten.  This flag is useful for keeping the screen on
+1 −1
Original line number Diff line number Diff line
@@ -107,7 +107,7 @@ public class BatteryStatsImpl extends BatteryStats {
    private static final int MAGIC = 0xBA757475; // 'BATSTATS'

    // Current on-disk Parcel version
    private static final int VERSION = 141 + (USE_OLD_HISTORY ? 1000 : 0);
    private static final int VERSION = 142 + (USE_OLD_HISTORY ? 1000 : 0);

    // Maximum number of items we will record in the history.
    private static final int MAX_HISTORY_ITEMS = 2000;
+13 −1
Original line number Diff line number Diff line
@@ -56,6 +56,7 @@ import android.os.Handler;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
import android.os.PowerManager;
import android.os.Process;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
@@ -174,6 +175,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {

    private final PackageManager mPackageManager;

    private final PowerManager mPowerManager;

    private final WindowManagerInternal mWindowManagerService;

    private final SecurityPolicy mSecurityPolicy;
@@ -232,6 +235,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
    public AccessibilityManagerService(Context context) {
        mContext = context;
        mPackageManager = mContext.getPackageManager();
        mPowerManager = (PowerManager) mContext.getSystemService(Context.POWER_SERVICE);
        mWindowManagerService = LocalServices.getService(WindowManagerInternal.class);
        mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
        mSecurityPolicy = new SecurityPolicy();
@@ -1802,7 +1806,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
    private KeyEventDispatcher getKeyEventDispatcher() {
        if (mKeyEventDispatcher == null) {
            mKeyEventDispatcher = new KeyEventDispatcher(
                    mMainHandler, MainHandler.MSG_SEND_KEY_EVENT_TO_INPUT_FILTER, mLock);
                    mMainHandler, MainHandler.MSG_SEND_KEY_EVENT_TO_INPUT_FILTER, mLock,
                    mPowerManager);
        }
        return mKeyEventDispatcher;
    }
@@ -2703,6 +2708,11 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
            final int interrogatingPid = Binder.getCallingPid();
            final long identityToken = Binder.clearCallingIdentity();
            try {
                // Regardless of whether or not the action succeeds, it was generated by an
                // accessibility service that is driven by user actions, so note user activity.
                mPowerManager.userActivity(SystemClock.uptimeMillis(),
                        PowerManager.USER_ACTIVITY_EVENT_ACCESSIBILITY, 0);

                connection.performAccessibilityAction(accessibilityNodeId, action, arguments,
                        interactionId, callback, mFetchFlags, interrogatingPid, interrogatingTid);
            } catch (RemoteException re) {
@@ -2724,6 +2734,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
            }
            final long identity = Binder.clearCallingIdentity();
            try {
                mPowerManager.userActivity(SystemClock.uptimeMillis(),
                        PowerManager.USER_ACTIVITY_EVENT_ACCESSIBILITY, 0);
                switch (action) {
                    case AccessibilityService.GLOBAL_ACTION_BACK: {
                        sendDownAndUpKeyEvents(KeyEvent.KEYCODE_BACK);
Loading