blob: 46df38837db3a9144068f2a2fd248ba601663cd7 [file] [log] [blame]
Dianne Hackborn632ca412012-06-14 19:34:10 -07001/*
2 * Copyright (C) 2012 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 android.media;
18
19import android.os.Parcel;
20import android.os.Parcelable;
21import android.text.TextUtils;
22
23/**
24 * Information available from AudioService about the current routes.
25 * @hide
26 */
27public class AudioRoutesInfo implements Parcelable {
John Spurlock61560172015-02-06 19:46:04 -050028 public static final int MAIN_SPEAKER = 0;
29 public static final int MAIN_HEADSET = 1<<0;
30 public static final int MAIN_HEADPHONES = 1<<1;
31 public static final int MAIN_DOCK_SPEAKERS = 1<<2;
32 public static final int MAIN_HDMI = 1<<3;
33 public static final int MAIN_USB = 1<<4;
Dianne Hackborn632ca412012-06-14 19:34:10 -070034
John Spurlock61560172015-02-06 19:46:04 -050035 public CharSequence bluetoothName;
36 public int mainType = MAIN_SPEAKER;
Dianne Hackborn632ca412012-06-14 19:34:10 -070037
38 public AudioRoutesInfo() {
39 }
40
41 public AudioRoutesInfo(AudioRoutesInfo o) {
John Spurlock61560172015-02-06 19:46:04 -050042 bluetoothName = o.bluetoothName;
43 mainType = o.mainType;
Dianne Hackborn632ca412012-06-14 19:34:10 -070044 }
45
46 AudioRoutesInfo(Parcel src) {
John Spurlock61560172015-02-06 19:46:04 -050047 bluetoothName = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(src);
48 mainType = src.readInt();
Dianne Hackborn632ca412012-06-14 19:34:10 -070049 }
50
51 @Override
52 public int describeContents() {
53 return 0;
54 }
55
56 @Override
Jae Seo18687b72016-05-07 14:09:43 -070057 public String toString() {
58 return getClass().getSimpleName() + "{ type=" + typeToString(mainType)
59 + (TextUtils.isEmpty(bluetoothName) ? "" : ", bluetoothName=" + bluetoothName)
60 + " }";
61 }
62
63 private static String typeToString(int type) {
64 if (type == MAIN_SPEAKER) return "SPEAKER";
65 if ((type & MAIN_HEADSET) != 0) return "HEADSET";
66 if ((type & MAIN_HEADPHONES) != 0) return "HEADPHONES";
67 if ((type & MAIN_DOCK_SPEAKERS) != 0) return "DOCK_SPEAKERS";
68 if ((type & MAIN_HDMI) != 0) return "HDMI";
69 if ((type & MAIN_USB) != 0) return "USB";
70 return Integer.toHexString(type);
71 }
72
73 @Override
Dianne Hackborn632ca412012-06-14 19:34:10 -070074 public void writeToParcel(Parcel dest, int flags) {
John Spurlock61560172015-02-06 19:46:04 -050075 TextUtils.writeToParcel(bluetoothName, dest, flags);
76 dest.writeInt(mainType);
Dianne Hackborn632ca412012-06-14 19:34:10 -070077 }
78
Jeff Sharkey9e8f83d2019-02-28 12:06:45 -070079 public static final @android.annotation.NonNull Parcelable.Creator<AudioRoutesInfo> CREATOR
Dianne Hackborn632ca412012-06-14 19:34:10 -070080 = new Parcelable.Creator<AudioRoutesInfo>() {
81 public AudioRoutesInfo createFromParcel(Parcel in) {
82 return new AudioRoutesInfo(in);
83 }
84
85 public AudioRoutesInfo[] newArray(int size) {
86 return new AudioRoutesInfo[size];
87 }
88 };
89}