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

Commit 15f3d215 authored by Jeremy Klein's avatar Jeremy Klein
Browse files

Implement ui-based provisioning for the new tether api.

This is dependent on ag/850648 and the Settings changes under the
uiprovisioning topic id.

BUG: 26247383
Change-Id: Ib151d56a1ece5ca3a55219abed965286eac5dd60
parent 0301cd95
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -128,6 +128,27 @@ public final class Settings {
    public static final String ACTION_WIRELESS_SETTINGS =
            "android.settings.WIRELESS_SETTINGS";

    /**
     * Activity Action: Show tether provisioning activity.
     *
     * <p>
     * In some cases, a matching Activity may not exist, so ensure you
     * safeguard against this.
     * <p>
     * Input: {@link ConnectivityManager.EXTRA_TETHER_TYPE} should be included to specify which type
     * of tethering should be checked. {@link ConnectivityManager.EXTRA_PROVISION_CALLBACK} should
     * contain a {@link ResultReceiver} which will be called back with a tether result code.
     * <p>
     * Output: The result of the provisioning check.
     * {@link ConnectivityManager.TETHER_ERROR_NO_ERROR} if successful,
     * {@link ConnectivityManager.TETHER_ERROR_PROVISION_FAILED} for failure.
     *
     * @hide
     */
    @SdkConstant(SdkConstantType.ACTIVITY_INTENT_ACTION)
    public static final String ACTION_TETHER_PROVISIONING =
            "android.settings.TETHER_PROVISIONING_UI";

    /**
     * Activity Action: Show settings to allow entering/exiting airplane mode.
     * <p>
+15 −2
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import android.os.Parcel;
import android.os.ResultReceiver;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings;
import android.telephony.CarrierConfigManager;
import android.telephony.TelephonyManager;
import android.util.Log;
@@ -464,8 +465,20 @@ public class Tethering extends BaseNetworkObserver {
    }

    private void runUiTetherProvisioningAndEnable(int type, ResultReceiver receiver) {
        // TODO: Fill in for real.
        enableTetheringInternal(type, true, receiver);
        ResultReceiver proxyReceiver = getProxyReceiver(type, receiver);
        sendUiTetherProvisionIntent(type, proxyReceiver);
    }

    private void sendUiTetherProvisionIntent(int type, ResultReceiver receiver) {
        Intent intent = new Intent(Settings.ACTION_TETHER_PROVISIONING);
        intent.putExtra(ConnectivityManager.EXTRA_ADD_TETHER_TYPE, type);
        intent.putExtra(ConnectivityManager.EXTRA_PROVISION_CALLBACK, receiver);
        final long ident = Binder.clearCallingIdentity();
        try {
            mContext.startActivityAsUser(intent, UserHandle.CURRENT);
        } finally {
            Binder.restoreCallingIdentity(ident);
        }
    }

    /**