handle shutdown form 8541.
authorTrillGates <williamtrillgates@gmail.com>
Wed, 25 Aug 2021 03:51:46 +0000 (11:51 +0800)
committerTrillGates <williamtrillgates@gmail.com>
Wed, 25 Aug 2021 03:51:46 +0000 (11:51 +0800)
14 files changed:
app/src/main/java/com/ic/protocolSrv/CoreService.java
app/src/main/java/com/ic/protocolSrv/service/Deliver.java
app/src/main/java/com/ic/protocolSrv/utils/CustomDialog.java
app/src/main/java/com/ic/protocolSrv/utils/ProcessReceiver.java
app/src/main/java/com/ic/protocolSrv/utils/Util.java
app/src/main/res/layout/dialog_misscall_layout.xml
app/src/main/res/layout/dialog_normal_layout.xml
app/src/main/res/values-de-rCH/strings.xml
app/src/main/res/values-fr-rCH/strings.xml
app/src/main/res/values-it-rCH/strings.xml
app/src/main/res/values-ja/strings.xml
app/src/main/res/values-w820dp/strings.xml
app/src/main/res/values-zh-rCN/strings.xml
app/src/main/res/values/strings.xml

index 1ac6cad..eb7d2f7 100644 (file)
@@ -1525,7 +1525,7 @@ public class CoreService extends Service {
                 mHandler.postDelayed(new Runnable() {
                     @Override
                     public void run() {
-                        Util.shutdown();
+                        Util.shutdown(context);
                     }
                 }, 1000);
             }
index a329291..e8dec33 100644 (file)
@@ -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", "");
index 5a2a349..f32796a 100644 (file)
@@ -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;
index 269aaf8..e4c42b3 100644 (file)
@@ -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")) {
index bcb0bb9..3d02fa0 100644 (file)
@@ -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);
         }
     }
 
index 4b70b36..e0d93f1 100644 (file)
@@ -1,7 +1,17 @@
 <?xml version="1.0" encoding="utf-8"?>\r
-<FrameLayout android:orientation="vertical" android:padding="20.0dip" android:clickable="true" android:layout_width="fill_parent" android:layout_height="fill_parent"\r
-  xmlns:android="http://schemas.android.com/apk/res/android">\r
-    <LinearLayout android:layout_gravity="center" android:orientation="vertical" android:background="@drawable/dialog_bottom_bg" android:layout_width="fill_parent" android:layout_height="wrap_content">\r
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"\r
+    android:layout_width="fill_parent"\r
+    android:layout_height="fill_parent"\r
+    android:clickable="true"\r
+    android:orientation="vertical"\r
+    android:padding="20.0dip">\r
+\r
+    <LinearLayout\r
+        android:layout_width="fill_parent"\r
+        android:layout_height="wrap_content"\r
+        android:layout_gravity="center"\r
+        android:background="@drawable/dialog_bottom_bg"\r
+        android:orientation="vertical">\r
 \r
         <TextView\r
             android:id="@+id/title"\r
             android:layout_height="40.0dip"\r
             android:gravity="center"\r
             android:text="@string/title_alert"\r
-            android:textSize="30sp"\r
+            android:textSize="26sp"\r
             android:visibility="visible" />\r
-        <LinearLayout android:gravity="center" android:id="@+id/noticeContent" android:layout_width="fill_parent" android:layout_height="wrap_content">\r
+\r
+        <LinearLayout\r
+            android:id="@+id/noticeContent"\r
+            android:layout_width="fill_parent"\r
+            android:layout_height="wrap_content"\r
+            android:gravity="center">\r
 \r
             <TextView\r
                 android:id="@+id/message"\r
                 android:paddingBottom="15.0dip"\r
                 android:textSize="25sp" />\r
         </LinearLayout>\r
+\r
         <View\r
-            android:background="#ffd0d0d0"\r
             android:layout_width="fill_parent"\r
-            android:layout_height="1.0px" />\r
+            android:layout_height="1.0px"\r
+            android:background="#ffd0d0d0" />\r
+\r
         <LinearLayout\r
-            android:gravity="center"\r
+            android:layout_width="fill_parent"\r
+            android:layout_height="60.0dip"\r
             android:layout_gravity="bottom"\r
-            android:orientation="horizontal"\r
             android:background="@drawable/bg_bombbox"\r
