android-testdpc icon indicating copy to clipboard operation
android-testdpc copied to clipboard

Please provide an example COSU config XML file

Open eliotstock opened this issue 8 years ago • 13 comments

CosuConfig.java looks great but it's rather difficult to reverse engineer an XML file for it to parse. Can you please provide one?

eliotstock avatar Aug 07 '17 15:08 eliotstock

This would be great to have.

johngag avatar Oct 09 '17 21:10 johngag

+1

chrisdew avatar Oct 13 '17 14:10 chrisdew

+1

ser-mk avatar Jan 03 '18 11:01 ser-mk

Bit late to the party, but here's a rough xml I'm using to test this app with:

cosu.xml:

<!-- see app/src/main/java/com/afwsamples/testdpc/cosu/EnableCosuActivity.java startCosuMode() for the "mode" values -->
<cosu-config mode="default">
    <hide-apps>
        <app package-name="com.android.vending"/>
        <app package-name="com.google.android.googlequicksearchbox"/>
        <app package-name="com.sec.android.app.myfiles"/>
        <app package-name="com.samsung.android.dialer"/>
        <app package-name="com.android.settings"/>
    </hide-apps>
    <kiosk-apps>
        <app package-name="org.fdroid.fdroid"/>
    </kiosk-apps>
    <download-apps>
        <app package-name="org.fdroid.fdroid" download-location="https://f-droid.org/FDroid.apk"/>
    </download-apps>
    <policies>
        <!-- for global settings, see https://developer.android.com/reference/android/app/admin/DevicePolicyManager#setGlobalSetting(android.content.ComponentName,%20java.lang.String,%20java.lang.String) setGlobalSetting() -->
        <global-setting name="adb_enabled" value="1"/>
        <global-setting name="usb_mass_storage_enabled" value="0"/>
        <global-setting name="stay_on_while_plugged_in" value="3"/> <!-- (BATTERY_PLUGGED_AC | BATTERY_PLUGGED_USB) == (1 | 2) == 3 -->

        <!-- for user restrictions, see https://developer.android.com/reference/android/app/admin/DevicePolicyManager#addUserRestriction(android.content.ComponentName,%20java.lang.String) -->
        <user-restriction name="no_fun"/>
        <user-restriction name="no_config_wifi"/>
        <user-restriction name="no_config_vpn"/>
        <user-restriction name="no_config_mobile_networks"/>
        <user-restriction name="no_airplane_mode"/>
        <user-restriction name="no_uninstall_apps"/>

        <disable-screen-capture value="true"/>
        <disable-camera value="true"/>
        <disable-status-bar value="false"/>
        <disable-keyguard value="false"/>
    </policies>
</cosu-config>

And while I'm at it, these two files to generate a QR code for the device setup:

qr.json:

{
        "android.app.extra.PROVISIONING_DEVICE_ADMIN_COMPONENT_NAME": "com.afwsamples.testdpc/com.afwsamples.testdpc.DeviceAdminReceiver",
        "android.app.extra.PROVISIONING_DEVICE_ADMIN_SIGNATURE_CHECKSUM": "gJD2YwtOiWJHkSMkkIfLRlj-quNqG1fb6v100QmzM9w=",
        "android.app.extra.PROVISIONING_DEVICE_ADMIN_PACKAGE_DOWNLOAD_LOCATION": "https://testdpc-latest-apk.appspot.com",
        "android.app.extra.PROVISIONING_ADMIN_EXTRAS_BUNDLE": {"cosu-demo-config-location": "https://example.com/cosu.xml"}
}

make_qr.sh:

#!/bin/bash
#uploads cosu.xml to x0.at, replaces example link in qr.json and displays it as a QR code
XMLURL=$(tidy -xml --hide-comments 1 ./cosu.xml | curl -X POST -F 'file=@-;filename=.xml' https://x0.at/)
sed "s,https://example.com/cosu.xml,$XMLURL," < qr.json | tee /dev/stderr | qrencode -o qr.png && xdg-open qr.png

Rouji avatar Jun 29 '20 08:06 Rouji

I am trying to use cosu.xml config however no config in cosu.xml has effect. How to debug?

thinhdd13 avatar Jan 05 '21 15:01 thinhdd13

@thinhdd13 Probably something wrong with your urls? You get a bit of helpful stuff in logcat if you enable adb quickly enough after doing the provisioning thing.

Rouji avatar Jan 05 '21 19:01 Rouji

Can we set the locationMode and "defaultPermissionPolicy" in cosu.xml file? If yes can you example. Many thanks.

thinhdd13 avatar Jan 08 '21 05:01 thinhdd13

@thinhdd13 Not implemented in the cosu config iirc, but it should be pretty trivial to code that in

Rouji avatar Jan 08 '21 10:01 Rouji

where to add wifi settings in this file

renukaghate avatar Oct 17 '22 09:10 renukaghate

where to add wifi settings in this file

The xml doesn't do anything with wifi, but you can add the following values to the provisioning json:

android.app.extra.PROVISIONING_WIFI_SSID
android.app.extra.PROVISIONING_WIFI_SECURITY_TYPE
android.app.extra.PROVISIONING_WIFI_PASSWORD

See the docs for the "security types" and other info about those.

The wifi configured there should persist after the provisioning is finished.

Rouji avatar Oct 18 '22 10:10 Rouji