Matthew 1 year ago
commit 898528d534

@ -1,10 +1,13 @@
package com.xypower.mpmaster;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
import android.Manifest;
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@ -28,7 +31,9 @@ import com.xypower.mpmaster.sms.DownloadUtils;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
public class MainActivity extends AppCompatActivity {
@ -172,8 +177,41 @@ public class MainActivity extends AppCompatActivity {
// SysApi.reboot(MainActivity.this);
DownloadUtils downloadUtils = new DownloadUtils(getApplicationContext(), "http://180.166.218.222:40101/upgrades/20240509_upd_663c857dbfcf7.apk", "test.apk");
// DownloadUtils downloadUtils = new DownloadUtils(getApplicationContext(), "http://180.166.218.222:40101/upgrades/20240509_upd_663c857dbfcf7.apk", "test.apk");
// ActivityManager manager = (ActivityManager) getApplicationContext().getSystemService(Context.ACTIVITY_SERVICE);
// manager.restartPackage(context.getPackageName());
// String ACTION_UPDATE_CONFIGS = "com.xypower.mpapp.ACT_UPD_CFG";
// Intent intent = new Intent();
// intent.setAction(ACTION_UPDATE_CONFIGS);
// intent.putExtra("restart", 1);
// // PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, 0);
// sendBroadcast(intent);
//// LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context);
//// localBroadcastManager.sendBroadcast(intent);
// boolean photoOrVideo;
// photoOrVideo = true;
// List<Long> schedules = new ArrayList<>();
// long ts = System.currentTimeMillis() / 1000;
// long val = 0;
// val |= ((long) 1 << 16);
// val |= ((long) 255 << 8);
// val |= photoOrVideo ? 0L : 1L;
//
// schedules.add(Long.valueOf(val));
//
// Intent intent1 = new Intent();
// intent1.setAction(ACTION_TAKE_PHOTO);
// int cnt = schedules.size();
// intent1.putExtra(EXTRA_PARAM_SCHEDULES, cnt);
// for (int idx = 0; idx < cnt; idx++) {
// intent1.putExtra(EXTRA_PARAM_SCHEDULE + idx, schedules.get(idx).longValue());
// }
// intent1.putExtra(EXTRA_PARAM_TIME, 0);
// intent1.putExtra(EXTRA_PARAM_TAKING_TIME, ts);
// sendBroadcast(intent1);
}
});
@ -186,6 +224,7 @@ public class MainActivity extends AppCompatActivity {
startMicroPhotoService(getApplicationContext());
}
private void requestPermissions() {
String[] accessPermissions = new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.FOREGROUND_SERVICE, Manifest.permission.READ_PHONE_STATE,
/*Manifest.permission.PACKAGE_USAGE_STATS,*/

@ -1,5 +1,6 @@
package com.xypower.mpmaster.sms;
import android.Manifest;
import android.app.Activity;
import android.app.PendingIntent;
@ -19,11 +20,6 @@ import androidx.core.app.ActivityCompat;
import com.dev.devapi.api.SysApi;
import com.xypower.common.RegexUtil;
import org.json.JSONArray;
import org.json.JSONException;
import java.io.IOException;
import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
@ -43,8 +39,9 @@ public class SimUtil {
//自定义ACTION常数 作为广播的IntentFilter识别常数
public static String SMS_SEND_ACTION = "com.xypower.mpmaster.SMS_SEND_ACTION";
public static String SMSTYPE = "smstype";
public static String SMSDATA = "smsdata";
public static String SMSIFCORRECT = "smsifcorrect";
@ -65,29 +62,29 @@ public class SimUtil {
}
if (content.contains(SmsTypeEnum.REBOOT1.value())) {
ifmessageCorrect = true;
sendmessage = content + " OK";
sendtype = SmsTypeEnum.REBOOT1.value();
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.REBOOT2.value())) {
ifmessageCorrect = true;
sendmessage = content + " OK";
sendtype = SmsTypeEnum.REBOOT2.value();
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.SET_YW_SCHEDULE.value())) {
ifmessageCorrect = true;
String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length > 1) {
if (split1 != null && split1.length == 2) {
String s = split1[1];
String[] split2 = StringUtils.splitString2(s);
if (split2 != null && split2.length >= 1) {
int length = split2.length;
if (length % 2 == 1) {
int spilt2len = split2.length;
if (split2 != null && spilt2len > 1 && spilt2len % 2 == 1) {
String num = split2[0];
Integer integer = StringUtils.convert2Int(num);
if (integer != null) {
if (integer == 0) {//删除所有运维
ifmessageCorrect = true;
} else {
if (length == integer + 1) {
if (spilt2len == integer * 2 + 1) {
int times = 0;
for (int i = 0; i < split2.length; i++) {
for (int i = 0; i < spilt2len; i++) {
if (i == 0) {
continue;
}
@ -116,15 +113,8 @@ public class SimUtil {
}
}
}
}
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
} else {
menssageBack = " ERROR";
}
sendmessage = content + menssageBack;
sendtype = SmsTypeEnum.SET_YW_SCHEDULE.value();
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_YW_SCHEDULE.value())) {
ifmessageCorrect = true;
List<Integer> absHeartbeats = UpdateSysConfigUtil.getAbsHeartbeats(context);
@ -137,7 +127,6 @@ public class SimUtil {
int mAbsHeartbeatTime = 0;
mAbsHeartbeatTime = absHeartbeats.get(i);
int hour = mAbsHeartbeatTime / 60;
// int leftsecond = mAbsHeartbeatTime % 60;
int minute = mAbsHeartbeatTime % 60;
sendmessage += "," + hour + "," + minute;
}
@ -155,18 +144,12 @@ public class SimUtil {
}
}
}
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
} else {
menssageBack = " ERROR";
}
sendmessage = content + menssageBack;
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_OPERATE.value())) {
sendtype = SmsTypeEnum.GET_OPERATE.value();
ifmessageCorrect = true;
int mntnMode = UpdateSysConfigUtil.getMntnMode(context);
sendmessage = SmsTypeEnum.GET_OPERATE + "=" + mntnMode;
sendmessage = SmsTypeEnum.GET_OPERATE.value() + "=" + mntnMode;
} else if (content.contains(SmsTypeEnum.SET_OPERATE_URL.value())) {
sendtype = SmsTypeEnum.SET_OPERATE_URL.value();
String[] split1 = StringUtils.splitString1(content);
@ -186,18 +169,12 @@ public class SimUtil {
}
}
}
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
} else {
menssageBack = " ERROR";
}
sendmessage = content + menssageBack;
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_OPERATE_URL.value())) {
sendtype = SmsTypeEnum.GET_OPERATE.value();
sendtype = SmsTypeEnum.GET_OPERATE_URL.value();
ifmessageCorrect = true;
String mntnServer = UpdateSysConfigUtil.getMntnServer(context);
sendmessage = SmsTypeEnum.GET_OPERATE + "=" + mntnServer;
sendmessage = SmsTypeEnum.GET_OPERATE_URL.value() + "=" + mntnServer;
} else if (content.contains(SmsTypeEnum.UPDATE.value())) {
sendtype = SmsTypeEnum.UPDATE.value();
String[] split1 = StringUtils.splitString1(content);
@ -206,32 +183,21 @@ public class SimUtil {
String s = split1[1];
DownloadUtils downloadUtils = new DownloadUtils(context.getApplicationContext(), s, "test.app");
}
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
} else {
menssageBack = " ERROR";
}
sendmessage = content + menssageBack;
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.SET_CMDID.value())) {
sendtype = SmsTypeEnum.SET_CMDID.value();
String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length > 1) {
ifmessageCorrect = true;
String cmdid = split1[1];
UpdateSysConfigUtil.setCmdid(context, cmdid);
}
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
} else {
menssageBack = " ERROR";
}
sendmessage = content + menssageBack;
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_CMDID.value())) {
sendtype = SmsTypeEnum.GET_CMDID.value();
ifmessageCorrect = true;
String cmdid = UpdateSysConfigUtil.getCmdid(context);
sendmessage = SmsTypeEnum.GET_OPERATE + "=" + cmdid;
sendmessage = SmsTypeEnum.GET_CMDID.value() + "=" + cmdid;
} else if (content.contains(SmsTypeEnum.SET_IP.value())) {
sendtype = SmsTypeEnum.SET_IP.value();
String[] split1 = StringUtils.splitString1(content);
@ -248,7 +214,6 @@ public class SimUtil {
int encrypto = -1;
if (integer != null) {
ifmessageCorrect = true;
}
if (split2.length == 4) {
String s1 = split2[2];
utcp = StringUtils.convert2Int(s1);
@ -258,39 +223,92 @@ public class SimUtil {
UpdateSysConfigUtil.setIP(context, server, integer, utcp, encrypto);
}
}
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
} else {
menssageBack = " ERROR";
}
sendmessage = content + menssageBack;
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_IP.value())) {
sendtype = SmsTypeEnum.GET_IP.value();
ifmessageCorrect = true;
String ip = UpdateSysConfigUtil.getIP(context);
sendmessage = SmsTypeEnum.GET_IP + "=" + ip;
sendmessage = SmsTypeEnum.GET_IP.value() + "=" + ip;
} else if (content.contains(SmsTypeEnum.SET_OSD.value())) {
sendtype = SmsTypeEnum.SET_OSD.value();
String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length > 1) {
sendmessage = getSendString(content, ifmessageCorrect);
if (split1 != null && split1.length == 2) {
ifmessageCorrect = true;
HashMap<String, String> osdmap = new HashMap<>();
String s = split1[1];
String[] split2 = StringUtils.splitString2(s);
if (split2 != null && split2.length == 2) {
int spilt2len = split2.length;
if (split2 != null && spilt2len > 1 && spilt2len % 2 == 1) {
String num = split2[0];
Integer integer = StringUtils.convert2Int(num);
if (integer != null) {
if (integer == 0) {//所有通道
ifmessageCorrect = true;
} else {
for (int i = 0; i < spilt2len; i++) {
if (i == 0) {
continue;
}
if (i % 2 == 1) {
if ((i + 1) <= spilt2len) {
String s1 = split2[i];
Integer position = StringUtils.convert2Int(s1);
if (position != null) {
if (position == 1) {
osdmap.put("leftTop", split2[i + 1]);
} else if (position == 2) {
osdmap.put("rightTop", split2[i + 1]);
} else if (position == 3) {
osdmap.put("leftBottom", split2[i + 1]);
} else if (position == 4) {
osdmap.put("rightBottom", split2[i + 1]);
} else {
ifmessageCorrect = false;
}
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
} else {
menssageBack = " ERROR";
ifmessageCorrect = false;
}
} else {
ifmessageCorrect = false;
}
}
}
}
if (ifmessageCorrect) {
UpdateSysConfigUtil.setChannelOSD(integer, osdmap);
}
}
}
}
sendmessage = content + menssageBack;
} else if (content.contains(SmsTypeEnum.GET_OSD.value())) {
sendtype = SmsTypeEnum.GET_OSD.value();
String[] split = StringUtils.splitString1(content);
if (split != null && split.length == 2) {
sendmessage = SmsTypeEnum.GET_OSD.value() + "=";
ifmessageCorrect = true;
Integer channel = StringUtils.convert2Int(split[0]);
HashMap<String, String> channelOSD = UpdateSysConfigUtil.getChannelOSD(channel);
String leftTop = channelOSD.get("leftTop");
String rightTop = channelOSD.get("rightTop");
String leftBottom = channelOSD.get("leftBottom");
String rightBottom = channelOSD.get("rightBottom");
if (leftTop != null && StringUtils.isNotEmpty(leftTop)) {
sendmessage += "1," + leftTop;
}
if (rightTop != null && StringUtils.isNotEmpty(rightTop)) {
sendmessage += "2," + rightTop;
}
if (leftBottom != null && StringUtils.isNotEmpty(leftBottom)) {
sendmessage += "3" + leftBottom;
}
if (rightBottom != null && StringUtils.isNotEmpty(rightBottom)) {
sendmessage += "4," + leftTop;
}
}
} else if (content.contains(SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value())) {
sendtype = SmsTypeEnum.SET_OSD.value();
sendtype = SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value();
String[] split1 = StringUtils.splitString1(content);
if (split1 != null && split1.length > 1) {
String s = split1[1];
@ -298,13 +316,7 @@ public class SimUtil {
if (split2 != null && split2.length == 2) {
}
}
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
} else {
menssageBack = " ERROR";
}
sendmessage = content + menssageBack;
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value())) {
sendtype = SmsTypeEnum.GET_PHOTO_SCHEDULE_LIST.value();
ifmessageCorrect = true;
@ -322,28 +334,43 @@ public class SimUtil {
Integer videoCY = StringUtils.convert2Int(split2[4]);
if (channel != null && resolutionCX != null && resolutionCY != null && videoCX != null && videoCY != null) {
ifmessageCorrect = true;
UpdateSysConfigUtil.setChannelResolution(packageName, channel, resolutionCX, resolutionCY, videoCX, videoCY);
UpdateSysConfigUtil.setChannelResolution(channel, resolutionCX, resolutionCY, videoCX, videoCY);
UpdateSysConfigUtil.restartApp(context);
}
}
}
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
} else {
menssageBack = " ERROR";
}
sendmessage = content + menssageBack;
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_RESOLUTION.value())) {
sendtype = SmsTypeEnum.GET_RESOLUTION.value();
ifmessageCorrect = true;
String[] split = StringUtils.splitString1(content);
Integer channel = StringUtils.convert2Int(split[0]);
HashMap<String, Integer> hashMap = UpdateSysConfigUtil.getChannelResolution(packageName, channel);
HashMap<String, Integer> hashMap = UpdateSysConfigUtil.getChannelResolution(channel);
Integer resolutionCX = hashMap.get("resolutionCX");
Integer resolutionCY = hashMap.get("resolutionCY");
Integer videoCX = hashMap.get("videoCX");
Integer videoCY = hashMap.get("videoCY");
sendmessage = SmsTypeEnum.GET_RESOLUTION.value() + "=" + resolutionCX + "," + resolutionCY + "," + videoCX + "," + videoCY;
} else if (content.contains(SmsTypeEnum.TAKE_PHOTO.value())) {
sendtype = SmsTypeEnum.TAKE_PHOTO.value();
ifmessageCorrect = true;
String[] split = StringUtils.splitString1(content);
if (split != null && split.length == 3) {
ifmessageCorrect = true;
Integer channel = StringUtils.convert2Int(split[0]);
Integer preset = StringUtils.convert2Int(split[1]);
Integer type = StringUtils.convert2Int(split[2]);
if (channel != null) {
boolean photoOrVideo;
if (type == 0) {
photoOrVideo = true;
} else {
photoOrVideo = false;
}
UpdateSysConfigUtil.takePhotoOrVideo(context, channel, preset, photoOrVideo);
}
sendmessage = getSendString(content, ifmessageCorrect);
}
} else if (content.contains(SmsTypeEnum.SET_HEART.value())) {
sendtype = SmsTypeEnum.SET_HEART.value();
String[] split1 = StringUtils.splitString1(content);
@ -353,13 +380,7 @@ public class SimUtil {
Integer integer = StringUtils.convert2Int(s);
UpdateSysConfigUtil.setHB(context, integer);
}
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
} else {
menssageBack = " ERROR";
}
sendmessage = content + menssageBack;
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_HEART.value())) {
sendtype = SmsTypeEnum.GET_HEART.value();
ifmessageCorrect = true;
@ -374,17 +395,10 @@ public class SimUtil {
Integer integer = StringUtils.convert2Int(s);
UpdateSysConfigUtil.setTB(context, integer);
}
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
} else {
menssageBack = " ERROR";
}
sendmessage = content + menssageBack;
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_TP.value())) {
sendtype = SmsTypeEnum.GET_TP.value();
ifmessageCorrect = true;
String[] split = StringUtils.splitString1(content);
int tb = UpdateSysConfigUtil.getTB(context);
sendmessage = SmsTypeEnum.GET_TP.value() + "=" + tb;
} else if (content.contains(SmsTypeEnum.SET_PACKAGE.value())) {
@ -396,13 +410,7 @@ public class SimUtil {
Integer integer = StringUtils.convert2Int(s);
UpdateSysConfigUtil.setPackage(context, integer);
}
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
} else {
menssageBack = " ERROR";
}
sendmessage = content + menssageBack;
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.GET_PACKAGE.value())) {
sendtype = SmsTypeEnum.GET_PACKAGE.value();
ifmessageCorrect = true;
@ -412,29 +420,27 @@ public class SimUtil {
sendtype = SmsTypeEnum.CLEAR_PHOTO.value();
ifmessageCorrect = true;
UpdateSysConfigUtil.clearHistoryPic(context);
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
} else {
menssageBack = " ERROR";
}
sendmessage = content + menssageBack;
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.CLEAR_LOG.value())) {
sendtype = SmsTypeEnum.CLEAR_LOG.value();
ifmessageCorrect = true;
UpdateSysConfigUtil.clearHistoryLogs(context);
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
} else {
menssageBack = " ERROR";
}
sendmessage = content + menssageBack;
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.CLEAR_ALL.value())) {
sendtype = SmsTypeEnum.CLEAR_ALL.value();
ifmessageCorrect = true;
UpdateSysConfigUtil.clearHistoryPic(context);
UpdateSysConfigUtil.clearHistoryLogs(context);
sendmessage = getSendString(content, ifmessageCorrect);
}
sendSms(context, slot, sender, sendmessage, sendtype, ifmessageCorrect);
}
}
private static String getSendString(String content, boolean ifmessageCorrect) {
String sendmessage;
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
@ -442,10 +448,7 @@ public class SimUtil {
menssageBack = " ERROR";
}
sendmessage = content + menssageBack;
}
sendSms(context, slot, sender, sendmessage, sendtype, ifmessageCorrect);
}
return sendmessage;
}
//短信解析
@ -528,7 +531,8 @@ public class SimUtil {
}
//指定sim卡位置发送短信
public static void sendSms(Context mContext, int slot, String sender, String message, String value, boolean ifmessageCorrect) {
public static void sendSms(Context mContext, int slot, String sender, String message, String
value, boolean ifmessageCorrect) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
SubscriptionManager localSubscriptionManager = SubscriptionManager.from(mContext);
if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
@ -536,15 +540,19 @@ public class SimUtil {
}
if (localSubscriptionManager.getActiveSubscriptionInfoCount() > 1) {
List localList = localSubscriptionManager.getActiveSubscriptionInfoList();
boolean doubleSim = isDoubleSim(mContext);
SubscriptionInfo simInfoAnother = null;
if (doubleSim) {
if (localList != null && localList.size() > 1) {
SubscriptionInfo simInfo1 = (SubscriptionInfo) localList.get(0);
SubscriptionInfo simInfo2 = (SubscriptionInfo) localList.get(1);
SubscriptionInfo simInfoAnother;
if (slot == 0) {
simInfoAnother = simInfo1;
} else {
simInfoAnother = simInfo2;
}
}
}
Intent itSend = new Intent(SMS_SEND_ACTION);
itSend.putExtra(SMSTYPE, value);
itSend.putExtra(SMSIFCORRECT, ifmessageCorrect);
@ -555,10 +563,12 @@ public class SimUtil {
// Intent itDeliver = new Intent(SMS_DELIVERED_ACTION);
//deliveryIntent参数为传送后接受的广播信息PendingIntent
// PendingIntent deliverPI = PendingIntent.getBroadcast(mContext,0,itDeliver,0);
if (simInfoAnother != null) {
SmsManager.getSmsManagerForSubscriptionId(simInfoAnother.getSubscriptionId()).sendTextMessage(sender, null, message, sendPI, null);
}
}
}
}
//判断是否是双卡
@ -626,7 +636,8 @@ public class SimUtil {
//申请该权限
public static void requestOnePermission(Activity activity, String permission, int permissionCode) {
public static void requestOnePermission(Activity activity, String permission,
int permissionCode) {
if (activity != null) {
activity.requestPermissions(new String[]{permission}, permissionCode);
}

@ -1,15 +1,11 @@
package com.xypower.mpmaster.sms;
import android.app.DownloadManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.dev.devapi.api.SysApi;
import org.json.JSONArray;
/**
* 广
* Android 4.4API 19广
@ -26,9 +22,29 @@ public class SmsSendReceiver extends BroadcastReceiver {
SysApi.reboot(context);
} else if (type.contains(SmsTypeEnum.REBOOT2.value())) {
SysApi.reboot(context);
} else if (type.contains(SmsTypeEnum.SET_YW_SCHEDULE.value())) {
UpdateSysConfigUtil.restartMasterApp(context);
} else if (type.contains(SmsTypeEnum.SET_OPERATE.value())) {
UpdateSysConfigUtil.restartMasterApp(context);
} else if (type.contains(SmsTypeEnum.SET_OPERATE_URL.value())) {
UpdateSysConfigUtil.restartMasterApp(context);
} else if (type.contains(SmsTypeEnum.SET_CMDID.value())) {
UpdateSysConfigUtil.restartApp(context);
} else if (type.contains(SmsTypeEnum.SET_IP.value())) {
UpdateSysConfigUtil.restartApp(context);
} else if (type.contains(SmsTypeEnum.SET_OSD.value())) {
UpdateSysConfigUtil.restartApp(context);
} else if (type.contains(SmsTypeEnum.SET_PHOTO_SCHEDULE_LIST.value())) {
UpdateSysConfigUtil.restartApp(context);
} else if (type.contains(SmsTypeEnum.SET_RESOLUTION.value())) {
UpdateSysConfigUtil.restartApp(context);
} else if (type.contains(SmsTypeEnum.SET_HEART.value())) {
UpdateSysConfigUtil.restartApp(context);
} else if (type.contains(SmsTypeEnum.SET_TP.value())) {
UpdateSysConfigUtil.restartApp(context);
} else if (type.contains(SmsTypeEnum.SET_PACKAGE.value())) {
UpdateSysConfigUtil.restartApp(context);
}
}
}
}

@ -1,11 +1,11 @@
package com.xypower.mpmaster.sms;
import static com.xypower.common.MicroPhotoContext.PACKAGE_NAME_MPAPP;
import static com.xypower.common.MicroPhotoContext.buildMpAppDir;
import android.content.Context;
import android.content.Intent;
import android.os.Environment;
import com.dev.devapi.api.SysApi;
import com.xypower.common.FileUtils;
import com.xypower.common.JSONUtils;
import com.xypower.common.MicroPhotoContext;
@ -22,6 +22,19 @@ import java.util.List;
public class UpdateSysConfigUtil {
public static final String PACKAGE_NAME_MPAPP = "com.xypower.mpapp";
public static final String APP_ACTION_UPDATE_CONFIGS = "com.xypower.mpapp.ACT_UPD_CFG";
private static final String MASTER_ACTION_UPDATE_CONFIGS = "com.xypower.mpmaster.ACT_UPD_CFG";
//拍照的广播
public static final String ACTION_TAKE_PHOTO = "com.xypower.mpapp.ACT_TP";
public static final String EXTRA_PARAM_SCHEDULES = "Schedules";
public static final String EXTRA_PARAM_SCHEDULE = "Schedule_";
public static final String EXTRA_PARAM_TAKING_TIME = "TakingTime";
public static final String EXTRA_PARAM_TIME = "Time";
//创建运维配置文件文件夹
public static String buildAppDir(String packageurl) {
@ -191,7 +204,7 @@ public class UpdateSysConfigUtil {
}
//设置通道分辨率
public static boolean setChannelResolution(String packageurl, int channel, int resolutionCX, int resolutionCY, int videoCX, int videoCY) {
public static boolean setChannelResolution(int channel, int resolutionCX, int resolutionCY, int videoCX, int videoCY) {
String path = getChannelDir(channel);
JSONObject jsonObject = JSONUtils.loadJson(path);
try {
@ -206,7 +219,7 @@ public class UpdateSysConfigUtil {
}
//查询通道分辨率
public static HashMap getChannelResolution(String packageurl, int channel) {
public static HashMap getChannelResolution(int channel) {
HashMap<String, Integer> hashMap = new HashMap<>();
String path = getChannelDir(channel);
JSONObject jsonObject = JSONUtils.loadJson(path);
@ -226,6 +239,41 @@ public class UpdateSysConfigUtil {
return hashMap;
}
//设置通道水印
public static boolean setChannelOSD(int channel, HashMap<String, String> hashMap) {
String path = getChannelDir(channel);
JSONObject jsonObject = JSONUtils.loadJson(path);
try {
jsonObject.put("leftTop", hashMap.get("leftTop"));
jsonObject.put("rightTop", hashMap.get("rightTop"));
jsonObject.put("leftBottom", hashMap.get("leftBottom"));
jsonObject.put("rightBottom", hashMap.get("rightBottom"));
} catch (Exception ex) {
ex.printStackTrace();
}
return JSONUtils.saveJson(path, jsonObject);
}
//查询通道分辨率
public static HashMap<String, String> getChannelOSD(int channel) {
HashMap<String, String> hashMap = new HashMap<>();
String path = getChannelDir(channel);
JSONObject jsonObject = JSONUtils.loadJson(path);
try {
String leftTop = jsonObject.getString("leftTop");
String rightTop = jsonObject.getString("rightTop");
String leftBottom = jsonObject.getString("leftBottom");
String rightBottom = jsonObject.getString("rightBottom");
hashMap.put("leftTop", leftTop);
hashMap.put("rightTop", rightTop);
hashMap.put("rightBottom", rightBottom);
hashMap.put("leftBottom", leftBottom);
} catch (Exception ex) {
ex.printStackTrace();
}
return hashMap;
}
//清除历史图片和视频
public static void clearHistoryPic(Context context) {
@ -261,4 +309,43 @@ public class UpdateSysConfigUtil {
}
//重启应用
public static void restartApp(Context context) {
Intent intent = new Intent();
intent.setAction(APP_ACTION_UPDATE_CONFIGS);
intent.putExtra("restart", 1);
context.sendBroadcast(intent);
}
//重启运维应用
public static void restartMasterApp(Context context) {
Intent intent = new Intent();
intent.setAction(MASTER_ACTION_UPDATE_CONFIGS);
intent.putExtra("restart", 1);
context.sendBroadcast(intent);
}
public static void takePhotoOrVideo(Context context, long channel, long preset, boolean photoOrVideo) {
List<Long> schedules = new ArrayList<>();
long ts = System.currentTimeMillis() / 1000;
long val = 0;
val |= (channel << 16);
val |= (preset << 8);
val |= photoOrVideo ? 0L : 1L;
schedules.add(Long.valueOf(val));
Intent intent1 = new Intent();
intent1.setAction(ACTION_TAKE_PHOTO);
int cnt = schedules.size();
intent1.putExtra(EXTRA_PARAM_SCHEDULES, cnt);
for (int idx = 0; idx < cnt; idx++) {
intent1.putExtra(EXTRA_PARAM_SCHEDULE + idx, schedules.get(idx).longValue());
}
intent1.putExtra(EXTRA_PARAM_TIME, 0);
intent1.putExtra(EXTRA_PARAM_TAKING_TIME, ts);
context.sendBroadcast(intent1);
}
}

Loading…
Cancel
Save