android4.0-4.4 How to add entity key Vibration Support (Java + Smali version)

Source: Internet
Author: User

Some mobile phones such as Pan-Thai a820l, pan-Thai A890 A900 and Nubia z5s and z5s Mini have entity keys (the entity keys here are relative to the virtual keys, including physical keys and touch screen more than the Touch entity button ), When compiling a third-party rom such as cm or Mokee or omni, you will find that if you do not modify the default Touch entity button is not vibration support, and even some patchrom miui or Coloros and other systems may not be supported. Do not know is the CM code problem or compiled config did not write completely, and later after I modified is can support key vibration, but only as a temporary solution reference.


Reprint please specify source and URL:

http://blog.csdn.net/syhost/article/details/32067695


Java version Code

I submitted the CM review, did not pass, because if added in not modified, will affect the virtual key vibration, will cause the home key vibration two times, but only as a support entity key vibration words can still:

Http://review.cyanogenmod.org/#/c/55274/1/policy/src/com/android/internal/policy/impl/PhoneWindowManager.java


The modified location is Android.policy.jar in the source code frameworks/base/policy/src/com/android/internal/policy/impl/ Phonewindowmanager.java


Diff--git A/policy/src/com/android/internal/policy/impl/phonewindowmanager.java B/policy/src/com/android/ Internal/policy/impl/phonewindowmanager.javaindex F0719e3. ca38166 100644---a/policy/src/com/android/internal/policy/impl/phonewindowmanager.java+++ b/policy/src/com/ android/internal/policy/impl/phonewindowmanager.java@@ -2333,6 +2333,22 @@ public class Phonewindowmanager implements Windowmanagerpolicy {WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.TYP E_system_error,};+ + private void Setkeyvib (WindowState win) {+ Windowmanager.layoutparams attrs; + Intent service;+ contentresolver res;+ +//If A system window has focus and then it doesn ' t make sense +//right, interact with applications.+attrs = win! = null? Win.getattrs (): Null;+service = new Intent (); +res = Mcontext.getcontentresolver (); +if (1 = = Settings.System.getInt (res, settings.system.haptic_feedback_enabled,0))//when SettinG feedback ENABLE+{+PERFORMHAPTICFEEDBACKLW (null, HAPTICFEEDBACKCONSTANTS.KEYBOARD_TAP, TRUE);//Start vibration by syhost+}+} /** {@inheritDoc} */@Override @@ -2441,7 +2457,8 @@ -2441,7 class Phonewindowmanager implements Windowmanagerpolicy                     {viewconfiguration.getdoubletaptimeout ());                 return-1;                 }-+ +setkeyvib (Win);                 Go home!                 Launchhomefromhotkey ();                 return-1;@@ -2514,6 +2531,7 @@ public class Phonewindowmanager implements Windowmanagerpolicy {}                     if (repeatcount = = 0) {mmenupressed = true;+ setkeyvib (win); if (Menableshiftmenubugreports && (metaState & chordbug) = = Chordbug) {Inten                         T intent = new Intent (intent.action_bug_report); Mcontext.sendorderedbroadcast (intent, NULL); @@ -2645,9 +2663,13 @@ -2645,9 class Phonewindowmanager implements Windowmanagerpolicy {} return-1;        } else if (keycode = = keyevent.keycode_back) {+ if (down && repeatcount = = 0) {+ setkeyvib (win); + } if (Settings.Secure.getIntForUser (Mcontext.getcontentresolver (), Settings.Secure.KI                Ll_app_longpress_back, 0, userhandle.user_current) = = 1) {if (down && repeatcount = = 0) {+                     Setkeyvib (Win);                 Mhandler.postdelayed (mbacklongpress, mbackkilltimeout); }             }




The corresponding Smali version,

I can find it in the CM10 version of the Pan Thai a820l, which I adapted before, and it is done in several times:


PATCH1:

Https://github.com/syhost/lewa_patchrom_ef65l/commit/18afafa2c7b770bdb593fee086c7cc07f8789e58

    Goto:goto_0 End Method +.method private Setkeyvib (landroid/view/windowmanagerpolicy$windowstate;) V +. Locals 7 +. Parameter "Win" + +. Prologue + CONST/4 v3, 0x0 + + CONST/4 V6, 0x1 + +. Line 2110 + if-eqz p1,: con D_1 + + Invoke-interface {p1}, Landroid/view/windowmanagerpolicy$windowstate;->getattrs () Landroid/view/ Windowmanager$layoutparams; + + Move-result-object V0 + +. Line 2111 +. Local V0, Attrs:landroid/view/windowmanager$layoutparams; +: Goto_0 + new-instance v2, landroid/content/intent; + + Invoke-direct {v2}, landroid/content/intent;-><init> () V + +. Line 2112 +. Local v2, Service:landroid /content/intent; + Iget-object v4, P0, lcom/android/internal/policy/impl/phonewindowmanager;->mcontext:landroid/content/context; + + invoke-virtual {v4}, Landroid/content/context;->getcontentresolver () Landroid/content/contentresolver; + + Move-result-object V1 + +. Line 2113 +. Local V1, Res:landroid/conTent/contentresolver; + const-string v4, "haptic_feedback_enabled" + + CONST/4 V5, 0x0 + + invoke-static {v1, v4, v5}, Landroid/provide R/settings$system;->getint (Landroid/content/contentresolver; Ljava/lang/string;i) I + + Move-result v4 + + If-ne V6, v4,: Cond_0 + +. Line 2115 + CONST/4 v4, 0x3 + + INV oke-virtual {p0, v3, V4, V6}, LCOM/ANDROID/INTERNAL/POLICY/IMPL/PHONEWINDOWMANAGER;-&GT;PERFORMHAPTICFEEDBACKLW (           Landroid/view/windowmanagerpolicy$windowstate;iz) Z + +. Line 2117 +: Cond_0 + return-void + +. End Local V0 #attrs: Landroid/view/windowmanager$layoutparams; +. End Local V1 #res: landroid/content/contentresolver; +. End Local v2 #service: landroid/content/intent;       +: Cond_1 + move-object V0, v3 + +. Line 2110 + goto:goto_0 +.end method +. Method Private Takescreenshot () V      . Locals 8 @@ -8384,6 +8446,7 @@ -8384,6 line 1799. End Local v11 #ex: landroid/os/remoteexception; : CoNd_6 + invoke-direct/range {p0. p1}, Lcom/android/internal/policy/impl/phonewindowmanager;->setkeyvib (Landroid/ view/windowmanagerpolicy$windowstate;) V invoke-virtual/range {p0. P0}, lcom/android/internal/policy/impl/    Phonewindowmanager;->launchhomefromhotkey () V goto:goto_4 @@ -8631,6 +8694,8 @@ -8631,6 v23,: cond_1c + Invoke-direct/range {p0. p1}, Lcom/android/internal/policy/impl/phonewindowmanager;->setkeyvib (Landroid/view/ windowmanagerpolicy$windowstate;) V +. Line 1853 move-object/from16 V0, P0



PATCH2:

https://github.com/syhost/lewa_patchrom_ef65l/commit/0e5ff497456e9428546be24bae36dfcf4544863f

       MOVE/FROM16 v1, v32   -    if-ne v0, v1,: cond_1c +    if-ne v0, v1,: cond_34        . Line 1894      If-eqz v9,: cond_1a @ @ -8887,7 +8887,25 @@ const-wide/16      v32, -0x1        goto/16:goto_1 +     +    : cond_34 +    const/16 v32, 0x4 + +
   MOVE/FROM16 V0, v18 + +    MOVE/FROM16 v1, v32 + +    if-ne v0, v1,: cond_1c + +    if-eqz v9,: cond_1c   +
   if-nez v23,: cond_1c + +    invoke-direct/range {p0: p1}, Lcom/android/internal/policy/impl/phonewindowmanager; ->setkeyvib (landroid/view/windowmanagerpolicy$windowstate;) V +     +    goto/16:goto_34 +     +          . Line 1897      : cond_19      const/16 v32, 0x1 @@ -8946,6 +8964,7 @@ -8946,6        . Line 1920x1080 +    : goto_34< c27/>:cond_1c      move-object/from16 V0, P0

The above PATCH2 is mainly added to prevent long press the home button long vibration, the corresponding Java part is:

+        if (down && repeatcount = = 0) {+        Setkeyvib (win); +        }






Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.