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,#=2\""; 78 79 public static final String FEATURE_TAG_CHATBOT_ROLE = "+g.gsma.rcs.isbot"; 80 81 public static final String FEATURE_TAG_MMTEL = 82 "+g.3gpp.icsi-ref=\"urn%3Aurn-7%3A3gpp-service.ims.icsi.mmtel\""; 83 84 public static final String FEATURE_TAG_VIDEO = "video"; 85 86 public static final String FEATURE_TAG_PRESENCE = 87 "+g.3gpp.iari-ref=\"urn%3Aurn-7%3A3gpp-application.ims.iari.rcse.dp\""; 88 89 /** 90 * Add the feature tags to the given RcsContactUceCapability OPTIONS builder. 91 * @param optionsBuilder The OptionsBuilder to add the feature tags 92 * @param mmtelAudioSupport If the audio capability is supported 93 * @param mmtelVideoSupport If the video capability is supported 94 * @param presenceSupport If presence is also supported 95 * @param callComposerSupport If call composer via telephony is supported 96 * @param registrationTags The other feature tags included in the IMS registration. 97 */ addFeatureTags(final OptionsBuilder optionsBuilder, boolean mmtelAudioSupport, boolean mmtelVideoSupport, boolean presenceSupport, boolean callComposerSupport, Set<String> registrationTags)98 public static void addFeatureTags(final OptionsBuilder optionsBuilder, 99 boolean mmtelAudioSupport, boolean mmtelVideoSupport, 100 boolean presenceSupport, boolean callComposerSupport, Set<String> registrationTags) { 101 if (presenceSupport) { 102 registrationTags.add(FEATURE_TAG_PRESENCE); 103 } else { 104 registrationTags.remove(FEATURE_TAG_PRESENCE); 105 } 106 if (mmtelAudioSupport && mmtelVideoSupport) { 107 registrationTags.add(FEATURE_TAG_MMTEL); 108 registrationTags.add(FEATURE_TAG_VIDEO); 109 } else if (mmtelAudioSupport) { 110 registrationTags.add(FEATURE_TAG_MMTEL); 111 registrationTags.remove(FEATURE_TAG_VIDEO); 112 } else { 113 registrationTags.remove(FEATURE_TAG_MMTEL); 114 registrationTags.remove(FEATURE_TAG_VIDEO); 115 } 116 if (callComposerSupport) { 117 registrationTags.add(FEATURE_TAG_CALL_COMPOSER_VIA_TELEPHONY); 118 } else { 119 registrationTags.remove(FEATURE_TAG_CALL_COMPOSER_VIA_TELEPHONY); 120 } 121 if (!registrationTags.isEmpty()) { 122 optionsBuilder.addFeatureTags(registrationTags); 123 } 124 } 125 126 /** 127 * Get RcsContactUceCapabilities from the given feature tags. 128 */ getContactCapability(Uri contact, @SourceType int sourceType, List<String> featureTags)129 public static RcsContactUceCapability getContactCapability(Uri contact, 130 @SourceType int sourceType, List<String> featureTags) { 131 OptionsBuilder builder = new OptionsBuilder(contact, sourceType); 132 builder.setRequestResult(RcsContactUceCapability.REQUEST_RESULT_FOUND); 133 featureTags.forEach(feature -> builder.addFeatureTag(feature)); 134 return builder.build(); 135 } 136 } 137