-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
ShadowContextHubClient.java
33 lines (28 loc) · 1.07 KB
/
ShadowContextHubClient.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package org.robolectric.shadows;
import android.hardware.location.ContextHubClient;
import android.hardware.location.ContextHubTransaction;
import android.hardware.location.NanoAppMessage;
import android.os.Build.VERSION_CODES;
import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
import org.robolectric.annotation.HiddenApi;
import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;
/** Shadow for {@link ContextHubClient}. */
@Implements(value = ContextHubClient.class, minSdk = VERSION_CODES.P, isInAndroidSdk = false)
public class ShadowContextHubClient {
private final List<NanoAppMessage> messages = new ArrayList<>();
@Implementation(minSdk = VERSION_CODES.P)
@HiddenApi
protected int sendMessageToNanoApp(NanoAppMessage message) {
messages.add(message);
return ContextHubTransaction.RESULT_SUCCESS;
}
@Implementation(minSdk = VERSION_CODES.P)
@HiddenApi
protected void close() {}
public List<NanoAppMessage> getMessages() {
return ImmutableList.copyOf(messages);
}
}