系统刚启动时,加大检查文件锁次数,确保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.Handler;
import android.os.IBinder; import android.os.IBinder;
import android.os.PowerManager; import android.os.PowerManager;
import android.os.SystemClock;
import android.telephony.SubscriptionInfo; import android.telephony.SubscriptionInfo;
import android.telephony.SubscriptionManager; import android.telephony.SubscriptionManager;
import android.telephony.TelephonyManager; import android.telephony.TelephonyManager;
@ -397,15 +398,18 @@ public class MpMasterService extends Service {
long ts = System.currentTimeMillis(); long ts = System.currentTimeMillis();
try { try {
boolean isMpAppRunning = detectMpAppRunning(); int detectionCnt = 4;
if (!isMpAppRunning) { if (SystemClock.elapsedRealtime() < 180000) {
try { // In 3 minutes after device reboot
Thread.sleep(1000); detectionCnt = 16;
} catch (Exception ex) { }
ex.printStackTrace(); boolean isMpAppRunning = false;
} for (int idx = 0; idx < detectionCnt; idx++) {
// Check twice
isMpAppRunning = detectMpAppRunning(); isMpAppRunning = detectMpAppRunning();
if (isMpAppRunning) {
break;
}
sleep(1000);
} }
if (!isMpAppRunning) { if (!isMpAppRunning) {
@ -1308,11 +1312,8 @@ public class MpMasterService extends Service {
@Override @Override
public void run() { public void run() {
try { sleep(5000);
Thread.sleep(5000);
} catch (Exception ex) {
}
File tmpDestPath = new File(MicroPhotoContext.buildMasterAppDir(context)); File tmpDestPath = new File(MicroPhotoContext.buildMasterAppDir(context));
tmpDestPath = new File(tmpDestPath, "mpdata"); tmpDestPath = new File(tmpDestPath, "mpdata");
if (tmpDestPath.exists()) { 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 getInt(int cmd);
public native static int setInt(int cmd, int val); public native static int setInt(int cmd, int val);
public native static int[] getStats(long ts); public native static int[] getStats(long ts);

Loading…
Cancel
Save