Skip to content

Commit e53d023

Browse files
authored
Merge branch 'project-chip:master' into toup-build-opt
2 parents 962ad8f + 7adac6e commit e53d023

File tree

13 files changed

+285
-122
lines changed

13 files changed

+285
-122
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
108 : Update vscode docker with java17 and fix java_home in java docker
1+
109 : [Tizen] Fix race when storing cert credentials

integrations/docker/images/stage-2/chip-build-tizen/tizen-sdk-installer/secret-tool.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def _save(self):
6161
self.fp.seek(0)
6262
self.fp.truncate()
6363
pickle.dump(self.secrets, self.fp)
64+
self.fp.flush()
6465
except IOError as e:
6566
print("ERROR: " + str(e), file=sys.stderr)
6667

@@ -92,14 +93,14 @@ def lookup(self, label: str, **kw):
9293
subparsers = parser.add_subparsers(dest='command', required=True)
9394

9495
parser_clear = subparsers.add_parser(
95-
"clear", help="Remove passward associated with given key value pairs")
96+
"clear", help="Remove password associated with given key value pairs")
9697
parser_clear.add_argument("-l", "--label", action='store', required=True,
9798
help="label for given key value pairs")
9899
parser_clear.add_argument("kw", nargs='*',
99100
help="key value pairs")
100101

101102
parser_store = subparsers.add_parser(
102-
"store", help="Store passward for given key value pairs")
103+
"store", help="Store password for given key value pairs")
103104
parser_store.add_argument("-l", "--label", action='store', required=True,
104105
help="label for given key value pairs")
105106
parser_store.add_argument("-p", "--password", action='store', required=True,
@@ -108,7 +109,7 @@ def lookup(self, label: str, **kw):
108109
help="key value pairs")
109110

