android14 设置下连续点击5次Settings标题跳转到拨号界面

发布于:2025-06-29 ⋅ 阅读:(12) ⋅ 点赞:(0)

部分项目隐藏了拨号器,但开发者需要间距跳转到拨号界面
设置一级界面:
packages/apps/Settings/src/com/android/settings/homepage/SettingsHomepageActivity.java
通过dispatchTouchEvent方法先获取Settings标题的区域X,Y数据。

import java.util.Set;
+import android.view.MotionEvent;
 /** Settings homepage activity */
 public class SettingsHomepageActivity extends FragmentActivity implements
         CategoryMixin.CategoryHandler {
@@ -675,7 +675,58 @@ public class SettingsHomepageActivity extends FragmentActivity implements
         view.setFocusableInTouchMode(true);
         view.requestFocus();
     }
-
+    // add 
+    long press_time = 0;
+    int[] xm = new int[5];
+    int[] ym = new int[5];
+    long delta_time;
+    int istep = 0;
+    public boolean dispatchTouchEvent(MotionEvent motionEvent) {
+        int actionMasked = motionEvent.getActionMasked();
+               Log.d(TAG, "dispatchTouchEvent 11 actionMasked="+actionMasked);
+        if (actionMasked == 0) {
+            long currentTimeMillis = System.currentTimeMillis();
+            long j = this.press_time;
+            long j2 = currentTimeMillis - j;
+            this.delta_time = j2;
+            this.press_time = j + j2;                  
+               Log.d(TAG, "actionMasked == 0 j="+j+";j2="+j2+";");
+            if (j2 > 1000) {
+                this.istep = 0;
+            }
+            this.xm[this.istep] = (int) motionEvent.getX();
+            this.ym[this.istep] = (int) motionEvent.getY();
+                       //float x = motionEvent.getX();
+                       //float y = motionEvent.getY();
+                       //Log.d(TAG, "actionMasked == 0 x="+x+";;y="+y);
+               Log.d(TAG, "actionMasked == 0 this.istep="+this.istep+"this.xm[this.istep]="+this.xm[this.istep]+";this.ym[this.istep]"+this.ym[this.istep]);
+            int i = this.istep + 1;
+            this.istep = i;
+            if (i == 5) {
+                int[] iArr = this.xm;
+                int[] yArr = this.ym;
+                               if((iArr[0]>50 && iArr[0]<256)||(iArr[1]>50 && iArr[1]<256) ||(iArr[2]>50 && iArr[2]<256) 
+                                       ||(iArr[3]>50 && iArr[3]<256) ||(iArr[4]>50 && iArr[4]<256)){
+                                               if((yArr[0]>232 && yArr[0]<307)||(yArr[1]>232 && yArr[1]<307) ||(yArr[2]>232 && yArr[2]<307) 
+                                               ||(yArr[3]>232 && yArr[3]<307) ||(yArr[4]>232 && yArr[4]<307) ){
+                                                       Intent mIntent = new Intent();
+                                                       mIntent.setClassName("com.android.dialer","com.android.dialer.main.impl.MainActivity");
+                                                       startActivity(mIntent);
+                                               }
+                                       }                
+                this.istep = 0;
+            }
+        } else if (actionMasked == 1) {
+            long currentTimeMillis2 = System.currentTimeMillis();
+            long j3 = this.press_time;
+            long j4 = currentTimeMillis2 - j3;
+            this.delta_time = j4;
+            this.press_time = j3 + j4;
+        }
+        return super.dispatchTouchEvent(motionEvent);
+    }
+   // add end
+       
     private void updateHomepageAppBar() {


网站公告

今日签到

点亮在社区的每一天
去签到