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