diff options
| author | TreeHugger Robot <treehugger-gerrit@google.com> | 2022-06-01 03:53:37 +0000 |
|---|---|---|
| committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-06-01 03:53:37 +0000 |
| commit | cf05c79ea0d64cf727c5fc0940019e772f3454a0 (patch) | |
| tree | 5a2789529a065032c2c495c9ff7c5e8e2dddafa9 /core/java/android/app/ActivityThread.java | |
| parent | fd51081ecf560f4165920c7735e7102fbeb4377e (diff) | |
| parent | 0d84708056a819c8e774fea4c7bba44cc97028c4 (diff) | |
Merge "Postpone the request direct actions before onStart" into tm-dev am: 0d84708056
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/18628126
Change-Id: Ieb1eaeb742bf3a98c466d32fb6fff3ba5d795daf
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'core/java/android/app/ActivityThread.java')
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index c6f59208c450..cf141c62d0e1 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -298,6 +298,11 @@ public final class ActivityThread extends ClientTransactionHandler /** Use background GC policy and default JIT threshold. */ private static final int VM_PROCESS_STATE_JANK_IMPERCEPTIBLE = 1; + /** The delay time for retrying to request DirectActions. */ + private static final long REQUEST_DIRECT_ACTIONS_RETRY_TIME_MS = 200; + /** The max count for retrying to request DirectActions. */ + private static final int REQUEST_DIRECT_ACTIONS_RETRY_MAX_COUNT = 3; + /** * Denotes an invalid sequence number corresponding to a process state change. */ @@ -1864,7 +1869,8 @@ public final class ActivityThread extends ClientTransactionHandler cancellationCallback.sendResult(cancellationResult); } mH.sendMessage(PooledLambda.obtainMessage(ActivityThread::handleRequestDirectActions, - ActivityThread.this, activityToken, interactor, cancellationSignal, callback)); + ActivityThread.this, activityToken, interactor, cancellationSignal, callback, + REQUEST_DIRECT_ACTIONS_RETRY_MAX_COUNT)); } @Override @@ -3970,7 +3976,7 @@ public final class ActivityThread extends ClientTransactionHandler /** Fetches the user actions for the corresponding activity */ private void handleRequestDirectActions(@NonNull IBinder activityToken, @NonNull IVoiceInteractor interactor, @NonNull CancellationSignal cancellationSignal, - @NonNull RemoteCallback callback) { + @NonNull RemoteCallback callback, int retryCount) { final ActivityClientRecord r = mActivities.get(activityToken); if (r == null) { Log.w(TAG, "requestDirectActions(): no activity for " + activityToken); @@ -3978,7 +3984,20 @@ public final class ActivityThread extends ClientTransactionHandler return; } final int lifecycleState = r.getLifecycleState(); - if (lifecycleState < ON_START || lifecycleState >= ON_STOP) { + if (lifecycleState < ON_START) { + // TODO(b/234173463): requestDirectActions callback should indicate errors + if (retryCount > 0) { + mH.sendMessageDelayed( + PooledLambda.obtainMessage(ActivityThread::handleRequestDirectActions, + ActivityThread.this, activityToken, interactor, cancellationSignal, + callback, retryCount - 1), REQUEST_DIRECT_ACTIONS_RETRY_TIME_MS); + return; + } + Log.w(TAG, "requestDirectActions(" + r + "): wrong lifecycle: " + lifecycleState); + callback.sendResult(null); + return; + } + if (lifecycleState >= ON_STOP) { Log.w(TAG, "requestDirectActions(" + r + "): wrong lifecycle: " + lifecycleState); callback.sendResult(null); return; |
