Development discussion of WireGuard
 help / color / mirror / Atom feed
* WireGuard as Android Device Owner
@ 2023-09-19 13:13 EuroDomenii .Eu .Ro Accredited Registrar
  0 siblings, 0 replies; only message in thread
From: EuroDomenii .Eu .Ro Accredited Registrar @ 2023-09-19 13:13 UTC (permalink / raw)
  To: wireguard

Dear all,

I'm tryin to set up WireGuard as Android Device Owner, but it fails,
even though there's the very same code that worked with Shadowsocks
fork. Below the files samples and full error message.

Thanks!

*ui/src/main/AndroidManifest.xml
<pre>
        <receiver
            android:name=".WireGuardReceiver"
            android:description="@string/app_name"
            android:label="@string/app_name"
            android:permission="android.permission.BIND_DEVICE_ADMIN"
            android:exported="true">
                       <intent-filter>
                          <!-- This action is required -->
                           <action
android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
                           <action
android:name="android.app.action.PROFILE_PROVISIONING_COMPLETE" />
                       </intent-filter>
            <meta-data
                android:name="android.app.device_admin"
                android:resource="@xml/device_owner_receiver" />
        </receiver>
</pre>

*ui/src/main/java/com/wireguard/android/WireGuardReceiver.kt
<pre>
/*
 * Copyright © 2017-2023 WireGuard LLC. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0
 */

package com.wireguard.android

import android.app.admin.DeviceAdminReceiver

/**
 * Trivial DeviceAdminReceiver used to identify this app's device administrator.
 */
class WireGuardReceiver : DeviceAdminReceiver()
</pre>

ui/src/main/res/xml/device_owner_receiver.xml
<pre>
<?xml version="1.0" encoding="utf-8"?>
<!--
 Copyright 2015 The Android Open Source Project

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

     http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<device-admin>
    <uses-policies>
        <limit-password/>
        <watch-login/>
        <reset-password/>
        <force-lock/>
        <wipe-data/>
        <expire-password/>
        <encrypted-storage/>
        <disable-camera/>
    </uses-policies>
</device-admin>

</pre>

*Error
<pre>
root@androids ~/AndroidStudioProjects/wireguard-android # adb shell
emu64x:/ $ dpm set-device-owner com.wireguard.android/.WireGuardReceiver

Exception occurred while executing 'set-device-owner':
java.lang.IllegalArgumentException: Unknown admin:
ComponentInfo{com.wireguard.android/com.wireguard.android.WireGuardReceiver}
        at com.android.server.devicepolicy.DevicePolicyManagerService.findAdmin(DevicePolicyManagerService.java:2838)
        at com.android.server.devicepolicy.DevicePolicyManagerService.setActiveAdmin(DevicePolicyManagerService.java:3342)
        at com.android.server.devicepolicy.DevicePolicyManagerServiceShellCommand.runSetDeviceOwner(DevicePolicyManagerServiceShellCommand.java:256)
        at com.android.server.devicepolicy.DevicePolicyManagerServiceShellCommand.onCommand(DevicePolicyManagerServiceShellCommand.java:89)
        at com.android.modules.utils.BasicShellCommandHandler.exec(BasicShellCommandHandler.java:97)
        at android.os.ShellCommand.exec(ShellCommand.java:38)
        at com.android.server.devicepolicy.DevicePolicyManagerService.onShellCommand(DevicePolicyManagerService.java:9905)
        at android.os.Binder.shellCommand(Binder.java:1049)
        at android.os.Binder.onTransact(Binder.java:877)
        at android.app.admin.IDevicePolicyManager$Stub.onTransact(IDevicePolicyManager.java:6054)
        at android.os.Binder.execTransactInternal(Binder.java:1285)
        at android.os.Binder.execTransact(Binder.java:1244)

</pre>

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-10-23 14:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-09-19 13:13 WireGuard as Android Device Owner EuroDomenii .Eu .Ro Accredited Registrar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).