Prevent connection to server until Android permissions granted.

Server pops up dialog requesting file system access when the server is
launched. This is only obvious when the device is unlocked, otherwise this
pop up is never displayed.

Fixed by waiting for the user to grant permissions by preventing starting
a target app until the server is ready to open captures.
This commit is contained in:
Michael Rennie
2017-06-12 11:55:41 +01:00
committed by Baldur Karlsson
parent 81610d5e05
commit 53c0c20c8a
@@ -13,5 +13,15 @@ public class Loader extends android.app.NativeActivity
super.onCreate(savedInstanceState);
// Popup a dialog if we haven't granted Android storage permissions.
requestPermissions(new String[]{android.Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);
// Request is asynchronous, so prevent connection to server until permissions granted.
while(checkSelfPermission(android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= android.content.pm.PackageManager.PERMISSION_GRANTED)
{
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
break;
}
}
}
}