diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index cfe2cf09ae19e..d29cf80bd74e1 100644 --- a/core/java/android/app/SystemServiceRegistry.java +++ b/core/java/android/app/SystemServiceRegistry.java @@ -1162,7 +1162,8 @@ 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); } }); diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 73bc908632b2d..0bac6835496b6 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -4109,6 +4109,9 @@ public abstract class Context { /** * Official published name of the app prediction service. * + *

NOTE: this service is optional; callers of + * {@code Context.getSystemServiceName(APP_PREDICTION_SERVICE)} should check for {@code null}. + * * @hide * @see #getSystemService(String) */