Android应用升级如何在技术上发挥作用?

时间:2015-05-14 16:06:56

标签: android app-update

有人可以解释或指出资源,我可以阅读Android应用升级实际上在操作系统级别上的详细信息吗?

3 个答案:

答案 0 :(得分:13)

从软件包管理器日志中,似乎采取了以下步骤进行升级:

1)在临时位置下载包裹。

  

ACT = android.intent.action.PACKAGE_NEEDS_VERIFICATION   DAT =文件:///data/app/vmdl1854135520.tmp   典型值=应用/ vnd.android.package - 归档

2)进行包装验证。

  

06-30 17:59:02.751 3701 3751 D PackageManager:[MSG]   PACKAGE_VERIFIED:observer {237546897}

3)重命名包。

  

06-30 17:59:03.361 3701 3751 D PackageManager:重命名   /data/app/vmdl1854135520.tmp到/data/app/com.vzw.hss.myverizon-1

4)杀死现有应用

  

06-30 17:59:03.361 3701 3751 D PackageManager:!@killApplicatoin:   10031,替换sys pkg

5)Dexopt apk

  

06-30 17:59:03.381 3701 3751 D PackageManager:运行dexopt on:   /data/app/com.vzw.hss.myverizon-1/base.apk pkg = com.vzw.hss.myverizon   isa = arm64 vmSafeMode = false interpret_only = false

