googlesamples / android-testdpc

Test DPC is a sample device policy controller for use with Android Enterprise. It gives developers the ability to see how their app will behave in a managed context such as device owner or within a managed profile. Users can set up a work profile, enable work apps, set applications restrictions, manage security polices, and much more. The app also serves as a implementation reference for other DPCs
https://play.google.com/store/apps/details?id=com.afwsamples.testdpc
Apache License 2.0
778 stars 328 forks source link

Crash when lockNow with FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY #68

Closed ss14 closed 2 years ago

ss14 commented 6 years ago

Cause: When the device does not support file based encryption, dpm.lockNow(flags) in PolicyManagementFragment throws UnsupportedOperationException.

Possible Counter Measure: Put a check if the device supports FBE before pass

Exception Stack: 07-13 15:58:31.735 1210153 13801 13801 D AndroidRuntime: Shutting down VM 07-13 15:58:31.736 1210153 13801 13801 E AndroidRuntime: FATAL EXCEPTION: main 07-13 15:58:31.736 1210153 13801 13801 E AndroidRuntime: Process: com.afwsamples.testdpc, PID: 13801 07-13 15:58:31.736 1210153 13801 13801 E AndroidRuntime: java.lang.UnsupportedOperationException: FLAG_EVICT_CREDENTIAL_ENCRYPTION_KEY only applies to FBE devices 07-13 15:58:31.736 1210153 13801 13801 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:2033) 07-13 15:58:31.736 1210153 13801 13801 E AndroidRuntime: at android.os.Parcel.readException(Parcel.java:1967) 07-13 15:58:31.736 1210153 13801 13801 E AndroidRuntime: at android.app.admin.IDevicePolicyManager$Stub$Proxy.lockNow(IDevicePolicyManager.java:5749) 07-13 15:58:31.736 1210153 13801 13801 E AndroidRuntime: at android.app.admin.DevicePolicyManager.lockNow(DevicePolicyManager.java:3199) 07-13 15:58:31.736 1210153 13801 13801 E AndroidRuntime: at com.afwsamples.testdpc.policy.PolicyManagementFragment.lambda$showLockNowPrompt$13$PolicyManagementFragment(PolicyManagementFragment.java:1102) 07-13 15:58:31.736 1210153 13801 13801 E AndroidRuntime: at com.afwsamples.testdpc.policy.PolicyManagementFragment$$Lambda$14.onClick(Unknown Source:6) 07-13 15:58:31.736 1210153 13801 13801 E AndroidRuntime: at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:177) 07-13 15:58:31.736 1210153 13801 13801 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:106) 07-13 15:58:31.736 1210153 13801 13801 E AndroidRuntime: at android.os.Looper.loop(Looper.java:164) 07-13 15:58:31.736 1210153 13801 13801 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:7000) 07-13 15:58:31.736 1210153 13801 13801 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 07-13 15:58:31.736 1210153 13801 13801 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:441)

jscott1989 commented 2 years ago

Closing all outstanding pull requests + issues as we've reworked the app to now build with Bazel. With this change, we should be able to properly accept pull requests going forward so these won't sit around for so long. If this is still relevant please check it with the latest version [Using the Android T SDK] and re-open.