优化OTA升级

hdrplus
Matthew 12 months ago
parent 669a05d6a7
commit 32adff37c5

@ -898,7 +898,7 @@ public class AppMaster {
Context context = mService.getApplicationContext(); Context context = mService.getApplicationContext();
mService.logger.info("Upgrade OTA: " + url); mService.logger.info("Upgrade OTA: " + url);
SysApi.installOTA(context, context.getPackageName(), otaPath); mService.installOTA(otaPath);
} else { } else {
mService.logger.warning("Failed to Download:" + url); mService.logger.warning("Failed to Download:" + url);
} }
@ -921,12 +921,12 @@ public class AppMaster {
final String mpAppDir = MicroPhotoContext.buildMpAppDir(mService.getApplicationContext()); final String mpAppDir = MicroPhotoContext.buildMpAppDir(mService.getApplicationContext());
final File logDir = new File(mpAppDir + "logs" + File.separator); final File logDir = new File(mpAppDir + "logs" + File.separator);
if (!logDir.exists()) {
return;
}
List<File> folders = new ArrayList<>(); List<File> folders = new ArrayList<>();
if (logDir.exists()) {
folders.add(logDir); folders.add(logDir);
}
final String masterAppDir = MicroPhotoContext.buildMasterAppDir(mService.getApplicationContext()); final String masterAppDir = MicroPhotoContext.buildMasterAppDir(mService.getApplicationContext());
final File mlogDir = new File(masterAppDir + "logs" + File.separator); final File mlogDir = new File(masterAppDir + "logs" + File.separator);
@ -934,6 +934,11 @@ public class AppMaster {
folders.add(mlogDir); folders.add(mlogDir);
} }
if (folders.isEmpty()) {
mService.logger.warning("Both Log Directories are not Existed");
return;
}
ZipUtils.Filter filter = new ZipUtils.Filter() { ZipUtils.Filter filter = new ZipUtils.Filter() {
@Override @Override
public boolean match(String fileName) { public boolean match(String fileName) {

@ -524,27 +524,21 @@ public class MpMasterService extends Service {
String cmd = intent.getStringExtra("cmd"); String cmd = intent.getStringExtra("cmd");
String msg = intent.getStringExtra("msg"); String msg = intent.getStringExtra("msg");
// Log.e("_otg_","cmd="+cmd); // mService.logger.info("cmd=" + cmd + " msg=" + msg);
if("write".equals(cmd)) if("write".equals(cmd)) {
{
// int progress = Integer.parseInt(msg); // int progress = Integer.parseInt(msg);
} }
else if("update".equals(cmd)) else if("update".equals(cmd)) {
{
// int progress = Integer.parseInt(msg); // int progress = Integer.parseInt(msg);
} }
else if("info".equals(cmd)) else if("info".equals(cmd)) {
{
} }
else if("error".equals(cmd)) else if("error".equals(cmd)) {
{
mService.logger.warning("UPD OTA Failed"); mService.logger.warning("UPD OTA Failed");
} }
else if("success".equals(cmd)) else if("success".equals(cmd)) {
{
//confirm to reboot device ?? //confirm to reboot device ??
mService.logger.warning("UPD OTA Succeeded, will RESET dev"); mService.logger.warning("UPD OTA Succeeded, will REBOOT device");
Handler handler = new Handler(); Handler handler = new Handler();
handler.postDelayed(new Runnable() { handler.postDelayed(new Runnable() {
@Override @Override
@ -568,6 +562,17 @@ public class MpMasterService extends Service {
} }
} }
public void installOTA(final String path) {
final Context context = getApplicationContext();
mHander.post(new Runnable() {
@Override
public void run() {
SysApi.installOTA(context, context.getPackageName(), path);
}
});
}
private void registerHeartbeatTimer() { private void registerHeartbeatTimer() {
long timeout = mHeartbeatDuration; long timeout = mHeartbeatDuration;

Loading…
Cancel
Save