[DPP R2] Update ACTION_PROCESS_WIFI_EASY_CONNECT_URI intent
Update ACTION_PROCESS_WIFI_EASY_CONNECT_URI intent to include additional information in case of a failure. The intent will return an extra field with result code for R1 and R2 devices, and additional details for R2 devices: SSID, channe list, and band list. Bug: 139381558 Test: Manual test Change-Id: I6f1805f3b1ff72efc83961083c1311a24d6ebd3e
This commit is contained in:
@@ -16,9 +16,15 @@
|
|||||||
|
|
||||||
package com.android.settings.wifi.dpp;
|
package com.android.settings.wifi.dpp;
|
||||||
|
|
||||||
|
import static android.provider.Settings.EXTRA_EASY_CONNECT_ATTEMPTED_SSID;
|
||||||
|
import static android.provider.Settings.EXTRA_EASY_CONNECT_BAND_LIST;
|
||||||
|
import static android.provider.Settings.EXTRA_EASY_CONNECT_CHANNEL_LIST;
|
||||||
|
import static android.provider.Settings.EXTRA_EASY_CONNECT_ERROR_CODE;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
import android.net.wifi.EasyConnectStatusCallback;
|
import android.net.wifi.EasyConnectStatusCallback;
|
||||||
import android.net.wifi.WifiManager;
|
import android.net.wifi.WifiManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -35,6 +41,9 @@ import androidx.lifecycle.ViewModelProviders;
|
|||||||
|
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
|
||||||
|
import org.json.JSONArray;
|
||||||
|
import org.json.JSONObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* After getting Wi-Fi network information and(or) QR code, this fragment config a device to connect
|
* After getting Wi-Fi network information and(or) QR code, this fragment config a device to connect
|
||||||
* to the Wi-Fi network.
|
* to the Wi-Fi network.
|
||||||
@@ -79,7 +88,8 @@ public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
|
|||||||
Log.d(TAG, sb.toString());
|
Log.d(TAG, sb.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
showErrorUi(code, /* isConfigurationChange */ false);
|
showErrorUi(code, ssid, channelListArray, operatingClassArray,
|
||||||
|
/* isConfigurationChange */ false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -110,7 +120,8 @@ public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showErrorUi(int code, boolean isConfigurationChange) {
|
private void showErrorUi(int code, String ssid, SparseArray<int[]> channelListArray,
|
||||||
|
int[] operatingClassArray, boolean isConfigurationChange) {
|
||||||
CharSequence summaryCharSequence;
|
CharSequence summaryCharSequence;
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_INVALID_URI:
|
case EasyConnectStatusCallback.EASY_CONNECT_EVENT_FAILURE_INVALID_URI:
|
||||||
@@ -191,7 +202,50 @@ public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
|
|||||||
mRightButton.setText(getContext(), R.string.retry);
|
mRightButton.setText(getContext(), R.string.retry);
|
||||||
} else {
|
} else {
|
||||||
mRightButton.setText(getContext(), R.string.done);
|
mRightButton.setText(getContext(), R.string.done);
|
||||||
mRightButton.setOnClickListener(v -> getActivity().finish());
|
mRightButton.setOnClickListener(v -> {
|
||||||
|
final Activity activity = getActivity();
|
||||||
|
final Intent intent = activity.getIntent();
|
||||||
|
intent.putExtra(EXTRA_EASY_CONNECT_ERROR_CODE, code);
|
||||||
|
|
||||||
|
if (!TextUtils.isEmpty(ssid)) {
|
||||||
|
intent.putExtra(EXTRA_EASY_CONNECT_ATTEMPTED_SSID, ssid);
|
||||||
|
}
|
||||||
|
if (channelListArray != null && channelListArray.size() != 0) {
|
||||||
|
int key;
|
||||||
|
int index = 0;
|
||||||
|
JSONObject formattedChannelList = new JSONObject();
|
||||||
|
|
||||||
|
// Build a JSON array of operating classes, with an array of channels for each
|
||||||
|
// operating class.
|
||||||
|
do {
|
||||||
|
try {
|
||||||
|
key = channelListArray.keyAt(index);
|
||||||
|
} catch (java.lang.ArrayIndexOutOfBoundsException e) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
JSONArray channelsInClassArray = new JSONArray();
|
||||||
|
|
||||||
|
int[] output = channelListArray.get(key);
|
||||||
|
for (int i = 0; i < output.length; i++) {
|
||||||
|
channelsInClassArray.put(output[i]);
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
formattedChannelList.put(Integer.toString(key), channelsInClassArray);
|
||||||
|
} catch (org.json.JSONException e) {
|
||||||
|
formattedChannelList = new JSONObject();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
} while (true);
|
||||||
|
|
||||||
|
intent.putExtra(EXTRA_EASY_CONNECT_CHANNEL_LIST,
|
||||||
|
formattedChannelList.toString());
|
||||||
|
}
|
||||||
|
if (operatingClassArray != null && operatingClassArray.length != 0) {
|
||||||
|
intent.putExtra(EXTRA_EASY_CONNECT_BAND_LIST, operatingClassArray);
|
||||||
|
}
|
||||||
|
activity.finish();
|
||||||
|
});
|
||||||
mLeftButton.setVisibility(View.INVISIBLE);
|
mLeftButton.setVisibility(View.INVISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -302,7 +356,8 @@ public class WifiDppAddDeviceFragment extends WifiDppQrCodeBaseFragment {
|
|||||||
mRightButton.setVisibility(isEasyConnectHandshaking() ?
|
mRightButton.setVisibility(isEasyConnectHandshaking() ?
|
||||||
View.INVISIBLE : View.VISIBLE);
|
View.INVISIBLE : View.VISIBLE);
|
||||||
} else {
|
} else {
|
||||||
showErrorUi(mLatestStatusCode, /* isConfigurationChange */ true);
|
showErrorUi(mLatestStatusCode, /*ssid */null, /* channelListArray */
|
||||||
|
null, /* operatingClassArray */ null, /* isConfigurationChange */ true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user