Skip to content

Commit

Permalink
Cleanup ForwardingCookieHandler class
Browse files Browse the repository at this point in the history
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
  • Loading branch information
mdvacca authored and facebook-github-bot committed Jul 31, 2020
1 parent f829722 commit b7d8641
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static Builder builder() {

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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -100,6 +101,7 @@ protected void onPostExecuteGuarded(Boolean result) {
}
}

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void clearCookiesAsync(final Callback callback) {
CookieManager cookieManager = getCookieManager();
if (cookieManager != null) {
Expand Down Expand Up @@ -148,7 +150,7 @@ public void run() {
}
}

@TargetApi(21)
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void addCookieAsync(String url, String cookie) {
CookieManager cookieManager = getCookieManager();
if (cookieManager != null) {
Expand Down Expand Up @@ -266,7 +268,7 @@ public void run() {
});
}

@TargetApi(21)
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void flush() {
CookieManager cookieManager = getCookieManager();
if (cookieManager != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,8 @@ public static OkHttpClient.Builder enableTls12OnPreLollipop(OkHttpClient.Builder
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);
}
}

Expand Down

0 comments on commit b7d8641

Please sign in to comment.