diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java index d32b6b516a7d8..fe4b0d52b1337 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 c3dd82729d6d3..41c3da394de3e 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -4106,6 +4106,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) */