We're encountering an issue with the Android Enterprise API in .NET Core. The problem we're facing is that when calling the management API or enterprise API to retrieve information about the private app we've added, it does not return the specific permission

"android.permission.PACKAGE_USAGE_STATS."

However, other special permissions such as

"android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" are present in the list.

This is how we're calling the API to get the application's info:

await _androidEnterpriseService.Products.Get(enterprise, "app:" + packageName).ExecuteAsync()

We're also using Android Management API but still not getting that permission.

using (AndroidManagementService androidService = manager.GetAndroidService())

{

  return await _androidService.Enterprises.Applications.Get($"enterprises/{enterprise}/applications/{packageName}").ExecuteAsync();

}

We've added the permission in the manifest file of the Android app.

Nuget Version:

Google.Apis.AndroidEnterprise.v1 1.45.0.1910

Google.Apis.AndroidManagement.v1 1.58.0.2881

1

There are 1 best solutions below

0
Clark Samson On BEST ANSWER

The issue you're facing seems to be linked to the android.permission.PACKAGE_USAGE_STATS permission which has a more complex protection level and defined as signature|privileged|development|appop|retailDemo, compared to android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS, which is a normal permission with permission level defined as normal.

To determine if your app qualifies for this permission, you'll need to review the protection level documentation here.

It's possible that the special permission isn't being properly handled or recognized by your app, which could explain why you're not seeing it returned when calling either the Google Play EMM API's Products.get or the Android Management API's Applications.Get. The issue might stem from the app's inability to recognize the permission due to not meeting its required protection level.