From e95651361e483ec47344c98fd12195766cf958a5 Mon Sep 17 00:00:00 2001 From: hitori1403 Date: Sun, 17 Nov 2024 00:49:20 +0700 Subject: [PATCH 1/2] Fix da_read_partition returning None instead of an empty string ("") when partition does not exist --- mtkclient/Library/DA/mtk_da_handler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mtkclient/Library/DA/mtk_da_handler.py b/mtkclient/Library/DA/mtk_da_handler.py index 0d082688..8d009803 100755 --- a/mtkclient/Library/DA/mtk_da_handler.py +++ b/mtkclient/Library/DA/mtk_da_handler.py @@ -240,7 +240,7 @@ def da_read_partition(self, partitionname, parttype="user"): length=rpartition.sectors * self.config.pagesize, filename="", parttype=parttype) return data - return None + return b"" def da_write_partition(self, partitionname, data:bytes=None, parttype="user"): rpartition = None From 247588859daaed32e60b7b770cc1dabbaf016b73 Mon Sep 17 00:00:00 2001 From: hitori1403 Date: Sun, 17 Nov 2024 00:50:20 +0700 Subject: [PATCH 2/2] Handle null bytes return in get_current_slot for non-A/B devices --- mtkclient/Library/DA/mtk_da_handler.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mtkclient/Library/DA/mtk_da_handler.py b/mtkclient/Library/DA/mtk_da_handler.py index 8d009803..dda9d690 100755 --- a/mtkclient/Library/DA/mtk_da_handler.py +++ b/mtkclient/Library/DA/mtk_da_handler.py @@ -677,6 +677,8 @@ def get_current_slot(self): tmp = self.da_read_partition("para") if tmp != b"": slot = tmp[0x800:0x802].decode('utf-8') + if slot == "\x00\x00": + slot = "" else: slot = "" return slot