xref: /aosp_15_r20/frameworks/native/libs/binder/aidl/android/os/IServiceManager.aidl (revision 38e8c45f13ce32b0dcecb25141ffecaf386fa17f)
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 
17 package android.os;
18 
19 import android.os.IClientCallback;
20 import android.os.IServiceCallback;
21 import android.os.Service;
22 import android.os.ServiceDebugInfo;
23 import android.os.ConnectionInfo;
24 
25 /**
26  * Basic interface for finding and publishing system services.
27  *
28  * You likely want to use android.os.ServiceManager in Java or
29  * android::IServiceManager in C++ in order to use this interface.
30  *
31  * @hide
32  */
33 interface IServiceManager {
34     /*
35      * Must update values in IServiceManager.h
36      */
37     /* Allows services to dump sections according to priorities. */
38     const int DUMP_FLAG_PRIORITY_CRITICAL = 1 << 0;
39     const int DUMP_FLAG_PRIORITY_HIGH = 1 << 1;
40     const int DUMP_FLAG_PRIORITY_NORMAL = 1 << 2;
41     /**
42      * Services are by default registered with a DEFAULT dump priority. DEFAULT priority has the
43      * same priority as NORMAL priority but the services are not called with dump priority
44      * arguments.
45      */
46     const int DUMP_FLAG_PRIORITY_DEFAULT = 1 << 3;
47 
48     const int DUMP_FLAG_PRIORITY_ALL =
49              DUMP_FLAG_PRIORITY_CRITICAL | DUMP_FLAG_PRIORITY_HIGH
50              | DUMP_FLAG_PRIORITY_NORMAL | DUMP_FLAG_PRIORITY_DEFAULT;
51 
52     const int FLAG_IS_LAZY_SERVICE = 1 << 30;
53 
54     /* Allows services to dump sections in protobuf format. */
55     const int DUMP_FLAG_PROTO = 1 << 4;
56 
57     /**
58      * Retrieve an existing service called @a name from the
59      * service manager.
60      *
61      * This is the same as checkService (returns immediately) but
62      * exists for legacy purposes.
63      *
64      * Returns null if the service does not exist.
65      *
66      * @deprecated TODO(b/355394904): Use getService2 instead. This does not return metadata
67      * that is included in ServiceWithMetadata
68      */
69     @UnsupportedAppUsage
getService(@tf8InCpp String name)70     @nullable IBinder getService(@utf8InCpp String name);
71 
72     /**
73      * Retrieve an existing service called @a name from the
74      * service manager.
75      *
76      * This is the same as checkService (returns immediately) but
77      * exists for legacy purposes.
78      *
79      * Returns an enum Service that can be of different types. The
80      * enum value is null if the service does not exist.
81      */
getService2(@tf8InCpp String name)82     Service getService2(@utf8InCpp String name);
83 
84     /**
85      * Retrieve an existing service called @a name from the service
86      * manager. Non-blocking. Returns null if the service does not
87      * exist.
88      */
89     @UnsupportedAppUsage
checkService(@tf8InCpp String name)90     Service checkService(@utf8InCpp String name);
91 
92     /**
93      * Place a new @a service called @a name into the service
94      * manager.
95      */
addService(@tf8InCpp String name, IBinder service, boolean allowIsolated, int dumpPriority)96     void addService(@utf8InCpp String name, IBinder service,
97         boolean allowIsolated, int dumpPriority);
98 
99     /**
100      * Return a list of all currently running services.
101      */
listServices(int dumpPriority)102     @utf8InCpp String[] listServices(int dumpPriority);
103 
104     /**
105      * Request a callback when a service is registered.
106      */
registerForNotifications(@tf8InCpp String name, IServiceCallback callback)107     void registerForNotifications(@utf8InCpp String name, IServiceCallback callback);
108 
109     /**
110      * Unregisters all requests for notifications for a specific callback.
111      */
unregisterForNotifications(@tf8InCpp String name, IServiceCallback callback)112     void unregisterForNotifications(@utf8InCpp String name, IServiceCallback callback);
113 
114     /**
115      * Returns whether a given interface is declared on the device, even if it
116      * is not started yet. For instance, this could be a service declared in the VINTF
117      * manifest.
118      */
isDeclared(@tf8InCpp String name)119     boolean isDeclared(@utf8InCpp String name);
120 
121     /**
122      * Returns all declared instances for a particular interface.
123      *
124      * For instance, if 'android.foo.IFoo/foo' is declared, and 'android.foo.IFoo' is
125      * passed here, then ["foo"] would be returned.
126      */
getDeclaredInstances(@tf8InCpp String iface)127     @utf8InCpp String[] getDeclaredInstances(@utf8InCpp String iface);
128 
129     /**
130      * If updatable-via-apex, returns the APEX via which this is updated.
131      */
updatableViaApex(@tf8InCpp String name)132     @nullable @utf8InCpp String updatableViaApex(@utf8InCpp String name);
133 
134     /**
135      * Returns all instances which are updatable via the APEX. Instance names are fully qualified
136      * like `pack.age.IFoo/default`.
137      */
getUpdatableNames(@tf8InCpp String apexName)138     @utf8InCpp String[] getUpdatableNames(@utf8InCpp String apexName);
139 
140     /**
141      * If connection info is available for the given instance, returns the ConnectionInfo
142      */
getConnectionInfo(@tf8InCpp String name)143     @nullable ConnectionInfo getConnectionInfo(@utf8InCpp String name);
144 
145     /**
146      * Request a callback when the number of clients of the service changes.
147      * Used by LazyServiceRegistrar to dynamically stop services that have no clients.
148      */
registerClientCallback(@tf8InCpp String name, IBinder service, IClientCallback callback)149     void registerClientCallback(@utf8InCpp String name, IBinder service, IClientCallback callback);
150 
151     /**
152      * Attempt to unregister and remove a service. Will fail if the service is still in use.
153      */
tryUnregisterService(@tf8InCpp String name, IBinder service)154     void tryUnregisterService(@utf8InCpp String name, IBinder service);
155 
156     /**
157      * Get debug information for all currently registered services.
158      */
getServiceDebugInfo()159     ServiceDebugInfo[] getServiceDebugInfo();
160 }
161