Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d7b1f411 authored by Svet Ganov's avatar Svet Ganov
Browse files

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
parent 2a061b5b
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -429,6 +429,16 @@ public class ApplicationPackageManager extends PackageManager {
        }
    }

    /** @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 {
+2 −0
Original line number Diff line number Diff line
@@ -534,4 +534,6 @@ interface IPackageManager {
    boolean isEphemeralApplication(String packageName, int userId);

    boolean setRequiredForSystemUser(String packageName, boolean systemUserApp);

    String getServicesSystemSharedLibraryPackageName();
}
+31 −0
Original line number Diff line number Diff line
@@ -2326,6 +2326,28 @@ public abstract class PackageManager {
    @SystemApi
    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.
@@ -3364,6 +3386,15 @@ public abstract class PackageManager {
     */
    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.
+12 −0
Original line number Diff line number Diff line
@@ -3426,6 +3426,18 @@ public class PackageManagerService extends IPackageManager.Stub {
        return null;
    }
    @Override
    public @Nullable String getServicesSystemSharedLibraryPackageName() {
        synchronized (mPackages) {
            SharedLibraryEntry libraryEntry = mSharedLibraries.get(
                    PackageManager.SYSTEM_SHARED_LIBRARY_SERVICES);
            if (libraryEntry != null) {
                return libraryEntry.apk;
            }
        }
        return null;
    }
    @Override
    public FeatureInfo[] getSystemAvailableFeatures() {
        Collection<FeatureInfo> featSet;
+7 −0
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package android.test.mock;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.PackageInstallObserver;
import android.content.ComponentName;
import android.content.Intent;
@@ -806,6 +807,12 @@ public class MockPackageManager extends PackageManager {
        throw new UnsupportedOperationException();
    }

    /** @hide */
    @Override
    public @Nullable String getServicesSystemSharedLibraryPackageName() {
        throw new UnsupportedOperationException();
    }

    @Override
    public FeatureInfo[] getSystemAvailableFeatures() {
        throw new UnsupportedOperationException();