mirror of
https://github.com/M66B/FairEmail.git
synced 2026-04-09 02:23:38 +02:00
Wait for installing security provider
This commit is contained in:
@@ -4,7 +4,12 @@ import android.content.Intent;
|
||||
|
||||
import com.google.android.gms.security.ProviderInstaller;
|
||||
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class ApplicationSecure extends ApplicationEx implements ProviderInstaller.ProviderInstallListener {
|
||||
private static final CountDownLatch lock = new CountDownLatch(1);
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
@@ -15,6 +20,7 @@ public class ApplicationSecure extends ApplicationEx implements ProviderInstalle
|
||||
@Override
|
||||
public void onProviderInstalled() {
|
||||
Log.i("Security provider installed");
|
||||
lock.countDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -22,5 +28,18 @@ public class ApplicationSecure extends ApplicationEx implements ProviderInstalle
|
||||
Log.i("Security provider install failed" +
|
||||
" errorCode=" + errorCode +
|
||||
" recoveryIntent=" + recoveryIntent);
|
||||
lock.countDown();
|
||||
}
|
||||
|
||||
public static boolean waitProviderInstalled() {
|
||||
Log.i("Security provider wait");
|
||||
try {
|
||||
boolean succeeded = lock.await(500L, TimeUnit.MILLISECONDS);
|
||||
Log.i("Security provider wait succeeded=" + succeeded);
|
||||
return succeeded;
|
||||
} catch (InterruptedException ex) {
|
||||
Log.e(ex);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user