Add MQTT dependencies, settings UI, and test coverage (CATROID-1670, CATROID-1672)#5220
Add MQTT dependencies, settings UI, and test coverage (CATROID-1670, CATROID-1672)#5220Paras-ydv wants to merge 11 commits into
Conversation
Add the Eclipse Paho MQTT Java library dependency to the Catroid module's build configuration. This lays the groundwork for the connection manager and the new MQTT bricks. - Declare org.eclipse.paho.client.mqttv3:1.2.5 via Maven Central (Eclipse Paho repo not required) - Declare org.eclipse.paho.android.service:1.1.1 via Maven Central - Add FEATURE_MQTT_ENABLED build config flag in build.gradle - Register MqttService in AndroidManifest.xml - Add MqttDependencySanityTest to verify Paho classes are accessible on the test classpath INTERNET and ACCESS_NETWORK_STATE permissions were already present in the manifest — no changes required.
harshsomankar123-tech
left a comment
There was a problem hiding this comment.
Thanks, @Paras-ydv. I only gave this a quick first pass, but I’ll do a full review ASAP. PTAL at the comments in the meantime.
…d default host, disable MQTT settings if feature is not enabled
wslany
left a comment
There was a problem hiding this comment.
Many thanks!!
MQTT password is stored in default SharedPreferences
mqtt_preferences.xml (line 63) defines the broker password as an EditTextPreference, and SettingsFragment.java (line 456) reads it from default shared preferences. That means broker credentials are persisted in plaintext app prefs. Since Catroid already has androidx.security:security-crypto and an EncryptedSharedPreferences pattern, this should either move to encrypted storage or avoid persisting the password.
MQTT Espresso smoke test toggles the navigation entry instead of the actual checkbox
In SettingsFragmentTest.java (line 264), the first click opens the MQTT settings screen using the title preference_title_enable_mqtt_bricks (“MQTT extension”). Then line 268 (line 268) passes the same title into checkPreference, whose helper expects a checkbox row to toggle. Inside the MQTT screen, the checkbox title is preference_title_mqtt_enabled (“Enable MQTT bricks”), so the test either fails to find the row or does not verify SETTINGS_SHOW_MQTT_BRICKS. It should navigate once, then call checkPreference(R.string.preference_title_mqtt_enabled, SETTINGS_SHOW_MQTT_BRICKS).
…encrypt password storage - Fix mqttSettingsTest() to use preference_title_mqtt_enabled instead of preference_title_enable_mqtt_bricks so Espresso finds the actual checkbox inside MqttSettingsFragment - Remove redundant password onPreferenceChangeListener that only returned true - Store MQTT password in EncryptedSharedPreferences (AES256) instead of plaintext default SharedPreferences
|
|
Hi @harshsomankar123-tech and @wslany, I've addressed the review comments:
PTAL. Thanks! |
| passwordPreference.isPersistent = false | ||
| passwordPreference.text = encryptedPrefs.getString(MQTT_PASSWORD, "") | ||
| passwordPreference.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> | ||
| with(encryptedPrefs.edit()) { |
| passwordPreference.isPersistent = false | ||
| passwordPreference.text = encryptedPrefs.getString(MQTT_PASSWORD, "") | ||
| passwordPreference.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, newValue -> | ||
| with(encryptedPrefs.edit()) { |



Summary
This PR introduces the initial MQTT foundation for Catroid by combining:
CATROID-1670 — MQTT Dependency and Android Configuration
Changes Implemented
catroid/build.gradle
org.eclipse.paho.client.mqttv3:1.2.5org.eclipse.paho.android.service:1.1.1FEATURE_MQTT_ENABLEDbuild config flagAndroidManifest.xml
org.eclipse.paho.android.service.MqttServiceTesting
Added dependency sanity tests verifying:
are available on the test classpath.
CATROID-1672 — MQTT Settings UI and Persistence
UI Demo
Watch UI Demo
Features Implemented
Added MQTT settings screen with:
Persistence
Implemented persistent storage using SharedPreferences.
Added accessor APIs:
Validation
Testing
Added automated tests covering:
28 unit tests added.
Followed TDD workflow:
Your Checklist