Some information about the system APK exploration (a)

 He started the job during that time because of work, so the study of the system's signature and telephone, Launcher  , contacts and other systems APK, Here are some of the finishing materials.

 

Android permission to share UID and signature

  Share UID:

    Each Android package file is installed in the device (.apk) will be assigned to one of their own unified Linux user ID, and create a sandbox for it to avoid affecting other applications (or other applications shadow

    Rang it). A user ID is assigned to the application is installed in the device, and keep it permanently in this device. By Shared User id, it has with more than one APK User id can be configured to run in the same process

    In so that they can visit each other any default data can also be configured to run a different process, and can access the database and other files in the data directory APK. Like this program to access the data of the same.

    For a APK, if you want to use a shared UID, we must do three steps:

    1, an increase in the Manifest android node: sharedUserId property.

    2, the increase in LOCAL_CERTIFICATE defined in Android.mk.

    If an increase in the above properties but does not define the corresponding LOCAL_CERTIFICATE words, APK is not installed up. Tip error: Package com.test.MyTest has no signatures that match

    those in shared user android.uid.system; ignoring other words, only two applications are the same signature and the same sharedUserID label's signature will be assigned the same user ID!. For example, and all

    media / download the relevant APK use android.media as sharedUserId, then they must have the same signature media.

    3, the APK source into packages / apps / directory, compiled by mm.

    Example to illustrate this.

    All systems used as android.uid.system APK shared UID, will first increase in android manifest node: sharedUserId = "android.uid.system", then the increase in Android.mk  

    LOCAL_CERTIFICATE: = platform. Can be found in Settings, etc.

    All systems used as android.uid.shared APK shared UID, will manifest increase in android node: sharedUserId = "android.uid.shared", then the increase in Android.mk

    LOCAL_CERTIFICATE: = shared. And so on can be found Launcher

    All systems used as android.media APK shared UID, will manifest increase in android node: sharedUserId = "android.media", then the increase LOCAL_CERTIFICATE in Android.mk

    : = Media. You can see Gallery and so on.

     In addition, any application files are created by the application user ID is assigned, and can not be accessed by other packages under normal circumstances. When by getSharedPreferences (String, int), openFileOutput (String,

    int) or openOrCreate Database (String, int, SQLiteDatabase.CursorFactory) when you create a new file, developers can use together or separately and MODE_WORLD_READABLE

    MODE_WORLD_RITEABLE flag allows other packages read / write file. After setting these flags, the file still own applications, but its global read / write and read / write permissions have been set, so the other

    Any application can see it.

  About Signature:

     build / target / product / security directory has four sets default signature for use in Android.mk compiled APK:

    1, testkey: general APK, use the default.

    2, platform: the APK to complete some of the core functions of the system. After testing access to the file system folder that exist, UID APK processes where the compilation out this way system.

    3, shared: the APK needs and home / contacts the process of sharing data.

    4, media: APK is the media / download a ring system.

    Android.mk application has a LOCAL_CERTIFICATE field, with which it is specified by the key signature, not specified default by testkey.

A method (effective pro-test)

  First, AndroidManifest.xml manifest in the node in android: sharedUserId = "android.uid.system" this property

  1.1 Access <Android_Source_Path> / build / target / product / security, platform.pk8 find [] and [] platform.x509.pem system key.

  1.2 Access <Android_Source_Path> / build / tools / signapk found SignApk.java, running javac compiled SignApk.class  

  In the third step before running the command, create a new structure under your current working directory folder:  

  com.android.signapk, then the second step of SignApk compiled into the directory. Or you can be SignApk.java the package statement to delete and then run javac compiler.

  Command java com.android.signapk.SignApk platform.x509.pem platform.pk8 input.apk output.apk not only can re-sign the apk file, you can re-sign all of the zip file, including the ROM file.

  1.3. Run
  java com.android.signapk.SignApk platform.x509.pem platform.pk8 input.apk output.apk

  (!) 1, platform.x509.pem supplement [] [] and platform.pk8 system key (must be a system to be used), the target apk to put <Android_Source_Path> / build / tools / signapk directory
  2, create a folder in the <Android_Source_Path> / build / tools / signapk directory: COM / Android / signapk
  3, the second step of the compiler-generated SignApk placed in the directory

 

Method 2 (not test out)

  eclipse source compiler, with no need to compile make (android source directory <D: / myandroid_mx27>):

  1, first, the node in the AndroidManifest.xml manifest in android: sharedUserId = "android.uid.system" this property

  2, with the eclipse compile the apk (ClockSetting.apk) file, but the file can not be used, deleted CERT.SF and CERT.RSA two files in the META-INF directory

  3, using the current system android (android system may be different) of the platform to re-key apk file signature (meters may not have to be signed by the user).
    First, find the key file location on my Android source directory is "build / target / product / security ", following platform.pk8 and platform.x509.pem two files.
    Then, the Android SignApk tool to provide a signature, signapk source code is in the "build / tools / signapk", this time to have to do to prepare the following compilation:
  <1>, the compiler jar
    line cd to signapk. under the code directory java,
    javac signapk.java
    get SignApk $ SignatureOutputStream.class and SignApk.class

    Create a directory s / com / android / signapk, two class files into the directory
    jar cvfm signapk.jar SignApk.mf -C s /.
    Note: "." "S /" in front of a space behind the
    generation signapk.jar file, the signature program signapk.jar Android has been provided by
  <2>, signed with the platform key target system,
    copy the files to the platform.pk8 and platform.x509.pem "D: / myandroid_mx27 / build / tools / signapk" directory under that directory signapk.jar and SignApk.mf located.
    java -jar signapk.jar platform.x509.pem platform.pk8 D: /ClockSetting.apk D: /ClockSettingSigned.apk
    my unsigned (ClockSetting.apk) and signed (ClockSettingSigned.apk) apk files on the D drive so that you get with the Android source code compiled files.

  <3>, open the real machine, installation:
    the adb Connect IP: Port (IP true IP address, Port port)
    the adb the install D: /ClockSettingSigned.apk

 

Guess you like

Origin www.cnblogs.com/gerall/p/11229241.html