java 鼠标隐藏_Android显示/隐藏鼠标的方法

功能:长按遥控的search键后,切换为飞鼠模式。

问题:

1.切换飞鼠模式鼠标没有显示出来(要按其他上下左右按钮才开始显示)

2.切换回按键模式后,鼠标是自动等待一段时间消失,而不是立即消失

隐藏鼠标功能的流程

1.从下面这个博客得到启示

画鼠标流程

鼠标由PointerController.cpp控制。

文件在framework/base/libs/input/PointerController.cpp

鼠标隐藏的方法void PointerController::fade(Transition transition) {

AutoMutex _l(mLock);

// Remove the inactivity timeout, since we are fading now.

removeInactivityTimeoutLocked();

// Start fading.

if (transition == TRANSITION_IMMEDIATE) {

mLocked.pointerFadeDirection = 0;

mLocked.pointerAlpha = 0.0f;

updatePointerLocked();

} else {

mLocked.pointerFadeDirection = -1;

startAnimationLocked();

}

}

本次补丁是framework/base/services/core/java/com/android/server/policy/PhoneWindowManaer.javadiff --git a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

index dac1474..6009abc 100755 (executable)

--- a/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

+++ b/frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.java

@@ -161,6 +161,8 @@ import java.io.PrintWriter;

import java.util.HashSet;

import java.util.List;

+import android.widget.Toast;

+

/**

* WindowManagerPolicy implementation for the Android phone UI.  This

* introduces a new method suffix, Lp, for an internal lock of the

@@ -366,11 +368,13 @@ public class PhoneWindowManager implements WindowManagerPolicy {

/** If true, hitting shift & menu will broadcast Intent.ACTION_BUG_REPORT */

boolean mEnableShiftMenuBugReports = false;

+    boolean mEscPressd = false;

+

boolean mSafeMode;

WindowState mStatusBar = null;

int mStatusBarHeight;

WindowState mNavigationBar = null;

-    boolean mHasNavigationBar = false;

+    boolean mHasNavigationBar = true;

boolean mNavigationBarCanMove = false; // can the navigation bar ever move to the side?

int mNavigationBarPosition = NAV_BAR_BOTTOM;

int[] mNavigationBarHeightForRotationDefault = new int[4];

@@ -1546,6 +1550,26 @@ public class PhoneWindowManager implements WindowManagerPolicy {

private final ScreenshotRunnable mScreenshotRunnable = new ScreenshotRunnable();

+    Runnable HPHRunable = new Runnable(){

+            public void run(){

+                mEscPressd = true;

+               Log.e(TAG,"linjc:HPHRunable");

+               mstate=SystemProperties.get("sys.KeyMouse.mKeyMouseState");

+               if(mstate.equals("on"))

+               {

+                       SystemProperties.set("sys.KeyMouse.mKeyMouseState","off");

+                              Toast.makeText(mContext, "Restore the default button mode", Toast.LENGTH_LONG).show();

+               //             Toast.makeText(getActivity(), "Restore the default button mode", Toast.LENGTH_LONG).show();

+                      }

+                      else

+                      {

+                              SystemProperties.set("sys.KeyMouse.mKeyMouseState","on");

+                              Toast.makeText(mContext, "Into Mouse mode,click this key again out of this mode", Toast.LENGTH_LONG).show();

+               //             Toast.makeText(getActivity(), "Into Mouse mode,click this key again out of this mode", Toast.LENGTH_LONG).show();

+               }

+            }

+    };

+

@Override

public void showGlobalActions() {

mHandler.removeMe

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值