No delay when already has permission

This commit is contained in:
Gregory
2023-12-24 19:43:34 +03:00
parent 4e26a02d78
commit 6edd7edcd2
2 changed files with 14 additions and 12 deletions

View File

@@ -7,7 +7,7 @@ class Installers {
static int _resPermShizuku = -2; // not set
static Future waitWhile(bool Function() test,
[Duration pollInterval = const Duration(milliseconds: 100)]) {
[Duration pollInterval = const Duration(milliseconds: 250)]) {
var completer = Completer();
check() {
if (test()) {
@@ -31,10 +31,12 @@ class Installers {
_channel.setMethodCallHandler(handleCalls);
_callbacksApplied = true;
}
await _channel.invokeMethod('checkPermissionShizuku');
await waitWhile(() => _resPermShizuku == -2);
int res = _resPermShizuku;
_resPermShizuku = -2;
int res = await _channel.invokeMethod('checkPermissionShizuku');
if(res == -2) {
await waitWhile(() => _resPermShizuku == -2);
res = _resPermShizuku;
_resPermShizuku = -2;
}
return res;
}