From: snickersun Date: Thu, 3 Sep 2020 11:57:01 +0000 (+0800) Subject: 为A9添加隐藏式关机 X-Git-Url: http://git.snicker.com.cn/sitemap.xml?a=commitdiff_plain;h=eba179cb46ffbaa5edf4b300fef6fd6e023c829f;p=factoryMode.git 为A9添加隐藏式关机 --- diff --git a/app/release/FactoryMode_V47_202009021830_release.apk b/app/release/FactoryMode_V48_202009031956_release.apk 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 Binary files a/app/release/FactoryMode_V47_202009021830_release.apk and b/app/release/FactoryMode_V48_202009031956_release.apk differ diff --git a/app/release/output.json b/app/release/output.json index 6cbb6bd..c86441b 100644 --- a/app/release/output.json +++ b/app/release/output.json @@ -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 diff --git a/app/src/main/java/mobile/miki/shutdown_activity.java b/app/src/main/java/mobile/miki/shutdown_activity.java index a6ff49d..478738c 100644 --- a/app/src/main/java/mobile/miki/shutdown_activity.java +++ b/app/src/main/java/mobile/miki/shutdown_activity.java @@ -4,61 +4,78 @@ import android.content.Context; import android.os.Build; import android.os.Bundle; import android.util.Log; +import android.view.MotionEvent; import android.view.View; import android.widget.Button; +import android.widget.Toast; import java.lang.reflect.Method; +import mobile.miki.util.FTUtils; + public class shutdown_activity extends BaseActivity { String TAG="shutdown_activity"; Button btn_yes; Button btn_no; + + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_shutdown_activity); + setclicklistener(true); + if(FTUtils.isA9()){ + btn_yes.setVisibility(View.GONE); + } + + } + + private void setclicklistener(boolean b){ btn_yes =(Button)findViewById(R.id.btn_yes); btn_no =(Button)findViewById(R.id.btn_no); - btn_yes.setClickable(true); - btn_no.setClickable(true); - btn_no.setEnabled(true); - btn_yes.setEnabled(true); - btn_yes.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - //log("shutdown"); - finish(); - try { - - //获得ServiceManagerç±» - Class ServiceManager = Class - .forName("android.os.ServiceManager"); - - //获得ServiceManager的getService方法 - Method getService = ServiceManager.getMethod("getService", java.lang.String.class); - - //调用getService获取RemoteService - Object oRemoteService = getService.invoke(null, Context.POWER_SERVICE); - - //获得IPowerManager.Stubç±» - Class cStub = Class - .forName("android.os.IPowerManager$Stub"); - //获得asInterface方法 - Method asInterface = cStub.getMethod("asInterface", android.os.IBinder.class); - //调用asInterface方法获取IPowerManager对象 - Object oIPowerManager = asInterface.invoke(null, oRemoteService); - //获得shutdown()方法 - Method shutdown = oIPowerManager.getClass().getMethod("shutdown",boolean.class,boolean.class); - //调用shutdown()方法 - shutdown.invoke(oIPowerManager,false,true); - - } catch (Exception e) { - Log.e(TAG, e.toString(), e); + if (b==true){ + btn_yes.setClickable(true); + btn_yes.setEnabled(true); + btn_yes.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + //log("shutdown"); + finish(); + try { + + //获得ServiceManagerç±» + Class ServiceManager = Class + .forName("android.os.ServiceManager"); + + //获得ServiceManager的getService方法 + Method getService = ServiceManager.getMethod("getService", java.lang.String.class); + + //调用getService获取RemoteService + Object oRemoteService = getService.invoke(null, Context.POWER_SERVICE); + + //获得IPowerManager.Stubç±» + Class cStub = Class + .forName("android.os.IPowerManager$Stub"); + //获得asInterface方法 + Method asInterface = cStub.getMethod("asInterface", android.os.IBinder.class); + //调用asInterface方法获取IPowerManager对象 + Object oIPowerManager = asInterface.invoke(null, oRemoteService); + //获得shutdown()方法 + Method shutdown = oIPowerManager.getClass().getMethod("shutdown",boolean.class,boolean.class); + //调用shutdown()方法 + shutdown.invoke(oIPowerManager,false,true); + + } catch (Exception e) { + Log.e(TAG, e.toString(), e); + } } - } - }); + }); + } + + btn_no.setClickable(true); + btn_no.setEnabled(true); btn_no.setOnClickListener(new View.OnClickListener() { @Override @@ -67,4 +84,39 @@ public class shutdown_activity extends BaseActivity { } }); } + //(0~20,0~20),(130~170,0~20),(130~170,120~170),(0~20,120~170) + int[][] mapx={{0,40},{130,240},{0,40},{130,240}}; + int[][] mapy={{100,240},{100,240},{0,40},{0,40}}; + int touchindex=0; + + @Override + public boolean dispatchTouchEvent(MotionEvent ev) { + switch (ev.getAction()) { + case MotionEvent.ACTION_DOWN: + //有按下动作时取消定时 + + break; + case MotionEvent.ACTION_UP: + //抬起时启动定时 + float x = ev.getX(); + float y= ev.getY(); + if(FTUtils.isA9()){ + if ((x >mapx[touchindex][0] && x < mapx[touchindex][1] ) && (y > mapy[touchindex][0] && y < mapy[touchindex][1])){ + touchindex++; + if (touchindex ==4){ + touchindex=0; + btn_yes.setVisibility(View.VISIBLE); + + } + }else{ + touchindex=0; + } + } + break; + } + return super.dispatchTouchEvent(ev); + + } + + } diff --git a/app/src/main/res/layout/activity_shutdown_activity.xml b/app/src/main/res/layout/activity_shutdown_activity.xml index 74c1739..8ca9e01 100644 --- a/app/src/main/res/layout/activity_shutdown_activity.xml +++ b/app/src/main/res/layout/activity_shutdown_activity.xml @@ -5,12 +5,13 @@ android:orientation="vertical" android:background="@android:color/white"> + - -