Release device without reset

121 views Asked by At

I'm using android management APIs, able to enroll and apply policies to the device.

When I release the device, the device is getting reset, I want to release without reset.

I tried the delete option,

def delete_device(device_name):
    # delete a device, which also reformats the device
    result = (androidmanagement.enterprises().devices()
              .delete(name=device_name, wipeDataFlags=['PRESERVE_RESET_PROTECTION_DATA']).execute())
    print('\nDevice deleted: ', result)
    return result

even tried without wipeDataFlags argument, device is still getting reset, of course device is de registered.

have tried issuing the RELINQUISH_OWNERSHIP command also

def issue_command(device_name, command_type):
    # issue a command to a device
    command = androidmanagement.enterprises().devices().issueCommand(
        name=device_name,
        body={"type": command_type}
    ).execute()
    print('\nCommand issued: ', command)
    return command

def relinquish_ownership(device_name):
    issue_command(device_name, 'RELINQUISH_OWNERSHIP')

nothing happens after applying/calling relinquish_ownership, even device won't get released.

1

There are 1 answers

1
Clark Samson On

It's important to note that the behavior of the devices.delete method in Android Management API depends on the management mode of the device.

For company-owned fully-managed devices and company-owned, personally-enabled (COPE) devices, the factory reset upon using devices.delete is the intended behavior.

The RELINQUISH_OWNERSHIP method you've tried is designed to remove the work profile without resetting the device, but it's specifically applicable to COPE devices. This will not work on fully-managed devices.

The wipeDataFlags argument controls specific data being wiped (SDCard and Reset Protection data), but the data on the device will still be wiped.