Andrii Kulian | 446e824 | 2017-10-26 15:17:29 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | package android.app; |
| 17 | |
| 18 | import android.app.servertransaction.ClientTransaction; |
Andrii Kulian | 88e05cb | 2017-12-05 17:21:10 -0800 | [diff] [blame] | 19 | import android.app.servertransaction.PendingTransactionActions; |
| 20 | import android.content.pm.ApplicationInfo; |
Andrii Kulian | 446e824 | 2017-10-26 15:17:29 -0700 | [diff] [blame] | 21 | import android.content.res.CompatibilityInfo; |
| 22 | import android.content.res.Configuration; |
Andrii Kulian | 446e824 | 2017-10-26 15:17:29 -0700 | [diff] [blame] | 23 | import android.os.IBinder; |
Andrii Kulian | 446e824 | 2017-10-26 15:17:29 -0700 | [diff] [blame] | 24 | |
Andrii Kulian | 446e824 | 2017-10-26 15:17:29 -0700 | [diff] [blame] | 25 | import com.android.internal.content.ReferrerIntent; |
| 26 | |
Bryce Lee | d946f86 | 2018-01-16 15:59:47 -0800 | [diff] [blame] | 27 | import java.io.PrintWriter; |
Andrii Kulian | 446e824 | 2017-10-26 15:17:29 -0700 | [diff] [blame] | 28 | import java.util.List; |
| 29 | |
| 30 | /** |
| 31 | * Defines operations that a {@link android.app.servertransaction.ClientTransaction} or its items |
| 32 | * can perform on client. |
| 33 | * @hide |
| 34 | */ |
| 35 | public abstract class ClientTransactionHandler { |
| 36 | |
| 37 | // Schedule phase related logic and handlers. |
| 38 | |
| 39 | /** Prepare and schedule transaction for execution. */ |
| 40 | void scheduleTransaction(ClientTransaction transaction) { |
Andrii Kulian | 88e05cb | 2017-12-05 17:21:10 -0800 | [diff] [blame] | 41 | transaction.preExecute(this); |
Andrii Kulian | 446e824 | 2017-10-26 15:17:29 -0700 | [diff] [blame] | 42 | sendMessage(ActivityThread.H.EXECUTE_TRANSACTION, transaction); |
| 43 | } |
| 44 | |
| 45 | abstract void sendMessage(int what, Object obj); |
| 46 | |
| 47 | |
| 48 | // Prepare phase related logic and handlers. Methods that inform about about pending changes or |
| 49 | // do other internal bookkeeping. |
| 50 | |
Andrii Kulian | 446e824 | 2017-10-26 15:17:29 -0700 | [diff] [blame] | 51 | /** Set pending config in case it will be updated by other transaction item. */ |
| 52 | public abstract void updatePendingConfiguration(Configuration config); |
| 53 | |
| 54 | /** Set current process state. */ |
| 55 | public abstract void updateProcessState(int processState, boolean fromIpc); |
| 56 | |
| 57 | |
| 58 | // Execute phase related logic and handlers. Methods here execute actual lifecycle transactions |
| 59 | // and deliver callbacks. |
| 60 | |
| 61 | /** Destroy the activity. */ |
| 62 | public abstract void handleDestroyActivity(IBinder token, boolean finishing, int configChanges, |
Bryce Lee | a33c13d | 2018-02-08 14:37:06 -0800 | [diff] [blame^] | 63 | boolean getNonConfigInstance, String reason); |
Andrii Kulian | 446e824 | 2017-10-26 15:17:29 -0700 | [diff] [blame] | 64 | |
| 65 | /** Pause the activity. */ |
| 66 | public abstract void handlePauseActivity(IBinder token, boolean finished, boolean userLeaving, |
Andrii Kulian | 88e05cb | 2017-12-05 17:21:10 -0800 | [diff] [blame] | 67 | int configChanges, boolean dontReport, PendingTransactionActions pendingActions); |
Andrii Kulian | 446e824 | 2017-10-26 15:17:29 -0700 | [diff] [blame] | 68 | |
| 69 | /** Resume the activity. */ |
| 70 | public abstract void handleResumeActivity(IBinder token, boolean clearHide, boolean isForward, |
Andrii Kulian | 88e05cb | 2017-12-05 17:21:10 -0800 | [diff] [blame] | 71 | String reason); |
Andrii Kulian | 446e824 | 2017-10-26 15:17:29 -0700 | [diff] [blame] | 72 | |
| 73 | /** Stop the activity. */ |
| 74 | public abstract void handleStopActivity(IBinder token, boolean show, int configChanges, |
Andrii Kulian | 88e05cb | 2017-12-05 17:21:10 -0800 | [diff] [blame] | 75 | PendingTransactionActions pendingActions); |
| 76 | |
| 77 | /** Report that activity was stopped to server. */ |
| 78 | public abstract void reportStop(PendingTransactionActions pendingActions); |
| 79 | |
| 80 | /** Restart the activity after it was stopped. */ |
| 81 | public abstract void performRestartActivity(IBinder token, boolean start); |
Andrii Kulian | 446e824 | 2017-10-26 15:17:29 -0700 | [diff] [blame] | 82 | |
| 83 | /** Deliver activity (override) configuration change. */ |
| 84 | public abstract void handleActivityConfigurationChanged(IBinder activityToken, |
| 85 | Configuration overrideConfig, int displayId); |
| 86 | |
| 87 | /** Deliver result from another activity. */ |
| 88 | public abstract void handleSendResult(IBinder token, List<ResultInfo> results); |
| 89 | |
| 90 | /** Deliver multi-window mode change notification. */ |
| 91 | public abstract void handleMultiWindowModeChanged(IBinder token, boolean isInMultiWindowMode, |
| 92 | Configuration overrideConfig); |
| 93 | |
| 94 | /** Deliver new intent. */ |
| 95 | public abstract void handleNewIntent(IBinder token, List<ReferrerIntent> intents, |
| 96 | boolean andPause); |
| 97 | |
| 98 | /** Deliver picture-in-picture mode change notification. */ |
| 99 | public abstract void handlePictureInPictureModeChanged(IBinder token, boolean isInPipMode, |
| 100 | Configuration overrideConfig); |
| 101 | |
| 102 | /** Update window visibility. */ |
| 103 | public abstract void handleWindowVisibility(IBinder token, boolean show); |
| 104 | |
| 105 | /** Perform activity launch. */ |
Andrii Kulian | 88e05cb | 2017-12-05 17:21:10 -0800 | [diff] [blame] | 106 | public abstract Activity handleLaunchActivity(ActivityThread.ActivityClientRecord r, |
| 107 | PendingTransactionActions pendingActions); |
| 108 | |
| 109 | /** Perform activity start. */ |
| 110 | public abstract void handleStartActivity(ActivityThread.ActivityClientRecord r, |
| 111 | PendingTransactionActions pendingActions); |
| 112 | |
| 113 | /** Get package info. */ |
Todd Kennedy | 233a0b1 | 2018-01-29 20:30:24 +0000 | [diff] [blame] | 114 | public abstract LoadedApk getPackageInfoNoCheck(ApplicationInfo ai, |
Andrii Kulian | 88e05cb | 2017-12-05 17:21:10 -0800 | [diff] [blame] | 115 | CompatibilityInfo compatInfo); |
Andrii Kulian | 446e824 | 2017-10-26 15:17:29 -0700 | [diff] [blame] | 116 | |
| 117 | /** Deliver app configuration change notification. */ |
| 118 | public abstract void handleConfigurationChanged(Configuration config); |
Andrii Kulian | 88e05cb | 2017-12-05 17:21:10 -0800 | [diff] [blame] | 119 | |
| 120 | /** |
| 121 | * Get {@link android.app.ActivityThread.ActivityClientRecord} instance that corresponds to the |
| 122 | * provided token. |
| 123 | */ |
| 124 | public abstract ActivityThread.ActivityClientRecord getActivityClient(IBinder token); |
Bryce Lee | d946f86 | 2018-01-16 15:59:47 -0800 | [diff] [blame] | 125 | |
| 126 | /** |
| 127 | * Debugging output. |
| 128 | * @param pw {@link PrintWriter} to write logs to. |
| 129 | * @param prefix Prefix to prepend to output. |
| 130 | */ |
| 131 | public abstract void dump(PrintWriter pw, String prefix); |
Andrii Kulian | 446e824 | 2017-10-26 15:17:29 -0700 | [diff] [blame] | 132 | } |