Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit 7627fe1

Browse files
authored
Merge pull request #443 from openweave/feature/feature-dm-in-mobile-support-java
Add Java API for DataManagement in client side
2 parents 6aabfe6 + 4b56ffe commit 7627fe1

File tree

11 files changed

+2694
-44
lines changed

11 files changed

+2694
-44
lines changed

src/device-manager/java/Makefile.am

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ WeaveDeviceManager_jar_JAVA_SRCS = \
103103
nl/Weave/DeviceManager/WeaveDeviceException.java \
104104
nl/Weave/DeviceManager/DeviceFeatures.java \
105105
nl/Weave/DeviceManager/NevisPairingCodeDecoding.java \
106+
nl/Weave/DeviceManager/WeaveDeviceManager.java \
107+
nl/Weave/DataManagement/WdmClient.java \
108+
nl/Weave/DataManagement/WdmClientImpl.java \
109+
nl/Weave/DataManagement/GenericTraitUpdatableDataSink.java \
110+
nl/Weave/DataManagement/GenericTraitUpdatableDataSinkImpl.java \
111+
nl/Weave/DataManagement/WdmClientFactory.java \
112+
nl/Weave/DataManagement/ResourceIdentifier.java \
106113
$(NULL)
107114

108115
WeaveDeviceManager_jar_JFLAGS = -source 6 -target 6

src/device-manager/java/WeaveDeviceManager-JNI.cpp

