Add an API to query the package name of the services shared lib

The servcies shared lib contains components apps can invoke such
as services to bind to, activities to start, UI choosers, etc.
This lib is built from AOSP code but an OEM may chage its
package name. For example, Google renames the package names for
GMS apps from android.foo.bar to com.google.android.foo.bar.
While we have more than one shared lib that are a part of the
platform (currently shared and services libs) the serivces lib
is the only one clients need to start components in, thus need
to know its package name. This change adds an API to query the
package name of the services shared lib. The API is hidden as
currently the only clients are a part of the system.

Change-Id: Ied48fa4819024522791764b22b3336d4f4b42cc3
diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java
index c071162..df4b7d1 100644
--- a/core/java/android/app/ApplicationPackageManager.java
+++ b/core/java/android/app/ApplicationPackageManager.java
@@ -429,6 +429,16 @@
         }
     }
 
+    /** @hide */
+    @Override
+    public @Nullable String getServicesSystemSharedLibraryPackageName() {
+        try {
+            return mPM.getServicesSystemSharedLibraryPackageName();
+        } catch (RemoteException e) {
+            throw new RuntimeException("Package manager has died", e);
+        }
+    }
+
     @Override
     public FeatureInfo[] getSystemAvailableFeatures() {
         try {
diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl
index 593fe2a..3863857 100644
--- a/core/java/android/content/pm/IPackageManager.aidl
+++ b/core/java/android/content/pm/IPackageManager.aidl
@@ -534,4 +534,6 @@
     boolean isEphemeralApplication(String packageName, int userId);
 
     boolean setRequiredForSystemUser(String packageName, boolean systemUserApp);
+
+    String getServicesSystemSharedLibraryPackageName();
 }
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 08deedb..bf0d4de 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -2327,6 +2327,28 @@
     public static final int MASK_PERMISSION_FLAGS = 0xFF;
 
     /**
+     * This is a library that contains components apps can invoke. For
+     * example, a services for apps to bind to, or standard chooser UI,
+     * etc. This library is versioned and backwards compatible. Clients
+     * should check its version via {@link android.ext.services.Version
+     * #getVersionCode()} and avoid calling APIs added in later versions.
+     *
+     * @hide
+     */
+    public static final String SYSTEM_SHARED_LIBRARY_SERVICES = "android.ext.services";
+
+    /**
+     * This is a library that contains components apps can dynamically
+     * load. For example, new widgets, helper classes, etc. This library
+     * is versioned and backwards compatible. Clients should check its
+     * version via {@link android.ext.shared.Version#getVersionCode()}
+     * and avoid calling APIs added in later versions.
+     *
+     * @hide
+     */
+    public static final String SYSTEM_SHARED_LIBRARY_SHARED = "android.ext.shared";
+
+    /**
      * Retrieve overall information about an application package that is
      * installed on the system.
      *
@@ -3365,6 +3387,15 @@
     public abstract String[] getSystemSharedLibraryNames();
 
     /**
+     * Get the name of the package hosting the services shared library.
+     *
+     * @return The library host package.
+     *
+     * @hide
+     */
+    public abstract @Nullable String getServicesSystemSharedLibraryPackageName();
+
+    /**
      * Get a list of features that are available on the
      * system.
      *