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

Commit 4d194845 authored by Quang Luong's avatar Quang Luong
Browse files

Added OSU provisioning support

Added support for clicking on an OSU provider AP to start the
provisioning service. Provisioning callbacks currently do nothing.
The connected AP while provisioning still appears to be a normal
AP and displays the SSID rather than the provider name.

Tracking bug for adding robolectric tests: b/122849296

Bug: 118705403
Test: manual, build and tap on the OSU provider AP
Change-Id: I71d4fd70597c00ec82086e090695b35a49d9a23f
parent 49ca479e
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -43,6 +43,7 @@ import android.net.wifi.WifiManager;
import android.net.wifi.WifiNetworkScoreCache;
import android.net.wifi.hotspot2.OsuProvider;
import android.net.wifi.hotspot2.PasspointConfiguration;
import android.net.wifi.hotspot2.ProvisioningCallback;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.RemoteException;
@@ -1015,6 +1016,17 @@ public class AccessPoint implements Comparable<AccessPoint> {
        return mOsuProvider != null;
    }

    /**
     * Starts the OSU Provisioning flow.
     */
    public void startOsuProvisioning() {
        mContext.getSystemService(WifiManager.class).startSubscriptionProvisioning(
                mOsuProvider,
                new AccessPointProvisioningCallback(),
                ThreadUtils.getUiThreadHandler()
        );
    }

    /**
     * Return whether the given {@link WifiInfo} is for this access point.
     * If the current AP does not have a network Id then the config is used to
@@ -1493,4 +1505,27 @@ public class AccessPoint implements Comparable<AccessPoint> {
    private static boolean isVerboseLoggingEnabled() {
        return WifiTracker.sVerboseLogging || Log.isLoggable(TAG, Log.VERBOSE);
    }

    /**
     * Callbacks relaying changes to the OSU provisioning status started in startOsuProvisioning().
     *
     * All methods are invoked on the Main Thread
     */
    private class AccessPointProvisioningCallback extends ProvisioningCallback {
        // TODO: Remove logs and implement summary changing logic for these provisioning callbacks.
        @Override
        @MainThread public void onProvisioningFailure(int status) {
            Log.i(TAG, "[qal] Provisioning failed with status: " + status);
        }

        @Override
        @MainThread public void onProvisioningComplete() {
            Log.i(TAG, "[qal] Provisioning Complete");
        }

        @Override
        @MainThread public void onProvisioningStatus(int status) {
            Log.i(TAG, "[qal] Provisioning status: " + status);
        }
    }
}