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

Commit a9c2500a authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Disallow disable of the system shared libs.

bug:28173410

Change-Id: If731f2d90312a083bb940f83431ba3eccf213947
parent 8bb7ad59
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -441,7 +441,7 @@ public class ApplicationPackageManager extends PackageManager {

    /** @hide */
    @Override
    public @Nullable String getServicesSystemSharedLibraryPackageName() {
    public @NonNull String getServicesSystemSharedLibraryPackageName() {
        try {
            return mPM.getServicesSystemSharedLibraryPackageName();
        } catch (RemoteException e) {
@@ -449,6 +449,17 @@ public class ApplicationPackageManager extends PackageManager {
        }
    }

    /**
     * @hide
     */
    public @NonNull String getSharedSystemSharedLibraryPackageName() {
        try {
            return mPM.getSharedSystemSharedLibraryPackageName();
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    @Override
    @SuppressWarnings("unchecked")
    public FeatureInfo[] getSystemAvailableFeatures() {
+1 −0
Original line number Diff line number Diff line
@@ -565,6 +565,7 @@ interface IPackageManager {
    boolean setRequiredForSystemUser(String packageName, boolean systemUserApp);

    String getServicesSystemSharedLibraryPackageName();
    String getSharedSystemSharedLibraryPackageName();

    boolean isPackageDeviceAdminOnAnyUser(String packageName);

+10 −1
Original line number Diff line number Diff line
@@ -3510,7 +3510,16 @@ public abstract class PackageManager {
     *
     * @hide
     */
    public abstract @Nullable String getServicesSystemSharedLibraryPackageName();
    public abstract @NonNull String getServicesSystemSharedLibraryPackageName();

    /**
     * Get the name of the package hosting the shared components shared library.
     *
     * @return The library host package.
     *
     * @hide
     */
    public abstract @NonNull String getSharedSystemSharedLibraryPackageName();

    /**
     * Get a list of features that are available on the
+13 −5
Original line number Diff line number Diff line
@@ -20,6 +20,10 @@ import com.android.settingslib.drawable.UserIconDrawable;
import java.text.NumberFormat;

public class Utils {
    private static Signature[] sSystemSignature;
    private static String sPermissionControllerPackageName;
    private static String sServicesSystemSharedLibPackageName;
    private static String sSharedSystemSharedLibPackageName;

    /**
     * Return string resource that best describes combination of tethering
@@ -161,15 +165,19 @@ public class Utils {
        if (sPermissionControllerPackageName == null) {
            sPermissionControllerPackageName = pm.getPermissionControllerPackageName();
        }
        if (sServicesSystemSharedLibPackageName == null) {
            sServicesSystemSharedLibPackageName = pm.getServicesSystemSharedLibraryPackageName();
        }
        if (sSharedSystemSharedLibPackageName == null) {
            sSharedSystemSharedLibPackageName = pm.getSharedSystemSharedLibraryPackageName();
        }
        return (sSystemSignature[0] != null
                        && sSystemSignature[0].equals(getFirstSignature(pkg)))
                || (sPermissionControllerPackageName != null
                        && sPermissionControllerPackageName.equals(pkg.packageName));
                || pkg.packageName.equals(sPermissionControllerPackageName)
                || pkg.packageName.equals(sServicesSystemSharedLibPackageName)
                || pkg.packageName.equals(sSharedSystemSharedLibPackageName);
    }

    private static Signature[] sSystemSignature;
    private static String sPermissionControllerPackageName;

    private static Signature getFirstSignature(PackageInfo pkg) {
        if (pkg != null && pkg.signatures != null && pkg.signatures.length > 0) {
            return pkg.signatures[0];
+10 −1
Original line number Diff line number Diff line
@@ -1104,6 +1104,7 @@ public class PackageManagerService extends IPackageManager.Stub {
    final @NonNull String mRequiredInstallerPackage;
    final @Nullable String mSetupWizardPackage;
    final @NonNull String mServicesSystemSharedLibraryPackageName;
    final @NonNull String mSharedSystemSharedLibraryPackageName;
    private final PackageUsage mPackageUsage = new PackageUsage();
@@ -2638,7 +2639,7 @@ public class PackageManagerService extends IPackageManager.Stub {
                        mIntentFilterVerifierComponent);
                mServicesSystemSharedLibraryPackageName = getRequiredSharedLibraryLPr(
                        PackageManager.SYSTEM_SHARED_LIBRARY_SERVICES);
                getRequiredSharedLibraryLPr(
                mSharedSystemSharedLibraryPackageName = getRequiredSharedLibraryLPr(
                        PackageManager.SYSTEM_SHARED_LIBRARY_SHARED);
            } else {
                mRequiredVerifierPackage = null;
@@ -2646,6 +2647,7 @@ public class PackageManagerService extends IPackageManager.Stub {
                mIntentFilterVerifierComponent = null;
                mIntentFilterVerifier = null;
                mServicesSystemSharedLibraryPackageName = null;
                mSharedSystemSharedLibraryPackageName = null;
            }
            mInstallerService = new PackageInstallerService(context, this);
@@ -3620,6 +3622,13 @@ public class PackageManagerService extends IPackageManager.Stub {
        }
    }
    @Override
    public @NonNull String getSharedSystemSharedLibraryPackageName() {
        synchronized (mPackages) {
            return mSharedSystemSharedLibraryPackageName;
        }
    }
    @Override
    public @NonNull ParceledListSlice<FeatureInfo> getSystemAvailableFeatures() {
        synchronized (mPackages) {
Loading