diff --git a/Example/nrf-mesh/app/build.gradle b/Example/nrf-mesh/app/build.gradle
index 19b5981a9..a0f29f492 100644
--- a/Example/nrf-mesh/app/build.gradle
+++ b/Example/nrf-mesh/app/build.gradle
@@ -30,8 +30,8 @@ android {
applicationId "no.nordicsemi.android.nrfmeshprovisioner"
minSdkVersion 18
targetSdkVersion 29
- versionCode 50
- versionName "2.0.2"
+ versionCode 51
+ versionName "2.0.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
multiDexEnabled true
vectorDrawables.useSupportLibrary = true
@@ -65,7 +65,7 @@ dependencies {
implementation 'androidx.test:runner:1.2.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
- implementation 'com.google.android.material:material:1.1.0-alpha08'
+ implementation 'com.google.android.material:material:1.1.0-alpha09'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
diff --git a/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/GroupControlsActivity.java b/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/GroupControlsActivity.java
index aa9476f16..8d1c748a7 100644
--- a/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/GroupControlsActivity.java
+++ b/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/GroupControlsActivity.java
@@ -171,7 +171,7 @@ public boolean onCreateOptionsMenu(final Menu menu) {
}
@Override
- public boolean onOptionsItemSelected(final MenuItem item) {
+ public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
onBackPressed();
diff --git a/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/ble/ReconnectActivity.java b/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/ble/ReconnectActivity.java
index 7f40e43ca..c9593fffc 100644
--- a/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/ble/ReconnectActivity.java
+++ b/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/ble/ReconnectActivity.java
@@ -31,6 +31,7 @@
import javax.inject.Inject;
+import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;
@@ -96,7 +97,7 @@ protected void onCreate(@Nullable final Bundle savedInstanceState) {
}
@Override
- public boolean onOptionsItemSelected(final MenuItem item) {
+ public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
return true;
diff --git a/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/ble/ScannerActivity.java b/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/ble/ScannerActivity.java
index df61d61ff..99e080886 100644
--- a/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/ble/ScannerActivity.java
+++ b/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/ble/ScannerActivity.java
@@ -60,6 +60,7 @@
public class ScannerActivity extends AppCompatActivity implements Injectable,
DevicesAdapter.OnItemClickListener {
+ private static final int REQUEST_ENABLE_BLUETOOTH = 1021; // random number
private static final int REQUEST_ACCESS_COARSE_LOCATION = 1022; // random number
@Inject
@@ -120,14 +121,13 @@ protected void onCreate(@Nullable final Bundle savedInstanceState) {
adapter.setOnItemClickListener(this);
recyclerViewDevices.setAdapter(adapter);
-
+ mViewModel.getScannerRepository().getScannerState().observe(this, this::startScan);
}
@Override
protected void onStart() {
super.onStart();
mViewModel.getScannerRepository().getScannerState().startScanning();
- mViewModel.getScannerRepository().getScannerState().observe(this, this::startScan);
}
@Override
@@ -137,7 +137,7 @@ protected void onStop() {
}
@Override
- public boolean onOptionsItemSelected(final MenuItem item) {
+ public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
return true;
@@ -163,6 +163,10 @@ protected void onActivityResult(final int requestCode, final int resultCode, fin
if (resultCode == RESULT_OK) {
finish();
}
+ } else if (requestCode == REQUEST_ENABLE_BLUETOOTH) {
+ if (resultCode == RESULT_OK) {
+ startScan(mViewModel.getScannerRepository().getScannerState());
+ }
}
}
@@ -200,7 +204,7 @@ public void onEnableLocationClicked() {
@OnClick(R.id.action_enable_bluetooth)
public void onEnableBluetoothClicked() {
final Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
- startActivity(enableIntent);
+ startActivityForResult(enableIntent, REQUEST_ENABLE_BLUETOOTH);
}
@OnClick(R.id.action_grant_location_permission)
diff --git a/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/keys/EditNetKeyActivity.java b/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/keys/EditNetKeyActivity.java
index b80091325..4d8912792 100644
--- a/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/keys/EditNetKeyActivity.java
+++ b/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/keys/EditNetKeyActivity.java
@@ -124,7 +124,7 @@ protected void onCreate(@Nullable final Bundle savedInstanceState) {
}
@Override
- public boolean onOptionsItemSelected(final MenuItem item) {
+ public boolean onOptionsItemSelected(@NonNull final MenuItem item) {
if (item.getItemId() == android.R.id.home) {
onBackPressed();
return true;
@@ -137,7 +137,8 @@ public boolean onKeyNameUpdated(@NonNull final String name) {
if (networkKey != null) {
final MeshNetwork network = mViewModel.getMeshManagerApi().getMeshNetwork();
if (network != null) {
- return network.updateNetKey(networkKey, name);
+ networkKey.setName(name);
+ return network.updateNetKey(networkKey);
}
}
return false;
diff --git a/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/keys/dialogs/DialogFragmentAddKey.java b/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/keys/dialogs/DialogFragmentAddKey.java
index 33a60abab..defacf881 100644
--- a/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/keys/dialogs/DialogFragmentAddKey.java
+++ b/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/keys/dialogs/DialogFragmentAddKey.java
@@ -131,7 +131,7 @@ public void afterTextChanged(final Editable s) {
private boolean validateInput(final String appKey) {
try {
- if(MeshParserUtils.validateAppKeyInput(appKey)) {
+ if(MeshParserUtils.validateKeyInput(appKey)) {
return true;
}
} catch (IllegalArgumentException ex) {
diff --git a/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/viewmodels/ScannerRepository.java b/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/viewmodels/ScannerRepository.java
index a5ecec6ff..83d59c261 100644
--- a/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/viewmodels/ScannerRepository.java
+++ b/Example/nrf-mesh/app/src/main/java/no/nordicsemi/android/nrfmeshprovisioner/viewmodels/ScannerRepository.java
@@ -137,6 +137,7 @@ public void onReceive(final Context context, final Intent intent) {
switch (state) {
case BluetoothAdapter.STATE_ON:
mScannerLiveData.bluetoothEnabled();
+ mScannerLiveData.startScanning();
break;
case BluetoothAdapter.STATE_TURNING_OFF:
case BluetoothAdapter.STATE_OFF:
diff --git a/Example/nrf-mesh/app/src/main/res/values/strings.xml b/Example/nrf-mesh/app/src/main/res/values/strings.xml
index d6ba642df..b09d29fae 100644
--- a/Example/nrf-mesh/app/src/main/res/values/strings.xml
+++ b/Example/nrf-mesh/app/src/main/res/values/strings.xml
@@ -106,7 +106,7 @@
- * In order to change the key call {@link BaseMeshNetwork#updateNetKey(NetworkKey) or {@link BaseMeshNetwork#updateNetKey(NetworkKey)}} + * In order to change the key call {@link BaseMeshNetwork#updateNetKey(NetworkKey, String)} or {@link BaseMeshNetwork#updateAppKey(ApplicationKey, String)})}} *
* * @param key 16-byte network key */ - @RestrictTo(RestrictTo.Scope.LIBRARY) public void setKey(@NonNull final byte[] key) { this.key = key; } @@ -173,6 +172,7 @@ public boolean equals(@Nullable final Object obj) { return false; } + @NonNull @Override public MeshKey clone() throws CloneNotSupportedException { return (MeshKey) super.clone(); diff --git a/android-nrf-mesh-library/meshprovisioner/src/main/java/no/nordicsemi/android/meshprovisioner/NetworkKey.java b/android-nrf-mesh-library/meshprovisioner/src/main/java/no/nordicsemi/android/meshprovisioner/NetworkKey.java index 8b593f190..2299a737d 100644 --- a/android-nrf-mesh-library/meshprovisioner/src/main/java/no/nordicsemi/android/meshprovisioner/NetworkKey.java +++ b/android-nrf-mesh-library/meshprovisioner/src/main/java/no/nordicsemi/android/meshprovisioner/NetworkKey.java @@ -168,6 +168,7 @@ public void setTimestamp(final long timestamp) { public @interface KeyRefreshPhases { } + @NonNull @Override public NetworkKey clone() throws CloneNotSupportedException { return (NetworkKey) super.clone(); diff --git a/android-nrf-mesh-library/meshprovisioner/src/main/java/no/nordicsemi/android/meshprovisioner/transport/PublicationSettings.java b/android-nrf-mesh-library/meshprovisioner/src/main/java/no/nordicsemi/android/meshprovisioner/transport/PublicationSettings.java index 23358b9c2..54b05f479 100644 --- a/android-nrf-mesh-library/meshprovisioner/src/main/java/no/nordicsemi/android/meshprovisioner/transport/PublicationSettings.java +++ b/android-nrf-mesh-library/meshprovisioner/src/main/java/no/nordicsemi/android/meshprovisioner/transport/PublicationSettings.java @@ -131,9 +131,11 @@ public PublicationSettings(final int publishAddress, private PublicationSettings(Parcel in) { publishAddress = in.readInt(); - final ParcelUuid parcelUuid = in.readParcelable(ParcelUuid.class.getClassLoader()); - if (parcelUuid != null) { - labelUUID = parcelUuid.getUuid(); + if (MeshAddress.isValidVirtualAddress(publishAddress)) { + final ParcelUuid parcelUuid = in.readParcelable(ParcelUuid.class.getClassLoader()); + if (parcelUuid != null) { + labelUUID = parcelUuid.getUuid(); + } } appKeyIndex = in.readInt(); credentialFlag = in.readInt() == 1; @@ -395,7 +397,9 @@ public int describeContents() { @Override public void writeToParcel(final Parcel dest, final int flags) { dest.writeInt(publishAddress); - dest.writeParcelable(new ParcelUuid(labelUUID), flags); + if (MeshAddress.isValidVirtualAddress(publishAddress)) { + dest.writeParcelable(new ParcelUuid(labelUUID), flags); + } dest.writeInt(appKeyIndex); dest.writeInt(credentialFlag ? 1 : 0); dest.writeInt(publishTtl); diff --git a/android-nrf-mesh-library/meshprovisioner/src/main/java/no/nordicsemi/android/meshprovisioner/utils/MeshParserUtils.java b/android-nrf-mesh-library/meshprovisioner/src/main/java/no/nordicsemi/android/meshprovisioner/utils/MeshParserUtils.java index 79d060ab1..24271ea98 100644 --- a/android-nrf-mesh-library/meshprovisioner/src/main/java/no/nordicsemi/android/meshprovisioner/utils/MeshParserUtils.java +++ b/android-nrf-mesh-library/meshprovisioner/src/main/java/no/nordicsemi/android/meshprovisioner/utils/MeshParserUtils.java @@ -253,17 +253,17 @@ public static boolean validateIvIndexInput(final Context context, final Integer } /** - * Validates the app key input + * Validates the key input * - * @param appKey App key - * @return true if the Network Key is a valid value + * @param key key + * @return true if the Key is a valid value * @throws IllegalArgumentException in case of an invalid was entered as an input and the message containing the error */ - public static boolean validateAppKeyInput(@NonNull final String appKey) throws IllegalArgumentException { - if (TextUtils.isEmpty(appKey)) { - throw new IllegalArgumentException("App key cannot be empty!"); - } else if (!appKey.matches(PATTERN_KEY)) { - throw new IllegalArgumentException("The key must be a 32-character hexadecimal string!"); + public static boolean validateKeyInput(@NonNull final String key) throws IllegalArgumentException { + if (TextUtils.isEmpty(key)) { + throw new IllegalArgumentException("Key cannot be empty!"); + } else if (!key.matches(PATTERN_KEY)) { + throw new IllegalArgumentException("key must be a 32-character hexadecimal string!"); } return true;