顯示具有 restore 標籤的文章。 顯示所有文章
顯示具有 restore 標籤的文章。 顯示所有文章

2023年4月19日 星期三

小米A3 Xiaomi Mi A3 Root 與 Restore 還原到原廠ROM的筆記 @ macOS 13.3.1




沒想到已經過了好幾年,當初花不到七千買的 Android one 手機,實在好用,試試看把小米A3 Root 一下吧!遙想十多年前,在製作 Android Image 時,還要埋個用C code包裝出 su 指令呢 XD 真的很久沒 root 手機了。整個過程稱不上快,但又覺得不會太不方便。

在進行前,依舊要老話重提:

Root 有風險,手機可能變磚又損失保固,請自行評估承擔風險,在此是對四年前的手機把玩,推論是小米A3國際版手機,產品代號 laurel_sprout 且系統沒有被限制不能 rollback,以下步驟不見得適合其他款手機或品牌。

先簡介如何還原到原廠 ROM 過程,這邊就不多提如何建置操作環境(例如 adb, fastboot 指令、手機的 bootloader 是解鎖狀態)

首先,先查看手機狀態,有個關鍵的產品代號:laurel_sprout ,這跟找尋小米A3原廠ROM有關。

% fastboot devices
############ fastboot

% fastboot getvar product
product: laurel_sprout
Finished. Total time: 0.002s

% fastboot getvar anti
anti: 0
Finished. Total time: 0.001s

% fastboot getvar all
(bootloader) crc:1
(bootloader) DP:0x0
(bootloader) parallel-download-flash:yes
(bootloader) hw-revision:10000
(bootloader) unlocked:yes
(bootloader) off-mode-charge:0
(bootloader) charger-screen-enabled:0
(bootloader) battery-soc-ok:yes
(bootloader) battery-voltage:4356
...

下載原廠ROM,網路上用 小米A3 跟 ROM 就會找到,當然,在用一下 laurel_sprout 或是小米A3國際版、全球版也能找到:


看到網址是 miui.com 就比較安心不用怕了。接著要讓手機進入 fastboot 模式,過程就是先關機,在開機時,同時按住 Power 和 Volume Down 按鍵:



進行燒機:

% cd ~/Downloads
% tar -xvf laurel_sprout_global_images_V12.0.26.0.RFQMIXM_20220808.0000.00_11.0_2292e2c0b1.tgz
% cd ~/Downloads/laurel_sprout_global_images_V12.0.26.0.RFQMIXM_11.0 
% chmod a+x ./flash_all.sh && time ./flash_all.sh

如果開機一直卡在這邊,就一樣先設法進入 fastboot 模式(先長按 Power 鍵促使關機又重開,重開時按 Power 和 Volume Down),接著一樣靠 fastboot devices 偵測到後,執行下面的指令,指定啟動位置即可排除:

% fastboot set_active a
% fastboot reboot



如此就可以順利進入到手機啟動畫面,若用時間來看,刷機(fastboot)約6-7分鐘,第一次重啟時,從 Android One 畫面到出現置中的 Mi logo 不到 30 秒,接著從 Mi logo 到進入首次啟用 Android 新機畫面要接近 3分鐘。


如此手機就還原到原廠狀態了!此時 bootloader 仍是處於解鎖狀態。

接下來,說說如何 root 手機,過程:
  1. 解開 bootloader (unlocked)
    • % fastboot flashing unlock
    • % fastboot flashing unlock_critical
  2. 打開開發者模式,也啟用 USB偵錯
  3. 下載原廠 ROM - laurel_sprout_global_images_V12.0.26.0.RFQMIXM_20220808.0000.00_11.0_2292e2c0b1.tgz 從中取出 boot.img 來製作使用
  4. 在 github.com 下載 Magisk apk 來安裝 ,並使用 Magisk boot.img 製作新的 boot image
  5. 把手機關鍵,再次進入到 fastboot 模式,把 magisk_patched-26100_MKaXg.img 燒入 boot 區,接著重啟後,就可以有 root 權限了。
以下連續動作:

