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

Commit 8a600247 authored by Taras Antoshchuk's avatar Taras Antoshchuk
Browse files

Change dynamic MIME feature accodring to API review

Remove PackageManager#clearMimeGroup method. Add expected best
practices of the MIME group naming to Javadocs.
getMimeGroup/setMimeGroup throw in case of undefined MIME group.

Bug: 151101912
Test: atest CtsDynamicMimeHostTestCases
Change-Id: Ica468c77785cb0f9862b412a0bbc664f23e2f2d4
parent 9bcbce4a
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -11968,7 +11968,6 @@ package android.content.pm {
    method @CheckResult public abstract int checkSignatures(@NonNull String, @NonNull String);
    method @CheckResult public abstract int checkSignatures(int, int);
    method public abstract void clearInstantAppCookie();
    method public void clearMimeGroup(@NonNull String);
    method @Deprecated public abstract void clearPackagePreferredActivities(@NonNull String);
    method public abstract String[] currentToCanonicalPackageNames(@NonNull String[]);
    method public abstract void extendVerificationTimeout(int, int, long);
@@ -12004,7 +12003,7 @@ package android.content.pm {
    method @NonNull public abstract android.content.pm.InstrumentationInfo getInstrumentationInfo(@NonNull android.content.ComponentName, int) throws android.content.pm.PackageManager.NameNotFoundException;
    method @Nullable public abstract android.content.Intent getLaunchIntentForPackage(@NonNull String);
    method @Nullable public abstract android.content.Intent getLeanbackLaunchIntentForPackage(@NonNull String);
    method @Nullable public java.util.Set<java.lang.String> getMimeGroup(@NonNull String);
    method @NonNull public java.util.Set<java.lang.String> getMimeGroup(@NonNull String);
    method @NonNull public android.content.pm.ModuleInfo getModuleInfo(@NonNull String, int) throws android.content.pm.PackageManager.NameNotFoundException;
    method @Nullable public abstract String getNameForUid(int);
    method @Nullable public android.content.pm.PackageInfo getPackageArchiveInfo(@NonNull String, int);
+3 −14
Original line number Diff line number Diff line
@@ -3358,31 +3358,20 @@ public class ApplicationPackageManager extends PackageManager {
        }
    }

    public void setMimeGroup(String mimeGroup, Set<String> mimeTypes) {
        try {
            mPM.setMimeGroup(mContext.getPackageName(), mimeGroup,
                    new ArrayList<String>(mimeTypes));
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
    }

    @Override
    public void clearMimeGroup(String mimeGroup) {
    public void setMimeGroup(String mimeGroup, Set<String> mimeTypes) {
        try {
            mPM.clearMimeGroup(mContext.getPackageName(), mimeGroup);
            mPM.setMimeGroup(mContext.getPackageName(), mimeGroup, new ArrayList<>(mimeTypes));
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
        }
    }

    @NonNull
    @Override
    public Set<String> getMimeGroup(String group) {
        try {
            List<String> mimeGroup = mPM.getMimeGroup(mContext.getPackageName(), group);
            if (mimeGroup == null) {
                return null;
            }
            return new ArraySet<>(mimeGroup);
        } catch (RemoteException e) {
            throw e.rethrowAsRuntimeException();
+0 −2
Original line number Diff line number Diff line
@@ -743,8 +743,6 @@ interface IPackageManager {

    void setMimeGroup(String packageName, String group, in List<String> mimeTypes);

    void clearMimeGroup(String packageName, String group);

    List<String> getMimeGroup(String packageName, String group);

    boolean isAutoRevokeWhitelisted(String packageName);
+14 −16
Original line number Diff line number Diff line
@@ -7894,10 +7894,14 @@ public abstract class PackageManager {
    }

    /**
     * Sets MIME group's MIME types
     * Sets MIME group's MIME types.
     *
     * @param mimeGroup MIME group to modify
     * @param mimeTypes new MIME types contained by MIME group
     * Libraries should use a reverse-DNS prefix followed by a ':' character and library-specific
     * group name to avoid namespace collisions, e.g. "com.example:myFeature".
     *
     * @param mimeGroup MIME group to modify.
     * @param mimeTypes new MIME types contained by MIME group.
     * @throws IllegalArgumentException if the MIME group was not declared in the manifest.
     */
    public void setMimeGroup(@NonNull String mimeGroup, @NonNull Set<String> mimeTypes) {
        throw new UnsupportedOperationException(
@@ -7905,22 +7909,16 @@ public abstract class PackageManager {
    }

    /**
     * Clears MIME group by removing all MIME types from it
     * Gets all MIME types contained by MIME group.
     *
     * @param mimeGroup MIME group to clear
     */
    public void clearMimeGroup(@NonNull String mimeGroup) {
        throw new UnsupportedOperationException(
                "clearMimeGroup not implemented in subclass");
    }

    /**
     * Gets all MIME types that MIME group contains
     * Libraries should use a reverse-DNS prefix followed by a ':' character and library-specific
     * group name to avoid namespace collisions, e.g. "com.example:myFeature".
     *
     * @return MIME types contained by the MIME group,
     *         or null if the MIME group was not declared in the manifest.
     * @param mimeGroup MIME group to retrieve.
     * @return MIME types contained by the MIME group.
     * @throws IllegalArgumentException if the MIME group was not declared in the manifest.
     */
    @Nullable
    @NonNull
    public Set<String> getMimeGroup(@NonNull String mimeGroup) {
        throw new UnsupportedOperationException(
                "getMimeGroup not implemented in subclass");
+0 −9
Original line number Diff line number Diff line
@@ -24659,15 +24659,6 @@ public class PackageManagerService extends IPackageManager.Stub
        }
    }
    @Override
    public void clearMimeGroup(String packageName, String mimeGroup) {
        boolean changed = mSettings.mPackages.get(packageName).clearMimeGroup(mimeGroup);
        if (changed) {
            applyMimeGroupChanges(packageName, mimeGroup);
        }
    }
    @Override
    public List<String> getMimeGroup(String packageName, String mimeGroup) {
        return mSettings.mPackages.get(packageName).getMimeGroup(mimeGroup);
Loading