• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2010 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.wifi;
18 
19 import static android.net.wifi.WifiConfiguration.INVALID_NETWORK_ID;
20 
21 import java.util.Objects;
22 
23 public class NetworkUpdateResult {
24     private final int mNetId;
25     private final boolean mIpChanged;
26     private final boolean mProxyChanged;
27     private final boolean mCredentialChanged;
28     private final boolean mIsNewNetwork;
29 
NetworkUpdateResult(int netId)30     public NetworkUpdateResult(int netId) {
31         this(netId, false, false, false, false);
32     }
33 
NetworkUpdateResult( int netId, boolean ip, boolean proxy, boolean credential, boolean isNewNetwork)34     public NetworkUpdateResult(
35             int netId,
36             boolean ip,
37             boolean proxy,
38             boolean credential,
39             boolean isNewNetwork) {
40         mNetId = netId;
41         mIpChanged = ip;
42         mProxyChanged = proxy;
43         mCredentialChanged = credential;
44         mIsNewNetwork = isNewNetwork;
45     }
46 
47     /** Make an instance of NetworkUpdateResult whose {@link #isSuccess()} method returns false. */
makeFailed()48     public static NetworkUpdateResult makeFailed() {
49         return new NetworkUpdateResult(INVALID_NETWORK_ID);
50     }
51 
getNetworkId()52     public int getNetworkId() {
53         return mNetId;
54     }
55 
hasIpChanged()56     public boolean hasIpChanged() {
57         return mIpChanged;
58     }
59 
hasProxyChanged()60     public boolean hasProxyChanged() {
61         return mProxyChanged;
62     }
63 
hasCredentialChanged()64     public boolean hasCredentialChanged() {
65         return mCredentialChanged;
66     }
67 
isNewNetwork()68     public boolean isNewNetwork() {
69         return mIsNewNetwork;
70     }
71 
isSuccess()72     public boolean isSuccess() {
73         return mNetId != INVALID_NETWORK_ID;
74     }
75 
76     @Override
equals(Object o)77     public boolean equals(Object o) {
78         if (this == o) return true;
79         if (o == null || getClass() != o.getClass()) return false;
80         NetworkUpdateResult that = (NetworkUpdateResult) o;
81         return mNetId == that.mNetId
82                 && mIpChanged == that.mIpChanged
83                 && mProxyChanged == that.mProxyChanged
84                 && mCredentialChanged == that.mCredentialChanged
85                 && mIsNewNetwork == that.mIsNewNetwork;
86     }
87 
88     @Override
hashCode()89     public int hashCode() {
90         return Objects.hash(mNetId, mIpChanged, mProxyChanged, mCredentialChanged, mIsNewNetwork);
91     }
92 
93     @Override
toString()94     public String toString() {
95         return "NetworkUpdateResult{"
96                 + "mNetId=" + mNetId
97                 + ", mIpChanged=" + mIpChanged
98                 + ", mProxyChanged=" + mProxyChanged
99                 + ", mCredentialChanged=" + mCredentialChanged
100                 + ", mIsNewNetwork=" + mIsNewNetwork
101                 + '}';
102     }
103 }
104