1 /* 2 * Copyright (C) 2024 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.phone.satellite.entitlement; 18 19 import android.annotation.IntDef; 20 21 import com.android.internal.telephony.satellite.SatelliteNetworkInfo; 22 23 import java.util.ArrayList; 24 import java.util.List; 25 import java.util.stream.Collectors; 26 27 /** 28 * This class stores the result of the satellite entitlement query and passes them to 29 * SatelliteEntitlementController. 30 */ 31 public class SatelliteEntitlementResult { 32 /** SatMode allowed, but not yet provisioned and activated on the network. */ 33 public static final int SATELLITE_ENTITLEMENT_STATUS_DISABLED = 0; 34 /** SatMode service allowed, provisioned and activated on the network. User can access the 35 * satellite service. */ 36 public static final int SATELLITE_ENTITLEMENT_STATUS_ENABLED = 1; 37 /** SatMode cannot be offered for network or device. */ 38 public static final int SATELLITE_ENTITLEMENT_STATUS_INCOMPATIBLE = 2; 39 /** SatMode is being provisioned on the network. Not yet activated. */ 40 public static final int SATELLITE_ENTITLEMENT_STATUS_PROVISIONING = 3; 41 42 @IntDef(prefix = {"SATELLITE_ENTITLEMENT_STATUS_"}, value = { 43 SATELLITE_ENTITLEMENT_STATUS_DISABLED, 44 SATELLITE_ENTITLEMENT_STATUS_ENABLED, 45 SATELLITE_ENTITLEMENT_STATUS_INCOMPATIBLE, 46 SATELLITE_ENTITLEMENT_STATUS_PROVISIONING 47 }) 48 public @interface SatelliteEntitlementStatus {} 49 50 private @SatelliteEntitlementStatus int mEntitlementStatus; 51 /** 52 * An SatelliteNetworkInfo list consisting of the PLMN and the DataPlanType in the PLMNAlowed 53 * item of the satellite configuration received from the entitlement server. 54 */ 55 private List<SatelliteNetworkInfo> mAllowedSatelliteNetworkInfoList; 56 /** 57 * List consisting of the PLMN in the PLMNBarred item of the satellite configuration received 58 * from the entitlement server 59 */ 60 private List<String> mBarredPlmnList; 61 62 /** 63 * Store the result of the satellite entitlement response. 64 * 65 * @param entitlementStatus The entitlement status. 66 * @param allowedSatelliteNetworkInfoList The allowedSatelliteNetworkInfoList 67 * @param barredPlmnList The barred plmn list 68 */ SatelliteEntitlementResult(@atelliteEntitlementStatus int entitlementStatus, List<SatelliteNetworkInfo> allowedSatelliteNetworkInfoList, List<String> barredPlmnList)69 public SatelliteEntitlementResult(@SatelliteEntitlementStatus int entitlementStatus, 70 List<SatelliteNetworkInfo> allowedSatelliteNetworkInfoList, 71 List<String> barredPlmnList) { 72 mEntitlementStatus = entitlementStatus; 73 mAllowedSatelliteNetworkInfoList = allowedSatelliteNetworkInfoList; 74 mBarredPlmnList = barredPlmnList; 75 } 76 77 /** 78 * Get the entitlement status. 79 * 80 * @return The entitlement status. 81 */ getEntitlementStatus()82 public @SatelliteEntitlementStatus int getEntitlementStatus() { 83 return mEntitlementStatus; 84 } 85 86 /** 87 * Get the plmn allowed list 88 * 89 * @return The plmn allowed list. 90 */ getAllowedPLMNList()91 public List<String> getAllowedPLMNList() { 92 return mAllowedSatelliteNetworkInfoList.stream().map(info -> info.mPlmn).collect( 93 Collectors.toList()); 94 } 95 96 /** 97 * Get the plmn barred list 98 * 99 * @return The plmn barred list. 100 */ getBarredPLMNList()101 public List<String> getBarredPLMNList() { 102 return mBarredPlmnList.stream().map(String::new).collect(Collectors.toList()); 103 } 104 105 /** 106 * Get the default SatelliteEntitlementResult. EntitlementStatus set to 107 * `SATELLITE_ENTITLEMENT_STATUS_DISABLED` and SatelliteNetworkInfo list set to empty. 108 * 109 * @return If there is no response, return default SatelliteEntitlementResult 110 */ getDefaultResult()111 public static SatelliteEntitlementResult getDefaultResult() { 112 return new SatelliteEntitlementResult(SATELLITE_ENTITLEMENT_STATUS_DISABLED, 113 new ArrayList<>(), new ArrayList<>()); 114 } 115 } 116