1282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski/* 2282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Copyright (C) 2009 The Android Open Source Project 3282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * 4282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Licensed under the Apache License, Version 2.0 (the "License"); 5282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * you may not use this file except in compliance with the License. 6282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * You may obtain a copy of the License at 7282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * 8282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * http://www.apache.org/licenses/LICENSE-2.0 9282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * 10282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Unless required by applicable law or agreed to in writing, software 11282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * distributed under the License is distributed on an "AS IS" BASIS, 12282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * See the License for the specific language governing permissions and 14282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * limitations under the License. 15282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski */ 16282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski 17282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskipackage android.os; 18282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski 19282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskiimport java.util.Map; 20282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski 21282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinskipublic final class ServiceManager { 22282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski 23282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski /** 24282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Returns a reference to a service with the given name. 25282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * 26282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * @param name the name of the service to get 27282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * @return a reference to the service, or <code>null</code> if the service doesn't exist 28282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski */ 29282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski public static IBinder getService(String name) { 30282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski return null; 31282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski } 32282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski 33282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski /** 34f666c0e2eaceb265069a77c520e84c1a08f08ae4Jerome Gaillard * Is not supposed to return null, but that is fine for layoutlib. 35f666c0e2eaceb265069a77c520e84c1a08f08ae4Jerome Gaillard */ 36f666c0e2eaceb265069a77c520e84c1a08f08ae4Jerome Gaillard public static IBinder getServiceOrThrow(String name) throws ServiceNotFoundException { 37f149ca784dd09bd97bd479ae254935ff3edaa617Jerome Gaillard throw new ServiceNotFoundException(name); 38f666c0e2eaceb265069a77c520e84c1a08f08ae4Jerome Gaillard } 39f666c0e2eaceb265069a77c520e84c1a08f08ae4Jerome Gaillard 40f666c0e2eaceb265069a77c520e84c1a08f08ae4Jerome Gaillard /** 41282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Place a new @a service called @a name into the service 42282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * manager. 43282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * 44282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * @param name the name of the new service 45282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * @param service the service object 46282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski */ 47282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski public static void addService(String name, IBinder service) { 48282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski // pass 49282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski } 50282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski 51282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski /** 52282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Retrieve an existing service called @a name from the 53282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * service manager. Non-blocking. 54282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski */ 55282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski public static IBinder checkService(String name) { 56282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski return null; 57282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski } 58282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski 59282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski /** 60282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * Return a list of all currently running services. 619ccebbfc370b24bfc4bba1ed65f254b2ed9d4e07Umair Khan * @return an array of all currently running services, or <code>null</code> in 629ccebbfc370b24bfc4bba1ed65f254b2ed9d4e07Umair Khan * case of an exception 63282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski */ 649ccebbfc370b24bfc4bba1ed65f254b2ed9d4e07Umair Khan public static String[] listServices() { 65282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski // actual implementation returns null sometimes, so it's ok 66282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski // to return null instead of an empty list. 67282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski return null; 68282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski } 69282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski 70282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski /** 71282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * This is only intended to be called when the process is first being brought 72282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * up and bound by the activity manager. There is only one thread in the process 73282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * at that time, so no locking is done. 74282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * 75282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * @param cache the cache of service references 76282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski * @hide 77282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski */ 78282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski public static void initServiceCache(Map<String, IBinder> cache) { 79282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski // pass 80282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski } 81e3607d2cc7296568fa4f56b537529da70cb09188Jerome Gaillard 82e3607d2cc7296568fa4f56b537529da70cb09188Jerome Gaillard /** 83e3607d2cc7296568fa4f56b537529da70cb09188Jerome Gaillard * Exception thrown when no service published for given name. This might be 84e3607d2cc7296568fa4f56b537529da70cb09188Jerome Gaillard * thrown early during boot before certain services have published 85e3607d2cc7296568fa4f56b537529da70cb09188Jerome Gaillard * themselves. 86e3607d2cc7296568fa4f56b537529da70cb09188Jerome Gaillard * 87e3607d2cc7296568fa4f56b537529da70cb09188Jerome Gaillard * @hide 88e3607d2cc7296568fa4f56b537529da70cb09188Jerome Gaillard */ 89e3607d2cc7296568fa4f56b537529da70cb09188Jerome Gaillard public static class ServiceNotFoundException extends Exception { 90e3607d2cc7296568fa4f56b537529da70cb09188Jerome Gaillard // identical to the original implementation 91e3607d2cc7296568fa4f56b537529da70cb09188Jerome Gaillard public ServiceNotFoundException(String name) { 92e3607d2cc7296568fa4f56b537529da70cb09188Jerome Gaillard super("No service published for: " + name); 93e3607d2cc7296568fa4f56b537529da70cb09188Jerome Gaillard } 94e3607d2cc7296568fa4f56b537529da70cb09188Jerome Gaillard } 95282e181b58cf72b6ca770dc7ca5f91f135444502Adam Lesinski} 96