Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Android] Plumb ActiveModeDuration, ActiveModeThreshold, IdleModeDuration to android #32768

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ class DeviceProvisioningFragment : Fragment() {
requireActivity(),
getString(
R.string.icd_registration_completed,
icdDeviceInfo.userActiveModeTriggerHint.toString()
icdDeviceInfo.userActiveModeTriggerHint.toString(),
icdDeviceInfo.userActiveModeTriggerInstruction,
icdDeviceInfo.idleModeDuration.toString(),
icdDeviceInfo.activeModeDuration.toString(),
icdDeviceInfo.activeModeThreshold.toString()
),
Toast.LENGTH_LONG
)
Expand Down
8 changes: 6 additions & 2 deletions src/controller/java/AndroidDeviceControllerWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,9 @@ void AndroidDeviceControllerWrapper::OnReadCommissioningInfo(const chip::Control
memset(mUserActiveModeTriggerInstructionBuffer, 0x00, kUserActiveModeTriggerInstructionBufferLen);
CopyCharSpanToMutableCharSpan(info.icd.userActiveModeTriggerInstruction, mUserActiveModeTriggerInstruction);

ChipLogProgress(AppServer, "OnReadCommissioningInfo ICD - IdleModeDuration=%u activeModeDuration=%u activeModeThreshold=%u",
info.icd.idleModeDuration, info.icd.activeModeDuration, info.icd.activeModeThreshold);

env->CallVoidMethod(mJavaObjectRef.ObjectRef(), onReadCommissioningInfoMethod, static_cast<jint>(info.basic.vendorId),
static_cast<jint>(info.basic.productId), static_cast<jint>(info.network.wifi.endpoint),
static_cast<jint>(info.network.thread.endpoint));
Expand Down Expand Up @@ -1035,7 +1038,7 @@ void AndroidDeviceControllerWrapper::OnICDRegistrationComplete(chip::NodeId icdN
methodErr = chip::JniReferences::GetInstance().GetLocalClassRef(env, "chip/devicecontroller/ICDDeviceInfo", icdDeviceInfoClass);
VerifyOrReturn(methodErr == CHIP_NO_ERROR, ChipLogError(Controller, "Could not find class ICDDeviceInfo"));

icdDeviceInfoStructCtor = env->GetMethodID(icdDeviceInfoClass, "<init>", "([BILjava/lang/String;JJJJI)V");
icdDeviceInfoStructCtor = env->GetMethodID(icdDeviceInfoClass, "<init>", "([BILjava/lang/String;JJIJJJJI)V");
VerifyOrReturn(icdDeviceInfoStructCtor != nullptr, ChipLogError(Controller, "Could not find ICDDeviceInfo constructor"));

methodErr =
Expand All @@ -1047,7 +1050,8 @@ void AndroidDeviceControllerWrapper::OnICDRegistrationComplete(chip::NodeId icdN

icdDeviceInfoObj = env->NewObject(
icdDeviceInfoClass, icdDeviceInfoStructCtor, jSymmetricKey, static_cast<jint>(mUserActiveModeTriggerHint.Raw()),
jUserActiveModeTriggerInstruction, static_cast<jlong>(icdNodeId), static_cast<jlong>(icdCounter),
jUserActiveModeTriggerInstruction, static_cast<jlong>(mIdleModeDuration), static_cast<jlong>(mActiveModeDuration),
static_cast<jint>(mActiveModeThreshold), static_cast<jlong>(icdNodeId), static_cast<jlong>(icdCounter),
static_cast<jlong>(mAutoCommissioner.GetCommissioningParameters().GetICDMonitoredSubject().Value()),
static_cast<jlong>(Controller()->GetFabricId()), static_cast<jint>(Controller()->GetFabricIndex()));

Expand Down
3 changes: 3 additions & 0 deletions src/controller/java/AndroidDeviceControllerWrapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,9 @@ class AndroidDeviceControllerWrapper : public chip::Controller::DevicePairingDel
chip::MutableCharSpan mUserActiveModeTriggerInstruction = chip::MutableCharSpan(mUserActiveModeTriggerInstructionBuffer);
chip::BitMask<chip::app::Clusters::IcdManagement::UserActiveModeTriggerBitmap> mUserActiveModeTriggerHint;

uint32_t mIdleModeDuration = 0;
uint32_t mActiveModeDuration = 0;
uint16_t mActiveModeThreshold = 0;
chip::Controller::CommissioningParameters mCommissioningParameter;

AndroidDeviceControllerWrapper(ChipDeviceControllerPtr controller,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ public int getBitIndex() {
private final byte[] symmetricKey;
private final Set<UserActiveModeTriggerBitmap> userActiveModeTriggerHint;
private final String userActiveModeTriggerInstruction;
private final long idleModeDuration;
private final long activeModeDuration;
private final int activeModeThreshold;
private final long icdNodeId;
private final long icdCounter;
private final long monitoredSubject;
Expand All @@ -66,6 +69,9 @@ public int getBitIndex() {
byte[] symmetricKey,
Set<UserActiveModeTriggerBitmap> userActiveModeTriggerHint,
String userActiveModeTriggerInstruction,
long idleModeDuration,
long activeModeDuration,
int activeModeThreshold,
long icdNodeId,
long icdCounter,
long monitoredSubject,
Expand All @@ -74,6 +80,9 @@ public int getBitIndex() {
this.symmetricKey = symmetricKey;
this.userActiveModeTriggerHint = userActiveModeTriggerHint;
this.userActiveModeTriggerInstruction = userActiveModeTriggerInstruction;
this.idleModeDuration = idleModeDuration;
this.activeModeDuration = activeModeDuration;
this.activeModeThreshold = activeModeThreshold;
this.icdNodeId = icdNodeId;
this.icdCounter = icdCounter;
this.monitoredSubject = monitoredSubject;
Expand All @@ -85,13 +94,19 @@ public int getBitIndex() {
byte[] symmetricKey,
int userActiveModeTriggerHintRaw,
String userActiveModeTriggerInstruction,
long idleModeDuration,
long activeModeDuration,
int activeModeThreshold,
long icdNodeId,
long icdCounter,
long monitoredSubject,
long fabricId,
int fabricIndex) {
this.symmetricKey = symmetricKey;
this.userActiveModeTriggerInstruction = userActiveModeTriggerInstruction;
this.idleModeDuration = idleModeDuration;
this.activeModeDuration = activeModeDuration;
this.activeModeThreshold = activeModeThreshold;
this.icdNodeId = icdNodeId;
this.icdCounter = icdCounter;
this.monitoredSubject = monitoredSubject;
Expand Down Expand Up @@ -122,6 +137,21 @@ public String getUserActiveModeTriggerInstruction() {
return userActiveModeTriggerInstruction;
}

/** Returns the GetIdleModeDuration. */
public long getIdleModeDuration() {
return idleModeDuration;
}

/** Returns the GetActiveModeDuration. */
public long getActiveModeDuration() {
return activeModeDuration;
}

/** Returns the GetActiveModeThreshold. */
public int getActiveModeThreshold() {
return activeModeThreshold;
}

/** Returns the ICD Node Id. */
public long getIcdNodeId() {
return icdNodeId;
Expand Down
Loading