From 881958d4b9d28e8723c70a51bec3b9f1544d8e77 Mon Sep 17 00:00:00 2001 From: mukesh agrawal Date: Wed, 11 Oct 2017 17:43:27 -0700 Subject: WiFiInstaller: catch exceptions on both delete paths WiFiInstaller provides the ability to automatically install a Passpoint configuration, if that configuration is served using the 'application/x-wifi-config' MIME type. Before installing the configuration, WiFiInstaller reads the configuration data into memory, and then attempts to delete the file. If the file was provided using the DocumentsContract API, then a failure to delete will be caught and logged. The installation of the configuration can still succeed. If, however, the file was provided using a ContentResolver, then a deletion failure causes the install process to fail. When Chrome is used to download a Passpoint configuration from a Passpoint provider, we see that the install reliably fails. The failure occurs because the config file is a) not provided using a DocumentsContract, and b) can not be deleted. To resolve the failure, we handle a failure to delete a ContentResovler-provided config the same way that we handle a failure to delete a DocumentsContract-provided config. Namely: catch the exception, log the failure, and continue to install the config. We will work separately to determine why this problem is only now surfacing. (We suspect some change in the way that Chrome provides the file to WiFiInstaller.) BUG: 66971720 Test: manual Manual test ----------- 1. flash build with changes onto device 2. open passpoint.boingo.com in chrome 3. scroll to bottom of page 4. tap 'Create Profile' 5. enter username and password from bug 6. tap 'Download Profile' 7. see 'Chrome needs storage access...' prompt 8. tap 'CONTINUE' 9. see 'Allow Chrome...' prompt 10. tap 'ALLOW' 11. see 'Install Wi-Fi credentials' prompt 12. tap 'INSTALL' 13. see 'Credentials installed' dialog 14. adb logcat -d | grep 'could not delete' 10-12 17:23:23.759 17030 17030 E WifiInstaller: could not delete document content://com.android.chrome.FileProvider/downloads/BoingoPasspointProfile (last step confirms that this patch was necessary) Change-Id: I5cc4ac9cec8d6942f64ede696ccac3a6d9204922 --- src/com/android/certinstaller/WiFiInstaller.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/com/android/certinstaller/WiFiInstaller.java b/src/com/android/certinstaller/WiFiInstaller.java index b745211..90b8eb7 100644 --- a/src/com/android/certinstaller/WiFiInstaller.java +++ b/src/com/android/certinstaller/WiFiInstaller.java @@ -147,14 +147,14 @@ public class WiFiInstaller extends Activity { * @param context The context of the current application */ private static void dropFile(Uri uri, Context context) { + try { if (DocumentsContract.isDocumentUri(context, uri)) { - try { - DocumentsContract.deleteDocument(context.getContentResolver(), uri); - } catch (Exception e) { - Log.e(TAG, "could not delete document " + uri); - } + DocumentsContract.deleteDocument(context.getContentResolver(), uri); } else { - context.getContentResolver().delete(uri, null, null); + context.getContentResolver().delete(uri, null, null); } + } catch (Exception e) { + Log.e(TAG, "could not delete document " + uri); + } } } -- cgit v1.2.3