Lines changed: 930 additions & 26 deletions
Large diffs are not rendered by default.
Lines changed: 344 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,344 @@
1+
/*
2+
3+
Copyright (c) 2020 Google LLC.
4+
All rights reserved.
5+
6+
Licensed under the Apache License, Version 2.0 (the "License");
7+
you may not use this file except in compliance with the License.
8+
You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
*/
18+
19+
/**
20+
* @file
21+
* Represents GenericTraitUpdatableDataSink Interface.
22+
*/
23+
24+
package nl.Weave.DataManagement;
25+
26+
import android.os.Build;
27+
import android.util.Log;
28+
29+
import java.math.BigInteger;
30+
import java.util.EnumSet;
31+
import java.util.Random;
32+
import java.util.HashMap;
33+
import java.util.Map;
34+
import java.util.Iterator;
35+
36+
public interface GenericTraitUpdatableDataSink
37+
{
38+
/**
39+
* Assigns the provided value to the given path as a signed integer value.
40+
*
41+
* @param path the proto path to the property to modify
42+
* @param value the int value to assign to the property
43+
* @param isConditional whether or not to allow overwriting any conflicting changes. If true, then if a later
44+
* version of the trait has modified this property and does not equal to required version from update,
45+
* this update will be dropped; otherwise, this value will overwrite the newer change
46+
*/
47+
public void setSigned(String path, int value, boolean isConditional);
48+
49+
/**
50+
* Assigns the provided value to the given path as a signed integer value.
51+
*
52+
* @param path the proto path to the property to modify
53+
* @param value the long value to assign to the property
54+
* @param isConditional whether or not to allow overwriting any conflicting changes. If true, then if a later
55+
* version of the trait has modified this property and does not equal to required version from update,
56+
* this update will be dropped; otherwise, this value will overwrite the newer change
57+
*/
58+
public void setSigned(String path, long value, boolean isConditional);
59+
60+
/**
61+
* Assigns the provided value to the given path as a signed integer value.
62+
*
63+
* @param path the proto path to the property to modify
64+
* @param value the BigInteger value to assign to the property
65+
* @param isConditional whether or not to allow overwriting any conflicting changes. If true, then if a later
66+
* version of the trait has modified this property and does not equal to required version from update,
67+
* this update will be dropped; otherwise, this value will overwrite the newer change
68+
*/
69+
public void setSigned(String path, BigInteger value, boolean isConditional);
70+
71+
/**
72+
* Assigns the provided value to the given path as an unsigned integer value.
73+
*
74+
* @param path the proto path to the property to modify
75+
* @param value the int value to assign to the property
76+
* @param isConditional whether or not to allow overwriting any conflicting changes. If true, then if a later
77+
* version of the trait has modified this property and does not equal to required version from update,
78+
* this update will be dropped; otherwise, this value will overwrite the newer change
79+
*/
80+
public void setUnsigned(String path, int value, boolean isConditional);
81+
82+
/**
83+
* Assigns the provided value to the given path as an unsigned integer value.
84+
*
85+
* @param path the proto path to the property to modify
86+
* @param value the int value to assign to the property
87+
* @param isConditional whether or not to allow overwriting any conflicting changes. If true, then if a later
88+
* version of the trait has modified this property and does not equal to required version from update,
89+
* this update will be dropped; otherwise, this value will overwrite the newer change
90+
*/
91+
public void setUnsigned(String path, long value, boolean isConditional);
92+
93+
/**
94+
* Assigns the provided value to the given path as an unsigned integer value.
95+
*
96+
* @param path the proto path to the property to modify
97+
* @param value the BigInteger value to assign to the property
98+
* @param isConditional whether or not to allow overwriting any conflicting changes. If true, then if a later
99+
* version of the trait has modified this property and does not equal to required version from update,
100+
* this update will be dropped; otherwise, this value will overwrite the newer change
101+
*/
102+
public void setUnsigned(String path, BigInteger value, boolean isConditional);
103+
104+
/**
105+
* Assigns the provided value to the given path.
106+
*
107+
* @param path the proto path to the property to modify
108+
* @param value the double value to assign to the property
109+
* @param isConditional whether or not to allow overwriting any conflicting changes. If true, then if a later
110+
* version of the trait has modified this property and does not equal to required version from update,
111+
* this update will be dropped; otherwise, this value will overwrite the newer change
112+
*/
113+
public void set(String path, double value, boolean isConditional);
114+
115+
/**
116+
* Assigns the provided value to the given path.
117+
*
118+
* @param path the proto path to the property to modify
119+
* @param value the boolean value to assign to the property
120+
* @param isConditional whether or not to allow overwriting any conflicting changes. If true, then if a later
121+
* version of the trait has modified this property and does not equal to required version from update,
122+
* this update will be dropped; otherwise, this value will overwrite the newer change
123+
*/
124+
public void set(String path, boolean value, boolean isConditional);
125+
126+
/**
127+
* Assigns the provided value to the given path.
128+
*
129+
* @param path the proto path to the property to modify
130+
* @param value the string value to assign to the property
131+
* @param isConditional whether or not to allow overwriting any conflicting changes. If true, then if a later
132+
* version of the trait has modified this property and does not equal to required version from update,
133+
* this update will be dropped; otherwise, this value will overwrite the newer change
134+
*/
135+
public void set(String path, String value, boolean isConditional);
136+
137+
/**
138+
* Assigns the provided value to the given path.
139+
*
140+
* @param path the proto path to the property to modify
141+
* @param value the bytes value to assign to the property
142+
* @param isConditional whether or not to allow overwriting any conflicting changes. If true, then if a later
143+
* version of the trait has modified this property and does not equal to required version from update,
144+
* this update will be dropped; otherwise, this value will overwrite the newer change
145+
*/
146+
public void set(String path, byte[] value, boolean isConditional);
147+
148+
/**
149+
* Assigns the provided value to the given path.
150+
*
151+
* @param path the proto path to the property to modify
152+
* @param value the string array value to assign to the property
153+
* @param isConditional whether or not to allow overwriting any conflicting changes. If true, then if a later
154+
* version of the trait has modified this property and does not equal to required version from update,
155+
* this update will be dropped; otherwise, this value will overwrite the newer change
156+
*/
157+
public void set(String path, String[] value, boolean isConditional);
158+
159+
/**
160+
* Assigns Null to the given path.
161+
*
162+
* @param path the proto path to the property to modify
163+
* @param isConditional whether or not to allow overwriting any conflicting changes. If true, then if a later
164+
* version of the trait has modified this property and does not equal to required version from update,
165+
* this update will be dropped; otherwise, this value will overwrite the newer change
166+
*/
167+
public void setNull(String path, boolean isConditional);
168+
169+
/**
170+
* Assigns the provided value to the given path as a signed integer value with unconditional capability
171+
*
172+
* @param path the proto path to the property to modify
173+
* @param value the int value to assign to the property
174+
*/
175+
public void setSigned(String path, int value);
176+
177+
/**
178+
* Assigns the provided value to the given path as a signed integer value with unconditional capability
179+
*
180+
* @param path the proto path to the property to modify
181+
* @param value the long value to assign to the property
182+
*/
183+
public void setSigned(String path, long value);
184+
185+
/**
186+
* Assigns the provided value to the given path as a signed integer value with unconditional capability
187+
*
188+
* @param path the proto path to the property to modify
189+
* @param value the BigInteger value to assign to the property
190+
*/
191+
public void setSigned(String path, BigInteger value);
192+
193+
/**
194+
* Assigns the provided value to the given path as a unsigned integer value with unconditional capability
195+
*
196+
* @param path the proto path to the property to modify
197+
* @param value the int value to assign to the property
198+
*/
199+
public void setUnsigned(String path, int value);
200+
201+
/**
202+
* Assigns the provided value to the given path as a unsigned integer value with unconditional capability
203+
*
204+
* @param path the proto path to the property to modify
205+
* @param value the long value to assign to the property
206+
*/
207+
public void setUnsigned(String path, long value);
208+
209+
/**
210+
* Assigns the provided value to the given path as a unsigned integer value with unconditional capability
211+
*
212+
* @param path the proto path to the property to modify
213+
* @param value the BigInteger value to assign to the property
214+
*/
215+
public void setUnsigned(String path, BigInteger value);
216+
217+
/**
218+
* Assigns the provided value to the given path with unconditional capability
219+
*
220+
* @param path the proto path to the property to modify
221+
* @param value the double value to assign to the property
222+
*/
223+
public void set(String path, double value);
224+
225+
/**
226+
* Assigns the provided value to the given path with unconditional capability
227+
*
228+
* @param path the proto path to the property to modify
229+
* @param value the boolean value to assign to the property
230+
*/
231+
public void set(String path, boolean value);
232+
233+
/**
234+
* Assigns the provided value to the given path with unconditional capability
235+
*
236+
* @param path the proto path to the property to modify
237+
* @param value the String value to assign to the property
238+
*/
239+
public void set(String path, String value);
240+
241+
/**
242+
* Assigns the provided value to the given path with unconditional capability
243+
*
244+
* @param path the proto path to the property to modify
245+
* @param value the bytes value to assign to the property
246+
*/
247+
public void set(String path, byte[] value);
248+
249+
/**
250+
* Assigns the provided value to the given path with unconditional capability
251+
*
252+
* @param path the proto path to the property to modify
253+
* @param value the string array to assign to the property
254+
*/
255+
public void set(String path, String[] value);
256+
257+
/**
258+
* Assigns Null to the given path with unconditional capability
259+
*
260+
* @param path the proto path to the property to modify
261+
*/
262+
public void setNull(String path);
263+
264+
/**
265+
* Returns the int value assigned to the property at the given path within this trait.
266+
*
267+
* @throws Exception if no property exists at this path, or if the type of the property does not match
268+
*/
269+
public int getInt(String path);
270+
271+
/**
272+
* Returns the long value assigned to the property at the given path within this trait.
273+
*
274+
* @throws Exception if no property exists at this path, or if the type of the property does not match
275+
*/
276+
public long getLong(String path);
277+
278+
/**
279+
* Returns the BigInteger value assigned to the property at the given path within this trait.
280+
*
281+
* @throws Exception if no property exists at this path, or if the type of the property does not match
282+
*/
283+
public BigInteger getBigInteger(String path);
284+
285+
/**
286+
* Returns the double value assigned to the property at the given path within this trait.
287+
*
288+
* @throws Exception if no property exists at this path, or if the type of the property does not match
289+
*/
290+
public double getDouble(String path);
291+
292+
/**
293+
* Returns the Boolean value assigned to the property at the given path within this trait.
294+
*
295+
* @throws Exception if no property exists at this path, or if the type of the property does not match
296+
*/
297+
public boolean getBoolean(String path);
298+
299+
/**
300+
* Returns the string value assigned to the property at the given path within this trait.
301+
*
302+
* @throws Exception if no property exists at this path, or if the type of the property does not match
303+
*/
304+
public String getString(String path);
305+
306+
/**
307+
* Returns the Bytes value assigned to the property at the given path within this trait.
308+
*
309+
* @throws Exception if no property exists at this path, or if the type of the property does not match
310+
*/
311+
public byte[] getBytes(String path);
312+
313+
/**
314+
* Check if null property at the given path within this trait.
315+
*
316+
* @throws Exception if no property exists at this path, or if the type of the property does not match
317+
*/
318+
public boolean isNull(String path);
319+
320+
/**
321+
* Returns the string array assigned to the property at the given path within this trait.
322+
*
323+
* @throws Exception if no property exists at this path, or if the type of the property does not match
324+
*/
325+
public String[] getStringArray(String path);
326+
327+
/** Returns the version of the trait represented by this data sink. */
328+
public long getVersion();
329+
330+
/**
331+
* Begins a sync of the trait data. The result of this operation can be observed through the {@link CompletionHandler}
332+
* that has been assigned via {@link #setCompletionHandler}.
333+
*/
334+
public void beginRefreshData();
335+
336+
public CompletionHandler getCompletionHandler();
337+
public void setCompletionHandler(CompletionHandler compHandler);
338+
339+
public interface CompletionHandler
340+
{
341+
void onRefreshDataComplete();
342+
void onError(Throwable err);
343+
}
344+
};

0 commit comments

Comments
 (0)