[Android] reads information about its own installation package

Source: Internet
Author: User

Today, I found a folder named "com" under the first directory of my APK, and the N-level directory under it was a text file named "Wup. properties. For example:

Curious, that is to say, the android program can read information from any place in the installation package like the one in the j2's (previously thought it could only read content under Res/raw ). After checking the decompilation, we finally found a class named "com/Tencent/QQ/JCE/Wup/wupinfo ". The Code is as follows:

Package COM. tencent. QQ. JCE. wup; <br/> Import Java. io. inputstream; <br/> Import Java. util. properties; <br/> public class wupinfo <br/>{< br/> Private Static string a; <br/> Private Static string B; <br/> Private Static string C; <br/> static <br/>{< br/> string STR = "unknown"; <br/> A = NULL; <br/> B = NULL; <br/> C = NULL; <br/> try <br/> {<br/> inputstream localinputstream = wupinfo. class. getresourceasstream ("/COM/QQ/JCE/Wup. properties "); <br/> properties localproperties = new properties (); <br/> localproperties. load (localinputstream); <br/> localinputstream. close (); <br/> A = localproperties. getproperty ("client.info"); <br/> B = localproperties. getproperty ("client. built "); <br/> C = localproperties. getproperty ("client. number "); <br/> if (a = NULL) <br/> A =" Tencent TAF "; <br/> If (B = NULL) <br/> B = STR; <br/> If (C = NULL) <br/> C = STR; <br/> return; <br/>}< br/> catch (throwable localthrowable) <br/>{< br/>}< br/>}

The key code is the content in try {} catch () {}. Use getresourceasstream ("file_path") to get the input stream. I tried to build a project by myself and a "Wup. properties" file with the same directory structure under the project directory. The Code failed. The next thought was that eclipse did not pack the folder "com" into the APK together, and exported the test package from the mobile phone. This is indeed true.
The solution is to manually put "com/QQ/JCE/Wup. properties" into the APK compressed package and re-sign the package.

Related Article

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.