-            android:layout_width="fill_parent"\r
-            android:layout_height="60.0dip">\r
+            android:gravity="center"\r
+            android:orientation="horizontal">\r
+\r
             <Button\r
-                android:textColor="#ff000000"\r
-                android:gravity="center"\r
                 android:id="@+id/positiveButton"\r
-                android:background="@drawable/btn_query"\r
+                style="@style/text_16_666666"\r
                 android:layout_width="wrap_content"\r
                 android:layout_height="wrap_content"\r
+                android:background="@drawable/btn_query"\r
+                android:gravity="center"\r
                 android:text="@string/ok"\r
-                style="@style/text_16_666666" />\r
+                android:textColor="#ff000000"\r
+                android:textSize="20sp" />\r
+\r
             <ImageButton\r
-                android:gravity="center"\r
                 android:id="@+id/negativeButton"\r
-                android:background="#00000000"\r
-                android:visibility="gone"\r
+                style="@style/text_15_666666_sdw"\r
                 android:layout_width="wrap_content"\r
                 android:layout_height="wrap_content"\r
                 android:layout_marginLeft="20.0dip"\r
+                android:background="#00000000"\r
+                android:gravity="center"\r
                 android:src="@drawable/btn_cancel_selector"\r
                 android:text="@string/cancel"\r
-                style="@style/text_15_666666_sdw" />\r
+                android:visibility="gone" />\r
         </LinearLayout>\r
     </LinearLayout>\r
 </FrameLayout>
\ No newline at end of file
index 65f6f63..aab470c 100644 (file)
@@ -21,7 +21,7 @@
             android:padding="10dp"\r
             android:text="@string/title_alert"\r
             android:textColor="#000000"\r
-            android:textSize="30sp"\r
+            android:textSize="26sp"\r
             android:visibility="visible" />\r
 \r
         <View\r
@@ -73,6 +73,7 @@
                         android:background="@drawable/selector_btn_confirm"\r
                         android:gravity="center"\r
                         android:padding="20dp"\r
+                        android:textSize="20sp"\r
                         android:text="@string/ok"\r
                         android:textColor="@color/white" />\r
 \r
@@ -85,6 +86,7 @@
                         android:background="@drawable/selector_btn_cancel"\r
                         android:gravity="center"\r
                         android:padding="20dp"\r
+                        android:textSize="20sp"\r
                         android:text="@string/cancel"\r
                         android:textColor="@color/white" />\r
                 </LinearLayout>\r
index 993d27d..427d980 100644 (file)
     <string name="send_success_tips_text">发送成功</string>\r
     <string name="back_text">返回</string>\r
     <string name="send_text">发送</string>\r
+    <string name="find_device_text">设备查找</string>\r
 </resources>\r
index 993d27d..427d980 100644 (file)
     <string name="send_success_tips_text">发送成功</string>\r
     <string name="back_text">返回</string>\r
     <string name="send_text">发送</string>\r
+    <string name="find_device_text">设备查找</string>\r
 </resources>\r
index 358fc5f..ad1bb32 100644 (file)
     <string name="send_success_tips_text">发送成功</string>\r
     <string name="back_text">返回</string>\r
     <string name="send_text">发送</string>\r
+    <string name="find_device_text">设备查找</string>\r
 </resources>\r
index 022080f..be9865a 100644 (file)
     <string name="send_success_tips_text">发送成功</string>
     <string name="back_text">返回</string>
     <string name="send_text">发送</string>
+    <string name="find_device_text">设备查找</string>
 
 </resources>
index 49acd3b..a8398e9 100644 (file)
@@ -6,4 +6,5 @@
     <string name="send_success_tips_text">发送成功</string>
     <string name="back_text">返回</string>
     <string name="send_text">发送</string>
+    <string name="find_device_text">设备查找</string>
 </resources>
\ No newline at end of file
index 089d5ff..f249037 100644 (file)
     <string name="send_success_tips_text">发送成功</string>
     <string name="back_text">返回</string>
     <string name="send_text">发送</string>
+    <string name="find_device_text">设备查找</string>
 </resources>
index cf9b7f8..715481a 100644 (file)
     <string name="send_success_tips_text">发送成功</string>
     <string name="back_text">返回</string>
     <string name="send_text">发送</string>
+    <string name="find_device_text">设备查找</string>
 
 </resources>