• 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.imsserviceentitlement.entitlement;
18 
19 import com.android.imsserviceentitlement.ts43.Ts43SmsOverIpStatus;
20 import com.android.imsserviceentitlement.ts43.Ts43VolteStatus;
21 import com.android.imsserviceentitlement.ts43.Ts43VowifiStatus;
22 
23 import com.google.auto.value.AutoValue;
24 
25 /** The result of the entitlement status check. */
26 @AutoValue
27 public abstract class EntitlementResult {
28     private static final Ts43VowifiStatus INACTIVE_VOWIFI_STATUS =
29             Ts43VowifiStatus.builder()
30                     .setEntitlementStatus(Ts43VowifiStatus.EntitlementStatus.INCOMPATIBLE)
31                     .setTcStatus(Ts43VowifiStatus.TcStatus.NOT_AVAILABLE)
32                     .setAddrStatus(Ts43VowifiStatus.AddrStatus.NOT_AVAILABLE)
33                     .setProvStatus(Ts43VowifiStatus.ProvStatus.NOT_PROVISIONED)
34                     .build();
35 
36     private static final Ts43VolteStatus INACTIVE_VOLTE_STATUS =
37             Ts43VolteStatus.builder()
38                     .setEntitlementStatus(Ts43VolteStatus.EntitlementStatus.INCOMPATIBLE)
39                     .build();
40 
41     private static final Ts43SmsOverIpStatus INACTIVE_SMSOVERIP_STATUS =
42             Ts43SmsOverIpStatus.builder()
43                     .setEntitlementStatus(Ts43SmsOverIpStatus.EntitlementStatus.INCOMPATIBLE)
44                     .build();
45 
46     /** Returns a new {@link Builder} object. */
builder()47     public static Builder builder() {
48         return new AutoValue_EntitlementResult.Builder()
49                 .setVowifiStatus(INACTIVE_VOWIFI_STATUS)
50                 .setVolteStatus(INACTIVE_VOLTE_STATUS)
51                 .setSmsoveripStatus(INACTIVE_SMSOVERIP_STATUS)
52                 .setEmergencyAddressWebUrl("")
53                 .setEmergencyAddressWebData("")
54                 .setTermsAndConditionsWebUrl("")
55                 .setRetryAfterSeconds(-1);
56     }
57 
58     /** The entitlement and service status of VoWiFi. */
getVowifiStatus()59     public abstract Ts43VowifiStatus getVowifiStatus();
60     /** The entitlement and service status of VoLTE. */
getVolteStatus()61     public abstract Ts43VolteStatus getVolteStatus();
62     /** The entitlement and service status of SMSoIP. */
getSmsoveripStatus()63     public abstract Ts43SmsOverIpStatus getSmsoveripStatus();
64     /** The URL to the WFC emergency address web form. */
getEmergencyAddressWebUrl()65     public abstract String getEmergencyAddressWebUrl();
66     /** The data associated with the POST request to the WFC emergency address web form. */
getEmergencyAddressWebData()67     public abstract String getEmergencyAddressWebData();
68     /** The URL to the WFC T&C web form. */
getTermsAndConditionsWebUrl()69     public abstract String getTermsAndConditionsWebUrl();
70     /** Service temporary unavailable, retry the status check after a delay in seconds. */
getRetryAfterSeconds()71     public abstract long getRetryAfterSeconds();
72 
73     /** Builder of {@link EntitlementResult}. */
74     @AutoValue.Builder
75     public abstract static class Builder {
build()76         public abstract EntitlementResult build();
setVowifiStatus(Ts43VowifiStatus vowifiStatus)77         public abstract Builder setVowifiStatus(Ts43VowifiStatus vowifiStatus);
setVolteStatus(Ts43VolteStatus volteStatus)78         public abstract Builder setVolteStatus(Ts43VolteStatus volteStatus);
setSmsoveripStatus(Ts43SmsOverIpStatus smsoveripStatus)79         public abstract Builder setSmsoveripStatus(Ts43SmsOverIpStatus smsoveripStatus);
setEmergencyAddressWebUrl(String emergencyAddressWebUrl)80         public abstract Builder setEmergencyAddressWebUrl(String emergencyAddressWebUrl);
setEmergencyAddressWebData(String emergencyAddressWebData)81         public abstract Builder setEmergencyAddressWebData(String emergencyAddressWebData);
setTermsAndConditionsWebUrl(String termsAndConditionsWebUrl)82         public abstract Builder setTermsAndConditionsWebUrl(String termsAndConditionsWebUrl);
setRetryAfterSeconds(long retryAfter)83         public abstract Builder setRetryAfterSeconds(long retryAfter);
84     }
85 
86     @Override
toString()87     public final String toString() {
88         StringBuilder builder = new StringBuilder("EntitlementResult{");
89         builder.append(",getVowifiStatus=").append(getVowifiStatus());
90         builder.append(",getVolteStatus=").append(getVolteStatus());
91         builder.append(",getSmsoveripStatus=").append(getSmsoveripStatus());
92         builder.append(",getEmergencyAddressWebUrl=").append(opaque(getEmergencyAddressWebUrl()));
93         builder.append(",getEmergencyAddressWebData=").append(opaque(getEmergencyAddressWebData()));
94         builder.append(",getTermsAndConditionsWebUrl=").append(getTermsAndConditionsWebUrl());
95         builder.append(",getRetryAfter=").append(getRetryAfterSeconds());
96         builder.append("}");
97         return builder.toString();
98     }
99 
opaque(String string)100     private static String opaque(String string) {
101         if (string == null) {
102             return "null";
103         }
104         return "string_of_length_" + string.length();
105     }
106 }
107