Skip to content

Commit 24c0306

Browse files
AgentFabulousGenkzsz11
authored andcommitted
WifiManager: Add StaState API [1/2]
Wifi stastate callback functions are refrenced by mediatek ims blobs when they init to register ims-service. test: IMS services (voLTE and voWIFI) works fine on mtk67xx (begonia) and crashes due to missing stastate callback functions is no more. - Reversed out from miui_BEGONIAININGlobal_V11.0.2.0.QGGINXM_7e11a54a70_10.0 Change-Id: I7309906d775f45c7ea42b3324679a0f7b776a1c9
1 parent 7a85b18 commit 24c0306

3 files changed

Lines changed: 98 additions & 0 deletions

File tree

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/*
2+
* Copyright (C) 2020 The Potato Open Sauce 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 android.net.wifi;
18+
19+
/**
20+
* @hide
21+
*/
22+
oneway interface IStaStateCallback
23+
{
24+
/**
25+
* @hide
26+
*/
27+
void onStaToBeOff();
28+
}

wifi/java/android/net/wifi/IWifiManager.aidl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ import android.net.wifi.IOnWifiUsabilityStatsListener;
3333
import android.net.wifi.IScanResultsCallback;
3434
import android.net.wifi.ISoftApCallback;
3535
import android.net.wifi.ISuggestionConnectionStatusListener;
36+
import android.net.wifi.IStaStateCallback;
3637
import android.net.wifi.ITrafficStateCallback;
3738
import android.net.wifi.IWifiConnectedNetworkScorer;
3839
import android.net.wifi.ScanResult;
@@ -275,4 +276,8 @@ interface IWifiManager
275276
void setAutoWakeupEnabled(boolean enable);
276277

277278
boolean isAutoWakeupEnabled();
279+
280+
void registerStaStateCallback(in IBinder binder, in IStaStateCallback callback, int callbackIdentifier);
281+
282+
void unregisterStaStateCallback(int callbackIdentifier);
278283
}

wifi/java/android/net/wifi/WifiManager.java

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5274,6 +5274,71 @@ public void unregisterTrafficStateCallback(@NonNull TrafficStateCallback callbac
52745274
}
52755275
}
52765276

5277+
/**
5278+
* @hide
5279+
*/
5280+
public interface StaStateCallback {
5281+
/**
5282+
* @hide
5283+
*/
5284+
void onStaToBeOff();
5285+
}
5286+
5287+
/**
5288+
* @hide
5289+
*/
5290+
private class StaStateCallbackProxy extends IStaStateCallback.Stub {
5291+
private final Handler mHandler;
5292+
private final StaStateCallback mCallback;
5293+
5294+
StaStateCallbackProxy(Looper looper, StaStateCallback callback) {
5295+
mHandler = new Handler(looper);
5296+
mCallback = callback;
5297+
}
5298+
5299+
@Override
5300+
public void onStaToBeOff() {
5301+
if (mVerboseLoggingEnabled) {
5302+
Log.v(TAG, "StaStateCallbackProxy: onStaToBeOff");
5303+
}
5304+
mHandler.post(() -> {
5305+
mCallback.onStaToBeOff();
5306+
});
5307+
}
5308+
}
5309+
5310+
/**
5311+
* @hide
5312+
*/
5313+
public void registerStaStateCallback(@NonNull StaStateCallback callback,
5314+
@Nullable Handler handler) {
5315+
if (callback == null) throw new IllegalArgumentException("callback cannot be null");
5316+
Log.v(TAG, "registerStaStateCallback: callback=" + callback + ", handler=" + handler);
5317+
5318+
Looper looper = (handler == null) ? mContext.getMainLooper() : handler.getLooper();
5319+
Binder binder = new Binder();
5320+
try {
5321+
mService.registerStaStateCallback(
5322+
binder, new StaStateCallbackProxy(looper, callback), callback.hashCode());
5323+
} catch (RemoteException e) {
5324+
throw e.rethrowFromSystemServer();
5325+
}
5326+
}
5327+
5328+
/**
5329+
* @hide
5330+
*/
5331+
public void unregisterStaStateCallback(@NonNull StaStateCallback callback) {
5332+
if (callback == null) throw new IllegalArgumentException("callback cannot be null");
5333+
Log.v(TAG, "unregisterStaStateCallback: callback=" + callback);
5334+
5335+
try {
5336+
mService.unregisterStaStateCallback(callback.hashCode());
5337+
} catch (RemoteException e) {
5338+
throw e.rethrowFromSystemServer();
5339+
}
5340+
}
5341+
52775342
/**
52785343
* Helper method to update the local verbose logging flag based on the verbose logging
52795344
* level from wifi service.

0 commit comments

Comments
 (0)