Android: Emulator factory data reset menu option n

2020-07-17 06:56发布

问题:

I'm attempting to test a new Android system level app of my own creation, that catches various system event hooks after a device factory reset has been performed.

Through the Android Studio AVD Manager i have created multiple emulated Android TV Devices, flavours Oreo (8.0.0) and Pi (9.0) but none of them allow a successful factory reset to be applied.

The steps i've have carried out:

  • Launch the freshly created emulated device (with the system partition writable option) eg.

~/Android/Sdk/emulator/emulator -avd Android_TV_1080p_API_26_Oreo_8.0.0_ -writable-system

  • Use adb root permissions to allow remount to be successful eg.

adb root

  • Re-mount to facilitate the root access to the emulated device eg.

adb remount

  • Create the system app directory eg.

adb -e shell mkdir /system/priv-app/ftiApp

  • Push the new system app to the targeted directory eg.

adb push app-debug.apk /system/priv-app/ftiApp/

  • Install the pushed System App eg.

adb install -r -d -t app-debug.apk

  • Reboot the device, to pick up the device changes eg.

adb reboot

I can see the installed system app in the system apps directory, and it's at this point that i want to apply the factory reset, so that the emulated device is kicked back to a state where first time boot setup wizard events should be fired that my system app is listening for.

(For Oreo 8.0.0) Navigating to the following menu option Settings >Storage & Reset >Factory Data Reset and selecting the Factory data reset button always results in failure with the following log message:

09-07 12:13:57.911 5979-5979/? I//system/bin/uncrypt:   received command: [--wipe_data
    --reason=ResetConfirmFragment
    --locale=en-US
    ] (57)
09-07 12:13:57.911 5979-5979/? E//system/bin/uncrypt: failed to set bootloader message: failed to find /misc partition
09-07 12:13:57.912 5979-5979/? I//system/bin/uncrypt:   received 0, exiting now
09-07 12:13:57.912 1962-5908/system_process E/RecoverySystemService: uncrypt failed with status: -1
09-07 12:13:57.916 1962-5908/system_process E/MasterClear: Can't perform master clear/factory reset
    java.io.IOException: Reboot failed (no permissions?)
        at android.os.RecoverySystem.bootCommand(RecoverySystem.java:935)
        at android.os.RecoverySystem.rebootWipeUserData(RecoverySystem.java:773)
        at com.android.server.MasterClearReceiver$1.run(MasterClearReceiver.java:75)
09-07 12:14:06.572 1962-2893/system_process I/GnssLocationProvider: WakeLock acquired by sendMessage(REPORT_SV_STATUS, 0, com.android.server.location.GnssLocationProvider$SvStatusInfo@7f1448f)

This failure to find a /misc partition seems to be the crux of the matter, but i've no idea how to solve it as these emulated devices are being spun up by AVD Manager as part of Android Studio using standard images?

(Note this is the latest incarnation of Android Studio 3.1.4)

Is factory reset in this way unsupported by these emulated devices? Or is something legitimately wrong with the configuration of these devices stopping the Factory reset data from working?