重启运维应用和app应用功能新增

serial
liuguijing 1 year ago
parent 8ca9ddd60c
commit 0a2c25be18

@ -3,8 +3,10 @@ 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;
@ -172,8 +174,18 @@ 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);
}
});
@ -186,6 +198,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;
@ -14,16 +15,11 @@ import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.text.TextUtils;
import androidx.annotation.NonNull;
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,8 @@ 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";
@ -195,7 +191,7 @@ public class SimUtil {
sendtype = SmsTypeEnum.GET_OPERATE_URL.value();
ifmessageCorrect = true;
String mntnServer = UpdateSysConfigUtil.getMntnServer(context);
sendmessage = SmsTypeEnum.GET_OPERATE_URL + "=" + mntnServer;
sendmessage = SmsTypeEnum.GET_OPERATE_URL.value() + "=" + mntnServer;
} else if (content.contains(SmsTypeEnum.UPDATE.value())) {
sendtype = SmsTypeEnum.UPDATE.value();
String[] split1 = StringUtils.splitString1(content);
@ -386,6 +382,7 @@ public class SimUtil {
if (channel != null && resolutionCX != null && resolutionCY != null && videoCX != null && videoCY != null) {
ifmessageCorrect = true;
UpdateSysConfigUtil.setChannelResolution(channel, resolutionCX, resolutionCY, videoCX, videoCY);
UpdateSysConfigUtil.restartApp(context);
}
}
}
@ -407,6 +404,12 @@ public class SimUtil {
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);
Integer channel = StringUtils.convert2Int(split[0]);
sendmessage = getSendString(content, ifmessageCorrect);
} else if (content.contains(SmsTypeEnum.SET_HEART.value())) {
sendtype = SmsTypeEnum.SET_HEART.value();
String[] split1 = StringUtils.splitString1(content);
@ -416,13 +419,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;
@ -437,13 +434,7 @@ 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;
@ -459,13 +450,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;
@ -511,6 +496,18 @@ public class SimUtil {
}
private static String getSendString(String content, boolean ifmessageCorrect) {
String sendmessage;
String menssageBack = "";
if (ifmessageCorrect) {
menssageBack = " OK";
} else {
menssageBack = " ERROR";
}
sendmessage = content + menssageBack;
return sendmessage;
}
//短信解析
public static SmsMessageModel getSMSInfo(Intent intent) {
SmsMessageModel smsMessageModel = new SmsMessageModel();

@ -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,36 @@ 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);
} else if (type.contains(SmsTypeEnum.REBOOT2.value())) {
} else if (type.contains(SmsTypeEnum.REBOOT2.value())) {
} else if (type.contains(SmsTypeEnum.REBOOT2.value())) {
} else if (type.contains(SmsTypeEnum.REBOOT2.value())) {
} else if (type.contains(SmsTypeEnum.REBOOT2.value())) {
} else if (type.contains(SmsTypeEnum.REBOOT2.value())) {
} else if (type.contains(SmsTypeEnum.REBOOT2.value())) {
}
}
}
}

@ -1,9 +1,8 @@
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.xypower.common.FileUtils;
@ -22,6 +21,8 @@ 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 String buildAppDir(String packageurl) {
@ -296,4 +297,20 @@ 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);
}
}

Loading…
Cancel
Save