110111
parser_lookup = subparsers.add_parser(
111-
"lookup", help="Retrieve passward associated with given key value pairs")
112+
"lookup", help="Retrieve password associated with given key value pairs")
112113
parser_lookup.add_argument("-l", "--label", action='store', required=True,
113114
help="label for given key value pairs")
114115
parser_lookup.add_argument("kw", nargs='*',

scripts/py_matter_idl/matter_idl/generators/java/ChipClusters_java.jinja

+14-9
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ import chip.devicecontroller.model.NodeState;
105105
import chip.devicecontroller.model.Status;
106106

107107
import javax.annotation.Nullable;
108+
import java.lang.ref.Cleaner;
108109
import java.util.ArrayList;
109110
import java.util.Arrays;
110111
import java.util.List;
@@ -169,10 +170,23 @@ public class ChipClusters {
169170

170171
private Optional<Long> timeoutMillis = Optional.empty();
171172

173+
private final Cleaner.Cleanable cleanable;
174+
172175
public BaseChipCluster(long devicePtr, int endpointId, long clusterId) {
173176
this.devicePtr = devicePtr;
174177
this.endpointId = endpointId;
175178
this.clusterId = clusterId;
179+
180+
this.cleanable =
181+
Cleaner.create()
182+
.register(
183+
this,
184+
() -> {
185+
if (chipClusterPtr != 0) {
186+
deleteCluster(chipClusterPtr);
187+
chipClusterPtr = 0;
188+
}
189+
});
176190
}
177191

178192
/**
@@ -241,15 +255,6 @@ public class ChipClusters {
241255

242256
@Deprecated
243257
public void deleteCluster(long chipClusterPtr) {}
244-
@SuppressWarnings("deprecation")
245-
protected void finalize() throws Throwable {
246-
super.finalize();
247-
248-
if (chipClusterPtr != 0) {
249-
deleteCluster(chipClusterPtr);
250-
chipClusterPtr = 0;
251-
}
252-
}
253258
}
254259

255260
abstract static class ReportCallbackImpl implements ReportCallback, SubscriptionEstablishedCallback, ResubscriptionAttemptCallback {

scripts/py_matter_idl/matter_idl/tests/outputs/several_clusters/java/ChipClusters.java

+14-9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import chip.devicecontroller.model.Status;
2929

3030
import javax.annotation.Nullable;
31+
import java.lang.ref.Cleaner;
3132
import java.util.ArrayList;
3233
import java.util.Arrays;
3334
import java.util.List;
@@ -92,10 +93,23 @@ public static abstract class BaseChipCluster {
9293

9394
private Optional<Long> timeoutMillis = Optional.empty();
9495

96+
private final Cleaner.Cleanable cleanable;
97+
9598
public BaseChipCluster(long devicePtr, int endpointId, long clusterId) {
9699
this.devicePtr = devicePtr;
97100
this.endpointId = endpointId;
98101
this.clusterId = clusterId;
102+
103+
this.cleanable =
104+
Cleaner.create()
105+
.register(
106+
this,
107+
() -> {
108+
if (chipClusterPtr != 0) {
109+
deleteCluster(chipClusterPtr);
110+
chipClusterPtr = 0;
111+
}
112+
});
99113
}
100114

101115
/**
@@ -164,15 +178,6 @@ protected void invoke(
164178

165179
@Deprecated
166180
public void deleteCluster(long chipClusterPtr) {}
167-
@SuppressWarnings("deprecation")
168-
protected void finalize() throws Throwable {
169-
super.finalize();
170-
171-
if (chipClusterPtr != 0) {
172-
deleteCluster(chipClusterPtr);
173-
chipClusterPtr = 0;
174-
}
175-
}
176181
}
177182

178183
abstract static class ReportCallbackImpl implements ReportCallback, SubscriptionEstablishedCallback, ResubscriptionAttemptCallback {

src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java

+14-9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import chip.devicecontroller.model.Status;
2929

3030
import javax.annotation.Nullable;
31+
import java.lang.ref.Cleaner;
3132
import java.util.ArrayList;
3233
import java.util.Arrays;
3334
import java.util.List;
@@ -92,10 +93,23 @@ public static abstract class BaseChipCluster {
9293

9394
private Optional<Long> timeoutMillis = Optional.empty();
9495

96+
private final Cleaner.Cleanable cleanable;
97+
9598
public BaseChipCluster(long devicePtr, int endpointId, long clusterId) {
9699
this.devicePtr = devicePtr;
97100
this.endpointId = endpointId;
98101
this.clusterId = clusterId;
102+
103+
this.cleanable =
104+
Cleaner.create()
105+
.register(
106+
this,
107+
() -> {
108+
if (chipClusterPtr != 0) {
109+
deleteCluster(chipClusterPtr);
110+
chipClusterPtr = 0;
111+
}
112+
});
99113
}
100114

101115
/**
@@ -164,15 +178,6 @@ protected void invoke(
164178

165179
@Deprecated
166180
public void deleteCluster(long chipClusterPtr) {}
167-
@SuppressWarnings("deprecation")
168-
protected void finalize() throws Throwable {
169-
super.finalize();
170-
171-
if (chipClusterPtr != 0) {
172-
deleteCluster(chipClusterPtr);
173-
chipClusterPtr = 0;
174-
}
175-
}
176181
}
177182

178183
abstract static class ReportCallbackImpl implements ReportCallback, SubscriptionEstablishedCallback, ResubscriptionAttemptCallback {

src/controller/java/src/chip/devicecontroller/BatchInvokeCallbackJni.java

+21-18
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,31 @@
1919

2020
import chip.devicecontroller.model.InvokeResponseData;
2121
import chip.devicecontroller.model.NoInvokeResponseData;
22+
import java.lang.ref.Cleaner;
2223
import java.util.Optional;
2324
import javax.annotation.Nullable;
2425

2526
/** JNI wrapper callback class for {@link InvokeCallback}. */
26-
public final class ExtendableInvokeCallbackJni {
27-
private final ExtendableInvokeCallback wrappedExtendableInvokeCallback;
27+
public final class BatchInvokeCallbackJni {
28+
private final BatchInvokeCallbackJni wrappedBatchInvokeCallback;
2829
private long callbackHandle;
2930

30-
public ExtendableInvokeCallbackJni(ExtendableInvokeCallback wrappedExtendableInvokeCallback) {
31-
this.wrappedExtendableInvokeCallback = wrappedExtendableInvokeCallback;
31+
private final Cleaner.Cleanable cleanable;
32+
33+
public BatchInvokeCallbackJni(BatchInvokeCallback wrappedBatchInvokeCallback) {
34+
this.wrappedBatchInvokeCallback = wrappedBatchInvokeCallback;
3235
this.callbackHandle = newCallback();
36+
37+
this.cleanable =
38+
Cleaner.create()
39+
.register(
40+
this,
41+
() -> {
42+
if (chipClusterPtr != 0) {
43+
deleteCluster(chipClusterPtr);
44+
chipClusterPtr = 0;
45+
}
46+
});
3347
}
3448

3549
long getCallbackHandle() {
@@ -41,7 +55,7 @@ long getCallbackHandle() {
4155
private native void deleteCallback(long callbackHandle);
4256

4357
private void onError(Exception e) {
44-
wrappedExtendableInvokeCallback.onError(e);
58+
wrappedBatchInvokeCallback.onError(e);
4559
}
4660

4761
private void onResponse(
@@ -74,21 +88,10 @@ private void onResponse(
7488
}
7589

7690
private void onNoResponse(int commandRef) {
77-
wrappedExtendableInvokeCallback.onNoResponse(NoInvokeResponseData.newInstance(commandRef));
91+
wrappedBatchInvokeCallback.onNoResponse(NoInvokeResponseData.newInstance(commandRef));
7892
}
7993

8094
private void onDone() {
81-
wrappedExtendableInvokeCallback.onDone();
82-
}
83-
84-
// TODO(#8578): Replace finalizer with PhantomReference.
85-
@SuppressWarnings("deprecation")
86-
protected void finalize() throws Throwable {
87-
super.finalize();
88-
89-
if (callbackHandle != 0) {
90-
deleteCallback(callbackHandle);
91-
callbackHandle = 0;
92-
}
95+
wrappedBatchInvokeCallback.onDone();
9396
}
9497
}

src/controller/java/src/chip/devicecontroller/ChipDeviceController.java

+14-10
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import chip.devicecontroller.model.ChipEventPath;
2727
import chip.devicecontroller.model.DataVersionFilter;
2828
import chip.devicecontroller.model.InvokeElement;
29+
import java.lang.ref.Cleaner;
2930
import java.time.ZoneOffset;
3031
import java.util.ArrayList;
3132
import java.util.Calendar;
@@ -44,6 +45,8 @@ public class ChipDeviceController {
4445
private ScanNetworksListener scanNetworksListener;
4546
private NOCChainIssuer nocChainIssuer;
4647

48+
private final Cleaner.Cleanable cleanable;
49+
4750
/**
4851
* To load class and jni, we need to new AndroidChipPlatform after jni load but before new
4952
* ChipDeviceController
@@ -67,6 +70,17 @@ public ChipDeviceController(ControllerParams params) {
6770
throw new NullPointerException("params cannot be null");
6871
}
6972
deviceControllerPtr = newDeviceController(params);
73+
74+
this.cleanable =
75+
Cleaner.create()
76+
.register(
77+
this,
78+
() -> {
79+
if (deviceControllerPtr != 0) {
80+
deleteDeviceController(deviceControllerPtr);
81+
deviceControllerPtr = 0;
82+
}
83+
});
7084
}
7185

7286
public void setCompletionListener(CompletionListener listener) {
@@ -1773,16 +1787,6 @@ private native void updateCommissioningICDRegistrationInfo(
17731787
System.loadLibrary("CHIPController");
17741788
}
17751789

1776-
@SuppressWarnings("deprecation")
1777-
protected void finalize() throws Throwable {
1778-
super.finalize();
1779-
1780-
if (deviceControllerPtr != 0) {
1781-
deleteDeviceController(deviceControllerPtr);
1782-
deviceControllerPtr = 0;
1783-
}
1784-
}
1785-
17861790
/** Interface to implement custom operational credentials issuer (NOC chain generation). */
17871791
public interface NOCChainIssuer {
17881792
/**

src/controller/java/src/chip/devicecontroller/ExtendableInvokeCallbackJni.java

+14-11
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
import chip.devicecontroller.model.InvokeResponseData;
2121
import chip.devicecontroller.model.NoInvokeResponseData;
22+
import java.lang.ref.Cleaner;
2223
import java.util.Optional;
2324
import javax.annotation.Nullable;
2425

@@ -27,9 +28,22 @@ public final class ExtendableInvokeCallbackJni {
2728
private final ExtendableInvokeCallback wrappedExtendableInvokeCallback;
2829
private long callbackHandle;
2930

31+
private final Cleaner.Cleanable cleanable;
32+
3033
public ExtendableInvokeCallbackJni(ExtendableInvokeCallback wrappedExtendableInvokeCallback) {
3134
this.wrappedExtendableInvokeCallback = wrappedExtendableInvokeCallback;
3235
this.callbackHandle = newCallback();
36+
37+
this.cleanable =
38+
Cleaner.create()
39+
.register(
40+
this,
41+
() -> {
42+
if (callbackHandle != 0) {
43+
deleteCallback(callbackHandle);
44+
callbackHandle = 0;
45+
}
46+
});
3347
}
3448

3549
long getCallbackHandle() {
@@ -80,15 +94,4 @@ private void onNoResponse(int commandRef) {
8094
private void onDone() {
8195
wrappedExtendableInvokeCallback.onDone();
8296
}
83-
84-
// TODO(#8578): Replace finalizer with PhantomReference.
85-
@SuppressWarnings("deprecation")
86-
protected void finalize() throws Throwable {
87-
super.finalize();
88-
89-
if (callbackHandle != 0) {
90-
deleteCallback(callbackHandle);
91-
callbackHandle = 0;
92-
}
93-
}
9497
}

src/controller/java/src/chip/devicecontroller/GetConnectedDeviceCallbackJni.java

+15-11
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,29 @@
1717
*/
1818
package chip.devicecontroller;
1919

20+
import java.lang.ref.Cleaner;
21+
2022
/** JNI wrapper callback class for getting a connected device. */
2123
public class GetConnectedDeviceCallbackJni {
2224
private final GetConnectedDeviceCallback wrappedCallback;
2325
private long callbackHandle;
2426

27+
private final Cleaner.Cleanable cleanable;
28+
2529
public GetConnectedDeviceCallbackJni(GetConnectedDeviceCallback wrappedCallback) {
2630
this.wrappedCallback = wrappedCallback;
2731
this.callbackHandle = newCallback(wrappedCallback);
32+
33+
this.cleanable =
34+
Cleaner.create()
35+
.register(
36+
this,
37+
() -> {
38+
if (callbackHandle != 0) {
39+
deleteCallback(callbackHandle);
40+
callbackHandle = 0;
41+
}
42+
});
2843
}
2944

3045
long getCallbackHandle() {
@@ -35,17 +50,6 @@ long getCallbackHandle() {
3550

3651
private native void deleteCallback(long callbackHandle);
3752

38-
// TODO(#8578): Replace finalizer with PhantomReference.
39-
@SuppressWarnings("deprecation")
40-
protected void finalize() throws Throwable {
41-
super.finalize();
42-
43-
if (callbackHandle != 0) {
44-
deleteCallback(callbackHandle);
45-
callbackHandle = 0;
46-
}
47-
}
48-
4953
/** Callbacks for getting a device connected with PASE or CASE, depending on the context. */
5054
public interface GetConnectedDeviceCallback {
5155
void onDeviceConnected(long devicePointer);

0 commit comments

Comments
 (0)