android 4.4 mtk 默认滑动解锁改为假指纹解锁

android4.4,客户要求去掉滑动解锁,更改为假指纹触摸方式············
先看一下kk锁屏界面
android 4.4 mtk 默认滑动解锁改为假指纹解锁_第1张图片

想法是直接把滑动解锁图标换成指纹,然后onTouch解锁,要把滑动事件去掉。
kk版本Keyguard代码和SystemUI是分开的,代码路径:frameworks/base/packages/Keyguard/

1.先替换中间锁图标的资源,一张图片:

frameworks\base\packages\Keyguard\res\drawable-hdpi\ic_lockscreen_handle_normal.png
替换为:
android 4.4 mtk 默认滑动解锁改为假指纹解锁_第2张图片

2.去掉触摸指纹区域时边界出现的开锁图标

+++ b/alps/frameworks/base/packages/Keyguard/res/drawable/ic_lockscreen_unlock.xml
@@ -15,11 +15,12 @@
 -->
 <selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item
         android:state_enabled="true"
         android:state_active="false"
         android:state_focused="false"
+        android:visibility="gone"
         android:drawable="@drawable/ic_lockscreen_unlock_normal" />

3.去掉拖动效果,改为长按解锁

解锁动画是一个自定义View:frameworks/base/packages/Keyguard/src/com/mediatek/keyguard/GlowPadView/MediatekGlowPadView.java

@@ -1024,18 +1026,30 @@ public class MediatekGlowPadView extends View implements OnTouchListener {
+       private Rect mTouchArea = new Rect(187, 231, 293, 333); ///mh.add 大概的触摸区域
         
         /// }@
         boolean handled = false;
+        long downTime = 0;
         switch (action) {
             case MotionEvent.ACTION_POINTER_DOWN:
             case MotionEvent.ACTION_DOWN:
                 if (DEBUG) Log.v(TAG, "*** DOWN ***");
                 handleDown(event);
-                handleMove(event);
+                //handleMove(event);//拖动效果
                 handled = true;
+                downTime = event.getDownTime();
                 break;
 
             case MotionEvent.ACTION_MOVE:
                 if (DEBUG) Log.v(TAG, "*** MOVE ***");
-                handleMove(event);
+                ///mh.modify
+                //handleMove(event);
+                int touchX = (int)event.getX();
+                int touchY = (int)event.getY();
+                long touchTime = (event.getEventTime() - event.getDownTime()) / 100;
+                android.util.Log.d("mh.mmi", "touchTime:"+touchTime+" mTouchArea:"+mTouchArea.contains(touchX, touchY)+" touchX:"+touchX +" touchY:"+touchY);
+                if (touchTime == 3 && mTouchArea.contains(touchX, touchY)) {
+                         dispatchTriggerEvent(0);///unlock
+                }
+                ///mh.end
                 handled = true;
                 break;

@@ -1044,12 +1058,13 @@ public class MediatekGlowPadView extends View implements OnTouchListener {
                 if (DEBUG) Log.v(TAG, "*** UP ***");
                 /// M: In default logic, ACTION_UP should trigger events, but ACTION_CANCEL should not.
                 mActionCancel = false;
-                handleMove(event);
+                //handleMove(event);///拖动
                 handleUp(event);

4.触摸指纹图标不要消失

+++ b/alps/frameworks/base/packages/Keyguard/src/com/mediatek/keyguard/GlowPadView/MediatekGlowPadView.java
@@ -571,7 +571,7 @@ public class MediatekGlowPadView extends View implements OnTouchListener {
 
             case STATE_FIRST_TOUCH:
                 mGlowPadViewState = STATE_FIRST_TOUCH;
-                mHandleDrawable.setAlpha(0.0f);
+                mHandleDrawable.setAlpha(1.0f);
                 deactivateTargets();
                 showTargets(true);
                 startBackgroundAnimation(INITIAL_SHOW_HANDLE_DURATION, 1.0f);
@@ -583,14 +583,14 @@ public class MediatekGlowPadView extends View implements OnTouchListener {
 
             case STATE_TRACKING:
                 mGlowPadViewState = STATE_TRACKING;
-                mHandleDrawable.setAlpha(0.0f);
+                mHandleDrawable.setAlpha(1.0f);
                 showGlow(REVEAL_GLOW_DURATION , REVEAL_GLOW_DELAY, 1.0f, null);
                 break;
 
             case STATE_SNAP:
                 // TODO: Add transition states (see list_selector_background_transition.xml)
                 mGlowPadViewState = STATE_SNAP;
-                mHandleDrawable.setAlpha(0.0f);
+                mHandleDrawable.setAlpha(1.0f);
                 showGlow(REVEAL_GLOW_DURATION , REVEAL_GLOW_DELAY, 0.0f, null);
                 break;
 
@@ -1859,7 +1859,7 @@ public class MediatekGlowPadView extends View implements OnTouchListener {
         mFakeHandleRealY = 0.0f;
         
         mHandleDrawable.setState(TargetDrawable.STATE_INACTIVE);
-        mHandleDrawable.setAlpha(0.0f);
+        mHandleDrawable.setAlpha(1.0f);

最后看下效果 》》》
android 4.4 mtk 默认滑动解锁改为假指纹解锁_第3张图片

你可能感兴趣的:(android客制,android,动画,java)