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 String registeredPlmn = networkRegistrationInfo.getRegisteredPlmn(); 43 if (TextUtils.isEmpty(registeredPlmn)) { 44 return; 45 } 46 47 SatelliteController satelliteController = SatelliteController.getInstance(); 48 List<String> satellitePlmnList = satelliteController.getSatellitePlmnsForCarrier(subId); 49 for (String satellitePlmn : satellitePlmnList) { 50 if (TextUtils.equals(satellitePlmn, registeredPlmn) 51 && networkRegistrationInfo.isInService()) { 52 logd("Registered to satellite PLMN " + satellitePlmn); 53 networkRegistrationInfo.setIsNonTerrestrialNetwork(true); 54 networkRegistrationInfo.setAvailableServices( 55 satelliteController.getSupportedSatelliteServices(subId, satellitePlmn)); 56 break; 57 } 58 } 59 } 60 logd(@onNull String log)61 private static void logd(@NonNull String log) { 62 Rlog.d(TAG, log); 63 } 64 } 65