• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2023 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.internal.telephony.satellite;
18 
19 import android.annotation.NonNull;
20 import android.telephony.NetworkRegistrationInfo;
21 import android.telephony.Rlog;
22 import android.text.TextUtils;
23 
24 import java.util.List;
25 
26 /**
27  * This utility class is responsible for resolving NTN capabilities of a
28  * {@link NetworkRegistrationInfo}.
29  */
30 public class NtnCapabilityResolver {
31     private static final String TAG = "NtnCapabilityResolver";
32 
33     /**
34      * Resolve NTN capability by updating the input NetworkRegistrationInfo to indicate whether
35      * connecting to a non-terrestrial network and the available services supported by the network.
36      *
37      * @param networkRegistrationInfo The NetworkRegistrationInfo of a network.
38      * @param subId The subscription ID associated with a phone.
39      */
resolveNtnCapability( @onNull NetworkRegistrationInfo networkRegistrationInfo, int subId)40     public static void resolveNtnCapability(
41             @NonNull NetworkRegistrationInfo networkRegistrationInfo, int subId) {
42         SatelliteController satelliteController = SatelliteController.getInstance();
43         List<String> satellitePlmnList = satelliteController.getSatellitePlmnList();
44         String registeredPlmn = networkRegistrationInfo.getRegisteredPlmn();
45         for (String satellitePlmn : satellitePlmnList) {
46             if (TextUtils.equals(satellitePlmn, registeredPlmn)) {
47                 logd("Registered to satellite PLMN " + satellitePlmn);
48                 networkRegistrationInfo.setIsNonTerrestrialNetwork(true);
49                 networkRegistrationInfo.setAvailableServices(
50                         satelliteController.getSupportedSatelliteServices(subId, satellitePlmn));
51                 break;
52             }
53         }
54     }
55 
logd(@onNull String log)56     private static void logd(@NonNull String log) {
57         Rlog.d(TAG, log);
58     }
59 }
60