通过应用商店更新高版本的系统app,在升级完成后重启会删除掉新安装的app?
解决方法:
修改frameworks/base/services/java/com/android/server/pm/PackageManagerService.java注释掉红色的部分
if (pkg.mVersionCode <= ps.versionCode) {
// The system package has been updated and the code path does not match // Ignore entry. Skip it.
Log.i(TAG, "Package " + ps.name + " at " + scanFile
+ " ignored: updated version " + ps.versionCode
+ " better than this " + pkg.mVersionCode);
if (!updatedPkg.codePath.equals(scanFile)) {
Slog.w(PackageManagerService.TAG, "Code path for hidden system pkg : "
+ ps.name + " changing from " + updatedPkg.codePathString
+ " to " + scanFile);
updatedPkg.codePath = scanFile;
updatedPkg.codePathString = scanFile.toString();
// This is the point at which we know that the system-disk APK
// for this package has moved during a reboot (e.g. due to an OTA),
// so we need to reevaluate it for privilege policy.
if (locationIsPrivileged(scanFile)) {
updatedPkg.pkgFlags |= ApplicationInfo.FLAG_PRIVILEGED;
}
}
updatedPkg.pkg = pkg;
mLastScanError = PackageManager.INSTALL_FAILED_DUPLICATE_PACKAGE;
return null;
}/*else {
// The current app on the system partion is better than
// what we have updated to on the data partition; switch
// back to the system partition version.
// At this point, its safely assumed that package installation for
// apps in system partition will go through. If not there won't be a working
// version of the app
// writer
synchronized (mPackages) {
// Just remove the loaded entries from package lists.
mPackages.remove(ps.name);
}
Slog.w(TAG, "Package " + ps.name + " at " + scanFile
+ "reverting from " + ps.codePathString
+ ": new version " + pkg.mVersionCode
+ " better than installed " + ps.versionCode);
InstallArgs args = createInstallArgs(packageFlagsToInstallFlags(ps),
ps.codePathString, ps.resourcePathString, ps.nativeLibraryPathString);
synchronized (mInstallLock) {
args.cleanUpResourcesLI();
}
synchronized (mPackages) {
mSettings.enableSystemPackageLPw(ps.name);
}
} */
根本原因:
Google为APK定义了两个关于版本属性:VersionCode和VersionName,他们有不同的用途。
VersionCode:对消费者不可见,仅用于应用市场、程序内部识别版本,判断新旧等用途。—整数值,代表应用程序代码的相对版本,也就是版本更新过多少次。整数值有利于其它程序比较,检查是升级还是降级。你可以把这个值设定为任何想设的值,但是,你必须保证后续更新版的值要比这个大。系统不会强制要求这一行为,但是随着版本更新值也增加是正常的行为。一般来说,你发布的第一版程序的versionCode设定为1,然后每次发布都会相应增加,不管发布的内容是较大还是较小的
VersionName:展示给消费者,消费者会通过它认知自己安装的版本,下文提到的版本号都是说
网友评论