Java lang securityexception no active admin componentinfo

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BasicManagedProfile sample not working on Android 10 #28

BasicManagedProfile sample not working on Android 10 #28

Comments

While the sample woks flawlessly on Android 8.1, on Android 10 the creation of a Work Profile stars anc completes but no DEVICE_ADMIN_ENABLED event is never captured by the BasicDeviceAdminReceiver.
As a consequence the Work Profile is never enabled.

EDIT: adding more detail.
I tryed bypassing the receiver (BasicDeviceAdminReceiver) whose only purpose is starting the Profile enabling process in EnableProfileActivity.
In this class just two things are done:

  • setting Profile name
  • enabling Profile
    It seems that DevicePolicyManager is crashing on setProfileName() or, if commented, on setProfileEnabled: hence Profile is never enabled.
    This is confirmed in device Settings where the Profile is available but marked as «not jet available».
    The error is:
Читайте также:  Html span image text

java.lang.RuntimeException: Unable to start activity ComponentInfo: java.lang.SecurityException: No active admin ComponentInfo

The text was updated successfully, but these errors were encountered:

Источник

Issue

I’m trying to run an app on the android emulator with full kiosk mode. So I wrote a DeviceAdminReceiver:

public class AdminReceiver : DeviceAdminReceiver < public override void OnEnabled(Context context, Intent intent) < base.OnEnabled(context, intent); Log.Info("Device Admin: ", "Enabled"); >public override void OnDisabled(Context context, Intent intent) < base.OnDisabled(context, intent); Log.Info("Device Admin: ", "Disabled"); >> 
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize)] [IntentFilter(new[] < Intent.ActionMain >, Categories = new[] < Intent.CategoryHome, Intent.CategoryDefault >)] public class MainActivity : MauiAppCompatActivity < protected override void OnCreate(Bundle savedInstanceState) < base.OnCreate(savedInstanceState); SetFullscreenFlags(); var devicePolicyManager = (DevicePolicyManager)GetSystemService(Context.DevicePolicyService); var deviceAdminComponent = new ComponentName(this, Java.Lang.Class.FromType(typeof(AdminReceiver))); var intent = new Intent(DevicePolicyManager.ActionAddDeviceAdmin); intent.PutExtra(DevicePolicyManager.ExtraDeviceAdmin, deviceAdminComponent); intent.PutExtra(DevicePolicyManager.ExtraAddExplanation, "Device administrator"); StartActivity(intent); devicePolicyManager.SetLockTaskPackages(deviceAdminComponent, new[] < PackageName >); StartLockTask(); > private void SetFullscreenFlags() < Window.SetFlags(WindowManagerFlags.Fullscreen, WindowManagerFlags.Fullscreen); if (Build.VERSION.SdkInt >= BuildVersionCodes.R) < Window.SetDecorFitsSystemWindows(true); var controller = Window.InsetsController; if (controller is not null) < controller.Hide(WindowInsets.Type.StatusBars() | WindowInsets.Type.NavigationBars()); >> else < Window.DecorView.SystemUiVisibility = (StatusBarVisibility) (SystemUiFlags.LowProfile | SystemUiFlags.Fullscreen | SystemUiFlags.LayoutFullscreen | SystemUiFlags.HideNavigation | SystemUiFlags.LayoutHideNavigation | SystemUiFlags.Immersive | SystemUiFlags.ImmersiveSticky); >> 

And finally here’s the AndroidManifest.xml:

The problem is that this line in MainActivity throw this exception:

devicePolicyManager.SetLockTaskPackages(deviceAdminComponent, new[] < PackageName >); Java.Lang.SecurityException: 'No active admin ComponentInfo' 

I already have a device_admin.xml in resources/xml with a device-admin tag, does it need more configuration? Or is the issue else where? Or maybe i’m instanciating two difference admin receiver?

Note: I already did the procedure to allow this app as device admin on the emulator and run the command via android debug bridge setting it as device owner:

dpm set-device-owner com.companyName.TestApp/.AdminReceiver 

Solution

Can you ensure that you are actually registering your BroadcastReceiver with attributes on the class instead of modifying the AndroidManifest.xml manually. I think what is throwing you off is that if you don’t register the receiver, it will get named as .AdminReceiver . However, when you are adding the reciever as .AdminReceiver in the AndroidManifest.xml, then Android will inflate that as .AdminReciever . So your AdminReceiver won’t get called.

[BroadcastReceiver( Name = "your.packagename.AdminReceiver", Description = "@string/device_owner_description", Label = "My Device Admin Receiver", Permission = Manifest.Permission.BindDeviceAdmin)] [MetaData("android.app.device_admin", Resource = "@xml/device_admin")] public class AdminReceiver : DeviceAdminReceiver

Then you should remove your entry in the manifest.

Читайте также:  Red black tree java implementation

If you need to filter specific intents, you can also add the [IntentFilter] attribute to add those, but it shouldn’t be necessary for device admin.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Agent crashes when in COSU mode and when system service is used #69

Agent crashes when in COSU mode and when system service is used #69

Comments

08-02 14:59:49.928 26936-26936/org.wso2.iot.agent E/AgentApplication: UncaughtExceptionHandler got an exception java.lang.RuntimeException: Unable to start receiver org.wso2.iot.agent.events.listeners.KioskAppInstallationListener: java.lang.SecurityException: No active admin ComponentInfo at android.app.ActivityThread.handleReceiver(ActivityThread.java:2616) at android.app.ActivityThread.access$1700(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5258) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) Caused by: java.lang.SecurityException: No active admin ComponentInfo at android.os.Parcel.readException(Parcel.java:1546) at android.os.Parcel.readException(Parcel.java:1499) at android.app.admin.IDevicePolicyManager$Stub$Proxy.setLockTaskPackages(IDevicePolicyManager.java:4212) at android.app.admin.DevicePolicyManager.setLockTaskPackages(DevicePolicyManager.java:3304) at org.wso2.iot.agent.events.listeners.KioskAppInstallationListener.onReceive(KioskAppInstallationListener.java:102) at android.app.ActivityThread.handleReceiver(ActivityThread.java:2609) at android.app.ActivityThread.access$1700(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1380) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:135) at android.app.ActivityThread.main(ActivityThread.java:5258) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 

I’ve noticed that there were no prompts to active device administration for the agent. The system service has been installed as a system application (/system/priv-app). Hope this helps.

Читайте также:  Svg css background safari

I’m testing this on Android 5.1.

The text was updated successfully, but these errors were encountered:

Источник

Оцените статью