blob: 29cb3c1f131b66482e756c666de03ba518435090 [file] [log] [blame]
Jeff Brown6e539312015-02-24 18:53:21 -08001/*
2 * Copyright (C) 2015 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
Jeff Brown6e539312015-02-24 18:53:21 -080019import android.accounts.AccountManager;
20import android.accounts.IAccountManager;
Makoto Onukid67070e2018-03-30 12:39:14 -070021import android.app.ContextImpl.ServiceInitializationState;
Jeff Brown6e539312015-02-24 18:53:21 -080022import android.app.admin.DevicePolicyManager;
Jeff Sharkey49ca5292016-05-10 12:54:45 -060023import android.app.admin.IDevicePolicyManager;
Winson Chung3fb0f252019-01-08 17:41:55 -080024import android.app.contentsuggestions.ContentSuggestionsManager;
25import android.app.contentsuggestions.IContentSuggestionsManager;
Jeff Brown6e539312015-02-24 18:53:21 -080026import android.app.job.IJobScheduler;
27import android.app.job.JobScheduler;
Sunny Goyal54e91342018-11-14 11:59:02 -080028import android.app.prediction.AppPredictionManager;
Hai Zhanga4959e52019-03-06 12:21:07 -080029import android.app.role.RoleControllerManager;
Hai Zhang4ef21d02018-11-09 14:43:51 -080030import android.app.role.RoleManager;
Jason Monk8f5f7ff2017-10-17 14:12:42 -040031import android.app.slice.SliceManager;
Neil Fullerfeeee682018-05-30 14:35:24 +010032import android.app.timedetector.TimeDetector;
Neil Fuller328532a2017-03-16 18:32:21 +000033import android.app.timezone.RulesManager;
Jeff Brown6e539312015-02-24 18:53:21 -080034import android.app.trust.TrustManager;
Jeff Sharkeye8cece92017-01-04 11:33:33 -070035import android.app.usage.IStorageStatsManager;
Jeff Brown6e539312015-02-24 18:53:21 -080036import android.app.usage.IUsageStatsManager;
Zoltan Szatmary-Ban9c5dfa52015-02-23 17:20:20 +000037import android.app.usage.NetworkStatsManager;
Jeff Sharkeye8cece92017-01-04 11:33:33 -070038import android.app.usage.StorageStatsManager;
Jeff Brown6e539312015-02-24 18:53:21 -080039import android.app.usage.UsageStatsManager;
40import android.appwidget.AppWidgetManager;
41import android.bluetooth.BluetoothManager;
Eugene Susla6ed45d82017-01-22 13:52:51 -080042import android.companion.CompanionDeviceManager;
43import android.companion.ICompanionDeviceManager;
Jeff Brown6e539312015-02-24 18:53:21 -080044import android.content.ClipboardManager;
Felipe Leme326f15a2019-02-19 09:42:24 -080045import android.content.ContentCaptureOptions;
Jeff Brown6e539312015-02-24 18:53:21 -080046import android.content.Context;
47import android.content.IRestrictionsManager;
48import android.content.RestrictionsManager;
Hyunyoung Song880a9512018-12-20 11:24:48 -080049import android.content.om.IOverlayManager;
50import android.content.om.OverlayManager;
Tony Makb0d22622018-01-18 12:49:49 +000051import android.content.pm.CrossProfileApps;
52import android.content.pm.ICrossProfileApps;
Svet Ganovd8eb8b22019-04-05 18:52:08 -070053import android.content.pm.IPackageManager;
Makoto Onuki6f7362d92016-03-04 13:39:41 -080054import android.content.pm.IShortcutService;
Jeff Brown6e539312015-02-24 18:53:21 -080055import android.content.pm.LauncherApps;
Svet Ganovec7daa52017-06-30 12:02:59 -070056import android.content.pm.PackageManager;
Makoto Onuki6f7362d92016-03-04 13:39:41 -080057import android.content.pm.ShortcutManager;
Jeff Brown6e539312015-02-24 18:53:21 -080058import android.content.res.Resources;
Richard Uhlerb29f1452018-09-12 16:38:15 +010059import android.content.rollback.IRollbackManager;
60import android.content.rollback.RollbackManager;
Kenny Rootf74bfde2018-01-18 15:42:48 -080061import android.debug.AdbManager;
62import android.debug.IAdbManager;
Jeff Brown6e539312015-02-24 18:53:21 -080063import android.hardware.ConsumerIrManager;
64import android.hardware.ISerialManager;
65import android.hardware.SensorManager;
Chad Brubaker90f391f2018-10-19 10:26:19 -070066import android.hardware.SensorPrivacyManager;
Jeff Brown6e539312015-02-24 18:53:21 -080067import android.hardware.SerialManager;
68import android.hardware.SystemSensorManager;
Kevin Chyn05c21502018-09-18 13:07:19 -070069import android.hardware.biometrics.BiometricManager;
70import android.hardware.biometrics.IBiometricService;
Jeff Brown6e539312015-02-24 18:53:21 -080071import android.hardware.camera2.CameraManager;
Christine Franks39b03112018-07-03 14:46:07 -070072import android.hardware.display.ColorDisplayManager;
Jeff Brown6e539312015-02-24 18:53:21 -080073import android.hardware.display.DisplayManager;
Gilad Brettercb51b8b2018-03-22 17:04:51 +020074import android.hardware.face.FaceManager;
75import android.hardware.face.IFaceService;
Jeff Sharkey49ca5292016-05-10 12:54:45 -060076import android.hardware.fingerprint.FingerprintManager;
77import android.hardware.fingerprint.IFingerprintService;
Jeff Brown6e539312015-02-24 18:53:21 -080078import android.hardware.hdmi.HdmiControlManager;
79import android.hardware.hdmi.IHdmiControlService;
80import android.hardware.input.InputManager;
Kevin Chyn51676d22018-11-05 18:00:43 -080081import android.hardware.iris.IIrisService;
Felipe Lemee348dc32018-11-05 12:35:29 -080082import android.hardware.iris.IrisManager;
Peng Xu9ff7d222016-02-11 13:02:05 -080083import android.hardware.location.ContextHubManager;
Jeff Sharkey49ca5292016-05-10 12:54:45 -060084import android.hardware.radio.RadioManager;
Jeff Brown6e539312015-02-24 18:53:21 -080085import android.hardware.usb.IUsbManager;
86import android.hardware.usb.UsbManager;
87import android.location.CountryDetector;
88import android.location.ICountryDetector;
89import android.location.ILocationManager;
90import android.location.LocationManager;
91import android.media.AudioManager;
92import android.media.MediaRouter;
93import android.media.midi.IMidiManager;
94import android.media.midi.MidiManager;
95import android.media.projection.MediaProjectionManager;
96import android.media.session.MediaSessionManager;
Arunesh Mishraa772e5f2016-01-25 10:33:11 -080097import android.media.soundtrigger.SoundTriggerManager;
Jeff Brown6e539312015-02-24 18:53:21 -080098import android.media.tv.ITvInputManager;
99import android.media.tv.TvInputManager;
100import android.net.ConnectivityManager;
Paul Stewartbf8cbb052016-03-17 10:11:54 -0700101import android.net.ConnectivityThread;
Jeff Brown6e539312015-02-24 18:53:21 -0800102import android.net.EthernetManager;
103import android.net.IConnectivityManager;
104import android.net.IEthernetManager;
Nathan Harold28084d82017-03-01 18:55:06 -0800105import android.net.IIpSecService;
Jeff Brown6e539312015-02-24 18:53:21 -0800106import android.net.INetworkPolicyManager;
Benedict Wong99a48412018-11-09 14:45:34 -0800107import android.net.ITestNetworkManager;
Nathan Harold28084d82017-03-01 18:55:06 -0800108import android.net.IpSecManager;
Jeff Brown6e539312015-02-24 18:53:21 -0800109import android.net.NetworkPolicyManager;
110import android.net.NetworkScoreManager;
Ricky Wai1a6e6672017-10-27 14:46:01 +0100111import android.net.NetworkWatchlistManager;
Benedict Wong99a48412018-11-09 14:45:34 -0800112import android.net.TestNetworkManager;
Robert Quattlebaum87a71042017-05-15 15:45:20 -0700113import android.net.lowpan.ILowpanManager;
114import android.net.lowpan.LowpanManager;
Etan Cohen17ba4722017-08-21 10:52:17 -0700115import android.net.nsd.INsdManager;
116import android.net.nsd.NsdManager;
Jeff Brown6e539312015-02-24 18:53:21 -0800117import android.net.wifi.IWifiManager;
118import android.net.wifi.IWifiScanner;
119import android.net.wifi.RttManager;
120import android.net.wifi.WifiManager;
121import android.net.wifi.WifiScanner;
Etan Cohen04133272016-10-26 11:22:06 -0700122import android.net.wifi.aware.IWifiAwareManager;
123import android.net.wifi.aware.WifiAwareManager;
Jeff Brown6e539312015-02-24 18:53:21 -0800124import android.net.wifi.p2p.IWifiP2pManager;
125import android.net.wifi.p2p.WifiP2pManager;
Etan Cohen17ba4722017-08-21 10:52:17 -0700126import android.net.wifi.rtt.IWifiRttManager;
127import android.net.wifi.rtt.WifiRttManager;
Jeff Brown6e539312015-02-24 18:53:21 -0800128import android.nfc.NfcManager;
129import android.os.BatteryManager;
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600130import android.os.BatteryStats;
Nandana Duttd11850c2018-12-12 17:26:57 +0000131import android.os.BugreportManager;
Jeff Sharkey351c2c22017-03-18 16:48:02 -0600132import android.os.Build;
Philip P. Moltmannf80809f2018-04-04 11:20:44 -0700133import android.os.DeviceIdleManager;
Jeff Brown6e539312015-02-24 18:53:21 -0800134import android.os.DropBoxManager;
Polina Bondarenko965ecbb2015-11-13 15:34:28 +0100135import android.os.HardwarePropertiesManager;
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600136import android.os.IBatteryPropertiesRegistrar;
Jeff Brown6e539312015-02-24 18:53:21 -0800137import android.os.IBinder;
Philip P. Moltmannf80809f2018-04-04 11:20:44 -0700138import android.os.IDeviceIdleController;
Nandana Duttd11850c2018-12-12 17:26:57 +0000139import android.os.IDumpstate;
Polina Bondarenkof8754ac2016-02-12 20:38:23 +0100140import android.os.IHardwarePropertiesManager;
Jeff Brown6e539312015-02-24 18:53:21 -0800141import android.os.IPowerManager;
Tao Baoe8a403d2015-12-31 07:44:55 -0800142import android.os.IRecoverySystem;
Tao Bao07342dc2017-01-24 15:08:21 -0800143import android.os.ISystemUpdateManager;
Jeff Brown6e539312015-02-24 18:53:21 -0800144import android.os.IUserManager;
Joe Onorato1754d742016-11-21 17:51:35 -0800145import android.os.IncidentManager;
Jeff Brown6e539312015-02-24 18:53:21 -0800146import android.os.PowerManager;
Tao Baoe8a403d2015-12-31 07:44:55 -0800147import android.os.RecoverySystem;
Benedict Wong99a48412018-11-09 14:45:34 -0800148import android.os.RemoteException;
Jeff Brown6e539312015-02-24 18:53:21 -0800149import android.os.ServiceManager;
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600150import android.os.ServiceManager.ServiceNotFoundException;
Tao Bao07342dc2017-01-24 15:08:21 -0800151import android.os.SystemUpdateManager;
Jeff Brown6e539312015-02-24 18:53:21 -0800152import android.os.SystemVibrator;
153import android.os.UserHandle;
154import android.os.UserManager;
155import android.os.Vibrator;
Joe Onorato713fec82016-03-04 10:34:02 -0800156import android.os.health.SystemHealthManager;
Po-Chien Hsueh4e908c22019-03-07 11:57:17 +0800157import android.os.image.DynamicSystemManager;
158import android.os.image.IDynamicSystemService;
Jeff Brown6e539312015-02-24 18:53:21 -0800159import android.os.storage.StorageManager;
Chen Xu8eb62f92019-10-13 17:30:32 -0700160import android.telephony.TelephonyRegistryManager;
Philip P. Moltmannbc054d82018-12-21 09:41:58 -0800161import android.permission.PermissionControllerManager;
Philip P. Moltmann039678e2018-09-18 13:04:38 -0700162import android.permission.PermissionManager;
Jeff Brown6e539312015-02-24 18:53:21 -0800163import android.print.IPrintManager;
164import android.print.PrintManager;
Andrew Scull3b8b46f2017-02-13 18:12:15 +0000165import android.service.oemlock.IOemLockService;
166import android.service.oemlock.OemLockManager;
Jeff Brown6e539312015-02-24 18:53:21 -0800167import android.service.persistentdata.IPersistentDataBlockService;
168import android.service.persistentdata.PersistentDataBlockManager;
Zak Cohen56345f42017-01-26 13:54:28 -0800169import android.service.vr.IVrManager;
Jeff Brown6e539312015-02-24 18:53:21 -0800170import android.telecom.TelecomManager;
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800171import android.telephony.CarrierConfigManager;
Jeff Brown6e539312015-02-24 18:53:21 -0800172import android.telephony.SubscriptionManager;
173import android.telephony.TelephonyManager;
Holly Jiuyu Sun5c110242017-12-21 18:44:59 -0800174import android.telephony.euicc.EuiccCardManager;
Neil Fuller009e77a2017-05-04 16:53:41 +0100175import android.telephony.euicc.EuiccManager;
Robert Benea1901a5b2018-05-15 16:36:07 -0700176import android.util.ArrayMap;
Jeff Brown6e539312015-02-24 18:53:21 -0800177import android.util.Log;
178import android.view.ContextThemeWrapper;
179import android.view.LayoutInflater;
Jeff Brown6e539312015-02-24 18:53:21 -0800180import android.view.WindowManager;
181import android.view.WindowManagerImpl;
182import android.view.accessibility.AccessibilityManager;
183import android.view.accessibility.CaptioningManager;
Neil Fuller009e77a2017-05-04 16:53:41 +0100184import android.view.autofill.AutofillManager;
185import android.view.autofill.IAutoFillManager;
Felipe Leme749b8892018-12-03 16:30:30 -0800186import android.view.contentcapture.ContentCaptureManager;
187import android.view.contentcapture.IContentCaptureManager;
Jeff Brown6e539312015-02-24 18:53:21 -0800188import android.view.inputmethod.InputMethodManager;
Abodunrinwa Tokif001fef2017-01-04 23:51:42 +0000189import android.view.textclassifier.TextClassificationManager;
Jeff Brown6e539312015-02-24 18:53:21 -0800190import android.view.textservice.TextServicesManager;
191
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600192import com.android.internal.app.IAppOpsService;
193import com.android.internal.app.IBatteryStats;
194import com.android.internal.app.ISoundTriggerService;
195import com.android.internal.appwidget.IAppWidgetService;
Ricky Wai1a6e6672017-10-27 14:46:01 +0100196import com.android.internal.net.INetworkWatchlistManager;
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600197import com.android.internal.os.IDropBoxManagerService;
198import com.android.internal.policy.PhoneLayoutInflater;
199
Robert Benea1901a5b2018-05-15 16:36:07 -0700200import java.util.Map;
Jeff Brown6e539312015-02-24 18:53:21 -0800201
202/**
203 * Manages all of the system services that can be returned by {@link Context#getSystemService}.
204 * Used by {@link ContextImpl}.
205 */
206final class SystemServiceRegistry {
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600207 private static final String TAG = "SystemServiceRegistry";
208
Jeff Brown6e539312015-02-24 18:53:21 -0800209 // Service registry information.
210 // This information is never changed once static initialization has completed.
Robert Benea1901a5b2018-05-15 16:36:07 -0700211 private static final Map<Class<?>, String> SYSTEM_SERVICE_NAMES =
212 new ArrayMap<Class<?>, String>();
213 private static final Map<String, ServiceFetcher<?>> SYSTEM_SERVICE_FETCHERS =
214 new ArrayMap<String, ServiceFetcher<?>>();
Jeff Brown6e539312015-02-24 18:53:21 -0800215 private static int sServiceCacheSize;
216
217 // Not instantiable.
218 private SystemServiceRegistry() { }
219
220 static {
Felipe Lemeecb08be2018-11-27 15:48:47 -0800221 //CHECKSTYLE:OFF IndentationCheck
Jeff Brown6e539312015-02-24 18:53:21 -0800222 registerService(Context.ACCESSIBILITY_SERVICE, AccessibilityManager.class,
223 new CachedServiceFetcher<AccessibilityManager>() {
224 @Override
225 public AccessibilityManager createService(ContextImpl ctx) {
226 return AccessibilityManager.getInstance(ctx);
227 }});
228
229 registerService(Context.CAPTIONING_SERVICE, CaptioningManager.class,
230 new CachedServiceFetcher<CaptioningManager>() {
231 @Override
232 public CaptioningManager createService(ContextImpl ctx) {
233 return new CaptioningManager(ctx);
234 }});
235
236 registerService(Context.ACCOUNT_SERVICE, AccountManager.class,
237 new CachedServiceFetcher<AccountManager>() {
238 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600239 public AccountManager createService(ContextImpl ctx) throws ServiceNotFoundException {
240 IBinder b = ServiceManager.getServiceOrThrow(Context.ACCOUNT_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800241 IAccountManager service = IAccountManager.Stub.asInterface(b);
242 return new AccountManager(ctx, service);
243 }});
244
245 registerService(Context.ACTIVITY_SERVICE, ActivityManager.class,
246 new CachedServiceFetcher<ActivityManager>() {
247 @Override
248 public ActivityManager createService(ContextImpl ctx) {
249 return new ActivityManager(ctx.getOuterContext(), ctx.mMainThread.getHandler());
250 }});
251
Wale Ogunwale65ebd952018-04-25 15:41:44 -0700252 registerService(Context.ACTIVITY_TASK_SERVICE, ActivityTaskManager.class,
253 new CachedServiceFetcher<ActivityTaskManager>() {
254 @Override
255 public ActivityTaskManager createService(ContextImpl ctx) {
256 return new ActivityTaskManager(
257 ctx.getOuterContext(), ctx.mMainThread.getHandler());
258 }});
259
Wale Ogunwale6d50dcc2018-07-21 23:00:40 -0700260 registerService(Context.URI_GRANTS_SERVICE, UriGrantsManager.class,
261 new CachedServiceFetcher<UriGrantsManager>() {
262 @Override
263 public UriGrantsManager createService(ContextImpl ctx) {
264 return new UriGrantsManager(
265 ctx.getOuterContext(), ctx.mMainThread.getHandler());
266 }});
267
Jeff Brown6e539312015-02-24 18:53:21 -0800268 registerService(Context.ALARM_SERVICE, AlarmManager.class,
269 new CachedServiceFetcher<AlarmManager>() {
270 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600271 public AlarmManager createService(ContextImpl ctx) throws ServiceNotFoundException {
272 IBinder b = ServiceManager.getServiceOrThrow(Context.ALARM_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800273 IAlarmManager service = IAlarmManager.Stub.asInterface(b);
274 return new AlarmManager(service, ctx);
275 }});
276
277 registerService(Context.AUDIO_SERVICE, AudioManager.class,
278 new CachedServiceFetcher<AudioManager>() {
279 @Override
280 public AudioManager createService(ContextImpl ctx) {
281 return new AudioManager(ctx);
282 }});
283
284 registerService(Context.MEDIA_ROUTER_SERVICE, MediaRouter.class,
285 new CachedServiceFetcher<MediaRouter>() {
286 @Override
287 public MediaRouter createService(ContextImpl ctx) {
288 return new MediaRouter(ctx);
289 }});
290
291 registerService(Context.BLUETOOTH_SERVICE, BluetoothManager.class,
292 new CachedServiceFetcher<BluetoothManager>() {
293 @Override
294 public BluetoothManager createService(ContextImpl ctx) {
295 return new BluetoothManager(ctx);
296 }});
297
298 registerService(Context.HDMI_CONTROL_SERVICE, HdmiControlManager.class,
299 new StaticServiceFetcher<HdmiControlManager>() {
300 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600301 public HdmiControlManager createService() throws ServiceNotFoundException {
302 IBinder b = ServiceManager.getServiceOrThrow(Context.HDMI_CONTROL_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800303 return new HdmiControlManager(IHdmiControlService.Stub.asInterface(b));
304 }});
305
Abodunrinwa Toki8158af52016-11-23 20:41:09 +0000306 registerService(Context.TEXT_CLASSIFICATION_SERVICE, TextClassificationManager.class,
Abodunrinwa Tokif001fef2017-01-04 23:51:42 +0000307 new CachedServiceFetcher<TextClassificationManager>() {
Abodunrinwa Toki8158af52016-11-23 20:41:09 +0000308 @Override
Abodunrinwa Tokif001fef2017-01-04 23:51:42 +0000309 public TextClassificationManager createService(ContextImpl ctx) {
310 return new TextClassificationManager(ctx);
Abodunrinwa Toki8158af52016-11-23 20:41:09 +0000311 }});
312
Jeff Brown6e539312015-02-24 18:53:21 -0800313 registerService(Context.CLIPBOARD_SERVICE, ClipboardManager.class,
314 new CachedServiceFetcher<ClipboardManager>() {
315 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600316 public ClipboardManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Jeff Brown6e539312015-02-24 18:53:21 -0800317 return new ClipboardManager(ctx.getOuterContext(),
318 ctx.mMainThread.getHandler());
319 }});
320
321 // The clipboard service moved to a new package. If someone asks for the old
322 // interface by class then we want to redirect over to the new interface instead
323 // (which extends it).
324 SYSTEM_SERVICE_NAMES.put(android.text.ClipboardManager.class, Context.CLIPBOARD_SERVICE);
325
326 registerService(Context.CONNECTIVITY_SERVICE, ConnectivityManager.class,
Lorenzo Colitticf959772016-02-29 16:07:37 +0900327 new StaticApplicationContextServiceFetcher<ConnectivityManager>() {
Jeff Brown6e539312015-02-24 18:53:21 -0800328 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600329 public ConnectivityManager createService(Context context) throws ServiceNotFoundException {
330 IBinder b = ServiceManager.getServiceOrThrow(Context.CONNECTIVITY_SERVICE);
Lorenzo Colittiffc42b02015-07-29 11:41:21 +0900331 IConnectivityManager service = IConnectivityManager.Stub.asInterface(b);
332 return new ConnectivityManager(context, service);
Jeff Brown6e539312015-02-24 18:53:21 -0800333 }});
334
Remi NGUYEN VANf9a8c2e2019-02-13 18:28:35 +0900335 registerService(Context.NETD_SERVICE, IBinder.class, new StaticServiceFetcher<IBinder>() {
Remi NGUYEN VAN31935982019-01-28 11:40:08 +0900336 @Override
Remi NGUYEN VANf9a8c2e2019-02-13 18:28:35 +0900337 public IBinder createService() throws ServiceNotFoundException {
338 return ServiceManager.getServiceOrThrow(Context.NETD_SERVICE);
Remi NGUYEN VAN31935982019-01-28 11:40:08 +0900339 }
340 });
341
Nathan Harold28084d82017-03-01 18:55:06 -0800342 registerService(Context.IPSEC_SERVICE, IpSecManager.class,
Nathan Harold592dadb2018-03-15 18:06:06 -0700343 new CachedServiceFetcher<IpSecManager>() {
Nathan Harold28084d82017-03-01 18:55:06 -0800344 @Override
Nathan Harold592dadb2018-03-15 18:06:06 -0700345 public IpSecManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Nathan Harold28084d82017-03-01 18:55:06 -0800346 IBinder b = ServiceManager.getService(Context.IPSEC_SERVICE);
347 IIpSecService service = IIpSecService.Stub.asInterface(b);
Nathan Harold592dadb2018-03-15 18:06:06 -0700348 return new IpSecManager(ctx, service);
Nathan Harold28084d82017-03-01 18:55:06 -0800349 }});
350
Benedict Wong99a48412018-11-09 14:45:34 -0800351 registerService(
352 Context.TEST_NETWORK_SERVICE,
353 TestNetworkManager.class,
354 new StaticApplicationContextServiceFetcher<TestNetworkManager>() {
355 @Override
356 public TestNetworkManager createService(Context context)
357 throws ServiceNotFoundException {
358 IBinder csBinder =
359 ServiceManager.getServiceOrThrow(Context.CONNECTIVITY_SERVICE);
360 IConnectivityManager csMgr =
361 IConnectivityManager.Stub.asInterface(csBinder);
362
363 final IBinder tnBinder;
364 try {
365 tnBinder = csMgr.startOrGetTestNetworkService();
366 } catch (RemoteException e) {
367 throw new ServiceNotFoundException(Context.TEST_NETWORK_SERVICE);
368 }
369 ITestNetworkManager tnMgr = ITestNetworkManager.Stub.asInterface(tnBinder);
Benedict Wongb4e98f32019-03-12 21:54:16 -0700370 return new TestNetworkManager(tnMgr);
Benedict Wong99a48412018-11-09 14:45:34 -0800371 }
372 });
373
Jeff Brown6e539312015-02-24 18:53:21 -0800374 registerService(Context.COUNTRY_DETECTOR, CountryDetector.class,
375 new StaticServiceFetcher<CountryDetector>() {
376 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600377 public CountryDetector createService() throws ServiceNotFoundException {
378 IBinder b = ServiceManager.getServiceOrThrow(Context.COUNTRY_DETECTOR);
Jeff Brown6e539312015-02-24 18:53:21 -0800379 return new CountryDetector(ICountryDetector.Stub.asInterface(b));
380 }});
381
382 registerService(Context.DEVICE_POLICY_SERVICE, DevicePolicyManager.class,
383 new CachedServiceFetcher<DevicePolicyManager>() {
384 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600385 public DevicePolicyManager createService(ContextImpl ctx) throws ServiceNotFoundException {
386 IBinder b = ServiceManager.getServiceOrThrow(Context.DEVICE_POLICY_SERVICE);
387 return new DevicePolicyManager(ctx, IDevicePolicyManager.Stub.asInterface(b));
Jeff Brown6e539312015-02-24 18:53:21 -0800388 }});
389
390 registerService(Context.DOWNLOAD_SERVICE, DownloadManager.class,
391 new CachedServiceFetcher<DownloadManager>() {
392 @Override
393 public DownloadManager createService(ContextImpl ctx) {
Jeff Sharkey60cfad82016-01-05 17:30:57 -0700394 return new DownloadManager(ctx);
Jeff Brown6e539312015-02-24 18:53:21 -0800395 }});
396
397 registerService(Context.BATTERY_SERVICE, BatteryManager.class,
Yifan Hongb0f13522017-10-31 15:48:50 -0700398 new CachedServiceFetcher<BatteryManager>() {
Jeff Brown6e539312015-02-24 18:53:21 -0800399 @Override
Yifan Hongb0f13522017-10-31 15:48:50 -0700400 public BatteryManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600401 IBatteryStats stats = IBatteryStats.Stub.asInterface(
402 ServiceManager.getServiceOrThrow(BatteryStats.SERVICE_NAME));
403 IBatteryPropertiesRegistrar registrar = IBatteryPropertiesRegistrar.Stub
404 .asInterface(ServiceManager.getServiceOrThrow("batteryproperties"));
Yifan Hongb0f13522017-10-31 15:48:50 -0700405 return new BatteryManager(ctx, stats, registrar);
Jeff Brown6e539312015-02-24 18:53:21 -0800406 }});
407
408 registerService(Context.NFC_SERVICE, NfcManager.class,
409 new CachedServiceFetcher<NfcManager>() {
410 @Override
411 public NfcManager createService(ContextImpl ctx) {
412 return new NfcManager(ctx);
413 }});
414
415 registerService(Context.DROPBOX_SERVICE, DropBoxManager.class,
Jeff Sharkeyb8e8a912016-03-09 16:27:40 -0700416 new CachedServiceFetcher<DropBoxManager>() {
Jeff Brown6e539312015-02-24 18:53:21 -0800417 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600418 public DropBoxManager createService(ContextImpl ctx) throws ServiceNotFoundException {
419 IBinder b = ServiceManager.getServiceOrThrow(Context.DROPBOX_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800420 IDropBoxManagerService service = IDropBoxManagerService.Stub.asInterface(b);
Jeff Sharkeyb8e8a912016-03-09 16:27:40 -0700421 return new DropBoxManager(ctx, service);
Jeff Brown6e539312015-02-24 18:53:21 -0800422 }});
423
424 registerService(Context.INPUT_SERVICE, InputManager.class,
425 new StaticServiceFetcher<InputManager>() {
426 @Override
427 public InputManager createService() {
428 return InputManager.getInstance();
429 }});
430
431 registerService(Context.DISPLAY_SERVICE, DisplayManager.class,
432 new CachedServiceFetcher<DisplayManager>() {
433 @Override
434 public DisplayManager createService(ContextImpl ctx) {
435 return new DisplayManager(ctx.getOuterContext());
436 }});
437
Christine Franks39b03112018-07-03 14:46:07 -0700438 registerService(Context.COLOR_DISPLAY_SERVICE, ColorDisplayManager.class,
439 new CachedServiceFetcher<ColorDisplayManager>() {
440 @Override
441 public ColorDisplayManager createService(ContextImpl ctx) {
442 return new ColorDisplayManager();
443 }
444 });
445
Yohei Yukawa4052a10f2018-10-15 15:35:55 +0800446 // InputMethodManager has its own cache strategy based on display id to support apps that
447 // still assume InputMethodManager is a per-process singleton and it's safe to directly
448 // access internal fields via reflection. Hence directly use ServiceFetcher instead of
449 // StaticServiceFetcher/CachedServiceFetcher.
Jeff Brown6e539312015-02-24 18:53:21 -0800450 registerService(Context.INPUT_METHOD_SERVICE, InputMethodManager.class,
Yohei Yukawa4052a10f2018-10-15 15:35:55 +0800451 new ServiceFetcher<InputMethodManager>() {
Jeff Brown6e539312015-02-24 18:53:21 -0800452 @Override
Yohei Yukawa4052a10f2018-10-15 15:35:55 +0800453 public InputMethodManager getService(ContextImpl ctx) {
454 return InputMethodManager.forContext(ctx.getOuterContext());
Jeff Brown6e539312015-02-24 18:53:21 -0800455 }});
456
457 registerService(Context.TEXT_SERVICES_MANAGER_SERVICE, TextServicesManager.class,
Yohei Yukawa9f141ee2019-01-18 09:17:16 -0800458 new CachedServiceFetcher<TextServicesManager>() {
Jeff Brown6e539312015-02-24 18:53:21 -0800459 @Override
Yohei Yukawa9f141ee2019-01-18 09:17:16 -0800460 public TextServicesManager createService(ContextImpl ctx)
461 throws ServiceNotFoundException {
462 return TextServicesManager.createInstance(ctx);
Jeff Brown6e539312015-02-24 18:53:21 -0800463 }});
464
465 registerService(Context.KEYGUARD_SERVICE, KeyguardManager.class,
Nancy Zheng43f166d2016-11-18 18:15:09 -0800466 new CachedServiceFetcher<KeyguardManager>() {
Jeff Brown6e539312015-02-24 18:53:21 -0800467 @Override
Nancy Zheng40cd8e42016-11-21 12:58:16 -0800468 public KeyguardManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Nancy Zheng43f166d2016-11-18 18:15:09 -0800469 return new KeyguardManager(ctx);
Jeff Brown6e539312015-02-24 18:53:21 -0800470 }});
471
472 registerService(Context.LAYOUT_INFLATER_SERVICE, LayoutInflater.class,
473 new CachedServiceFetcher<LayoutInflater>() {
474 @Override
475 public LayoutInflater createService(ContextImpl ctx) {
476 return new PhoneLayoutInflater(ctx.getOuterContext());
477 }});
478
479 registerService(Context.LOCATION_SERVICE, LocationManager.class,
480 new CachedServiceFetcher<LocationManager>() {
481 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600482 public LocationManager createService(ContextImpl ctx) throws ServiceNotFoundException {
483 IBinder b = ServiceManager.getServiceOrThrow(Context.LOCATION_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800484 return new LocationManager(ctx, ILocationManager.Stub.asInterface(b));
485 }});
486
487 registerService(Context.NETWORK_POLICY_SERVICE, NetworkPolicyManager.class,
Svet Ganov16a16892015-04-16 10:32:04 -0700488 new CachedServiceFetcher<NetworkPolicyManager>() {
Jeff Brown6e539312015-02-24 18:53:21 -0800489 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600490 public NetworkPolicyManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Svet Ganov16a16892015-04-16 10:32:04 -0700491 return new NetworkPolicyManager(ctx, INetworkPolicyManager.Stub.asInterface(
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600492 ServiceManager.getServiceOrThrow(Context.NETWORK_POLICY_SERVICE)));
Jeff Brown6e539312015-02-24 18:53:21 -0800493 }});
494
495 registerService(Context.NOTIFICATION_SERVICE, NotificationManager.class,
496 new CachedServiceFetcher<NotificationManager>() {
497 @Override
498 public NotificationManager createService(ContextImpl ctx) {
499 final Context outerContext = ctx.getOuterContext();
500 return new NotificationManager(
501 new ContextThemeWrapper(outerContext,
502 Resources.selectSystemTheme(0,
503 outerContext.getApplicationInfo().targetSdkVersion,
504 com.android.internal.R.style.Theme_Dialog,
505 com.android.internal.R.style.Theme_Holo_Dialog,
506 com.android.internal.R.style.Theme_DeviceDefault_Dialog,
507 com.android.internal.R.style.Theme_DeviceDefault_Light_Dialog)),
508 ctx.mMainThread.getHandler());
509 }});
510
511 registerService(Context.NSD_SERVICE, NsdManager.class,
512 new CachedServiceFetcher<NsdManager>() {
513 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600514 public NsdManager createService(ContextImpl ctx) throws ServiceNotFoundException {
515 IBinder b = ServiceManager.getServiceOrThrow(Context.NSD_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800516 INsdManager service = INsdManager.Stub.asInterface(b);
517 return new NsdManager(ctx.getOuterContext(), service);
518 }});
519
520 registerService(Context.POWER_SERVICE, PowerManager.class,
521 new CachedServiceFetcher<PowerManager>() {
522 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600523 public PowerManager createService(ContextImpl ctx) throws ServiceNotFoundException {
524 IBinder b = ServiceManager.getServiceOrThrow(Context.POWER_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800525 IPowerManager service = IPowerManager.Stub.asInterface(b);
Jeff Brown6e539312015-02-24 18:53:21 -0800526 return new PowerManager(ctx.getOuterContext(),
527 service, ctx.mMainThread.getHandler());
528 }});
529
Tao Baoe8a403d2015-12-31 07:44:55 -0800530 registerService(Context.RECOVERY_SERVICE, RecoverySystem.class,
531 new CachedServiceFetcher<RecoverySystem>() {
532 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600533 public RecoverySystem createService(ContextImpl ctx) throws ServiceNotFoundException {
534 IBinder b = ServiceManager.getServiceOrThrow(Context.RECOVERY_SERVICE);
Tao Baoe8a403d2015-12-31 07:44:55 -0800535 IRecoverySystem service = IRecoverySystem.Stub.asInterface(b);
Tao Baoe8a403d2015-12-31 07:44:55 -0800536 return new RecoverySystem(service);
537 }});
538
Jeff Brown6e539312015-02-24 18:53:21 -0800539 registerService(Context.SEARCH_SERVICE, SearchManager.class,
540 new CachedServiceFetcher<SearchManager>() {
541 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600542 public SearchManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Jeff Brown6e539312015-02-24 18:53:21 -0800543 return new SearchManager(ctx.getOuterContext(),
544 ctx.mMainThread.getHandler());
545 }});
546
547 registerService(Context.SENSOR_SERVICE, SensorManager.class,
548 new CachedServiceFetcher<SensorManager>() {
549 @Override
550 public SensorManager createService(ContextImpl ctx) {
551 return new SystemSensorManager(ctx.getOuterContext(),
552 ctx.mMainThread.getHandler().getLooper());
553 }});
554
Chad Brubaker90f391f2018-10-19 10:26:19 -0700555 registerService(Context.SENSOR_PRIVACY_SERVICE, SensorPrivacyManager.class,
556 new CachedServiceFetcher<SensorPrivacyManager>() {
557 @Override
558 public SensorPrivacyManager createService(ContextImpl ctx) {
559 return SensorPrivacyManager.getInstance(ctx);
560 }});
561
David Chenadaf8b32017-11-03 15:42:08 -0700562 registerService(Context.STATS_MANAGER, StatsManager.class,
Jeff Sharkey6b649252018-04-16 09:50:22 -0600563 new CachedServiceFetcher<StatsManager>() {
564 @Override
565 public StatsManager createService(ContextImpl ctx) {
566 return new StatsManager(ctx.getOuterContext());
567 }});
David Chenadaf8b32017-11-03 15:42:08 -0700568
Jeff Brown6e539312015-02-24 18:53:21 -0800569 registerService(Context.STATUS_BAR_SERVICE, StatusBarManager.class,
570 new CachedServiceFetcher<StatusBarManager>() {
571 @Override
572 public StatusBarManager createService(ContextImpl ctx) {
573 return new StatusBarManager(ctx.getOuterContext());
574 }});
575
576 registerService(Context.STORAGE_SERVICE, StorageManager.class,
577 new CachedServiceFetcher<StorageManager>() {
578 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600579 public StorageManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Jeff Sharkey48877892015-03-18 11:27:19 -0700580 return new StorageManager(ctx, ctx.mMainThread.getHandler().getLooper());
Jeff Brown6e539312015-02-24 18:53:21 -0800581 }});
582
Jeff Sharkeye8cece92017-01-04 11:33:33 -0700583 registerService(Context.STORAGE_STATS_SERVICE, StorageStatsManager.class,
584 new CachedServiceFetcher<StorageStatsManager>() {
585 @Override
586 public StorageStatsManager createService(ContextImpl ctx) throws ServiceNotFoundException {
587 IStorageStatsManager service = IStorageStatsManager.Stub.asInterface(
588 ServiceManager.getServiceOrThrow(Context.STORAGE_STATS_SERVICE));
589 return new StorageStatsManager(ctx, service);
590 }});
591
Tao Bao07342dc2017-01-24 15:08:21 -0800592 registerService(Context.SYSTEM_UPDATE_SERVICE, SystemUpdateManager.class,
593 new CachedServiceFetcher<SystemUpdateManager>() {
594 @Override
595 public SystemUpdateManager createService(ContextImpl ctx)
596 throws ServiceNotFoundException {
597 IBinder b = ServiceManager.getServiceOrThrow(
598 Context.SYSTEM_UPDATE_SERVICE);
599 ISystemUpdateManager service = ISystemUpdateManager.Stub.asInterface(b);
600 return new SystemUpdateManager(service);
601 }});
602
Jeff Brown6e539312015-02-24 18:53:21 -0800603 registerService(Context.TELEPHONY_SERVICE, TelephonyManager.class,
604 new CachedServiceFetcher<TelephonyManager>() {
605 @Override
606 public TelephonyManager createService(ContextImpl ctx) {
607 return new TelephonyManager(ctx.getOuterContext());
608 }});
609
Chen Xu1f1c25e2019-09-15 18:28:21 -0700610 registerService(Context.TELEPHONY_REGISTRY_SERVICE, TelephonyRegistryManager.class,
611 new CachedServiceFetcher<TelephonyRegistryManager>() {
612 @Override
613 public TelephonyRegistryManager createService(ContextImpl ctx) {
Chen Xu8eb62f92019-10-13 17:30:32 -0700614 return new TelephonyRegistryManager(ctx);
Chen Xu1f1c25e2019-09-15 18:28:21 -0700615 }});
616
Jeff Brown6e539312015-02-24 18:53:21 -0800617 registerService(Context.TELEPHONY_SUBSCRIPTION_SERVICE, SubscriptionManager.class,
618 new CachedServiceFetcher<SubscriptionManager>() {
619 @Override
Jeff Sharkey717f52f2018-01-04 16:04:11 -0700620 public SubscriptionManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Jeff Brown6e539312015-02-24 18:53:21 -0800621 return new SubscriptionManager(ctx.getOuterContext());
622 }});
623
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800624 registerService(Context.CARRIER_CONFIG_SERVICE, CarrierConfigManager.class,
625 new CachedServiceFetcher<CarrierConfigManager>() {
626 @Override
627 public CarrierConfigManager createService(ContextImpl ctx) {
Malcolm Chend1272d12018-02-28 15:20:45 -0800628 return new CarrierConfigManager(ctx.getOuterContext());
Jonathan Basseri9a1c9b62015-02-25 13:01:52 -0800629 }});
630
Jeff Brown6e539312015-02-24 18:53:21 -0800631 registerService(Context.TELECOM_SERVICE, TelecomManager.class,
632 new CachedServiceFetcher<TelecomManager>() {
633 @Override
634 public TelecomManager createService(ContextImpl ctx) {
635 return new TelecomManager(ctx.getOuterContext());
636 }});
637
Jeff Davidson35cda392017-02-27 09:46:00 -0800638 registerService(Context.EUICC_SERVICE, EuiccManager.class,
639 new CachedServiceFetcher<EuiccManager>() {
640 @Override
641 public EuiccManager createService(ContextImpl ctx) {
642 return new EuiccManager(ctx.getOuterContext());
643 }});
644
Holly Jiuyu Sun5c110242017-12-21 18:44:59 -0800645 registerService(Context.EUICC_CARD_SERVICE, EuiccCardManager.class,
646 new CachedServiceFetcher<EuiccCardManager>() {
647 @Override
648 public EuiccCardManager createService(ContextImpl ctx) {
649 return new EuiccCardManager(ctx.getOuterContext());
650 }});
651
Jeff Brown6e539312015-02-24 18:53:21 -0800652 registerService(Context.UI_MODE_SERVICE, UiModeManager.class,
653 new CachedServiceFetcher<UiModeManager>() {
654 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600655 public UiModeManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Tyler Gunnf05f2c22019-09-30 15:12:24 -0700656 return new UiModeManager(ctx.getOuterContext());
Jeff Brown6e539312015-02-24 18:53:21 -0800657 }});
658
659 registerService(Context.USB_SERVICE, UsbManager.class,
660 new CachedServiceFetcher<UsbManager>() {
661 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600662 public UsbManager createService(ContextImpl ctx) throws ServiceNotFoundException {
663 IBinder b = ServiceManager.getServiceOrThrow(Context.USB_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800664 return new UsbManager(ctx, IUsbManager.Stub.asInterface(b));
665 }});
666
Kenny Rootf74bfde2018-01-18 15:42:48 -0800667 registerService(Context.ADB_SERVICE, AdbManager.class,
668 new CachedServiceFetcher<AdbManager>() {
669 @Override
670 public AdbManager createService(ContextImpl ctx)
671 throws ServiceNotFoundException {
672 IBinder b = ServiceManager.getServiceOrThrow(Context.ADB_SERVICE);
673 return new AdbManager(ctx, IAdbManager.Stub.asInterface(b));
674 }});
675
Jeff Brown6e539312015-02-24 18:53:21 -0800676 registerService(Context.SERIAL_SERVICE, SerialManager.class,
677 new CachedServiceFetcher<SerialManager>() {
678 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600679 public SerialManager createService(ContextImpl ctx) throws ServiceNotFoundException {
680 IBinder b = ServiceManager.getServiceOrThrow(Context.SERIAL_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800681 return new SerialManager(ctx, ISerialManager.Stub.asInterface(b));
682 }});
683
684 registerService(Context.VIBRATOR_SERVICE, Vibrator.class,
685 new CachedServiceFetcher<Vibrator>() {
686 @Override
687 public Vibrator createService(ContextImpl ctx) {
688 return new SystemVibrator(ctx);
689 }});
690
691 registerService(Context.WALLPAPER_SERVICE, WallpaperManager.class,
692 new CachedServiceFetcher<WallpaperManager>() {
693 @Override
Svet Ganov8f90bcc2017-12-22 23:29:24 -0800694 public WallpaperManager createService(ContextImpl ctx)
695 throws ServiceNotFoundException {
696 final IBinder b;
697 if (ctx.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.P) {
698 b = ServiceManager.getServiceOrThrow(Context.WALLPAPER_SERVICE);
699 } else {
700 b = ServiceManager.getService(Context.WALLPAPER_SERVICE);
701 }
702 IWallpaperManager service = IWallpaperManager.Stub.asInterface(b);
703 return new WallpaperManager(service, ctx.getOuterContext(),
Jeff Brown6e539312015-02-24 18:53:21 -0800704 ctx.mMainThread.getHandler());
705 }});
706
Robert Quattlebaum87a71042017-05-15 15:45:20 -0700707 registerService(Context.LOWPAN_SERVICE, LowpanManager.class,
708 new CachedServiceFetcher<LowpanManager>() {
709 @Override
710 public LowpanManager createService(ContextImpl ctx) throws ServiceNotFoundException {
711 IBinder b = ServiceManager.getServiceOrThrow(Context.LOWPAN_SERVICE);
712 ILowpanManager service = ILowpanManager.Stub.asInterface(b);
713 return new LowpanManager(ctx.getOuterContext(), service,
714 ConnectivityThread.getInstanceLooper());
715 }});
716
Jeff Brown6e539312015-02-24 18:53:21 -0800717 registerService(Context.WIFI_SERVICE, WifiManager.class,
718 new CachedServiceFetcher<WifiManager>() {
719 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600720 public WifiManager createService(ContextImpl ctx) throws ServiceNotFoundException {
721 IBinder b = ServiceManager.getServiceOrThrow(Context.WIFI_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800722 IWifiManager service = IWifiManager.Stub.asInterface(b);
Paul Stewartbf8cbb052016-03-17 10:11:54 -0700723 return new WifiManager(ctx.getOuterContext(), service,
724 ConnectivityThread.getInstanceLooper());
Jeff Brown6e539312015-02-24 18:53:21 -0800725 }});
726
Jeff Brown6e539312015-02-24 18:53:21 -0800727 registerService(Context.WIFI_P2P_SERVICE, WifiP2pManager.class,
728 new StaticServiceFetcher<WifiP2pManager>() {
729 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600730 public WifiP2pManager createService() throws ServiceNotFoundException {
731 IBinder b = ServiceManager.getServiceOrThrow(Context.WIFI_P2P_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800732 IWifiP2pManager service = IWifiP2pManager.Stub.asInterface(b);
733 return new WifiP2pManager(service);
734 }});
735
Etan Cohen04133272016-10-26 11:22:06 -0700736 registerService(Context.WIFI_AWARE_SERVICE, WifiAwareManager.class,
737 new CachedServiceFetcher<WifiAwareManager>() {
Etan Cohen20d329b2015-09-29 13:49:02 -0700738 @Override
Etan Cohen04133272016-10-26 11:22:06 -0700739 public WifiAwareManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Jeff Sharkey589f3092016-11-29 12:54:39 -0700740 IBinder b = ServiceManager.getServiceOrThrow(Context.WIFI_AWARE_SERVICE);
Etan Cohen04133272016-10-26 11:22:06 -0700741 IWifiAwareManager service = IWifiAwareManager.Stub.asInterface(b);
Etan Cohen20d329b2015-09-29 13:49:02 -0700742 if (service == null) {
743 return null;
744 }
Etan Cohen04133272016-10-26 11:22:06 -0700745 return new WifiAwareManager(ctx.getOuterContext(), service);
Etan Cohen20d329b2015-09-29 13:49:02 -0700746 }});
747
Jeff Brown6e539312015-02-24 18:53:21 -0800748 registerService(Context.WIFI_SCANNING_SERVICE, WifiScanner.class,
749 new CachedServiceFetcher<WifiScanner>() {
750 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600751 public WifiScanner createService(ContextImpl ctx) throws ServiceNotFoundException {
752 IBinder b = ServiceManager.getServiceOrThrow(Context.WIFI_SCANNING_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800753 IWifiScanner service = IWifiScanner.Stub.asInterface(b);
Mitchell Wills91312c72016-04-06 17:03:35 -0700754 return new WifiScanner(ctx.getOuterContext(), service,
755 ConnectivityThread.getInstanceLooper());
Jeff Brown6e539312015-02-24 18:53:21 -0800756 }});
757
758 registerService(Context.WIFI_RTT_SERVICE, RttManager.class,
759 new CachedServiceFetcher<RttManager>() {
Etan Cohen9accbba2018-01-30 16:41:00 -0800760 @Override
761 public RttManager createService(ContextImpl ctx) throws ServiceNotFoundException {
762 IBinder b = ServiceManager.getServiceOrThrow(Context.WIFI_RTT_RANGING_SERVICE);
763 IWifiRttManager service = IWifiRttManager.Stub.asInterface(b);
764 return new RttManager(ctx.getOuterContext(),
765 new WifiRttManager(ctx.getOuterContext(), service));
766 }});
Jeff Brown6e539312015-02-24 18:53:21 -0800767
Etan Cohen46efb482017-12-07 13:50:57 -0800768 registerService(Context.WIFI_RTT_RANGING_SERVICE, WifiRttManager.class,
Etan Cohen17ba4722017-08-21 10:52:17 -0700769 new CachedServiceFetcher<WifiRttManager>() {
770 @Override
771 public WifiRttManager createService(ContextImpl ctx)
772 throws ServiceNotFoundException {
Etan Cohen46efb482017-12-07 13:50:57 -0800773 IBinder b = ServiceManager.getServiceOrThrow(
774 Context.WIFI_RTT_RANGING_SERVICE);
Etan Cohen17ba4722017-08-21 10:52:17 -0700775 IWifiRttManager service = IWifiRttManager.Stub.asInterface(b);
776 return new WifiRttManager(ctx.getOuterContext(), service);
777 }});
778
Jeff Brown6e539312015-02-24 18:53:21 -0800779 registerService(Context.ETHERNET_SERVICE, EthernetManager.class,
780 new CachedServiceFetcher<EthernetManager>() {
781 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600782 public EthernetManager createService(ContextImpl ctx) throws ServiceNotFoundException {
783 IBinder b = ServiceManager.getServiceOrThrow(Context.ETHERNET_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800784 IEthernetManager service = IEthernetManager.Stub.asInterface(b);
785 return new EthernetManager(ctx.getOuterContext(), service);
786 }});
787
788 registerService(Context.WINDOW_SERVICE, WindowManager.class,
789 new CachedServiceFetcher<WindowManager>() {
790 @Override
791 public WindowManager createService(ContextImpl ctx) {
Adam Lesinski4ece3d62016-06-16 18:05:41 -0700792 return new WindowManagerImpl(ctx);
Jeff Brown6e539312015-02-24 18:53:21 -0800793 }});
794
795 registerService(Context.USER_SERVICE, UserManager.class,
796 new CachedServiceFetcher<UserManager>() {
797 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600798 public UserManager createService(ContextImpl ctx) throws ServiceNotFoundException {
799 IBinder b = ServiceManager.getServiceOrThrow(Context.USER_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800800 IUserManager service = IUserManager.Stub.asInterface(b);
801 return new UserManager(ctx, service);
802 }});
803
804 registerService(Context.APP_OPS_SERVICE, AppOpsManager.class,
805 new CachedServiceFetcher<AppOpsManager>() {
806 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600807 public AppOpsManager createService(ContextImpl ctx) throws ServiceNotFoundException {
808 IBinder b = ServiceManager.getServiceOrThrow(Context.APP_OPS_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800809 IAppOpsService service = IAppOpsService.Stub.asInterface(b);
810 return new AppOpsManager(ctx, service);
811 }});
812
813 registerService(Context.CAMERA_SERVICE, CameraManager.class,
814 new CachedServiceFetcher<CameraManager>() {
815 @Override
816 public CameraManager createService(ContextImpl ctx) {
817 return new CameraManager(ctx);
818 }});
819
820 registerService(Context.LAUNCHER_APPS_SERVICE, LauncherApps.class,
821 new CachedServiceFetcher<LauncherApps>() {
822 @Override
823 public LauncherApps createService(ContextImpl ctx) {
Makoto Onuki5ba0d3e2016-04-11 14:03:46 -0700824 return new LauncherApps(ctx);
Jeff Brown6e539312015-02-24 18:53:21 -0800825 }});
826
827 registerService(Context.RESTRICTIONS_SERVICE, RestrictionsManager.class,
828 new CachedServiceFetcher<RestrictionsManager>() {
829 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600830 public RestrictionsManager createService(ContextImpl ctx) throws ServiceNotFoundException {
831 IBinder b = ServiceManager.getServiceOrThrow(Context.RESTRICTIONS_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800832 IRestrictionsManager service = IRestrictionsManager.Stub.asInterface(b);
833 return new RestrictionsManager(ctx, service);
834 }});
835
836 registerService(Context.PRINT_SERVICE, PrintManager.class,
837 new CachedServiceFetcher<PrintManager>() {
838 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600839 public PrintManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Svet Ganovec7daa52017-06-30 12:02:59 -0700840 IPrintManager service = null;
841 // If the feature not present, don't try to look up every time
842 if (ctx.getPackageManager().hasSystemFeature(PackageManager.FEATURE_PRINTING)) {
843 service = IPrintManager.Stub.asInterface(ServiceManager
844 .getServiceOrThrow(Context.PRINT_SERVICE));
845 }
Jeff Sharkeyad357d12018-02-02 13:25:31 -0700846 final int userId = ctx.getUserId();
847 final int appId = UserHandle.getAppId(ctx.getApplicationInfo().uid);
848 return new PrintManager(ctx.getOuterContext(), service, userId, appId);
Jeff Brown6e539312015-02-24 18:53:21 -0800849 }});
850
Eugene Susla6ed45d82017-01-22 13:52:51 -0800851 registerService(Context.COMPANION_DEVICE_SERVICE, CompanionDeviceManager.class,
852 new CachedServiceFetcher<CompanionDeviceManager>() {
Svet Ganovec7daa52017-06-30 12:02:59 -0700853 @Override
854 public CompanionDeviceManager createService(ContextImpl ctx)
855 throws ServiceNotFoundException {
856 ICompanionDeviceManager service = null;
857 // If the feature not present, don't try to look up every time
858 if (ctx.getPackageManager().hasSystemFeature(
859 PackageManager.FEATURE_COMPANION_DEVICE_SETUP)) {
860 service = ICompanionDeviceManager.Stub.asInterface(
861 ServiceManager.getServiceOrThrow(Context.COMPANION_DEVICE_SERVICE));
862 }
863 return new CompanionDeviceManager(service, ctx.getOuterContext());
864 }});
Eugene Susla6ed45d82017-01-22 13:52:51 -0800865
Jeff Brown6e539312015-02-24 18:53:21 -0800866 registerService(Context.CONSUMER_IR_SERVICE, ConsumerIrManager.class,
867 new CachedServiceFetcher<ConsumerIrManager>() {
868 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600869 public ConsumerIrManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Jeff Brown6e539312015-02-24 18:53:21 -0800870 return new ConsumerIrManager(ctx);
871 }});
872
873 registerService(Context.MEDIA_SESSION_SERVICE, MediaSessionManager.class,
874 new CachedServiceFetcher<MediaSessionManager>() {
875 @Override
876 public MediaSessionManager createService(ContextImpl ctx) {
877 return new MediaSessionManager(ctx);
878 }});
879
880 registerService(Context.TRUST_SERVICE, TrustManager.class,
881 new StaticServiceFetcher<TrustManager>() {
882 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600883 public TrustManager createService() throws ServiceNotFoundException {
884 IBinder b = ServiceManager.getServiceOrThrow(Context.TRUST_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800885 return new TrustManager(b);
886 }});
887
888 registerService(Context.FINGERPRINT_SERVICE, FingerprintManager.class,
889 new CachedServiceFetcher<FingerprintManager>() {
890 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600891 public FingerprintManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Jeff Sharkey351c2c22017-03-18 16:48:02 -0600892 final IBinder binder;
893 if (ctx.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.O) {
894 binder = ServiceManager.getServiceOrThrow(Context.FINGERPRINT_SERVICE);
895 } else {
896 binder = ServiceManager.getService(Context.FINGERPRINT_SERVICE);
897 }
Jeff Brown6e539312015-02-24 18:53:21 -0800898 IFingerprintService service = IFingerprintService.Stub.asInterface(binder);
899 return new FingerprintManager(ctx.getOuterContext(), service);
900 }});
901
Gilad Brettercb51b8b2018-03-22 17:04:51 +0200902 registerService(Context.FACE_SERVICE, FaceManager.class,
903 new CachedServiceFetcher<FaceManager>() {
904 @Override
905 public FaceManager createService(ContextImpl ctx)
906 throws ServiceNotFoundException {
907 final IBinder binder;
908 if (ctx.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.O) {
909 binder = ServiceManager.getServiceOrThrow(Context.FACE_SERVICE);
910 } else {
911 binder = ServiceManager.getService(Context.FACE_SERVICE);
912 }
913 IFaceService service = IFaceService.Stub.asInterface(binder);
914 return new FaceManager(ctx.getOuterContext(), service);
915 }
916 });
917
Kevin Chyn51676d22018-11-05 18:00:43 -0800918 registerService(Context.IRIS_SERVICE, IrisManager.class,
919 new CachedServiceFetcher<IrisManager>() {
920 @Override
921 public IrisManager createService(ContextImpl ctx)
922 throws ServiceNotFoundException {
923 final IBinder binder =
924 ServiceManager.getServiceOrThrow(Context.IRIS_SERVICE);
925 IIrisService service = IIrisService.Stub.asInterface(binder);
926 return new IrisManager(ctx.getOuterContext(), service);
927 }
928 });
929
Kevin Chyn05c21502018-09-18 13:07:19 -0700930 registerService(Context.BIOMETRIC_SERVICE, BiometricManager.class,
931 new CachedServiceFetcher<BiometricManager>() {
932 @Override
933 public BiometricManager createService(ContextImpl ctx)
934 throws ServiceNotFoundException {
Kevin Chyne739daf2018-11-06 17:11:06 -0800935 if (BiometricManager.hasBiometrics(ctx)) {
936 final IBinder binder =
937 ServiceManager.getServiceOrThrow(Context.BIOMETRIC_SERVICE);
938 final IBiometricService service =
939 IBiometricService.Stub.asInterface(binder);
940 return new BiometricManager(ctx.getOuterContext(), service);
941 } else {
942 // Allow access to the manager when service is null. This saves memory
943 // on devices without biometric hardware.
944 return new BiometricManager(ctx.getOuterContext(), null);
945 }
Kevin Chyn05c21502018-09-18 13:07:19 -0700946 }
947 });
948
Jeff Brown6e539312015-02-24 18:53:21 -0800949 registerService(Context.TV_INPUT_SERVICE, TvInputManager.class,
Jeff Sharkeyad357d12018-02-02 13:25:31 -0700950 new CachedServiceFetcher<TvInputManager>() {
Jeff Brown6e539312015-02-24 18:53:21 -0800951 @Override
Jeff Sharkeyad357d12018-02-02 13:25:31 -0700952 public TvInputManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600953 IBinder iBinder = ServiceManager.getServiceOrThrow(Context.TV_INPUT_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800954 ITvInputManager service = ITvInputManager.Stub.asInterface(iBinder);
Jeff Sharkeyad357d12018-02-02 13:25:31 -0700955 return new TvInputManager(service, ctx.getUserId());
Jeff Brown6e539312015-02-24 18:53:21 -0800956 }});
957
958 registerService(Context.NETWORK_SCORE_SERVICE, NetworkScoreManager.class,
959 new CachedServiceFetcher<NetworkScoreManager>() {
960 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600961 public NetworkScoreManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Jeff Brown6e539312015-02-24 18:53:21 -0800962 return new NetworkScoreManager(ctx);
963 }});
964
965 registerService(Context.USAGE_STATS_SERVICE, UsageStatsManager.class,
966 new CachedServiceFetcher<UsageStatsManager>() {
967 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600968 public UsageStatsManager createService(ContextImpl ctx) throws ServiceNotFoundException {
969 IBinder iBinder = ServiceManager.getServiceOrThrow(Context.USAGE_STATS_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800970 IUsageStatsManager service = IUsageStatsManager.Stub.asInterface(iBinder);
971 return new UsageStatsManager(ctx.getOuterContext(), service);
972 }});
973
Zoltan Szatmary-Ban9c5dfa52015-02-23 17:20:20 +0000974 registerService(Context.NETWORK_STATS_SERVICE, NetworkStatsManager.class,
975 new CachedServiceFetcher<NetworkStatsManager>() {
976 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600977 public NetworkStatsManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Zoltan Szatmary-Ban9c5dfa52015-02-23 17:20:20 +0000978 return new NetworkStatsManager(ctx.getOuterContext());
979 }});
980
Jeff Brown6e539312015-02-24 18:53:21 -0800981 registerService(Context.JOB_SCHEDULER_SERVICE, JobScheduler.class,
982 new StaticServiceFetcher<JobScheduler>() {
983 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600984 public JobScheduler createService() throws ServiceNotFoundException {
985 IBinder b = ServiceManager.getServiceOrThrow(Context.JOB_SCHEDULER_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800986 return new JobSchedulerImpl(IJobScheduler.Stub.asInterface(b));
987 }});
988
989 registerService(Context.PERSISTENT_DATA_BLOCK_SERVICE, PersistentDataBlockManager.class,
990 new StaticServiceFetcher<PersistentDataBlockManager>() {
991 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -0600992 public PersistentDataBlockManager createService() throws ServiceNotFoundException {
993 IBinder b = ServiceManager.getServiceOrThrow(Context.PERSISTENT_DATA_BLOCK_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -0800994 IPersistentDataBlockService persistentDataBlockService =
995 IPersistentDataBlockService.Stub.asInterface(b);
996 if (persistentDataBlockService != null) {
997 return new PersistentDataBlockManager(persistentDataBlockService);
998 } else {
999 // not supported
1000 return null;
1001 }
1002 }});
1003
Andrew Scull3b8b46f2017-02-13 18:12:15 +00001004 registerService(Context.OEM_LOCK_SERVICE, OemLockManager.class,
1005 new StaticServiceFetcher<OemLockManager>() {
1006 @Override
1007 public OemLockManager createService() throws ServiceNotFoundException {
1008 IBinder b = ServiceManager.getServiceOrThrow(Context.OEM_LOCK_SERVICE);
1009 IOemLockService oemLockService = IOemLockService.Stub.asInterface(b);
1010 if (oemLockService != null) {
1011 return new OemLockManager(oemLockService);
1012 } else {
1013 // not supported
1014 return null;
1015 }
1016 }});
1017
Jeff Brown6e539312015-02-24 18:53:21 -08001018 registerService(Context.MEDIA_PROJECTION_SERVICE, MediaProjectionManager.class,
1019 new CachedServiceFetcher<MediaProjectionManager>() {
1020 @Override
1021 public MediaProjectionManager createService(ContextImpl ctx) {
1022 return new MediaProjectionManager(ctx);
1023 }});
1024
1025 registerService(Context.APPWIDGET_SERVICE, AppWidgetManager.class,
1026 new CachedServiceFetcher<AppWidgetManager>() {
1027 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001028 public AppWidgetManager createService(ContextImpl ctx) throws ServiceNotFoundException {
1029 IBinder b = ServiceManager.getServiceOrThrow(Context.APPWIDGET_SERVICE);
Jeff Brown6e539312015-02-24 18:53:21 -08001030 return new AppWidgetManager(ctx, IAppWidgetService.Stub.asInterface(b));
1031 }});
1032
1033 registerService(Context.MIDI_SERVICE, MidiManager.class,
1034 new CachedServiceFetcher<MidiManager>() {
1035 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001036 public MidiManager createService(ContextImpl ctx) throws ServiceNotFoundException {
1037 IBinder b = ServiceManager.getServiceOrThrow(Context.MIDI_SERVICE);
Mike Lockwoode0a6ca62015-06-04 13:43:56 -07001038 return new MidiManager(IMidiManager.Stub.asInterface(b));
Jeff Brown6e539312015-02-24 18:53:21 -08001039 }});
Eric Laurent2035ac82015-03-05 15:18:44 -08001040
1041 registerService(Context.RADIO_SERVICE, RadioManager.class,
1042 new CachedServiceFetcher<RadioManager>() {
1043 @Override
Tomasz Wasilczyk347192e2017-04-04 11:13:44 -07001044 public RadioManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Eric Laurent2035ac82015-03-05 15:18:44 -08001045 return new RadioManager(ctx);
1046 }});
Arunesh Mishraa772e5f2016-01-25 10:33:11 -08001047
Polina Bondarenko965ecbb2015-11-13 15:34:28 +01001048 registerService(Context.HARDWARE_PROPERTIES_SERVICE, HardwarePropertiesManager.class,
1049 new CachedServiceFetcher<HardwarePropertiesManager>() {
1050 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001051 public HardwarePropertiesManager createService(ContextImpl ctx) throws ServiceNotFoundException {
1052 IBinder b = ServiceManager.getServiceOrThrow(Context.HARDWARE_PROPERTIES_SERVICE);
1053 IHardwarePropertiesManager service =
1054 IHardwarePropertiesManager.Stub.asInterface(b);
1055 return new HardwarePropertiesManager(ctx, service);
Polina Bondarenko965ecbb2015-11-13 15:34:28 +01001056 }});
Arunesh Mishraa772e5f2016-01-25 10:33:11 -08001057
1058 registerService(Context.SOUND_TRIGGER_SERVICE, SoundTriggerManager.class,
1059 new CachedServiceFetcher<SoundTriggerManager>() {
1060 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001061 public SoundTriggerManager createService(ContextImpl ctx) throws ServiceNotFoundException {
1062 IBinder b = ServiceManager.getServiceOrThrow(Context.SOUND_TRIGGER_SERVICE);
Arunesh Mishraa772e5f2016-01-25 10:33:11 -08001063 return new SoundTriggerManager(ctx, ISoundTriggerService.Stub.asInterface(b));
1064 }});
Makoto Onuki6f7362d92016-03-04 13:39:41 -08001065
1066 registerService(Context.SHORTCUT_SERVICE, ShortcutManager.class,
1067 new CachedServiceFetcher<ShortcutManager>() {
Makoto Onuki55046222016-03-08 10:49:47 -08001068 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001069 public ShortcutManager createService(ContextImpl ctx) throws ServiceNotFoundException {
1070 IBinder b = ServiceManager.getServiceOrThrow(Context.SHORTCUT_SERVICE);
1071 return new ShortcutManager(ctx, IShortcutService.Stub.asInterface(b));
Makoto Onuki55046222016-03-08 10:49:47 -08001072 }});
Joe Onorato713fec82016-03-04 10:34:02 -08001073
Hyunyoung Song880a9512018-12-20 11:24:48 -08001074 registerService(Context.OVERLAY_SERVICE, OverlayManager.class,
1075 new CachedServiceFetcher<OverlayManager>() {
1076 @Override
1077 public OverlayManager createService(ContextImpl ctx) throws ServiceNotFoundException {
1078 IBinder b = ServiceManager.getServiceOrThrow(Context.OVERLAY_SERVICE);
1079 return new OverlayManager(ctx, IOverlayManager.Stub.asInterface(b));
1080 }});
1081
Ricky Wai1a6e6672017-10-27 14:46:01 +01001082 registerService(Context.NETWORK_WATCHLIST_SERVICE, NetworkWatchlistManager.class,
1083 new CachedServiceFetcher<NetworkWatchlistManager>() {
1084 @Override
1085 public NetworkWatchlistManager createService(ContextImpl ctx)
1086 throws ServiceNotFoundException {
1087 IBinder b =
1088 ServiceManager.getServiceOrThrow(Context.NETWORK_WATCHLIST_SERVICE);
1089 return new NetworkWatchlistManager(ctx,
1090 INetworkWatchlistManager.Stub.asInterface(b));
1091 }});
1092
Joe Onorato713fec82016-03-04 10:34:02 -08001093 registerService(Context.SYSTEM_HEALTH_SERVICE, SystemHealthManager.class,
1094 new CachedServiceFetcher<SystemHealthManager>() {
1095 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001096 public SystemHealthManager createService(ContextImpl ctx) throws ServiceNotFoundException {
1097 IBinder b = ServiceManager.getServiceOrThrow(BatteryStats.SERVICE_NAME);
1098 return new SystemHealthManager(IBatteryStats.Stub.asInterface(b));
Joe Onorato713fec82016-03-04 10:34:02 -08001099 }});
Peng Xu9ff7d222016-02-11 13:02:05 -08001100
1101 registerService(Context.CONTEXTHUB_SERVICE, ContextHubManager.class,
1102 new CachedServiceFetcher<ContextHubManager>() {
1103 @Override
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001104 public ContextHubManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Peng Xu9ff7d222016-02-11 13:02:05 -08001105 return new ContextHubManager(ctx.getOuterContext(),
1106 ctx.mMainThread.getHandler().getLooper());
1107 }});
Joe Onorato1754d742016-11-21 17:51:35 -08001108
1109 registerService(Context.INCIDENT_SERVICE, IncidentManager.class,
1110 new CachedServiceFetcher<IncidentManager>() {
1111 @Override
1112 public IncidentManager createService(ContextImpl ctx) throws ServiceNotFoundException {
1113 return new IncidentManager(ctx);
1114 }});
Clara Bayarri04d72ab2017-01-10 09:31:51 -08001115
Nandana Duttd11850c2018-12-12 17:26:57 +00001116 registerService(Context.BUGREPORT_SERVICE, BugreportManager.class,
1117 new CachedServiceFetcher<BugreportManager>() {
1118 @Override
1119 public BugreportManager createService(ContextImpl ctx)
1120 throws ServiceNotFoundException {
1121 IBinder b = ServiceManager.getServiceOrThrow(Context.BUGREPORT_SERVICE);
1122 return new BugreportManager(ctx.getOuterContext(),
1123 IDumpstate.Stub.asInterface(b));
1124 }});
1125
Felipe Leme640f30a2017-03-06 15:44:06 -08001126 registerService(Context.AUTOFILL_MANAGER_SERVICE, AutofillManager.class,
1127 new CachedServiceFetcher<AutofillManager>() {
Felipe Leme3461d3c2017-01-19 08:54:55 -08001128 @Override
Felipe Leme640f30a2017-03-06 15:44:06 -08001129 public AutofillManager createService(ContextImpl ctx) throws ServiceNotFoundException {
Svet Ganov43574b02017-04-12 09:25:20 -07001130 // Get the services without throwing as this is an optional feature
1131 IBinder b = ServiceManager.getService(Context.AUTOFILL_MANAGER_SERVICE);
Svet Ganov782043c2017-02-11 00:52:02 +00001132 IAutoFillManager service = IAutoFillManager.Stub.asInterface(b);
Felipe Leme640f30a2017-03-06 15:44:06 -08001133 return new AutofillManager(ctx.getOuterContext(), service);
Felipe Leme3461d3c2017-01-19 08:54:55 -08001134 }});
Zak Cohen56345f42017-01-26 13:54:28 -08001135
Felipe Lemeecb08be2018-11-27 15:48:47 -08001136 registerService(Context.CONTENT_CAPTURE_MANAGER_SERVICE, ContentCaptureManager.class,
1137 new CachedServiceFetcher<ContentCaptureManager>() {
Felipe Lemee348dc32018-11-05 12:35:29 -08001138 @Override
Felipe Lemeecb08be2018-11-27 15:48:47 -08001139 public ContentCaptureManager createService(ContextImpl ctx)
Felipe Lemee348dc32018-11-05 12:35:29 -08001140 throws ServiceNotFoundException {
1141 // Get the services without throwing as this is an optional feature
Felipe Lemeecb08be2018-11-27 15:48:47 -08001142 Context outerContext = ctx.getOuterContext();
Felipe Leme326f15a2019-02-19 09:42:24 -08001143 ContentCaptureOptions options = outerContext.getContentCaptureOptions();
1144 // Options is null when the service didn't whitelist the activity or package
Felipe Lemecbf7f262019-04-17 13:57:59 -07001145 if (options != null && (options.lite || options.isWhitelisted(outerContext))) {
Felipe Lemeecb08be2018-11-27 15:48:47 -08001146 IBinder b = ServiceManager
1147 .getService(Context.CONTENT_CAPTURE_MANAGER_SERVICE);
Felipe Leme749b8892018-12-03 16:30:30 -08001148 IContentCaptureManager service = IContentCaptureManager.Stub.asInterface(b);
Felipe Leme326f15a2019-02-19 09:42:24 -08001149 // Service is null when not provided by OEM or disabled by kill-switch.
Felipe Lemed49d52c2019-02-15 09:48:20 -08001150 if (service != null) {
Felipe Leme326f15a2019-02-19 09:42:24 -08001151 return new ContentCaptureManager(outerContext, service, options);
Felipe Lemed49d52c2019-02-15 09:48:20 -08001152 }
Felipe Lemeecb08be2018-11-27 15:48:47 -08001153 }
Felipe Leme326f15a2019-02-19 09:42:24 -08001154 // When feature is disabled or app / package not whitelisted, we return a null
1155 // manager to apps so the performance impact is practically zero
Felipe Lemeecb08be2018-11-27 15:48:47 -08001156 return null;
Felipe Lemee348dc32018-11-05 12:35:29 -08001157 }});
1158
Sunny Goyal54e91342018-11-14 11:59:02 -08001159 registerService(Context.APP_PREDICTION_SERVICE, AppPredictionManager.class,
1160 new CachedServiceFetcher<AppPredictionManager>() {
1161 @Override
1162 public AppPredictionManager createService(ContextImpl ctx)
1163 throws ServiceNotFoundException {
1164 return new AppPredictionManager(ctx);
1165 }
1166 });
1167
Winson Chung3fb0f252019-01-08 17:41:55 -08001168 registerService(Context.CONTENT_SUGGESTIONS_SERVICE,
1169 ContentSuggestionsManager.class,
1170 new CachedServiceFetcher<ContentSuggestionsManager>() {
1171 @Override
1172 public ContentSuggestionsManager createService(ContextImpl ctx) {
1173 // No throw as this is an optional service
1174 IBinder b = ServiceManager.getService(
1175 Context.CONTENT_SUGGESTIONS_SERVICE);
1176 IContentSuggestionsManager service =
1177 IContentSuggestionsManager.Stub.asInterface(b);
Zak Cohen4834e9f2019-03-08 12:59:01 -08001178 return new ContentSuggestionsManager(ctx.getUserId(), service);
Winson Chung3fb0f252019-01-08 17:41:55 -08001179 }
1180 });
1181
Zak Cohen56345f42017-01-26 13:54:28 -08001182 registerService(Context.VR_SERVICE, VrManager.class, new CachedServiceFetcher<VrManager>() {
1183 @Override
1184 public VrManager createService(ContextImpl ctx) throws ServiceNotFoundException {
1185 IBinder b = ServiceManager.getServiceOrThrow(Context.VR_SERVICE);
1186 return new VrManager(IVrManager.Stub.asInterface(b));
1187 }
1188 });
Neil Fuller328532a2017-03-16 18:32:21 +00001189
1190 registerService(Context.TIME_ZONE_RULES_MANAGER_SERVICE, RulesManager.class,
1191 new CachedServiceFetcher<RulesManager>() {
1192 @Override
1193 public RulesManager createService(ContextImpl ctx) {
1194 return new RulesManager(ctx.getOuterContext());
1195 }});
Tony Mak1b708e62017-10-12 10:59:11 +01001196
1197 registerService(Context.CROSS_PROFILE_APPS_SERVICE, CrossProfileApps.class,
1198 new CachedServiceFetcher<CrossProfileApps>() {
1199 @Override
1200 public CrossProfileApps createService(ContextImpl ctx)
1201 throws ServiceNotFoundException {
1202 IBinder b = ServiceManager.getServiceOrThrow(
1203 Context.CROSS_PROFILE_APPS_SERVICE);
1204 return new CrossProfileApps(ctx.getOuterContext(),
1205 ICrossProfileApps.Stub.asInterface(b));
1206 }
1207 });
Jason Monk8f5f7ff2017-10-17 14:12:42 -04001208
1209 registerService(Context.SLICE_SERVICE, SliceManager.class,
1210 new CachedServiceFetcher<SliceManager>() {
1211 @Override
1212 public SliceManager createService(ContextImpl ctx)
1213 throws ServiceNotFoundException {
1214 return new SliceManager(ctx.getOuterContext(),
1215 ctx.mMainThread.getHandler());
1216 }
1217 });
Philip P. Moltmannf80809f2018-04-04 11:20:44 -07001218
1219 registerService(Context.DEVICE_IDLE_CONTROLLER, DeviceIdleManager.class,
1220 new CachedServiceFetcher<DeviceIdleManager>() {
1221 @Override
1222 public DeviceIdleManager createService(ContextImpl ctx)
1223 throws ServiceNotFoundException {
1224 IDeviceIdleController service = IDeviceIdleController.Stub.asInterface(
1225 ServiceManager.getServiceOrThrow(
1226 Context.DEVICE_IDLE_CONTROLLER));
1227 return new DeviceIdleManager(ctx.getOuterContext(), service);
1228 }});
Neil Fullerfeeee682018-05-30 14:35:24 +01001229
1230 registerService(Context.TIME_DETECTOR_SERVICE, TimeDetector.class,
1231 new CachedServiceFetcher<TimeDetector>() {
1232 @Override
1233 public TimeDetector createService(ContextImpl ctx)
1234 throws ServiceNotFoundException {
1235 return new TimeDetector();
1236 }});
Philip P. Moltmann039678e2018-09-18 13:04:38 -07001237
1238 registerService(Context.PERMISSION_SERVICE, PermissionManager.class,
1239 new CachedServiceFetcher<PermissionManager>() {
1240 @Override
1241 public PermissionManager createService(ContextImpl ctx) {
Svet Ganovd8eb8b22019-04-05 18:52:08 -07001242 IPackageManager packageManager = AppGlobals.getPackageManager();
1243 return new PermissionManager(ctx.getOuterContext(), packageManager);
Philip P. Moltmann039678e2018-09-18 13:04:38 -07001244 }});
Hai Zhang4ef21d02018-11-09 14:43:51 -08001245
Philip P. Moltmannbc054d82018-12-21 09:41:58 -08001246 registerService(Context.PERMISSION_CONTROLLER_SERVICE, PermissionControllerManager.class,
1247 new CachedServiceFetcher<PermissionControllerManager>() {
1248 @Override
1249 public PermissionControllerManager createService(ContextImpl ctx) {
Svet Ganovd8eb8b22019-04-05 18:52:08 -07001250 return new PermissionControllerManager(ctx.getOuterContext(),
1251 ctx.getMainThreadHandler());
Philip P. Moltmannbc054d82018-12-21 09:41:58 -08001252 }});
1253
Hai Zhang4ef21d02018-11-09 14:43:51 -08001254 registerService(Context.ROLE_SERVICE, RoleManager.class,
1255 new CachedServiceFetcher<RoleManager>() {
1256 @Override
1257 public RoleManager createService(ContextImpl ctx)
1258 throws ServiceNotFoundException {
1259 return new RoleManager(ctx.getOuterContext());
1260 }});
Richard Uhlerb29f1452018-09-12 16:38:15 +01001261
Hai Zhanga4959e52019-03-06 12:21:07 -08001262 registerService(Context.ROLE_CONTROLLER_SERVICE, RoleControllerManager.class,
1263 new CachedServiceFetcher<RoleControllerManager>() {
1264 @Override
1265 public RoleControllerManager createService(ContextImpl ctx)
1266 throws ServiceNotFoundException {
1267 return new RoleControllerManager(ctx.getOuterContext());
1268 }});
1269
Richard Uhlerb29f1452018-09-12 16:38:15 +01001270 registerService(Context.ROLLBACK_SERVICE, RollbackManager.class,
1271 new CachedServiceFetcher<RollbackManager>() {
1272 @Override
1273 public RollbackManager createService(ContextImpl ctx)
1274 throws ServiceNotFoundException {
1275 IBinder b = ServiceManager.getServiceOrThrow(Context.ROLLBACK_SERVICE);
1276 return new RollbackManager(ctx.getOuterContext(),
1277 IRollbackManager.Stub.asInterface(b));
1278 }});
Howard Chen0a947642019-01-07 14:10:44 +08001279
Po-Chien Hsueh4e908c22019-03-07 11:57:17 +08001280 registerService(Context.DYNAMIC_SYSTEM_SERVICE, DynamicSystemManager.class,
1281 new CachedServiceFetcher<DynamicSystemManager>() {
Howard Chen0a947642019-01-07 14:10:44 +08001282 @Override
Po-Chien Hsueh4e908c22019-03-07 11:57:17 +08001283 public DynamicSystemManager createService(ContextImpl ctx)
Howard Chen0a947642019-01-07 14:10:44 +08001284 throws ServiceNotFoundException {
1285 IBinder b = ServiceManager.getServiceOrThrow(
Po-Chien Hsueh4e908c22019-03-07 11:57:17 +08001286 Context.DYNAMIC_SYSTEM_SERVICE);
1287 return new DynamicSystemManager(
1288 IDynamicSystemService.Stub.asInterface(b));
Howard Chen0a947642019-01-07 14:10:44 +08001289 }});
Felipe Lemeecb08be2018-11-27 15:48:47 -08001290 //CHECKSTYLE:ON IndentationCheck
Jeff Brown6e539312015-02-24 18:53:21 -08001291 }
1292
1293 /**
1294 * Creates an array which is used to cache per-Context service instances.
1295 */
1296 public static Object[] createServiceCache() {
1297 return new Object[sServiceCacheSize];
1298 }
1299
1300 /**
1301 * Gets a system service from a given context.
1302 */
1303 public static Object getSystemService(ContextImpl ctx, String name) {
1304 ServiceFetcher<?> fetcher = SYSTEM_SERVICE_FETCHERS.get(name);
1305 return fetcher != null ? fetcher.getService(ctx) : null;
1306 }
1307
1308 /**
Paul McLeane3383cc2015-05-08 11:41:20 -07001309 * Gets the name of the system-level service that is represented by the specified class.
Jeff Brown6e539312015-02-24 18:53:21 -08001310 */
1311 public static String getSystemServiceName(Class<?> serviceClass) {
1312 return SYSTEM_SERVICE_NAMES.get(serviceClass);
1313 }
1314
1315 /**
1316 * Statically registers a system service with the context.
1317 * This method must be called during static initialization only.
1318 */
1319 private static <T> void registerService(String serviceName, Class<T> serviceClass,
1320 ServiceFetcher<T> serviceFetcher) {
1321 SYSTEM_SERVICE_NAMES.put(serviceClass, serviceName);
1322 SYSTEM_SERVICE_FETCHERS.put(serviceName, serviceFetcher);
1323 }
1324
1325 /**
1326 * Base interface for classes that fetch services.
1327 * These objects must only be created during static initialization.
1328 */
1329 static abstract interface ServiceFetcher<T> {
1330 T getService(ContextImpl ctx);
1331 }
1332
1333 /**
1334 * Override this class when the system service constructor needs a
1335 * ContextImpl and should be cached and retained by that context.
1336 */
1337 static abstract class CachedServiceFetcher<T> implements ServiceFetcher<T> {
1338 private final int mCacheIndex;
1339
Makoto Onukid67070e2018-03-30 12:39:14 -07001340 CachedServiceFetcher() {
1341 // Note this class must be instantiated only by the static initializer of the
1342 // outer class (SystemServiceRegistry), which already does the synchronization,
1343 // so bare access to sServiceCacheSize is okay here.
Jeff Brown6e539312015-02-24 18:53:21 -08001344 mCacheIndex = sServiceCacheSize++;
1345 }
1346
1347 @Override
1348 @SuppressWarnings("unchecked")
1349 public final T getService(ContextImpl ctx) {
1350 final Object[] cache = ctx.mServiceCache;
Makoto Onukid67070e2018-03-30 12:39:14 -07001351 final int[] gates = ctx.mServiceInitializationStateArray;
Makoto Onukif896f122018-01-25 09:50:24 -08001352
Makoto Onukid67070e2018-03-30 12:39:14 -07001353 for (;;) {
1354 boolean doInitialize = false;
1355 synchronized (cache) {
1356 // Return it if we already have a cached instance.
1357 T service = (T) cache[mCacheIndex];
1358 if (service != null || gates[mCacheIndex] == ContextImpl.STATE_NOT_FOUND) {
1359 return service;
1360 }
Makoto Onukif896f122018-01-25 09:50:24 -08001361
Makoto Onukid67070e2018-03-30 12:39:14 -07001362 // If we get here, there's no cached instance.
Makoto Onukif896f122018-01-25 09:50:24 -08001363
Makoto Onukid67070e2018-03-30 12:39:14 -07001364 // Grr... if gate is STATE_READY, then this means we initialized the service
1365 // once but someone cleared it.
1366 // We start over from STATE_UNINITIALIZED.
1367 if (gates[mCacheIndex] == ContextImpl.STATE_READY) {
1368 gates[mCacheIndex] = ContextImpl.STATE_UNINITIALIZED;
1369 }
1370
1371 // It's possible for multiple threads to get here at the same time, so
1372 // use the "gate" to make sure only the first thread will call createService().
1373
1374 // At this point, the gate must be either UNINITIALIZED or INITIALIZING.
1375 if (gates[mCacheIndex] == ContextImpl.STATE_UNINITIALIZED) {
1376 doInitialize = true;
1377 gates[mCacheIndex] = ContextImpl.STATE_INITIALIZING;
1378 }
Makoto Onukif896f122018-01-25 09:50:24 -08001379 }
1380
Makoto Onukid67070e2018-03-30 12:39:14 -07001381 if (doInitialize) {
1382 // Only the first thread gets here.
Makoto Onukif896f122018-01-25 09:50:24 -08001383
Makoto Onukid67070e2018-03-30 12:39:14 -07001384 T service = null;
1385 @ServiceInitializationState int newState = ContextImpl.STATE_NOT_FOUND;
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001386 try {
Makoto Onukid67070e2018-03-30 12:39:14 -07001387 // This thread is the first one to get here. Instantiate the service
1388 // *without* the cache lock held.
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001389 service = createService(ctx);
Makoto Onukid67070e2018-03-30 12:39:14 -07001390 newState = ContextImpl.STATE_READY;
Makoto Onukif896f122018-01-25 09:50:24 -08001391
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001392 } catch (ServiceNotFoundException e) {
Jeff Sharkey589f3092016-11-29 12:54:39 -07001393 onServiceNotFound(e);
Makoto Onukif896f122018-01-25 09:50:24 -08001394
Makoto Onukid67070e2018-03-30 12:39:14 -07001395 } finally {
1396 synchronized (cache) {
1397 cache[mCacheIndex] = service;
1398 gates[mCacheIndex] = newState;
1399 cache.notifyAll();
1400 }
1401 }
1402 return service;
1403 }
1404 // The other threads will wait for the first thread to call notifyAll(),
1405 // and go back to the top and retry.
1406 synchronized (cache) {
1407 while (gates[mCacheIndex] < ContextImpl.STATE_READY) {
1408 try {
1409 cache.wait();
1410 } catch (InterruptedException e) {
1411 Log.w(TAG, "getService() interrupted");
1412 Thread.currentThread().interrupt();
1413 return null;
1414 }
Makoto Onukif896f122018-01-25 09:50:24 -08001415 }
1416 }
Makoto Onukif896f122018-01-25 09:50:24 -08001417 }
Jeff Brown6e539312015-02-24 18:53:21 -08001418 }
1419
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001420 public abstract T createService(ContextImpl ctx) throws ServiceNotFoundException;
Jeff Brown6e539312015-02-24 18:53:21 -08001421 }
1422
1423 /**
1424 * Override this class when the system service does not need a ContextImpl
1425 * and should be cached and retained process-wide.
1426 */
1427 static abstract class StaticServiceFetcher<T> implements ServiceFetcher<T> {
1428 private T mCachedInstance;
1429
1430 @Override
Jeff Sharkey589f3092016-11-29 12:54:39 -07001431 public final T getService(ContextImpl ctx) {
Jeff Brown6e539312015-02-24 18:53:21 -08001432 synchronized (StaticServiceFetcher.this) {
1433 if (mCachedInstance == null) {
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001434 try {
1435 mCachedInstance = createService();
1436 } catch (ServiceNotFoundException e) {
Jeff Sharkey589f3092016-11-29 12:54:39 -07001437 onServiceNotFound(e);
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001438 }
Jeff Brown6e539312015-02-24 18:53:21 -08001439 }
1440 return mCachedInstance;
1441 }
1442 }
1443
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001444 public abstract T createService() throws ServiceNotFoundException;
Jeff Brown6e539312015-02-24 18:53:21 -08001445 }
Lorenzo Colittiffc42b02015-07-29 11:41:21 +09001446
1447 /**
Lorenzo Colitticf959772016-02-29 16:07:37 +09001448 * Like StaticServiceFetcher, creates only one instance of the service per application, but when
1449 * creating the service for the first time, passes it the application context of the creating
1450 * application.
Lorenzo Colittiffc42b02015-07-29 11:41:21 +09001451 *
Lorenzo Colittiffc42b02015-07-29 11:41:21 +09001452 * TODO: Delete this once its only user (ConnectivityManager) is known to work well in the
1453 * case where multiple application components each have their own ConnectivityManager object.
1454 */
Lorenzo Colitticf959772016-02-29 16:07:37 +09001455 static abstract class StaticApplicationContextServiceFetcher<T> implements ServiceFetcher<T> {
Lorenzo Colittiffc42b02015-07-29 11:41:21 +09001456 private T mCachedInstance;
1457
1458 @Override
1459 public final T getService(ContextImpl ctx) {
Lorenzo Colitticf959772016-02-29 16:07:37 +09001460 synchronized (StaticApplicationContextServiceFetcher.this) {
Lorenzo Colittiffc42b02015-07-29 11:41:21 +09001461 if (mCachedInstance == null) {
Lorenzo Colitti0ad9ab02016-03-25 17:40:11 +09001462 Context appContext = ctx.getApplicationContext();
1463 // If the application context is null, we're either in the system process or
1464 // it's the application context very early in app initialization. In both these
1465 // cases, the passed-in ContextImpl will not be freed, so it's safe to pass it
1466 // to the service. http://b/27532714 .
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001467 try {
1468 mCachedInstance = createService(appContext != null ? appContext : ctx);
1469 } catch (ServiceNotFoundException e) {
Jeff Sharkey589f3092016-11-29 12:54:39 -07001470 onServiceNotFound(e);
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001471 }
Lorenzo Colittiffc42b02015-07-29 11:41:21 +09001472 }
1473 return mCachedInstance;
1474 }
1475 }
1476
Jeff Sharkey49ca5292016-05-10 12:54:45 -06001477 public abstract T createService(Context applicationContext) throws ServiceNotFoundException;
Lorenzo Colittiffc42b02015-07-29 11:41:21 +09001478 }
Jeff Sharkey589f3092016-11-29 12:54:39 -07001479
1480 public static void onServiceNotFound(ServiceNotFoundException e) {
1481 // We're mostly interested in tracking down long-lived core system
1482 // components that might stumble if they obtain bad references; just
1483 // emit a tidy log message for normal apps
1484 if (android.os.Process.myUid() < android.os.Process.FIRST_APPLICATION_UID) {
1485 Log.wtf(TAG, e.getMessage(), e);
1486 } else {
1487 Log.w(TAG, e.getMessage());
1488 }
1489 }
Jeff Brown6e539312015-02-24 18:53:21 -08001490}