* commit '9e289d70a8baaed0030413b5991653792e2a816d': System services detect and register app CPU ABIs
This commit is contained in:
@@ -446,6 +446,15 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
|
||||
*/
|
||||
public String nativeLibraryDir;
|
||||
|
||||
/**
|
||||
* The ABI that this application requires, This is inferred from the ABIs
|
||||
* of the native JNI libraries the application bundles. Will be {@code null}
|
||||
* if this application does not require any particular ABI.
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
public String requiredCpuAbi;
|
||||
|
||||
/**
|
||||
* The kernel user-ID that has been assigned to this application;
|
||||
* currently this is not a unique ID (multiple applications can have
|
||||
@@ -583,6 +592,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
|
||||
sourceDir = orig.sourceDir;
|
||||
publicSourceDir = orig.publicSourceDir;
|
||||
nativeLibraryDir = orig.nativeLibraryDir;
|
||||
requiredCpuAbi = orig.requiredCpuAbi;
|
||||
resourceDirs = orig.resourceDirs;
|
||||
seinfo = orig.seinfo;
|
||||
sharedLibraryFiles = orig.sharedLibraryFiles;
|
||||
@@ -624,6 +634,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
|
||||
dest.writeString(sourceDir);
|
||||
dest.writeString(publicSourceDir);
|
||||
dest.writeString(nativeLibraryDir);
|
||||
dest.writeString(requiredCpuAbi);
|
||||
dest.writeStringArray(resourceDirs);
|
||||
dest.writeString(seinfo);
|
||||
dest.writeStringArray(sharedLibraryFiles);
|
||||
@@ -664,6 +675,7 @@ public class ApplicationInfo extends PackageItemInfo implements Parcelable {
|
||||
sourceDir = source.readString();
|
||||
publicSourceDir = source.readString();
|
||||
nativeLibraryDir = source.readString();
|
||||
requiredCpuAbi = source.readString();
|
||||
resourceDirs = source.readStringArray();
|
||||
seinfo = source.readString();
|
||||
sharedLibraryFiles = source.readStringArray();
|
||||
|
||||
@@ -466,6 +466,7 @@ public class Process {
|
||||
* @param debugFlags Additional flags.
|
||||
* @param targetSdkVersion The target SDK version for the app.
|
||||
* @param seInfo null-ok SELinux information for the new process.
|
||||
* @param abi non-null the ABI this app should be started with.
|
||||
* @param zygoteArgs Additional arguments to supply to the zygote process.
|
||||
*
|
||||
* @return An object that describes the result of the attempt to start the process.
|
||||
@@ -479,12 +480,12 @@ public class Process {
|
||||
int debugFlags, int mountExternal,
|
||||
int targetSdkVersion,
|
||||
String seInfo,
|
||||
String abi,
|
||||
String[] zygoteArgs) {
|
||||
try {
|
||||
return startViaZygote(processClass, niceName, uid, gid, gids,
|
||||
debugFlags, mountExternal, targetSdkVersion, seInfo,
|
||||
null, /* zygoteAbi TODO: Replace this with the real ABI */
|
||||
zygoteArgs);
|
||||
abi, zygoteArgs);
|
||||
} catch (ZygoteStartFailedEx ex) {
|
||||
Log.e(LOG_TAG,
|
||||
"Starting VM process through Zygote failed");
|
||||
@@ -702,13 +703,6 @@ public class Process {
|
||||
primaryZygoteState = ZygoteState.connect(ZYGOTE_SOCKET, getNumTries(primaryZygoteState));
|
||||
}
|
||||
|
||||
// TODO: Revert this temporary change. This is required to test
|
||||
// and submit this change ahead of the package manager changes
|
||||
// that supply this abi.
|
||||
if (abi == null) {
|
||||
return primaryZygoteState;
|
||||
}
|
||||
|
||||
if (primaryZygoteState.matches(abi)) {
|
||||
return primaryZygoteState;
|
||||
}
|
||||
|
||||
@@ -2756,11 +2756,16 @@ public final class ActivityManagerService extends ActivityManagerNative
|
||||
debugFlags |= Zygote.DEBUG_ENABLE_ASSERT;
|
||||
}
|
||||
|
||||
String requiredAbi = app.info.requiredCpuAbi;
|
||||
if (requiredAbi == null) {
|
||||
requiredAbi = Build.SUPPORTED_ABIS[0];
|
||||
}
|
||||
|
||||
// Start the process. It will either succeed and return a result containing
|
||||
// the PID of the new process, or else throw a RuntimeException.
|
||||
Process.ProcessStartResult startResult = Process.start("android.app.ActivityThread",
|
||||
app.processName, uid, uid, gids, debugFlags, mountExternal,
|
||||
app.info.targetSdkVersion, app.info.seinfo, null);
|
||||
app.info.targetSdkVersion, app.info.seinfo, requiredAbi, null);
|
||||
|
||||
BatteryStatsImpl bs = mBatteryStatsService.getActiveStatistics();
|
||||
synchronized (bs) {
|
||||
|
||||
@@ -2054,6 +2054,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
pkg.applicationInfo.dataDir =
|
||||
getDataPathForPackage(packageName, 0).getPath();
|
||||
pkg.applicationInfo.nativeLibraryDir = ps.nativeLibraryPathString;
|
||||
pkg.applicationInfo.requiredCpuAbi = ps.requiredCpuAbiString;
|
||||
}
|
||||
return generatePackageInfo(pkg, flags, userId);
|
||||
}
|
||||
@@ -3994,6 +3995,8 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
codePath = pkg.mScanPath;
|
||||
// Set application objects path explicitly.
|
||||
setApplicationInfoPaths(pkg, codePath, resPath);
|
||||
// Applications can run with the primary Cpu Abi unless otherwise is specified
|
||||
pkg.applicationInfo.requiredCpuAbi = null;
|
||||
// Note that we invoke the following method only if we are about to unpack an application
|
||||
PackageParser.Package scannedPkg = scanPackageLI(pkg, parseFlags, scanMode
|
||||
| SCAN_UPDATE_SIGNATURE, currentTime, user);
|
||||
@@ -4565,6 +4568,7 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
// the PkgSetting exists already and doesn't have to be created.
|
||||
pkgSetting = mSettings.getPackageLPw(pkg, origPackage, realName, suid, destCodeFile,
|
||||
destResourceFile, pkg.applicationInfo.nativeLibraryDir,
|
||||
pkg.applicationInfo.requiredCpuAbi,
|
||||
pkg.applicationInfo.flags, user, false);
|
||||
if (pkgSetting == null) {
|
||||
Slog.w(TAG, "Creating application package " + pkg.packageName + " failed");
|
||||
@@ -4876,6 +4880,14 @@ public class PackageManagerService extends IPackageManager.Stub {
|
||||
mLastScanError = PackageManager.INSTALL_FAILED_INTERNAL_ERROR;
|
||||
return null;
|
||||
}
|
||||
|
||||
// We've successfully copied native libraries across, so we make a
|
||||
// note of what ABI we're using
|
||||
if (copyRet != PackageManager.NO_NATIVE_LIBRARIES) {
|
||||
pkg.applicationInfo.requiredCpuAbi = Build.SUPPORTED_ABIS[copyRet];
|
||||
} else {
|
||||
pkg.applicationInfo.requiredCpuAbi = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
Slog.e(TAG, "Unable to copy native libraries", e);
|
||||
mLastScanError = PackageManager.INSTALL_FAILED_INTERNAL_ERROR;
|
||||
|
||||
@@ -30,8 +30,8 @@ final class PackageSetting extends PackageSettingBase {
|
||||
SharedUserSetting sharedUser;
|
||||
|
||||
PackageSetting(String name, String realName, File codePath, File resourcePath,
|
||||
String nativeLibraryPathString, int pVersionCode, int pkgFlags) {
|
||||
super(name, realName, codePath, resourcePath, nativeLibraryPathString, pVersionCode,
|
||||
String nativeLibraryPathString, String requiredCpuAbiString, int pVersionCode, int pkgFlags) {
|
||||
super(name, realName, codePath, resourcePath, nativeLibraryPathString, requiredCpuAbiString, pVersionCode,
|
||||
pkgFlags);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@ class PackageSettingBase extends GrantedPermissions {
|
||||
File resourcePath;
|
||||
String resourcePathString;
|
||||
String nativeLibraryPathString;
|
||||
String requiredCpuAbiString;
|
||||
long timeStamp;
|
||||
long firstInstallTime;
|
||||
long lastUpdateTime;
|
||||
@@ -77,11 +78,11 @@ class PackageSettingBase extends GrantedPermissions {
|
||||
/* package name of the app that installed this package */
|
||||
String installerPackageName;
|
||||
PackageSettingBase(String name, String realName, File codePath, File resourcePath,
|
||||
String nativeLibraryPathString, int pVersionCode, int pkgFlags) {
|
||||
String nativeLibraryPathString, String requiredCpuAbiString, int pVersionCode, int pkgFlags) {
|
||||
super(pkgFlags);
|
||||
this.name = name;
|
||||
this.realName = realName;
|
||||
init(codePath, resourcePath, nativeLibraryPathString, pVersionCode);
|
||||
init(codePath, resourcePath, nativeLibraryPathString, requiredCpuAbiString, pVersionCode);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -98,6 +99,7 @@ class PackageSettingBase extends GrantedPermissions {
|
||||
resourcePath = base.resourcePath;
|
||||
resourcePathString = base.resourcePathString;
|
||||
nativeLibraryPathString = base.nativeLibraryPathString;
|
||||
requiredCpuAbiString = base.requiredCpuAbiString;
|
||||
timeStamp = base.timeStamp;
|
||||
firstInstallTime = base.firstInstallTime;
|
||||
lastUpdateTime = base.lastUpdateTime;
|
||||
@@ -125,12 +127,13 @@ class PackageSettingBase extends GrantedPermissions {
|
||||
}
|
||||
|
||||
void init(File codePath, File resourcePath, String nativeLibraryPathString,
|
||||
int pVersionCode) {
|
||||
String requiredCpuAbiString, int pVersionCode) {
|
||||
this.codePath = codePath;
|
||||
this.codePathString = codePath.toString();
|
||||
this.resourcePath = resourcePath;
|
||||
this.resourcePathString = resourcePath.toString();
|
||||
this.nativeLibraryPathString = nativeLibraryPathString;
|
||||
this.requiredCpuAbiString = requiredCpuAbiString;
|
||||
this.versionCode = pVersionCode;
|
||||
}
|
||||
|
||||
@@ -161,6 +164,7 @@ class PackageSettingBase extends GrantedPermissions {
|
||||
grantedPermissions = base.grantedPermissions;
|
||||
gids = base.gids;
|
||||
|
||||
requiredCpuAbiString = base.requiredCpuAbiString;
|
||||
timeStamp = base.timeStamp;
|
||||
firstInstallTime = base.firstInstallTime;
|
||||
lastUpdateTime = base.lastUpdateTime;
|
||||
|
||||
@@ -22,8 +22,8 @@ final class PendingPackage extends PackageSettingBase {
|
||||
final int sharedId;
|
||||
|
||||
PendingPackage(String name, String realName, File codePath, File resourcePath,
|
||||
String nativeLibraryPathString, int sharedId, int pVersionCode, int pkgFlags) {
|
||||
super(name, realName, codePath, resourcePath, nativeLibraryPathString, pVersionCode,
|
||||
String nativeLibraryPathString, String requiredCpuAbiString, int sharedId, int pVersionCode, int pkgFlags) {
|
||||
super(name, realName, codePath, resourcePath, nativeLibraryPathString, requiredCpuAbiString, pVersionCode,
|
||||
pkgFlags);
|
||||
this.sharedId = sharedId;
|
||||
}
|
||||
|
||||
@@ -217,10 +217,10 @@ final class Settings {
|
||||
|
||||
PackageSetting getPackageLPw(PackageParser.Package pkg, PackageSetting origPackage,
|
||||
String realName, SharedUserSetting sharedUser, File codePath, File resourcePath,
|
||||
String nativeLibraryPathString, int pkgFlags, UserHandle user, boolean add) {
|
||||
String nativeLibraryPathString, String requiredCpuAbiString, int pkgFlags, UserHandle user, boolean add) {
|
||||
final String name = pkg.packageName;
|
||||
PackageSetting p = getPackageLPw(name, origPackage, realName, sharedUser, codePath,
|
||||
resourcePath, nativeLibraryPathString, pkg.mVersionCode, pkgFlags,
|
||||
resourcePath, nativeLibraryPathString, requiredCpuAbiString, pkg.mVersionCode, pkgFlags,
|
||||
user, add, true /* allowInstall */);
|
||||
return p;
|
||||
}
|
||||
@@ -302,7 +302,7 @@ final class Settings {
|
||||
p.pkg.applicationInfo.flags &= ~ApplicationInfo.FLAG_UPDATED_SYSTEM_APP;
|
||||
}
|
||||
PackageSetting ret = addPackageLPw(name, p.realName, p.codePath, p.resourcePath,
|
||||
p.nativeLibraryPathString, p.appId, p.versionCode, p.pkgFlags);
|
||||
p.nativeLibraryPathString, p.requiredCpuAbiString, p.appId, p.versionCode, p.pkgFlags);
|
||||
mDisabledSysPackages.remove(name);
|
||||
return ret;
|
||||
}
|
||||
@@ -316,7 +316,7 @@ final class Settings {
|
||||
}
|
||||
|
||||
PackageSetting addPackageLPw(String name, String realName, File codePath, File resourcePath,
|
||||
String nativeLibraryPathString, int uid, int vc, int pkgFlags) {
|
||||
String nativeLibraryPathString, String requiredCpuAbiString, int uid, int vc, int pkgFlags) {
|
||||
PackageSetting p = mPackages.get(name);
|
||||
if (p != null) {
|
||||
if (p.appId == uid) {
|
||||
@@ -326,7 +326,7 @@ final class Settings {
|
||||
"Adding duplicate package, keeping first: " + name);
|
||||
return null;
|
||||
}
|
||||
p = new PackageSetting(name, realName, codePath, resourcePath, nativeLibraryPathString,
|
||||
p = new PackageSetting(name, realName, codePath, resourcePath, nativeLibraryPathString, requiredCpuAbiString,
|
||||
vc, pkgFlags);
|
||||
p.appId = uid;
|
||||
if (addUserIdLPw(uid, p, name)) {
|
||||
@@ -395,10 +395,11 @@ final class Settings {
|
||||
|
||||
private PackageSetting getPackageLPw(String name, PackageSetting origPackage,
|
||||
String realName, SharedUserSetting sharedUser, File codePath, File resourcePath,
|
||||
String nativeLibraryPathString, int vc, int pkgFlags,
|
||||
String nativeLibraryPathString, String requiredCpuAbiString, int vc, int pkgFlags,
|
||||
UserHandle installUser, boolean add, boolean allowInstall) {
|
||||
PackageSetting p = mPackages.get(name);
|
||||
if (p != null) {
|
||||
p.requiredCpuAbiString = requiredCpuAbiString;
|
||||
if (!p.codePath.equals(codePath)) {
|
||||
// Check to see if its a disabled system app
|
||||
if ((p.pkgFlags & ApplicationInfo.FLAG_SYSTEM) != 0) {
|
||||
@@ -442,7 +443,7 @@ final class Settings {
|
||||
if (origPackage != null) {
|
||||
// We are consuming the data from an existing package.
|
||||
p = new PackageSetting(origPackage.name, name, codePath, resourcePath,
|
||||
nativeLibraryPathString, vc, pkgFlags);
|
||||
nativeLibraryPathString, requiredCpuAbiString, vc, pkgFlags);
|
||||
if (PackageManagerService.DEBUG_UPGRADE) Log.v(PackageManagerService.TAG, "Package "
|
||||
+ name + " is adopting original package " + origPackage.name);
|
||||
// Note that we will retain the new package's signature so
|
||||
@@ -459,7 +460,7 @@ final class Settings {
|
||||
p.setTimeStamp(codePath.lastModified());
|
||||
} else {
|
||||
p = new PackageSetting(name, realName, codePath, resourcePath,
|
||||
nativeLibraryPathString, vc, pkgFlags);
|
||||
nativeLibraryPathString, requiredCpuAbiString, vc, pkgFlags);
|
||||
p.setTimeStamp(codePath.lastModified());
|
||||
p.sharedUser = sharedUser;
|
||||
// If this is not a system app, it starts out stopped.
|
||||
@@ -585,6 +586,8 @@ final class Settings {
|
||||
&& !nativeLibraryPath.equalsIgnoreCase(p.nativeLibraryPathString)) {
|
||||
p.nativeLibraryPathString = nativeLibraryPath;
|
||||
}
|
||||
// Update the required Cpu Abi
|
||||
p.requiredCpuAbiString = pkg.applicationInfo.requiredCpuAbi;
|
||||
// Update version code if needed
|
||||
if (pkg.mVersionCode != p.versionCode) {
|
||||
p.versionCode = pkg.mVersionCode;
|
||||
@@ -1551,6 +1554,9 @@ final class Settings {
|
||||
if (pkg.nativeLibraryPathString != null) {
|
||||
serializer.attribute(null, "nativeLibraryPath", pkg.nativeLibraryPathString);
|
||||
}
|
||||
if (pkg.requiredCpuAbiString != null) {
|
||||
serializer.attribute(null, "requiredCpuAbi", pkg.requiredCpuAbiString);
|
||||
}
|
||||
if (pkg.sharedUser == null) {
|
||||
serializer.attribute(null, "userId", Integer.toString(pkg.appId));
|
||||
} else {
|
||||
@@ -1593,6 +1599,9 @@ final class Settings {
|
||||
if (pkg.nativeLibraryPathString != null) {
|
||||
serializer.attribute(null, "nativeLibraryPath", pkg.nativeLibraryPathString);
|
||||
}
|
||||
if (pkg.requiredCpuAbiString != null) {
|
||||
serializer.attribute(null, "requiredCpuAbi", pkg.requiredCpuAbiString);
|
||||
}
|
||||
serializer.attribute(null, "flags", Integer.toString(pkg.pkgFlags));
|
||||
serializer.attribute(null, "ft", Long.toHexString(pkg.timeStamp));
|
||||
serializer.attribute(null, "it", Long.toHexString(pkg.firstInstallTime));
|
||||
@@ -1861,7 +1870,7 @@ final class Settings {
|
||||
if (idObj != null && idObj instanceof SharedUserSetting) {
|
||||
PackageSetting p = getPackageLPw(pp.name, null, pp.realName,
|
||||
(SharedUserSetting) idObj, pp.codePath, pp.resourcePath,
|
||||
pp.nativeLibraryPathString, pp.versionCode, pp.pkgFlags,
|
||||
pp.nativeLibraryPathString, pp.requiredCpuAbiString, pp.versionCode, pp.pkgFlags,
|
||||
null, true /* add */, false /* allowInstall */);
|
||||
if (p == null) {
|
||||
PackageManagerService.reportSettingsProblem(Log.WARN,
|
||||
@@ -2281,6 +2290,8 @@ final class Settings {
|
||||
String codePathStr = parser.getAttributeValue(null, "codePath");
|
||||
String resourcePathStr = parser.getAttributeValue(null, "resourcePath");
|
||||
String nativeLibraryPathStr = parser.getAttributeValue(null, "nativeLibraryPath");
|
||||
String requiredCpuAbiString = parser.getAttributeValue(null, "requiredCpuAbi");
|
||||
|
||||
if (resourcePathStr == null) {
|
||||
resourcePathStr = codePathStr;
|
||||
}
|
||||
@@ -2300,7 +2311,7 @@ final class Settings {
|
||||
pkgFlags |= ApplicationInfo.FLAG_PRIVILEGED;
|
||||
}
|
||||
PackageSetting ps = new PackageSetting(name, realName, codePathFile,
|
||||
new File(resourcePathStr), nativeLibraryPathStr, versionCode, pkgFlags);
|
||||
new File(resourcePathStr), nativeLibraryPathStr, requiredCpuAbiString, versionCode, pkgFlags);
|
||||
String timeStampStr = parser.getAttributeValue(null, "ft");
|
||||
if (timeStampStr != null) {
|
||||
try {
|
||||
@@ -2367,6 +2378,7 @@ final class Settings {
|
||||
String codePathStr = null;
|
||||
String resourcePathStr = null;
|
||||
String nativeLibraryPathStr = null;
|
||||
String requiredCpuAbiString = null;
|
||||
String systemStr = null;
|
||||
String installerPackageName = null;
|
||||
String uidError = null;
|
||||
@@ -2386,6 +2398,8 @@ final class Settings {
|
||||
codePathStr = parser.getAttributeValue(null, "codePath");
|
||||
resourcePathStr = parser.getAttributeValue(null, "resourcePath");
|
||||
nativeLibraryPathStr = parser.getAttributeValue(null, "nativeLibraryPath");
|
||||
requiredCpuAbiString = parser.getAttributeValue(null, "requiredCpuAbi");
|
||||
|
||||
version = parser.getAttributeValue(null, "version");
|
||||
if (version != null) {
|
||||
try {
|
||||
@@ -2462,7 +2476,7 @@ final class Settings {
|
||||
+ parser.getPositionDescription());
|
||||
} else if (userId > 0) {
|
||||
packageSetting = addPackageLPw(name.intern(), realName, new File(codePathStr),
|
||||
new File(resourcePathStr), nativeLibraryPathStr, userId, versionCode,
|
||||
new File(resourcePathStr), nativeLibraryPathStr, requiredCpuAbiString, userId, versionCode,
|
||||
pkgFlags);
|
||||
if (PackageManagerService.DEBUG_SETTINGS)
|
||||
Log.i(PackageManagerService.TAG, "Reading package " + name + ": userId="
|
||||
@@ -2480,7 +2494,7 @@ final class Settings {
|
||||
userId = sharedIdStr != null ? Integer.parseInt(sharedIdStr) : 0;
|
||||
if (userId > 0) {
|
||||
packageSetting = new PendingPackage(name.intern(), realName, new File(
|
||||
codePathStr), new File(resourcePathStr), nativeLibraryPathStr, userId,
|
||||
codePathStr), new File(resourcePathStr), nativeLibraryPathStr, requiredCpuAbiString, userId,
|
||||
versionCode, pkgFlags);
|
||||
packageSetting.setTimeStamp(timeStamp);
|
||||
packageSetting.firstInstallTime = firstInstallTime;
|
||||
@@ -2509,6 +2523,7 @@ final class Settings {
|
||||
packageSetting.uidError = "true".equals(uidError);
|
||||
packageSetting.installerPackageName = installerPackageName;
|
||||
packageSetting.nativeLibraryPathString = nativeLibraryPathStr;
|
||||
packageSetting.requiredCpuAbiString = requiredCpuAbiString;
|
||||
// Handle legacy string here for single-user mode
|
||||
final String enabledStr = parser.getAttributeValue(null, ATTR_ENABLED);
|
||||
if (enabledStr != null) {
|
||||
@@ -3008,6 +3023,7 @@ final class Settings {
|
||||
pw.print(prefix); pw.print(" codePath="); pw.println(ps.codePathString);
|
||||
pw.print(prefix); pw.print(" resourcePath="); pw.println(ps.resourcePathString);
|
||||
pw.print(prefix); pw.print(" nativeLibraryPath="); pw.println(ps.nativeLibraryPathString);
|
||||
pw.print(prefix); pw.print(" requiredCpuAbi="); pw.println(ps.requiredCpuAbiString);
|
||||
pw.print(prefix); pw.print(" versionCode="); pw.print(ps.versionCode);
|
||||
if (ps.pkg != null) {
|
||||
pw.print(" targetSdk="); pw.print(ps.pkg.applicationInfo.targetSdkVersion);
|
||||
|
||||
Reference in New Issue
Block a user