WireGuard Archive mirror
 help / color / mirror / Atom feed
From: "EuroDomenii .Eu .Ro Accredited Registrar" <info@euro-domenii.eu>
To: wireguard@lists.zx2c4.com
Subject: WireGuard as Android Device Owner
Date: Tue, 19 Sep 2023 16:13:40 +0300	[thread overview]
Message-ID: <CADw2znBiKvc+1Budiuc=MCPAN=bOnkH6rjogjT2NyN2FHrvnAQ@mail.gmail.com> (raw)

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>

                 reply	other threads:[~2023-10-23 14:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CADw2znBiKvc+1Budiuc=MCPAN=bOnkH6rjogjT2NyN2FHrvnAQ@mail.gmail.com' \
    --to=info@euro-domenii.eu \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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 read-only IMAP folder(s) and NNTP newsgroup(s).