我有一个带有外部API的服务。 在某些情况下,我必须抛出SecurityException。 奇怪的是以下内容: 在某些API中,当我引发异常时,绑定程序成功进行了此事务 并且该异常由服务的经理捕获。 但是,在其他API中,异常不会到达管理器,因为Binder会吞咽 它。 活页夹日志消息如下: “ 06年11月6日:04:05.766 3632 W活页夹活页夹调用失败。” 从Binder代码可以看出,由于事务是单向的,因此吞噬了该异常:
if ((flags & flaG_ONEWAY) != 0) {
737 if (e instanceof RemoteException) {
738 Log.w(TAG,"Binder call failed.",e);
739 } else {
740 Log.w(TAG,"Caught a RuntimeException from the binder stub implementation.",e);
741 }
742 } else {
743 // Clear the parcel before writing the exception
744 reply.setDataSize(0);
745 reply.setDataPosition(0);
746 reply.writeException(e);
747 }
我需要转发异常。我不明白为什么在某些情况下会转发异常,而在其他情况下却不会。我看不到这两种API之间的任何区别。如果可能的话,如何使我的例外不是单向的? 请帮忙。 提前致谢。 问候,Sveta