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

Commit 13bc0a31 authored by Vania Januar's avatar Vania Januar
Browse files

Add @TestApi to test STYLUS_BUTTONS_ENABLED.

Includes StatusBarManagerService @TestApis to access
the last received system key event.

Bug: 272032405
Test: used in CTS
Change-Id: Iabd62f901543e9899bee445666ee750900ddc265
parent f2c1506e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -415,6 +415,7 @@ package android.app {
    method public void clickNotification(@Nullable String, int, int, boolean);
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void collapsePanels();
    method public void expandNotificationsPanel();
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public int getLastSystemKey();
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void handleSystemKey(int);
    method public void sendNotificationFeedback(@Nullable String, @Nullable android.os.Bundle);
    method @RequiresPermission(android.Manifest.permission.STATUS_BAR) public void setExpansionDisabledForSimNetworkLock(boolean);
@@ -2625,6 +2626,7 @@ package android.provider {
    field public static final String SELECTED_SPELL_CHECKER_SUBTYPE = "selected_spell_checker_subtype";
    field public static final String SHOW_FIRST_CRASH_DIALOG_DEV_OPTION = "show_first_crash_dialog_dev_option";
    field public static final String SHOW_IME_WITH_HARD_KEYBOARD = "show_ime_with_hard_keyboard";
    field public static final String STYLUS_BUTTONS_ENABLED = "stylus_buttons_enabled";
    field @RequiresPermission(android.Manifest.permission.WRITE_SECURE_SETTINGS) public static final String SYNC_PARENT_SOUNDS = "sync_parent_sounds";
    field public static final String VOICE_INTERACTION_SERVICE = "voice_interaction_service";
  }
+23 −0
Original line number Diff line number Diff line
@@ -751,6 +751,29 @@ public class StatusBarManager {
        }
    }

    /**
     * Gets the last handled system key. A system key is a KeyEvent that the
     * {@link com.android.server.policy.PhoneWindowManager} sends directly to the
     * status bar, rather than forwarding to apps. If a key has never been sent to the
     * status bar, will return -1.
     *
     * @return the keycode of the last KeyEvent that has been sent to the system.
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.STATUS_BAR)
    @TestApi
    public int getLastSystemKey() {
        try {
            final IStatusBarService svc = getService();
            if (svc != null) {
                return svc.getLastSystemKey();
            }
        } catch (RemoteException ex) {
            throw ex.rethrowFromSystemServer();
        }
        return -1;
    }

    /**
     * Expand the settings panel.
     *
+2 −0
Original line number Diff line number Diff line
@@ -7414,6 +7414,8 @@ public final class Settings {
         *
         * @hide
         */
        @TestApi
        @Readable
        @SuppressLint("NoSettingsProvider")
        public static final String STYLUS_BUTTONS_ENABLED = "stylus_buttons_enabled";
+1 −0
Original line number Diff line number Diff line
@@ -111,6 +111,7 @@ interface IStatusBarService
    void clickTile(in ComponentName tile);
    @UnsupportedAppUsage
    void handleSystemKey(in int key);
    int getLastSystemKey();

    /**
     * Methods to show toast messages for screen pinning
+12 −0
Original line number Diff line number Diff line
@@ -33,6 +33,7 @@ import android.Manifest;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
import android.annotation.TestApi;
import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
import android.app.ActivityThread;
@@ -178,6 +179,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
    private final SessionMonitor mSessionMonitor;
    private int mCurrentUserId;
    private boolean mTracingEnabled;
    private int mLastSystemKey = -1;

    private final TileRequestTracker mTileRequestTracker;

@@ -905,6 +907,8 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
            return;
        }

        mLastSystemKey = key;

        if (mBar != null) {
            try {
                mBar.handleSystemKey(key);
@@ -913,6 +917,14 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
        }
    }

    @Override
    @TestApi
    public int getLastSystemKey() {
        enforceStatusBar();

        return mLastSystemKey;
    }

    @Override
    public void showPinningEnterExitToast(boolean entering) throws RemoteException {
        if (mBar != null) {