ConfFix: Repairing Configuration Compatibility Issues in Android Apps
Authors/Creators
- 1. The Hong Kong University of Science and Technology
- 2. Southern University of Science and Technology
Description
# ConfFix
This repository contains the source code of ConfFix tool.
# ConfFix Dataset
We release the ConfFix dataset in a separate link of 10.5281/zenodo.7981210. Please refer to it.
# Build and Use ConfFix from Scratch
## Prerequisite
* UIAutomator2
* Python 3
* Android emulators at target API levels (e.g., API level 33)
## Steps
### 1. Create emulators
1. Download Android SDK Command line tools [link](https://dl.google.com/android/repository/commandlinetools-linux-7302050_latest.zip) and unzip the .zip file.
2. Rename cmdline-tools to be tools and put it under an SDK root folder (e.g., `/ssddata/SDK/android_sdk_linux`). So now the tools path will be `/ssddata/SDK/android_sdk_linu/tools`
3. Navigate to the SDK root and type in the following commands to install necessary files for the SDK
```
(1) tools/bin/sdkmanager --sdk_root=/ssddata/SDK/android_sdk_linux --install "system-images;android-33;google_apis;x86_64"
(2) tools/bin/sdkmanager --sdk_root=/ssddata/SDK/android_sdk_linux --install "platforms;android-33"
(3) tools/bin/sdkmanager --sdk_root=/ssddata/SDK/android_sdk_linux --install "platform-tools"
(4) tools/bin/sdkmanager --sdk_root=/ssddata/SDK/android_sdk_linux --install "emulator"
(5) tools/bin/sdkmanager --sdk_root=/ssddata/SDK/android_sdk_linux --install "build-tools;31.0.0"
```
4. Add something into PATH
```
export ANDROID_HOME=/ssddata/SDK/android_sdk_linux
export PATH=$PATH:$ANDROID_HOME:$ANDROID_HOME/emulator:$ANDROID_HOME/tools/bin:$ANDROID_HOME/platform-tools
export ANDROID_SDK_ROOT=$ANDROID_HOME
export ANDROID_AVD_HOME=~/.android/avd
export PATH=$PATH:$ANDROID_AVD_HOME
```
5. Create an folder under the SDK root named avds and create an Android emulator: `avdmanager create avd -n emulator0 -k "system-images;android-33;google_apis;x86_64" -p avds/emulator0`
6. Modify the emulator configuration to change the screen size of your emulator: In our evaluation, we set an emulator with 560dpi density. The density is set following the device profile of Google Pixel 6 Pro. To achieve this, modify the emulator configuration files (the file usually is: `./emulator0/config.ini`). Please change `hw.lcd.density=560`
7. Launch the emulators:
- Copy the essential files
```
cd /SDK/android_sdk_linux
mkdir android_sdk_linux && cd android_sdk_linux && mkdir system-images
cd /SDK/android_sdk_linux
cp system-images/* ./android_sdk_linux/system-images/ -r
```
- Launch the emulator
```
emulator @emulator0 -wipe-data -no-window -no-audio -memory 4096 -port 5554 -partition-size 8192 -skin 1440x3120 “android_sdk_linux/....”
```
This command launches the emulator `emulator0` in the port 5554. We set the device with 4GB RAM, 8GB disk, and 1440x3120 resolution. The resolution is set following the device profile of Google Pixel 6 Pro.
### 2. Run ConfFix
1. Install uiautomator2, which is used for executing test scripts
```
pip3 install --upgrade --pre uiautomator2
```
2. Add zipaligner and apksigner, which are used to sign the apk files generated by apktool. You can find zipaligner and apksigner in ```android_sdk/build-tools/[version_number]``` (the version number of the build tools you installed). For example, you may add the following environment variable.
```
export ANDROIDBUILDPATH=$ANDROID_SDK_ROOT/build-tools/31.0.0
export ANDROIDPLATFORMPATH=$ANDROID_SDK_ROOT/platform-tools
```
3. ConfFix takes nine parameters to run. e.g.,
``
python -u xmlutilrandom_uiautomator.py emulator-5554 ./subject_apks/ProtonMail-Android-vpn_logo.apk res/layout/activity_onboarding.xml ImageView src drawable ch.protonmail.android vpn_logo proton_mail_vpn_logo
``
The parameter list contains: (1) emulator id, (2) apk path, (3) xml file contains CC issue, (4) xml tag, (5) issue-inducing attribute, (6) attribute data type, (7) app id, (8) id of issue-inducing XML element, and (9) test case that can reproduce the issue (see ``xmltestcasedriver.py`` for more information). For you to easily reproduce the experiment result, please refer to ``list_sh.xlsx`` in 10.5281/zenodo.7981210 for more information.
Current implementation of ConfFix works on our experiment dataset and requires hard-coded test cases written based on UIAutomator2. We will further maintain its implementation by test cases written by another Android testing frameworks (e.g., Espresso).
Files
README.md
Files
(19.8 MB)
| Name | Size | Download all |
|---|---|---|
|
md5:b80bfaf8607c215c34ad6ddeb259559e
|
4.3 kB | Preview Download |
|
md5:82ffc9e954849b33e4cffe4bbf4af47f
|
19.8 MB | Preview Download |