public class

ParcelableIBinder

extends java.lang.Object

 java.lang.Object

↳androidx.test.internal.util.ParcelableIBinder

Gradle dependencies

compile group: 'androidx.test', name: 'orchestrator', version: '1.5.0'

  • groupId: androidx.test
  • artifactId: orchestrator
  • version: 1.5.0

Artifact androidx.test:orchestrator:1.5.0 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.test:orchestrator com.android.support.test:orchestrator

Overview

Helper class to help create parcelable IBinder.

Required to maintain backwards comparability back to API level 8. Since Bundle.putBinder(...) was only introduced in API level 18.

Summary

Fields
public static final <any>CREATOR

Constructors
publicParcelableIBinder(IBinder iBinder)

protectedParcelableIBinder(Parcel in)

Methods
public intdescribeContents()

public IBindergetIBinder()

public voidwriteToParcel(Parcel dest, int flags)

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

Fields

public static final <any> CREATOR

Constructors

public ParcelableIBinder(IBinder iBinder)

protected ParcelableIBinder(Parcel in)

Methods

public IBinder getIBinder()

public int describeContents()

public void writeToParcel(Parcel dest, int flags)

Source

/*
 * Copyright (C) 2016 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.test.internal.util;

import static androidx.test.internal.util.Checks.checkNotNull;

import android.os.IBinder;
import android.os.Parcel;
import android.os.Parcelable;
import androidx.annotation.RestrictTo;

/**
 * Helper class to help create parcelable IBinder.
 *
 * <p>Required to maintain backwards comparability back to API level 8. Since {@code
 * Bundle.putBinder(...)} was only introduced in API level 18.
 *
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) // used by espresso remote
public class ParcelableIBinder implements Parcelable {

  private final IBinder iBinder;

  public ParcelableIBinder(IBinder iBinder) {
    this.iBinder = checkNotNull(iBinder);
  }

  public IBinder getIBinder() {
    return iBinder;
  }

  protected ParcelableIBinder(Parcel in) {
    iBinder = in.readStrongBinder();
  }

  public static final Creator<ParcelableIBinder> CREATOR =
      new Creator<ParcelableIBinder>() {
        @Override
        public ParcelableIBinder createFromParcel(Parcel in) {
          return new ParcelableIBinder(in);
        }

        @Override
        public ParcelableIBinder[] newArray(int size) {
          return new ParcelableIBinder[size];
        }
      };

  @Override
  public int describeContents() {
    return 0;
  }

  @Override
  public void writeToParcel(Parcel dest, int flags) {
    dest.writeStrongBinder(iBinder);
  }
}