Ultimate solution! install apps directly onto Sonim phones!

Is the first Post the latest version?

I think it’s working on others devices correct?

Correct.

side note: There are quite some issues in that version though. Mainly missing basic features. I created a new 1 with more and better features but apparently i must’ve messed up with the device admin receiver and it doesn’t work to set it as admin. I tried asking ai but they couldn’t figure it out either. So meanwhile i’m stuck unless someone here can help.

this is what i currently got as DeviceAdmin.java

code
package com.example.deviceownerapp;

import android.app.admin.DeviceAdminReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;

/**
 * This is the core component that receives administrator-level callbacks.
 * It's mostly here to be declared in the manifest so the system
 * recognizes our app as a potential admin.
 */
public class DeviceAdmin extends DeviceAdminReceiver {

    private static final String TAG = "DeviceAdmin";

    @Override
    public void onEnabled(Context context, Intent intent) {
        super.onEnabled(context, intent);
        Toast.makeText(context, "Device Admin Enabled", Toast.LENGTH_SHORT).show();
        Log.d(TAG, "Device Admin Enabled");
    }

    @Override
    public void onDisabled(Context context, Intent intent) {
        super.onDisabled(context, intent);
        Toast.makeText(context, "Device Admin Disabled", Toast.LENGTH_SHORT).show();
        Log.d(TAG, "Device Admin Disabled");
    }
}

