hawk icon indicating copy to clipboard operation
hawk copied to clipboard

IllegalStateException: SharedPreferences in credential encrypted storage are not available until after user is unlocked

Open nikedlab opened this issue 6 years ago • 4 comments

Please try to fill all questions below before submitting an issue.

  • [x] On which android versions do you have this issue? : 8.1.0
  • [x] On which phones do you have this issue? : Google Pixel XL
  • [x] Which hawk version are you using? : 2.0.1
  • [x] Does this issue happen always or is it flaky? : always
  • [x] Can you write failing test? : no
  • [ ] If it is Hawk.put and Hawk.get issue, can you write down which data you were trying to save and get it back? -
  • [ ] Is the data you are trying to save it huge or small? -

The problem is when I tried to access to stored data when device is just started. BootReceiver fired when received <action android:name="android.intent.action.LOCKED_BOOT_COMPLETED" />, service started with success but after crashed with exception java.lang.IllegalStateException: SharedPreferences in credential encrypted storage are not available until after user is unlocked Root of cause is known, storage is crypted until user is not logged in. Accordingly to https://developer.android.com/training/articles/direct-boot should be created second context with decrypted storage. What I should do in this case? Is it required to write own Storage implementation?

nikedlab avatar Aug 29 '18 07:08 nikedlab

Hi! Is any solution?

nikedlab avatar Aug 31 '18 16:08 nikedlab

You should wait until user unlock or use device protected storage

k4dima avatar May 22 '19 12:05 k4dima

What is an example for device protected storage?

karthikts-github avatar Jan 21 '20 14:01 karthikts-github

@KrazyKode101 google android device protected storage

k4dima avatar Mar 14 '20 16:03 k4dima