Skip to content

Commit

Permalink
Logspam: Properly handle optional app widgets service
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Svet Ganov authored and DennySPB committed Dec 19, 2022
1 parent 366b3c9 commit 3f1945f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions core/java/android/app/SystemServiceRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -1040,9 +1040,10 @@ public MediaProjectionManager createService(ContextImpl ctx) {
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,
Expand Down

0 comments on commit 3f1945f

Please sign in to comment.