diff options
author | Quang Luong <qal@google.com> | 2019-12-11 16:05:13 -0800 |
---|---|---|
committer | Quang Luong <qal@google.com> | 2019-12-16 13:49:45 -0800 |
commit | 56193231e11dc363c240cf0382d1f996e066c87b (patch) | |
tree | c4fd1fdc6585388f8a8ff9d2b3126d6fefc77ea3 | |
parent | ed05e3bf5c662dcdca623ffe045d25f5864a76b5 (diff) |
Add overlooked WifiEntry APIs
Add missing getMacAddress() API as well as APIs for captive portal
sign-in and DPP sharing.
Bug: 70983952
Test: build
Change-Id: I540bb6f39f5f9f422388cb874dc6282316ca998e
-rw-r--r-- | libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java | 34 | ||||
-rw-r--r-- | libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java | 45 |
2 files changed, 76 insertions, 3 deletions
diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java index 50d4158fc..74f4bdccc 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/StandardWifiEntry.java @@ -161,6 +161,12 @@ class StandardWifiEntry extends WifiEntry { } @Override + public String getMacAddress() { + // TODO(b/70983952): Fill this method in + return null; + } + + @Override public boolean isMetered() { // TODO(b/70983952): Fill this method in return false; @@ -237,6 +243,34 @@ class StandardWifiEntry extends WifiEntry { // TODO(b/70983952): Fill this method in } + public boolean canSignIn() { + // TODO(b/70983952): Fill this method in + return false; + } + + @Override + public void signIn() { + // TODO(b/70983952): Fill this method in + } + + @Override + public boolean canShare() { + // TODO(b/70983952): Fill this method in + return false; + } + + @Override + public boolean canEasyConnect() { + // TODO(b/70983952): Fill this method in + return false; + } + + @Override + public String getQrCodeString() { + // TODO(b/70983952): Fill this method in + return null; + } + @Override public boolean canSetPassword() { // TODO(b/70983952): Fill this method in diff --git a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java index 14e40db61..29823b430 100644 --- a/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java +++ b/libs/WifiTrackerLib/src/com/android/wifitrackerlib/WifiEntry.java @@ -168,6 +168,9 @@ public abstract class WifiEntry implements Comparable<WifiEntry> { @Security public abstract int getSecurity(); + /** Returns the MAC address of the connection */ + public abstract String getMacAddress(); + /** * Indicates when a network is metered or the user marked the network as metered. */ @@ -217,6 +220,18 @@ public abstract class WifiEntry implements Comparable<WifiEntry> { /** Forgets the network */ public abstract void forget(); + /** Returns whether the network can be signed-in to */ + public abstract boolean canSignIn(); + /** Sign-in to the network. For captive portals. */ + public abstract void signIn(); + + /** Returns whether the network can be shared via QR code */ + public abstract boolean canShare(); + /** Returns whether the user can use Easy Connect to onboard a device to the network */ + public abstract boolean canEasyConnect(); + /** Returns the QR code string for the network */ + public abstract String getQrCodeString(); + // Modifiable settings /** Returns whether the entry should show a password input */ @@ -364,6 +379,17 @@ public abstract class WifiEntry implements Comparable<WifiEntry> { int FORGET_STATUS_SUCCESS = 0; int FORGET_STATUS_FAILURE_UNKNOWN = 1; + @Retention(RetentionPolicy.SOURCE) + @IntDef(value = { + SIGNIN_STATUS_SUCCESS, + SIGNIN_STATUS_FAILURE_UNKNOWN + }) + + public @interface SignInStatus {} + + int SIGNIN_STATUS_SUCCESS = 0; + int SIGNIN_STATUS_FAILURE_UNKNOWN = 1; + /** * Indicates the state of the WifiEntry has changed and clients may retrieve updates through * the WifiEntry getter methods. @@ -388,6 +414,12 @@ public abstract class WifiEntry implements Comparable<WifiEntry> { */ @MainThread void onForgetResult(@ForgetStatus int status); + + /** + * Result of the sign-in request indicated by the SIGNIN_STATUS constants. + */ + @MainThread + void onSignInResult(@SignInStatus int status); } // TODO (b/70983952) Come up with a sorting scheme that does the right thing. @@ -438,26 +470,33 @@ public abstract class WifiEntry implements Comparable<WifiEntry> { } @AnyThread - protected void notifyOnConnectResult(int status) { + protected void notifyOnConnectResult(@WifiEntryCallback.ConnectStatus int status) { if (mListener != null) { mCallbackHandler.post(() -> mListener.onConnectResult(status)); } } @AnyThread - protected void notifyOnDisconnectResult(int status) { + protected void notifyOnDisconnectResult(@WifiEntryCallback.DisconnectStatus int status) { if (mListener != null) { mCallbackHandler.post(() -> mListener.onDisconnectResult(status)); } } @AnyThread - protected void notifyOnForgetResult(int status) { + protected void notifyOnForgetResult(@WifiEntryCallback.ForgetStatus int status) { if (mListener != null) { mCallbackHandler.post(() -> mListener.onForgetResult(status)); } } + @AnyThread + protected void notifyOnSignInResult(@WifiEntryCallback.SignInStatus int status) { + if (mListener != null) { + mCallbackHandler.post(() -> mListener.onSignInResult(status)); + } + } + class ConnectListener implements WifiManager.ActionListener { @Override public void onSuccess() { |