1 /* 2 * Copyright (C) 2019 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.networkstack.apishim.common; 18 19 import android.net.INetworkMonitorCallbacks; 20 import android.net.Uri; 21 import android.os.RemoteException; 22 23 import androidx.annotation.NonNull; 24 25 /** 26 * Compatibility interface for {@link android.net.CaptivePortalData}. 27 */ 28 public interface CaptivePortalDataShim { 29 /** 30 * @see android.net.CaptivePortalData#isCaptive() 31 */ isCaptive()32 boolean isCaptive(); 33 34 /** 35 * @see android.net.CaptivePortalData#getByteLimit() 36 */ getByteLimit()37 long getByteLimit(); 38 39 /** 40 * @see android.net.CaptivePortalData#getExpiryTimeMillis() 41 */ getExpiryTimeMillis()42 long getExpiryTimeMillis(); 43 44 /** 45 * @see android.net.CaptivePortalData#getUserPortalUrl() 46 */ getUserPortalUrl()47 Uri getUserPortalUrl(); 48 49 /** 50 * @see android.net.CaptivePortalData#getVenueInfoUrl() 51 */ getVenueInfoUrl()52 Uri getVenueInfoUrl(); 53 54 /** 55 * @see CaptivePortalData#getVenueFriendlyName() 56 */ getVenueFriendlyName()57 CharSequence getVenueFriendlyName(); 58 59 /** 60 * @see CaptivePortalData#getUserPortalUrlSource() 61 */ getUserPortalUrlSource()62 int getUserPortalUrlSource(); 63 64 /** 65 * @see INetworkMonitorCallbacks#notifyCaptivePortalDataChanged(android.net.CaptivePortalData) 66 */ notifyChanged(INetworkMonitorCallbacks cb)67 void notifyChanged(INetworkMonitorCallbacks cb) throws RemoteException; 68 69 /** 70 * Generate a {@link CaptivePortalData} object with a friendly name set 71 * 72 * @param friendlyName The friendly name to set 73 * @throws UnsupportedApiLevelException when used with API level lower than 31 74 * @return a {@link CaptivePortalData} object with a friendly name set 75 */ withVenueFriendlyName(@onNull String friendlyName)76 CaptivePortalDataShim withVenueFriendlyName(@NonNull String friendlyName) 77 throws UnsupportedApiLevelException; 78 79 /** 80 * Generate a {@link CaptivePortalData} object with a friendly name and Passpoint external URLs 81 * set 82 * 83 * @param friendlyName The friendly name to set 84 * @param venueInfoUrl Venue information URL 85 * @param termsAndConditionsUrl Terms and conditions URL 86 * 87 * @throws UnsupportedApiLevelException when used with API level lower than 31 88 * @return a {@link CaptivePortalData} object with friendly name, venue info URL and terms 89 * and conditions URL set 90 */ withPasspointInfo(@onNull String friendlyName, @NonNull Uri venueInfoUrl, @NonNull Uri termsAndConditionsUrl)91 CaptivePortalDataShim withPasspointInfo(@NonNull String friendlyName, 92 @NonNull Uri venueInfoUrl, @NonNull Uri termsAndConditionsUrl) 93 throws UnsupportedApiLevelException; 94 } 95