Merge "Better status update"

This commit is contained in:
Chun-Wei Wang
2023-06-02 05:08:53 +00:00
committed by Gerrit Code Review
3 changed files with 23 additions and 2 deletions

View File

@@ -209,6 +209,13 @@ public class DynamicSystemClient {
public static final String ACTION_HIDE_NOTIFICATION =
"android.os.image.action.HIDE_NOTIFICATION";
/**
* Intent action: notify the service to post a status update when keyguard is dismissed.
* @hide
*/
public static final String ACTION_NOTIFY_KEYGUARD_DISMISSED =
"android.os.image.action.NOTIFY_KEYGUARD_DISMISSED";
/*
* Intent Keys
*/

View File

@@ -16,11 +16,10 @@
package com.android.dynsystem;
import static android.os.AsyncTask.Status.FINISHED;
import static android.os.AsyncTask.Status.PENDING;
import static android.os.AsyncTask.Status.RUNNING;
import static android.os.image.DynamicSystemClient.ACTION_HIDE_NOTIFICATION;
import static android.os.image.DynamicSystemClient.ACTION_NOTIFY_IF_IN_USE;
import static android.os.image.DynamicSystemClient.ACTION_NOTIFY_KEYGUARD_DISMISSED;
import static android.os.image.DynamicSystemClient.ACTION_START_INSTALL;
import static android.os.image.DynamicSystemClient.CAUSE_ERROR_EXCEPTION;
import static android.os.image.DynamicSystemClient.CAUSE_ERROR_INVALID_URL;
@@ -234,6 +233,8 @@ public class DynamicSystemInstallationService extends Service
executeNotifyIfInUseCommand();
} else if (ACTION_HIDE_NOTIFICATION.equals(action)) {
executeHideNotificationCommand();
} else if (ACTION_NOTIFY_KEYGUARD_DISMISSED.equals(action)) {
executeNotifyKeyguardDismissed();
}
return Service.START_NOT_STICKY;
@@ -477,6 +478,10 @@ public class DynamicSystemInstallationService extends Service
}
}
private void executeNotifyKeyguardDismissed() {
postStatus(STATUS_NOT_STARTED, CAUSE_INSTALL_CANCELLED, null);
}
private void resetTaskAndStop() {
resetTaskAndStop(/* removeNotification= */ false);
}

View File

@@ -16,6 +16,7 @@
package com.android.dynsystem;
import static android.os.image.DynamicSystemClient.ACTION_NOTIFY_KEYGUARD_DISMISSED;
import static android.os.image.DynamicSystemClient.KEY_KEYGUARD_USE_DEFAULT_STRINGS;
import android.app.Activity;
@@ -83,11 +84,19 @@ public class VerificationActivity extends Activity {
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
startInstallationService();
} else {
notifyKeyguardDismissed();
}
finish();
}
private void notifyKeyguardDismissed() {
Intent intent = new Intent(this, DynamicSystemInstallationService.class);
intent.setAction(ACTION_NOTIFY_KEYGUARD_DISMISSED);
startServiceAsUser(intent, UserHandle.SYSTEM);
}
private void startInstallationService() {
// retrieve data from calling intent
Intent callingIntent = getIntent();