RK3288 系统升级流程

编程知识 更新时间:2023-04-27 08:39:26

1.在RKUpdateService中调用findFromSdOrUsb检测update.zip文件或者update.img文件
2.检测到文件后 如果是 img文件则携带 version参数跳转 android.rockchip.update.service.FirmwareUpdatingActivity,是zip则直接跳转
3.在 FirmwareUpdatingActivity 文件中 点击 ok 跳转 UpdateAndRebootActivity 携带 文件path;
4.在 UpdateAndRebootActivity 页面 如果是 img 则调用 updateFirmware ,model : RKUPDATE_MODE:1 ; 如果是 zip,model :OTAUPDATE_MODE:2
5. 回到RKUpdateService 的 LocalBinder 的 RKRecoverySystem.installPackage 
6.调用 RecoverySystem.installPackage(context, packageFile); 

然后回到 frameworks/base/core/java/android/os/RecoverySystem.java

 public static void installPackage(Context context, File packageFile, boolean processed)
            throws IOException {
        synchronized (sRequestLock) {
            LOG_FILE.delete();
            // Must delete the file in case it was created by system server.
            UNCRYPT_PACKAGE_FILE.delete();

            String filename = packageFile.getCanonicalPath();
            Log.w(TAG, "!!! REBOOTING TO INSTALL " + filename + " !!!");

            // If the package name ends with "_s.zip", it's a security update.
            boolean securityUpdate = filename.endsWith("_s.zip");

            // If the package is on the /data partition, the package needs to
            // be processed (i.e. uncrypt'd). The caller specifies if that has
            // been done in 'processed' parameter.
            if (filename.startsWith("/data/")) {
                if (processed) {
                    if (!BLOCK_MAP_FILE.exists()) {
                        Log.e(TAG, "Package claimed to have been processed but failed to find "
                                + "the block map file.");
                        throw new IOException("Failed to find block map file");
                    }
                } else {
                    FileWriter uncryptFile = new FileWriter(UNCRYPT_PACKAGE_FILE);
                    try {
                        uncryptFile.write(filename + "\n");
                    } finally {
                        uncryptFile.close();
                    }
                    // UNCRYPT_PACKAGE_FILE needs to be readable and writable
                    // by system server.
                    if (!UNCRYPT_PACKAGE_FILE.setReadable(true, false)
                            || !UNCRYPT_PACKAGE_FILE.setWritable(true, false)) {
                        Log.e(TAG, "Error setting permission for " + UNCRYPT_PACKAGE_FILE);
                    }

                    BLOCK_MAP_FILE.delete();
                }

                // If the package is on the /data partition, use the block map
                // file as the package name instead.
                filename = "@/cache/recovery/block.map";
            }

            final String filenameArg = "--update_package=" + filename + "\n";
            final String localeArg = "--locale=" + Locale.getDefault().toLanguageTag() + "\n";
            final String securityArg = "--security\n";

            String command = filenameArg + localeArg;
            if (securityUpdate) {
                command += securityArg;
            }

            RecoverySystem rs = (RecoverySystem) context.getSystemService(
                    Context.RECOVERY_SERVICE);
            if (!rs.setupBcb(command)) {
                throw new IOException("Setup BCB failed");
            }

            // Having set up the BCB (bootloader control block), go ahead and reboot
            PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
            String reason = PowerManager.REBOOT_RECOVERY_UPDATE;

            // On TV, reboot quiescently if the screen is off
            if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
                WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
                if (wm.getDefaultDisplay().getState() != Display.STATE_ON) {
                    reason += ",quiescent";
                }
            }
            pm.reboot(reason);

            throw new IOException("Reboot failed (no permissions?)");
        }
    }

如何禁止自动升级并让用户App可以执行升级命令


修改思路及内容
1. 在RKUpdateService中不检测update.zip文件和update.img文件
2. 修改页面布局 notify_dialog,及 UpdateAndRebootActivity页面的显示,使该页面透明悬浮
3. 调用方式为 = 直接跳转 

    Intent intent = new Intent();
    intent.setComponent(new ComponentName("android.rockchip.update.service", "android.rockchip.update.service.UpdateAndRebootActivity") );
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.putExtra("android.rockchip.update.extra.IMAGE_PATH", path);
    context.startActivity(intent);


        

更多推荐

RK3288 系统升级流程

本文发布于:2023-04-20 14:55:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/5e6c7cba2c8736b996a62f2fa1857aec.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:系统升级   流程

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 90501文章数
  • 23320阅读数
  • 0评论数