Merge "OBB API for PackageManager" into gingerbread
This commit is contained in:
@ -154519,6 +154519,21 @@
|
||||
<parameter name="flags" type="int">
|
||||
</parameter>
|
||||
</method>
|
||||
<method name="setPackageObbPath"
|
||||
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="path" type="java.lang.String">
|
||||
</parameter>
|
||||
</method>
|
||||
</class>
|
||||
<class name="MockResources"
|
||||
extends="android.content.res.Resources"
|
||||
|
@ -2657,6 +2657,15 @@ class ContextImpl extends Context {
|
||||
return PackageManager.COMPONENT_ENABLED_STATE_DEFAULT;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPackageObbPath(String packageName, String path) {
|
||||
try {
|
||||
mPM.setPackageObbPath(packageName, path);
|
||||
} catch (RemoteException e) {
|
||||
// Should never happen!
|
||||
}
|
||||
}
|
||||
|
||||
private final ContextImpl mContext;
|
||||
private final IPackageManager mPM;
|
||||
|
||||
|
@ -319,4 +319,6 @@ interface IPackageManager {
|
||||
|
||||
boolean setInstallLocation(int loc);
|
||||
int getInstallLocation();
|
||||
|
||||
void setPackageObbPath(String packageName, String path);
|
||||
}
|
||||
|
@ -2193,4 +2193,17 @@ public abstract class PackageManager {
|
||||
*/
|
||||
public abstract void movePackage(
|
||||
String packageName, IPackageMoveObserver observer, int flags);
|
||||
|
||||
/**
|
||||
* Sets the Opaque Binary Blob (OBB) file location.
|
||||
* <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
|
||||
*/
|
||||
public abstract void setPackageObbPath(String packageName, String path);
|
||||
}
|
||||
|
@ -4583,6 +4583,8 @@ class PackageManagerService extends IPackageManager.Stub {
|
||||
}
|
||||
};
|
||||
|
||||
private static final boolean DEBUG_OBB = false;
|
||||
|
||||
private static final void sendPackageBroadcast(String action, String pkg,
|
||||
Bundle extras, IIntentReceiver finishedReceiver) {
|
||||
IActivityManager am = ActivityManagerNative.getDefault();
|
||||
@ -4757,6 +4759,27 @@ class PackageManagerService extends IPackageManager.Stub {
|
||||
mHandler.sendMessage(msg);
|
||||
}
|
||||
|
||||
public void setPackageObbPath(String packageName, String path) {
|
||||
if (DEBUG_OBB)
|
||||
Log.v(TAG, "Setting .obb path for " + packageName + " to: " + path);
|
||||
PackageSetting pkgSetting;
|
||||
final int uid = Binder.getCallingUid();
|
||||
boolean allowedByPermission = false;
|
||||
synchronized (mPackages) {
|
||||
pkgSetting = mSettings.mPackages.get(packageName);
|
||||
if (pkgSetting == null) {
|
||||
throw new IllegalArgumentException("Unknown package: " + packageName);
|
||||
}
|
||||
if (!allowedByPermission && (uid != pkgSetting.userId)) {
|
||||
throw new SecurityException("Permission denial: attempt to set .obb file from pid="
|
||||
+ Binder.getCallingPid() + ", uid=" + uid + ", package uid="
|
||||
+ pkgSetting.userId);
|
||||
}
|
||||
pkgSetting.obbPathString = path;
|
||||
mSettings.writeLP();
|
||||
}
|
||||
}
|
||||
|
||||
private void processPendingInstall(final InstallArgs args, final int currentStatus) {
|
||||
// Queue up an async operation since the package installation may take a little while.
|
||||
mHandler.post(new Runnable() {
|
||||
@ -7118,6 +7141,7 @@ class PackageManagerService extends IPackageManager.Stub {
|
||||
pw.print(" pkg="); pw.println(ps.pkg);
|
||||
pw.print(" codePath="); pw.println(ps.codePathString);
|
||||
pw.print(" resourcePath="); pw.println(ps.resourcePathString);
|
||||
pw.print(" obbPath="); pw.println(ps.obbPathString);
|
||||
if (ps.pkg != null) {
|
||||
pw.print(" dataDir="); pw.println(ps.pkg.applicationInfo.dataDir);
|
||||
pw.print(" targetSdk="); pw.println(ps.pkg.applicationInfo.targetSdkVersion);
|
||||
@ -7684,6 +7708,7 @@ class PackageManagerService extends IPackageManager.Stub {
|
||||
String codePathString;
|
||||
File resourcePath;
|
||||
String resourcePathString;
|
||||
String obbPathString;
|
||||
private long timeStamp;
|
||||
private String timeStampString = "0";
|
||||
int versionCode;
|
||||
@ -8684,6 +8709,9 @@ class PackageManagerService extends IPackageManager.Stub {
|
||||
if (pkg.installerPackageName != null) {
|
||||
serializer.attribute(null, "installer", pkg.installerPackageName);
|
||||
}
|
||||
if (pkg.obbPathString != null) {
|
||||
serializer.attribute(null, "obbPath", pkg.obbPathString);
|
||||
}
|
||||
pkg.signatures.writeXml(serializer, "sigs", mPastSignatures);
|
||||
if ((pkg.pkgFlags&ApplicationInfo.FLAG_SYSTEM) == 0) {
|
||||
serializer.startTag(null, "perms");
|
||||
@ -9060,6 +9088,7 @@ class PackageManagerService extends IPackageManager.Stub {
|
||||
String sharedIdStr = null;
|
||||
String codePathStr = null;
|
||||
String resourcePathStr = null;
|
||||
String obbPathStr = null;
|
||||
String systemStr = null;
|
||||
String installerPackageName = null;
|
||||
String uidError = null;
|
||||
@ -9077,6 +9106,7 @@ class PackageManagerService extends IPackageManager.Stub {
|
||||
sharedIdStr = parser.getAttributeValue(null, "sharedUserId");
|
||||
codePathStr = parser.getAttributeValue(null, "codePath");
|
||||
resourcePathStr = parser.getAttributeValue(null, "resourcePath");
|
||||
obbPathStr = parser.getAttributeValue(null, "obbPath");
|
||||
version = parser.getAttributeValue(null, "version");
|
||||
if (version != null) {
|
||||
try {
|
||||
@ -9174,6 +9204,7 @@ class PackageManagerService extends IPackageManager.Stub {
|
||||
if (packageSetting != null) {
|
||||
packageSetting.uidError = "true".equals(uidError);
|
||||
packageSetting.installerPackageName = installerPackageName;
|
||||
packageSetting.obbPathString = obbPathStr;
|
||||
final String enabledStr = parser.getAttributeValue(null, "enabled");
|
||||
if (enabledStr != null) {
|
||||
if (enabledStr.equalsIgnoreCase("true")) {
|
||||
|
@ -483,4 +483,9 @@ public class MockPackageManager extends PackageManager {
|
||||
public boolean isSafeMode() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPackageObbPath(String packageName, String path) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user