public final class

HandshakeInfo

extends java.lang.Object

 java.lang.Object

↳androidx.car.app.HandshakeInfo

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

A container for the information conveyed by the host after the handshake with the app is completed.

Summary

Constructors
publicHandshakeInfo(java.lang.String hostPackageName, int hostCarAppApiLevel)

Creates an instance of HandshakeInfo.

Methods
public intgetHostCarAppApiLevel()

Returns the negotiated API level that should be used to communicate with the host.

public java.lang.StringgetHostPackageName()

Returns the host package name.

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

Constructors

public HandshakeInfo(java.lang.String hostPackageName, int hostCarAppApiLevel)

Creates an instance of HandshakeInfo.

Parameters:

hostPackageName: the host package name
hostCarAppApiLevel: the API level that should be used to communicate with the host

Methods

public java.lang.String getHostPackageName()

Returns the host package name.

public int getHostCarAppApiLevel()

Returns the negotiated API level that should be used to communicate with the host.

Source

/*
 * Copyright 2020 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;

import static java.util.Objects.requireNonNull;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.car.app.annotations.CarProtocol;
import androidx.car.app.annotations.KeepFields;

/**
 * A container for the information conveyed by the host after the handshake with the app is
 * completed.
 */
@CarProtocol
@KeepFields
public final class HandshakeInfo {
    @Nullable
    private final String mHostPackageName;
    private final int mHostCarAppApiLevel;

    /**
     * Creates an instance of {@link HandshakeInfo}.
     *
     * @param hostPackageName    the host package name
     * @param hostCarAppApiLevel the API level that should be used to communicate with the host
     */
    public HandshakeInfo(@NonNull String hostPackageName, int hostCarAppApiLevel) {
        mHostPackageName = hostPackageName;
        mHostCarAppApiLevel = hostCarAppApiLevel;
    }

    // Used for serialization
    private HandshakeInfo() {
        mHostPackageName = null;
        mHostCarAppApiLevel = 0;
    }

    /**
     * Returns the host package name.
     */
    @NonNull
    public String getHostPackageName() {
        return requireNonNull(mHostPackageName);
    }

    /**
     * Returns the negotiated API level that should be used to communicate with the host.
     */
    public int getHostCarAppApiLevel() {
        return mHostCarAppApiLevel;
    }
}