android 过滤cmcc,Android 无法通过cmcc wap2.0 test解决
最近發(fā)現(xiàn)中國(guó)移動(dòng)有個(gè)wap2.0測(cè)試,即測(cè)試你的瀏覽器是否能打開(kāi)移動(dòng)夢(mèng)網(wǎng)wap2.0網(wǎng)站,不知道的可以google一下cmcc wap2.0 test。用Android手機(jī)試了下,當(dāng)點(diǎn)擊測(cè)試鏈接的時(shí)候會(huì)出現(xiàn)無(wú)法解析網(wǎng)頁(yè)的情況,然后用同事Iphone試試,也不行。奇怪了,我們知道android 和 iphone都是用的webkit的引擎,難道webkit有這么搓,連個(gè)wap2.0都沒(méi)搞定。
網(wǎng)上有說(shuō)是wml沒(méi)開(kāi)啟,好吧,于是照著大神的指導(dǎo),將webkit封存的wml代碼開(kāi)啟,加入編譯系統(tǒng),前后各種調(diào)試做了2天,終于成功編譯得到libwebcore.so,果斷push進(jìn)機(jī)器,打開(kāi)測(cè)試,還是不行。。。頓時(shí)肉牛滿面。
靜下心來(lái),決定潛心研究下wap2.0為何物。這有個(gè)很好的網(wǎng)站分享之
http://www.developershome.com/wap/xhtmlmp/xhtml_mp_tutorial.asp?page=mimeTypesFileExtension
wap2.0 用的語(yǔ)言是XHTML MP,XHTML MP是XHTML的子集,在XHTML MP出現(xiàn)之前,WAP網(wǎng)站的開(kāi)發(fā)者們只能用WML和WML script來(lái)創(chuàng)建WAP的網(wǎng)站。而與此同時(shí),web的開(kāi)發(fā)者們卻在用強(qiáng)大得多的HTML、CSS、XHTML等來(lái)進(jìn)行傳統(tǒng)網(wǎng)站的開(kāi)發(fā)。所以XHTML MP的目標(biāo)就是瀏覽者在WAP和web上獲得盡可能相似的瀏覽體驗(yàn)。
好吧,我承認(rèn)上段是維基百科copy下來(lái)的
再看看XHTML MP 處理的MIME類型
The following three MIME types can be used for XHTML MP documents:
application/vnd.wap.xhtml+xml
application/xhtml+xml
text/html xhtml跟html類似,但語(yǔ)法上更加嚴(yán)格。相比之下html語(yǔ)法就顯得比較松散,對(duì)網(wǎng)頁(yè)編寫者來(lái)說(shuō),比較方便,但對(duì)于機(jī)器來(lái)說(shuō),語(yǔ)言的
語(yǔ)法越松散,處理起來(lái)就越困難。
就是說(shuō)XHTML MP可以加載以上3種類型的網(wǎng)頁(yè)。
在看了下webkit的代碼,都有支持啊,也就是說(shuō)webkit是支持XHTML MP的,那這樣為什么還過(guò)不了CMCC的測(cè)試,CMCC有這么牛逼?
偶然用同事諾基亞測(cè)試,竟然可以通過(guò),這是神馬情況。。
偶然又看到網(wǎng)上說(shuō)CMCC的網(wǎng)頁(yè)代碼本身又不是嚴(yán)格按照W3C標(biāo)準(zhǔn)來(lái)的, 導(dǎo)致在解析的時(shí)候出現(xiàn)了語(yǔ)法錯(cuò)誤提示。神馬意思?難道是網(wǎng)頁(yè)打開(kāi)的時(shí)候加載的MIME類型是application/xhtml+xml,但它本身代碼語(yǔ)法卻沒(méi)達(dá)到這個(gè)標(biāo)準(zhǔn)。于是決定把它降降級(jí),將上面2種
application/vnd.wap.xhtml+xml
application/xhtml+xml 網(wǎng)頁(yè)全部轉(zhuǎn)
text/html處理
于是在webkit 目錄下grep -R “vnd.wap.xhtml+xml' ./*
發(fā)現(xiàn)在external/webkit/Source/WebCore/dom/DOMImplementation.cpp有處理的代碼 PassRefPtr DOMImplementation::createDocument(const String& type, Frame* frame, const KURL& url, bool inViewSourceMode)
{
if (inViewSourceMode)
return HTMLViewSourceDocument::create(frame, url, type);
// Plugins cannot take HTML and XHTML from us, and we don't even need to initialize the plugin database for those.
if (type == "text/html")
return HTMLDocument::create(frame, url);
if (type == "application/xhtml+xml"
#if ENABLE(XHTMLMP)
|| type == "application/vnd.wap.xhtml+xml"
#endif
)
return Document::createXHTML(frame, url);
。。。。。。
}
將application/vnd.wap.xhtml+xml 和application/xhtml+xml改為跟text/html一樣
PassRefPtr DOMImplementation::createDocument(const String& type, Frame* frame, const KURL& url, bool inViewSourceMode)
{
if (inViewSourceMode)
return HTMLViewSourceDocument::create(frame, url, type);
// Plugins cannot take HTML and XHTML from us, and we don't even need to initialize the plugin database for those.
if (type == "text/html")
return HTMLDocument::create(frame, url);
if (type == "application/xhtml+xml"
#if ENABLE(XHTMLMP)
|| type == "application/vnd.wap.xhtml+xml"
#endif
)
//return Document::createXHTML(frame, url);
return HTMLDocument::create(frame, url);
。。。。。
}
然后編譯webkit,push進(jìn)去libwebcore.so
再打開(kāi)測(cè)試頁(yè)面,bingo通過(guò)啦。。
ok收工
總結(jié)
以上是生活随笔為你收集整理的android 过滤cmcc,Android 无法通过cmcc wap2.0 test解决的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: android arrays.xml 二
- 下一篇: android 相机 全功能,一加7系首