Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix android wifi rename #13349

Merged
merged 3 commits into from
Jan 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ class CHIPToolActivity :
showFragment(BarcodeFragment.newInstance())
}

override fun onProvisionWifiCredentialsClicked() {
override fun onProvisionWiFiCredentialsClicked() {
networkType = ProvisionNetworkType.WIFI
showFragment(BarcodeFragment.newInstance(), false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import androidx.core.content.ContextCompat
import androidx.fragment.app.Fragment
import com.google.chip.chiptool.util.FragmentUtil
import kotlinx.android.synthetic.main.select_action_fragment.provisionThreadCredentialsBtn
import kotlinx.android.synthetic.main.select_action_fragment.provisionWifiCredentialsBtn
import kotlinx.android.synthetic.main.select_action_fragment.provisionWiFiCredentialsBtn
import kotlinx.android.synthetic.main.select_action_fragment.view.*

/** Fragment to select from various options to interact with a CHIP device. */
Expand All @@ -42,9 +42,9 @@ class SelectActionFragment : Fragment() {
): View {
return inflater.inflate(R.layout.select_action_fragment, container, false).apply {
scanQrBtn.setOnClickListener { getCallback()?.handleScanQrCodeClicked() }
provisionWifiCredentialsBtn.apply {
provisionWiFiCredentialsBtn.apply {
isEnabled = hasLocationPermission()
setOnClickListener { getCallback()?.onProvisionWifiCredentialsClicked() }
setOnClickListener { getCallback()?.onProvisionWiFiCredentialsClicked() }
}
provisionThreadCredentialsBtn.apply {
isEnabled = hasLocationPermission()
Expand All @@ -71,10 +71,10 @@ class SelectActionFragment : Fragment() {
ActivityResultContracts.RequestPermission()
) { granted ->
if (granted) {
provisionWifiCredentialsBtn.isEnabled = true
provisionWiFiCredentialsBtn.isEnabled = true
provisionThreadCredentialsBtn.isEnabled = true
} else {
provisionWifiCredentialsBtn.isEnabled = false
provisionWiFiCredentialsBtn.isEnabled = false
provisionThreadCredentialsBtn.isEnabled = false

AlertDialog.Builder(requireContext())
Expand Down Expand Up @@ -106,8 +106,8 @@ class SelectActionFragment : Fragment() {
interface Callback {
/** Notifies listener of Scan QR code button click. */
fun handleScanQrCodeClicked()
/** Notifies listener of provision-Wifi-credentials button click. */
fun onProvisionWifiCredentialsClicked()
/** Notifies listener of provision-WiFi-credentials button click. */
fun onProvisionWiFiCredentialsClicked()
/** Notifies listener of provision-Thread-credentials button click. */
fun onProvisionThreadCredentialsClicked()
/** Notifies listener of Light On/Off & Level Cluster button click. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ class EnterNetworkFragment : Fragment() {

private fun onSaveNetworkClicked() {
if (networkType == ProvisionNetworkType.WIFI) {
saveWifiNetwork()
saveWiFiNetwork()
} else {
saveThreadNetwork()
}
}

private fun saveWifiNetwork() {
private fun saveWiFiNetwork() {
val ssid = ssidEd?.text
val pwd = pwdEd?.text

Expand All @@ -79,8 +79,8 @@ class EnterNetworkFragment : Fragment() {
return
}

val networkCredentials = NetworkCredentials.forWifi(
NetworkCredentials.WifiCredentials(ssid.toString(), pwd.toString())
val networkCredentials = NetworkCredentials.forWiFi(
NetworkCredentials.WiFiCredentials(ssid.toString(), pwd.toString())
)
FragmentUtil.getHost(this, Callback::class.java)
?.onNetworkCredentialsEntered(networkCredentials)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
android:text="@string/scan_qr_code_btn_text" />

<Button
android:id="@+id/provisionWifiCredentialsBtn"
android:id="@+id/provisionWiFiCredentialsBtn"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginStart="8dp"
Expand Down
14 changes: 7 additions & 7 deletions src/controller/java/AndroidDeviceControllerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@ CHIP_ERROR AndroidDeviceControllerWrapper::ApplyNetworkCredentials(chip::Control

// Retrieve WiFi or Thread credentials from the NetworkCredentials Java object, and set them in the commissioning params.
JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread();
jmethodID getWifiCredentials;
err = chip::JniReferences::GetInstance().FindMethod(env, networkCredentials, "getWifiCredentials",
"()Lchip/devicecontroller/NetworkCredentials$WifiCredentials;",
&getWifiCredentials);
jmethodID getWiFiCredentials;
err = chip::JniReferences::GetInstance().FindMethod(env, networkCredentials, "getWiFiCredentials",
"()Lchip/devicecontroller/NetworkCredentials$WiFiCredentials;",
&getWiFiCredentials);
VerifyOrReturnError(err == CHIP_NO_ERROR, err);
jobject wifiCredentialsJava = env->CallObjectMethod(networkCredentials, getWifiCredentials);
jobject wifiCredentialsJava = env->CallObjectMethod(networkCredentials, getWiFiCredentials);

jmethodID getThreadCredentials;
err = chip::JniReferences::GetInstance().FindMethod(env, networkCredentials, "getThreadCredentials",
Expand Down Expand Up @@ -323,8 +323,8 @@ CHIP_ERROR AndroidDeviceControllerWrapper::ApplyNetworkCredentials(chip::Control
jsize ssidLength = env->GetStringUTFLength(ssidStr);
jsize passwordLength = env->GetStringUTFLength(passwordStr);

params.SetWifiCredentials(
WifiCredentials(chip::ByteSpan(reinterpret_cast<const uint8_t *>(ssid), static_cast<size_t>(ssidLength)),
params.SetWiFiCredentials(
WiFiCredentials(chip::ByteSpan(reinterpret_cast<const uint8_t *>(ssid), static_cast<size_t>(ssidLength)),
chip::ByteSpan(reinterpret_cast<const uint8_t *>(password), static_cast<size_t>(passwordLength))));
}
else if (threadCredentialsJava != nullptr)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,30 +23,30 @@

/** Class for holding WiFi or Thread credentials, but not both. */
public class NetworkCredentials implements Parcelable {
@Nullable private WifiCredentials wifiCredentials;
@Nullable private WiFiCredentials wifiCredentials;
@Nullable private ThreadCredentials threadCredentials;

private NetworkCredentials(
@Nullable WifiCredentials wifiCredentials, @Nullable ThreadCredentials threadCredentials) {
@Nullable WiFiCredentials wifiCredentials, @Nullable ThreadCredentials threadCredentials) {
this.wifiCredentials = wifiCredentials;
this.threadCredentials = threadCredentials;
}

/**
* Return a NetworkCredentials object with the given WifiCredentials and null ThreadCredentials.
* Return a NetworkCredentials object with the given WiFiCredentials and null ThreadCredentials.
*/
public static NetworkCredentials forWifi(WifiCredentials wifiCredentials) {
public static NetworkCredentials forWiFi(WiFiCredentials wifiCredentials) {
return new NetworkCredentials(wifiCredentials, null);
}

/**
* Return a NetworkCredentials object with the given ThreadCredentials and null WifiCredentials.
* Return a NetworkCredentials object with the given ThreadCredentials and null WiFiCredentials.
*/
public static NetworkCredentials forThread(ThreadCredentials threadCredentials) {
return new NetworkCredentials(null, threadCredentials);
}

public WifiCredentials getWifiCredentials() {
public WiFiCredentials getWiFiCredentials() {
return wifiCredentials;
}

Expand All @@ -57,7 +57,7 @@ public ThreadCredentials getThreadCredentials() {
// Begin Parcelable implementation

private NetworkCredentials(Parcel in) {
wifiCredentials = in.readParcelable(WifiCredentials.class.getClassLoader());
wifiCredentials = in.readParcelable(WiFiCredentials.class.getClassLoader());
threadCredentials = in.readParcelable(ThreadCredentials.class.getClassLoader());
}

Expand All @@ -81,11 +81,11 @@ public NetworkCredentials[] newArray(int size) {
}
};

public static class WifiCredentials implements Parcelable {
public static class WiFiCredentials implements Parcelable {
private final String ssid;
private final String password;

public WifiCredentials(String ssid, String password) {
public WiFiCredentials(String ssid, String password) {
this.ssid = ssid;
this.password = password;
}
Expand All @@ -100,7 +100,7 @@ public String getPassword() {

// Begin Parcelable implementation

private WifiCredentials(Parcel in) {
private WiFiCredentials(Parcel in) {
ssid = in.readString();
password = in.readString();
}
Expand All @@ -114,14 +114,14 @@ public void writeToParcel(Parcel out, int flags) {
out.writeString(password);
}

public static final Parcelable.Creator<WifiCredentials> CREATOR =
new Parcelable.Creator<WifiCredentials>() {
public WifiCredentials createFromParcel(Parcel in) {
return new WifiCredentials(in);
public static final Parcelable.Creator<WiFiCredentials> CREATOR =
new Parcelable.Creator<WiFiCredentials>() {
public WiFiCredentials createFromParcel(Parcel in) {
return new WiFiCredentials(in);
}

public WifiCredentials[] newArray(int size) {
return new WifiCredentials[size];
public WiFiCredentials[] newArray(int size) {
return new WiFiCredentials[size];
}
};
}
Expand Down