% wget https://github.com/topjohnwu/Magisk/releases/download/v26.1/Magisk-v26.1.apk  
% adb install ~/Downloads/Magisk-v26.1.apk 
% tar -tzf ~/Downloads/laurel_sprout_global_images_V12.0.26.0.RFQMIXM_20220808.0000.00_11.0_2292e2c0b1.tgz
% tar -xvf ~/Downloads/laurel_sprout_global_images_V12.0.26.0.RFQMIXM_20220808.0000.00_11.0_2292e2c0b1.tgz laurel_sprout_global_images_V12.0.26.0.RFQMIXM_11.0/images/boot.img
% adb push ~/Downloads/laurel_sprout_global_images_V12.0.26.0.RFQMIXM_11.0/images/boot.img /sdcard/





接著是使用 Magisk app 製作出新的 magisk_patched-26100_MKaXg.img ,把它取出後,等下靠 fastboot 燒錄進去:

% adb pull /storage/emulated/0/Download/magisk_patched-26100_MKaXg.img ~/Downloads/
/storage/emulated/0/Download/magisk_patched-26100_MKaXg.img: 1 file pulled, 0 skipped. 36.4 MB/s (67108864 bytes in 1.760s)

接著手機進入 fastboot 模式後,燒錄:

% fastboot devices
############ fastboot
% fastboot flash boot ~/Downloads/magisk_patched-26100_MKaXg.img 
Sending 'boot_a' (65536 KB)                        OKAY [  1.682s]
Writing 'boot_a'                                   OKAY [  0.333s]
Finished. Total time: 2.026s
% fastboot reboot
Rebooting                                          OKAY [  0.000s]
Finished. Total time: 0.000s

如此,手機重啟動後,已完成 root 了,這時單純用 adb shell 進去後打 su 則可以看到手機出現攔截的事件資訊,收工!

2014年4月15日 星期二

Linode - 使用 Backup 服務處理事件: An issue affecting the physical hardware this Linode resides on has been detected.

下班前收到這個 event ,結果就是繼續加班 Orz 若下班前的會議沒 delay 的話,我應該是在回家的路上被狂 call XDD

An issue affecting the physical hardware this Linode resides on has been detected.

We are working to resolve the issue as quickly as possible and will update you as soon as we have more information.
Your Linode will return to its previous state once the issue is resolved. Thank you for your patience and understanding.

記得以前問過學弟,他說 Linode 也會有維護的情況,沒想到真的碰到了...直接把你的機器關掉,我跟老闆說,這就像我們租的機房碰到火災一樣 XD 沒轍。

至於解法也沒有啥好辦法,一種就是等他維護好,另一種則是另外建一台 backup server 出來用,由於我們的服務都有建 backup ,所以就來體驗一下。

切換到被關掉的那台機的 backup 區,可以看到有一些選項可用:


此例就選 daily backup 的 restore to 選項,接著選要去哪台機器:


由於我已經先開了新機器(最下面那台),不然可以點 Add a Linode,此例也意外發現只能 restore to 同一區 DataCenter 的機器。最後,那台新機器的情況就會顯示正在處理:

 

處理完後,就可以 Boot 啦 :P

註:還好 Linode 只花了 3 小時處理,接著就可以把新機器著手進行關閉了。

2014年2月13日 星期四

iOS 開發筆記 - App Submission Feedback (Resolution Center) - non-consumable In-App Purchase(s)

最近一直收到 App Submission Feedback 信件轟炸,直到今天我終於搞懂這些 reviewer 的意思了 Orz 乃覺三十里!!

主因是使用了 non-consumable products,接著每次都收到一模模一樣樣的回應:

We found that your app offers In-App Purchase(s) that can be restored but does not include the required "Restore" feature to allow users to restore the previously purchased In-App Purchase(s), as specified in the Hosting Non-Consumable In-App Purchases section of the iTunes Connect Developer Guide:

"Users purchase non-consumable products only once, so if you host your own non-consumables, you need to provide a way for users to restore them. (You implement the restoreCompletedTransactions method in Store Kit to do so)."

To restore previously purchased In-App Purchase products, it would be appropriate to provide a "Restore" button and initiate the restore process when the "Restore" button is tapped by the user.

For more information on restoring In-App Purchases, see the section, Restoring Transactions, in the In-App Purchase Programming Guide.

A screenshot has been attached for your reference.

直到測試幾番後,終於搞懂他們在想什麼,也就是 non-consumable IAP products 必須提供類似 Restore button 才行,也不是沒實作,而是購買後才顯示出來,第一次還沒購買時,並不會顯示 Restore 字樣,就這樣一直調整 IAP 流程,每次調整都還是收到這樣的回應,直到把 non-consumable IAP products 一開始就加上 Restore button 時才通過。