Loading api/current.xml +56 −0 Original line number Diff line number Diff line Loading @@ -45952,6 +45952,19 @@ <exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException"> </exception> </method> <method name="getPackageObbPaths" return="java.lang.String[]" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="packageName" type="java.lang.String"> </parameter> </method> <method name="getPackagesForUid" return="java.lang.String[]" abstract="true" Loading Loading @@ -46423,6 +46436,21 @@ <parameter name="flags" type="int"> </parameter> </method> <method name="setPackageObbPaths" return="void" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="packageName" type="java.lang.String"> </parameter> <parameter name="paths" type="java.lang.String[]"> </parameter> </method> <field name="COMPONENT_ENABLED_STATE_DEFAULT" type="int" transient="false" Loading Loading @@ -159105,6 +159133,19 @@ <exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException"> </exception> </method> <method name="getPackageObbPaths" return="java.lang.String[]" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="packageName" type="java.lang.String"> </parameter> </method> <method name="getPackagesForUid" return="java.lang.String[]" abstract="false" Loading Loading @@ -159589,6 +159630,21 @@ <parameter name="path" type="java.lang.String"> </parameter> </method> <method name="setPackageObbPaths" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="packageName" type="java.lang.String"> </parameter> <parameter name="paths" type="java.lang.String[]"> </parameter> </method> </class> <class name="MockResources" extends="android.content.res.Resources" core/java/android/app/ContextImpl.java +12 −2 Original line number Diff line number Diff line Loading @@ -2700,14 +2700,24 @@ class ContextImpl extends Context { } @Override public void setPackageObbPath(String packageName, String path) { public void setPackageObbPaths(String packageName, String[] paths) { try { mPM.setPackageObbPath(packageName, path); mPM.setPackageObbPaths(packageName, paths); } catch (RemoteException e) { // Should never happen! } } @Override public String[] getPackageObbPaths(String packageName) { try { return mPM.getPackageObbPaths(packageName); } catch (RemoteException e) { // Should never happen! } return null; } private final ContextImpl mContext; private final IPackageManager mPM; Loading core/java/android/content/pm/IPackageManager.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -322,5 +322,6 @@ interface IPackageManager { boolean setInstallLocation(int loc); int getInstallLocation(); void setPackageObbPath(String packageName, String path); void setPackageObbPaths(in String packageName, in String[] paths); String[] getPackageObbPaths(in String packageName); } core/java/android/content/pm/PackageManager.java +20 −5 Original line number Diff line number Diff line Loading @@ -2273,15 +2273,30 @@ public abstract class PackageManager { String packageName, IPackageMoveObserver observer, int flags); /** * Sets the Opaque Binary Blob (OBB) file location. * Sets the Opaque Binary Blob (OBB) file path associated with a package * name. The caller must have the * {@link android.Manifest.permission#INSTALL_PACKAGES} permission. * <p> * NOTE: The existence or format of this file is not currently checked, but * it may be in the future. * * @param packageName Name of the package with which to associate the .obb * file * @param path Path on the filesystem to the .obb file * @hide * file. * @param paths Arrays of paths on the filesystem to the .obb files * associated with the package. * @see #getPackageObbPaths(String) */ public abstract void setPackageObbPaths(String packageName, String[] paths); /** * Gets the Opaque Binary Blob (OBB) file path associated with the package. * The caller must be the owner of the package queried or have the * {@link android.Manifest.permission#INSTALL_PACKAGES} permission. * * @param packageName Name of the package with which to associate the .obb * file. * @return array of paths to .obb files associated with the package * @see #setPackageObbPaths(String, String[]) */ public abstract void setPackageObbPath(String packageName, String path); public abstract String[] getPackageObbPaths(String packageName); } core/tests/coretests/src/android/content/pm/PackageManagerTests.java +159 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.util.Log; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; public class PackageManagerTests extends AndroidTestCase { private static final boolean localLOGV = true; Loading Loading @@ -2838,6 +2839,164 @@ public class PackageManagerTests extends AndroidTestCase { installFromRawResource("install.apk", rapk2, PackageManager.INSTALL_REPLACE_EXISTING, true, fail, retCode, PackageInfo.INSTALL_LOCATION_UNSPECIFIED); } @LargeTest public void testPackageObbPaths_Nonexistent() { try { final PackageManager pm = getPm(); // Invalid Java package name. pm.getPackageObbPaths("=non-existent"); fail("Should not be able to get package OBB paths for non-existent package"); } catch (IllegalArgumentException e) { // pass } } @LargeTest public void testPackageObbPaths_Initial() { InstallParams ip = sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, false); try { final PackageManager pm = getPm(); assertEquals("Initial obb paths should be null", null, pm.getPackageObbPaths(ip.pkg.packageName)); } finally { cleanUpInstall(ip); } } @LargeTest public void testPackageObbPaths_Null() { InstallParams ip = sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, false); try { final PackageManager pm = getPm(); pm.setPackageObbPaths(ip.pkg.packageName, null); assertEquals("Returned paths should be null", null, pm.getPackageObbPaths(ip.pkg.packageName)); } finally { cleanUpInstall(ip); } } @LargeTest public void testPackageObbPaths_Empty() { InstallParams ip = sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, false); try { final PackageManager pm = getPm(); final String[] paths = new String[0]; pm.setPackageObbPaths(ip.pkg.packageName, paths); assertEquals("Empty list should be interpreted as null", null, pm.getPackageObbPaths(ip.pkg.packageName)); } finally { cleanUpInstall(ip); } } @LargeTest public void testPackageObbPaths_Single() { InstallParams ip = sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, false); try { final PackageManager pm = getPm(); final String[] paths = new String[] { "/example/test", }; pm.setPackageObbPaths(ip.pkg.packageName, paths.clone()); assertTrue("Previously set paths should be the same as the returned paths.", Arrays.equals(paths, pm.getPackageObbPaths(ip.pkg.packageName))); } finally { cleanUpInstall(ip); } } @LargeTest public void testPackageObbPaths_Multiple() { InstallParams ip = sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, false); try { final PackageManager pm = getPm(); final String[] paths = new String[] { "/example/test1", "/example/test2", }; pm.setPackageObbPaths(ip.pkg.packageName, paths.clone()); assertTrue("Previously set paths should be the same as the returned paths.", Arrays.equals(paths, pm.getPackageObbPaths(ip.pkg.packageName))); } finally { cleanUpInstall(ip); } } @LargeTest public void testPackageObbPaths_Twice() { InstallParams ip = sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, false); try { final PackageManager pm = getPm(); final String[] paths = new String[] { "/example/test1", "/example/test2", }; pm.setPackageObbPaths(ip.pkg.packageName, paths.clone()); assertTrue("Previously set paths should be the same as the returned paths.", Arrays.equals(paths, pm.getPackageObbPaths(ip.pkg.packageName))); paths[0] = "/example/test3"; pm.setPackageObbPaths(ip.pkg.packageName, paths.clone()); assertTrue("Previously set paths should be the same as the returned paths.", Arrays.equals(paths, pm.getPackageObbPaths(ip.pkg.packageName))); } finally { cleanUpInstall(ip); } } @LargeTest public void testPackageObbPaths_ReplacePackage() { InstallParams ip = sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, false); try { final PackageManager pm = getPm(); final String[] paths = new String[] { "/example/test1", "/example/test2", }; pm.setPackageObbPaths(ip.pkg.packageName, paths.clone()); Log.i(TAG, "Creating replaceReceiver"); final GenericReceiver receiver = new ReplaceReceiver(ip.pkg.packageName); final int flags = PackageManager.INSTALL_REPLACE_EXISTING; invokeInstallPackage(ip.packageURI, flags, receiver); assertInstall(ip.pkg, flags, ip.pkg.installLocation); assertTrue("Previously set paths should be the same as the returned paths.", Arrays.equals(paths, pm.getPackageObbPaths(ip.pkg.packageName))); } finally { cleanUpInstall(ip); } } /*---------- Recommended install location tests ----*/ /* * TODO's Loading Loading
api/current.xml +56 −0 Original line number Diff line number Diff line Loading @@ -45952,6 +45952,19 @@ <exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException"> </exception> </method> <method name="getPackageObbPaths" return="java.lang.String[]" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="packageName" type="java.lang.String"> </parameter> </method> <method name="getPackagesForUid" return="java.lang.String[]" abstract="true" Loading Loading @@ -46423,6 +46436,21 @@ <parameter name="flags" type="int"> </parameter> </method> <method name="setPackageObbPaths" return="void" abstract="true" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="packageName" type="java.lang.String"> </parameter> <parameter name="paths" type="java.lang.String[]"> </parameter> </method> <field name="COMPONENT_ENABLED_STATE_DEFAULT" type="int" transient="false" Loading Loading @@ -159105,6 +159133,19 @@ <exception name="PackageManager.NameNotFoundException" type="android.content.pm.PackageManager.NameNotFoundException"> </exception> </method> <method name="getPackageObbPaths" return="java.lang.String[]" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="packageName" type="java.lang.String"> </parameter> </method> <method name="getPackagesForUid" return="java.lang.String[]" abstract="false" Loading Loading @@ -159589,6 +159630,21 @@ <parameter name="path" type="java.lang.String"> </parameter> </method> <method name="setPackageObbPaths" return="void" abstract="false" native="false" synchronized="false" static="false" final="false" deprecated="not deprecated" visibility="public" > <parameter name="packageName" type="java.lang.String"> </parameter> <parameter name="paths" type="java.lang.String[]"> </parameter> </method> </class> <class name="MockResources" extends="android.content.res.Resources"
core/java/android/app/ContextImpl.java +12 −2 Original line number Diff line number Diff line Loading @@ -2700,14 +2700,24 @@ class ContextImpl extends Context { } @Override public void setPackageObbPath(String packageName, String path) { public void setPackageObbPaths(String packageName, String[] paths) { try { mPM.setPackageObbPath(packageName, path); mPM.setPackageObbPaths(packageName, paths); } catch (RemoteException e) { // Should never happen! } } @Override public String[] getPackageObbPaths(String packageName) { try { return mPM.getPackageObbPaths(packageName); } catch (RemoteException e) { // Should never happen! } return null; } private final ContextImpl mContext; private final IPackageManager mPM; Loading
core/java/android/content/pm/IPackageManager.aidl +2 −1 Original line number Diff line number Diff line Loading @@ -322,5 +322,6 @@ interface IPackageManager { boolean setInstallLocation(int loc); int getInstallLocation(); void setPackageObbPath(String packageName, String path); void setPackageObbPaths(in String packageName, in String[] paths); String[] getPackageObbPaths(in String packageName); }
core/java/android/content/pm/PackageManager.java +20 −5 Original line number Diff line number Diff line Loading @@ -2273,15 +2273,30 @@ public abstract class PackageManager { String packageName, IPackageMoveObserver observer, int flags); /** * Sets the Opaque Binary Blob (OBB) file location. * Sets the Opaque Binary Blob (OBB) file path associated with a package * name. The caller must have the * {@link android.Manifest.permission#INSTALL_PACKAGES} permission. * <p> * NOTE: The existence or format of this file is not currently checked, but * it may be in the future. * * @param packageName Name of the package with which to associate the .obb * file * @param path Path on the filesystem to the .obb file * @hide * file. * @param paths Arrays of paths on the filesystem to the .obb files * associated with the package. * @see #getPackageObbPaths(String) */ public abstract void setPackageObbPaths(String packageName, String[] paths); /** * Gets the Opaque Binary Blob (OBB) file path associated with the package. * The caller must be the owner of the package queried or have the * {@link android.Manifest.permission#INSTALL_PACKAGES} permission. * * @param packageName Name of the package with which to associate the .obb * file. * @return array of paths to .obb files associated with the package * @see #setPackageObbPaths(String, String[]) */ public abstract void setPackageObbPath(String packageName, String path); public abstract String[] getPackageObbPaths(String packageName); }
core/tests/coretests/src/android/content/pm/PackageManagerTests.java +159 −0 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ import android.util.Log; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.util.Arrays; public class PackageManagerTests extends AndroidTestCase { private static final boolean localLOGV = true; Loading Loading @@ -2838,6 +2839,164 @@ public class PackageManagerTests extends AndroidTestCase { installFromRawResource("install.apk", rapk2, PackageManager.INSTALL_REPLACE_EXISTING, true, fail, retCode, PackageInfo.INSTALL_LOCATION_UNSPECIFIED); } @LargeTest public void testPackageObbPaths_Nonexistent() { try { final PackageManager pm = getPm(); // Invalid Java package name. pm.getPackageObbPaths("=non-existent"); fail("Should not be able to get package OBB paths for non-existent package"); } catch (IllegalArgumentException e) { // pass } } @LargeTest public void testPackageObbPaths_Initial() { InstallParams ip = sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, false); try { final PackageManager pm = getPm(); assertEquals("Initial obb paths should be null", null, pm.getPackageObbPaths(ip.pkg.packageName)); } finally { cleanUpInstall(ip); } } @LargeTest public void testPackageObbPaths_Null() { InstallParams ip = sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, false); try { final PackageManager pm = getPm(); pm.setPackageObbPaths(ip.pkg.packageName, null); assertEquals("Returned paths should be null", null, pm.getPackageObbPaths(ip.pkg.packageName)); } finally { cleanUpInstall(ip); } } @LargeTest public void testPackageObbPaths_Empty() { InstallParams ip = sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, false); try { final PackageManager pm = getPm(); final String[] paths = new String[0]; pm.setPackageObbPaths(ip.pkg.packageName, paths); assertEquals("Empty list should be interpreted as null", null, pm.getPackageObbPaths(ip.pkg.packageName)); } finally { cleanUpInstall(ip); } } @LargeTest public void testPackageObbPaths_Single() { InstallParams ip = sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, false); try { final PackageManager pm = getPm(); final String[] paths = new String[] { "/example/test", }; pm.setPackageObbPaths(ip.pkg.packageName, paths.clone()); assertTrue("Previously set paths should be the same as the returned paths.", Arrays.equals(paths, pm.getPackageObbPaths(ip.pkg.packageName))); } finally { cleanUpInstall(ip); } } @LargeTest public void testPackageObbPaths_Multiple() { InstallParams ip = sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, false); try { final PackageManager pm = getPm(); final String[] paths = new String[] { "/example/test1", "/example/test2", }; pm.setPackageObbPaths(ip.pkg.packageName, paths.clone()); assertTrue("Previously set paths should be the same as the returned paths.", Arrays.equals(paths, pm.getPackageObbPaths(ip.pkg.packageName))); } finally { cleanUpInstall(ip); } } @LargeTest public void testPackageObbPaths_Twice() { InstallParams ip = sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, false); try { final PackageManager pm = getPm(); final String[] paths = new String[] { "/example/test1", "/example/test2", }; pm.setPackageObbPaths(ip.pkg.packageName, paths.clone()); assertTrue("Previously set paths should be the same as the returned paths.", Arrays.equals(paths, pm.getPackageObbPaths(ip.pkg.packageName))); paths[0] = "/example/test3"; pm.setPackageObbPaths(ip.pkg.packageName, paths.clone()); assertTrue("Previously set paths should be the same as the returned paths.", Arrays.equals(paths, pm.getPackageObbPaths(ip.pkg.packageName))); } finally { cleanUpInstall(ip); } } @LargeTest public void testPackageObbPaths_ReplacePackage() { InstallParams ip = sampleInstallFromRawResource(PackageManager.INSTALL_INTERNAL, false); try { final PackageManager pm = getPm(); final String[] paths = new String[] { "/example/test1", "/example/test2", }; pm.setPackageObbPaths(ip.pkg.packageName, paths.clone()); Log.i(TAG, "Creating replaceReceiver"); final GenericReceiver receiver = new ReplaceReceiver(ip.pkg.packageName); final int flags = PackageManager.INSTALL_REPLACE_EXISTING; invokeInstallPackage(ip.packageURI, flags, receiver); assertInstall(ip.pkg, flags, ip.pkg.installLocation); assertTrue("Previously set paths should be the same as the returned paths.", Arrays.equals(paths, pm.getPackageObbPaths(ip.pkg.packageName))); } finally { cleanUpInstall(ip); } } /*---------- Recommended install location tests ----*/ /* * TODO's Loading