|
|
|
@ -24,6 +24,8 @@ import android.os.Messenger;
|
|
|
|
|
import android.os.PowerManager;
|
|
|
|
|
import android.os.SystemClock;
|
|
|
|
|
import android.telephony.SignalStrength;
|
|
|
|
|
import android.telephony.SubscriptionInfo;
|
|
|
|
|
import android.telephony.SubscriptionManager;
|
|
|
|
|
import android.telephony.TelephonyManager;
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
import android.text.format.DateFormat;
|
|
|
|
@ -116,6 +118,9 @@ public class MpMasterService extends Service {
|
|
|
|
|
private PendingIntent mPreviousHB = null;
|
|
|
|
|
private long mPreviousHeartbeatTime = 0;
|
|
|
|
|
|
|
|
|
|
private String mIccid1 = null;
|
|
|
|
|
private String mIccid2 = null;
|
|
|
|
|
|
|
|
|
|
public MpMasterService() {
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
@ -129,7 +134,7 @@ public class MpMasterService extends Service {
|
|
|
|
|
super.onCreate();
|
|
|
|
|
|
|
|
|
|
loadConfig();
|
|
|
|
|
|
|
|
|
|
loadIccid();
|
|
|
|
|
logger = Logger.getLogger("com.xypower.mpmaster.logger");
|
|
|
|
|
logger.setLevel(Level.ALL);
|
|
|
|
|
// LogFormatter.installFormatter(logger);
|
|
|
|
@ -226,6 +231,14 @@ public class MpMasterService extends Service {
|
|
|
|
|
registerHeartbeatTimer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getIccid(int number) {
|
|
|
|
|
if (number == 1) {
|
|
|
|
|
return mIccid1 == null ? "" : mIccid1;
|
|
|
|
|
} else {
|
|
|
|
|
return mIccid2 == null ? "" : mIccid2;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void onDestroy() {
|
|
|
|
|
|
|
|
|
@ -273,6 +286,31 @@ public class MpMasterService extends Service {
|
|
|
|
|
mTimeOfMpAppAlive = masterConfig.mpappMonitorTimeout;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void loadIccid() {
|
|
|
|
|
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP_MR1)
|
|
|
|
|
{
|
|
|
|
|
try {
|
|
|
|
|
SubscriptionManager sm = SubscriptionManager.from(this);
|
|
|
|
|
List<SubscriptionInfo> sis = sm.getActiveSubscriptionInfoList();
|
|
|
|
|
if (sis.size() >= 1) {
|
|
|
|
|
SubscriptionInfo si1 = sis.get(0);
|
|
|
|
|
mIccid1 = si1.getIccId();
|
|
|
|
|
// String phoneNum1 = si1.getNumber();
|
|
|
|
|
}
|
|
|
|
|
if (sis.size() >= 2) {
|
|
|
|
|
SubscriptionInfo si2 = sis.get(1);
|
|
|
|
|
mIccid1 = si2.getIccId();
|
|
|
|
|
// String phoneNum2 = si2.getNumber();
|
|
|
|
|
}
|
|
|
|
|
// int count = sm.getActiveSubscriptionInfoCount();// real cards
|
|
|
|
|
// int max = sm.getActiveSubscriptionInfoCountMax();// Slot number
|
|
|
|
|
|
|
|
|
|
} catch (Exception ex) {
|
|
|
|
|
ex.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// public boolean useSeparater
|
|
|
|
|
public String getCmdid() {
|
|
|
|
|
return mCmdid;
|
|
|
|
|