fixed signing properties
This commit is contained in:
parent
2d3d536e6d
commit
685e61cc7e
Binary file not shown.
|
@ -31,6 +31,11 @@ import android.webkit.WebSettings;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.concurrent.FutureTask;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import java.util.concurrent.TimeoutException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by mariotaku on 15/4/12.
|
* Created by mariotaku on 15/4/12.
|
||||||
|
@ -73,48 +78,32 @@ public class UserAgentUtils {
|
||||||
|
|
||||||
@WorkerThread
|
@WorkerThread
|
||||||
@Nullable
|
@Nullable
|
||||||
public static String getDefaultUserAgentStringSafe(Context context) {
|
public static String getDefaultUserAgentStringSafe(final Context context) {
|
||||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||||
//noinspection ResourceType
|
//noinspection ResourceType
|
||||||
return getDefaultUserAgentString(context);
|
return getDefaultUserAgentString(context);
|
||||||
}
|
}
|
||||||
final Handler handler = new Handler(Looper.getMainLooper());
|
final Handler handler = new Handler(Looper.getMainLooper());
|
||||||
|
FutureTask<String> task = new FutureTask<>(new Callable<String>() {
|
||||||
|
@Override
|
||||||
|
public String call() throws Exception {
|
||||||
|
return getDefaultUserAgentString(context);
|
||||||
|
}
|
||||||
|
});
|
||||||
try {
|
try {
|
||||||
final FetchUserAgentRunnable runnable = new FetchUserAgentRunnable(context);
|
handler.post(task);
|
||||||
handler.post(runnable);
|
return task.get(1, TimeUnit.SECONDS);
|
||||||
runnable.waitForExecution();
|
} catch (InterruptedException e) {
|
||||||
return runnable.getUserAgent();
|
throw new RuntimeException(e);
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (TimeoutException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
} finally {
|
} finally {
|
||||||
handler.removeCallbacksAndMessages(null);
|
handler.removeCallbacksAndMessages(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FetchUserAgentRunnable implements Runnable {
|
|
||||||
|
|
||||||
private final Context context;
|
|
||||||
private String userAgent;
|
|
||||||
private boolean userAgentSet;
|
|
||||||
|
|
||||||
public FetchUserAgentRunnable(Context context) {
|
|
||||||
this.context = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
userAgent = getDefaultUserAgentString(context);
|
|
||||||
userAgentSet = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getUserAgent() {
|
|
||||||
return userAgent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void waitForExecution() {
|
|
||||||
//noinspection StatementWithEmptyBody
|
|
||||||
while (!userAgentSet) ;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
|
||||||
static class NewApiWrapper {
|
static class NewApiWrapper {
|
||||||
private NewApiWrapper() {
|
private NewApiWrapper() {
|
||||||
|
|
|
@ -169,7 +169,7 @@ internal object AccountDataQueue {
|
||||||
} else handler.post {
|
} else handler.post {
|
||||||
future.run()
|
future.run()
|
||||||
}
|
}
|
||||||
return future.get()
|
return future.get(1, TimeUnit.SECONDS)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun peekAuthToken(manager: AccountManager, account: Account, authTokenType: String): String? {
|
fun peekAuthToken(manager: AccountManager, account: Account, authTokenType: String): String? {
|
||||||
|
@ -179,7 +179,7 @@ internal object AccountDataQueue {
|
||||||
} else handler.post {
|
} else handler.post {
|
||||||
future.run()
|
future.run()
|
||||||
}
|
}
|
||||||
return future.get()
|
return future.get(1, TimeUnit.SECONDS)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue