Cleanup ForwardingCookieHandler class

Summary:
This diff cleansup the class ForwardingCookieHandler, refactoring constants and adding annotations to avoid lint errors

changelog: [Internal]

Reviewed By: JoshuaGross

Differential Revision: D22771914

fbshipit-source-id: 4fdff2df5ea103f93519c2f4504288202114b1fc
This commit is contained in:
David Vacca
2020-07-31 10:44:05 -07:00
committed by Facebook GitHub Bot
parent f829722b54
commit b7d8641a28
3 changed files with 9 additions and 7 deletions
@@ -45,7 +45,7 @@ public class ReactQueueConfigurationSpec {
public static ReactQueueConfigurationSpec createDefault() {
MessageQueueThreadSpec spec =
Build.VERSION.SDK_INT < 21
Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP
? MessageQueueThreadSpec.newBackgroundThreadSpec(
"native_modules", LEGACY_STACK_SIZE_BYTES)
: MessageQueueThreadSpec.newBackgroundThreadSpec("native_modules");
@@ -40,8 +40,9 @@ public class ForwardingCookieHandler extends CookieHandler {
private static final String VERSION_ONE_HEADER = "Set-cookie2";
private static final String COOKIE_HEADER = "Cookie";
// As CookieManager was synchronous before API 21 this class emulates the async behavior on <21.
private static final boolean USES_LEGACY_STORE = Build.VERSION.SDK_INT < 21;
// As CookieManager was synchronous before API 21 this class emulates the async behavior on < 21.
private static final boolean USES_LEGACY_STORE =
Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP;
private final CookieSaver mCookieSaver;
private final ReactContext mContext;
@@ -100,6 +101,7 @@ public class ForwardingCookieHandler extends CookieHandler {
}
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void clearCookiesAsync(final Callback callback) {
CookieManager cookieManager = getCookieManager();
if (cookieManager != null) {
@@ -148,7 +150,7 @@ public class ForwardingCookieHandler extends CookieHandler {
}
}
@TargetApi(21)
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void addCookieAsync(String url, String cookie) {
CookieManager cookieManager = getCookieManager();
if (cookieManager != null) {
@@ -266,7 +268,7 @@ public class ForwardingCookieHandler extends CookieHandler {
});
}
@TargetApi(21)
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void flush() {
CookieManager cookieManager = getCookieManager();
if (cookieManager != null) {
@@ -116,8 +116,8 @@ public class OkHttpClientProvider {
specs.add(ConnectionSpec.CLEARTEXT);
client.connectionSpecs(specs);
} catch (Exception exc) {
FLog.e("OkHttpClientProvider", "Error while enabling TLS 1.2", exc);
} catch (Exception ex) {
FLog.e("OkHttpClientProvider", "Error while enabling TLS 1.2", ex);
}
}