优化重启方法

hdrplus
Matthew 12 months ago
parent 95c87c7467
commit d6cd52dc7d

@ -422,6 +422,7 @@ public class MicroPhotoService extends Service {
// 创建延迟意图
Intent alarmIntent = new Intent();
alarmIntent.setAction(ACTION_HEARTBEAT);
alarmIntent.putExtra("HeartbeatDuration", mHeartbeatDuration);
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);

@ -57,6 +57,29 @@ Java_com_xypower_mpmaster_MpMasterService_getInt(JNIEnv* env, jclass cls, jint c
return -1;
}
extern "C" JNIEXPORT jint JNICALL
Java_com_xypower_mpmaster_MpMasterService_setInt(JNIEnv* env, jclass cls, jint cmd, jint val) {
int fd = open("/dev/mtkgpioctrl", O_RDONLY);
// LOGE("set_int fd=%d,cmd=%d,value=%d\r\n",fd, cmd, value);
if( fd > 0 )
{
IOT_PARAM param;
param.cmd = cmd;
param.value = val;
int res = ioctl(fd, IOT_PARAM_WRITE, &param);
// LOGE("set_int22 cmd=%d,value=%d,result=%d\r\n",param.cmd, param.value, param.result);
close(fd);
return 0;
}
return -1;
}
extern "C" JNIEXPORT void JNICALL
Java_com_xypower_mpmaster_MpMasterService_rebootDevice(JNIEnv* env, jclass cls) {
// setInt(CMD_SET_SYSTEM_RESET, 1);
Java_com_xypower_mpmaster_MpMasterService_setInt(env, cls, 202, 1);
}
extern "C" JNIEXPORT jintArray JNICALL
Java_com_xypower_mpmaster_MpMasterService_getStats(JNIEnv* env, jclass cls, jlong ts) {
std::string path = PATH_MPAPP_STATS;

@ -27,6 +27,7 @@ import com.xypower.common.ZipUtils;
import org.json.JSONArray;
import org.json.JSONObject;
import org.w3c.dom.Text;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@ -652,10 +653,23 @@ public class AppMaster {
private void startFrp(JSONObject jsonObject) {
try {
// SysApi.forceStopApp(context, packageName);
String frp = jsonObject.optString("frpc", null);
if (TextUtils.isEmpty(frp)) {
mService.logger.warning("Empty frpc node");
return;
}
JSONObject jsonFrp = new JSONObject(frp);
String server = jsonFrp.optString("server_addr");
int port = jsonFrp.optInt("server_port", 7000);
Context context = mService.getApplicationContext();
Intent intent = context.getPackageManager().getLaunchIntentForPackage("io.github.acedroidx.frp");
if (intent != null) {
intent.putExtra("startFrp", 1);
intent.putExtra("server", server);
intent.putExtra("port", port);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(intent);
}

@ -93,6 +93,8 @@ public class MpMasterService extends Service {
private static int mStateService = STATE_SERVICE.NOT_CONNECTED;
private int mMpHeartbeatDuration = 10;
private boolean mMntnMode = false;
private boolean mQuickHbMode = false;
private boolean mUsingAbsHbTime = false;
@ -495,6 +497,7 @@ public class MpMasterService extends Service {
} else if (TextUtils.equals(MicroPhotoContext.ACTION_HEARTBEAT_MP, action)) {
mService.mPreviousMpHbTime = System.currentTimeMillis();
mService.mMpHeartbeatDuration = intent.getIntExtra("HeartbeatDuration", 10);
if (!mService.mSeparateNetwork && (!mService.mMntnMode)) {
mService.logger.info("Heartbeat Timer Fired By MpAPP ACTION=" + action);
@ -975,9 +978,10 @@ public class MpMasterService extends Service {
}
public native static int getInt(int cmd);
public native static int setInt(int cmd, int val);
public native static int[] getStats(long ts);
public native static String getSystemProperty(String key);
public native static void rebootDevice();
////////////////////////GPS////////////////////

@ -6,6 +6,7 @@ import android.content.Intent;
import android.text.TextUtils;
import com.dev.devapi.api.SysApi;
import com.xypower.mpmaster.MpMasterService;
/**
* 广
@ -40,9 +41,9 @@ public class SmsSendReceiver extends BroadcastReceiver {
public void processSms(final Context context, Intent intent, final String action, final String type) {
if (type.contains(SmsTypeEnum.REBOOT1.value())) {
SysApi.reboot(context);
MpMasterService.rebootDevice();
} else if (type.contains(SmsTypeEnum.REBOOT2.value())) {
SysApi.reboot(context);
MpMasterService.rebootDevice();
} else if (type.contains(SmsTypeEnum.SET_YW_SCHEDULE.value())) {
UpdateSysConfigUtil.restartMasterApp(context);
} else if (type.contains(SmsTypeEnum.SET_OPERATE.value())) {

@ -347,7 +347,6 @@ public class UpdateSysConfigUtil {
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;

Loading…
Cancel
Save