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