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

Commit 216fe086 authored by Tony Mak's avatar Tony Mak
Browse files

PackageManager no longer requires the ExtServices to be a "Shared Library"

BUG: 147663325

Test: Boot
Test: atest cts/tests/tests/os/src/android/os/cts/RequiredComponentsTest.java
Test: mts-tradefed run mts-extservices

Change-Id: I32fcb27e54d50e362b3005dd6d235bcc30a60ac8
parent bcd1d7f6
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -3379,6 +3379,10 @@ public abstract class PackageManager {
     * 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.
     * <p>
     * This shared library no longer exists since Android R.
     *
     * @see #getServicesSystemSharedLibraryPackageName()
     *
     * @hide
     */
@@ -4733,6 +4737,9 @@ public abstract class PackageManager {

    /**
     * Get the name of the package hosting the services shared library.
     * <p>
     * Note that this package is no longer a shared library since Android R. It is now a package
     * that hosts for a bunch of updatable services that the system binds to.
     *
     * @return The library host package.
     *
+3 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.annotation.SdkConstant;
import android.annotation.SystemApi;
import android.app.Service;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
@@ -48,7 +49,8 @@ import java.util.concurrent.TimeUnit;
 * <p>To extend this class, you must declare the service in your manifest file with the
 * {@link android.Manifest.permission#BIND_EXPLICIT_HEALTH_CHECK_SERVICE} permission,
 * and include an intent filter with the {@link #SERVICE_INTERFACE} action. In adddition,
 * your implementation must live in {@link PackageManger#SYSTEM_SHARED_LIBRARY_SERVICES}.
 * your implementation must live in
 * {@link PackageManager#getServicesSystemSharedLibraryPackageName()}.
 * For example:</p>
 * <pre>
 *     &lt;service android:name=".FooExplicitHealthCheckService"
+3 −0
Original line number Diff line number Diff line
@@ -4294,4 +4294,7 @@

    <!-- Class name of the custom country detector to be used. -->
    <string name="config_customCountryDetector" translatable="false">com.android.server.location.ComprehensiveCountryDetector</string>

    <!-- Package name of the required service extension package. -->
    <string name="config_servicesExtensionPackage" translatable="false">android.ext.services</string>
</resources>
+1 −0
Original line number Diff line number Diff line
@@ -3816,4 +3816,5 @@
  <java-symbol type="string" name="capability_desc_canTakeScreenshot" />
  <java-symbol type="string" name="capability_title_canTakeScreenshot" />

  <java-symbol type="string" name="config_servicesExtensionPackage" />
</resources>
+17 −6
Original line number Diff line number Diff line
@@ -1534,7 +1534,7 @@ public class PackageManagerService extends IPackageManager.Stub
    final @Nullable String mAppPredictionServicePackage;
    final @Nullable String mIncidentReportApproverPackage;
    final @Nullable String[] mTelephonyPackages;
    final @NonNull String mServicesSystemSharedLibraryPackageName;
    final @NonNull String mServicesExtensionPackageName;
    final @NonNull String mSharedSystemSharedLibraryPackageName;
    private final PackageUsage mPackageUsage = new PackageUsage();
@@ -3303,9 +3303,7 @@ public class PackageManagerService extends IPackageManager.Stub
                } else {
                    mIntentFilterVerifier = null;
                }
                mServicesSystemSharedLibraryPackageName = getRequiredSharedLibraryLPr(
                        PackageManager.SYSTEM_SHARED_LIBRARY_SERVICES,
                        SharedLibraryInfo.VERSION_UNDEFINED);
                mServicesExtensionPackageName = getRequiredServicesExtensionPackageLPr();
                mSharedSystemSharedLibraryPackageName = getRequiredSharedLibraryLPr(
                        PackageManager.SYSTEM_SHARED_LIBRARY_SHARED,
                        SharedLibraryInfo.VERSION_UNDEFINED);
@@ -3315,7 +3313,7 @@ public class PackageManagerService extends IPackageManager.Stub
                mRequiredUninstallerPackage = null;
                mIntentFilterVerifierComponent = null;
                mIntentFilterVerifier = null;
                mServicesSystemSharedLibraryPackageName = null;
                mServicesExtensionPackageName = null;
                mSharedSystemSharedLibraryPackageName = null;
            }
            // PermissionController hosts default permission granting and role management, so it's a
@@ -3745,6 +3743,19 @@ public class PackageManagerService extends IPackageManager.Stub
        }
    }
    @NonNull
    private String getRequiredServicesExtensionPackageLPr() {
        String servicesExtensionPackage =
                ensureSystemPackageName(
                        mContext.getString(R.string.config_servicesExtensionPackage));
        if (TextUtils.isEmpty(servicesExtensionPackage)) {
            throw new RuntimeException(
                    "Required services extension package is missing, check "
                            + "config_servicesExtensionPackage.");
        }
        return servicesExtensionPackage;
    }
    private @NonNull String getRequiredInstallerLPr() {
        final Intent intent = new Intent(Intent.ACTION_INSTALL_PACKAGE);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
@@ -5467,7 +5478,7 @@ public class PackageManagerService extends IPackageManager.Stub
    public @NonNull String getServicesSystemSharedLibraryPackageName() {
        // allow instant applications
        synchronized (mLock) {
            return mServicesSystemSharedLibraryPackageName;
            return mServicesExtensionPackageName;
        }
    }