summaryrefslogtreecommitdiffstats
path: root/telecomm/java/android/telecom/PhoneCapabilities.java
blob: 3d3c6bd1732462b2d45a7d994043a6627a2181d6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*
 * Copyright 2014, 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 android.telecom;

/**
 * Defines capabilities for {@link Connection}s and {@link Conference}s such as hold, swap, and
 * merge.
 */
public final class PhoneCapabilities {
    /** Call can currently be put on hold or unheld. */
    public static final int HOLD               = 0x00000001;

    /** Call supports the hold feature. */
    public static final int SUPPORT_HOLD       = 0x00000002;

    /**
     * Calls within a conference can be merged. A {@link ConnectionService} has the option to
     * add a {@link Conference} call before the child {@link Connection}s are merged. This is how
     * CDMA-based {@link Connection}s are implemented. For these unmerged {@link Conference}s, this
     * capability allows a merge button to be shown while the conference call is in the foreground
     * of the in-call UI.
     * <p>
     * This is only intended for use by a {@link Conference}.
     */
    public static final int MERGE_CONFERENCE   = 0x00000004;

    /**
     * Calls within a conference can be swapped between foreground and background.
     * See {@link #MERGE_CONFERENCE} for additional information.
     * <p>
     * This is only intended for use by a {@link Conference}.
     */
    public static final int SWAP_CONFERENCE    = 0x00000008;

    /** Call currently supports adding another call to this one. */
    public static final int ADD_CALL           = 0x00000010;

    /** Call supports responding via text option. */
    public static final int RESPOND_VIA_TEXT   = 0x00000020;

    /** Call can be muted. */
    public static final int MUTE               = 0x00000040;

    /**
     * Call supports conference call management. This capability only applies to {@link Conference}
     * calls which can have {@link Connection}s as children.
     */
    public static final int MANAGE_CONFERENCE = 0x00000080;

    /**
     * Local device supports video telephony.
     * @hide
     */
    public static final int SUPPORTS_VT_LOCAL  = 0x00000100;

    /**
     * Remote device supports video telephony.
     * @hide
     */
    public static final int SUPPORTS_VT_REMOTE = 0x00000200;

    /**
     * Call is using voice over LTE.
     * @hide
     */
    public static final int VoLTE = 0x00000400;

    /**
     * Call is using voice over WIFI.
     * @hide
     */
    public static final int VoWIFI = 0x00000800;

    /**
     * Call is able to be separated from its parent {@code Conference}, if any.
     */
    public static final int SEPARATE_FROM_CONFERENCE = 0x00001000;

    /**
     * Call is able to be individually disconnected when in a {@code Conference}.
     */
    public static final int DISCONNECT_FROM_CONFERENCE = 0x00002000;

    public static final int ALL = HOLD | SUPPORT_HOLD | MERGE_CONFERENCE | SWAP_CONFERENCE
            | ADD_CALL | RESPOND_VIA_TEXT | MUTE | MANAGE_CONFERENCE | SEPARATE_FROM_CONFERENCE
            | DISCONNECT_FROM_CONFERENCE;

    /**
     * Whether this set of capabilities supports the specified capability.
     * @param capabilities The set of capabilities.
     * @param capability The capability to check capabilities for.
     * @return Whether the specified capability is supported.
     * @hide
     */
    public static boolean can(int capabilities, int capability) {
        return (capabilities & capability) != 0;
    }

    /**
     * Removes the specified capability from the set of capabilities and returns the new set.
     * @param capabilities The set of capabilities.
     * @param capability The capability to remove from the set.
     * @return The set of capabilities, with the capability removed.
     * @hide
     */
    public static int remove(int capabilities, int capability) {
        return capabilities & ~capability;
    }

    public static String toString(int capabilities) {
        StringBuilder builder = new StringBuilder();
        builder.append("[Capabilities:");
        if (can(capabilities, HOLD)) {
            builder.append(" HOLD");
        }
        if (can(capabilities, SUPPORT_HOLD)) {
            builder.append(" SUPPORT_HOLD");
        }
        if (can(capabilities, MERGE_CONFERENCE)) {
            builder.append(" MERGE_CONFERENCE");
        }
        if (can(capabilities, SWAP_CONFERENCE)) {
            builder.append(" SWAP_CONFERENCE");
        }
        if (can(capabilities, ADD_CALL)) {
            builder.append(" ADD_CALL");
        }
        if (can(capabilities, RESPOND_VIA_TEXT)) {
            builder.append(" RESPOND_VIA_TEXT");
        }
        if (can(capabilities, MUTE)) {
            builder.append(" MUTE");
        }
        if (can(capabilities, MANAGE_CONFERENCE)) {
            builder.append(" MANAGE_CONFERENCE");
        }
        if (can(capabilities, SUPPORTS_VT_LOCAL)) {
            builder.append(" SUPPORTS_VT_LOCAL");
        }
        if (can(capabilities, SUPPORTS_VT_REMOTE)) {
            builder.append(" SUPPORTS_VT_REMOTE");
        }
        if (can(capabilities, VoLTE)) {
            builder.append(" VoLTE");
        }
        if (can(capabilities, VoWIFI)) {
            builder.append(" VoWIFI");
        }
        builder.append("]");
        return builder.toString();
    }

    private PhoneCapabilities() {}
}