I carefully studied the Oma download mechanism and shared the research results with you.
Network Processing Layer
Package COM. eshore. oma; <br/> Import Java. util. hashmap; <br/> Import android. content. context; <br/> Import com.eshore.ezone.net. baseaccessor; <br/> // network layer <br/> public class omaconnection {<br/> Public static omade1_parseomaurl (context, string URL) {<br/> string [] arr = URL. split ("//? "); <Br/> string urlstring = arr [0]; <br/> hashmap <string, string> Params = new hashmap <string, string> (); <br/> arr = arr [1]. split ("&"); <br/> for (INT I = 0; I <arr. length; I ++) {<br/> string [] string = arr [I]. split ("="); <br/> If (string. length = 2) {<br/> Params. put (string [0], string [1]); <br/>} else {<br/> Params. put (string [0], ""); <br/>}< br/> return baseaccessor. omarequest (context, urlst Ring, Params); <br/>}</P> <p> Public static void installnotify (context, string URL) {<br/> string [] arr = URL. split ("//? "); <Br/> string urlstring = arr [0]; <br/> hashmap <string, string> Params = new hashmap <string, string> (); <br/> arr = arr [1]. split ("&"); <br/> for (INT I = 0; I <arr. length; I ++) {<br/> string [] string = arr [I]. split ("="); <br/> If (string. length = 2) {<br/> Params. put (string [0], string [1]); <br/>} else {<br/> Params. put (string [0], ""); <br/>}< br/> string result = baseaccessor. derequest (context, urlstring, Params); <br/>}< br/>
Get the description file downloaded from Oma using parseromaurl
The installnofiy method returns the final status when the installation is complete.
Model Layer
Package com. eshore. oma; <br/> public class omadescription {<br/> Public String objecturi; <br/> Public String installpolicyuri; <br/>}< br/>
Objecturi is the URI of the object to be downloaded.
Installpolicyuri is the address of the server to be notified when the installation is complete.
Convert the returned xml to the oma download description object.
Package COM. eshore. oma; <br/> Import Java. io. stringreader; <br/> Import javax. XML. parsers. documentbuilder; <br/> Import javax. XML. parsers. documentbuilderfactory; <br/> Import Org. w3C. dom. document; <br/> Import Org. w3C. dom. element; <br/> Import Org. w3C. dom. nodelist; <br/> Import Org. XML. sax. inputsource; <br/> Import COM. eshore. ezone. util. constants; <br/> Import android. content. sharedpreferences; <br/> Import android. util. log; <br/> public class omaparser {<br/> Public static omade1_parserstring (string XML) {<br/> log. D ("dddd", XML); <br/> omadeworkflow omad = new omadeworkflow (); <br/> documentbuilderfactory docbuilderfactory = NULL; <br/> documentbuilder docbuilder = NULL; <br/> document DOC = NULL; <br/> try {<br/> docbuilderfactory = documentbuilderfactory. newinstance (); <br/> docbuilder = docbuilderfactory. newdocumentbuilder (); <br/> stringreader READ = new stringreader (XML. replace ('&', '*'); <br/> inputsource source = new inputsource (read); <br/> Doc = docbuilder. parse (source); <br/> element root = Doc. getdocumentelement (); <br/> nodelist = root. getelementsbytagname ("objecturi"); <br/> omad. objecturi = nodelist. item (0 ). getfirstchild (). getnodevalue () <br/>. replace ('*', '&'); <br/> nodelist nodelist2 = root. getelementsbytagname ("installpolicyuri"); <br/> omad. installpolicyuri = nodelist2.item (0 ). getfirstchild (). getnodevalue () <br/>. replace ('*', '&'); <br/>} catch (exception e) {<br/> E. printstacktrace (); <br/>}< br/> return omad; <br/>}< br/>}
The descriptor format is as follows:
<Media xmlns = "http://www.openmobilealliance.org/xmlns/dd"> <br/> <objecturi> </P> <p> http://xxx.xxxx.xxx/cot/20100409095238.apkID=035000000000000008320000000000000000001858 </P> <p> </objecturi> <br/> <size & gt; 123000 </size> <br/> <type> application/X-cab-compressed </type> <br/> <Name> DSDs </Name> <br/> <description> SSS </description> <br/> <installpolicyuri> </P> <p> http://xxx.xxxx.xxx/report? Id = 035000000000000008320000000000000000001858 </P> <p> </installpolicyuri> <br/> <nexturl> http://xxx.xxxx.xxx/portalapp </nexturl> <br/> </media>