1/*
2 * Copyright (C) 2006 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
17package android.app;
18
19import android.content.ComponentName;
20import android.content.Intent;
21import android.content.IIntentReceiver;
22import android.content.pm.ActivityInfo;
23import android.content.pm.ApplicationInfo;
24import android.content.pm.ProviderInfo;
25import android.content.pm.ServiceInfo;
26import android.content.res.CompatibilityInfo;
27import android.content.res.Configuration;
28import android.net.Uri;
29import android.os.Bundle;
30import android.os.Debug;
31import android.os.ParcelFileDescriptor;
32import android.os.PersistableBundle;
33import android.os.RemoteException;
34import android.os.IBinder;
35import android.os.IInterface;
36import com.android.internal.app.IVoiceInteractor;
37import com.android.internal.content.ReferrerIntent;
38
39import java.io.FileDescriptor;
40import java.util.List;
41import java.util.Map;
42
43/**
44 * System private API for communicating with the application.  This is given to
45 * the activity manager by an application  when it starts up, for the activity
46 * manager to tell the application about things it needs to do.
47 *
48 * {@hide}
49 */
50public interface IApplicationThread extends IInterface {
51    void schedulePauseActivity(IBinder token, boolean finished, boolean userLeaving,
52            int configChanges, boolean dontReport) throws RemoteException;
53    void scheduleStopActivity(IBinder token, boolean showWindow,
54            int configChanges) throws RemoteException;
55    void scheduleWindowVisibility(IBinder token, boolean showWindow) throws RemoteException;
56    void scheduleSleeping(IBinder token, boolean sleeping) throws RemoteException;
57    void scheduleResumeActivity(IBinder token, int procState, boolean isForward, Bundle resumeArgs)
58            throws RemoteException;
59    void scheduleSendResult(IBinder token, List<ResultInfo> results) throws RemoteException;
60    void scheduleLaunchActivity(Intent intent, IBinder token, int ident,
61            ActivityInfo info, Configuration curConfig, Configuration overrideConfig,
62            CompatibilityInfo compatInfo, String referrer, IVoiceInteractor voiceInteractor,
63            int procState, Bundle state, PersistableBundle persistentState,
64            List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents,
65            boolean notResumed, boolean isForward, ProfilerInfo profilerInfo) throws RemoteException;
66    void scheduleRelaunchActivity(IBinder token, List<ResultInfo> pendingResults,
67            List<ReferrerIntent> pendingNewIntents, int configChanges, boolean notResumed,
68            Configuration config, Configuration overrideConfig, boolean preserveWindow)
69            throws RemoteException;
70    void scheduleNewIntent(
71            List<ReferrerIntent> intent, IBinder token, boolean andPause) throws RemoteException;
72    void scheduleDestroyActivity(IBinder token, boolean finished,
73            int configChanges) throws RemoteException;
74    void scheduleReceiver(Intent intent, ActivityInfo info, CompatibilityInfo compatInfo,
75            int resultCode, String data, Bundle extras, boolean sync,
76            int sendingUser, int processState) throws RemoteException;
77    static final int BACKUP_MODE_INCREMENTAL = 0;
78    static final int BACKUP_MODE_FULL = 1;
79    static final int BACKUP_MODE_RESTORE = 2;
80    static final int BACKUP_MODE_RESTORE_FULL = 3;
81    void scheduleCreateBackupAgent(ApplicationInfo app, CompatibilityInfo compatInfo,
82            int backupMode) throws RemoteException;
83    void scheduleDestroyBackupAgent(ApplicationInfo app, CompatibilityInfo compatInfo)
84            throws RemoteException;
85    void scheduleCreateService(IBinder token, ServiceInfo info,
86            CompatibilityInfo compatInfo, int processState) throws RemoteException;
87    void scheduleBindService(IBinder token,
88            Intent intent, boolean rebind, int processState) throws RemoteException;
89    void scheduleUnbindService(IBinder token,
90            Intent intent) throws RemoteException;
91    void scheduleServiceArgs(IBinder token, boolean taskRemoved, int startId,
92            int flags, Intent args) throws RemoteException;
93    void scheduleStopService(IBinder token) throws RemoteException;
94    static final int DEBUG_OFF = 0;
95    static final int DEBUG_ON = 1;
96    static final int DEBUG_WAIT = 2;
97    void bindApplication(String packageName, ApplicationInfo info, List<ProviderInfo> providers,
98            ComponentName testName, ProfilerInfo profilerInfo, Bundle testArguments,
99            IInstrumentationWatcher testWatcher, IUiAutomationConnection uiAutomationConnection,
100            int debugMode, boolean enableBinderTracking, boolean trackAllocation,
101            boolean restrictedBackupMode, boolean persistent, Configuration config,
102            CompatibilityInfo compatInfo, Map<String, IBinder> services, Bundle coreSettings)
103            throws RemoteException;
104    void scheduleExit() throws RemoteException;
105    void scheduleSuicide() throws RemoteException;
106    void scheduleConfigurationChanged(Configuration config) throws RemoteException;
107    void updateTimeZone() throws RemoteException;
108    void clearDnsCache() throws RemoteException;
109    void setHttpProxy(String proxy, String port, String exclList,
110            Uri pacFileUrl) throws RemoteException;
111    void processInBackground() throws RemoteException;
112    void dumpService(FileDescriptor fd, IBinder servicetoken, String[] args)
113            throws RemoteException;
114    void dumpProvider(FileDescriptor fd, IBinder servicetoken, String[] args)
115            throws RemoteException;
116    void scheduleRegisteredReceiver(IIntentReceiver receiver, Intent intent,
117            int resultCode, String data, Bundle extras, boolean ordered,
118            boolean sticky, int sendingUser, int processState) throws RemoteException;
119    void scheduleLowMemory() throws RemoteException;
120    void scheduleActivityConfigurationChanged(IBinder token, Configuration overrideConfig,
121            boolean reportToActivity) throws RemoteException;
122    void profilerControl(boolean start, ProfilerInfo profilerInfo, int profileType)
123            throws RemoteException;
124    void dumpHeap(boolean managed, String path, ParcelFileDescriptor fd)
125            throws RemoteException;
126    void setSchedulingGroup(int group) throws RemoteException;
127    // the package has been removed, clean up internal references
128    static final int PACKAGE_REMOVED = 0;
129    static final int EXTERNAL_STORAGE_UNAVAILABLE = 1;
130    // the package is being modified in-place, don't kill it and retain references to it
131    static final int PACKAGE_REMOVED_DONT_KILL = 2;
132    // a previously removed package was replaced with a new version [eg. upgrade, split added, ...]
133    static final int PACKAGE_REPLACED = 3;
134    void dispatchPackageBroadcast(int cmd, String[] packages) throws RemoteException;
135    void scheduleCrash(String msg) throws RemoteException;
136    void dumpActivity(FileDescriptor fd, IBinder servicetoken, String prefix, String[] args)
137            throws RemoteException;
138    void setCoreSettings(Bundle coreSettings) throws RemoteException;
139    void updatePackageCompatibilityInfo(String pkg, CompatibilityInfo info) throws RemoteException;
140    void scheduleTrimMemory(int level) throws RemoteException;
141    void dumpMemInfo(FileDescriptor fd, Debug.MemoryInfo mem, boolean checkin, boolean dumpInfo,
142            boolean dumpDalvik, boolean dumpSummaryOnly, boolean dumpUnreachable,
143            String[] args) throws RemoteException;
144    void dumpGfxInfo(FileDescriptor fd, String[] args) throws RemoteException;
145    void dumpDbInfo(FileDescriptor fd, String[] args) throws RemoteException;
146    void unstableProviderDied(IBinder provider) throws RemoteException;
147    void requestAssistContextExtras(IBinder activityToken, IBinder requestToken, int requestType,
148            int sessionId) throws RemoteException;
149    void scheduleTranslucentConversionComplete(IBinder token, boolean timeout)
150            throws RemoteException;
151    void scheduleOnNewActivityOptions(IBinder token, ActivityOptions options)
152            throws RemoteException;
153    void setProcessState(int state) throws RemoteException;
154    void scheduleInstallProvider(ProviderInfo provider) throws RemoteException;
155    void updateTimePrefs(boolean is24Hour) throws RemoteException;
156    void scheduleCancelVisibleBehind(IBinder token) throws RemoteException;
157    void scheduleBackgroundVisibleBehindChanged(IBinder token, boolean enabled) throws RemoteException;
158    void scheduleEnterAnimationComplete(IBinder token) throws RemoteException;
159    void notifyCleartextNetwork(byte[] firstPacket) throws RemoteException;
160    void startBinderTracking() throws RemoteException;
161    void stopBinderTrackingAndDump(FileDescriptor fd) throws RemoteException;
162    void scheduleMultiWindowModeChanged(IBinder token, boolean isInMultiWindowMode) throws RemoteException;
163    void schedulePictureInPictureModeChanged(IBinder token, boolean isInPictureInPictureMode) throws RemoteException;
164    void scheduleLocalVoiceInteractionStarted(IBinder token, IVoiceInteractor voiceInteractor) throws RemoteException;
165
166    String descriptor = "android.app.IApplicationThread";
167
168    int SCHEDULE_PAUSE_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION;
169    int SCHEDULE_STOP_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+2;
170    int SCHEDULE_WINDOW_VISIBILITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+3;
171    int SCHEDULE_RESUME_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+4;
172    int SCHEDULE_SEND_RESULT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+5;
173    int SCHEDULE_LAUNCH_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+6;
174    int SCHEDULE_NEW_INTENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+7;
175    int SCHEDULE_FINISH_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+8;
176    int SCHEDULE_RECEIVER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+9;
177    int SCHEDULE_CREATE_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+10;
178    int SCHEDULE_STOP_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+11;
179    int BIND_APPLICATION_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+12;
180    int SCHEDULE_EXIT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+13;
181
182    int SCHEDULE_CONFIGURATION_CHANGED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+15;
183    int SCHEDULE_SERVICE_ARGS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+16;
184    int UPDATE_TIME_ZONE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+17;
185    int PROCESS_IN_BACKGROUND_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+18;
186    int SCHEDULE_BIND_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+19;
187    int SCHEDULE_UNBIND_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+20;
188    int DUMP_SERVICE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+21;
189    int SCHEDULE_REGISTERED_RECEIVER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+22;
190    int SCHEDULE_LOW_MEMORY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+23;
191    int SCHEDULE_ACTIVITY_CONFIGURATION_CHANGED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+24;
192    int SCHEDULE_RELAUNCH_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+25;
193    int SCHEDULE_SLEEPING_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+26;
194    int PROFILER_CONTROL_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+27;
195    int SET_SCHEDULING_GROUP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+28;
196    int SCHEDULE_CREATE_BACKUP_AGENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+29;
197    int SCHEDULE_DESTROY_BACKUP_AGENT_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+30;
198    int SCHEDULE_ON_NEW_ACTIVITY_OPTIONS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+31;
199    int SCHEDULE_SUICIDE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+32;
200    int DISPATCH_PACKAGE_BROADCAST_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+33;
201    int SCHEDULE_CRASH_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+34;
202    int DUMP_HEAP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+35;
203    int DUMP_ACTIVITY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+36;
204    int CLEAR_DNS_CACHE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+37;
205    int SET_HTTP_PROXY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+38;
206    int SET_CORE_SETTINGS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+39;
207    int UPDATE_PACKAGE_COMPATIBILITY_INFO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+40;
208    int SCHEDULE_TRIM_MEMORY_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+41;
209    int DUMP_MEM_INFO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+42;
210    int DUMP_GFX_INFO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+43;
211    int DUMP_PROVIDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+44;
212    int DUMP_DB_INFO_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+45;
213    int UNSTABLE_PROVIDER_DIED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+46;
214    int REQUEST_ASSIST_CONTEXT_EXTRAS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+47;
215    int SCHEDULE_TRANSLUCENT_CONVERSION_COMPLETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+48;
216    int SET_PROCESS_STATE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+49;
217    int SCHEDULE_INSTALL_PROVIDER_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+50;
218    int UPDATE_TIME_PREFS_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+51;
219    int CANCEL_VISIBLE_BEHIND_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+52;
220    int BACKGROUND_VISIBLE_BEHIND_CHANGED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+53;
221    int ENTER_ANIMATION_COMPLETE_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+54;
222    int NOTIFY_CLEARTEXT_NETWORK_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+55;
223    int START_BINDER_TRACKING_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+56;
224    int STOP_BINDER_TRACKING_AND_DUMP_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+57;
225    int SCHEDULE_MULTI_WINDOW_CHANGED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+58;
226    int SCHEDULE_PICTURE_IN_PICTURE_CHANGED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+59;
227    int SCHEDULE_LOCAL_VOICE_INTERACTION_STARTED_TRANSACTION = IBinder.FIRST_CALL_TRANSACTION+60;
228}
229