1 /* 2 * Copyright (C) 2022 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.server.connectivity; 18 19 import android.annotation.NonNull; 20 import android.annotation.Nullable; 21 import android.net.NetworkCapabilities; 22 import android.os.UserHandle; 23 24 /** 25 * A single profile preference, as it applies to a given user profile. 26 */ 27 public class ProfileNetworkPreferenceInfo 28 implements NetworkPreferenceList.NetworkPreference<UserHandle> { 29 @NonNull 30 public final UserHandle user; 31 // Capabilities are only null when sending an object to remove the setting for a user 32 @Nullable 33 public final NetworkCapabilities capabilities; 34 public final boolean allowFallback; 35 public final boolean blockingNonEnterprise; 36 ProfileNetworkPreferenceInfo(@onNull final UserHandle user, @Nullable final NetworkCapabilities capabilities, final boolean allowFallback, final boolean blockingNonEnterprise)37 public ProfileNetworkPreferenceInfo(@NonNull final UserHandle user, 38 @Nullable final NetworkCapabilities capabilities, 39 final boolean allowFallback, final boolean blockingNonEnterprise) { 40 this.user = user; 41 this.capabilities = null == capabilities ? null : new NetworkCapabilities(capabilities); 42 this.allowFallback = allowFallback; 43 this.blockingNonEnterprise = blockingNonEnterprise; 44 } 45 46 @Override isCancel()47 public boolean isCancel() { 48 return null == capabilities; 49 } 50 51 @Override 52 @NonNull getKey()53 public UserHandle getKey() { 54 return user; 55 } 56 57 /** toString */ toString()58 public String toString() { 59 return "[ProfileNetworkPreference user=" + user 60 + " caps=" + capabilities 61 + " allowFallback=" + allowFallback 62 + " blockingNonEnterprise=" + blockingNonEnterprise 63 + "]"; 64 } 65 } 66