|
|
@ -168,7 +168,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
mHander.postDelayed(new Runnable() {
|
|
|
|
mHander.postDelayed(new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
restartApp(context, MicroPhotoContext.PACKAGE_NAME_MPAPP);
|
|
|
|
restartApp(context, MicroPhotoContext.PACKAGE_NAME_MPAPP, "TrimMemory");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 1000);
|
|
|
|
}, 1000);
|
|
|
|
} catch (Exception ex) {
|
|
|
|
} catch (Exception ex) {
|
|
|
@ -434,7 +434,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
int restart = intent.getIntExtra("restart", 0);
|
|
|
|
int restart = intent.getIntExtra("restart", 0);
|
|
|
|
Log.i(TAG, "UPD CFG Fired ACTION=" + action + " restart=" + restart);
|
|
|
|
Log.i(TAG, "UPD CFG Fired ACTION=" + action + " restart=" + restart);
|
|
|
|
if (restart != 0) {
|
|
|
|
if (restart != 0) {
|
|
|
|
MicroPhotoService.restartApp(context, context.getPackageName());
|
|
|
|
MicroPhotoService.restartApp(context, context.getPackageName(), "Config Updated");
|
|
|
|
} else if (mService.mNativeHandle != 0) {
|
|
|
|
} else if (mService.mNativeHandle != 0) {
|
|
|
|
mService.reloadConfigs(mService.mNativeHandle);
|
|
|
|
mService.reloadConfigs(mService.mNativeHandle);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -553,7 +553,7 @@ public class MicroPhotoService extends Service {
|
|
|
|
} catch (Exception ex) {
|
|
|
|
} catch (Exception ex) {
|
|
|
|
ex.printStackTrace();
|
|
|
|
ex.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
MicroPhotoService.restartApp(context.getApplicationContext(), MicroPhotoContext.PACKAGE_NAME_MPAPP);
|
|
|
|
MicroPhotoService.restartApp(context.getApplicationContext(), MicroPhotoContext.PACKAGE_NAME_MPAPP, "Restart Cmd");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1262,14 +1262,14 @@ public class MicroPhotoService extends Service {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void reboot(final int rebootType, final long timeout) {
|
|
|
|
public void reboot(final int rebootType, final long timeout, final String reason) {
|
|
|
|
|
|
|
|
|
|
|
|
Runnable runnable = new Runnable() {
|
|
|
|
Runnable runnable = new Runnable() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void run() {
|
|
|
|
public void run() {
|
|
|
|
if (rebootType == 0) {
|
|
|
|
if (rebootType == 0) {
|
|
|
|
Context context = MicroPhotoService.this.getApplicationContext();
|
|
|
|
Context context = MicroPhotoService.this.getApplicationContext();
|
|
|
|
restartApp(context, context.getPackageName());
|
|
|
|
restartApp(context, context.getPackageName(), reason);
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Log.w(TAG, "Recv REBOOT command");
|
|
|
|
Log.w(TAG, "Recv REBOOT command");
|
|
|
@ -1280,11 +1280,14 @@ public class MicroPhotoService extends Service {
|
|
|
|
mHander.postDelayed(runnable, timeout > 0 ? timeout : 1000);
|
|
|
|
mHander.postDelayed(runnable, timeout > 0 ? timeout : 1000);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public static void restartApp(Context context, String packageName) {
|
|
|
|
public static void restartApp(Context context, String packageName, String reason) {
|
|
|
|
|
|
|
|
|
|
|
|
Intent intent = new Intent(context, MainActivity.class);
|
|
|
|
Intent intent = new Intent(context, MainActivity.class);
|
|
|
|
int noDelay = 1;
|
|
|
|
int noDelay = 1;
|
|
|
|
intent.putExtra("noDelay", noDelay);
|
|
|
|
intent.putExtra("noDelay", noDelay);
|
|
|
|
|
|
|
|
if (!TextUtils.isEmpty(reason)) {
|
|
|
|
|
|
|
|
intent.putExtra("reason", reason);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
|
|
|
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
|
|
|
context.startActivity(intent);
|
|
|
|
context.startActivity(intent);
|
|
|
|