Better status update

Keyguard prompt is part of the installation flow.
We should post a status update to notify the caller if
the keyguard is dismissed and installation won't continue.

Cherry-picked from aosp/2612430.

Bug: 277691885
Test: 1. set up lock screen password
      2. kick off DSU installation
      3. press back key to dismiss keyguard
      4. check logcat messages and find
         "DynamicSystemInstallationService: status: NOT_STARTED, cause: INSTALL_CANCELLED"
Change-Id: I0c919841d756ada6e94414e58f310635e4d8c12c
Merged-In: I0c919841d756ada6e94414e58f310635e4d8c12c
This commit is contained in:
Chun-Wei Wang
2023-06-01 07:56:37 +00:00
parent 8911c37ae2
commit f23096d78a
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 = public static final String ACTION_HIDE_NOTIFICATION =
"android.os.image.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 * Intent Keys
*/ */

View File

@@ -16,11 +16,10 @@
package com.android.dynsystem; 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.AsyncTask.Status.RUNNING;
import static android.os.image.DynamicSystemClient.ACTION_HIDE_NOTIFICATION; 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_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.ACTION_START_INSTALL;
import static android.os.image.DynamicSystemClient.CAUSE_ERROR_EXCEPTION; import static android.os.image.DynamicSystemClient.CAUSE_ERROR_EXCEPTION;
import static android.os.image.DynamicSystemClient.CAUSE_ERROR_INVALID_URL; import static android.os.image.DynamicSystemClient.CAUSE_ERROR_INVALID_URL;
@@ -234,6 +233,8 @@ public class DynamicSystemInstallationService extends Service
executeNotifyIfInUseCommand(); executeNotifyIfInUseCommand();
} else if (ACTION_HIDE_NOTIFICATION.equals(action)) { } else if (ACTION_HIDE_NOTIFICATION.equals(action)) {
executeHideNotificationCommand(); executeHideNotificationCommand();
} else if (ACTION_NOTIFY_KEYGUARD_DISMISSED.equals(action)) {
executeNotifyKeyguardDismissed();
} }
return Service.START_NOT_STICKY; 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() { private void resetTaskAndStop() {
resetTaskAndStop(/* removeNotification= */ false); resetTaskAndStop(/* removeNotification= */ false);
} }

View File

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