• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

frameworks/base


Commit MetaInfo

Revisioncbefcdf6db80341d78a01b6d4770beba47fd18ff (tree)
Zeit2016-10-09 21:46:31
AutorSteve Kondik <shade@chem...>
CommiterSteve Kondik

Log Message

input: Add option to toggle pointer icon when using stylus

* The visible pointer icon when hovering or drawing with the stylus is

quite annoying when trying to actually draw with it. Turn it off by
default and add an option to turn it on.

Change-Id: I26ba2ca8b92511799033759ca85c36f4ba2b7833

Ändern Zusammenfassung

Diff

--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -212,6 +212,7 @@ public class InputManagerService extends IInputManager.Stub
212212 InputChannel fromChannel, InputChannel toChannel);
213213 private static native void nativeSetPointerSpeed(long ptr, int speed);
214214 private static native void nativeSetShowTouches(long ptr, boolean enabled);
215+ private static native void nativeSetStylusIconEnabled(long ptr, boolean enabled);
215216 private static native void nativeSetVolumeKeysRotation(long ptr, int mode);
216217 private static native void nativeSetInteractive(long ptr, boolean interactive);
217218 private static native void nativeReloadCalibration(long ptr);
@@ -325,6 +326,7 @@ public class InputManagerService extends IInputManager.Stub
325326 registerPointerSpeedSettingObserver();
326327 registerShowTouchesSettingObserver();
327328 registerAccessibilityLargePointerSettingObserver();
329+ registerStylusIconEnabledSettingObserver();
328330 registerVolumeKeysRotationSettingObserver();
329331
330332 mContext.registerReceiver(new BroadcastReceiver() {
@@ -333,6 +335,7 @@ public class InputManagerService extends IInputManager.Stub
333335 updatePointerSpeedFromSettings();
334336 updateShowTouchesFromSettings();
335337 updateAccessibilityLargePointerFromSettings();
338+ updateStylusIconEnabledFromSettings();
336339 updateVolumeKeysRotationFromSettings();
337340 }
338341 }, new IntentFilter(Intent.ACTION_USER_SWITCHED), null, mHandler);
@@ -340,6 +343,7 @@ public class InputManagerService extends IInputManager.Stub
340343 updatePointerSpeedFromSettings();
341344 updateShowTouchesFromSettings();
342345 updateAccessibilityLargePointerFromSettings();
346+ updateStylusIconEnabledFromSettings();
343347 updateVolumeKeysRotationFromSettings();
344348 }
345349
@@ -1667,6 +1671,32 @@ public class InputManagerService extends IInputManager.Stub
16671671 return result;
16681672 }
16691673
1674+ public void updateStylusIconEnabledFromSettings() {
1675+ int enabled = getStylusIconEnabled(0);
1676+ nativeSetStylusIconEnabled(mPtr, enabled != 0);
1677+ }
1678+
1679+ public void registerStylusIconEnabledSettingObserver() {
1680+ mContext.getContentResolver().registerContentObserver(
1681+ CMSettings.System.getUriFor(CMSettings.System.STYLUS_ICON_ENABLED), false,
1682+ new ContentObserver(mHandler) {
1683+ @Override
1684+ public void onChange(boolean selfChange) {
1685+ updateStylusIconEnabledFromSettings();
1686+ }
1687+ });
1688+ }
1689+
1690+ private int getStylusIconEnabled(int defaultValue) {
1691+ int result = defaultValue;
1692+ try {
1693+ result = CMSettings.System.getInt(mContext.getContentResolver(),
1694+ CMSettings.System.STYLUS_ICON_ENABLED);
1695+ } catch (CMSettings.CMSettingNotFoundException snfe) {
1696+ }
1697+ return result;
1698+ }
1699+
16701700 public void updateVolumeKeysRotationFromSettings() {
16711701 int mode = getVolumeKeysRotationSetting(0);
16721702 nativeSetVolumeKeysRotation(mPtr, mode);
--- a/services/core/jni/com_android_server_input_InputManagerService.cpp
+++ b/services/core/jni/com_android_server_input_InputManagerService.cpp
@@ -202,6 +202,7 @@ public:
202202 void setSystemUiVisibility(int32_t visibility);
203203 void setPointerSpeed(int32_t speed);
204204 void setShowTouches(bool enabled);
205+ void setStylusIconEnabled(bool enabled);
205206 void setVolumeKeysRotation(int mode);
206207 void setInteractive(bool interactive);
207208 void reloadCalibration();
@@ -277,6 +278,9 @@ private:
277278 // Show touches feature enable/disable.
278279 bool showTouches;
279280
281+ // Show icon when stylus is used
282+ bool stylusIconEnabled;
283+
280284 // Volume keys rotation mode (0 - off, 1 - phone, 2 - tablet)
281285 int32_t volumeKeysRotationMode;
282286
@@ -316,6 +320,7 @@ NativeInputManager::NativeInputManager(jobject contextObj,
316320 mLocked.pointerSpeed = 0;
317321 mLocked.pointerGesturesEnabled = true;
318322 mLocked.showTouches = false;
323+ mLocked.stylusIconEnabled = false;
319324 mLocked.volumeKeysRotationMode = 0;
320325 }
321326 mInteractive = true;
@@ -464,6 +469,7 @@ void NativeInputManager::getReaderConfiguration(InputReaderConfiguration* outCon
464469 outConfig->pointerGesturesEnabled = mLocked.pointerGesturesEnabled;
465470
466471 outConfig->showTouches = mLocked.showTouches;
472+ outConfig->stylusIconEnabled = mLocked.stylusIconEnabled;
467473 outConfig->volumeKeysRotationMode = mLocked.volumeKeysRotationMode;
468474
469475 outConfig->setDisplayInfo(false /*external*/, mLocked.internalViewport);
@@ -773,6 +779,22 @@ void NativeInputManager::setShowTouches(bool enabled) {
773779 InputReaderConfiguration::CHANGE_SHOW_TOUCHES);
774780 }
775781
782+void NativeInputManager::setStylusIconEnabled(bool enabled) {
783+ { // acquire lock
784+ AutoMutex _l(mLock);
785+
786+ if (mLocked.stylusIconEnabled == enabled) {
787+ return;
788+ }
789+
790+ ALOGI("Setting stylus icon enabled to %s.", enabled ? "enabled" : "disabled");
791+ mLocked.stylusIconEnabled = enabled;
792+ } // release lock
793+
794+ mInputManager->getReader()->requestRefreshConfiguration(
795+ InputReaderConfiguration::CHANGE_STYLUS_ICON_ENABLED);
796+}
797+
776798 void NativeInputManager::setVolumeKeysRotation(int mode) {
777799 { // acquire lock
778800 AutoMutex _l(mLock);
@@ -1394,6 +1416,13 @@ static void nativeSetShowTouches(JNIEnv* /* env */,
13941416 im->setShowTouches(enabled);
13951417 }
13961418
1419+static void nativeSetStylusIconEnabled(JNIEnv* env,
1420+ jclass clazz, jlong ptr, jboolean enabled) {
1421+ NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
1422+
1423+ im->setStylusIconEnabled(enabled);
1424+}
1425+
13971426 static void nativeSetVolumeKeysRotation(JNIEnv* env,
13981427 jclass clazz, jlong ptr, int mode) {
13991428 NativeInputManager* im = reinterpret_cast<NativeInputManager*>(ptr);
@@ -1544,6 +1573,8 @@ static const JNINativeMethod gInputManagerMethods[] = {
15441573 (void*) nativeSetPointerSpeed },
15451574 { "nativeSetShowTouches", "(JZ)V",
15461575 (void*) nativeSetShowTouches },
1576+ { "nativeSetStylusIconEnabled", "(JZ)V",
1577+ (void*) nativeSetStylusIconEnabled },
15471578 { "nativeSetVolumeKeysRotation", "(JI)V",
15481579 (void*) nativeSetVolumeKeysRotation },
15491580 { "nativeSetInteractive", "(JZ)V",