1 /* 2 * Copyright (C) 2018 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.ons; 18 19 import android.telephony.AvailableNetworkInfo; 20 import android.telephony.SubscriptionManager; 21 22 import com.android.internal.telephony.IUpdateAvailableNetworksCallback; 23 24 import java.util.ArrayList; 25 import java.util.List; 26 27 /** 28 * OpportunisticNetworkService implements ions. 29 * It scans network and matches the results with opportunistic subscriptions. 30 * Use the same to provide user opportunistic data in areas with corresponding networks 31 */ 32 public class ONSConfigInput { 33 private static final String TAG = "ONSConfigInput"; 34 private static final boolean DBG = true; 35 private ArrayList<AvailableNetworkInfo> mAvailableNetworkInfos; 36 private int mPreferredDataSub; 37 private int mPrimarySub; 38 private IUpdateAvailableNetworksCallback mAvailableNetworkCallback; 39 ONSConfigInput(ArrayList<AvailableNetworkInfo> availableNetworkInfos, IUpdateAvailableNetworksCallback callback)40 ONSConfigInput(ArrayList<AvailableNetworkInfo> availableNetworkInfos, 41 IUpdateAvailableNetworksCallback callback) { 42 mAvailableNetworkInfos = availableNetworkInfos; 43 mPreferredDataSub = SubscriptionManager.INVALID_SUBSCRIPTION_ID; 44 mPrimarySub = SubscriptionManager.INVALID_SUBSCRIPTION_ID; 45 mAvailableNetworkCallback = callback; 46 } 47 getAvailableNetworkCallback()48 public IUpdateAvailableNetworksCallback getAvailableNetworkCallback() { 49 return mAvailableNetworkCallback; 50 } 51 setAvailableNetworkInfo(ArrayList<AvailableNetworkInfo> availableNetworkInfos)52 public void setAvailableNetworkInfo(ArrayList<AvailableNetworkInfo> availableNetworkInfos) { 53 mAvailableNetworkInfos = availableNetworkInfos; 54 } 55 setPreferredDataSub(int preferredDataSub)56 public void setPreferredDataSub(int preferredDataSub) { 57 mPreferredDataSub = preferredDataSub; 58 } 59 getPreferredDataSub()60 public int getPreferredDataSub() { 61 return mPreferredDataSub; 62 } 63 setPrimarySub(int primarySub)64 public void setPrimarySub(int primarySub) { 65 mPrimarySub = primarySub; 66 } 67 getPrimarySub()68 public int getPrimarySub() { 69 return mPrimarySub; 70 } 71 getAvailableNetworkInfos()72 public ArrayList<AvailableNetworkInfo> getAvailableNetworkInfos() { 73 return mAvailableNetworkInfos; 74 } 75 76 @Override toString()77 public String toString() { 78 return ("ONSConfigInput:" 79 + " " + mAvailableNetworkInfos 80 + " " + mPreferredDataSub); 81 } 82 } 83