|
|
|
@ -69,7 +69,9 @@ public class MpMasterService extends Service {
|
|
|
|
|
public static final String ACTION_STOP = "com.xypower.mpmaster.ACT_STOP";
|
|
|
|
|
public static final String ACTION_MAIN = "com.xypower.mpmaster.ACT_MAIN";
|
|
|
|
|
|
|
|
|
|
public static final String ACTION_UPD_OTA = "com.xy.otaupdateresult";
|
|
|
|
|
public static final String ACTION_UPD_OTA = SysApi.OTA_RESULT_ACTION;
|
|
|
|
|
public static final String ACTION_INSTALL_RESULT = SysApi.INSTALL_RESULT_ACTION;
|
|
|
|
|
public static final String ACTION_UNINSTALL_RESULT = SysApi.UNINSTALL_RESULT_ACTION;
|
|
|
|
|
|
|
|
|
|
private static final String ACTION_UPDATE_CONFIGS = "com.xypower.mpmaster.ACT_UPD_CFG";
|
|
|
|
|
|
|
|
|
@ -207,6 +209,8 @@ public class MpMasterService extends Service {
|
|
|
|
|
intentFilter.addAction(ACTION_MSG_BROADCAST);
|
|
|
|
|
intentFilter.addAction(ACTION_UPDATE_CONFIGS);
|
|
|
|
|
intentFilter.addAction(ACTION_UPD_OTA);
|
|
|
|
|
intentFilter.addAction(ACTION_INSTALL_RESULT);
|
|
|
|
|
intentFilter.addAction(ACTION_UNINSTALL_RESULT);
|
|
|
|
|
if (!mSeparateNetwork) {
|
|
|
|
|
intentFilter.addAction(MicroPhotoContext.ACTION_HEARTBEAT_MP);
|
|
|
|
|
}
|
|
|
|
@ -470,6 +474,48 @@ public class MpMasterService extends Service {
|
|
|
|
|
}
|
|
|
|
|
} else if (TextUtils.equals(ACTION_UPD_OTA, action)) {
|
|
|
|
|
|
|
|
|
|
String cmd = intent.getStringExtra("cmd");
|
|
|
|
|
String msg = intent.getStringExtra("msg");
|
|
|
|
|
// Log.e("_otg_","cmd="+cmd);
|
|
|
|
|
if("write".equals(cmd))
|
|
|
|
|
{
|
|
|
|
|
// int progress = Integer.parseInt(msg);
|
|
|
|
|
}
|
|
|
|
|
else if("update".equals(cmd))
|
|
|
|
|
{
|
|
|
|
|
// int progress = Integer.parseInt(msg);
|
|
|
|
|
}
|
|
|
|
|
else if("info".equals(cmd))
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else if("error".equals(cmd))
|
|
|
|
|
{
|
|
|
|
|
mService.logger.warning("UPD OTA Failed");
|
|
|
|
|
}
|
|
|
|
|
else if("success".equals(cmd))
|
|
|
|
|
{
|
|
|
|
|
//confirm to reboot device ??
|
|
|
|
|
mService.logger.warning("UPD OTA Succeeded, will RESET dev");
|
|
|
|
|
Handler handler = new Handler();
|
|
|
|
|
handler.postDelayed(new Runnable() {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
SysApi.reboot(context);
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
|
|
|
|
}
|
|
|
|
|
} else if (TextUtils.equals(ACTION_INSTALL_RESULT, action)) {
|
|
|
|
|
boolean bSucc = intent.getBooleanExtra("succ", false);
|
|
|
|
|
String pkname = intent.getStringExtra("pkname");
|
|
|
|
|
String msg = intent.getStringExtra("msg");
|
|
|
|
|
// Log.e("_otg_","install result bsuc="+bSucc+",pkname="+pkname+",msg="+msg);
|
|
|
|
|
mService.logger.warning("INSTALL APP result =" + bSucc + ",pkname=" + pkname + ",msg=" + msg);
|
|
|
|
|
} else if (TextUtils.equals(ACTION_UNINSTALL_RESULT, action)) {
|
|
|
|
|
boolean bSucc = intent.getBooleanExtra("succ", false);
|
|
|
|
|
String pkname = intent.getStringExtra("pkname");
|
|
|
|
|
String msg = intent.getStringExtra("msg");
|
|
|
|
|
mService.logger.warning("UNINSTALL APP result =" + bSucc + ",pkname=" + pkname + ",msg=" + msg);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -787,11 +833,12 @@ public class MpMasterService extends Service {
|
|
|
|
|
@Override
|
|
|
|
|
public void run() {
|
|
|
|
|
if (rebootType == 0) {
|
|
|
|
|
logger.warning("Recv REBOOT MpMst APP cmd");
|
|
|
|
|
Context context = MpMasterService.this.getApplicationContext();
|
|
|
|
|
restartApp(context, context.getPackageName());
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
Log.w(TAG, "Recv REBOOT command");
|
|
|
|
|
logger.warning("Recv RESET cmd");
|
|
|
|
|
SysApi.reboot(MpMasterService.this.getApplicationContext());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -820,6 +867,7 @@ public class MpMasterService extends Service {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void selectSimCard(int num) {
|
|
|
|
|
logger.warning("Select SimCard: " + Integer.toString(num));
|
|
|
|
|
SysApi.selectSimCard4Data(getApplicationContext(), num);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|