**06-30 17:59:02.741  3701  3751 D PackageManager: [VERIFY] Found 1 verifiers for intent Intent { act=android.intent.action.PACKAGE_NEEDS_VERIFICATION dat=file:///data/app/vmdl1854135520.tmp** typ=application/vnd.android.package-archive flg=0x10000001 } with 0 optional verifiers
06-30 17:59:02.741  3701  3751 D PackageManager: [VERIFY] sendOrderedBroadcastToRequiredVerifier:
06-30 17:59:02.741  3701  3751 D PackageManager: PackageVerificationState{
06-30 17:59:02.741  3701  3751 D PackageManager:     verifier packages=com.android.vending(10034),
06-30 17:59:02.741  3701  3751 D PackageManager:     intent=Intent { act=android.intent.action.PACKAGE_NEEDS_VERIFICATION dat=file:///data/app/vmdl1854135520.tmp typ=application/vnd.android.package-archive flg=0x10000001 (has extras) }
06-30 17:59:02.741  3701  3751 D PackageManager:     others=28, false, false, false, false, false
06-30 17:59:02.741  3701  3751 D PackageManager: }
06-30 17:59:02.741  3701  3751 D PackageManager: remove MCS_UNBIND message and Posting MCS_UNBIND 10 secs later
06-30 17:59:02.751  3701  3701 D PackageManager: [VERIFY] onReceive for RequiredVerifier id=28
06-30 17:59:02.751  3701  3701 D PackageManager: [VERIFY] send delayed message for CHECK_PENDING_VERIFICATION after : 10000
06-30 17:59:02.751  3701  4589 D PackageManager: [VERIFY] verifyPendingInstall(28, VERIFICATION_ALLOW), uid=10034
06-30 17:59:02.751  3701  3751 D PackageManager: [MSG] PACKAGE_VERIFIED: observer{237546897}
06-30 17:59:02.751  3701  3751 D PackageManager: [VERIFY] PACKAGE_VERIFIED: 
06-30 17:59:02.751  3701  3751 D PackageManager: PackageVerificationState{
06-30 17:59:02.751  3701  3751 D PackageManager:     verifier packages=com.android.vending(10034),
06-30 17:59:02.751  3701  3751 D PackageManager:     intent=Intent { act=android.intent.action.PACKAGE_NEEDS_VERIFICATION dat=file:///data/app/vmdl1854135520.tmp typ=application/vnd.android.package-archive flg=0x10000001 cmp=com.android.vending/com.google.android.vending.verifier.PackageVerificationReceiver (has extras) }
06-30 17:59:02.751  3701  3751 D PackageManager:     others=28, false, false, false, false, false
06-30 17:59:02.751  3701  3751 D PackageManager: }
06-30 17:59:02.751  3701  3751 D PackageManager: [VERIFY] broadcastPackageVerified(28, VERIFICATION_ALLOW, file:///data/app/vmdl1854135520.tmp)
06-30 17:59:02.761  3701  3751 D PackageManager: /data/app/vmdl1854135520.tmp already staged; skipping copy
06-30 17:59:02.761  3701  3751 D PackageManager: remove MCS_UNBIND and Posting MCS_UNBIND
06-30 17:59:02.761  3701  3751 D PackageManager: [MSG] PROCESS_PENDING_INSTALL: observer{237546897}
06-30 17:59:02.761  3701  3751 D PackageManager: currentStatus{1}
06-30 17:59:02.761  3701  3751 D PackageManager: installPackageLI: path
06-30 17:59:03.321  3701  3751 W PackageManager: verifying app can be installed or not
**06-30 17:59:03.361  3701  3751 D PackageManager: Renaming /data/app/vmdl1854135520.tmp to /data/app/com.vzw.hss.myverizon-1**
**06-30 17:59:03.361  3701  3751 D PackageManager: replacePackageLI**
**06-30 17:59:03.361  3701  3751 D PackageManager: !@killApplicatoin: 10031, replace sys pkg**
06-30 17:59:03.371  3701  3751 W PackageManager: Trying to update system app code path from /system/priv-app/MyVerizon to /data/app/com.vzw.hss.myverizon-1
06-30 17:59:03.371  3701  3751 I PackageManager: scanFileNewer : com.vzw.hss.myverizon
**06-30 17:59:03.381  3701  3751 D PackageManager: Running dexopt on: /data/app/com.vzw.hss.myverizon-1/base.apk pkg=com.vzw.hss.myverizon isa=arm64 vmSafeMode=false interpret_only=false**
06-30 17:59:06.861  3701  3751 I PackageManager: do mInstaller.dexopt : 0
06-30 17:59:06.861  3701  3751 D PackageManager: Time to dexopt: 3.482 seconds
06-30 17:59:06.861  3701  3751 D PackageManager: !@killApplicatoin: 10031, update pkg
06-30 17:59:06.861  3701  3751 W PackageManager: Code path for pkg : com.vzw.hss.myverizon changing from /system/priv-app/MyVerizon to /data/app/com.vzw.hss.myverizon-1
06-30 17:59:06.861  3701  3751 W PackageManager: Resource path for pkg : com.vzw.hss.myverizon changing from /system/priv-app/MyVerizon to /data/app/com.vzw.hss.myverizon-1
06-30 17:59:06.961  3701  3751 D PackageManager: New package installed
06-30 17:59:06.971  3701  3751 I PackageManager: Un-granting permission android.permission.sec.ENTERPRISE_DEVICE_ADMIN from package com.samsung.mdmtest1 (protectionLevel=2 flags=0x89be44)
06-30 17:59:06.971  3701  3751 I PackageManager: Un-granting permission com.sec.enterprise.knox.permission.KNOX_ENTERPRISE_BILLING from package com.samsung.mdmtest1 (protectionLevel=2 flags=0x89be44)
06-30 17:59:07.141  3701  3751 D PackageManager: doPostInstall for uid{10031}
06-30 17:59:07.151  3701  3751 D PackageManager: [MSG] MCS_UNBIND
06-30 17:59:07.151  3701  3751 D PackageManager: [MSG] POST_INSTALL: observer{237546897}
06-30 17:59:07.151  3701  3751 D PackageManager:           Handling post-install for 29
06-30 17:59:07.661  3701  3751 D PackageManager: result of install: 1{237546897}

答案 1 :(得分:6)

我找不到一个好的资源,但这是我对这个过程的理解。

安装时,

APK会存储在手机的私人目录中。当升级发生时,从商店下载新的APK,然后用新的APK替换旧的APK。新的AndroidManifest被解析并安装,好像它是一个新的安装,并检查版本,签名密钥等,以确保允许升级。实际的应用程序数据存储在一个单独的位置,在升级过程中不会被触及。如果您更改数据库架构或其他内容,则需要在首次启动时迁移数据。

答案 2 :(得分:2)

来源:http://java.dzone.com/articles/depth-android-package-manager

我不确定那是你所追求的,但我能找到的最好的就是这个。

Package Manager API负责管理安装,卸载和升级APK文件。

它调用方法" InstallPackage"使用' uri',' installFlags','观察者'和' InstallPackageName'然后,它启动名为" package"的服务。这将实际安装/升级它。

程序包管理器服务在system_service进程中运行,并且安装守护程序(installd)作为本机进程运行。两者都从系统启动时开始。

流程概述:

  • 等待;
  • 将包添加到队列以进行安装;
  • 确定软件包安装的适当位置;
  • 确定安装安装/更新新
  • 将APK文件复制到指定目录;
  • 确定应用的UID;
  • 请求installd守护进程;
  • 创建应用程序目录并设置权限;
  • 将dex代码提取到缓存目录;
  • 反映packages.list / system / data / packages.xml最新的包状态;
  • 向系统广播以及安装效果的包名称;
  • Intent.ACTION_PACKAGE_ADDED:如果包是新的//(Intent.ACTION_PACKAGE_REPLACED)如果包更新 Overview of the instalation/upgrade process

包管理器将应用程序信息存储在三个文件中,位于/ data / system:

  1. packages.xml - 具有属于包的权限
  2. packages.list - 它只是包含包名,用户ID,标志和数据目录的文本文件
  3. packages-stopped.xml:此文件包含已停止状态的包列表。停止状态的应用程序无法接收任何广播。
  4. 包管理器(和包安装程序)的相关源代码的链接如下:

    包管理器 https://android.googlesource.com/platform/frameworks/base/+/483f3b06ea84440a082e21b68ec2c2e54046f5a6/services/java/com/android/server/pm/Settings.java

    https://android.googlesource.com/platform/frameworks/base/+/483f3b06ea84440a082e21b68ec2c2e54046f5a6/services/java/com/android/server/pm/PackageManagerService.java

    https://android.googlesource.com/platform/frameworks/base/+/483f3b06ea84440a082e21b68ec2c2e54046f5a6/core/java/android/content/pm/IPackageManager.aidl

    https://android.googlesource.com/platform/frameworks/base/+/483f3b06ea84440a082e21b68ec2c2e54046f5a6/services/java/com/android/server/pm/PackageSignatures.java

    https://android.googlesource.com/platform/frameworks/base/+/483f3b06ea84440a082e21b68ec2c2e54046f5a6/services/java/com/android/server/pm/PreferredActivity.java

    https://android.googlesource.com/platform/frameworks/base/+/483f3b06ea84440a082e21b68ec2c2e54046f5a6/services/java/com/android/server/PreferredComponent.java

    https://android.googlesource.com/platform/frameworks/base/+/483f3b06ea84440a082e21b68ec2c2e54046f5a6/core/java/android/content/IntentFilter.java

    https://android.googlesource.com/platform/frameworks/base/+/483f3b06ea84440a082e21b68ec2c2e54046f5a6/core/java/android/content/pm/PackageParser.java

    https://android.googlesource.com/platform/frameworks/base/+/483f3b06ea84440a082e21b68ec2c2e54046f5a6/core/java/android/content/pm/IPackageManager.aidl

    https://android.googlesource.com/platform/frameworks/base/+/483f3b06ea84440a082e21b68ec2c2e54046f5a6/services/java/com/android/server/pm/Installer.java

    https://android.googlesource.com/platform/frameworks/base/+/483f3b06ea84440a082e21b68ec2c2e54046f5a6/core/java/com/android/internal/app/IMediaContainerService.aidl

    https://android.googlesource.com/platform/frameworks/base/+/483f3b06ea84440a082e21b68ec2c2e54046f5a6/packages/DefaultContainerService/src/com/android/defcontainer/DefaultContainerService.java

    套餐安装程序

    https://android.googlesource.com/platform/packages/apps/PackageInstaller/+/47fe118e0178e9d72c98073ff588ee5cf353258e/src/com/android/packageinstaller/PackageInstallerActivity.java

    https://android.googlesource.com/platform/packages/apps/PackageInstaller/+/47fe118e0178e9d72c98073ff588ee5cf353258e/src/com/android/packageinstaller/PackageUtil.java

    https://android.googlesource.com/platform/packages/apps/PackageInstaller/+/47fe118e0178e9d72c98073ff588ee5cf353258e/src/com/android/packageinstaller/InstallAppProgress.java