Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Please provide an example COSU config XML file #40

Open
eliotstock opened this issue Aug 7, 2017 · 11 comments
Open

Please provide an example COSU config XML file #40

eliotstock opened this issue Aug 7, 2017 · 11 comments
Assignees

Comments

@eliotstock
Copy link

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

@johngag
Copy link

johngag commented Oct 9, 2017

This would be great to have.

@chrisdew
Copy link

+1

1 similar comment
@ser-mk
Copy link

ser-mk commented Jan 3, 2018

+1

@Rouji
Copy link

Rouji commented Jun 29, 2020

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

@thinhdd13
Copy link

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

@Rouji
Copy link

Rouji commented Jan 5, 2021

@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.

@thinhdd13
Copy link

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

@Rouji
Copy link

Rouji commented Jan 8, 2021

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

@renukaghate
Copy link

where to add wifi settings in this file

@Rouji
Copy link

Rouji commented Oct 18, 2022

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.

@pfmaggi pfmaggi self-assigned this Mar 20, 2024
@Rouji
Copy link

Rouji commented May 31, 2024

@pfmaggi I could probably rejigger my comments into a PR quite easily, if that's roughly good enough as an example(?)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

9 participants