Browse Source

WifiManager: Add StaState API

- Reversed out from miui_BEGONIAININGlobal_V11.0.2.0.QGGINXM_7e11a54a70_10.0

Change-Id: I7309906d775f45c7ea42b3324679a0f7b776a1c9
ten
Kshitij Gupta 1 year ago
parent
commit
ab385d4994

+ 1
- 0
Android.bp View File

@@ -642,6 +642,7 @@ java_defaults {
"wifi/java/android/net/wifi/INetworkRequestMatchCallback.aidl",
"wifi/java/android/net/wifi/INetworkRequestUserSelectionCallback.aidl",
"wifi/java/android/net/wifi/ISoftApCallback.aidl",
"wifi/java/android/net/wifi/IStaStateCallback.aidl",
"wifi/java/android/net/wifi/ITrafficStateCallback.aidl",
"wifi/java/android/net/wifi/IWifiManager.aidl",
"wifi/java/android/net/wifi/IOnWifiUsabilityStatsListener.aidl",

+ 28
- 0
wifi/java/android/net/wifi/IStaStateCallback.aidl View File

@@ -0,0 +1,28 @@
/*
* Copyright (C) 2020 The Potato Open Sauce 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;

/**
* @hide
*/
oneway interface IStaStateCallback
{
/**
* @hide
*/
void onStaToBeOff();
}

+ 5
- 0
wifi/java/android/net/wifi/IWifiManager.aidl View File

@@ -27,6 +27,7 @@ import android.net.Network;
import android.net.wifi.IDppCallback;
import android.net.wifi.INetworkRequestMatchCallback;
import android.net.wifi.ISoftApCallback;
import android.net.wifi.IStaStateCallback;
import android.net.wifi.ITrafficStateCallback;
import android.net.wifi.IOnWifiUsabilityStatsListener;
import android.net.wifi.PasspointManagementObjectDefinition;
@@ -219,4 +220,8 @@ interface IWifiManager
void stopDppSession();

void updateWifiUsabilityScore(int seqNum, int score, int predictionHorizonSec);

void registerStaStateCallback(in IBinder binder, in IStaStateCallback callback, int callbackIdentifier);

void unregisterStaStateCallback(int callbackIdentifier);
}

+ 65
- 0
wifi/java/android/net/wifi/WifiManager.java View File

@@ -4553,6 +4553,71 @@ public class WifiManager {
}

/**
* @hide
*/
public interface StaStateCallback {
/**
* @hide
*/
void onStaToBeOff();
}

/**
* @hide
*/
private class StaStateCallbackProxy extends IStaStateCallback.Stub {
private final Handler mHandler;
private final StaStateCallback mCallback;

StaStateCallbackProxy(Looper looper, StaStateCallback callback) {
mHandler = new Handler(looper);
mCallback = callback;
}

@Override
public void onStaToBeOff() {
if (mVerboseLoggingEnabled) {
Log.v(TAG, "StaStateCallbackProxy: onStaToBeOff");
}
mHandler.post(() -> {
mCallback.onStaToBeOff();
});
}
}

/**
* @hide
*/
public void registerStaStateCallback(@NonNull StaStateCallback callback,
@Nullable Handler handler) {
if (callback == null) throw new IllegalArgumentException("callback cannot be null");
Log.v(TAG, "registerStaStateCallback: callback=" + callback + ", handler=" + handler);

Looper looper = (handler == null) ? mContext.getMainLooper() : handler.getLooper();
Binder binder = new Binder();
try {
mService.registerStaStateCallback(
binder, new StaStateCallbackProxy(looper, callback), callback.hashCode());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}

/**
* @hide
*/
public void unregisterStaStateCallback(@NonNull StaStateCallback callback) {
if (callback == null) throw new IllegalArgumentException("callback cannot be null");
Log.v(TAG, "unregisterStaStateCallback: callback=" + callback);

try {
mService.unregisterStaStateCallback(callback.hashCode());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
}

/**
* Helper method to update the local verbose logging flag based on the verbose logging
* level from wifi service.
*/

+ 12
- 0
wifi/java/com/android/server/wifi/BaseWifiService.java View File

@@ -25,6 +25,7 @@ import android.net.wifi.IDppCallback;
import android.net.wifi.INetworkRequestMatchCallback;
import android.net.wifi.IOnWifiUsabilityStatsListener;
import android.net.wifi.ISoftApCallback;
import android.net.wifi.IStaStateCallback;
import android.net.wifi.ITrafficStateCallback;
import android.net.wifi.IWifiManager;
import android.net.wifi.ScanResult;
@@ -481,4 +482,15 @@ public class BaseWifiService extends IWifiManager.Stub {
public void updateWifiUsabilityScore(int seqNum, int score, int predictionHorizonSec) {
throw new UnsupportedOperationException();
}

@Override
public void registerStaStateCallback(
IBinder binder, IStaStateCallback callback, int callbackIdentifier) {
throw new UnsupportedOperationException();
}

@Override
public void unregisterStaStateCallback(int callbackIdentifier) {
throw new UnsupportedOperationException();
}
}

Loading…
Cancel
Save