@Override public void setUp() throws Exception { Logger.v(TAG, "setUp()"); super.setUp(); // Get WindowBinder from ApiService Intent intent = new Intent(getSystemContext(), ApiService.class); intent.setAction(IRemoteWindowBinder.class.getName()); IBinder service = bindService(intent); assertTrue(service.isBinderAlive()); mBinder = (WindowBinder) IRemoteWindowBinder.Stub.asInterface(service); assertNotNull(mBinder); mMockRemoteChatWindowManager = new MockRemoteChatWindowManager(); Field fieldRemoteChatWindowManagers = Utils.getPrivateField(WindowBinder.class, "mChatWindowManagerAdapters"); mChatWindowManagerAdapters = (List<ChatWindowManagerAdapter>) fieldRemoteChatWindowManagers.get(mBinder); // Add RemoteChatWindowManager to binder int startSize = mChatWindowManagerAdapters.size(); mBinder.addChatWindowManager(mMockRemoteChatWindowManager, false); assertEquals(startSize + 1, mChatWindowManagerAdapters.size()); mRemoteChatWindowManager = mChatWindowManagerAdapters.get(0); assertNotNull(mRemoteChatWindowManager); }
@Override public boolean isBinderAlive() { return mRemote.isBinderAlive(); }