Fixed SystemServiceRegistry to return a null AppPredictionManager when the service is not defined.

Test: manual verification
Test: atest CtsAssistTestCases

Fixes: 139416391

Change-Id: Ieb2ae3f39bd42dc077ed3db1c6acdf429a39d519
This commit is contained in:
Felipe Leme
2019-08-14 18:14:55 -07:00
parent 620c61dc8a
commit 6378bd40dd
2 changed files with 5 additions and 1 deletions

View File

@@ -1166,7 +1166,8 @@ public final class SystemServiceRegistry {
@Override
public AppPredictionManager createService(ContextImpl ctx)
throws ServiceNotFoundException {
return new AppPredictionManager(ctx);
IBinder b = ServiceManager.getService(Context.APP_PREDICTION_SERVICE);
return b == null ? null : new AppPredictionManager(ctx);
}
});

View File

@@ -4109,6 +4109,9 @@ public abstract class Context {
/**
* Official published name of the app prediction service.
*
* <p><b>NOTE: </b> this service is optional; callers of
* {@code Context.getSystemServiceName(APP_PREDICTION_SERVICE)} should check for {@code null}.
*
* @hide
* @see #getSystemService(String)
*/