Tracking Pre-Installed Apps using Android Property System

Introduction

Android property system maintains key-value pairs that manage system configuration and can be used for start/stop services (daemon process).  

For example: wpa_supplicant, dhcpcd etc.

You can also use it to check the status of the services and other system parameters.  In addition, it can be used as an IPC mechanism, although it may not be very effective as it takes time for changes to be reflected.

Accessing Properties

Android provides three methods to access properties:

  • Native code (cutils/properties.h)
  • Java code (android.os.SystemProperties) that eventually calls the native code library
  • Shell (getprop/setprop). Click here to read more in detail.

The Android property system is initialized by an init process which loads properties from:

/default.prop, /system/build.prop, /system/default.prop, /data/local.prop files.

NOTE: Not all of the files might be present on the actual device, though build.prop is always present, as it contains system properties.

Adding a Key-Value Pair to Android System Properties

To add a key-value pair to Android System Properties:

[Root is needed] Run these shell commands:

> adb shell su
> setprop ro.appsflyer.preinstall.path=/data/pre_install.appsflyer

A similar method is to retrieve the system-properties-file from the android file system, edit it, and push it back:

> adb root
> adb remount
> adb pull /system/build.prop
> echo ro.appsflyer.preinstall.path=/data/pre_install.appsflyer >> build.prop
> adb push build.prop /system/build.prop
> adb shell chmod 644 /system/build.prop
> adb reboot

Alternatively, if you are building an Android Open-Source Project:

- build.prop is an autogenerated file generated by buildinfo.sh script present in "{AOSP root}/build/tools". 
- Add your key-value pair at the end. Ex - "ro.appsflyer.preinstall.path=/data/pre_install.appsflyer". Here key is "ro.appsflyer.preinstall.path" and value is "/data/pre_install.appsflyer".
- Now do a build and flash system.img to your phone.
- Reboot and login to phone shell (adb shell su) and type "getprop ro.appsflyer.preinstall.path" to verify.
- Note, you need to be root in order to be able to change property (setprop) or execute your program/command as root.
Was this article helpful?
0 out of 1 found this helpful
Have more questions? Submit a request
Powered by Zendesk