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

Commit a3df2e68 authored by Yeabkal Wubshit's avatar Yeabkal Wubshit Committed by Android (Google) Code Review
Browse files

Merge "Allow configuring user activity poke rate" into main

parents fd95bcba d9016dc8
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -6905,4 +6905,7 @@
    <!-- Whether to show a percentage text next to the progressbar while preparing to update the
         device -->
    <bool name="config_showPercentageTextDuringRebootToUpdate">true</bool>

    <!-- Defines the minimum interval (in ms) between two input-based user-activity poke events. -->
    <integer name="config_minMillisBetweenInputUserActivityEvents">100</integer>
</resources>
+2 −0
Original line number Diff line number Diff line
@@ -5320,4 +5320,6 @@

  <!-- Shutdown thread config flags -->
  <java-symbol type="bool" name="config_showPercentageTextDuringRebootToUpdate" />

  <java-symbol type="integer" name="config_minMillisBetweenInputUserActivityEvents" />
</resources>
+13 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.server.input;

import static com.android.input.flags.Flags.rateLimitUserActivityPokeInDispatcher;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -113,6 +115,8 @@ class InputSettingsObserver extends ContentObserver {
        for (Consumer<String> observer : mObservers.values()) {
            observer.accept("just booted");
        }

        configureUserActivityPokeInterval();
    }

    @Override
@@ -228,4 +232,13 @@ class InputSettingsObserver extends ContentObserver {
        mService.setAccessibilityStickyKeysEnabled(
                InputSettings.isAccessibilityStickyKeysEnabled(mContext));
    }

    private void configureUserActivityPokeInterval() {
        if (rateLimitUserActivityPokeInDispatcher()) {
            final int intervalMillis = mContext.getResources().getInteger(
                    com.android.internal.R.integer.config_minMillisBetweenInputUserActivityEvents);
            Log.i(TAG, "Setting user activity interval (ms) of " + intervalMillis);
            mNative.setMinTimeBetweenUserActivityPokes(intervalMillis);
        }
    }
}
+5 −0
Original line number Diff line number Diff line
@@ -108,6 +108,8 @@ interface NativeInputManagerService {

    void setFocusedDisplay(int displayId);

    void setMinTimeBetweenUserActivityPokes(long millis);

    boolean transferTouchFocus(IBinder fromChannelToken, IBinder toChannelToken,
            boolean isDragDrop);

@@ -343,6 +345,9 @@ interface NativeInputManagerService {
        @Override
        public native void setFocusedDisplay(int displayId);

        @Override
        public native void setMinTimeBetweenUserActivityPokes(long millis);

        @Override
        public native boolean transferTouchFocus(IBinder fromChannelToken, IBinder toChannelToken,
                boolean isDragDrop);
+14 −0
Original line number Diff line number Diff line
@@ -281,6 +281,7 @@ public:
    void displayRemoved(JNIEnv* env, int32_t displayId);
    void setFocusedApplication(JNIEnv* env, int32_t displayId, jobject applicationHandleObj);
    void setFocusedDisplay(int32_t displayId);
    void setMinTimeBetweenUserActivityPokes(int64_t intervalMillis);
    void setInputDispatchMode(bool enabled, bool frozen);
    void setSystemUiLightsOut(bool lightsOut);
    void setPointerDisplayId(int32_t displayId);
@@ -1169,6 +1170,11 @@ void NativeInputManager::setFocusedDisplay(int32_t displayId) {
    mInputManager->getDispatcher().setFocusedDisplay(displayId);
}

void NativeInputManager::setMinTimeBetweenUserActivityPokes(int64_t intervalMillis) {
    mInputManager->getDispatcher().setMinTimeBetweenUserActivityPokes(
            std::chrono::milliseconds(intervalMillis));
}

void NativeInputManager::setInputDispatchMode(bool enabled, bool frozen) {
    mInputManager->getDispatcher().setInputDispatchMode(enabled, frozen);
}
@@ -2122,6 +2128,13 @@ static void nativeSetFocusedDisplay(JNIEnv* env, jobject nativeImplObj, jint dis
    im->setFocusedDisplay(displayId);
}

static void nativeSetUserActivityPokeInterval(JNIEnv* env, jobject nativeImplObj,
                                              jlong intervalMillis) {
    NativeInputManager* im = getNativeInputManager(env, nativeImplObj);

    im->setMinTimeBetweenUserActivityPokes(intervalMillis);
}

static void nativeRequestPointerCapture(JNIEnv* env, jobject nativeImplObj, jobject tokenObj,
                                        jboolean enabled) {
    NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
@@ -2805,6 +2818,7 @@ static const JNINativeMethod gInputManagerMethods[] = {
        {"setFocusedApplication", "(ILandroid/view/InputApplicationHandle;)V",
         (void*)nativeSetFocusedApplication},
        {"setFocusedDisplay", "(I)V", (void*)nativeSetFocusedDisplay},
        {"setMinTimeBetweenUserActivityPokes", "(J)V", (void*)nativeSetUserActivityPokeInterval},
        {"requestPointerCapture", "(Landroid/os/IBinder;Z)V", (void*)nativeRequestPointerCapture},
        {"setInputDispatchMode", "(ZZ)V", (void*)nativeSetInputDispatchMode},
        {"setSystemUiLightsOut", "(Z)V", (void*)nativeSetSystemUiLightsOut},
Loading