Skip to content

Commit 1722828

Browse files
xylophone21pull[bot]
authored andcommitted
added Java DAC Provider (#16059)
1 parent ce648f3 commit 1722828

File tree

11 files changed

+337
-2
lines changed

11 files changed

+337
-2
lines changed

examples/tv-app/android/App/app/src/main/java/com/tcl/chip/chiptvserver/service/MatterServant.java

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.tcl.chip.tvapp.ChannelManagerStub;
3131
import com.tcl.chip.tvapp.Clusters;
3232
import com.tcl.chip.tvapp.ContentLaunchManagerStub;
33+
import com.tcl.chip.tvapp.DACProviderStub;
3334
import com.tcl.chip.tvapp.KeypadInputManagerStub;
3435
import com.tcl.chip.tvapp.LowPowerManagerStub;
3536
import com.tcl.chip.tvapp.MediaInputManagerStub;
@@ -79,6 +80,7 @@ public void init(@NonNull Context context) {
7980
break;
8081
}
8182
});
83+
tvApp.setDACProvider(new DACProviderStub());
8284

8385
Context applicationContext = context.getApplicationContext();
8486
AndroidChipPlatform chipPlatform =

examples/tv-app/android/BUILD.gn

+4
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ shared_library("jni") {
4242
"java/ChannelManager.h",
4343
"java/ContentLauncherManager.cpp",
4444
"java/ContentLauncherManager.h",
45+
"java/JNIDACProvider.cpp",
46+
"java/JNIDACProvider.h",
4547
"java/KeypadInputManager.cpp",
4648
"java/KeypadInputManager.h",
4749
"java/LowPowerManager.cpp",
@@ -93,6 +95,8 @@ android_library("java") {
9395
"java/src/com/tcl/chip/tvapp/ContentLaunchManagerStub.java",
9496
"java/src/com/tcl/chip/tvapp/ContentLaunchResponse.java",
9597
"java/src/com/tcl/chip/tvapp/ContentLaunchSearchParameter.java",
98+
"java/src/com/tcl/chip/tvapp/DACProvider.java",
99+
"java/src/com/tcl/chip/tvapp/DACProviderStub.java",
96100
"java/src/com/tcl/chip/tvapp/KeypadInputManager.java",
97101
"java/src/com/tcl/chip/tvapp/KeypadInputManagerStub.java",
98102
"java/src/com/tcl/chip/tvapp/LowPowerManager.java",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
/*
2+
*
3+
* Copyright (c) 2021 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#include "JNIDACProvider.h"
19+
#include "lib/support/logging/CHIPLogging.h"
20+
#include <credentials/CHIPCert.h>
21+
#include <crypto/CHIPCryptoPAL.h>
22+
#include <cstdlib>
23+
#include <jni.h>
24+
#include <lib/core/CHIPError.h>
25+
#include <lib/support/CHIPJNIError.h>
26+
#include <lib/support/JniReferences.h>
27+
#include <lib/support/JniTypeWrappers.h>
28+
#include <lib/support/Span.h>
29+
30+
using namespace chip;
31+
32+
JNIDACProvider::JNIDACProvider(jobject provider)
33+
{
34+
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
35+
VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Failed to GetEnvForCurrentThread for JNIDACProvider"));
36+
37+
mJNIDACProviderObject = env->NewGlobalRef(provider);
38+
VerifyOrReturn(mJNIDACProviderObject != nullptr, ChipLogError(Zcl, "Failed to NewGlobalRef JNIDACProvider"));
39+
40+
jclass JNIDACProviderClass = env->GetObjectClass(provider);
41+
VerifyOrReturn(JNIDACProviderClass != nullptr, ChipLogError(Zcl, "Failed to get JNIDACProvider Java class"));
42+
43+
mGetCertificationDeclarationMethod = env->GetMethodID(JNIDACProviderClass, "GetCertificationDeclaration", "()[B");
44+
if (mGetCertificationDeclarationMethod == nullptr)
45+
{
46+
ChipLogError(Zcl, "Failed to access JNIDACProvider 'GetCertificationDeclaration' method");
47+
env->ExceptionClear();
48+
}
49+
50+
mGetFirmwareInformationMethod = env->GetMethodID(JNIDACProviderClass, "GetFirmwareInformation", "()[B");
51+
if (mGetFirmwareInformationMethod == nullptr)
52+
{
53+
ChipLogError(Zcl, "Failed to access JNIDACProvider 'GetFirmwareInformation' method");
54+
env->ExceptionClear();
55+
}
56+
57+
mGetDeviceAttestationCertMethod = env->GetMethodID(JNIDACProviderClass, "GetDeviceAttestationCert", "()[B");
58+
if (mGetDeviceAttestationCertMethod == nullptr)
59+
{
60+
ChipLogError(Zcl, "Failed to access JNIDACProvider 'GetDeviceAttestationCert' method");
61+
env->ExceptionClear();
62+
}
63+
64+
mGetProductAttestationIntermediateCertMethod =
65+
env->GetMethodID(JNIDACProviderClass, "GetProductAttestationIntermediateCert", "()[B");
66+
if (mGetProductAttestationIntermediateCertMethod == nullptr)
67+
{
68+
ChipLogError(Zcl, "Failed to access JNIDACProvider 'GetProductAttestationIntermediateCert' method");
69+
env->ExceptionClear();
70+
}
71+
72+
mGetDeviceAttestationCertPrivateKeyMethod = env->GetMethodID(JNIDACProviderClass, "GetDeviceAttestationCertPrivateKey", "()[B");
73+
if (mGetDeviceAttestationCertPrivateKeyMethod == nullptr)
74+
{
75+
ChipLogError(Zcl, "Failed to access JNIDACProvider 'GetDeviceAttestationCertPrivateKey' method");
76+
env->ExceptionClear();
77+
}
78+
79+
mGetDeviceAttestationCertPublicKeyKeyMethod =
80+
env->GetMethodID(JNIDACProviderClass, "GetDeviceAttestationCertPublicKeyKey", "()[B");
81+
if (mGetDeviceAttestationCertPublicKeyKeyMethod == nullptr)
82+
{
83+
ChipLogError(Zcl, "Failed to access JNIDACProvider 'GetDeviceAttestationCertPublicKeyKey' method");
84+
env->ExceptionClear();
85+
}
86+
}
87+
88+
CHIP_ERROR JNIDACProvider::GetJavaByteByMethod(jmethodID method, MutableByteSpan & out_buffer)
89+
{
90+
JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread();
91+
VerifyOrReturnLogError(mJNIDACProviderObject != nullptr, CHIP_ERROR_INCORRECT_STATE);
92+
VerifyOrReturnLogError(method != nullptr, CHIP_ERROR_INCORRECT_STATE);
93+
VerifyOrReturnLogError(env != nullptr, CHIP_JNI_ERROR_NO_ENV);
94+
95+
jbyteArray outArray = (jbyteArray) env->CallObjectMethod(mJNIDACProviderObject, method);
96+
if (env->ExceptionCheck())
97+
{
98+
ChipLogError(Zcl, "Java exception in get Method");
99+
env->ExceptionDescribe();
100+
env->ExceptionClear();
101+
return CHIP_ERROR_INCORRECT_STATE;
102+
}
103+
104+
if (outArray == nullptr || env->GetArrayLength(outArray) <= 0)
105+
{
106+
out_buffer.reduce_size(0);
107+
return CHIP_NO_ERROR;
108+
}
109+
110+
JniByteArray JniOutArray(env, outArray);
111+
return CopySpanToMutableSpan(JniOutArray.byteSpan(), out_buffer);
112+
}
113+
114+
CHIP_ERROR JNIDACProvider::GetCertificationDeclaration(MutableByteSpan & out_cd_buffer)
115+
{
116+
ChipLogProgress(Zcl, "Received GetCertificationDeclaration");
117+
return GetJavaByteByMethod(mGetCertificationDeclarationMethod, out_cd_buffer);
118+
}
119+
120+
CHIP_ERROR JNIDACProvider::GetFirmwareInformation(MutableByteSpan & out_firmware_info_buffer)
121+
{
122+
ChipLogProgress(Zcl, "Received GetFirmwareInformation");
123+
return GetJavaByteByMethod(mGetFirmwareInformationMethod, out_firmware_info_buffer);
124+
}
125+
126+
CHIP_ERROR JNIDACProvider::GetDeviceAttestationCert(MutableByteSpan & out_dac_buffer)
127+
{
128+
ChipLogProgress(Zcl, "Received GetDeviceAttestationCert");
129+
return GetJavaByteByMethod(mGetDeviceAttestationCertMethod, out_dac_buffer);
130+
}
131+
132+
CHIP_ERROR JNIDACProvider::GetProductAttestationIntermediateCert(MutableByteSpan & out_pai_buffer)
133+
{
134+
ChipLogProgress(Zcl, "Received GetProductAttestationIntermediateCert");
135+
return GetJavaByteByMethod(mGetProductAttestationIntermediateCertMethod, out_pai_buffer);
136+
}
137+
138+
// TODO: This should be moved to a method of P256Keypair
139+
CHIP_ERROR LoadKeypairFromRaw(ByteSpan private_key, ByteSpan public_key, Crypto::P256Keypair & keypair)
140+
{
141+
Crypto::P256SerializedKeypair serialized_keypair;
142+
ReturnErrorOnFailure(serialized_keypair.SetLength(private_key.size() + public_key.size()));
143+
memcpy(serialized_keypair.Bytes(), public_key.data(), public_key.size());
144+
memcpy(serialized_keypair.Bytes() + public_key.size(), private_key.data(), private_key.size());
145+
return keypair.Deserialize(serialized_keypair);
146+
}
147+
148+
CHIP_ERROR JNIDACProvider::SignWithDeviceAttestationKey(const ByteSpan & digest_to_sign, MutableByteSpan & out_signature_buffer)
149+
{
150+
ChipLogProgress(Zcl, "Received SignWithDeviceAttestationKey");
151+
Crypto::P256ECDSASignature signature;
152+
Crypto::P256Keypair keypair;
153+
154+
VerifyOrReturnError(IsSpanUsable(out_signature_buffer), CHIP_ERROR_INVALID_ARGUMENT);
155+
VerifyOrReturnError(IsSpanUsable(digest_to_sign), CHIP_ERROR_INVALID_ARGUMENT);
156+
VerifyOrReturnError(out_signature_buffer.size() >= signature.Capacity(), CHIP_ERROR_BUFFER_TOO_SMALL);
157+
158+
uint8_t privateKeyBuf[Crypto::kP256_PrivateKey_Length];
159+
MutableByteSpan privateKeyBufSpan(privateKeyBuf);
160+
ReturnErrorOnFailure(GetJavaByteByMethod(mGetDeviceAttestationCertPrivateKeyMethod, privateKeyBufSpan));
161+
162+
uint8_t publicKeyBuf[Crypto::kP256_PublicKey_Length];
163+
MutableByteSpan publicKeyBufSpan(publicKeyBuf);
164+
ReturnErrorOnFailure(GetJavaByteByMethod(mGetDeviceAttestationCertPublicKeyKeyMethod, publicKeyBufSpan));
165+
166+
// In a non-exemplary implementation, the public key is not needed here. It is used here merely because
167+
// Crypto::P256Keypair is only (currently) constructable from raw keys if both private/public keys are present.
168+
ReturnErrorOnFailure(LoadKeypairFromRaw(privateKeyBufSpan, publicKeyBufSpan, keypair));
169+
ReturnErrorOnFailure(keypair.ECDSA_sign_hash(digest_to_sign.data(), digest_to_sign.size(), signature));
170+
171+
return CopySpanToMutableSpan(ByteSpan{ signature.ConstBytes(), signature.Length() }, out_signature_buffer);
172+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
*
3+
* Copyright (c) 2021 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
#pragma once
18+
19+
#include "lib/support/logging/CHIPLogging.h"
20+
#include <credentials/DeviceAttestationCredsProvider.h>
21+
#include <jni.h>
22+
23+
class JNIDACProvider : public chip::Credentials::DeviceAttestationCredentialsProvider
24+
{
25+
public:
26+
JNIDACProvider(jobject provider);
27+
CHIP_ERROR GetCertificationDeclaration(chip::MutableByteSpan & out_cd_buffer) override;
28+
CHIP_ERROR GetFirmwareInformation(chip::MutableByteSpan & out_firmware_info_buffer) override;
29+
CHIP_ERROR GetDeviceAttestationCert(chip::MutableByteSpan & out_dac_buffer) override;
30+
CHIP_ERROR GetProductAttestationIntermediateCert(chip::MutableByteSpan & out_pai_buffer) override;
31+
CHIP_ERROR SignWithDeviceAttestationKey(const chip::ByteSpan & digest_to_sign,
32+
chip::MutableByteSpan & out_signature_buffer) override;
33+
34+
private:
35+
CHIP_ERROR GetJavaByteByMethod(jmethodID method, chip::MutableByteSpan & out_buffer);
36+
jobject mJNIDACProviderObject = nullptr;
37+
jmethodID mGetCertificationDeclarationMethod = nullptr;
38+
jmethodID mGetFirmwareInformationMethod = nullptr;
39+
jmethodID mGetDeviceAttestationCertMethod = nullptr;
40+
jmethodID mGetProductAttestationIntermediateCertMethod = nullptr;
41+
jmethodID mGetDeviceAttestationCertPrivateKeyMethod = nullptr;
42+
jmethodID mGetDeviceAttestationCertPublicKeyKeyMethod = nullptr;
43+
};

examples/tv-app/android/java/TVApp-JNI.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@
1919
#include "TvApp-JNI.h"
2020
#include "ChannelManager.h"
2121
#include "ContentLauncherManager.h"
22+
#include "JNIDACProvider.h"
2223
#include "KeypadInputManager.h"
2324
#include "LowPowerManager.h"
2425
#include "MediaInputManager.h"
2526
#include "MediaPlaybackManager.h"
2627
#include "WakeOnLanManager.h"
28+
#include "credentials/DeviceAttestationCredsProvider.h"
2729
#include <app/server/java/AndroidAppServerWrapper.h>
2830
#include <jni.h>
2931
#include <lib/core/CHIPError.h>
@@ -119,3 +121,12 @@ JNI_METHOD(void, setChannelManager)(JNIEnv *, jobject, jint endpoint, jobject ma
119121
{
120122
ChannelManager::NewManager(endpoint, manager);
121123
}
124+
125+
JNI_METHOD(void, setDACProvider)(JNIEnv *, jobject, jobject provider)
126+
{
127+
if (!chip::Credentials::IsDeviceAttestationCredentialsProviderSet())
128+
{
129+
JNIDACProvider * p = new JNIDACProvider(provider);
130+
chip::Credentials::SetDeviceAttestationCredentialsProvider(p);
131+
}
132+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*
2+
* Copyright (c) 2021 Project CHIP Authors
3+
* All rights reserved.
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
package com.tcl.chip.tvapp;
19+
20+
public interface DACProvider {
21+
byte[] GetCertificationDeclaration();
22+
23+
byte[] GetFirmwareInformation();
24+
25+
byte[] GetDeviceAttestationCert();
26+
27+
byte[] GetProductAttestationIntermediateCert();
28+
29+
byte[] GetDeviceAttestationCertPrivateKey();
30+
31+
byte[] GetDeviceAttestationCertPublicKeyKey();
32+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
package com.tcl.chip.tvapp;
2+
3+
import android.util.Base64;
4+
5+
public class DACProviderStub implements DACProvider {
6+
7+
private String kDevelopmentDAC_Cert_FFF1_8001 =
8+
"MIIB5zCCAY6gAwIBAgIIac3xDenlTtEwCgYIKoZIzj0EAwIwPTElMCMGA1UEAwwcTWF0dGVyIERldiBQQUkgMHhGRkYxIG5vIFBJRDEUMBIGCisGAQQBgqJ8AgEMBEZGRjEwIBcNMjIwMjA1MDAwMDAwWhgPOTk5OTEyMzEyMzU5NTlaMFMxJTAjBgNVBAMMHE1hdHRlciBEZXYgREFDIDB4RkZGMS8weDgwMDExFDASBgorBgEEAYKifAIBDARGRkYxMRQwEgYKKwYBBAGConwCAgwEODAwMTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABEY6xpNCkQoOVYj8b/Vrtj5i7M7LFI99TrA+5VJgFBV2fRalxmP3k+SRIyYLgpenzX58/HsxaznZjpDSk3dzjoKjYDBeMAwGA1UdEwEB/wQCMAAwDgYDVR0PAQH/BAQDAgeAMB0GA1UdDgQWBBSI3eezADgpMs/3NMBGJIEPRBaKbzAfBgNVHSMEGDAWgBRjVA5H9kscONE4hKRi0WwZXY/7PDAKBggqhkjOPQQDAgNHADBEAiABJ6J7S0RhDuL83E0reIVWNmC8D3bxchntagjfsrPBzQIga1ngr0Xz6yqFuRnTVzFSjGAoxBUjlUXhCOTlTnCXE1M=";
9+
10+
private String kDevelopmentDAC_PrivateKey_FFF1_8001 =
11+
"qrYAroroqrfXNifCF7fCBHCcppRq9fL3UwgzpStE+/8=";
12+
13+
private String kDevelopmentDAC_PublicKey_FFF1_8001 =
14+
"BEY6xpNCkQoOVYj8b/Vrtj5i7M7LFI99TrA+5VJgFBV2fRalxmP3k+SRIyYLgpenzX58/HsxaznZjpDSk3dzjoI=";
15+
16+
private String KPAI_FFF1_8000_Cert_Array =
17+
"MIIByzCCAXGgAwIBAgIIVq2CIq2UW2QwCgYIKoZIzj0EAwIwMDEYMBYGA1UEAwwPTWF0dGVyIFRlc3QgUEFBMRQwEgYKKwYBBAGConwCAQwERkZGMTAgFw0yMjAyMDUwMDAwMDBaGA85OTk5MTIzMTIzNTk1OVowPTElMCMGA1UEAwwcTWF0dGVyIERldiBQQUkgMHhGRkYxIG5vIFBJRDEUMBIGCisGAQQBgqJ8AgEMBEZGRjEwWTATBgcqhkjOPQIBBggqhkjOPQMBBwNCAARBmpMVwhc+DIyHbQPM/JRIUmR/f+xeUIL0BZko7KiUxZQVEwmsYx5MsDOSr2hLC6+35ls7gWLC9Sv5MbjneqqCo2YwZDASBgNVHRMBAf8ECDAGAQH/AgEAMA4GA1UdDwEB/wQEAwIBBjAdBgNVHQ4EFgQUY1QOR/ZLHDjROISkYtFsGV2P+zwwHwYDVR0jBBgwFoAUav0idx9RH+y/FkGXZxDc3DGhcX4wCgYIKoZIzj0EAwIDSAAwRQIhALLvJ/Sa6bUPuR7qyUxNC9u415KcbLiPrOUpNo0SBUwMAiBlXckrhr2QmIKmxiF3uCXX0F7b58Ivn+pxIg5+pwP4kQ==";
18+
19+
/**
20+
* format_version = 1 vendor_id = 0xFFF1 product_id_array = [ 0x8000,0x8001...0x8063]
21+
* device_type_id = 0x1234 certificate_id = "ZIG20141ZB330001-24" security_level = 0
22+
* security_information = 0 version_number = 0x2694 certification_type = 0 dac_origin_vendor_id is
23+
* not present dac_origin_product_id is not present
24+
*/
25+
private String kCertificationDeclaration =
26+
"MIICGQYJKoZIhvcNAQcCoIICCjCCAgYCAQMxDTALBglghkgBZQMEAgEwggFxBgkqhkiG9w0BBwGgggFiBIIBXhUkAAElAfH/NgIFAIAFAYAFAoAFA4AFBIAFBYAFBoAFB4AFCIAFCYAFCoAFC4AFDIAFDYAFDoAFD4AFEIAFEYAFEoAFE4AFFIAFFYAFFoAFF4AFGIAFGYAFGoAFG4AFHIAFHYAFHoAFH4AFIIAFIYAFIoAFI4AFJIAFJYAFJoAFJ4AFKIAFKYAFKoAFK4AFLIAFLYAFLoAFL4AFMIAFMYAFMoAFM4AFNIAFNYAFNoAFN4AFOIAFOYAFOoAFO4AFPIAFPYAFPoAFP4AFQIAFQYAFQoAFQ4AFRIAFRYAFRoAFR4AFSIAFSYAFSoAFS4AFTIAFTYAFToAFT4AFUIAFUYAFUoAFU4AFVIAFVYAFVoAFV4AFWIAFWYAFWoAFW4AFXIAFXYAFXoAFX4AFYIAFYYAFYoAFY4AYJAMWLAQTWklHMjAxNDJaQjMzMDAwMy0yNCQFACQGACUHlCYkCAAYMX0wewIBA4AUYvqCM1ms+qmWPhz6FArd9QTzcWAwCwYJYIZIAWUDBAIBMAoGCCqGSM49BAMCBEcwRQIgJOXR9Hp9ew0gaibvaZt8l1e3LUaQid4xkuZ4x0Xn9gwCIQD4qi+nEfy3m5fjl87aZnuuRk4r0//fw8zteqjKX0wafA==";
27+
28+
@Override
29+
public byte[] GetCertificationDeclaration() {
30+
return Base64.decode(kCertificationDeclaration, Base64.DEFAULT);
31+
}
32+
33+
@Override
34+
public byte[] GetFirmwareInformation() {
35+
return new byte[0];
36+
}
37+
38+
@Override
39+
public byte[] GetDeviceAttestationCert() {
40+
return Base64.decode(kDevelopmentDAC_Cert_FFF1_8001, Base64.DEFAULT);
41+
}
42+
43+
@Override
44+
public byte[] GetProductAttestationIntermediateCert() {
45+
return Base64.decode(KPAI_FFF1_8000_Cert_Array, Base64.DEFAULT);
46+
}
47+
48+
@Override
49+
public byte[] GetDeviceAttestationCertPrivateKey() {
50+
return Base64.decode(kDevelopmentDAC_PrivateKey_FFF1_8001, Base64.DEFAULT);
51+
}
52+
53+
@Override
54+
public byte[] GetDeviceAttestationCertPublicKeyKey() {
55+
return Base64.decode(kDevelopmentDAC_PublicKey_FFF1_8001, Base64.DEFAULT);
56+
}
57+
}

examples/tv-app/android/java/src/com/tcl/chip/tvapp/TvApp.java

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ private void postClusterInit(int clusterId, int endpoint) {
5151

5252
public native void setChannelManager(int endpoint, ChannelManager manager);
5353

54+
public native void setDACProvider(DACProvider provider);
55+
5456
static {
5557
System.loadLibrary("TvApp");
5658
}

src/app/server/java/AndroidAppServerWrapper.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,10 @@ CHIP_ERROR ChipAndroidAppInit(void)
5151
err = chip::Server::GetInstance().Init(nullptr, CHIP_PORT, CHIP_UDC_PORT);
5252
SuccessOrExit(err);
5353

54-
// TODO: move load DAC to java
55-
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
54+
if (!IsDeviceAttestationCredentialsProviderSet())
55+
{
56+
SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider());
57+
}
5658

5759
exit:
5860
if (err != CHIP_NO_ERROR)

0 commit comments

Comments
 (0)