Logspam: Properly handle optional app widgets service

If a service is not present and an exeception is thrown in
the SystemServiceRegistry, we log a message and proceed with
the null service. Optional feature services, like app widgets,
are expected to be missing if not supported. Properly
handle the lookup, so no exception that pollutes the logs is
emitted for what is normal operation.

Test: No exception logged with the app widgets feature disabled

Upstream from Meta

Change-Id: I1cae4f9188ec47b55d68d7c8208f0da1c6c263b4
This commit is contained in:
Svet Ganov
2022-10-29 14:35:16 -07:00
parent 9e7649d5e7
commit 2d55b23e7d

View File

@@ -1020,9 +1020,10 @@ public final class SystemServiceRegistry {
registerService(Context.APPWIDGET_SERVICE, AppWidgetManager.class,
new CachedServiceFetcher<AppWidgetManager>() {
@Override
public AppWidgetManager createService(ContextImpl ctx) throws ServiceNotFoundException {
IBinder b = ServiceManager.getServiceOrThrow(Context.APPWIDGET_SERVICE);
return new AppWidgetManager(ctx, IAppWidgetService.Stub.asInterface(b));
public AppWidgetManager createService(ContextImpl ctx) {
IBinder b = ServiceManager.getService(Context.APPWIDGET_SERVICE);
return b == null ? null : new AppWidgetManager(ctx,
IAppWidgetService.Stub.asInterface(b));
}});
registerService(Context.MIDI_SERVICE, MidiManager.class,