mirror of
https://github.com/TwidereProject/Twidere-Android
synced 2025-02-16 19:50:53 +01:00
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 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.
|
||||
@ -73,48 +78,32 @@ public class UserAgentUtils {
|
||||
|
||||
@WorkerThread
|
||||
@Nullable
|
||||
public static String getDefaultUserAgentStringSafe(Context context) {
|
||||
public static String getDefaultUserAgentStringSafe(final Context context) {
|
||||
if (Looper.myLooper() == Looper.getMainLooper()) {
|
||||
//noinspection ResourceType
|
||||
return getDefaultUserAgentString(context);
|
||||
}
|
||||
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 {
|
||||
final FetchUserAgentRunnable runnable = new FetchUserAgentRunnable(context);
|
||||
handler.post(runnable);
|
||||
runnable.waitForExecution();
|
||||
return runnable.getUserAgent();
|
||||
handler.post(task);
|
||||
return task.get(1, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (TimeoutException e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
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)
|
||||
static class NewApiWrapper {
|
||||
private NewApiWrapper() {
|
||||
|
@ -169,7 +169,7 @@ internal object AccountDataQueue {
|
||||
} else handler.post {
|
||||
future.run()
|
||||
}
|
||||
return future.get()
|
||||
return future.get(1, TimeUnit.SECONDS)
|
||||
}
|
||||
|
||||
fun peekAuthToken(manager: AccountManager, account: Account, authTokenType: String): String? {
|
||||
@ -179,7 +179,7 @@ internal object AccountDataQueue {
|
||||
} else handler.post {
|
||||
future.run()
|
||||
}
|
||||
return future.get()
|
||||
return future.get(1, TimeUnit.SECONDS)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user