blob: d061a9824f65a35f389cf9e92df7154f0745446c [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 Kulian446e8242017-10-26 15:17:29 -070024
Andrii Kulian446e8242017-10-26 15:17:29 -070025import com.android.internal.content.ReferrerIntent;
26
Bryce Leed946f862018-01-16 15:59:47 -080027import java.io.PrintWriter;
Andrii Kulian446e8242017-10-26 15:17:29 -070028import 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 */
35public 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 Kulian88e05cb2017-12-05 17:21:10 -080041 transaction.preExecute(this);
Andrii Kulian446e8242017-10-26 15:17:29 -070042 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 Kulian446e8242017-10-26 15:17:29 -070051 /** 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 Leea33c13d2018-02-08 14:37:06 -080063 boolean getNonConfigInstance, String reason);
Andrii Kulian446e8242017-10-26 15:17:29 -070064
65 /** Pause the activity. */
66 public abstract void handlePauseActivity(IBinder token, boolean finished, boolean userLeaving,
Andrii Kulian88e05cb2017-12-05 17:21:10 -080067 int configChanges, boolean dontReport, PendingTransactionActions pendingActions);
Andrii Kulian446e8242017-10-26 15:17:29 -070068
69 /** Resume the activity. */
70 public abstract void handleResumeActivity(IBinder token, boolean clearHide, boolean isForward,
Andrii Kulian88e05cb2017-12-05 17:21:10 -080071 String reason);
Andrii Kulian446e8242017-10-26 15:17:29 -070072
73 /** Stop the activity. */
74 public abstract void handleStopActivity(IBinder token, boolean show, int configChanges,
Andrii Kulian88e05cb2017-12-05 17:21:10 -080075 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 Kulian446e8242017-10-26 15:17:29 -070082
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 Kulian88e05cb2017-12-05 17:21:10 -0800106 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 Kennedy233a0b12018-01-29 20:30:24 +0000114 public abstract LoadedApk getPackageInfoNoCheck(ApplicationInfo ai,
Andrii Kulian88e05cb2017-12-05 17:21:10 -0800115 CompatibilityInfo compatInfo);
Andrii Kulian446e8242017-10-26 15:17:29 -0700116
117 /** Deliver app configuration change notification. */
118 public abstract void handleConfigurationChanged(Configuration config);
Andrii Kulian88e05cb2017-12-05 17:21:10 -0800119
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 Leed946f862018-01-16 15:59:47 -0800125
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 Kulian446e8242017-10-26 15:17:29 -0700132}