android-testdpc icon indicating copy to clipboard operation
android-testdpc copied to clipboard

Crashes on launching. Cannot uninstall.

Open e792a8 opened this issue 3 years ago • 5 comments

I installed the prebuilt apk from releases here and made it device owner. Unfortunately the app failed to launch - it crashes immediately after flashing a white screen. Now I cannot revoke its device owner because I cannot enter the app to configure. I cannot revoke via adb because the app is not test-only. I cannot uninstall the app because it is device owner. I do not want to restore my phone. I cloned and increased the version of your code trying to recover the original app, but I do not have your signature. I am here requesting for your help - is there any way to remove this app harmlessly, for example providing a fake upgrade version to override this app and directly revoke its device owner. Thanks.

For more information, my device is HUAWEI DVC-AN00 and the logcat when trying to launch the app:

AndroidRuntime          pid-25532                            E  FATAL EXCEPTION: main
	Process: com.afwsamples.testdpc, PID: 25532
	java.lang.RuntimeException: Unable to start activity ComponentInfo{com.afwsamples.testdpc/com.afwsamples.testdpc.PolicyManagementActivity}: java.lang.NullPointerException
		at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4060)
		at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4247)
		at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91)
		at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149)
		at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103)
		at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2613)
		at android.os.Handler.dispatchMessage(Handler.java:110)
		at android.os.Looper.loop(Looper.java:219)
		at android.app.ActivityThread.main(ActivityThread.java:8668)
		at java.lang.reflect.Method.invoke(Native Method)
		at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
		at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)
	Caused by: java.lang.NullPointerException
		at android.os.Parcel.createException(Parcel.java:2097)
		at android.os.Parcel.readException(Parcel.java:2059)
		at android.os.Parcel.readException(Parcel.java:2007)
		at android.app.admin.IDevicePolicyManager$Stub$Proxy.isSecurityLoggingEnabled(IDevicePolicyManager.java:12639)
		at android.app.admin.DevicePolicyManager.isSecurityLoggingEnabled(DevicePolicyManager.java:9218)
		at com.afwsamples.testdpc.policy.PolicyManagementFragment.isSecurityLoggingEnabled(PolicyManagementFragment.java:1763)
		at com.afwsamples.testdpc.policy.PolicyManagementFragment.lambda$onCreatePreferences$98$PolicyManagementFragment(PolicyManagementFragment.java:668)
		at com.afwsamples.testdpc.policy.PolicyManagementFragment$$Lambda$12.validateConstraint(Unknown Source:2)
		at com.afwsamples.testdpc.common.preference.DpcPreferenceHelper.findConstraintViolation(DpcPreferenceHelper.java:244)
		at com.afwsamples.testdpc.common.preference.DpcPreferenceHelper.disableIfConstraintsNotMet(DpcPreferenceHelper.java:220)
		at com.afwsamples.testdpc.common.preference.DpcPreferenceHelper.addCustomConstraint(DpcPreferenceHelper.java:206)
		at com.afwsamples.testdpc.common.preference.DpcPreferenceHelper.setCustomConstraint(DpcPreferenceHelper.java:192)
		at com.afwsamples.testdpc.common.preference.DpcPreference.setCustomConstraint(DpcPreference.java:103)
		at com.afwsamples.testdpc.policy.PolicyManagementFragment.onCreatePreferences(PolicyManagementFragment.java:671)
		at androidx.preference.PreferenceFragment.onCreate(PreferenceFragment.java:225)
		at com.afwsamples.testdpc.common.BaseSearchablePolicyPreferenceFragment.onCreate(BaseSearchablePolicyPreferenceFragment.java:53)
		at com.afwsamples.testdpc.policy.PolicyManagementFragment.onCreate(PolicyManagementFragment.java:558)
		at android.app.Fragment.performCreate(Fragment.java:2529)
		at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1264)
		at android.app.FragmentManagerImpl.addAddedFragments(FragmentManager.java:2447)
		at android.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2226)
		at android.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2182)
		at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2083)
		at android.app.FragmentManagerImpl.dispatchMoveToState(FragmentManager.java:3073)
		at android.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3020)
		at android.app.FragmentController.dispatchActivityCreated(FragmentController.java:184)
		at android.app.Activity.performCreate(Activity.java:8221)
		at android.app.Activity.performCreate(Activity.java:8202)
		at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1320)
		at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:4033)
		at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:4247) 
		at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:91) 
		at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:149) 
		at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:103) 
		at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2613) 
		at android.os.Handler.dispatchMessage(Handler.java:110) 
		at android.os.Looper.loop(Looper.java:219) 
		at android.app.ActivityThread.main(ActivityThread.java:8668) 
		at java.lang.reflect.Method.invoke(Native Method) 
		at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513) 
		at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109) 
	Caused by: android.os.RemoteException: Remote stack trace:
WindowManager           pid-1788                             E  win=Window{d44d640 u0 Splash Screen com.afwsamples.testdpc EXITING} destroySurfaces: appStopped=false win.mWindowRemovalAllowed=true win.mRemoveOnExit=true

e792a8 avatar Oct 11 '22 18:10 e792a8

Same problem since upgrading to android 13

justcop avatar Oct 12 '22 18:10 justcop

Hi I'm sorry this happened.

We've changed build system and I haven't yet got round to getting the keys working again so releasing another signed build at this moment is difficult. Let's try something else first:

can you try running

adb shell dumpsys activity service --user 0 com.afwsamples.testdpc clear-device-owner

Let me know what happens

jscott1989 avatar Oct 13 '22 18:10 jscott1989

The argument --user 0 seems wrong. I tried:

> adb shell dumpsys activity service com.afwsamples.testdpc clear-device-owner

SERVICE com.afwsamples.testdpc/.DeviceAdminService d234e12 pid=(not running)

Service is not running. Then I tried this way: execute the command immediately when launching the app. For the first 3 tries I got:

SERVICE com.afwsamples.testdpc/.DeviceAdminService d234e12 pid=16385 (<-changes each time)
  Client:

And then for the 4th try I got:

SERVICE com.afwsamples.testdpc/.DeviceAdminService d234e12 pid=16506
  Client:
    Removed com.afwsamples.testdpc as device owner

So this works. Now device owner is cleared. Thanks for your help!

e792a8 avatar Oct 14 '22 02:10 e792a8

My aim isn't to uninstall, I'd just like to launch the app! Is there a quick fix to that too?

justcop avatar Oct 14 '22 07:10 justcop

Quick fix is to build it from source in this repository. You'll need to uninstall using this command then reinstall your build (as the keys won't match)

Otherwise it'll have to wait until I get the build system working correctly.

jscott1989 avatar Oct 14 '22 09:10 jscott1989

We have now a new release (v9.0.1) that supports Android 13 and 14. Please test again with this release and open a new issue if the problem persist.

pfmaggi avatar Nov 23 '23 14:11 pfmaggi