Skip to content

Commit 3f1945f

Browse files
Svet GanovDennySPB
Svet Ganov
authored andcommitted
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 Signed-off-by: DennySPb <[email protected]>
1 parent 366b3c9 commit 3f1945f

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

core/java/android/app/SystemServiceRegistry.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,9 +1040,10 @@ public MediaProjectionManager createService(ContextImpl ctx) {
10401040
registerService(Context.APPWIDGET_SERVICE, AppWidgetManager.class,
10411041
new CachedServiceFetcher<AppWidgetManager>() {
10421042
@Override
1043-
public AppWidgetManager createService(ContextImpl ctx) throws ServiceNotFoundException {
1044-
IBinder b = ServiceManager.getServiceOrThrow(Context.APPWIDGET_SERVICE);
1045-
return new AppWidgetManager(ctx, IAppWidgetService.Stub.asInterface(b));
1043+
public AppWidgetManager createService(ContextImpl ctx) {
1044+
IBinder b = ServiceManager.getService(Context.APPWIDGET_SERVICE);
1045+
return b == null ? null : new AppWidgetManager(ctx,
1046+
IAppWidgetService.Stub.asInterface(b));
10461047
}});
10471048

10481049
registerService(Context.MIDI_SERVICE, MidiManager.class,

0 commit comments

Comments
 (0)