Is that meant to be ```?

1 Like

was just trying each till it worked lol. always forget md syntax

What’s the error when setting?

Got the manifest?

bad component followed by the component name. Tested on sonim and tcl for fun both same error.

manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.deviceownerapp"> <!-- This is your app's unique ID -->

    <!-- Permissions -->
    <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
    <uses-permission android:name="android.permission.QUERY_ALL_PACKAGES"
         tools:ignore="QueryAllPackagesPermission" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.DeviceOwnerApp">

        <!-- 1. The Main Activity (App Launcher Entry) -->
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <!-- 2. The App Detail Activity (Hide/Permissions) -->
        <activity
            android:name=".AppDetailActivity"
            android:exported="false" /> <!-- Not exported, only our app can launch it -->

        <!-- 3. The Invisible Install Activity -->
        <activity
            android:name=".InstallActivity"
            android:theme="@android:style/Theme.Translucent.NoTitleBar"
            android:exported="true"
            android:taskAffinity=""
            android:excludeFromRecents="true">
            
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.DEFAULT" />
                <!-- This is the MIME type for APK files -->
                <data android:mimeType="application/vnd.android.package-archive" />
                <!-- Add ZIP and generic binary file types for XAPK -->
                <data android:mimeType="application/zip" />
                <data android:mimeType="application/octet-stream" />
                <!-- Handle "content://" and "file://" schemes -->
                <data android:scheme="content" />
                <data android:scheme="file" />
            </intent-filter>
        </activity>

        <!-- 4. The Device Admin Receiver (The Core) -->
        <receiver
            android:name=".DeviceAdmin"
            android:description="@string/admin_description"
            android:exported="true"
            android:permission="android.permission.BIND_DEVICE_ADMIN">
            <meta-data
                android:name="android.app.admin"
                android:resource="@xml/device_admin_policies" />
            <intent-filter>
                <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" />
            </intent-filter>
        </receiver>

        <!-- 5. The Receiver for Install Results -->
        <receiver
            android:name=".InstallResultReceiver"
            android:exported="false" />

    </application>

</manifest>
device_admin_policies.xml
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is still required, even if empty,
to declare the app as an admin.
-->
<device-admin xmlns:android="http://schemas.android.com/apk/res/android">
    <uses-policies>
        <!-- As Device Owner, we get powers implicitly. -->
    </uses-policies>
</device-admin>

Can you give me exact output?

Did you build debug by mistake?

no purposely so i can easily uninstall if needed. The first version is also debug and can therefore be easily uninstalled but still works to set as admin. Unless i didn’t make the first 1 debug really?

Error: Bad admin: ComponentInfo{com.example.deviceownerapp/com.example.deviceownerapp.DeviceAdmin}

You used two different app names

deviceownerapp
appinstaller

Which one?

The APK posted in op is com.example.appinstaller

the 1 i posted works. Trying to fix new 1

Line 57

android:name="android.app.admin"

Change to:

android:name="android.app.device_admin"

That’s what your old one has, and seems to be the proper way.

1 Like

thanks! That worked!
Can’t post the new 1 yet. Its better then the old 1 but still has tons of bugs i gotta take care of. Including xapk install function failing. don’t have patience now maybe later. If anyone wants to help please lmk i’ll post the source.

1 weird issue i ran into is that this new app can also hide apps or paths disable any app including system apps. I tried disabling a user app and a system app and it worked perfectly. But then when i rebooted no installed apps show up in applications. I have no clue why. All apps are still installed and still work (i had to launch using am start in termux which came up in recent apps). If anyone knows why or if there’s a fix to this lmk

1 Like

Which apps did you disable

Pull system and post?

Disabled browser and file explorer.

you mean entire system image? Can do but upload time to google drive is crazy slow here so will take time. If you have another way i can send it to you pm.

Edit: google drive upload will take longer then the time the phone is on between reboots. Since i reset this old phone it reboots every few minutes!

I dunno, there’s probably something there that does a weird check for apps. I’ve seen weirder, like:

https://forums.jtechforums.org/t/small-questions-that-dont-deserve-their-own-thread/393/1058?u=ars18

1 Like

I’ll be glad to help send source via….

1 Like

Major update coming to the app. Way easier to play around support for xapk, uninstall from within the app itself, easily update without needing adb each time etc.

1 Like

total new app. Here’s the readme

Device Owner App

A utility application designed for Sonim XP5800 and XP3800 devices (Android 8.1) to facilitate local app installation without constant ADB connection.

These devices often restrict app installation, allowing only ADB or Device Owner/Admin based installations. This app acts as a Device Owner/Admin to bypass these restrictions and allow users to install APK and XAPK files directly from the device.

Features

  • Install APKs: Directly install standard .apk files.
  • Install XAPKs: Supports installing .xapk (and .zip) bundles containing Split APKs. Uses robust ZipFile processing to handle various compression types.
  • Progress UI: Visual feedback during installation preventing “App Not Responding” errors on large files.
  • Error Logging: Detailed error logs are saved to Android/data/com.example.deviceownerapp/files/app_errors.log.
  • Permissions Management: Allows granting or denying runtime permissions for installed apps.
  • Admin Management: Easy uninstallation and admin removal via the main interface.
  • Self-Update: Built-in feature to check for updates and self-install them while retaining Device Owner status.

Usage

  1. Installation:

    • Download Latest Release
    • Install this app via ADB for the first time: adb install -t -r DeviceAdminApp.apk
    • Important: Remove the SIM card from the device before setting the device owner. Sonim devices treat the SIM as an account and may block the command if present.
    • Set it as Device Owner:
      adb shell dpm set-device-owner com.example.deviceownerapp/.DeviceAdmin
      
  2. Troubleshooting:

    • If you have existing accounts (Google, etc.) that prevent setting Device Owner, use adb shell dumpsys account to list them and remove them from Settings > Accounts.
  3. Installing Apps:

    • Option A: Open “Device Owner App” and click “Install File” to pick an APK/XAPK.
    • Option B: Use a file manager to open an APK/XAPK and select “Device Owner App” as the handler.
  4. Uninstallation:

    • Open the app and click “Uninstall App”. This will remove the Device Owner status and then uninstall the app itself.

Releases

Build

To build this project, you can use the included build.sh script if you are in a Termux environment with the appropriate android.jar.

./build.sh

Ensure you have aapt2, ecj, d8, zip, and apksigner installed.

GitHub repo

please provide feedback!

2 Likes

@HalachiDev

1 Like