public final class

RootHintsPopulator

extends java.lang.Object

 java.lang.Object

↳androidx.car.app.mediaextensions.analytics.client.RootHintsPopulator

Gradle dependencies

compile group: 'androidx.car.app', name: 'app', version: '1.7.0-beta01'

  • groupId: androidx.car.app
  • artifactId: app
  • version: 1.7.0-beta01

Artifact androidx.car.app:app:1.7.0-beta01 it located at Google repository (https://maven.google.com/)

Overview

Populates Root hints for returned in MediaBrowserServiceCompat.onGetRoot(String, int, Bundle).

RootExtras can be updated after MediaBrowserServiceCompat.onGetRoot(String, int, Bundle) with a call to setExtras.

Summary

Constructors
publicRootHintsPopulator(Bundle rootHints)

Methods
public RootHintsPopulatorsetAnalyticsOptIn(boolean analyticsOptIn)

Sets analytics opt in state.

public RootHintsPopulatorsetShareOem(boolean shareOem)

Sets flag to share diagnostic analytics with OEM

public RootHintsPopulatorsetSharePlatform(boolean sharePlatform)

Sets flag to share diagnostic analytics with the platform

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public RootHintsPopulator(Bundle rootHints)

Methods

public RootHintsPopulator setAnalyticsOptIn(boolean analyticsOptIn)

Sets analytics opt in state.

Parameters:

analyticsOptIn: boolean value indicating opt-in to receive analytics.

public RootHintsPopulator setShareOem(boolean shareOem)

Sets flag to share diagnostic analytics with OEM

Parameters:

shareOem: boolean value indicating opt-in to share diagnostic analytics with OEM.

public RootHintsPopulator setSharePlatform(boolean sharePlatform)

Sets flag to share diagnostic analytics with the platform

Parameters:

sharePlatform: boolean value indicating opt-in to share diagnostic analytics with the platform.

Source

/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.car.app.mediaextensions.analytics.client;

import static androidx.car.app.mediaextensions.analytics.Constants.ANALYTICS_ROOT_KEY_OPT_IN;
import static androidx.car.app.mediaextensions.analytics.Constants.ANALYTICS_SHARE_OEM_DIAGNOSTICS;
import static androidx.car.app.mediaextensions.analytics.Constants.ANALYTICS_SHARE_PLATFORM_DIAGNOSTICS;

import android.os.Bundle;
import android.support.v4.media.session.MediaSessionCompat;

import androidx.annotation.NonNull;
import androidx.car.app.annotations.ExperimentalCarApi;
import androidx.media.MediaBrowserServiceCompat;

/**
 * Populates Root hints {@link Bundle} for {@link MediaBrowserServiceCompat.BrowserRoot}
 * returned in {@link MediaBrowserServiceCompat#onGetRoot(String, int, Bundle)}.
 *
 * <p>
 * RootExtras can be updated after
 * {@link MediaBrowserServiceCompat#onGetRoot(String, int, Bundle)} with a call to
 * {@link MediaSessionCompat#setExtras(Bundle)}.
 *
 * @see MediaBrowserServiceCompat#onGetRoot(String, int, Bundle)
 * @see MediaSessionCompat#setExtras(Bundle)
 */
@ExperimentalCarApi
public final class RootHintsPopulator {
    private final Bundle mRootHintsBundle;

    public RootHintsPopulator(@NonNull Bundle rootHints) {
        mRootHintsBundle = rootHints;
    }

    /**
     * Sets analytics opt in state.
     *
     * @param analyticsOptIn boolean value indicating opt-in to receive analytics.
     */
    @NonNull
    public RootHintsPopulator setAnalyticsOptIn(boolean analyticsOptIn) {
        mRootHintsBundle.putBoolean(ANALYTICS_ROOT_KEY_OPT_IN, analyticsOptIn);
        return this;
    }

    /**
     * Sets flag to share diagnostic analytics with OEM
     * @param shareOem boolean value indicating opt-in to share diagnostic analytics with OEM.
     */
    @NonNull
    public RootHintsPopulator setShareOem(boolean shareOem) {
        mRootHintsBundle.putBoolean(ANALYTICS_SHARE_OEM_DIAGNOSTICS, shareOem);
        return this;
    }

    /**
     * Sets flag to share diagnostic analytics with the platform
     * @param sharePlatform boolean value indicating opt-in to share diagnostic analytics with
     *                      the platform.
     */
    @NonNull
    public RootHintsPopulator setSharePlatform(boolean sharePlatform) {
        mRootHintsBundle.putBoolean(ANALYTICS_SHARE_PLATFORM_DIAGNOSTICS, sharePlatform);
        return this;
    }
}