Loading api/system-current.txt +7 −0 Original line number Diff line number Diff line Loading @@ -4657,6 +4657,13 @@ package android.net.wifi { field @Deprecated public byte id; } public final class WifiClient implements android.os.Parcelable { method public int describeContents(); method @NonNull public android.net.MacAddress getMacAddress(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.net.wifi.WifiClient> CREATOR; } @Deprecated public class WifiConfiguration implements android.os.Parcelable { method @Deprecated public boolean hasNoInternetAccess(); method @Deprecated public boolean isEphemeral(); Loading packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java +13 −8 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.systemui.Dependency.MAIN_HANDLER_NAME; import android.app.ActivityManager; import android.content.Context; import android.net.ConnectivityManager; import android.net.wifi.WifiClient; import android.net.wifi.WifiManager; import android.os.Handler; import android.os.UserManager; Loading @@ -29,12 +30,14 @@ import android.util.Log; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; /** * Controller used to retrieve information related to a hotspot. */ @Singleton public class HotspotControllerImpl implements HotspotController, WifiManager.SoftApCallback { Loading @@ -49,10 +52,11 @@ public class HotspotControllerImpl implements HotspotController, WifiManager.Sof private final Context mContext; private int mHotspotState; private int mNumConnectedDevices; private volatile int mNumConnectedDevices; private boolean mWaitingForTerminalState; /** * Controller used to retrieve information related to a hotspot. */ @Inject public HotspotControllerImpl(Context context, @Named(MAIN_HANDLER_NAME) Handler mainHandler) { Loading Loading @@ -96,7 +100,6 @@ public class HotspotControllerImpl implements HotspotController, WifiManager.Sof /** * Adds {@code callback} to the controller. The controller will update the callback on state * changes. It will immediately trigger the callback added to notify current state. * @param callback */ @Override public void addCallback(Callback callback) { Loading @@ -108,11 +111,13 @@ public class HotspotControllerImpl implements HotspotController, WifiManager.Sof if (mCallbacks.size() == 1) { mWifiManager.registerSoftApCallback(this, mMainHandler); } else { // mWifiManager#registerSoftApCallback triggers a call to onNumClientsChanged // on the Main Handler. In order to always update the callback on added, we // make this call when adding callbacks after the first. // mWifiManager#registerSoftApCallback triggers a call to // onConnectedClientsChanged on the Main Handler. In order to always update // the callback on added, we make this call when adding callbacks after the // first. mMainHandler.post(() -> callback.onHotspotChanged(isHotspotEnabled(), mNumConnectedDevices)); callback.onHotspotChanged(isHotspotEnabled(), mNumConnectedDevices)); } } } Loading Loading @@ -217,8 +222,8 @@ public class HotspotControllerImpl implements HotspotController, WifiManager.Sof } @Override public void onNumClientsChanged(int numConnectedDevices) { mNumConnectedDevices = numConnectedDevices; public void onConnectedClientsChanged(List<WifiClient> clients) { mNumConnectedDevices = clients.size(); fireHotspotChangedCallback(); } } packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HotspotControllerImplTest.java +4 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,8 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.invocation.InvocationOnMock; import java.util.ArrayList; @SmallTest @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper Loading @@ -67,7 +69,8 @@ public class HotspotControllerImplTest extends SysuiTestCase { mContext.addMockSystemService(WifiManager.class, mWifiManager); doAnswer((InvocationOnMock invocation) -> { ((WifiManager.SoftApCallback) invocation.getArgument(0)).onNumClientsChanged(1); ((WifiManager.SoftApCallback) invocation.getArgument(0)) .onConnectedClientsChanged(new ArrayList<>()); return null; }).when(mWifiManager).registerSoftApCallback(any(WifiManager.SoftApCallback.class), any(Handler.class)); Loading wifi/java/android/net/wifi/ISoftApCallback.aidl +5 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.net.wifi; import android.net.wifi.WifiClient; /** * Interface for Soft AP callback. * Loading @@ -36,9 +38,9 @@ oneway interface ISoftApCallback void onStateChanged(int state, int failureReason); /** * Service to manager callback providing number of connected clients. * Service to manager callback providing connected client's information. * * @param numClients number of connected clients * @param clients the currently connected clients */ void onNumClientsChanged(int numClients); void onConnectedClientsChanged(in List<WifiClient> clients); } wifi/java/android/net/wifi/WifiClient.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.net.wifi; @JavaOnlyStableParcelable parcelable WifiClient; No newline at end of file Loading
api/system-current.txt +7 −0 Original line number Diff line number Diff line Loading @@ -4657,6 +4657,13 @@ package android.net.wifi { field @Deprecated public byte id; } public final class WifiClient implements android.os.Parcelable { method public int describeContents(); method @NonNull public android.net.MacAddress getMacAddress(); method public void writeToParcel(@NonNull android.os.Parcel, int); field @NonNull public static final android.os.Parcelable.Creator<android.net.wifi.WifiClient> CREATOR; } @Deprecated public class WifiConfiguration implements android.os.Parcelable { method @Deprecated public boolean hasNoInternetAccess(); method @Deprecated public boolean isEphemeral(); Loading
packages/SystemUI/src/com/android/systemui/statusbar/policy/HotspotControllerImpl.java +13 −8 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import static com.android.systemui.Dependency.MAIN_HANDLER_NAME; import android.app.ActivityManager; import android.content.Context; import android.net.ConnectivityManager; import android.net.wifi.WifiClient; import android.net.wifi.WifiManager; import android.os.Handler; import android.os.UserManager; Loading @@ -29,12 +30,14 @@ import android.util.Log; import java.io.FileDescriptor; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import javax.inject.Inject; import javax.inject.Named; import javax.inject.Singleton; /** * Controller used to retrieve information related to a hotspot. */ @Singleton public class HotspotControllerImpl implements HotspotController, WifiManager.SoftApCallback { Loading @@ -49,10 +52,11 @@ public class HotspotControllerImpl implements HotspotController, WifiManager.Sof private final Context mContext; private int mHotspotState; private int mNumConnectedDevices; private volatile int mNumConnectedDevices; private boolean mWaitingForTerminalState; /** * Controller used to retrieve information related to a hotspot. */ @Inject public HotspotControllerImpl(Context context, @Named(MAIN_HANDLER_NAME) Handler mainHandler) { Loading Loading @@ -96,7 +100,6 @@ public class HotspotControllerImpl implements HotspotController, WifiManager.Sof /** * Adds {@code callback} to the controller. The controller will update the callback on state * changes. It will immediately trigger the callback added to notify current state. * @param callback */ @Override public void addCallback(Callback callback) { Loading @@ -108,11 +111,13 @@ public class HotspotControllerImpl implements HotspotController, WifiManager.Sof if (mCallbacks.size() == 1) { mWifiManager.registerSoftApCallback(this, mMainHandler); } else { // mWifiManager#registerSoftApCallback triggers a call to onNumClientsChanged // on the Main Handler. In order to always update the callback on added, we // make this call when adding callbacks after the first. // mWifiManager#registerSoftApCallback triggers a call to // onConnectedClientsChanged on the Main Handler. In order to always update // the callback on added, we make this call when adding callbacks after the // first. mMainHandler.post(() -> callback.onHotspotChanged(isHotspotEnabled(), mNumConnectedDevices)); callback.onHotspotChanged(isHotspotEnabled(), mNumConnectedDevices)); } } } Loading Loading @@ -217,8 +222,8 @@ public class HotspotControllerImpl implements HotspotController, WifiManager.Sof } @Override public void onNumClientsChanged(int numConnectedDevices) { mNumConnectedDevices = numConnectedDevices; public void onConnectedClientsChanged(List<WifiClient> clients) { mNumConnectedDevices = clients.size(); fireHotspotChangedCallback(); } }
packages/SystemUI/tests/src/com/android/systemui/statusbar/policy/HotspotControllerImplTest.java +4 −1 Original line number Diff line number Diff line Loading @@ -42,6 +42,8 @@ import org.mockito.Mock; import org.mockito.MockitoAnnotations; import org.mockito.invocation.InvocationOnMock; import java.util.ArrayList; @SmallTest @RunWith(AndroidTestingRunner.class) @TestableLooper.RunWithLooper Loading @@ -67,7 +69,8 @@ public class HotspotControllerImplTest extends SysuiTestCase { mContext.addMockSystemService(WifiManager.class, mWifiManager); doAnswer((InvocationOnMock invocation) -> { ((WifiManager.SoftApCallback) invocation.getArgument(0)).onNumClientsChanged(1); ((WifiManager.SoftApCallback) invocation.getArgument(0)) .onConnectedClientsChanged(new ArrayList<>()); return null; }).when(mWifiManager).registerSoftApCallback(any(WifiManager.SoftApCallback.class), any(Handler.class)); Loading
wifi/java/android/net/wifi/ISoftApCallback.aidl +5 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.net.wifi; import android.net.wifi.WifiClient; /** * Interface for Soft AP callback. * Loading @@ -36,9 +38,9 @@ oneway interface ISoftApCallback void onStateChanged(int state, int failureReason); /** * Service to manager callback providing number of connected clients. * Service to manager callback providing connected client's information. * * @param numClients number of connected clients * @param clients the currently connected clients */ void onNumClientsChanged(int numClients); void onConnectedClientsChanged(in List<WifiClient> clients); }
wifi/java/android/net/wifi/WifiClient.aidl 0 → 100644 +19 −0 Original line number Diff line number Diff line /* * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package android.net.wifi; @JavaOnlyStableParcelable parcelable WifiClient; No newline at end of file