android.media.tv.TvInputService Java Examples

The following examples show how to use android.media.tv.TvInputService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TvInputManagerService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private void updateServiceConnectionLocked(ComponentName component, int userId) {
    UserState userState = getOrCreateUserStateLocked(userId);
    ServiceState serviceState = userState.serviceStateMap.get(component);
    if (serviceState == null) {
        return;
    }
    if (serviceState.reconnecting) {
        if (!serviceState.sessionTokens.isEmpty()) {
            // wait until all the sessions are removed.
            return;
        }
        serviceState.reconnecting = false;
    }

    boolean shouldBind;
    if (userId == mCurrentUserId) {
        shouldBind = !serviceState.sessionTokens.isEmpty() || serviceState.isHardware;
    } else {
        // For a non-current user,
        // if sessionTokens is not empty, it contains recording sessions only
        // because other sessions must have been removed while switching user
        // and non-recording sessions are not created by createSession().
        shouldBind = !serviceState.sessionTokens.isEmpty();
    }

    if (serviceState.service == null && shouldBind) {
        // This means that the service is not yet connected but its state indicates that we
        // have pending requests. Then, connect the service.
        if (serviceState.bound) {
            // We have already bound to the service so we don't try to bind again until after we
            // unbind later on.
            return;
        }
        if (DEBUG) {
            Slog.d(TAG, "bindServiceAsUser(service=" + component + ", userId=" + userId + ")");
        }

        Intent i = new Intent(TvInputService.SERVICE_INTERFACE).setComponent(component);
        serviceState.bound = mContext.bindServiceAsUser(
                i, serviceState.connection,
                Context.BIND_AUTO_CREATE | Context.BIND_FOREGROUND_SERVICE_WHILE_AWAKE,
                new UserHandle(userId));
    } else if (serviceState.service != null && !shouldBind) {
        // This means that the service is already connected but its state indicates that we have
        // nothing to do with it. Then, disconnect the service.
        if (DEBUG) {
            Slog.d(TAG, "unbindService(service=" + component + ")");
        }
        mContext.unbindService(serviceState.connection);
        userState.serviceStateMap.remove(component);
    }
}
 
Example #2
Source File: TestTvInputService.java    From xipl with Apache License 2.0 4 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.N)
@Nullable
@Override
public TvInputService.RecordingSession onCreateRecordingSession(String inputId) {
    return new TestRecordingSession(this, inputId);
}
 
Example #3
Source File: CumulusTvTifService.java    From CumulusTV with MIT License 4 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.N)
@Nullable
@Override
public TvInputService.RecordingSession onCreateRecordingSession(String inputId) {
    return null;
}
 
Example #4
Source File: RichTvInputService.java    From androidtv-sample-inputs with Apache License 2.0 4 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.N)
@Nullable
@Override
public TvInputService.RecordingSession onCreateRecordingSession(String inputId) {
    return new RichRecordingSession(this, inputId);
}
 
Example #5
Source File: TestTvInputService.java    From androidtv-sample-inputs with Apache License 2.0 4 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.N)
@Nullable
@Override
public TvInputService.RecordingSession onCreateRecordingSession(String inputId) {
    return new TestRecordingSession(this, inputId);
}