Skip to content

Commit 7dfa046

Browse files
Add the new getCapability() method to Isdl
1 parent f6c872e commit 7dfa046

4 files changed

Lines changed: 32 additions & 0 deletions

File tree

android/sdl_android/src/androidTest/java/com/smartdevicelink/test/proxy/SystemCapabilityManagerTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -998,6 +998,11 @@ public boolean removeOnRPCListener(FunctionID messageId, OnRPCListener listener)
998998
@Override
999999
public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener) { }
10001000

1001+
@Override
1002+
public Object getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener, boolean forceUpdate) {
1003+
return null;
1004+
}
1005+
10011006
@Override
10021007
public SdlMsgVersion getSdlMsgVersion(){
10031008
return null;

android/sdl_android/src/main/java/com/smartdevicelink/managers/SdlManager.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -866,6 +866,14 @@ public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCap
866866
proxy.getCapability(systemCapabilityType, scListener);
867867
}
868868

869+
@Override
870+
public Object getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener, boolean forceUpdate) {
871+
if (proxy.getSystemCapabilityManager() != null) {
872+
return proxy.getSystemCapabilityManager().getCapability(systemCapabilityType, scListener, forceUpdate);
873+
}
874+
return null;
875+
}
876+
869877
@Override
870878
public boolean isCapabilitySupported(SystemCapabilityType systemCapabilityType){
871879
return proxy.isCapabilitySupported(systemCapabilityType);

android/sdl_android/src/main/java/com/smartdevicelink/proxy/SdlProxyBase.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,6 +449,14 @@ public void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCap
449449
SdlProxyBase.this.getCapability(systemCapabilityType, scListener);
450450
}
451451

452+
@Override
453+
public Object getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener, boolean forceUpdate) {
454+
if (_systemCapabilityManager != null) {
455+
return _systemCapabilityManager.getCapability(systemCapabilityType, scListener, forceUpdate);
456+
}
457+
return null;
458+
}
459+
452460
@Override
453461
public SdlMsgVersion getSdlMsgVersion(){
454462
try {

base/src/main/java/com/smartdevicelink/proxy/interfaces/ISdl.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ public interface ISdl {
208208
* @param systemCapabilityType a system capability type that should be retrieved
209209
* @return the system capability provided if available, null if not
210210
*/
211+
@Deprecated
211212
Object getCapability(SystemCapabilityType systemCapabilityType);
212213

213214
/**
@@ -216,8 +217,18 @@ public interface ISdl {
216217
* @param scListener listener that will be called when the system capability is retrieved. If already cached, it
217218
* will be called immediately
218219
*/
220+
@Deprecated
219221
void getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener);
220222

223+
/** Gets the capability object that corresponds to the supplied capability type by returning the currently cached value immediately (or null) as well as calling the listener immediately with the cached value, if available. If not available, the listener will retrieve a new value and return that when the head unit responds.
224+
* <strong>If capability is not cached, the method will return null and trigger the supplied listener when the capability becomes available</strong>
225+
* @param systemCapabilityType type of capability desired
226+
* @param scListener callback to execute upon retrieving capability
227+
* @param forceUpdate flag to force getting a new fresh copy of the capability from the head unit even if it is cached
228+
* @return desired capability if it is cached in the manager, otherwise returns a null object
229+
*/
230+
Object getCapability(SystemCapabilityType systemCapabilityType, OnSystemCapabilityListener scListener, boolean forceUpdate);
231+
221232
/**
222233
* Check if capability is supported
223234
* @param systemCapabilityType a system capability type that should be checked for support

0 commit comments

Comments
 (0)