1/*
2 * Copyright (C) 2021 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.bedstead.remoteframeworkclasses;
18
19import android.bluetooth.RemoteBluetoothAdapter;
20import android.os.Parcel;
21import android.os.Parcelable;
22
23import com.google.android.enterprise.connectedapps.annotations.CustomParcelableWrapper;
24import com.google.android.enterprise.connectedapps.internal.Bundler;
25import com.google.android.enterprise.connectedapps.internal.BundlerType;
26
27/**
28 * This parcelable wrapper just passes null to callers.
29 *
30 * <p>It is not functional and only enables use of {@link RemoteBluetoothAdapter} for clients
31 * which do not need to actually use the {@link RemoteBluetoothAdapter} param or return value.
32 */
33@CustomParcelableWrapper(originalType = RemoteBluetoothAdapter.class)
34public final class NullParcelableRemoteBluetoothAdapter implements Parcelable {
35
36    /**
37     * Create a wrapper for a given {@link RemoteBluetoothAdapter}.
38     */
39    public static <F> NullParcelableRemoteBluetoothAdapter of(
40            Bundler bundler, BundlerType type,
41            RemoteBluetoothAdapter remoteBluetoothAdapter) {
42        return new NullParcelableRemoteBluetoothAdapter();
43    }
44
45    private NullParcelableRemoteBluetoothAdapter() {
46    }
47
48    public RemoteBluetoothAdapter get() {
49        return null;
50    }
51
52    @Override
53    public void writeToParcel(Parcel dest, int flags) {
54    }
55
56    @Override
57    public int describeContents() {
58        return 0;
59    }
60
61    @SuppressWarnings("rawtypes")
62    public static final Creator<NullParcelableRemoteBluetoothAdapter> CREATOR =
63            new Creator<NullParcelableRemoteBluetoothAdapter>() {
64                @Override
65                public NullParcelableRemoteBluetoothAdapter createFromParcel(Parcel in) {
66                    return new NullParcelableRemoteBluetoothAdapter();
67                }
68
69                @Override
70                public NullParcelableRemoteBluetoothAdapter[] newArray(int size) {
71                    return new NullParcelableRemoteBluetoothAdapter[size];
72                }
73            };
74}