Skip to content
This repository has been archived by the owner on Apr 10, 2024. It is now read-only.

Commit

Permalink
WifiManager: Add StaState API
Browse files Browse the repository at this point in the history
- Reversed out from miui_BEGONIAININGlobal_V11.0.2.0.QGGINXM_7e11a54a70_10.0

Change-Id: I7309906d775f45c7ea42b3324679a0f7b776a1c9
  • Loading branch information
AgentFabulous authored and ZIDAN44 committed Nov 22, 2020
1 parent 1e5e19a commit 37f5a32
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 0 deletions.
28 changes: 28 additions & 0 deletions wifi/java/android/net/wifi/IStaStateCallback.aidl
Original file line number Diff line number Diff line change
@@ -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 changes: 5 additions & 0 deletions wifi/java/android/net/wifi/IWifiManager.aidl
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import android.net.wifi.IOnWifiUsabilityStatsListener;
import android.net.wifi.IScanResultsCallback;
import android.net.wifi.ISoftApCallback;
import android.net.wifi.ISuggestionConnectionStatusListener;
import android.net.wifi.IStaStateCallback;
import android.net.wifi.ITrafficStateCallback;
import android.net.wifi.IWifiConnectedNetworkScorer;
import android.net.wifi.ScanResult;
Expand Down Expand Up @@ -275,4 +276,8 @@ interface IWifiManager
void setAutoWakeupEnabled(boolean enable);

boolean isAutoWakeupEnabled();

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

void unregisterStaStateCallback(int callbackIdentifier);
}
65 changes: 65 additions & 0 deletions wifi/java/android/net/wifi/WifiManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -5270,6 +5270,71 @@ public void unregisterTrafficStateCallback(@NonNull TrafficStateCallback callbac
}
}

/**
* @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.
Expand Down

0 comments on commit 37f5a32

Please sign in to comment.