blob: 6bc66ecdb2618e89f913bbc7f31045ba259d2f2e [file] [log] [blame]
Andrii Kulian446e8242017-10-26 15:17:29 -07001/*
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 */
16package android.app;
17
18import android.app.servertransaction.ClientTransaction;
Andrii Kulian88e05cb2017-12-05 17:21:10 -080019import android.app.servertransaction.PendingTransactionActions;
20import android.content.pm.ApplicationInfo;
Andrii Kulian446e8242017-10-26 15:17:29 -070021import android.content.res.CompatibilityInfo;
22import android.content.res.Configuration;
Andrii Kulian446e8242017-10-26 15:17:29 -070023import android.os.IBinder;
Andrii Kulianb372da62018-01-18 10:46:24 -080024import android.util.MergedConfiguration;
Andrii Kulian446e8242017-10-26 15:17:29 -070025
Andrii Kulian446e8242017-10-26 15:17:29 -070026import com.android.internal.content.ReferrerIntent;
27
Bryce Leed946f862018-01-16 15:59:47 -080028import java.io.PrintWriter;
Andrii Kulian446e8242017-10-26 15:17:29 -070029import java.util.List;
30
31/**
32 * Defines operations that a {@link android.app.servertransaction.ClientTransaction} or its items
33 * can perform on client.
34 * @hide
35 */
36public abstract class ClientTransactionHandler {
37
38 // Schedule phase related logic and handlers.
39
40 /** Prepare and schedule transaction for execution. */
41 void scheduleTransaction(ClientTransaction transaction) {
Andrii Kulian88e05cb2017-12-05 17:21:10 -080042 transaction.preExecute(this);
Andrii Kulian446e8242017-10-26 15:17:29 -070043 sendMessage(ActivityThread.H.EXECUTE_TRANSACTION, transaction);
44 }
45
46 abstract void sendMessage(int what, Object obj);
47
48
49 // Prepare phase related logic and handlers. Methods that inform about about pending changes or
50 // do other internal bookkeeping.
51
Andrii Kulian446e8242017-10-26 15:17:29 -070052 /** Set pending config in case it will be updated by other transaction item. */
53 public abstract void updatePendingConfiguration(Configuration config);
54
55 /** Set current process state. */
56 public abstract void updateProcessState(int processState, boolean fromIpc);
57
58
59 // Execute phase related logic and handlers. Methods here execute actual lifecycle transactions
60 // and deliver callbacks.
61
62 /** Destroy the activity. */
63 public abstract void handleDestroyActivity(IBinder token, boolean finishing, int configChanges,
Bryce Leea33c13d2018-02-08 14:37:06 -080064 boolean getNonConfigInstance, String reason);
Andrii Kulian446e8242017-10-26 15:17:29 -070065
66 /** Pause the activity. */
67 public abstract void handlePauseActivity(IBinder token, boolean finished, boolean userLeaving,
Andrii Kuliana6176e32018-02-27 11:51:18 -080068 int configChanges, PendingTransactionActions pendingActions, String reason);
Andrii Kulian446e8242017-10-26 15:17:29 -070069
70 /** Resume the activity. */
71 public abstract void handleResumeActivity(IBinder token, boolean clearHide, boolean isForward,
Andrii Kulian88e05cb2017-12-05 17:21:10 -080072 String reason);
Andrii Kulian446e8242017-10-26 15:17:29 -070073
74 /** Stop the activity. */
75 public abstract void handleStopActivity(IBinder token, boolean show, int configChanges,
Andrii Kuliand25680c2018-02-21 15:16:58 -080076 PendingTransactionActions pendingActions, String reason);
Andrii Kulian88e05cb2017-12-05 17:21:10 -080077
78 /** Report that activity was stopped to server. */
79 public abstract void reportStop(PendingTransactionActions pendingActions);
80
81 /** Restart the activity after it was stopped. */
82 public abstract void performRestartActivity(IBinder token, boolean start);
Andrii Kulian446e8242017-10-26 15:17:29 -070083
84 /** Deliver activity (override) configuration change. */
85 public abstract void handleActivityConfigurationChanged(IBinder activityToken,
86 Configuration overrideConfig, int displayId);
87
88 /** Deliver result from another activity. */
89 public abstract void handleSendResult(IBinder token, List<ResultInfo> results);
90
91 /** Deliver multi-window mode change notification. */
92 public abstract void handleMultiWindowModeChanged(IBinder token, boolean isInMultiWindowMode,
93 Configuration overrideConfig);
94
95 /** Deliver new intent. */
96 public abstract void handleNewIntent(IBinder token, List<ReferrerIntent> intents,
97 boolean andPause);
98
99 /** Deliver picture-in-picture mode change notification. */
100 public abstract void handlePictureInPictureModeChanged(IBinder token, boolean isInPipMode,
101 Configuration overrideConfig);
102
103 /** Update window visibility. */
104 public abstract void handleWindowVisibility(IBinder token, boolean show);
105
106 /** Perform activity launch. */
Andrii Kulian88e05cb2017-12-05 17:21:10 -0800107 public abstract Activity handleLaunchActivity(ActivityThread.ActivityClientRecord r,
108 PendingTransactionActions pendingActions);
109
110 /** Perform activity start. */
111 public abstract void handleStartActivity(ActivityThread.ActivityClientRecord r,
112 PendingTransactionActions pendingActions);
113
114 /** Get package info. */
Todd Kennedy233a0b12018-01-29 20:30:24 +0000115 public abstract LoadedApk getPackageInfoNoCheck(ApplicationInfo ai,
Andrii Kulian88e05cb2017-12-05 17:21:10 -0800116 CompatibilityInfo compatInfo);
Andrii Kulian446e8242017-10-26 15:17:29 -0700117
118 /** Deliver app configuration change notification. */
119 public abstract void handleConfigurationChanged(Configuration config);
Andrii Kulian88e05cb2017-12-05 17:21:10 -0800120
121 /**
122 * Get {@link android.app.ActivityThread.ActivityClientRecord} instance that corresponds to the
123 * provided token.
124 */
125 public abstract ActivityThread.ActivityClientRecord getActivityClient(IBinder token);
Bryce Leed946f862018-01-16 15:59:47 -0800126
127 /**
Andrii Kulianb372da62018-01-18 10:46:24 -0800128 * Prepare activity relaunch to update internal bookkeeping. This is used to track multiple
129 * relaunch and config update requests.
130 * @param token Activity token.
131 * @param pendingResults Activity results to be delivered.
132 * @param pendingNewIntents New intent messages to be delivered.
133 * @param configChanges Mask of configuration changes that have occurred.
134 * @param config New configuration applied to the activity.
135 * @param preserveWindow Whether the activity should try to reuse the window it created,
136 * including the decor view after the relaunch.
137 * @return An initialized instance of {@link ActivityThread.ActivityClientRecord} to use during
138 * relaunch, or {@code null} if relaunch cancelled.
139 */
140 public abstract ActivityThread.ActivityClientRecord prepareRelaunchActivity(IBinder token,
141 List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents,
142 int configChanges, MergedConfiguration config, boolean preserveWindow);
143
144 /**
145 * Perform activity relaunch.
146 * @param r Activity client record prepared for relaunch.
147 * @param pendingActions Pending actions to be used on later stages of activity transaction.
148 * */
149 public abstract void handleRelaunchActivity(ActivityThread.ActivityClientRecord r,
150 PendingTransactionActions pendingActions);
151
152 /**
153 * Report that relaunch request was handled.
154 * @param token Target activity token.
155 * @param pendingActions Pending actions initialized on earlier stages of activity transaction.
156 * Used to check if we should report relaunch to WM.
157 * */
158 public abstract void reportRelaunch(IBinder token, PendingTransactionActions pendingActions);
159
160 /**
Bryce Leed946f862018-01-16 15:59:47 -0800161 * Debugging output.
162 * @param pw {@link PrintWriter} to write logs to.
163 * @param prefix Prefix to prepend to output.
164 */
165 public abstract void dump(PrintWriter pw, String prefix);
Andrii Kulian446e8242017-10-26 15:17:29 -0700166}