系统刚启动时,加大检查文件锁次数,确保mpapp已经启动

设备重启时,mpapp可能延迟启动
ptz
Matthew 4 months ago
parent e01c19e9f8
commit 8a14578952

@ -19,6 +19,7 @@ import android.os.Environment;
import android.os.Handler;
import android.os.IBinder;
import android.os.PowerManager;
import android.os.SystemClock;
import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager;
@ -397,15 +398,18 @@ public class MpMasterService extends Service {
long ts = System.currentTimeMillis();
try {
boolean isMpAppRunning = detectMpAppRunning();
if (!isMpAppRunning) {
try {
Thread.sleep(1000);
} catch (Exception ex) {
ex.printStackTrace();
}
// Check twice
int detectionCnt = 4;
if (SystemClock.elapsedRealtime() < 180000) {
// In 3 minutes after device reboot
detectionCnt = 16;
}
boolean isMpAppRunning = false;
for (int idx = 0; idx < detectionCnt; idx++) {
isMpAppRunning = detectMpAppRunning();
if (isMpAppRunning) {
break;
}
sleep(1000);
}
if (!isMpAppRunning) {
@ -1308,11 +1312,8 @@ public class MpMasterService extends Service {
@Override
public void run() {
try {
Thread.sleep(5000);
} catch (Exception ex) {
sleep(5000);
}
File tmpDestPath = new File(MicroPhotoContext.buildMasterAppDir(context));
tmpDestPath = new File(tmpDestPath, "mpdata");
if (tmpDestPath.exists()) {
@ -1430,6 +1431,13 @@ public class MpMasterService extends Service {
}
}
private static void sleep(long ms) {
try {
Thread.sleep(ms);
} catch (Exception ex) {
}
}
public native static int getInt(int cmd);
public native static int setInt(int cmd, int val);
public native static int[] getStats(long ts);

Loading…
Cancel
Save