Android: fix cookies lost on Android 5.0 and above (#19770)

Summary:
This fixes cookie missing bug on Android 5.0 and above.
On Android 5.0 and above, after the app successfully obtains the cookie, you kills the App within 30 seconds and restarts the App. It accesses the interface that needs to carry the cookie and finds that the cookie does not exist.

Updated tests for the addCookies function to include test cases specifying Android version, and tested on the command line in my app to make sure it has the expected behavior.

Updated tests for the addCookies function to include test cases specifying Android version, and tested on the command line in my app to make sure it has the expected behavior.

[ANDROID] [BUGFIX] [Cookie] - Fix cookies lost on Android 5.0 and above
Pull Request resolved: https://github.com/facebook/react-native/pull/19770

Differential Revision: D10114102

Pulled By: hramos

fbshipit-source-id: 5b4766f02f70541fd46ac5db36f1179fe386ac7a
This commit is contained in:
chenwenyu 2018-09-28 16:00:35 -07:00 committed by Facebook Github Bot
parent af181fb192
commit ea53727e16
1 changed files with 1 additions and 0 deletions

View File

@ -129,6 +129,7 @@ public class ForwardingCookieHandler extends CookieHandler {
for (String cookie : cookies) { for (String cookie : cookies) {
addCookieAsync(url, cookie); addCookieAsync(url, cookie);
} }
getCookieManager().flush();
mCookieSaver.onCookiesModified(); mCookieSaver.onCookiesModified();
} }
} }