From: TrillGates Date: Wed, 25 Aug 2021 03:51:46 +0000 (+0800) Subject: handle shutdown form 8541. X-Git-Url: http://git.snicker.com.cn/?a=commitdiff_plain;h=5572678e0f16c6f08f50a61bb5eb8371b5be1795;p=protocol_srv.git handle shutdown form 8541. --- diff --git a/app/src/main/java/com/ic/protocolSrv/CoreService.java b/app/src/main/java/com/ic/protocolSrv/CoreService.java index 1ac6cadd..eb7d2f7c 100644 --- a/app/src/main/java/com/ic/protocolSrv/CoreService.java +++ b/app/src/main/java/com/ic/protocolSrv/CoreService.java @@ -1525,7 +1525,7 @@ public class CoreService extends Service { mHandler.postDelayed(new Runnable() { @Override public void run() { - Util.shutdown(); + Util.shutdown(context); } }, 1000); } diff --git a/app/src/main/java/com/ic/protocolSrv/service/Deliver.java b/app/src/main/java/com/ic/protocolSrv/service/Deliver.java index a329291c..e8dec33f 100644 --- a/app/src/main/java/com/ic/protocolSrv/service/Deliver.java +++ b/app/src/main/java/com/ic/protocolSrv/service/Deliver.java @@ -188,8 +188,8 @@ public class Deliver extends AbstractConnectionService { .append("\nDate ").append(msg.getDate()).append(msg.getTime()) .append("\nflag ").append(msg.haveSent()) .append("\ntopic ").append(msg.cmd()); - if(Config.protocol_no == Config.PROTOCOL_GATOR){ - if(msg.isFromCache().length()>8) { + if (Config.protocol_no == Config.PROTOCOL_GATOR) { + if (msg.isFromCache().length() > 8) { sb.append("\norigin ").append(AESCipher.aesDecryptStringFixedKey(msg.isFromCache().substring(8))); } } @@ -447,7 +447,7 @@ public class Deliver extends AbstractConnectionService { if (mConnection instanceof NettyConnection) { ((NettyConnection) mConnection).sendMsg("RAWPACKET", protocolAPIHelper.getVoicePacketItem(voicepacket.getSender(), - voicepacket.getDurationHex(),voicepacket.getPacketTime(), + voicepacket.getDurationHex(), voicepacket.getPacketTime(), voicepacket.getPacketCount(), (voicepacket.getCurrentIndexToSent() + 1), voicepacket.getVoicePacketWithIndex(voicepacket.getCurrentIndexToSent()).getPacketLen(), @@ -455,7 +455,7 @@ public class Deliver extends AbstractConnectionService { ); } } else { - ICLogger.i("voicepacket Sender "+voicepacket.getSender()+" duration 0x"+voicepacket.getDurationHex()+" " + voicepacket.getName() + " filetype " + voicepacket.getFiletype() + " , datatype " + voicepacket.getDateType() + " " + voicepacket.getPacketTime() + " sent Done!"); + ICLogger.i("voicepacket Sender " + voicepacket.getSender() + " duration 0x" + voicepacket.getDurationHex() + " " + voicepacket.getName() + " filetype " + voicepacket.getFiletype() + " , datatype " + voicepacket.getDateType() + " " + voicepacket.getPacketTime() + " sent Done!"); } return true; } else if ("PhotoRemoteTaken".equals(paramStringMessage.cmd())) { @@ -488,10 +488,10 @@ public class Deliver extends AbstractConnectionService { //创建voiceConent并添加到数据 final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, - "123", msgUrl,"0000", 2, 2); + "123", msgUrl, "0000", 2, 2); // 把voiceContent拆解成1024的分包 - Util.parseToVoicePacketSent(voiceContent,1024); + Util.parseToVoicePacketSent(voiceContent, 1024); //trigger 分包发送 if (CoreService.getInstance().getConnection() != null) { //H88 专用功能拍照时检测用户体温心率 @@ -521,12 +521,8 @@ public class Deliver extends AbstractConnectionService { } else { Util.ShowToast(paramRuntime, "Do poweroff!"); } - mSendMSGHandler.postDelayed(new Runnable() { - @Override - public void run() { - Util.shutdown(); - } - }, 2000); + mSendMSGHandler.postDelayed(() -> + Util.shutdown(paramRuntime.getContextProxy().context), 2000); return true; } else if ("FactoryResetCheckSim".equals(paramStringMessage.cmd())) { @@ -550,7 +546,7 @@ public class Deliver extends AbstractConnectionService { mSendMSGHandler.postDelayed(new Runnable() { @Override public void run() { - Util.shutdown(); + Util.shutdown(paramRuntime.getContextProxy().context); } }, 2000); return true; @@ -573,7 +569,6 @@ public class Deliver extends AbstractConnectionService { } else if ("heartbeat".equals(paramStringMessage.cmd())) { //每次心跳,查询一下 是否有语音消息需要接收。 // paramConnection.send(protocolAPIHelper.genStringMessage("AP05",protocolAPIHelper.AP05(true))); - } else if ("getWeather".equals(paramStringMessage.cmd())) { ICLogger.i("获取天气"); mConnection.send(protocolAPIHelper.getWeatherMSG(mRuntime)); @@ -624,13 +619,16 @@ public class Deliver extends AbstractConnectionService { context.sendBroadcast(intent); } } else if ("findDev".equals(paramStringMessage.cmd())) { + ICLogger.d("find device..."); mSendMSGHandler.postDelayed(() -> { final Context context = (mRuntime.getContextProxy()).context; Intent intent = new Intent(); ICLogger.d(Constants.ACTION_MESSAGE_RECEIVED + " " + paramStringMessage.isFromCache()); //显示提示窗口 intent.setAction(DIALOG_ACTION); - intent.putExtra("findDev", "Find Device"); + intent.putExtra("findDev", context.getString(R.string.find_device_text)); + intent.setPackage(context.getPackageName()); + ICLogger.d("send find device action..."); context.sendBroadcast(intent); }, 500); @@ -665,9 +663,9 @@ public class Deliver extends AbstractConnectionService { * * * 1 语音—— 1.监听语音 * 2.SOS语音 * 3.扩展 * * * 2 图片—— 1.签到图片 * 2.指令图片 * 3.设备图片 * 4.扩展 */ - final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, "123","0000", recordfilepath, 1, 1); + final VoiceContent voiceContent = VoiceContent.placeHolderOut(CONTACT_CATEGORY_GROUP, "123", "0000", recordfilepath, 1, 1); // 把voiceContent拆解成1024的分包 - Util.parseToVoicePacketSent(voiceContent,1024); + Util.parseToVoicePacketSent(voiceContent, 1024); //trigger 分包发送 if (CoreService.getInstance().getConnection() != null) CoreService.getInstance().getConnection().DeliverCMDMessageToSystem("SentVoicePacket", ""); diff --git a/app/src/main/java/com/ic/protocolSrv/utils/CustomDialog.java b/app/src/main/java/com/ic/protocolSrv/utils/CustomDialog.java index 5a2a349d..f32796a7 100644 --- a/app/src/main/java/com/ic/protocolSrv/utils/CustomDialog.java +++ b/app/src/main/java/com/ic/protocolSrv/utils/CustomDialog.java @@ -52,7 +52,6 @@ public class CustomDialog extends Dialog { } private CustomDialog getDialogInstance() { - this.mDialog = new CustomDialog(this.context, R.style.Dialog); LayoutInflater var1 = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View view; diff --git a/app/src/main/java/com/ic/protocolSrv/utils/ProcessReceiver.java b/app/src/main/java/com/ic/protocolSrv/utils/ProcessReceiver.java index 269aaf88..e4c42b3c 100644 --- a/app/src/main/java/com/ic/protocolSrv/utils/ProcessReceiver.java +++ b/app/src/main/java/com/ic/protocolSrv/utils/ProcessReceiver.java @@ -109,7 +109,8 @@ public class ProcessReceiver extends BroadcastReceiver { contentBuilder.append(" "); contentBuilder.append(fromWhere); contentBuilder.append(context.getString(R.string.voiceMessageEnd)); - mCustomDialog = tmpDialog.setMessage(contentBuilder.toString()).setPositiveButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() { + mCustomDialog = tmpDialog.setMessage(contentBuilder.toString()) + .setPositiveButton(context.getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface var1x, int var2x) { var1x.dismiss(); ComponentName var3 = new ComponentName("com.ic.icwetalk", @@ -135,7 +136,7 @@ public class ProcessReceiver extends BroadcastReceiver { VibrateUtil.getInstance(context).vibrateOn(false); } }).create(); - mCustomDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST); + mCustomDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); mCustomDialog.show(); } else if (app_id == 2) { tmpDialog = this.mDialog.setTitle(context.getString(R.string.hht_misscall_call)).setApp(app_id); @@ -149,7 +150,7 @@ public class ProcessReceiver extends BroadcastReceiver { VibrateUtil.getInstance(context).vibrateOn(false); } }).create(); - mCustomDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST); + mCustomDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); mCustomDialog.show(); } else if (app_id == 3) { tmpDialog = this.mDialog.setTitle(context.getString(R.string.sms_title)).setApp(1); @@ -177,7 +178,7 @@ public class ProcessReceiver extends BroadcastReceiver { VibrateUtil.getInstance(context).vibrateOn(false); } }).create(); - mCustomDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST); + mCustomDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); mCustomDialog.show(); } else if (app_id == 4) { tmpDialog = this.mDialog.setTitle("WEB" + context.getString(R.string.sms_title)).setApp(1); @@ -209,7 +210,7 @@ public class ProcessReceiver extends BroadcastReceiver { } }).create(); } - mCustomDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST); + mCustomDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); mCustomDialog.show(); } else if (app_id == 5) { tmpDialog = this.mDialog.setTitle(context.getString(R.string.findDev)).setApp(1); @@ -222,7 +223,7 @@ public class ProcessReceiver extends BroadcastReceiver { stopmediaplayer(); } }).create(); - mCustomDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST); + mCustomDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); mCustomDialog.show(); } else if (app_id == 6) { tmpDialog = this.mDialog.setTitle(context.getString(R.string.notification_title)).setApp(1); @@ -255,7 +256,7 @@ public class ProcessReceiver extends BroadcastReceiver { } } }).create(); - mCustomDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_TOAST); + mCustomDialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT); mCustomDialog.show(); } } @@ -356,16 +357,11 @@ public class ProcessReceiver extends BroadcastReceiver { playshutdownsound(paramContext); - Util.shutdown(); + Util.shutdown(paramContext); return; } else if (ACTION_PLAYTIME.equals(str)) { LedUtil.setBlueLedOn(true); - mHandler.postDelayed(new Runnable() { - @Override - public void run() { - LedUtil.setBlueLedOn(false); - } - }, 2000L); + mHandler.postDelayed(() -> LedUtil.setBlueLedOn(false), 2000L); return; } else if (ACTION_REMOTE_CAMERA.equals(str)) { if (paramIntent.hasExtra("remote_number")) { @@ -412,6 +408,7 @@ public class ProcessReceiver extends BroadcastReceiver { return; } else if (DIALOG_ACTION.equals(str)) { + ICLogger.d("receive DIALOG_ACTION"); if (paramIntent.hasExtra("contact")) { contact = (Contact) paramIntent.getParcelableExtra("contact"); SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false); @@ -472,14 +469,16 @@ public class ProcessReceiver extends BroadcastReceiver { this.screenOn(paramContext); } } else if (paramIntent.hasExtra("findDev")) { - String finddevtxt = paramIntent.getStringExtra("findDev"); + ICLogger.d("hasExtra(findDev)"); + String findDevTxt = paramIntent.getStringExtra("findDev"); SharePreferenceUtil.getPrefBoolean(paramContext, "key_is_resume", false); isSilence = SharePreferenceUtil.getPrefBoolean(paramContext, "KEY_ISSILENCE", false); - if (finddevtxt != null && !isSilence) { - this.initMyDialog(paramContext, null, 5, finddevtxt, false); + ICLogger.d("isSilence ==> " + isSilence); + ICLogger.d("findDevTxt ==> " + findDevTxt); + if (findDevTxt != null && !isSilence) { + this.initMyDialog(paramContext, null, 5, findDevTxt, false); this.playFindDevVoice(paramContext); VibrateUtil.getInstance(paramContext).vibrateOn(true); - this.screenOn(paramContext); } } else if (paramIntent.hasExtra("takephoto")) { diff --git a/app/src/main/java/com/ic/protocolSrv/utils/Util.java b/app/src/main/java/com/ic/protocolSrv/utils/Util.java index bcb0bb9e..3d02fa08 100644 --- a/app/src/main/java/com/ic/protocolSrv/utils/Util.java +++ b/app/src/main/java/com/ic/protocolSrv/utils/Util.java @@ -70,10 +70,11 @@ public class Util { private static String FT6236U_upgrade_dev = "/sys/devices/platform/soc/soc:ap-apb/70800000.i2c/i2c-3/3-0038/ftsfwupdate"; private static String FT6236U_getver_dev = "/sys/devices/platform/soc/soc:ap-apb/70800000.i2c/i2c-3/3-0038/ftstpfwver"; - public static boolean needResizeSquare(){ - String modelname=getSystemProperties("ro.product.model",""); - return (modelname.contains("C46")||modelname.contains("C48")); + public static boolean needResizeSquare() { + String modelname = getSystemProperties("ro.product.model", ""); + return (modelname.contains("C46") || modelname.contains("C48")); } + public static void mSleep(int ms) { try { Thread.yield(); @@ -1238,7 +1239,7 @@ public class Util { } - public static void shutdown() { + public static void shutdown(Context context) { try { ICLogger.i("do shutdown!"); //获得ServiceManager类 @@ -1262,10 +1263,13 @@ public class Util { Method shutdown = oIPowerManager.getClass().getMethod("shutdown", boolean.class, boolean.class); //调用shutdown()方法 shutdown.invoke(oIPowerManager, false, true); - } catch (Exception e) { e.printStackTrace(); ICLogger.e(e.getMessage(), e); + //如果出错了,就调用8.1的关机,发个广播完事 + Intent intent = new Intent(); + intent.setAction("com.ic.action.SYSTEM_POWER_OFF_NO_CONFIRM"); + context.sendBroadcast(intent); } } diff --git a/app/src/main/res/layout/dialog_misscall_layout.xml b/app/src/main/res/layout/dialog_misscall_layout.xml index 4b70b360..e0d93f12 100644 --- a/app/src/main/res/layout/dialog_misscall_layout.xml +++ b/app/src/main/res/layout/dialog_misscall_layout.xml @@ -1,7 +1,17 @@ - - + + + - + + + + android:layout_height="1.0px" + android:background="#ffd0d0d0" /> + + android:gravity="center" + android:orientation="horizontal"> +