monkeyrunner - Android.isUserAMonkey throws RuntimeException -
i'm seeing exceptions when activitymanager.isuseramonkey()
run on older android devices:
java.lang.runtimeexception: unable start activity componentinfo{com.myapp.androidapp}: java.lang.runtimeexception: unknown exception code: 1 msg null @ android.app.activitythread.performlaunchactivity(activitythread.java:2781) @ android.app.activitythread.handlelaunchactivity(activitythread.java:2797) @ android.app.activitythread.access$2300(activitythread.java:135) @ android.app.activitythread$h.handlemessage(activitythread.java:2132) @ android.os.handler.dispatchmessage(handler.java:99) @ android.os.looper.loop(looper.java:143) @ android.app.activitythread.main(activitythread.java:4914) @ java.lang.reflect.method.invokenative(native method) @ java.lang.reflect.method.invoke(method.java:521) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:858) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616) @ dalvik.system.nativestart.main(native method) caused by: java.lang.runtimeexception: unknown exception code: 1 msg null @ android.os.parcel.readexception(parcel.java:1257) @ android.os.parcel.readexception(parcel.java:1235) @ android.app.activitymanagerproxy.isuseramonkey(activitymanagernative.java:2762) @ android.app.activitymanager.isuseramonkey(activitymanager.java:990) @ <com.myapp....> ...
there bit of discussion of bug here (including classic thats-not-possible response 1 of developers: "in standard platform implementation pretty not possible.")
https://groups.google.com/forum/?fromgroups=#!topic/android-developers/tqjcm4o4wxm
its not clear me if happens, or happens when running under test monkey, or on devices or what. (i'm running problem using apkudo's device testing service, user monkey.) not clear when fixed, either (it doesn't happen on (all?) newer devices).
the exception seems restricted android 2.2 (sdk version 8) releases. , seems have been bug in android.app.activitymanagernative
.
here's 2.2.1 code (found in activitymanagernative.java on grepcode.com):
1248 case is_user_a_monkey_transaction: { 1249 data.enforceinterface(iactivitymanager.descriptor); 1250 reply.writeint(isuseramonkey() ? 1 : 0); 1251 reply.writenoexception(); 1252 return true; 1253 }
here's 2.3.1 code (which seems same more recent 4.x code know works correctly). (also found on grepcode.com):
1248 case is_user_a_monkey_transaction: { 1239 data.enforceinterface(iactivitymanager.descriptor); 1240 boolean arethey = isuseramonkey(); 1241 reply.writenoexception(); 1242 reply.writeint(arethey ? 1 : 0); 1243 return true; 1244 }
notice order of writenoexception
, writeint
reversed in newer code. corresponding code read parcel seems unchanged since 2.2.1 far can tell:
2749 public boolean isuseramonkey() throws remoteexception { 2750 parcel data = parcel.obtain(); 2751 parcel reply = parcel.obtain(); 2752 data.writeinterfacetoken(iactivitymanager.descriptor); 2753 mremote.transact(is_user_a_monkey_transaction, data, reply, 0); 2754 reply.readexception(); 2755 boolean res = reply.readint() != 0; 2756 data.recycle(); 2757 reply.recycle(); 2758 return res; 2759 }
this side reads exception first, expects data.
the javadoc parcel readexception
, writeexception
imply record exception in parcel's header (and shouldn't impact actual data in parcel), seems order matter.
this means on sdk version 8 activietymanager.isuseramonkey()
api always throw exception, monkey or not. android builds after sdk 8 should not throw exception.
i suspect sdk 8 exception message might different without monkey ("1 msg null" vs. maybe "0 msg null"?), don't have example of exception without monkey running.
Comments
Post a Comment