Skip to content

Commit

Permalink
fix lineupInfoTypeEnum naming error and add response.data (#16869)
Browse files Browse the repository at this point in the history
* fix lineupInfoTypeEnum naming error and add response.data

* fix restyled-io and ci errors

* using MakeOptional
  • Loading branch information
xylophone21 authored and pull[bot] committed Sep 13, 2023
1 parent 1a57e56 commit ad4ecfb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
15 changes: 11 additions & 4 deletions examples/tv-app/android/java/ChannelManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ CHIP_ERROR ChannelManager::HandleGetLineup(AttributeValueEncoder & aEncoder)
lineupInfo.postalCode = Optional<CharSpan>(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<app::Clusters::Channel::LineupInfoTypeEnum>(jlineupInfoType);

Expand Down Expand Up @@ -246,9 +246,6 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp
std::string name(match.data(), match.size());
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();

ChangeChannelResponseType response;
response.data = chip::MakeOptional(CharSpan::fromCharString("data response"));

ChipLogProgress(Zcl, "Received ChannelManager::HandleChangeChannel name %s", name.c_str());
VerifyOrExit(mChannelManagerObject != nullptr, ChipLogError(Zcl, "mChannelManagerObject null"));
VerifyOrExit(mChangeChannelMethod != nullptr, ChipLogError(Zcl, "mChangeChannelMethod null"));
Expand All @@ -268,10 +265,20 @@ void ChannelManager::HandleChangeChannel(CommandResponseHelper<ChangeChannelResp

jclass channelClass = env->GetObjectClass(channelObject);

ChangeChannelResponseType response;

jfieldID getStatusField = env->GetFieldID(channelClass, "status", "I");
jint jstatus = env->GetIntField(channelObject, getStatusField);
response.status = static_cast<app::Clusters::Channel::StatusEnum>(jstatus);

jfieldID getNameField = env->GetFieldID(channelClass, "name", "Ljava/lang/String;");
jstring jname = static_cast<jstring>(env->GetObjectField(channelObject, getNameField));
JniUtfString junitname(env, jname);
if (jname != NULL)
{
response.data = MakeOptional(junitname.charSpan());
}

helper.Success(response);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -32,23 +32,23 @@ 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;
this.callSign = callSign;
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="
Expand Down

0 comments on commit ad4ecfb

Please sign in to comment.