开机提示“Android正在升级...”

有时候我们对手机重新刷ROM后或者升级了某些程序开机时会显示"Android正在升级..."的提示,这个过程实际上是DalvikVM对程序进行优化的过程。Android启动时,Dalvik VM扫描所有的app,并为它们创建了一个依存关系库,DalvikVM通过这个依存关系树来为每个程序优化代码并存储在Dalvik缓存中(dalvik-cache),程序运行会使用优化过的代码。

正常情况下手机第一次开机会执行DexOpt的优化,第一次开机是在后台执行,不会有提示,如果以后开机dalvik发现某个应用发生变化会重新执行代码优化并将优化后的代码存入对应的dalvik-cache中,非第一次开机的优化过程都会有"Android正在升级"的提示。如果想无论什么情况下都不提示可以修改下面代码,注释掉如下的代码:

frameworks\base\services\java\com\android\server\pm\PackageManagerService.java 
    public void performBootDexOpt() {
        ArrayList pkgs = null;
        synchronized (mPackages) {
            if (mDeferredDexOpt.size() > 0) {
                pkgs = new ArrayList(mDeferredDexOpt);
                mDeferredDexOpt.clear();
            }
        }
        if (pkgs != null) {
            for (int i=0; i                /*if (!isFirstBoot()) {
                    try {
                        ActivityManagerNative.getDefault().showBootMessage(
                                mContext.getResources().getString(
                                        com.android.internal.R.string.android_upgrading_apk,
                                        i+1, pkgs.size()), true);
                    } catch (RemoteException e) {
                    }
                }*/

PackageManagerService.java 
主要负责apk程序的安装、检查和优化等,下面是一个apk程序的安装过程:

V/PackageManager(  374): Install from ADB
I/PackageManager(  374): init_copy
I/PackageManager(  374): Trying to bind to DefaultContainerService
I/PackageManager(  374): idx=0
W/ActivityManager(  374): No content provider found for permission revoke: file:///data/local/tmp/subwaysurf_1.30.0.apk
W/ActivityManager(  374): No content provider found for permission revoke: file:///data/local/tmp/subwaysurf_1.30.0.apk
I/PackageManager(  374): Copying native libraries to /data/app-lib/vmdl201603937
V/NativeLibraryHelper(  374): Comparing ABIs armeabi-v7a and armeabi versus armeabi-v7a/libmain.so
V/NativeLibraryHelper(  374): Using primary ABI armeabi-v7a
V/NativeLibraryHelper(  374): Couldn't stat /data/app-lib/vmdl201603937/libmain.so, copying: No such file or directory
V/NativeLibraryHelper(  374): Successfully moved /data/app-lib/vmdl201603937/tmp.Fta374 to /data/app-lib/vmdl201603937/libmain.so
V/NativeLibraryHelper(  374): Comparing ABIs armeabi-v7a and armeabi versus armeabi-v7a/libmono.so
V/NativeLibraryHelper(  374): Using primary ABI armeabi-v7a
V/NativeLibraryHelper(  374): Couldn't stat /data/app-lib/vmdl201603937/libmono.so, copying: No such file or directory
V/NativeLibraryHelper(  374): Successfully moved /data/app-lib/vmdl201603937/tmp.woL374 to /data/app-lib/vmdl201603937/libmono.so
V/NativeLibraryHelper(  374): Comparing ABIs armeabi-v7a and armeabi versus armeabi-v7a/libunity.so
V/NativeLibraryHelper(  374): Using primary ABI armeabi-v7a
V/NativeLibraryHelper(  374): Couldn't stat /data/app-lib/vmdl201603937/libunity.so, copying: No such file or directory
D/MemClearService(  460): getmem_UNUSED = 92MB, extraAvailableSize=81MB,testret=153MB,realret=145MB
V/NativeLibraryHelper(  374): Successfully moved /data/app-lib/vmdl201603937/tmp.HDU374 to /data/app-lib/vmdl201603937/libunity.so
I/PackageManager(  374): Checking for more work or unbind...
I/PackageManager(  374): Posting delayed MCS_UNBIND
D/PackageManager(  374): manifestDigest was not present, but parser got: ManifestDigest {mDigest=cc,e1,d4,b2,95,ad,14,81,da,af,40,c9,39,64,73,5c,f5,ad,78,26,}
V/NativeLibraryHelper(  374): Comparing ABIs armeabi-v7a and armeabi versus armeabi-v7a/libmain.so
V/NativeLibraryHelper(  374): Using primary ABI armeabi-v7a
V/NativeLibraryHelper(  374): /data/app-lib/com.kiloo.subwaysurf-1/libmain.so: crc = 3abf987b, zipCrc = 3abf987b
V/NativeLibraryHelper(  374): Comparing ABIs armeabi-v7a and armeabi versus armeabi-v7a/libmono.so
V/NativeLibraryHelper(  374): Using primary ABI armeabi-v7a
I/PackageManager(  374): Linking native library dir for /data/app/com.kiloo.subwaysurf-1.apk
I/PackageManager(  374): Running dexopt on: com.kiloo.subwaysurf
V/installd(   75): DexInv: --- BEGIN '/data/app/com.kiloo.subwaysurf-1.apk' ---
D/LogIfSlow(  374): start at 1074702493ms
D/LogIfSlow(  374): end durationMillis is 0ms
D/MemClearService(  460): getmem_UNUSED = 94MB, extraAvailableSize=82MB,testret=156MB,realret=148MB
V/installd(   75): DexInv: --- END '/data/app/com.kiloo.subwaysurf-1.apk' (success) ---
I/ActivityManager(  374): Force stopping package com.kiloo.subwaysurf appid=10055 user=-1
V/ActivityManager(  374): Activity idle: null
V/installd(   75): move /data/dalvik-cache/data@[email protected]@classes.dex -> /data/dalvik-cache/data@[email protected]@classes.dex
D/PackageManager(  374): New package installed in /data/app/com.kiloo.subwaysurf-1.apk



你可能感兴趣的:(Android)