Loading packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java +17 −9 Original line number Original line Diff line number Diff line Loading @@ -139,6 +139,7 @@ public class DynamicSystemInstallationService extends Service private long mCurrentPartitionInstalledSize; private long mCurrentPartitionInstalledSize; private boolean mJustCancelledByUser; private boolean mJustCancelledByUser; private boolean mKeepNotification; // This is for testing only now // This is for testing only now private boolean mEnableWhenCompleted; private boolean mEnableWhenCompleted; Loading Loading @@ -173,9 +174,12 @@ public class DynamicSystemInstallationService extends Service if (cache != null) { if (cache != null) { cache.flush(); cache.flush(); } } if (!mKeepNotification) { // Cancel the persistent notification. // Cancel the persistent notification. mNM.cancel(NOTIFICATION_ID); mNM.cancel(NOTIFICATION_ID); } } } @Override @Override public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) { Loading Loading @@ -227,9 +231,6 @@ public class DynamicSystemInstallationService extends Service return; return; } } // if it's not successful, reset the task and stop self. resetTaskAndStop(); switch (result) { switch (result) { case RESULT_CANCELLED: case RESULT_CANCELLED: postStatus(STATUS_NOT_STARTED, CAUSE_INSTALL_CANCELLED, null); postStatus(STATUS_NOT_STARTED, CAUSE_INSTALL_CANCELLED, null); Loading @@ -248,6 +249,9 @@ public class DynamicSystemInstallationService extends Service postStatus(STATUS_NOT_STARTED, CAUSE_ERROR_EXCEPTION, detail); postStatus(STATUS_NOT_STARTED, CAUSE_ERROR_EXCEPTION, detail); break; break; } } // if it's not successful, reset the task and stop self. resetTaskAndStop(); } } private void executeInstallCommand(Intent intent) { private void executeInstallCommand(Intent intent) { Loading Loading @@ -392,10 +396,10 @@ public class DynamicSystemInstallationService extends Service private void resetTaskAndStop() { private void resetTaskAndStop() { mInstallTask = null; mInstallTask = null; stopForeground(true); new Handler().postDelayed(() -> { stopForeground(STOP_FOREGROUND_DETACH); // stop self, but this service is not destroyed yet if it's still bound stopSelf(); stopSelf(); }, 50); } } private void prepareNotification() { private void prepareNotification() { Loading Loading @@ -503,6 +507,7 @@ public class DynamicSystemInstallationService extends Service private void postStatus(int status, int cause, Throwable detail) { private void postStatus(int status, int cause, Throwable detail) { String statusString; String statusString; String causeString; String causeString; mKeepNotification = false; switch (status) { switch (status) { case STATUS_NOT_STARTED: case STATUS_NOT_STARTED: Loading Loading @@ -531,12 +536,15 @@ public class DynamicSystemInstallationService extends Service break; break; case CAUSE_ERROR_IO: case CAUSE_ERROR_IO: causeString = "ERROR_IO"; causeString = "ERROR_IO"; mKeepNotification = true; break; break; case CAUSE_ERROR_INVALID_URL: case CAUSE_ERROR_INVALID_URL: causeString = "ERROR_INVALID_URL"; causeString = "ERROR_INVALID_URL"; mKeepNotification = true; break; break; case CAUSE_ERROR_EXCEPTION: case CAUSE_ERROR_EXCEPTION: causeString = "ERROR_EXCEPTION"; causeString = "ERROR_EXCEPTION"; mKeepNotification = true; break; break; default: default: causeString = "CAUSE_NOT_SPECIFIED"; causeString = "CAUSE_NOT_SPECIFIED"; Loading Loading
packages/DynamicSystemInstallationService/src/com/android/dynsystem/DynamicSystemInstallationService.java +17 −9 Original line number Original line Diff line number Diff line Loading @@ -139,6 +139,7 @@ public class DynamicSystemInstallationService extends Service private long mCurrentPartitionInstalledSize; private long mCurrentPartitionInstalledSize; private boolean mJustCancelledByUser; private boolean mJustCancelledByUser; private boolean mKeepNotification; // This is for testing only now // This is for testing only now private boolean mEnableWhenCompleted; private boolean mEnableWhenCompleted; Loading Loading @@ -173,9 +174,12 @@ public class DynamicSystemInstallationService extends Service if (cache != null) { if (cache != null) { cache.flush(); cache.flush(); } } if (!mKeepNotification) { // Cancel the persistent notification. // Cancel the persistent notification. mNM.cancel(NOTIFICATION_ID); mNM.cancel(NOTIFICATION_ID); } } } @Override @Override public IBinder onBind(Intent intent) { public IBinder onBind(Intent intent) { Loading Loading @@ -227,9 +231,6 @@ public class DynamicSystemInstallationService extends Service return; return; } } // if it's not successful, reset the task and stop self. resetTaskAndStop(); switch (result) { switch (result) { case RESULT_CANCELLED: case RESULT_CANCELLED: postStatus(STATUS_NOT_STARTED, CAUSE_INSTALL_CANCELLED, null); postStatus(STATUS_NOT_STARTED, CAUSE_INSTALL_CANCELLED, null); Loading @@ -248,6 +249,9 @@ public class DynamicSystemInstallationService extends Service postStatus(STATUS_NOT_STARTED, CAUSE_ERROR_EXCEPTION, detail); postStatus(STATUS_NOT_STARTED, CAUSE_ERROR_EXCEPTION, detail); break; break; } } // if it's not successful, reset the task and stop self. resetTaskAndStop(); } } private void executeInstallCommand(Intent intent) { private void executeInstallCommand(Intent intent) { Loading Loading @@ -392,10 +396,10 @@ public class DynamicSystemInstallationService extends Service private void resetTaskAndStop() { private void resetTaskAndStop() { mInstallTask = null; mInstallTask = null; stopForeground(true); new Handler().postDelayed(() -> { stopForeground(STOP_FOREGROUND_DETACH); // stop self, but this service is not destroyed yet if it's still bound stopSelf(); stopSelf(); }, 50); } } private void prepareNotification() { private void prepareNotification() { Loading Loading @@ -503,6 +507,7 @@ public class DynamicSystemInstallationService extends Service private void postStatus(int status, int cause, Throwable detail) { private void postStatus(int status, int cause, Throwable detail) { String statusString; String statusString; String causeString; String causeString; mKeepNotification = false; switch (status) { switch (status) { case STATUS_NOT_STARTED: case STATUS_NOT_STARTED: Loading Loading @@ -531,12 +536,15 @@ public class DynamicSystemInstallationService extends Service break; break; case CAUSE_ERROR_IO: case CAUSE_ERROR_IO: causeString = "ERROR_IO"; causeString = "ERROR_IO"; mKeepNotification = true; break; break; case CAUSE_ERROR_INVALID_URL: case CAUSE_ERROR_INVALID_URL: causeString = "ERROR_INVALID_URL"; causeString = "ERROR_INVALID_URL"; mKeepNotification = true; break; break; case CAUSE_ERROR_EXCEPTION: case CAUSE_ERROR_EXCEPTION: causeString = "ERROR_EXCEPTION"; causeString = "ERROR_EXCEPTION"; mKeepNotification = true; break; break; default: default: causeString = "CAUSE_NOT_SPECIFIED"; causeString = "CAUSE_NOT_SPECIFIED"; Loading