当前位置:网站首页>[andoid][step pit]cts 11_ Testbootclasspathandsystemserverclasspath at the beginning of R3_ Analysis of nonduplicateclasses fail
[andoid][step pit]cts 11_ Testbootclasspathandsystemserverclasspath at the beginning of R3_ Analysis of nonduplicateclasses fail
2022-06-13 01:31:00 【Ryan ZHENG】
[Andoid][ Step on the pit ]CTS 11_r3 The beginning of testBootClassPathAndSystemServerClasspath_nonDuplicateClasses FAIL Problem analysis
The problem background
from CTS The test results can be clearly seen leading to FAIL Class ; I added this class myself , In order to be in Installd And system_server Between registered callbacks ;
Due to the tight schedule of the project , The project that initially reported the problem adopted the method of code fallback , Guarantee CTS The test results are normal ;
In passing nearly 2 Days of analysis , Gradually clarify the cause of the problem and the solution , It is summarized as follows :
Cause of the problem
According to the problem description , Use CTS 11_r3 During the test FAIL, While using 11_r2 The result of the test is PASS;
The test instruction is :
run cts -m CtsStrictJavaPackagesTestCases -t android.compat.sjp.cts.StrictJavaPackagesTest#testBootClassPathAndSystemServerClasspath_nonDuplicateClasses
Check the code according to , The logic and purpose of the test item are as follows :
- Get environment variables BOOTCLASSPATH And SYSTEMSERVERCLASSPATH Value ;
- take BOOTCLASSPATH And SYSTEMSERVERCLASSPATH The value of corresponds to jar Pull the package to the host ;
- Use dexlib2 For these jar The package is decompiled , Get one of them dex file ;
- be based on dex File to get the classes contained in it ;
- Double check all classes ;
- The duplicate classes are filtered in the white list ;
- Finally, record the list of all duplicate classes by comparison , If it's not empty , Then test FAIL, whereas PASS;
It is not difficult to see from logic , This is a Google Want to protect system_server And framework Does not contain a means of repeating classes ;
But why 11_r2 Sure PASS, here we are 11_r3 Not anymore ?
According to the comparison of baseline code and AOSP After the latest code, you can find ;
Google stay 18-Nov-2020 The test item has been updated once , There are two main areas for improvement :
- Increase the number of classes in the whitelist ;
- modify getDuplicateClasses Method implementation , To support the multi-dex Of jar package ;
thus it can be seen ,11_r2 Sure PASS It is completely drilled the loophole of the test item , Because we added ICallback Just packed into a non first classes.dex It's in ; And in the 11_r3 Chinese vs multi-dex Supported , This problem was exposed ;
But here's a line ,Google I also know my own IInstalld It's also FAIL Of , So I updated my white list IInstalld Exclude , This operation can only be said to be admiration …
Problem solving ideas
Okay , No matter Google How about this manual operation , We are always trying to solve this problem . But after further analysis, it is found that , This problem is more troublesome than I thought .
The picture below is AOSP Original design structure , You can see :installd_aidl This filegroup Be separated by services And framework Two modules are imported 、 Compile the ;
And the one I added to register callbacks AIDL file ( Let's call it ICallback.aidl, The same below ), Needed ICallback.aidl It is also added here :
filegroup {
name: "installd_aidl",
srcs: [
"binder/android/os/IInstalld.aidl",
"binder/android/os/storage/CrateMetadata.aidl",
"binder/android/os/ICallback.aidl", //Added
],
path: "binder",
}
Which leads to ICallback And its inner classes and IInstalld equally , Has been compiled twice , They have entered services.jar And framework.jar It's in ;
Come here , The solution should be clear :
Give Way ICallback Compile into only framework.jar, Instead of compiling into services.jar in ;
Solution steps
- First, we need to ICallback from installd_aidl This filegroup Split in , And control it separately ; meanwhile , We need to define the rules to put this ICallback export , Make globally visible :
filegroup {
name: "installd_aidl_ext",
srcs: [
"binder/android/os/ICallback.aidl",
],
path: "binder",
visibility: ["//visibility:public"],
}
cc_defaults {
name: "installd_aidl_ext_cc_defaults",
aidl: {
//Note, this path should vary according to current location
include_dirs: ["xxx( Current directory )/binder/"],
export_aidl_headers: true,
},
export_include_dirs : ["."],
srcs: [
":installd_aidl_ext",
],
}
java_defaults {
name: "installd_aidl_ext_java_defaults",
aidl: {
//Note, this path should vary according to current location
include_dirs: ["xxx( Current directory )/binder/"],
},
}
- And then in installd In the Compilation Rules of :
cc_defaults {
name: "installd_defaults",
defaults: ["installd_aidl_ext_cc_defaults"],//Added
...
srcs: [
...
"InstalldNativeService.cpp",
...
":installd_aidl",
],
...
}
- and frameworks/base The next is the most troublesome , Based on the principle of minimum change , I combine the above structure diagram , Decided to framework-non-updatable-sources Of filegroup in ( With the original :installd_aidl Put together ):
filegroup {
name: "framework-non-updatable-sources",
srcs: [
...
":installd_aidl",
...
":installd_aidl_ext",//Added
],
}
- At the same time, it is necessary to make services Compiling installd_aidl From time to tome ICallback This class can reference , stay services.core.unboosted Add :
java_library_static {
name: "services.core.unboosted",
defaults: ["installd_aidl_ext_java_defaults"],//Added
srcs: [
...
":installd_aidl",
...
],
...
}
- Replace after compilation system.img To test CTS FAIL term , result PASS;
The structure diagram after modification is as follows :( In fact, it's just a separate one installd_aidl_ext)
Postscript
The above is only the final result , The frustrations of the middle exploration have not been mentioned ;
The whole process is the most difficult 、 It is also the place that impressed me most , is “ How to let aidl analysis AIDL File can be found ICallback, But don't compile it into services”
And I can finally determine the above plan , To a large extent, it depends on here The means mentioned : By locating the compiled parameters , And then turn it upside down Android.bp Supported options , To use minimal changes , Solve this problem ;
边栏推荐
- V-inline-date, similar to Ctrip, flying pig, time selection with price
- Wikipedia User Guide
- Idea installation tutorial
- Leetcode find duplicates
- ES6 deconstruction assignment
- Three paradigms of database
- [learn FPGA programming from scratch -22]: Advanced chapter - Architecture - Design and modeling of FPGA internal hardware circuit
- 使用Pygame创建一个简单游戏界面
- spiral matrix visit Search a 2D Matrix
- Detailed explanation of Joseph problem
猜你喜欢
ES6解构赋值
A problem discovery and attempted solution to the strange stop of server script
C language implementation of the classic eight queens problem
How to print infinite symbol in WPS
Large end storage and small end storage
项目实训(十七)---个人工作总结
Leetcode find duplicates
Application advantages of 5g industrial gateway in coal industry
Leetcode-11- container with the most water (medium)
Mathematical knowledge arrangement: extremum & maximum, stagnation point, Lagrange multiplier
随机推荐
Argparse command line passes list type parameter
This of phaser3 add. add. image
Wangdao machine test - Chapter 6 - maximum common divisor GCD and minimum common multiple LCM
ng-tv-focusable
Work and life
Redis usage optimization summary learning
Exercise 5.14 input n strings, arrange them in alphabetical order and output them.
Auto commit attribute of MySQL
Leetcode 01 array
Memory learning book reference
How to print infinite symbol in WPS
[learn FPGA programming from scratch -22]: Advanced chapter - Architecture - Design and modeling of FPGA internal hardware circuit
Five classic articles worth reading (2)
Pytorch's leafnode understanding
pycharm add configutions
Polymorphism and virtual function
The tle4253gs is a monolithic integrated low dropout tracking regulator in a small pg-dso-8 package.
Leetcode-18- sum of four numbers (medium)
Study notes on the introduction paper of face recognition deep facial expression recognition: a survey
Transaction characteristics and isolation levels