• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /*
2   * Copyright (C) 2009 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 java.util.Map;
20  
21  public final class ServiceManager {
22  
23      /**
24       * Returns a reference to a service with the given name.
25       *
26       * @param name the name of the service to get
27       * @return a reference to the service, or <code>null</code> if the service doesn't exist
28       */
getService(String name)29      public static IBinder getService(String name) {
30          return null;
31      }
32  
33      /**
34       * Is not supposed to return null, but that is fine for layoutlib.
35       */
getServiceOrThrow(String name)36      public static IBinder getServiceOrThrow(String name) throws ServiceNotFoundException {
37          throw new ServiceNotFoundException(name);
38      }
39  
40      /**
41       * Place a new @a service called @a name into the service
42       * manager.
43       *
44       * @param name the name of the new service
45       * @param service the service object
46       */
addService(String name, IBinder service)47      public static void addService(String name, IBinder service) {
48          // pass
49      }
50  
51      /**
52       * Retrieve an existing service called @a name from the
53       * service manager.  Non-blocking.
54       */
checkService(String name)55      public static IBinder checkService(String name) {
56          return null;
57      }
58  
59      /**
60       * Return a list of all currently running services.
61       * @return an array of all currently running services, or <code>null</code> in
62       * case of an exception
63       */
listServices()64      public static String[] listServices() {
65          // actual implementation returns null sometimes, so it's ok
66          // to return null instead of an empty list.
67          return null;
68      }
69  
70      /**
71       * This is only intended to be called when the process is first being brought
72       * up and bound by the activity manager. There is only one thread in the process
73       * at that time, so no locking is done.
74       *
75       * @param cache the cache of service references
76       * @hide
77       */
initServiceCache(Map<String, IBinder> cache)78      public static void initServiceCache(Map<String, IBinder> cache) {
79          // pass
80      }
81  
82      /**
83       * Exception thrown when no service published for given name. This might be
84       * thrown early during boot before certain services have published
85       * themselves.
86       *
87       * @hide
88       */
89      public static class ServiceNotFoundException extends Exception {
90          // identical to the original implementation
ServiceNotFoundException(String name)91          public ServiceNotFoundException(String name) {
92              super("No service published for: " + name);
93          }
94      }
95  }
96