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

Commit 47096934 authored by Dianne Hackborn's avatar Dianne Hackborn
Browse files

Add APIs for mapping between new and current package names.

This will allow Market and others to find out what the "real" name
of a package is, when it is currently running under the old name of
a previously installed version.
parent b509065a
Loading
Loading
Loading
Loading
+52 −0
Original line number Diff line number Diff line
@@ -43257,6 +43257,19 @@
<parameter name="activity" type="android.content.ComponentName">
</parameter>
</method>
<method name="canonicalToCurrentPackageNames"
 return="java.lang.String[]"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="names" type="java.lang.String[]">
</parameter>
</method>
<method name="checkPermission"
 return="int"
 abstract="true"
@@ -43315,6 +43328,19 @@
<parameter name="packageName" type="java.lang.String">
</parameter>
</method>
<method name="currentToCanonicalPackageNames"
 return="java.lang.String[]"
 abstract="true"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="names" type="java.lang.String[]">
</parameter>
</method>
<method name="getActivityIcon"
 return="android.graphics.drawable.Drawable"
 abstract="true"
@@ -145995,6 +146021,19 @@
<parameter name="activity" type="android.content.ComponentName">
</parameter>
</method>
<method name="canonicalToCurrentPackageNames"
 return="java.lang.String[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="names" type="java.lang.String[]">
</parameter>
</method>
<method name="checkPermission"
 return="int"
 abstract="false"
@@ -146053,6 +146092,19 @@
<parameter name="packageName" type="java.lang.String">
</parameter>
</method>
<method name="currentToCanonicalPackageNames"
 return="java.lang.String[]"
 abstract="false"
 native="false"
 synchronized="false"
 static="false"
 final="false"
 deprecated="not deprecated"
 visibility="public"
>
<parameter name="names" type="java.lang.String[]">
</parameter>
</method>
<method name="getActivityIcon"
 return="android.graphics.drawable.Drawable"
 abstract="false"
+18 −0
Original line number Diff line number Diff line
@@ -1614,6 +1614,24 @@ class ContextImpl extends Context {
            throw new NameNotFoundException(packageName);
        }

        @Override
        public String[] currentToCanonicalPackageNames(String[] names) {
            try {
                return mPM.currentToCanonicalPackageNames(names);
            } catch (RemoteException e) {
                throw new RuntimeException("Package manager has died", e);
            }
        }
        
        @Override
        public String[] canonicalToCurrentPackageNames(String[] names) {
            try {
                return mPM.canonicalToCurrentPackageNames(names);
            } catch (RemoteException e) {
                throw new RuntimeException("Package manager has died", e);
            }
        }
        
        @Override
        public Intent getLaunchIntentForPackage(String packageName) {
            // First see if the package has an INFO activity; the existence of
+3 −0
Original line number Diff line number Diff line
@@ -48,6 +48,9 @@ interface IPackageManager {
    int getPackageUid(String packageName);
    int[] getPackageGids(String packageName);
    
    String[] currentToCanonicalPackageNames(in String[] names);
    String[] canonicalToCurrentPackageNames(in String[] names);

    PermissionInfo getPermissionInfo(String name, int flags);
    
    List<PermissionInfo> queryPermissionsByGroup(String group, int flags);
+17 −0
Original line number Diff line number Diff line
@@ -690,6 +690,23 @@ public abstract class PackageManager {
    public abstract PackageInfo getPackageInfo(String packageName, int flags)
            throws NameNotFoundException;

    /**
     * Map from the current package names in use on the device to whatever
     * the current canonical name of that package is.
     * @param names Array of current names to be mapped.
     * @return Returns an array of the same size as the original, containing
     * the canonical name for each package.
     */
    public abstract String[] currentToCanonicalPackageNames(String[] names);
    
    /**
     * Map from a packages canonical name to the current name in use on the device.
     * @param names Array of new names to be mapped.
     * @return Returns an array of the same size as the original, containing
     * the current name for each package.
     */
    public abstract String[] canonicalToCurrentPackageNames(String[] names);
    
    /**
     * Return a "good" intent to launch a front-door activity in a package,
     * for use for example to implement an "open" button when browsing through
+22 −0
Original line number Diff line number Diff line
@@ -1076,6 +1076,28 @@ class PackageManagerService extends IPackageManager.Stub {
        return null;
    }

    public String[] currentToCanonicalPackageNames(String[] names) {
        String[] out = new String[names.length];
        synchronized (mPackages) {
            for (int i=names.length-1; i>=0; i--) {
                PackageSetting ps = mSettings.mPackages.get(names[i]);
                out[i] = ps != null && ps.realName != null ? ps.realName : names[i];
            }
        }
        return out;
    }
    
    public String[] canonicalToCurrentPackageNames(String[] names) {
        String[] out = new String[names.length];
        synchronized (mPackages) {
            for (int i=names.length-1; i>=0; i--) {
                String cur = mSettings.mRenamedPackages.get(names[i]);
                out[i] = cur != null ? cur : names[i];
            }
        }
        return out;
    }
    
    public int getPackageUid(String packageName) {
        synchronized (mPackages) {
            PackageParser.Package p = mPackages.get(packageName);
Loading