[formerly] Baidu bus offline data format Analysis--4. Summary

Source: Internet
Author: User

Two more questions are not resolved.

(1) Prov_city_list.json after download, if it becomes an object of com.baidu.bus.f.b?

In 3. In the 14th step of loading the city list, the member C of Hobject is assigned a value, and the type is COM.BAIDU.BUS.F.A, looking up how this object is generated:

invoke-static {v0, p1}, Lcom/baidu/bus/net/a/b;->a (ljava/lang/string; lcom/baidu/a/a/m;) Lcom/baidu/bus/f/a;move-result-object V0

It appears to be a static method of the Com.baidu.bus.net.a.b class, passing in two arguments, the first being the string literal after decoding (UTF-8), and the second being the function (the A () method of the COM.BAIDU.BUS.NET.A.C Class) passed in. The COM.BAIDU.A.A.M object. In the A () method of the Com.baidu.bus.net.a.b class, there is this code:

Iget-object v1, p1, lcom/baidu/bus/base/f;->b:ljava/lang/string;invoke-static {v1}, lcom/baidu/bus/net/a/g;-> A (ljava/lang/string;) lcom/baidu/bus/f/a;

Called The A () method of COM.BAIDU.BUS.NET.A.G and passed in the object of the Com.baidu.bus.base.f class, which is actually the second argument, and COM.BAIDU.A.A.M is a derived class. With step 3.2 (9), we know that the value of the B member of this instance is the string "City_list", which has the code in the A () method of the COM.BAIDU.BUS.NET.A.G class:

: Cond_0const-string v1, "City_list" invoke-virtual {p0, v1}, Ljava/lang/string;->equals (Ljava/lang/object;) Zmove-result V1IF-EQZ v1,: Cond_1new-instance v0, Lcom/baidu/bus/f/b;invoke-direct {v0}, lcom/baidu/bus/f/b;->< Init> () V

The Com.baidu.bus.f.b object is created here. In the Com.baidu.bus.net.a.b class, after the Com.baidu.bus.f.b object has been obtained, its A () method is called:

Move-result-object v1invoke-virtual {v1, v0}, Lcom/baidu/bus/f/a;->a (lcom/baidu/bus/base/e;) Lcom/baidu/bus/f/a;

By looking at the A () method of the Com.baidu.bus.f.b class, only the Alllist and hotcitylist in Jsonobject are parsed, respectively, into its members B and a (both ArrayList).
As for JSON parsing, you can see

New-instance V0, Lcom/baidu/bus/base/e;invoke-direct {v0, p0}, Lcom/baidu/bus/base/e;-><init> (Ljava/lang/ String;) V

The COM.BAIDU.BUS.BASE.E class is used here to see that it is derived from jsonobject and that the actual parsing is also a library function.

(2) How are the details of the cities contained in each province obtained?

3. Loading the city list describes the process of getting Prov_city_list.json, the downloaded action is mainly in the com.baidu.bus.activity.ch class, already know that the class is derived from Asynctask, this class has a The OnPostExecute () method is the action that is given to the UI thread after the Doinbackground () method finishes executing. Viewing the Ch class overloads this method, in addition to changing the background image of the pop-up cue box to Loading_desc_checkofflinedatastatus (ID 0x7f0200c9):

(the original is a transparent background, white font, here in order to display convenient, changed to a black background)

What's more, it's called the offlinedatamanageactivity inside of the method J

Iget-object V0, P0, lcom/baidu/bus/activity/ch;->a:lcom/baidu/bus/activity/offlinedatamanageactivity; invoke-static {v0}, Lcom/baidu/bus/activity/offlinedatamanageactivity;->j (lcom/baidu/bus/activity/ offlinedatamanageactivity;) V

To see the J method inside the offlinedatamanageactivity, there are two loops, each of which is called the B () method for each element inside the offlinedatamanageactivity M and N two members (all list types):

Check-cast V0, Lcom/baidu/bus/b/a;invoke-direct {p0, v0}, Lcom/baidu/bus/activity/offlinedatamanageactivity;->b ( lcom/baidu/bus/b/a;) V

Look at the B () method, call the Execute () method of the other member cm for the passed parameter, view the CM class, derive from Asynctask, and call its A () method in its Doinbackground () method, which has the following code:

Iget v3, V0, lcom/baidu/bus/b/a;->a:iinvoke-static {v3}, ljava/lang/string;->valueof (I) ljava/lang/string; Move-result-object V3invoke-direct {v2, v3}, Ljava/lang/stringbuilder;-><init> (Ljava/lang/String;) vinvoke-virtual {v2}, ljava/lang/stringbuilder;->tostring () ljava/lang/string;move-result-object v2invoke-virtual {v1, v2}, Lcom/baidu/bus/a/b;->a (ljava/lang/string;) lcom/baidu/bus/net/bean/update/ Dataupdateinfo;move-result-object v1

According to the context, V0 is an incoming parameter, V1 is an instance of COM.BAIDU.BUS.A.B, and its A () method constructs a URL based on the parameters passed in:
Http://bs.baidu.com/offlinebusdata/{engineversion}/{cityid}/meta.txt
The above engineversion is 3 (this value is obtained by COM.BAIDU.BUS.D.B.A.A (). D (), the real value is in JNI, i.e. libbusoffline.so, the process of analysis is behind), Cityid is from prov_ ID entries for each city that are parsed in City_list.json. In Beijing, for example, Cityid is 131, so the URL to construct is:
Http://bs.baidu.com/offlinebusdata/3/131/meta.txt
It returns a JSON object:

{"description": "","Downloadpath": "Http://bs.baidu.com/offlinebusdata/3/131/131_14082210.dat", "MD5": "faf26f270c83f1628dfad85e16e2326e","Versioncode": "14082210","engineversion": 3  ,"size": 10560011}

This will be at a glance. Through analysis, we know that the members of the Offlinedatamanageactivity class M are "downloaded City", N is "Hot City".

From the above analysis, the Baidu bus offline data download method is this:

1. Obtain all city information from Http://bs.baidu.com/offlinebusdata/prov_city_list.json;
2. Information on individual cities is obtained through Http://bs.baidu.com/offlinebusdata/3/{cityid}/meta.txt;
3. The city's offline data is obtained from the Downloadpath item obtained in step 2nd.


In the actual operation, you can not analyze these smali files, for this simple task, using tools such as Wireshark or tcpdump to view the network request, you can easily draw conclusions.
However, after this download the file is garbled like something, the following steps to decrypt the format of the file.

[formerly] Baidu bus offline data format Analysis--4. Summary

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.