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

Commit 392b71a5 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "wifi:Provide UI with SIM info for EAP-SIM authentication"

parents af2f04db 16a7ab0d
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package android.net.wifi;
import android.net.wifi.BatchedScanResult;
import android.net.wifi.BatchedScanSettings;
import android.net.wifi.WifiConfiguration;
import android.net.wifi.WifiEapSimInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.ScanSettings;
import android.net.wifi.WifiChannel;
@@ -152,5 +153,7 @@ interface IWifiManager
    void setAllowScansWithTraffic(int enabled);

    WifiConnectionStatistics getConnectionStatistics();

    WifiEapSimInfo getSimInfo();
}
+16 −0
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ public class WifiConfiguration implements Parcelable {
    public static final String updateIdentiferVarName = "update_identifier";
    /** {@hide} */
    public static final int INVALID_NETWORK_ID = -1;
    /** {@hide} */
    public static final String SIMNumVarName = "sim_num";
    /**
     * Recognized key management schemes.
     */
@@ -382,6 +384,12 @@ public class WifiConfiguration implements Parcelable {
     */
    public String autoJoinBSSID;

    /**
     * @hide
     * sim number selected
     */
    public int SIMNum;

    /**
     * @hide
     * BSSID list on which this configuration was seen.
@@ -836,6 +844,7 @@ public class WifiConfiguration implements Parcelable {
        noInternetAccess = false;
        mIpConfiguration = new IpConfiguration();
        duplicateNetwork = false;
        SIMNum = 1;
    }

    /**
@@ -1049,6 +1058,10 @@ public class WifiConfiguration implements Parcelable {
        if (this.preSharedKey != null) {
            sbuf.append('*');
        }
        sbuf.append('\n').append(" sim_num ");
        if (this.SIMNum > 0 ) {
            sbuf.append('*');
        }
        sbuf.append("\nEnterprise config:\n");
        sbuf.append(enterpriseConfig);

@@ -1474,6 +1487,7 @@ public class WifiConfiguration implements Parcelable {
            autoJoinBailedDueToLowRssi = source.autoJoinBailedDueToLowRssi;
            dirty = source.dirty;
            duplicateNetwork = source.duplicateNetwork;
            SIMNum = source.SIMNum;
        }
    }

@@ -1538,6 +1552,7 @@ public class WifiConfiguration implements Parcelable {
        dest.writeInt(numUserTriggeredJoinAttempts);
        dest.writeInt(autoJoinUseAggressiveJoinAttemptThreshold);
        dest.writeInt(autoJoinBailedDueToLowRssi ? 1 : 0);
        dest.writeInt(SIMNum);
    }

    /** Implement the Parcelable interface {@hide} */
@@ -1598,6 +1613,7 @@ public class WifiConfiguration implements Parcelable {
                config.numUserTriggeredJoinAttempts = in.readInt();
                config.autoJoinUseAggressiveJoinAttemptThreshold = in.readInt();
                config.autoJoinBailedDueToLowRssi = in.readInt() != 0;
                config.SIMNum = in.readInt();
                return config;
            }

+32 −0
Original line number Diff line number Diff line
/**
* Copyright (c) 2014, The Linux Foundation. All rights reserved.

* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*    * Redistributions of source code must retain the above copyright
*      notice, this list of conditions and the following disclaimer.
*    * Redistributions in binary form must reproduce the above
*      copyright notice, this list of conditions and the following
*      disclaimer in the documentation and/or other materials provided
*      with the distribution.
*    * Neither the name of The Linux Foundation nor the names of its
*      contributors may be used to endorse or promote products derived
*      from this software without specific prior written permission.

* THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
* ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
* IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

package android.net.wifi;

parcelable WifiEapSimInfo;
+182 −0
Original line number Diff line number Diff line
/*
 * Copyright (c) 2014, The Linux Foundation. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are
 * met:
 *   * Redistributions of source code must retain the above copyright
 *     notice, this list of conditions and the following disclaimer.
 *   * Redistributions in binary form must reproduce the above
 *     copyright notice, this list of conditions and the following
 *     disclaimer in the documentation and/or other materials provided
 *     with the distribution.
 *   * Neither the name of The Linux Foundation nor the names of its
 *     contributors may be used to endorse or promote products derived
 *     from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

package android.net.wifi;

import android.os.Parcelable;
import android.os.Parcel;

import java.util.ArrayList;
import android.util.Slog;
import android.util.Log;

/**
 * Describes information about EAP sim information.
 * {@hide}
 */
public class WifiEapSimInfo implements Parcelable {

    private static final String TAG = "WifiEapSimInfo";
    /**
     * No of sims device support
     */
    public int  mNumOfSims;

    /**
     * SIM info
     */
    public ArrayList <Integer> mSimTypes = new ArrayList <Integer>();

    /**
     * These definitions are for deviceState
     */
    public static final int SIM_UNSUPPORTED = 0;
    public static final int SIM_2G = 1;
    public static final int SIM_3G = 3;
    public static final int MAX_NUM_OF_SIMS_SUPPORTED = 4;

    /**
     * Sim supported EAP types
     */
     public static final String[]  m2GSupportedTypes={ "SIM" };
     public static final String[]  m3GSupportedTypes={ "SIM", "AKA" };

     /**
     *  Strings constants to parse
     */
    private static final String NUM_OF_SIMS_STR = "no_of_sims=";
    private static final String SIM_ONE_TYPE_STR = "sim1=";
    private static final String SIM_TWO_TYPE_STR = "sim2=";
    private static final String SIM_THREE_TYPE_STR = "sim3=";
    private static final String SIM_FOUR_TYPE_STR = "sim4=";
    private static final boolean DBG = false;

    /** {@hide} */
    public WifiEapSimInfo() {}

    /** copy constructor {@hide} */
    public WifiEapSimInfo(WifiEapSimInfo source) {
        if (source != null) {
            mNumOfSims = source.mNumOfSims;
            mSimTypes= source.mSimTypes;
        }
    }

    /**
     * @param string formats supported include
     *  no_of_sims=2 sim1=3 sim2=0
     *
     * @hide
     */
    public WifiEapSimInfo(String dataString) throws IllegalArgumentException {
        String[] sims = dataString.split(" ");
        int mSimInfo = -1;

        if ((sims.length < 1)||(sims.length > MAX_NUM_OF_SIMS_SUPPORTED )) {
            throw new IllegalArgumentException();
        }
        for (String sim :sims) {
            if (sim.startsWith(NUM_OF_SIMS_STR)) {
                try {
                    mNumOfSims = Integer.parseInt(sim.substring(NUM_OF_SIMS_STR.length()));
                    if (DBG) Log.d(TAG,"mNumOfSims =" + mNumOfSims);
                } catch (NumberFormatException e) {
                    mNumOfSims = 0;
                }
            } else if (sim.startsWith(SIM_ONE_TYPE_STR)) {
                try {
                    mSimInfo = Integer.parseInt(sim.substring(SIM_ONE_TYPE_STR.length()));
                    if (DBG) Log.d(TAG,"SIM_ONE_TYPE mSimInfo =" + mSimInfo);
                } catch (NumberFormatException e) {
                    mSimInfo = 0;
                }
                mSimTypes.add(mSimInfo);
            } else if (sim.startsWith(SIM_TWO_TYPE_STR)) {
                try {
                    mSimInfo = Integer.parseInt(sim.substring(SIM_TWO_TYPE_STR.length()));
                    if (DBG) Log.d(TAG,"SIM_TWO_TYPE mSimInfo =" + mSimInfo);
                } catch (NumberFormatException e) {
                    mSimInfo = 0;
                }
                mSimTypes.add(mSimInfo);
            } else if (sim.startsWith(SIM_THREE_TYPE_STR)) {
                try {
                    mSimInfo = Integer.parseInt(sim.substring(SIM_THREE_TYPE_STR.length()));
                    if (DBG) Log.d(TAG,"SIM_THREE_TYPE mSimInfo =" + mSimInfo);
                } catch (NumberFormatException e) {
                    mSimInfo = 0;
                }
                mSimTypes.add(mSimInfo);
            } else if (sim.startsWith(SIM_FOUR_TYPE_STR)) {
                try {
                    mSimInfo = Integer.parseInt(sim.substring(SIM_FOUR_TYPE_STR.length()));
                    if (DBG) Log.d(TAG,"SIM_FOUR_TYPE mSimInfo =" + mSimInfo);
                } catch (NumberFormatException e) {
                    mSimInfo = 0;
                }
                mSimTypes.add(mSimInfo);
            } else {
                throw new IllegalArgumentException();
            }
        }
    }

    /** Implement the Parcelable interface {@hide} */
    public int describeContents() {
        return 0;
    }

    /** Implement the Parcelable interface {@hide} */
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeInt(mNumOfSims);
        dest.writeInt(mSimTypes.size());
        for(Integer mInteger : mSimTypes) {
           dest.writeInt(mInteger.intValue());
        }
    }

    /** Implement the Parcelable interface {@hide} */
    public static final Creator<WifiEapSimInfo> CREATOR =
        new Creator<WifiEapSimInfo>() {
            public WifiEapSimInfo createFromParcel(Parcel in) {
                WifiEapSimInfo mWifiEapSimInfo = new WifiEapSimInfo();
                mWifiEapSimInfo.mNumOfSims = in.readInt();
                int count = in.readInt();
                if (DBG) Log.d(TAG,"Creator mNumOfSims =" + mWifiEapSimInfo.mNumOfSims);
                while(count-- > 0) {
                  mWifiEapSimInfo.mSimTypes.add(new Integer(in.readInt()));
                }
                return mWifiEapSimInfo;
            }

            public WifiEapSimInfo[] newArray(int size) {
                return new WifiEapSimInfo[size];
            }
        };
}
+14 −0
Original line number Diff line number Diff line
@@ -1242,6 +1242,20 @@ public class WifiManager {
        } catch (RemoteException e) { }
    }

    /**
     * Get the EAP Sim info from supplicant and provide to UI
     * @return WifiEapSimInfo class
     *         mNoOfSims and an Array list of mSimTypes
     * @hide
    */
    public WifiEapSimInfo getSimInfo() {
        try {
            return mService.getSimInfo();
        } catch (RemoteException e) {
            return null;
        }
    }

    /**
     * Get the operational frequency band.
     * @return One of