From 7e2ed631f2793d26b9029b0bd3218ab7dbca7e6c Mon Sep 17 00:00:00 2001 From: yanyh2 Date: Fri, 12 Jun 2020 17:41:01 +0800 Subject: [PATCH] adjust factory image identification Adjust the way to identify factory bootloader to decide whether SW is factory SW version. When device in factory mode may be identified as factory version in previous implementation. Change-Id: I38b4fe9ea12d70b8e07416110c2d7e8a5bbf994a Signed-off-by: yanyh2 Reviewed-on: https://gerrit.mot.com/1616461 SME-Granted: SME Approvals Granted SLTApproved: Slta Waiver Tested-by: Jira Key Reviewed-by: Zhenxin Xi Submit-Approved: Jira Key --- .../qpnp-smbcharger-mmi/qpnp-smbcharger-mmi.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/power/qpnp-smbcharger-mmi/qpnp-smbcharger-mmi.c b/drivers/power/qpnp-smbcharger-mmi/qpnp-smbcharger-mmi.c index f0de3043ada4..fba33a33e9f8 100644 --- a/drivers/power/qpnp-smbcharger-mmi/qpnp-smbcharger-mmi.c +++ b/drivers/power/qpnp-smbcharger-mmi/qpnp-smbcharger-mmi.c @@ -1349,6 +1349,7 @@ static bool mmi_factory_check(int type) bool factory = false; const char *bootargs = NULL; char *bl_version = NULL; + char *end = NULL; if (!np) return factory; @@ -1359,12 +1360,16 @@ static bool mmi_factory_check(int type) "mmi,factory-cable"); break; case MMI_FACTORY_BUILD: - if (!of_property_read_string(np, - "bootargs", &bootargs)) { - bl_version = strstr(bootargs, - "androidboot.bootloader="); - if (bl_version && strstr(bl_version, "factory")) + if (!of_property_read_string(np, "bootargs", &bootargs)) { + bl_version = strstr(bootargs, "androidboot.bootloader="); + if (bl_version) { + end = strpbrk(bl_version, " "); + bl_version = strpbrk(bl_version, "="); + } + if (bl_version && end > bl_version && + strnstr(bl_version, "factory", end - bl_version)) { factory = true; + } } break; default: