• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
17 package com.android.ims.rcs.uce.util;
18 
19 import android.net.Uri;
20 import android.telephony.ims.RcsContactUceCapability;
21 import android.telephony.ims.RcsContactUceCapability.OptionsBuilder;
22 import android.telephony.ims.RcsContactUceCapability.SourceType;
23 
24 import java.util.List;
25 import java.util.Set;
26 
27 /**
28  * The util class of the feature tags.
29  */
30 public class FeatureTags {
31 
32     public static final String FEATURE_TAG_STANDALONE_MSG =
33             "+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-"
34                     + "service.ims.icsi.oma.cpm.msg,urn%3Aurn-7%3A3gpp-"
35                     + "service.ims.icsi.oma.cpm.largemsg,urn%3Aurn-7%3A3gpp-"
36                     + "service.ims.icsi.oma.cpm.deferred\";+g.gsma.rcs.cpm.pager-large";
37 
38     public static final String FEATURE_TAG_CHAT_IM =
39             "+g.3gpp.iari-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.rcse.im\"";
40 
41     public static final String FEATURE_TAG_CHAT_SESSION =
42             "+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.oma.cpm.session\"";
43 
44     public static final String FEATURE_TAG_FILE_TRANSFER =
45             "+g.3gpp.iari-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.rcs.fthttp\"";
46 
47     public static final String FEATURE_TAG_FILE_TRANSFER_VIA_SMS =
48             "+g.3gpp.iari-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.rcs.ftsms\"";
49 
50     public static final String FEATURE_TAG_CALL_COMPOSER_ENRICHED_CALLING =
51             "+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.gsma.callcomposer\"";
52 
53     public static final String FEATURE_TAG_CALL_COMPOSER_VIA_TELEPHONY = "+g.gsma.callcomposer";
54 
55     public static final String FEATURE_TAG_POST_CALL =
56             "+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.gsma.callunanswered\"";
57 
58     public static final String FEATURE_TAG_SHARED_MAP =
59             "+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.gsma.sharedmap\"";
60 
61     public static final String FEATURE_TAG_SHARED_SKETCH =
62             "+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.gsma.sharedsketch\"";
63 
64     public static final String FEATURE_TAG_GEO_PUSH =
65             "+g.3gpp.iari-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.rcs.geopush\"";
66 
67     public static final String FEATURE_TAG_GEO_PUSH_VIA_SMS =
68             "+g.3gpp.iari-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.rcs.geosms\"";
69 
70     public static final String FEATURE_TAG_CHATBOT_COMMUNICATION_USING_SESSION =
71             "+g.3gpp.iari-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.rcs.chatbot\"";
72 
73     public static final String FEATURE_TAG_CHATBOT_COMMUNICATION_USING_STANDALONE_MSG =
74             "+g.3gpp.iari-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.rcs.chatbot.sa\"";
75 
76     public static final String FEATURE_TAG_CHATBOT_VERSION_SUPPORTED =
77             "+g.gsma.rcs.botversion=\"#=1\"";
78 
79     public static final String FEATURE_TAG_CHATBOT_VERSION_V2_SUPPORTED =
80             "+g.gsma.rcs.botversion=\"#=1,#=2\"";
81 
82     public static final String FEATURE_TAG_CHATBOT_ROLE = "+g.gsma.rcs.isbot";
83 
84     public static final String FEATURE_TAG_MMTEL =
85             "+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\"";
86 
87     public static final String FEATURE_TAG_VIDEO = "video";
88 
89     public static final String FEATURE_TAG_PRESENCE =
90             "+g.3gpp.iari-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.rcse.dp\"";
91 
92     /**
93      * Add the feature tags to the given RcsContactUceCapability OPTIONS builder.
94      * @param optionsBuilder The OptionsBuilder to add the feature tags
95      * @param mmtelAudioSupport If the audio capability is supported
96      * @param mmtelVideoSupport If the video capability is supported
97      * @param presenceSupport If presence is also supported
98      * @param callComposerSupport If call composer via telephony is supported
99      * @param registrationTags The other feature tags included in the IMS registration.
100      */
addFeatureTags(final OptionsBuilder optionsBuilder, boolean mmtelAudioSupport, boolean mmtelVideoSupport, boolean presenceSupport, boolean callComposerSupport, Set<String> registrationTags)101     public static void addFeatureTags(final OptionsBuilder optionsBuilder,
102             boolean mmtelAudioSupport, boolean mmtelVideoSupport,
103             boolean presenceSupport, boolean callComposerSupport, Set<String> registrationTags) {
104         if (presenceSupport) {
105             registrationTags.add(FEATURE_TAG_PRESENCE);
106         } else {
107             registrationTags.remove(FEATURE_TAG_PRESENCE);
108         }
109         if (mmtelAudioSupport && mmtelVideoSupport) {
110             registrationTags.add(FEATURE_TAG_MMTEL);
111             registrationTags.add(FEATURE_TAG_VIDEO);
112         } else if (mmtelAudioSupport) {
113             registrationTags.add(FEATURE_TAG_MMTEL);
114             registrationTags.remove(FEATURE_TAG_VIDEO);
115         } else {
116             registrationTags.remove(FEATURE_TAG_MMTEL);
117             registrationTags.remove(FEATURE_TAG_VIDEO);
118         }
119         if (callComposerSupport) {
120             registrationTags.add(FEATURE_TAG_CALL_COMPOSER_VIA_TELEPHONY);
121         } else {
122             registrationTags.remove(FEATURE_TAG_CALL_COMPOSER_VIA_TELEPHONY);
123         }
124         if (!registrationTags.isEmpty()) {
125             optionsBuilder.addFeatureTags(registrationTags);
126         }
127     }
128 
129     /**
130      * Get RcsContactUceCapabilities from the given feature tags.
131      */
getContactCapability(Uri contact, @SourceType int sourceType, List<String> featureTags)132     public static RcsContactUceCapability getContactCapability(Uri contact,
133             @SourceType int sourceType, List<String> featureTags) {
134         OptionsBuilder builder = new OptionsBuilder(contact, sourceType);
135         builder.setRequestResult(RcsContactUceCapability.REQUEST_RESULT_FOUND);
136         featureTags.forEach(feature -> builder.addFeatureTag(feature));
137         return builder.build();
138     }
139 }
140