• 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.ts43;
18 
19 import com.android.imsserviceentitlement.ts43.Ts43Constants.ResponseXmlAttributes;
20 import com.android.imsserviceentitlement.ts43.Ts43Constants.ResponseXmlNode;
21 import com.android.imsserviceentitlement.utils.XmlDoc;
22 import com.android.libraries.entitlement.ServiceEntitlement;
23 
24 import com.google.auto.value.AutoValue;
25 
26 /**
27  * Implementation of Volte entitlement status and server data availability for TS.43 entitlement
28  * solution. This class is only used to report the entitlement status of Volte.
29  */
30 @AutoValue
31 public abstract class Ts43VolteStatus {
32     /** The entitlement status of Volte service. */
33     public static class EntitlementStatus {
EntitlementStatus()34         public EntitlementStatus() {}
35 
36         public static final int DISABLED = 0;
37         public static final int ENABLED = 1;
38         public static final int INCOMPATIBLE = 2;
39         public static final int PROVISIONING = 3;
40     }
41 
42     /** The entitlement status of Volte service. */
entitlementStatus()43     public abstract int entitlementStatus();
44 
builder()45     public static Ts43VolteStatus.Builder builder() {
46         return new AutoValue_Ts43VolteStatus.Builder()
47                 .setEntitlementStatus(EntitlementStatus.DISABLED);
48     }
49 
builder(XmlDoc doc)50     public static Ts43VolteStatus.Builder builder(XmlDoc doc) {
51         return builder()
52                 .setEntitlementStatus(
53                         doc.get(ResponseXmlNode.APPLICATION,
54                                 ResponseXmlAttributes.ENTITLEMENT_STATUS,
55                                 ServiceEntitlement.APP_VOLTE)
56                                 .map(status -> Integer.parseInt(status))
57                                 .orElse(EntitlementStatus.INCOMPATIBLE));
58     }
59 
60     /** Builder of {@link Ts43VolteStatus}. */
61     @AutoValue.Builder
62     public abstract static class Builder {
build()63         public abstract Ts43VolteStatus build();
64 
setEntitlementStatus(int entitlementStatus)65         public abstract Builder setEntitlementStatus(int entitlementStatus);
66     }
67 
isActive()68     public boolean isActive() {
69         return entitlementStatus() == EntitlementStatus.ENABLED;
70     }
71 
toString()72     public final String toString() {
73         return "Ts43VolteStatus {"
74                 + "entitlementStatus="
75                 + entitlementStatus()
76                 + "}";
77     }
78 }
79