Skip to content

Device Policy Controller Ops Mode#1858

Open
Tharow wants to merge 5 commits into
MuntashirAkon:masterfrom
Tharow-Services:DeviceAdmin
Open

Device Policy Controller Ops Mode#1858
Tharow wants to merge 5 commits into
MuntashirAkon:masterfrom
Tharow-Services:DeviceAdmin

Conversation

@Tharow

@Tharow Tharow commented Jan 17, 2026

Copy link
Copy Markdown
Contributor

Still Setting up the full Dev Environment for working of overlays / Platform integration
Thought I'd take a Swing at adding DPC support as it doesn't require a full AOSP Dev Environment to work on.

Known issues

  • Full Disclaimer and setup process info is needed.
  • Proper Interface for Removal / Transfer of DPC.
  • We Support Transfer in but not out of App Manager.
  • Warn User that removal of DPC will not remove it's policies, as it would be very difficult to track all the changes made with DPC and revert at removal time.

Fixed

  • Can't Toggle dev permissions and won't be able to, need to hide the toggle for them.
  • Fix Default policies of DPC as to give back the user full control.
  • Support Enabling and disabling of system app/ normal apps
  • Doesn't Display owner of device as App Manager.
  • No support interface to tell the user who restricted their access to something.

Signed-off-by: Theray Tharow <tharowt@tharow.net>
# Conflicts:
#	app/src/main/java/io/github/muntashirakon/AppManager/settings/Ops.java
#	app/src/main/res/values/strings.xml
Signed-off-by: Theray Tharow <tharowt@tharow.net>
Signed-off-by: Theray Tharow <tharowt@tharow.net>
Signed-off-by: Theray Tharow <tharowt@tharow.net>
@Tharow

Tharow commented Feb 1, 2026

Copy link
Copy Markdown
Contributor Author

@MuntashirAkon I need advisement for the UI for this feature, See Known Issues for more details.

Also how to trigger a Refresh/Mode Change of ModeOfOpsPreference Page from a receiver.

@Tharow Tharow marked this pull request as ready for review February 1, 2026 03:25
@MuntashirAkon MuntashirAkon reopened this Mar 1, 2026
@Tharow

Tharow commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

@MuntashirAkon while you're online, give me an idea of what you'd like ui wise so i can finish the feature.

@MuntashirAkon

Copy link
Copy Markdown
Owner

I have no idea what you're trying to do here. At first prepare a document that indicates the features and APIs supported by DPC. From what I understand, DPC doesn't use the standard APIs. Instead, they have their own dumbed down version of the APIs. If that's the case, it's not possible to add support for DPC at all, because it will render the project unmaintainable from my part.

@Tharow

Tharow commented May 3, 2026

Copy link
Copy Markdown
Contributor Author

@MuntashirAkon, yes it uses a more dumbdown version, it also is a public api meaning that it hasn't changed and is unlikely to change, plus the general usability that this offers can't be understated. This allows the basic functionality of AM to be persisted. Which besides the platform version I am currently working on, and direct root, AM can't currently do.
Both of which require modified android in some capacity.

And the way dpc is implemented, means that its a seperate section at the start of any normal AM operation it checks for dpc so you can always version lock the feature later if google fucks it up, by adding a android version check in canModifypermission in the dpc compact.
I will implement custom errors so it's obvious when its dpc fucking up.

But yes give me a day and I'll do a writeup of the feature. And see if theres a way to use the normal apis with it.

@MuntashirAkon

Copy link
Copy Markdown
Owner

But yes give me a day and I'll do a writeup of the feature. And see if theres a way to use the normal apis with it.

Any updates?

The back-end of App Manager is not mode of operation based, it is permission based. So, technically, it is possible to add one more section in Mode of Ops setting to allow the user to add AM to DPC. Once added, DPC APIs could be used as a fall-back mechanism in our existing compat-library (but this may require a review of the usage of those compat library functions since in some places, the permissions are checked before those functions are called). But in general, it might be possible to use DPC if App Manager itself is the DPC. If it's via a third-party app (provided the app adheres to our FLOSS policies), things might get even more complicated.

@Tharow

Tharow commented Jun 6, 2026

Copy link
Copy Markdown
Contributor Author

But yes give me a day and I'll do a writeup of the feature. And see if theres a way to use the normal apis with it.

Any updates?

The back-end of App Manager is not mode of operation based, it is permission based. So, technically, it is possible to add one more section in Mode of Ops setting to allow the user to add AM to DPC. Once added, DPC APIs could be used as a fall-back mechanism in our existing compat-library (but this may require a review of the usage of those compat library functions since in some places, the permissions are checked before those functions are called). But in general, it might be possible to use DPC if App Manager itself is the DPC. If it's via a third-party app (provided the app adheres to our FLOSS policies), things might get even more complicated.

@MuntashirAkon About DPC

I'm Sorry have been distracted by a police raid/replacing my font door.
The way I Implemented works sorta in the way you are discussing.

The way it is functions right now

You can only setup it up as device owner, Provisioning Guide from Google
In-fact it will self-destruct if it loads as admin or any of the other modes.
In the key functions of which DPC allows us to use, the Normal AM Permission check is OR'd with DevicePolicyManagerCompat.canModifyPermissions() and later with the functions it will check again and run against the dpc api accordingly.
I'll unify the code so that it is always the fallback, if I recall some instances check for dpc first before evaluating the rest of the function.

All DPC functions are done internally to AM, Via DevicePolicyManagerCompact, third-party solutions where not up-to the task when I wrote this.

This Feature does fully work, even if rough around the edges as I have not unified the code to be a consistent implementation across the board and has only be lightly tested, and is missing UI is facilitate setup of the feature.

I think it might be best to for me to hide the mode of OP selection for DPC, unless it's available, It won't show up in any system menu, because i have it set as owner-only, as it can only be activated under some restrictions that require some knowledge to begin with.
I'll put the disclaimer in the doc for setup instead of in the app it self.

Current Install Process

Setup a new device, it can NOT have any accounts on the device at the start of this process accounts can be added later.
install AM/Debug, run adb exec-out dpm set-device-owner io.github.muntashirakon.AppManager.debug/io.github.muntashirakon.AppManager.dpc.DpcReceiver
The command is automatically generated and displayed on the mode of ops page.

The Current Functions

  • Permission Modification/Locking This is a weird feature as it gives control of the permission only to AM, even the app can no longer request the permission if we deny first.

  • Complete Background Install (Only leaves a Notification)

  • Uninstall, and Available Freeze Options.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants