Merge "Grant URI permissions to the MCS" into gingerbread
This commit is contained in:
@@ -186,9 +186,11 @@ class PackageManagerService extends IPackageManager.Stub {
|
|||||||
static final int SCAN_UPDATE_TIME = 1<<6;
|
static final int SCAN_UPDATE_TIME = 1<<6;
|
||||||
|
|
||||||
static final int REMOVE_CHATTY = 1<<16;
|
static final int REMOVE_CHATTY = 1<<16;
|
||||||
|
|
||||||
|
static final String DEFAULT_CONTAINER_PACKAGE = "com.android.defcontainer";
|
||||||
|
|
||||||
static final ComponentName DEFAULT_CONTAINER_COMPONENT = new ComponentName(
|
static final ComponentName DEFAULT_CONTAINER_COMPONENT = new ComponentName(
|
||||||
"com.android.defcontainer",
|
DEFAULT_CONTAINER_PACKAGE,
|
||||||
"com.android.defcontainer.DefaultContainerService");
|
"com.android.defcontainer.DefaultContainerService");
|
||||||
|
|
||||||
private static final String LIB_DIR_NAME = "lib";
|
private static final String LIB_DIR_NAME = "lib";
|
||||||
@@ -4774,7 +4776,15 @@ class PackageManagerService extends IPackageManager.Stub {
|
|||||||
ret = PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION;
|
ret = PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION;
|
||||||
} else {
|
} else {
|
||||||
// Remote call to find out default install location
|
// Remote call to find out default install location
|
||||||
PackageInfoLite pkgLite = mContainerService.getMinimalPackageInfo(packageURI, flags);
|
final PackageInfoLite pkgLite;
|
||||||
|
try {
|
||||||
|
mContext.grantUriPermission(DEFAULT_CONTAINER_PACKAGE, packageURI,
|
||||||
|
Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
pkgLite = mContainerService.getMinimalPackageInfo(packageURI, flags);
|
||||||
|
} finally {
|
||||||
|
mContext.revokeUriPermission(packageURI, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
}
|
||||||
|
|
||||||
int loc = pkgLite.recommendedInstallLocation;
|
int loc = pkgLite.recommendedInstallLocation;
|
||||||
if (loc == PackageHelper.RECOMMEND_FAILED_INVALID_LOCATION){
|
if (loc == PackageHelper.RECOMMEND_FAILED_INVALID_LOCATION){
|
||||||
ret = PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION;
|
ret = PackageManager.INSTALL_FAILED_INVALID_INSTALL_LOCATION;
|
||||||
@@ -4989,8 +4999,14 @@ class PackageManagerService extends IPackageManager.Stub {
|
|||||||
libraryPath = new File(dataDir, LIB_DIR_NAME).getPath();
|
libraryPath = new File(dataDir, LIB_DIR_NAME).getPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean checkFreeStorage(IMediaContainerService imcs) throws RemoteException {
|
boolean checkFreeStorage(IMediaContainerService imcs) throws RemoteException {
|
||||||
return imcs.checkFreeStorage(false, packageURI);
|
try {
|
||||||
|
mContext.grantUriPermission(DEFAULT_CONTAINER_PACKAGE, packageURI,
|
||||||
|
Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
return imcs.checkFreeStorage(false, packageURI);
|
||||||
|
} finally {
|
||||||
|
mContext.revokeUriPermission(packageURI, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String getCodePath() {
|
String getCodePath() {
|
||||||
@@ -5034,11 +5050,14 @@ class PackageManagerService extends IPackageManager.Stub {
|
|||||||
// Copy the resource now
|
// Copy the resource now
|
||||||
int ret = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
|
int ret = PackageManager.INSTALL_FAILED_INSUFFICIENT_STORAGE;
|
||||||
try {
|
try {
|
||||||
|
mContext.grantUriPermission(DEFAULT_CONTAINER_PACKAGE, packageURI,
|
||||||
|
Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
if (imcs.copyResource(packageURI, out)) {
|
if (imcs.copyResource(packageURI, out)) {
|
||||||
ret = PackageManager.INSTALL_SUCCEEDED;
|
ret = PackageManager.INSTALL_SUCCEEDED;
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
try { if (out != null) out.close(); } catch (IOException e) {}
|
try { if (out != null) out.close(); } catch (IOException e) {}
|
||||||
|
mContext.revokeUriPermission(packageURI, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
@@ -5209,17 +5228,31 @@ class PackageManagerService extends IPackageManager.Stub {
|
|||||||
cid = getTempContainerId();
|
cid = getTempContainerId();
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean checkFreeStorage(IMediaContainerService imcs) throws RemoteException {
|
boolean checkFreeStorage(IMediaContainerService imcs) throws RemoteException {
|
||||||
return imcs.checkFreeStorage(true, packageURI);
|
try {
|
||||||
|
mContext.grantUriPermission(DEFAULT_CONTAINER_PACKAGE, packageURI,
|
||||||
|
Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
return imcs.checkFreeStorage(true, packageURI);
|
||||||
|
} finally {
|
||||||
|
mContext.revokeUriPermission(packageURI, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int copyApk(IMediaContainerService imcs, boolean temp) throws RemoteException {
|
int copyApk(IMediaContainerService imcs, boolean temp) throws RemoteException {
|
||||||
if (temp) {
|
if (temp) {
|
||||||
createCopyFile();
|
createCopyFile();
|
||||||
}
|
}
|
||||||
String newCachePath = imcs.copyResourceToContainer(
|
|
||||||
packageURI, cid,
|
final String newCachePath;
|
||||||
getEncryptKey(), RES_FILE_NAME);
|
try {
|
||||||
|
mContext.grantUriPermission(DEFAULT_CONTAINER_PACKAGE, packageURI,
|
||||||
|
Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
newCachePath = imcs.copyResourceToContainer(packageURI, cid,
|
||||||
|
getEncryptKey(), RES_FILE_NAME);
|
||||||
|
} finally {
|
||||||
|
mContext.revokeUriPermission(packageURI, Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||||
|
}
|
||||||
|
|
||||||
if (newCachePath != null) {
|
if (newCachePath != null) {
|
||||||
setCachePath(newCachePath);
|
setCachePath(newCachePath);
|
||||||
return PackageManager.INSTALL_SUCCEEDED;
|
return PackageManager.INSTALL_SUCCEEDED;
|
||||||
|
|||||||
Reference in New Issue
Block a user