MA-18087-2 Support snapshot-update-status variable
authorJi Luo <ji.luo@nxp.com>
Wed, 21 Oct 2020 02:52:21 +0000 (10:52 +0800)
committerJi Luo <ji.luo@nxp.com>
Thu, 13 May 2021 01:49:18 +0000 (09:49 +0800)
Add support for 'fastboot getvar snapshot-update-status', it
returns the snapshot update states.

Test: run 'fastboot getvar snapshot-update-status'

Signed-off-by: Ji Luo <ji.luo@nxp.com>
Change-Id: Ifd46410994b11c327373a35eb86d121f321e39ae
(cherry picked from commit 28c6cbec7fe9e613620e5d80b7b43d1ca6bdd9c6)
(cherry picked from commit dece52d012e8c6e06f96f1ad34b47f5da6514d2e)

drivers/fastboot/fb_fsl/fb_fsl_getvar.c
drivers/fastboot/fb_fsl/fb_fsl_virtual_ab.h

index f4808f5..457b5ae 100644 (file)
 #define ATAP_UUID_STR_SIZE ((ATAP_UUID_SIZE*2) + 1)
 #endif
 
+#ifdef CONFIG_VIRTUAL_AB_SUPPORT
+#include "fb_fsl_virtual_ab.h"
+#endif
+
 #if defined(CONFIG_ANDROID_THINGS_SUPPORT) && defined(CONFIG_ARCH_IMX8M)
 #define FASTBOOT_COMMON_VAR_NUM 15
 #else
@@ -433,6 +437,16 @@ static int get_single_var(char *cmd, char *response)
                }
 
        }
+#endif
+#ifdef CONFIG_VIRTUAL_AB_SUPPORT
+       else if (!strcmp_l1("snapshot-update-status", cmd)) {
+               if (virtual_ab_update_is_merging())
+                       strncat(response, "merging", chars_left);
+               else if (virtual_ab_update_is_snapshoted())
+                       strncat(response, "snapshotted", chars_left);
+               else
+                       strncat(response, "none", chars_left);
+       }
 #endif
        else {
                char envstr[32];
@@ -540,6 +554,12 @@ void fastboot_getvar(char *cmd, char *response)
                        }
                }
 
+#ifdef CONFIG_VIRTUAL_AB_SUPPORT
+               strncpy(response, "INFOsnapshot-update-status:", FASTBOOT_RESPONSE_LEN);
+               get_single_var("snapshot-update-status", response);
+               fastboot_tx_write_more(response);
+#endif
+
                strncpy(response, "OKAYDone!", 10);
                fastboot_tx_write_more(response);
                fastboot_none_resp(response);
index 3b33cd7..13769fd 100644 (file)
@@ -3,6 +3,9 @@
  * Copyright 2020 NXP
  */
 
+#ifndef __FB_FSL_VIRTUAL_AB_H__
+#define __FB_FSL_VIRTUAL_AB_H__
+
 typedef enum {
        VIRTUAL_AB_NONE = 0,
        VIRTUAL_AB_UNKNOWN,
@@ -16,3 +19,5 @@ bool virtual_ab_update_is_merging(void);
 bool virtual_ab_update_is_snapshoted(void);
 bool virtual_ab_slot_match(void);
 int virtual_ab_cancel_update(void);
+
+#endif