5

i'm trying to trigger the encryption of my ICS device programmatically by launching an intent (Intent --> DevicePolicyManager.ACTION_START_ENCRYPTION). This works quite well. I would like to know whether there is sent an broadcast or sth like that to recognize if the user clicked on "encrypt device" or declined the request. I need to notice the users decision.

My second question concerns the method setStorageEncryption(admin, boolean), which is implemented within the DevicePolicyManager. Does a call of setStorageEncryption(admin, false) has any impacts on the device encryption, if I afterwards launch the Encryption intent which is mentioned above?

Kind regards

TZHX
  • 5,291
  • 15
  • 47
  • 56
user1168876
  • 157
  • 3
  • 14
  • 1
    "I would like to know whether there is sent an broadcast or sth like that to recognize if the user clicked on "encrypt device" or declined the request" -- AFAIK, no, probably because the encryption process will involve reboots. "I need to notice the users decision" -- you can call `getStorageEncryptionStatus()` as needed, I suppose. – CommonsWare Aug 09 '12 at 10:53
  • Well, i actually just need to know if the user clicked on "encrypt device" or not. Is there no possibility to get that information? – user1168876 Aug 09 '12 at 13:22
  • How would I fire that intent using adb? – Frederick Nord Jan 16 '15 at 18:10

1 Answers1

2

The intent DevicePolicyManager.ACTION_START_ENCRYPTION sends the user to Settings -> Security -> Encrypt Phone dialogue, where the user must confirm the action twice. Also the device need to have at least 80% battery and be connected to a charging cable.

If the user declines this action or he is prohibited if e.g. charging cable is not inserted, no broadcast is sent.

As CommonsWare correctly mentions, your application can regularly check the encryption status using DevicePolicyManager.getStorageEncryptionStatus().

Calling DevicePolicyManager.setStorageEncryption(admin, false) sets the minimum policy for that admin to not encrypted. Other admins can however have stronger policies.

Setting a not encrypted policy doesn't decrypt the device if it is already encrypted. Also it does not prevent the user to manually encrypt the device using Settings -> Security -> Encrypt Phone. The intent DevicePolicyManager.ACTION_START_ENCRYPTION is also not blocked in this case.

Aleksei Zyrianov
  • 2,294
  • 1
  • 24
  • 32
Marek Pola
  • 200
  • 1
  • 10