|
|
@ -55,6 +55,7 @@ import java.util.List;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
import java.util.logging.Logger;
|
|
|
|
|
|
|
|
import java.util.concurrent.atomic.AtomicInteger;;
|
|
|
|
|
|
|
|
|
|
|
|
public class MpMasterService extends Service {
|
|
|
|
public class MpMasterService extends Service {
|
|
|
|
static {
|
|
|
|
static {
|
|
|
@ -141,6 +142,8 @@ public class MpMasterService extends Service {
|
|
|
|
private String mIccid1 = null;
|
|
|
|
private String mIccid1 = null;
|
|
|
|
private String mIccid2 = null;
|
|
|
|
private String mIccid2 = null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AtomicInteger reqCode = new AtomicInteger(0);
|
|
|
|
|
|
|
|
|
|
|
|
public MpMasterService() {
|
|
|
|
public MpMasterService() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -149,7 +152,8 @@ public class MpMasterService extends Service {
|
|
|
|
final Context context = getApplicationContext();
|
|
|
|
final Context context = getApplicationContext();
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
Intent intent = new Intent(this, MainActivity.class);
|
|
|
|
Intent intent = new Intent(this, MainActivity.class);
|
|
|
|
PendingIntent pi = PendingIntent.getActivity(this,0, intent,0);
|
|
|
|
int uniqueReqCode = reqCode.getAndIncrement();
|
|
|
|
|
|
|
|
PendingIntent pi = PendingIntent.getActivity(this,uniqueReqCode, intent,0);
|
|
|
|
AlarmManager alarmManager=(AlarmManager)getSystemService(ALARM_SERVICE);
|
|
|
|
AlarmManager alarmManager=(AlarmManager)getSystemService(ALARM_SERVICE);
|
|
|
|
alarmManager.set(AlarmManager.RTC_WAKEUP,System.currentTimeMillis() + 5000, pi);
|
|
|
|
alarmManager.set(AlarmManager.RTC_WAKEUP,System.currentTimeMillis() + 5000, pi);
|
|
|
|
logger.info("Restart MpApp after 5s as for LowMemory");
|
|
|
|
logger.info("Restart MpApp after 5s as for LowMemory");
|
|
|
@ -420,11 +424,11 @@ public class MpMasterService extends Service {
|
|
|
|
|
|
|
|
|
|
|
|
logger.warning("Restart MpAPP as it is NOT Running Prev MPAPP HB=" +
|
|
|
|
logger.warning("Restart MpAPP as it is NOT Running Prev MPAPP HB=" +
|
|
|
|
Long.toString((ts - mPreviousMpHbTime) / 1000) + " MPAPP HBDuration=" + Long.toString(mMpHeartbeatDuration)
|
|
|
|
Long.toString((ts - mPreviousMpHbTime) / 1000) + " MPAPP HBDuration=" + Long.toString(mMpHeartbeatDuration)
|
|
|
|
+ " Prev MpRestart Time=" + Long.toString(mTimeToStartMpApp));
|
|
|
|
+ " Prev MpRestart Time=" + Long.toString(mTimeToStartMpApp) + " last MPAPPHB =" + (mPreviousMpHbTime/1000));
|
|
|
|
|
|
|
|
|
|
|
|
mTimeToStartMpApp = ts;
|
|
|
|
mTimeToStartMpApp = ts;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
logger.warning("MpAPP has restarted during 30s, skip the check.");
|
|
|
|
logger.warning("MpAPP has restarted during 30min, skip the check.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -451,7 +455,8 @@ public class MpMasterService extends Service {
|
|
|
|
alarmIntent.setAction(ACTION_MP_RESTART);
|
|
|
|
alarmIntent.setAction(ACTION_MP_RESTART);
|
|
|
|
alarmIntent.putExtra("reason", msg);
|
|
|
|
alarmIntent.putExtra("reason", msg);
|
|
|
|
|
|
|
|
|
|
|
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
int uniqueReqCode = reqCode.getAndIncrement();
|
|
|
|
|
|
|
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, uniqueReqCode, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
|
|
|
|
|
|
|
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, ts + mDelayedRestartMpTime, pendingIntent);
|
|
|
|
alarmManager.setExactAndAllowWhileIdle(AlarmManager.RTC_WAKEUP, ts + mDelayedRestartMpTime, pendingIntent);
|
|
|
|
|
|
|
|
|
|
|
@ -655,7 +660,7 @@ public class MpMasterService extends Service {
|
|
|
|
mService.mMpHeartbeatDuration = hbDuration > 0 ? hbDuration : 600000;
|
|
|
|
mService.mMpHeartbeatDuration = hbDuration > 0 ? hbDuration : 600000;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
mService.mPreviousMpHbTime = intent.getLongExtra("HeartbeatTime", System.currentTimeMillis());
|
|
|
|
mService.mPreviousMpHbTime = intent.getLongExtra("HeartbeatTime", System.currentTimeMillis());
|
|
|
|
mService.logger.info("Heartbeat Timer Fired By MpAPP ACTION=" + action + " MpHB=" + Long.toString(mService.mMpHeartbeatDuration));
|
|
|
|
mService.logger.info("Heartbeat Timer Fired By MpAPP ACTION=" + action + " MpHB=" + Long.toString(mService.mMpHeartbeatDuration) + " HBTime =" + mService.mPreviousMpHbTime);
|
|
|
|
|
|
|
|
|
|
|
|
mService.registerHeartbeatTimer();
|
|
|
|
mService.registerHeartbeatTimer();
|
|
|
|
|
|
|
|
|
|
|
@ -806,7 +811,9 @@ public class MpMasterService extends Service {
|
|
|
|
if (keepAlive) {
|
|
|
|
if (keepAlive) {
|
|
|
|
alarmIntent.putExtra("keepAlive", keepAlive);
|
|
|
|
alarmIntent.putExtra("keepAlive", keepAlive);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, keepAlive ? 0 : 1, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
int uniqueReqCode = reqCode.getAndIncrement();
|
|
|
|
|
|
|
|
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, uniqueReqCode, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
|
|
|
// PendingIntent pendingIntent = PendingIntent.getBroadcast(this, keepAlive ? 0 : 1, alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
|
|
|
|
|
|
|
Date dt = new Date(triggerTime);
|
|
|
|
Date dt = new Date(triggerTime);
|
|
|
|
|
|
|
|
|
|
|
@ -913,12 +920,14 @@ public class MpMasterService extends Service {
|
|
|
|
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
|
|
|
}*/
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
int uniqueReqCode = reqCode.getAndIncrement();
|
|
|
|
|
|
|
|
PendingIntent pendingIntent = PendingIntent.getActivity(this, uniqueReqCode, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
|
|
|
|
|
|
|
|
// make a stop intent
|
|
|
|
// make a stop intent
|
|
|
|
Intent stopIntent = new Intent(this, MpMasterService.class);
|
|
|
|
Intent stopIntent = new Intent(this, MpMasterService.class);
|
|
|
|
stopIntent.setAction(ACTION_STOP);
|
|
|
|
stopIntent.setAction(ACTION_STOP);
|
|
|
|
PendingIntent pendingStopIntent = PendingIntent.getService(this, 0, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
uniqueReqCode = reqCode.getAndIncrement();
|
|
|
|
|
|
|
|
PendingIntent pendingStopIntent = PendingIntent.getService(this, uniqueReqCode, stopIntent, PendingIntent.FLAG_UPDATE_CURRENT);
|
|
|
|
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.notification);
|
|
|
|
RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.notification);
|
|
|
|
remoteViews.setOnClickPendingIntent(R.id.btn_stop, pendingStopIntent);
|
|
|
|
remoteViews.setOnClickPendingIntent(R.id.btn_stop, pendingStopIntent);
|
|
|
|
|
|
|
|
|
|
|
|