为A9添加隐藏式关机
authorsnickersun <scy@incartech.cn>
Thu, 3 Sep 2020 11:57:01 +0000 (19:57 +0800)
committersnickersun <scy@incartech.cn>
Thu, 3 Sep 2020 11:57:01 +0000 (19:57 +0800)
app/release/FactoryMode_V48_202009031956_release.apk [moved from app/release/FactoryMode_V47_202009021830_release.apk with 80% similarity]
app/release/output.json
app/src/main/java/mobile/miki/shutdown_activity.java
app/src/main/res/layout/activity_shutdown_activity.xml
app/version_code.properties

similarity index 80%
rename from app/release/FactoryMode_V47_202009021830_release.apk
rename to app/release/FactoryMode_V48_202009031956_release.apk
index c38957a..8d9eda1 100644 (file)
Binary files a/app/release/FactoryMode_V47_202009021830_release.apk and b/app/release/FactoryMode_V48_202009031956_release.apk differ
index 6cbb6bd..c86441b 100644 (file)
@@ -1 +1 @@
-[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":47,"versionName":"202009021830","enabled":true,"outputFile":"FactoryMode_V47_202009021830_release.apk","fullName":"release","baseName":"release"},"path":"FactoryMode_V47_202009021830_release.apk","properties":{}}]
\ No newline at end of file
+[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":48,"versionName":"202009031956","enabled":true,"outputFile":"FactoryMode_V48_202009031956_release.apk","fullName":"release","baseName":"release"},"path":"FactoryMode_V48_202009031956_release.apk","properties":{}}]
\ No newline at end of file
index a6ff49d..478738c 100644 (file)
@@ -4,61 +4,78 @@ import android.content.Context;
 import android.os.Build;\r
 import android.os.Bundle;\r
 import android.util.Log;\r
+import android.view.MotionEvent;\r
 import android.view.View;\r
 import android.widget.Button;\r
+import android.widget.Toast;\r
 \r
 import java.lang.reflect.Method;\r
 \r
+import mobile.miki.util.FTUtils;\r
+\r
 public class shutdown_activity extends BaseActivity {\r
 \r
     String TAG="shutdown_activity";\r
     Button btn_yes;\r
     Button btn_no;\r
+\r
+\r
     @Override\r
     protected void onCreate(Bundle savedInstanceState) {\r
         super.onCreate(savedInstanceState);\r
         setContentView(R.layout.activity_shutdown_activity);\r
+        setclicklistener(true);\r
+        if(FTUtils.isA9()){\r
+            btn_yes.setVisibility(View.GONE);\r
+        }\r
+\r
+    }\r
+\r
+    private void setclicklistener(boolean b){\r
         btn_yes =(Button)findViewById(R.id.btn_yes);\r
         btn_no =(Button)findViewById(R.id.btn_no);\r
-        btn_yes.setClickable(true);\r
-        btn_no.setClickable(true);\r
-        btn_no.setEnabled(true);\r
-        btn_yes.setEnabled(true);\r
 \r
-        btn_yes.setOnClickListener(new View.OnClickListener() {\r
-            @Override\r
-            public void onClick(View v) {\r
-                //log("shutdown");\r
-                finish();\r
-                try {\r
-\r
-                    //获得ServiceManager类\r
-                    Class  ServiceManager = Class\r
-                            .forName("android.os.ServiceManager");\r
-\r
-                    //获得ServiceManager的getService方法\r
-                    Method getService = ServiceManager.getMethod("getService", java.lang.String.class);\r
-\r
-                    //调用getService获取RemoteService\r
-                    Object oRemoteService = getService.invoke(null, Context.POWER_SERVICE);\r
-\r
-                    //获得IPowerManager.Stub类\r
-                    Class cStub = Class\r
-                            .forName("android.os.IPowerManager$Stub");\r
-                    //获得asInterface方法\r
-                    Method asInterface = cStub.getMethod("asInterface", android.os.IBinder.class);\r
-                    //调用asInterface方法获取IPowerManager对象\r
-                    Object oIPowerManager = asInterface.invoke(null, oRemoteService);\r
-                    //获得shutdown()方法\r
-                    Method shutdown = oIPowerManager.getClass().getMethod("shutdown",boolean.class,boolean.class);\r
-                    //调用shutdown()方法\r
-                    shutdown.invoke(oIPowerManager,false,true);\r
-\r
-                } catch (Exception e) {\r
-                    Log.e(TAG, e.toString(), e);\r
+        if (b==true){\r
+            btn_yes.setClickable(true);\r
+            btn_yes.setEnabled(true);\r
+            btn_yes.setOnClickListener(new View.OnClickListener() {\r
+                @Override\r
+                public void onClick(View v) {\r
+                    //log("shutdown");\r
+                    finish();\r
+                    try {\r
+\r
+                        //获得ServiceManager类\r
+                        Class  ServiceManager = Class\r
+                                .forName("android.os.ServiceManager");\r
+\r
+                        //获得ServiceManager的getService方法\r
+                        Method getService = ServiceManager.getMethod("getService", java.lang.String.class);\r
+\r
+                        //调用getService获取RemoteService\r
+                        Object oRemoteService = getService.invoke(null, Context.POWER_SERVICE);\r
+\r
+                        //获得IPowerManager.Stub类\r
+                        Class cStub = Class\r
+                                .forName("android.os.IPowerManager$Stub");\r
+                        //获得asInterface方法\r
+                        Method asInterface = cStub.getMethod("asInterface", android.os.IBinder.class);\r
+                        //调用asInterface方法获取IPowerManager对象\r
+                        Object oIPowerManager = asInterface.invoke(null, oRemoteService);\r
+                        //获得shutdown()方法\r
+                        Method shutdown = oIPowerManager.getClass().getMethod("shutdown",boolean.class,boolean.class);\r
+                        //调用shutdown()方法\r
+                        shutdown.invoke(oIPowerManager,false,true);\r
+\r
+                    } catch (Exception e) {\r
+                        Log.e(TAG, e.toString(), e);\r
+                    }\r
                 }\r
-            }\r
-        });\r
+            });\r
+        }\r
+\r
+        btn_no.setClickable(true);\r
+        btn_no.setEnabled(true);\r
 \r
         btn_no.setOnClickListener(new View.OnClickListener() {\r
             @Override\r
@@ -67,4 +84,39 @@ public class shutdown_activity extends BaseActivity {
             }\r
         });\r
     }\r
+    //(0~20,0~20),(130~170,0~20),(130~170,120~170),(0~20,120~170)\r
+    int[][] mapx={{0,40},{130,240},{0,40},{130,240}};\r
+    int[][] mapy={{100,240},{100,240},{0,40},{0,40}};\r
+    int touchindex=0;\r
+\r
+    @Override\r
+    public boolean dispatchTouchEvent(MotionEvent ev) {\r
+        switch (ev.getAction()) {\r
+            case MotionEvent.ACTION_DOWN:\r
+                //有按下动作时取消定时\r
+\r
+                break;\r
+            case MotionEvent.ACTION_UP:\r
+                //抬起时启动定时\r
+                float x = ev.getX();\r
+                float y= ev.getY();\r
+                if(FTUtils.isA9()){\r
+                    if  ((x >mapx[touchindex][0] && x < mapx[touchindex][1] ) && (y > mapy[touchindex][0] && y < mapy[touchindex][1])){\r
+                        touchindex++;\r
+                        if (touchindex ==4){\r
+                            touchindex=0;\r
+                            btn_yes.setVisibility(View.VISIBLE);\r
+\r
+                        }\r
+                    }else{\r
+                        touchindex=0;\r
+                    }\r
+                }\r
+                break;\r
+        }\r
+        return super.dispatchTouchEvent(ev);\r
+\r
+    }\r
+\r
+\r
 }\r
index 74c1739..8ca9e01 100644 (file)
@@ -5,12 +5,13 @@
     android:orientation="vertical"\r
     android:background="@android:color/white">\r
 \r
+\r
     <LinearLayout\r
+        android:id="@+id/pf_layout2"\r
         android:layout_width="match_parent"\r
         android:layout_height="wrap_content"\r
         android:layout_centerInParent="true"\r
         android:orientation="vertical">\r
-\r
         <TextView\r
             android:id="@+id/shutdownText"\r
             android:layout_width="wrap_content"\r
@@ -23,7 +24,6 @@
             android:textStyle="bold" />\r
     </LinearLayout>\r
 \r
-\r
     <LinearLayout\r
         android:layout_width="match_parent"\r
         android:layout_height="wrap_content"\r
@@ -35,7 +35,7 @@
             android:id="@+id/btn_no"\r
             style="@style/button_white_text"\r
             android:layout_width="0dp"\r
-            android:layout_height="match_parent"\r
+            android:layout_height="40dp"\r
             android:layout_weight="1"\r
             android:background="#DA5B17"\r
             android:text="@string/rf_no"\r
@@ -46,7 +46,7 @@
             android:id="@+id/btn_yes"\r
             style="@style/button_white_text"\r
             android:layout_width="0dp"\r
-            android:layout_height="match_parent"\r
+            android:layout_height="40dp"\r
             android:layout_weight="1"\r
             android:background="#DA5B17"\r
             android:text="@string/rf_yes"\r
index dbaba4f..1126675 100644 (file)
@@ -1,2 +1,2 @@
-#Wed Sep 02 18:30:55 CST 2020\r
-VERSION_CODE=47\r
+#Thu Sep 03 19:56:10 CST 2020\r
+VERSION_CODE=48\r