Android O failing to inflate webview after AFW enrollment

丶灬走出姿态 提交于 2019-12-04 12:52:05
Fred

This is a bug in Android O: if Chrome is disabled in one of the profiles then WebView is broken for both profiles until it's updated by Play.

To fix this issue during provisioning and avoid having to update WebView, you can enable Chrome in the work profile using DevicePolicyManager.enableSystemApp() with the package name com.android.chrome, and then prevent the user from disabling it using DevicePolicyManager.setUninstallBlocked().

If you then want to prevent the user from using the Chrome browser, you should use DevicePolicyManager.setPackagesSuspended() instead of DevicePolicyManager.setApplicationHidden().

I found a workaround which may help someone else. Before we start AFW enrollment , the developer options in device shows Webview Implementation to be Chrome. Android System Webview is disabled. At this point if I go to playstore, I can see Android System Webview but nothing happens when I click 'Enable'. After we do the AFW, and we see the managed profile has been successfully created, if I go to playstore now, I see an 'update' button for Android System Webview and I'm able to do the update. Once complete, if I look at the developer options, the webview implementation has switched from chrome to system webview. After this, if I launch my app in the work container, I do not see the crash and the app works as expected. Also, once we've removed the work profile, the webview implementation switches back to chrome. Note that same thing happens in Nexus device also but we didn't need to do any update of webview. The webview implementation switches back and forth between chrome and system webview, and things work. Its only in Pixel that we do the update to make it work.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!