|
|
@ -121,6 +121,9 @@ public class MpMasterService extends Service {
|
|
|
|
|
|
|
|
|
|
|
|
private String mSerialNo = null;
|
|
|
|
private String mSerialNo = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private long mTimeToStartMpApp = 0;
|
|
|
|
|
|
|
|
private long mTimeOfMpAppAlive = 1800000; // 30minutes
|
|
|
|
|
|
|
|
|
|
|
|
public MpMasterService() {
|
|
|
|
public MpMasterService() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -184,6 +187,7 @@ public class MpMasterService extends Service {
|
|
|
|
// AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
|
|
|
|
// AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
|
|
|
|
|
|
|
|
|
|
|
|
startMaster();
|
|
|
|
startMaster();
|
|
|
|
|
|
|
|
startMpApp();
|
|
|
|
|
|
|
|
|
|
|
|
registerHeartbeatTimer();
|
|
|
|
registerHeartbeatTimer();
|
|
|
|
|
|
|
|
|
|
|
@ -221,6 +225,36 @@ public class MpMasterService extends Service {
|
|
|
|
return mCmdid;
|
|
|
|
return mCmdid;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void startMpApp() {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
final Context context = getApplicationContext();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (MicroPhotoContext.isAppAlive(context, MicroPhotoContext.PACKAGE_NAME_MPAPP)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String appPath = MicroPhotoContext.buildMpAppDir(context);
|
|
|
|
|
|
|
|
long ts = System.currentTimeMillis();
|
|
|
|
|
|
|
|
if (ts - mTimeToStartMpApp < 30000) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
File mpappDb = new File(appPath + "data/App.db");
|
|
|
|
|
|
|
|
long modifiedTimeOfDb = 0;
|
|
|
|
|
|
|
|
if (mpappDb.exists()) {
|
|
|
|
|
|
|
|
modifiedTimeOfDb = mpappDb.lastModified();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((ts - modifiedTimeOfDb) > mTimeOfMpAppAlive) {
|
|
|
|
|
|
|
|
// greater than 30m
|
|
|
|
|
|
|
|
MicroPhotoContext.restartMpApp(context);
|
|
|
|
|
|
|
|
mTimeToStartMpApp = ts;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String getMpAppVersion() {
|
|
|
|
public String getMpAppVersion() {
|
|
|
|
if (TextUtils.isEmpty(mMpAppVersion)) {
|
|
|
|
if (TextUtils.isEmpty(mMpAppVersion)) {
|
|
|
|
PackageManager packageManager = getPackageManager();
|
|
|
|
PackageManager packageManager = getPackageManager();
|
|
|
@ -306,6 +340,7 @@ public class MpMasterService extends Service {
|
|
|
|
mService.registerHeartbeatTimer();
|
|
|
|
mService.registerHeartbeatTimer();
|
|
|
|
|
|
|
|
|
|
|
|
mService.startMaster();
|
|
|
|
mService.startMaster();
|
|
|
|
|
|
|
|
mService.startMpApp();
|
|
|
|
|
|
|
|
|
|
|
|
} else if (TextUtils.equals(ACTION_MSG_BROADCAST, action)) {
|
|
|
|
} else if (TextUtils.equals(ACTION_MSG_BROADCAST, action)) {
|
|
|
|
|
|
|
|
|
|
|
@ -693,5 +728,9 @@ public class MpMasterService extends Service {
|
|
|
|
SysApi.selectSimCard4Data(getApplicationContext(), num);
|
|
|
|
SysApi.selectSimCard4Data(getApplicationContext(), num);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
////////////////////////GPS////////////////////
|
|
|
|
////////////////////////GPS////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|