From c7e5517a0b0dd77e47a80f68e0de7e545755e6a3 Mon Sep 17 00:00:00 2001 From: Sandeep Sharma Date: Mon, 17 Oct 2016 20:09:11 +0530 Subject: [PATCH] Fix crash in Android provisioning client App. Catch exception in provision Android client for setDeviceId API. Change-Id: I19918e47eac9f040d490e3805964c6cc7d5d3fba Signed-off-by: Sandeep Sharma Reviewed-on: https://gerrit.iotivity.org/gerrit/13345 Tested-by: jenkins-iotivity Reviewed-by: Randeep Singh (cherry picked from commit add0610e0eafe8c51d669151fa77aeca5ee59bd6) Reviewed-on: https://gerrit.iotivity.org/gerrit/13347 --- .../base/src/main/java/org/iotivity/base/OcPlatform.java | 2 +- .../base/examples/provisioningclient/ProvisioningClient.java | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java b/android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java index 110577c..8eacd4b 100644 --- a/android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java +++ b/android/android_api/base/src/main/java/org/iotivity/base/OcPlatform.java @@ -1447,5 +1447,5 @@ public final class OcPlatform { /** * Method to set DeviceId. */ - public static native void setDeviceId(byte[] deviceId); + public static native void setDeviceId(byte[] deviceId) throws OcException; } diff --git a/android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java b/android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java index b2e857c..820eddf 100644 --- a/android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java +++ b/android/examples/provisioningclient/src/main/java/org/iotivity/base/examples/provisioningclient/ProvisioningClient.java @@ -211,9 +211,14 @@ OcSecureResource.DoOwnershipTransferListener, OcSecureResource.ProvisionPairwise String devId = new String(deviceIdBytes); Log.d(TAG, "Get Device Id "+devId); //Set deviceId - String setId = "adminDeviceUuid1"; - OcPlatform.setDeviceId(setId.getBytes()); - Log.d(TAG, "Set Device Id done"); + try { + String setId = "adminDeviceUuid1"; + OcPlatform.setDeviceId(setId.getBytes()); + Log.d(TAG, "Set Device Id done"); + } + catch (OcException e) { + Log.d(TAG, e.getMessage()); + } try { /* -- 2.7.4