Merge "Add configuration for disabling stylus button motion events"
This commit is contained in:
committed by
Android (Google) Code Review
commit
2bbd276473
@@ -206,4 +206,11 @@ public abstract class InputManagerInternal {
|
||||
* @param inputPort The port of the input device.
|
||||
*/
|
||||
public abstract void removeKeyboardLayoutAssociation(@NonNull String inputPort);
|
||||
|
||||
/**
|
||||
* Set whether stylus button reporting through motion events should be enabled.
|
||||
*
|
||||
* @param enabled When true, stylus buttons will not be reported through motion events.
|
||||
*/
|
||||
public abstract void setStylusButtonMotionEventsEnabled(boolean enabled);
|
||||
}
|
||||
|
||||
@@ -3383,6 +3383,11 @@ public class InputManagerService extends IInputManager.Stub
|
||||
public void removeKeyboardLayoutAssociation(@NonNull String inputPort) {
|
||||
InputManagerService.this.removeKeyboardLayoutAssociation(inputPort);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStylusButtonMotionEventsEnabled(boolean enabled) {
|
||||
mNative.setStylusButtonMotionEventsEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -213,6 +213,9 @@ interface NativeInputManagerService {
|
||||
/** Get the bluetooth address of an input device if known, otherwise return null. */
|
||||
String getBluetoothAddress(int deviceId);
|
||||
|
||||
/** Set whether stylus button reporting through motion events should be enabled. */
|
||||
void setStylusButtonMotionEventsEnabled(boolean enabled);
|
||||
|
||||
/** The native implementation of InputManagerService methods. */
|
||||
class NativeImpl implements NativeInputManagerService {
|
||||
/** Pointer to native input manager service object, used by native code. */
|
||||
@@ -439,5 +442,8 @@ interface NativeInputManagerService {
|
||||
|
||||
@Override
|
||||
public native String getBluetoothAddress(int deviceId);
|
||||
|
||||
@Override
|
||||
public native void setStylusButtonMotionEventsEnabled(boolean enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2577,6 +2577,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
|
||||
|
||||
mStylusButtonsDisabled = Settings.Secure.getIntForUser(resolver,
|
||||
Secure.STYLUS_BUTTONS_DISABLED, 0, UserHandle.USER_CURRENT) == 1;
|
||||
mInputManagerInternal.setStylusButtonMotionEventsEnabled(!mStylusButtonsDisabled);
|
||||
}
|
||||
if (updateRotation) {
|
||||
updateRotation(true);
|
||||
|
||||
@@ -302,6 +302,7 @@ public:
|
||||
void setCustomPointerIcon(const SpriteIcon& icon);
|
||||
void setMotionClassifierEnabled(bool enabled);
|
||||
std::optional<std::string> getBluetoothAddress(int32_t deviceId);
|
||||
void setStylusButtonMotionEventsEnabled(bool enabled);
|
||||
|
||||
/* --- InputReaderPolicyInterface implementation --- */
|
||||
|
||||
@@ -405,6 +406,9 @@ private:
|
||||
|
||||
// Associated Pointer controller display.
|
||||
int32_t pointerDisplayId{ADISPLAY_ID_DEFAULT};
|
||||
|
||||
// True if stylus button reporting through motion events is enabled.
|
||||
bool stylusButtonMotionEventsEnabled{true};
|
||||
} mLocked GUARDED_BY(mLock);
|
||||
|
||||
std::atomic<bool> mInteractive;
|
||||
@@ -654,6 +658,8 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon
|
||||
outConfig->defaultPointerDisplayId = mLocked.pointerDisplayId;
|
||||
|
||||
outConfig->disabledDevices = mLocked.disabledInputDevices;
|
||||
|
||||
outConfig->stylusButtonMotionEventsEnabled = mLocked.stylusButtonMotionEventsEnabled;
|
||||
} // release lock
|
||||
}
|
||||
|
||||
@@ -1524,6 +1530,21 @@ std::optional<std::string> NativeInputManager::getBluetoothAddress(int32_t devic
|
||||
return mInputManager->getReader().getBluetoothAddress(deviceId);
|
||||
}
|
||||
|
||||
void NativeInputManager::setStylusButtonMotionEventsEnabled(bool enabled) {
|
||||
{ // acquire lock
|
||||
AutoMutex _l(mLock);
|
||||
|
||||
if (mLocked.stylusButtonMotionEventsEnabled == enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
mLocked.stylusButtonMotionEventsEnabled = enabled;
|
||||
} // release lock
|
||||
|
||||
mInputManager->getReader().requestRefreshConfiguration(
|
||||
InputReaderConfiguration::CHANGE_STYLUS_BUTTON_REPORTING);
|
||||
}
|
||||
|
||||
bool NativeInputManager::isPerDisplayTouchModeEnabled() {
|
||||
JNIEnv* env = jniEnv();
|
||||
jboolean enabled =
|
||||
@@ -2393,6 +2414,12 @@ static jstring nativeGetBluetoothAddress(JNIEnv* env, jobject nativeImplObj, jin
|
||||
return address ? env->NewStringUTF(address->c_str()) : nullptr;
|
||||
}
|
||||
|
||||
static void nativeSetStylusButtonMotionEventsEnabled(JNIEnv* env, jobject nativeImplObj,
|
||||
jboolean enabled) {
|
||||
NativeInputManager* im = getNativeInputManager(env, nativeImplObj);
|
||||
im->setStylusButtonMotionEventsEnabled(enabled);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
static const JNINativeMethod gInputManagerMethods[] = {
|
||||
@@ -2479,6 +2506,8 @@ static const JNINativeMethod gInputManagerMethods[] = {
|
||||
{"cancelCurrentTouch", "()V", (void*)nativeCancelCurrentTouch},
|
||||
{"setPointerDisplayId", "(I)V", (void*)nativeSetPointerDisplayId},
|
||||
{"getBluetoothAddress", "(I)Ljava/lang/String;", (void*)nativeGetBluetoothAddress},
|
||||
{"setStylusButtonMotionEventsEnabled", "(Z)V",
|
||||
(void*)nativeSetStylusButtonMotionEventsEnabled},
|
||||
};
|
||||
|
||||
#define FIND_CLASS(var, className) \
|
||||
|
||||
Reference in New Issue
Block a user