build AOSP with device owner configuration
Asked Answered
C

2

6

I want to build AOSP with a Device Manager app.

How can I build the AOSP with device_owner.xml and device_policies.xml already configured ?

PS: My target will be nexus5.

Chase answered 30/11, 2015 at 17:37 Comment(0)
T
4

I guess it is a bit late for you, but for the others looking for the exact same thing (like I was), there is a great article about kiosk mode with lots of tech details:

http://trac.gateworks.com/wiki/Android/Kiosk

Details regarding the device ownership:

"However, if building from source you can bypass the request to the user and give your app device ownership/admin on first boot by injecting the following two files under out/target/product/ventana/data/system/. The injection is done by adding the files to the PRODUCT_COPY_FILES variable in your device configuration file (ie device/gateworks/ventana/ventana.mk)."

TL;DR:

just add this to the end of your device config file (.mk) using your configured ownership/policy xmls:

# Set device ownership for the kiosk mode app
PRODUCT_COPY_FILES += \
    device/gateworks/ventana/device_owner.xml:data/system/device_owner.xml \
    device/gateworks/ventana/device_policies.xml:data/system/device_policies.xml
Trivandrum answered 27/4, 2017 at 11:6 Comment(0)
L
2

That's not enough, adding the files directly to /data/system will not survive a factory reset (wiping the data partition).

Instead you will need to add your device_owner.xml and device_policies.xml to your system partition (any folder, could be simply under /system/), then edit your init.rc file to copy device_owner.xml and device_policies.xml, this should be done in a on post-fs-data section (executed after the data partition has been mounted).

Dont' forget to set the correct permissions to said files chmod 0600 and chown system sytem

your makefile should look like:

PRODUCT_COPY_FILES += \
    device/gateworks/ventana/device_owner.xml:system/device_owner.xml \
    device/gateworks/ventana/device_policies.xml:system/device_policies.xml

your init.rc file should look like:

on post-fs-data
    # set device manager as device owner
    copy /system/device_owner_2.xml /data/system/device_owner_2.xml
    chmod 0600 /data/system/device_owner_2.xml
    chown system system /data/system/device_owner_2.xml
    copy /system/device_policies.xml /data/system/device_policies.xml
    chmod 0600 /data/system/device_policies.xml
    chown system system /data/system/device_policies.xml
Lafountain answered 10/8, 2021 at 14:48 Comment(2)
I followed steps for android 13 but system doesn't boot, and goes to recovery mode. Any suggestion?Ramachandra
I want to add that this only works when adding to init.rc after the line starting with mkdir /data/system.Delacourt

© 2022 - 2024 — McMap. All rights reserved.