안드로이드(Android 5.0) Lollipop Webview issue

안드로이드 롤리팝 Webview 에서 발생한 문제들..
몇일전부터 안드로이드 5.0 버전으로 테스트중인 Nexus 5 에서 결제작업을 연동중에

문제점들이 발견되기 시작했다.

첫번째 : 의외로 간단하게 해결된 문제

HTTPS > HTTP 전송시 내장 브라우저에서 block 시켜 데이터 전송이 안되는 문제였다. 


[blocked] The page at 'https://xxx' was loaded over HTTPS, but ran insecure content from http://xxx.css': this content should also be loaded over HTTPS.


라는 메세지를 콘솔창으로 마구 뱉는 문제였다...

이 문제는 롤리팝에서 변경된 문제였다.

구글링 해보았으나 실제로 안드로이드 관련정보는 찾을수 없었고

해결방안은 Anroid 5.0 Changes 를 보고 찾을 수 있었다.

WebView



If your app targets API level 21 or higher:
  • The system blocks mixed content and third party cookies by default. To allow mixed content and third party cookies, use the setMixedContentMode() and setAcceptThirdPartyCookies() methods respectively.
  • The system now intelligently chooses portions of the HTML document to draw. This new default behavior helps to reduce memory footprint and increase performance. If you want to render the whole document at once, disable this optimization by calling enableSlowWholeDocumentDraw().
  • If your app targets API levels lower than 21: The system allows mixed content and third party cookies, and always renders the whole document at once.

혼합된 컨텐츠와 서드파티 쿠키가 설정에 따라 Webview 에서 Block 시키는 게 기본이 됬다는 내용이였다.


public abstract void setMixedContentMode (int mode)


Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. By default, apps that target KITKAT or below default to MIXED_CONTENT_ALWAYS_ALLOW. Apps targeting LOLLIPOP default toMIXED_CONTENT_NEVER_ALLOW. The preferred and most secure mode of operation for the WebView is MIXED_CONTENT_NEVER_ALLOW and use of MIXED_CONTENT_ALWAYS_ALLOW is strongly discouraged.


MIXED_CONTENT_ALWAYS_ALLOW : 항상 허용



MIXED_CONTENT_COMPATIBILITY_MODE : 호환성 모드



MIXED_CONTENT_NEVER_ALLOW : 허용 안함

해결 소스

mWebView.getSettings().setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW);

CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.setAcceptThirdPartyCookies(mWebView, true);



두번째는 

문자셋 문제

국내 결제 시스템을 보면 대부분 서버가 대부분 euc-kr 로 되어있는데 

서버의 환경은 대부분 리눅스 UTF-8 가 일반적이라 

서로 통신간에 문자셋 문제가 발생할 위험이 높다.

가장 큰 문제는 한글이 깨지는 문제다.

대부분의 문제는 

document.charset = "EUC-KR";

이방법으로 해결이된다.

근데 Android 5.0 에선 -_- , 크롬 viewport rendreing , Nexus 5 환경에선 잘되는데...


 

오늘안에 해결이 됬으면 좋겠다...


댓글

이 블로그의 인기 게시물

넥서스유저의 Galaxy S6 Edge 리뷰