Skip to content

Commit

Permalink
Fix android wifi rename (project-chip#13349)
Browse files Browse the repository at this point in the history
* More renaming of Wifi to WiFi

* Use proper name for WifiManager for java

* Restyle update
  • Loading branch information
andy31415 authored and step0035 committed Feb 8, 2022
1 parent 3078d2a commit 6f197e9
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 36 deletions.
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

0 comments on commit 6f197e9

Please sign in to comment.