From ad4ecfbe72129a2f711205ff3e8572b8e6c97d0c Mon Sep 17 00:00:00 2001 From: "Hui.Li-TCL" Date: Sat, 2 Apr 2022 00:24:01 +0800 Subject: [PATCH] fix lineupInfoTypeEnum naming error and add response.data (#16869) * fix lineupInfoTypeEnum naming error and add response.data * fix restyled-io and ci errors * using MakeOptional --- examples/tv-app/android/java/ChannelManager.cpp | 15 +++++++++++---- .../java/src/com/tcl/chip/tvapp/ChannelInfo.java | 14 +++++++------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/examples/tv-app/android/java/ChannelManager.cpp b/examples/tv-app/android/java/ChannelManager.cpp index 02ca88ef9e6a74..303c2afbd61e8c 100644 --- a/examples/tv-app/android/java/ChannelManager.cpp +++ b/examples/tv-app/android/java/ChannelManager.cpp @@ -167,7 +167,7 @@ CHIP_ERROR ChannelManager::HandleGetLineup(AttributeValueEncoder & aEncoder) lineupInfo.postalCode = Optional(postalCode.charSpan()); } - jfieldID lineupInfoTypeFild = env->GetFieldID(channelLineupClazz, "lineupInfoTypeEnum", "I"); + jfieldID lineupInfoTypeFild = env->GetFieldID(channelLineupClazz, "lineupInfoType", "I"); jint jlineupInfoType = (env->GetIntField(channelLineupObject, lineupInfoTypeFild)); lineupInfo.lineupInfoType = static_cast(jlineupInfoType); @@ -246,9 +246,6 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelperGetObjectClass(channelObject); + ChangeChannelResponseType response; + jfieldID getStatusField = env->GetFieldID(channelClass, "status", "I"); jint jstatus = env->GetIntField(channelObject, getStatusField); response.status = static_cast(jstatus); + jfieldID getNameField = env->GetFieldID(channelClass, "name", "Ljava/lang/String;"); + jstring jname = static_cast(env->GetObjectField(channelObject, getNameField)); + JniUtfString junitname(env, jname); + if (jname != NULL) + { + response.data = MakeOptional(junitname.charSpan()); + } + helper.Success(response); } diff --git a/examples/tv-app/android/java/src/com/tcl/chip/tvapp/ChannelInfo.java b/examples/tv-app/android/java/src/com/tcl/chip/tvapp/ChannelInfo.java index 908d923d80e609..5f8ed38d6c0c28 100644 --- a/examples/tv-app/android/java/src/com/tcl/chip/tvapp/ChannelInfo.java +++ b/examples/tv-app/android/java/src/com/tcl/chip/tvapp/ChannelInfo.java @@ -19,11 +19,11 @@ public class ChannelInfo { - public static final int kNoError = -1; // todo: what will be the value of no error? + public static final int kSuccess = -1; // todo: what will be the value of no error? public static final int kMultipleMatches = 0; public static final int kNoMatches = 1; - public int errorType; + public int status; public int majorNumber; public int minorNumber; public String name; @@ -32,7 +32,7 @@ public class ChannelInfo { public ChannelInfo( int majorNumber, int minorNumber, String name, String callSign, String affiliateCallSign) { - this.errorType = kNoError; + this.status = kSuccess; this.majorNumber = majorNumber; this.minorNumber = minorNumber; this.name = name; @@ -40,15 +40,15 @@ public ChannelInfo( this.affiliateCallSign = affiliateCallSign; } - public ChannelInfo(int errorType) { - this.errorType = errorType; + public ChannelInfo(int status) { + this.status = status; } @Override public String toString() { return "ChannelInfo{" - + "errorType=" - + errorType + + "status=" + + status + ", majorNumber=" + majorNumber + ", minorNumber="