Tian haili
This article analyzes the factory test framework built in Android (including test mode, factory mode, and engineering mode), rather than explaining how to write each test in factorytest.
Factorytest has been supported in the android framework. With some configuration and development work, You can integrate the factorytest code into the Android system.
1. factorytest-Level Definition
In the Android system, the level of factorytest is defined in COM. Android. server. systemserver (LOC: Frameworks/base/services/Java:
public static final int FACTORY_TEST_OFF =0;public static final int FACTORY_TEST_LOW_LEVEL = 1;public static final int FACTORY_TEST_HIGH_LEVEL= 2;
- Factory_test_off is in normal mode;
- Factory_test_low_level is implemented at a lower level in the engineering mode, that is, when running the engineering mode, many services do not need to be started;
- Factory_test_high_level is a relatively high level of engineering mode, that is, when running the engineering mode, the basic Android runtime environment is the same as the normal mode. In the native implementation, it is not much different from the normal mode except activitymanagerservice.
Later, we will focus on factory_test_low_level. We also use this mode to replace the expression of factorytest.
2. factorytest services that do not need to be started
The system is started in factory_test_low_level mode. The following services or observers are not started at all:
Bluetoothservice
Bluetootha2dpservice
Devicepolicyservice
Statusbarmanagerservice
Clipboardservice
Inputmethodmanagerservice
Netstatservice
Networkmanagementservice
Connectivityservice
Throttleservice
Accessibilitymanagerservice
Mountservice
Icationicationmanagerservice
Devicestoragemonitorservice
Locationmanagerservice
Searchmanagerservice
Dropboxmanagerservice
Wallpapermanagerservice
Audioservice
Headsetobserver
Hookswitchobserver
Hdmiobserver
Dockobserver
USB Service
Uimodemanagerservice
Backupmanagerservice
Appwidgetservice
Recognitionmanagerservice
Diskstatsservice
The path of the following basic services in the factory_test_low_level mode is different:
Activitymanagerservice
In factory_test_low_level mode, no boot_completed broadcast is sent. The first program to be started is not to start the first program through the intent of acrtion as main and category as home, but to use acrtion as intent. action_factory_test ("android. intent. action. factory_test) intent to start.
Packagemanagerservice
In the factory_test_low_level mode, add the applicationinfo. flag_factory_test flag to the package containing the permission factory_test.
Contentservice
In the factory_test_low_level mode, syncmanager performs differently because of the differences in the factorytest mode.
Windowmanagerservice
In factory_test_low_level mode, there is no input method.
3. configuration of factorytest
The above brief analysis shows that in factory_test_low_level mode, you need to configure the factorytest program. In addition, you must configure how to enter the factorytest mode.
3.1 configuration of factorytest Application
According to the brief analysis above, in factory_test_low_level mode, the first program to be started is the test program in engineering mode, which must:
- Activity with the response action intent. action_factory_test ("android. Intent. Action. factory_test;
- In addition, this program must obtain "android. Permission. factory_test ";
- This program must be a built-in Program (installed in/system/APP /)
The activity responding to action intent. action_factory_test ("Android. Intent. Action. factory_test") is executed after the startup.
3.2 Startup Mode settings
The startup mode is determined by the system attribute "Ro. factorytest". The value range is 0/1/2, which corresponds to the three level modes defined in the first part. You can append an attribute such as product_property_overrides or additional_defualt_properties in the. mk file. For example:
#FactoryTest LowLevelPRODUCT_PROPERTY_OVERRIDE += ro.factorytest=1
3.3 kernel Startup Mode
Some implementations do not work after the above settings, because during kernel startup, the system attribute "Ro. factorytest" is set in startup mode.
The ideal status is determined by the kernel, rather than the preceding section.
The kernel uses the parameter "androidboot. mode" to determine the factory mode ("Factory" corresponds to factory_test_low_level; "factory2" corresponds to factory_test_high_level; other values or "Factory" corresponding to factory_test_off ).
The above requires Kernel support. If not, it is fixed to the normal mode.
Therefore, if the kernel does not support the init. in C, Judge "androidboot. and set "Ro. factorytest code is temporarily blocked. Use the "Ro. factorytest "to determine the factory mode.
Summary
This article analyzes:
1. Existing factorytest framework in Android native implementation: some services and functions are blocked;
2. The factory test mode can be implemented through the following methods:
1) Write A factorytest application;
2) set the system property of "Ro. factorytest" and disable the settings set by the kernel,
Or
3) The factorytest mode is determined by the kernel startup parameter "androidboot. mode.