Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d41cf50b authored by Kshitij's avatar Kshitij Committed by Rashed Abdel-Tawab
Browse files

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
parent 1ed91f78
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
/*
 * 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
Original line number Diff line number Diff line
@@ -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
Original line number Diff line number Diff line
@@ -4551,6 +4551,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
Original line number Diff line number Diff line
@@ -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();
    }
}