private void setSelectedRouteLocked(IMediaRouterClient client, String routeId, boolean explicit) { ClientRecord clientRecord = mAllClientRecords.get(client.asBinder()); if (clientRecord != null) { final String oldRouteId = clientRecord.mSelectedRouteId; if (!Objects.equals(routeId, oldRouteId)) { if (DEBUG) { Slog.d(TAG, clientRecord + ": Set selected route, routeId=" + routeId + ", oldRouteId=" + oldRouteId + ", explicit=" + explicit); } clientRecord.mSelectedRouteId = routeId; if (explicit) { // Any app can disconnect from the globally selected route. if (oldRouteId != null) { clientRecord.mUserRecord.mHandler.obtainMessage( UserHandler.MSG_UNSELECT_ROUTE, oldRouteId).sendToTarget(); } // Only let the system connect to new global routes for now. // A similar check exists in the display manager for wifi display. if (routeId != null && clientRecord.mTrusted) { clientRecord.mUserRecord.mHandler.obtainMessage( UserHandler.MSG_SELECT_ROUTE, routeId).sendToTarget(); } } } } }
private MediaRouterClientState getStateLocked(IMediaRouterClient client) { ClientRecord clientRecord = mAllClientRecords.get(client.asBinder()); if (clientRecord != null) { return clientRecord.getState(); } return null; }
private void disposeClientLocked(ClientRecord clientRecord, boolean died) { if (DEBUG) { if (died) { Slog.d(TAG, clientRecord + ": Died!"); } else { Slog.d(TAG, clientRecord + ": Unregistered"); } } if (clientRecord.mRouteTypes != 0 || clientRecord.mActiveScan) { clientRecord.mUserRecord.mHandler.sendEmptyMessage( UserHandler.MSG_UPDATE_DISCOVERY_REQUEST); } clientRecord.dispose(); }
private void setDiscoveryRequestLocked(IMediaRouterClient client, int routeTypes, boolean activeScan) { final IBinder binder = client.asBinder(); ClientRecord clientRecord = mAllClientRecords.get(binder); if (clientRecord != null) { // Only let the system discover remote display routes for now. if (!clientRecord.mTrusted) { routeTypes &= ~MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY; } if (clientRecord.mRouteTypes != routeTypes || clientRecord.mActiveScan != activeScan) { if (DEBUG) { Slog.d(TAG, clientRecord + ": Set discovery request, routeTypes=0x" + Integer.toHexString(routeTypes) + ", activeScan=" + activeScan); } clientRecord.mRouteTypes = routeTypes; clientRecord.mActiveScan = activeScan; clientRecord.mUserRecord.mHandler.sendEmptyMessage( UserHandler.MSG_UPDATE_DISCOVERY_REQUEST); } } }
/** * Schedules the client with the task, if it is in the proper threadgroup and has not thrown a * stop scheduling order for it. */ protected boolean schedule(ClientRecord client, TestTask task, long now) { if (task.usesThreadGroup(client.getThreadGroupName()) && !task.receivedStopSchedulingTaskOnClientOrder(client)) { ClientVmRecord vm = client.vm(); synchronized (vm) { if (vm.isLive()) { synchronized (client) { client.setBusy(true); client.setTask(task); client.setStartTime(now); synchronized (task) { task.incrementNumTimesInUse(); } assignTask(client, task); } } } return true; } else { return false; } }