• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 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.presence.publish;
18 
19 import android.annotation.IntDef;
20 import android.annotation.NonNull;
21 import android.telephony.ims.RcsContactUceCapability;
22 import android.telephony.ims.RcsContactUceCapability.CapabilityMechanism;
23 import android.telephony.ims.RcsUceAdapter.PublishState;
24 import android.telephony.ims.aidl.IRcsUcePublishStateCallback;
25 
26 import com.android.ims.rcs.uce.ControllerBase;
27 
28 import java.io.PrintWriter;
29 import java.lang.annotation.Retention;
30 import java.lang.annotation.RetentionPolicy;
31 import java.time.Instant;
32 import java.util.Set;
33 
34 /**
35  * The interface related to the PUBLISH request.
36  */
37 public interface PublishController extends ControllerBase {
38 
39     /** Publish is triggered by the ImsService */
40     int PUBLISH_TRIGGER_SERVICE = 1;
41 
42     /** Publish trigger type: retry */
43     int PUBLISH_TRIGGER_RETRY = 2;
44 
45     /** Publish trigger type: TTY preferred changes */
46     int PUBLISH_TRIGGER_TTY_PREFERRED_CHANGE = 3;
47 
48     /** Publish trigger type: Mobile data changes */
49     int PUBLISH_TRIGGER_MOBILE_DATA_CHANGE = 4;
50 
51     /** Publish trigger type: VT setting changes */
52     int PUBLISH_TRIGGER_VT_SETTING_CHANGE = 5;
53 
54     /** Publish trigger type: MMTEL registered */
55     int PUBLISH_TRIGGER_MMTEL_REGISTERED = 6;
56 
57     /** Publish trigger type: MMTEL unregistered */
58     int PUBLISH_TRIGGER_MMTEL_UNREGISTERED = 7;
59 
60     /** Publish trigger type: MMTEL capability changes */
61     int PUBLISH_TRIGGER_MMTEL_CAPABILITY_CHANGE = 8;
62 
63     /** Publish trigger type: MMTEL associated uri changes */
64     int PUBLISH_TRIGGER_MMTEL_URI_CHANGE = 9;
65 
66     /** Publish trigger type: RCS registered */
67     int PUBLISH_TRIGGER_RCS_REGISTERED = 10;
68 
69     /** Publish trigger type: RCS unregistered */
70     int PUBLISH_TRIGGER_RCS_UNREGISTERED = 11;
71 
72     /** Publish trigger type: RCS associated uri changes */
73     int PUBLISH_TRIGGER_RCS_URI_CHANGE = 12;
74 
75     /** Publish trigger type: provisioning changes */
76     int PUBLISH_TRIGGER_PROVISIONING_CHANGE = 13;
77 
78     /**The caps have been overridden for a test*/
79     int PUBLISH_TRIGGER_OVERRIDE_CAPS = 14;
80 
81     /** The Carrier Config for the subscription has Changed **/
82     int PUBLISH_TRIGGER_CARRIER_CONFIG_CHANGED = 15;
83 
84     /** MMTEL and RCS are unregistered. **/
85     int PUBLISH_TRIGGER_MMTEL_RCS_UNREGISTERED = 16;
86 
87     @IntDef(value = {
88             PUBLISH_TRIGGER_SERVICE,
89             PUBLISH_TRIGGER_RETRY,
90             PUBLISH_TRIGGER_TTY_PREFERRED_CHANGE,
91             PUBLISH_TRIGGER_MOBILE_DATA_CHANGE,
92             PUBLISH_TRIGGER_VT_SETTING_CHANGE,
93             PUBLISH_TRIGGER_MMTEL_REGISTERED,
94             PUBLISH_TRIGGER_MMTEL_UNREGISTERED,
95             PUBLISH_TRIGGER_MMTEL_CAPABILITY_CHANGE,
96             PUBLISH_TRIGGER_MMTEL_URI_CHANGE,
97             PUBLISH_TRIGGER_RCS_REGISTERED,
98             PUBLISH_TRIGGER_RCS_UNREGISTERED,
99             PUBLISH_TRIGGER_RCS_URI_CHANGE,
100             PUBLISH_TRIGGER_PROVISIONING_CHANGE,
101             PUBLISH_TRIGGER_OVERRIDE_CAPS,
102             PUBLISH_TRIGGER_CARRIER_CONFIG_CHANGED,
103             PUBLISH_TRIGGER_MMTEL_RCS_UNREGISTERED
104     }, prefix="PUBLISH_TRIGGER_")
105     @Retention(RetentionPolicy.SOURCE)
106     @interface PublishTriggerType {}
107 
108     /**
109      * Receive the callback from the sub-components which interact with PublishController.
110      */
111     interface PublishControllerCallback {
112         /**
113          * Request publish from local.
114          */
requestPublishFromInternal(@ublishTriggerType int type)115         void requestPublishFromInternal(@PublishTriggerType int type);
116 
117         /**
118          * Receive the command error callback of the request from ImsService.
119          */
onRequestCommandError(PublishRequestResponse requestResponse)120         void onRequestCommandError(PublishRequestResponse requestResponse);
121 
122         /**
123          * Receive the network response callback fo the request from ImsService.
124          */
onRequestNetworkResp(PublishRequestResponse requestResponse)125         void onRequestNetworkResp(PublishRequestResponse requestResponse);
126 
127         /**
128          * Set the timer to cancel the request. This timer is to prevent taking too long for
129          * waiting the response callback.
130          */
setupRequestCanceledTimer(long taskId, long delay)131         void setupRequestCanceledTimer(long taskId, long delay);
132 
133         /**
134          * Clear the request canceled timer. This api will be called if the request is finished.
135          */
clearRequestCanceledTimer()136         void clearRequestCanceledTimer();
137 
138         /**
139          * Update the publish request result.
140          */
updatePublishRequestResult(int publishState, Instant updatedTimestamp, String pidfXml)141         void updatePublishRequestResult(int publishState, Instant updatedTimestamp, String pidfXml);
142 
143         /**
144          * Update the value of the publish throttle.
145          */
updatePublishThrottle(int value)146         void updatePublishThrottle(int value);
147 
148         /**
149          * Update the device state with the publish request result.
150          */
refreshDeviceState(int SipCode, String reason)151         void refreshDeviceState(int SipCode, String reason);
152 
153         /**
154          * Sent the publish request to ImsService.
155          */
notifyPendingPublishRequest()156         void notifyPendingPublishRequest();
157 
158         /**
159          * Update the Ims unregistered. This api will be called if the IMS unregistered.
160          */
updateImsUnregistered()161         void updateImsUnregistered();
162     }
163 
164     /**
165      * Add new feature tags to the Set used to calculate the capabilities in PUBLISH.
166      * <p>
167      * Used for testing ONLY.
168      * @return the new capabilities that will be used for PUBLISH.
169      */
addRegistrationOverrideCapabilities(Set<String> featureTags)170     RcsContactUceCapability addRegistrationOverrideCapabilities(Set<String> featureTags);
171 
172     /**
173      * Remove existing feature tags to the Set used to calculate the capabilities in PUBLISH.
174      * <p>
175      * Used for testing ONLY.
176      * @return the new capabilities that will be used for PUBLISH.
177      */
removeRegistrationOverrideCapabilities(Set<String> featureTags)178     RcsContactUceCapability removeRegistrationOverrideCapabilities(Set<String> featureTags);
179 
180     /**
181      * Clear all overrides in the Set used to calculate the capabilities in PUBLISH.
182      * <p>
183      * Used for testing ONLY.
184      * @return the new capabilities that will be used for PUBLISH.
185      */
clearRegistrationOverrideCapabilities()186     RcsContactUceCapability clearRegistrationOverrideCapabilities();
187 
188     /**
189      * @return latest RcsContactUceCapability instance that will be used for PUBLISH.
190      */
getLatestRcsContactUceCapability()191     RcsContactUceCapability getLatestRcsContactUceCapability();
192 
193     /**
194      * Retrieve the RCS UCE Publish state.
195      */
getUcePublishState(boolean isSupportPublishingState)196     @PublishState int getUcePublishState(boolean isSupportPublishingState);
197 
198     /**
199      * @return the last PIDF XML used for publish or {@code null} if the device is not published.
200      */
getLastPidfXml()201     String getLastPidfXml();
202 
203     /**
204      * Notify that the device's capabilities have been unpublished from the network.
205      */
onUnpublish()206     void onUnpublish();
207 
208     /**
209      * Notify that the device's publish status have been changed.
210      */
onPublishUpdated(int reasonCode, String reasonPhrase, int reasonHeaderCause, String reasonHeaderText)211     void onPublishUpdated(int reasonCode, String reasonPhrase,
212             int reasonHeaderCause, String reasonHeaderText);
213 
214     /**
215      * Retrieve the device's capabilities.
216      */
getDeviceCapabilities(@apabilityMechanism int mechanism)217     RcsContactUceCapability getDeviceCapabilities(@CapabilityMechanism int mechanism);
218 
219     /**
220      * Publish the device's capabilities to the Presence server.
221      */
requestPublishCapabilitiesFromService(int triggerType)222     void requestPublishCapabilitiesFromService(int triggerType);
223 
224     /**
225      * Register a {@link PublishStateCallback} to listen to the published state changed.
226      */
registerPublishStateCallback(@onNull IRcsUcePublishStateCallback c, boolean supportPublishingState)227     void registerPublishStateCallback(@NonNull IRcsUcePublishStateCallback c,
228             boolean supportPublishingState);
229 
230     /**
231      * Removes an existing {@link PublishStateCallback}.
232      */
unregisterPublishStateCallback(@onNull IRcsUcePublishStateCallback c)233     void unregisterPublishStateCallback(@NonNull IRcsUcePublishStateCallback c);
234 
235     /**
236      * Setup the timer to reset the device state.
237      */
setupResetDeviceStateTimer(long resetAfterSec)238     void setupResetDeviceStateTimer(long resetAfterSec);
239 
240     /**
241      * Clear the reset device state timer.
242      */
clearResetDeviceStateTimer()243     void clearResetDeviceStateTimer();
244 
245     /**
246      * Dump the state of this PublishController to the printWriter.
247      */
dump(PrintWriter printWriter)248     void dump(PrintWriter printWriter);
249 }
250