From 499d4bff668d33613287d394c2a7c4157c11ff5f Mon Sep 17 00:00:00 2001 From: atrost Date: Thu, 15 Aug 2019 16:53:01 +0100 Subject: [PATCH] Start platform compat service eariler. It's needed by ActivityManager and PackageManager. Also use a constant in Context for the name. Test: flashed device with ag/9025572 and ag/9204795 and the platfrom compat was accessible. Bug: 137769727 Change-Id: Ie1130a3f0bdd1769fe0755db0089702ea64d9db6 Merged-In: Ie1130a3f0bdd1769fe0755db0089702ea64d9db6 --- core/java/android/content/Context.java | 9 +++++++++ services/java/com/android/server/SystemServer.java | 11 +++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java index 4ab8c5fcf8207..3c5cfbe0a7436 100644 --- a/core/java/android/content/Context.java +++ b/core/java/android/content/Context.java @@ -37,6 +37,7 @@ import android.app.ActivityManager; import android.app.IApplicationThread; import android.app.IServiceConnection; import android.app.VrManager; +import android.compat.IPlatformCompat; import android.content.pm.ApplicationInfo; import android.content.pm.PackageManager; import android.content.res.AssetManager; @@ -3064,6 +3065,7 @@ public abstract class Context { RESTRICTIONS_SERVICE, APP_OPS_SERVICE, CAMERA_SERVICE, + //@hide: PLATFORM_COMPAT_SERVICE, PRINT_SERVICE, CONSUMER_IR_SERVICE, //@hide: TRUST_SERVICE, @@ -4225,6 +4227,13 @@ public abstract class Context { @SystemApi public static final String STATS_MANAGER = "stats"; + /** + * Use with {@link android.os.ServiceManager.getService()} to retrieve a + * {@link IPlatformCompat} IBinder for communicating with the platform compat service. + * @hide + */ + public static final String PLATFORM_COMPAT_SERVICE = "platform_compat"; + /** * Service to capture a bugreport. * @see #getSystemService(String) diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java index 10db049a3e632..bbe7456853d5c 100644 --- a/services/java/com/android/server/SystemServer.java +++ b/services/java/com/android/server/SystemServer.java @@ -562,6 +562,13 @@ public final class SystemServer { SystemServerInitThreadPool.get().submit(SystemConfig::getInstance, TAG_SYSTEM_CONFIG); traceEnd(); + // Platform compat service is used by ActivityManagerService, PackageManagerService, and + // possibly others in the future. b/135010838. + traceBeginAndSlog("PlatformCompat"); + ServiceManager.addService(Context.PLATFORM_COMPAT_SERVICE, + new PlatformCompat(mSystemContext)); + traceEnd(); + // Wait for installd to finish starting up so that it has a chance to // create critical directories such as /data/user with the appropriate // permissions. We need this to complete before we initialize other services. @@ -977,10 +984,6 @@ public final class SystemServer { mSystemServiceManager.startService(PinnerService.class); traceEnd(); - traceBeginAndSlog("PlatformCompat"); - ServiceManager.addService("platform_compat", new PlatformCompat(context)); - traceEnd(); - } catch (RuntimeException e) { Slog.e("System", "******************************************"); Slog.e("System", "************ Failure starting core service", e);