Re-sign, modify the system time, Android. uid. System

Source: Internet
Author: User

I wrote an application yesterday, involving operations such as modifying the system time. I checked the setting source code of Android. The method is as follows:

 

Public void ondateset (datepicker view, int year, int month, int day ){
Calendar c = calendar. getinstance ();

C. Set (calendar. year, year );
C. Set (calendar. Month, month );
C. Set (calendar. day_of_month, Day );
Long when = C. gettimeinmillis ();

If (when/ 1000 <integer. max_value ){
Systemclock. setcurrenttimemillis (when );
}
Updatetimeanddatedisplay ();
}

 

From the Android Application source code, we can see that to modify the system date, you need to set the year, month, and day for the calendar, and then call systemclock. the setcurrenttimemillis method sets the system date. Since the source code is written in this way, let's take a look at it. below is the code to modify the date by using datepicker:

 

Canlendar = calendar. getinstance ();
Year = datepicker. getyear ();
Month = datepicker. getmonth ();
Day = datepicker. getdayofmonth ();
Canlendar. Set (calendar. year, year );
Canlendar. Set (calendar. Month, month );
Canlendar. Set (calendar. day_of_month, Day );
Long when = canlendar. gettimeinmillis ();
If (when/ 1000 <integer. max_value ){
Systemclock. setcurrenttimemillis (when );
TV _date.settext (canlendar. Get (calendar. Year) + "/"
+ (Canlendar. Get (calendar. month) + 1) + "/"
+ Canlendar. Get (calendar. day_of_month ));
}

 

 

Tip: You must obtain the instance once each time you use calendar. Otherwise, it will use the date format of the last time you get the instance. The modification may be slightly problematic.

However, the following warning is reported when the code above is used:

 

I checked online, said systemclock. setcurrenttimemillis this function requires root permissions or run in the system process can be used, by referring to this article I got a solution: http://dev.10086.cn/blog? Uid-49302-action-viewspace-itemid-907, but the second method of this article is a bit not very clear, here I will give you a detailed description

First, go to the android source code directory F:/android_source/build/target/product/security, and select the specific machine directory. Find [platform. pk8 and [platform. x509.pem: These two files are copied to the root directory for convenience. For example, in the F:/sign folder, the next step is to package the jar package, however, in the source code of the Android system, find the out Encoding Directory.

Signapk. jar package. You can create a jar package or download the jar package. Change the suffix to signapk. jar format: place the jar package in the F:/sign file. Open the DOS operation interface and set it to F:/sign, as shown below:, and then enter the following command: java-jar signapk. jar platform. x509.pem platform. pk8 test.apk testnew.apk: for example, in the DOS command name, "set.apk" indicates the original file APK that we want to sign, and "setnew.apk" indicates the name of the APK file output after signature.

Tip: at the time of signing, open set.apk with RAR file in advance, enter the META-INF directory, delete the CERT. SF and cert. RSA files, and then perform the above operation. At this step, the program can be properly installed.

If failure [install_failed_already_exists] is prompted, run the following command to remove the application: uninstall is followed by the package name of the application, run ADB install [package name] to install the package successfully.

Tip: do not forget to register Android: shareduserid = "android. uid. System" under your manifest file ".

If you follow the steps above, you can modify the system time or date.

 

 

Source: http://dev.10086.cn/cmdn/supesite? Uid-49302-action-viewspace-itemid-1034

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.