The Android Developer Challenge is back! Submit your idea before December 2.

FakeKeyedAppStatesReporter

public class FakeKeyedAppStatesReporter
extends KeyedAppStatesReporter

java.lang.Object
   ↳ androidx.enterprise.feedback.KeyedAppStatesReporter
     ↳ androidx.enterprise.feedback.FakeKeyedAppStatesReporter


A fake KeyedAppStatesReporter for testing.

Example usage:

FakeKeyedAppStatesReporter reporter = new FakeKeyedAppStatesReporter();
   // Inject the reporter to the part of your code it will be used.
   assertThat(reporter.getKeyedAppStatesByKey().get("myKey").getMessage()).isEqualTo("expected");
 

Summary

Public constructors

FakeKeyedAppStatesReporter()

Public methods

List<KeyedAppState> getKeyedAppStates()

Get a list of all KeyedAppState instances that have been set.

Map<String, KeyedAppState> getKeyedAppStatesByKey()

Get a map of the latest KeyedAppState set for each key.

int getNumberOfUploads()

Get the number of times setStatesImmediate(Collection) has been called.

List<KeyedAppState> getOnDeviceKeyedAppStates()

Get a list of KeyedAppState instances that have been set but not yet uploaded.

Map<String, KeyedAppState> getOnDeviceKeyedAppStatesByKey()

Get a map of the latest KeyedAppState set for each key that has not yet uploaded.

List<KeyedAppState> getUploadedKeyedAppStates()

Get a list of KeyedAppState instances that have been set and uploaded.

Map<String, KeyedAppState> getUploadedKeyedAppStatesByKey()

Get a list of the latest KeyedAppState set for each key that has been uploaded.

void setStates(Collection<KeyedAppState> states)

Set app states to be sent to an EMM (enterprise mobility management).

void setStatesImmediate(Collection<KeyedAppState> states)

Record the set states and immediately mark all states as having been uploaded.

Inherited methods

Public constructors

FakeKeyedAppStatesReporter

public FakeKeyedAppStatesReporter ()

Public methods

getKeyedAppStates

public List<KeyedAppState> getKeyedAppStates ()

Get a list of all KeyedAppState instances that have been set.

This is in the order that they were set, and may contain multiple with the same key, if that key has been set twice.

Returns
List<KeyedAppState>

getKeyedAppStatesByKey

public Map<String, KeyedAppState> getKeyedAppStatesByKey ()

Get a map of the latest KeyedAppState set for each key.

Returns
Map<String, KeyedAppState>

getNumberOfUploads

public int getNumberOfUploads ()

Get the number of times setStatesImmediate(Collection) has been called.

Returns
int

getOnDeviceKeyedAppStates

public List<KeyedAppState> getOnDeviceKeyedAppStates ()

Get a list of KeyedAppState instances that have been set but not yet uploaded.

This is in the order that they were set, and may contain multiple with the same key, if that key has been set twice.

Once uploaded (using setStatesImmediate(Collection)) instances will no longer be returned by this method.

Returns
List<KeyedAppState>

getOnDeviceKeyedAppStatesByKey

public Map<String, KeyedAppState> getOnDeviceKeyedAppStatesByKey ()

Get a map of the latest KeyedAppState set for each key that has not yet uploaded.

Once uploaded (using setStatesImmediate(Collection)) instances will no longer be returned by this method.

Returns
Map<String, KeyedAppState>

getUploadedKeyedAppStates

public List<KeyedAppState> getUploadedKeyedAppStates ()

Get a list of KeyedAppState instances that have been set and uploaded.

This is in the order that they were set, and may contain multiple with the same key, if that key has been set twice.

States will be returned by this method if they were set using setStatesImmediate(Collection) or if setStatesImmediate(Collection) has been called since they were set.

Returns
List<KeyedAppState>

getUploadedKeyedAppStatesByKey

public Map<String, KeyedAppState> getUploadedKeyedAppStatesByKey ()

Get a list of the latest KeyedAppState set for each key that has been uploaded.

This is in the order that they were set, and may contain multiple with the same key, if that key has been set twice.

States will be returned by this method if they were set using setStatesImmediate(Collection) or if setStatesImmediate(Collection) has been called since they were set.

Returns
Map<String, KeyedAppState>

setStates

public void setStates (Collection<KeyedAppState> states)

Set app states to be sent to an EMM (enterprise mobility management). The EMM can then display this information to the management organization.

Do not send personally-identifiable information with this method.

Each provided keyed app state will replace any previously set keyed app states with the same key for this package name.

If multiple keyed app states are set with the same key, only one will be received by the EMM. Which will be received is not defined.

This information is sent immediately to all device owner and profile owner apps on the device. It is also sent immediately to the app with package name com.android.vending if it exists, which is the Play Store on GMS devices.

EMMs can access these states either directly in a custom DPC (device policy manager), via Android Management APIs, or via Play EMM APIs.

Parameters
states Collection

setStatesImmediate

public void setStatesImmediate (Collection<KeyedAppState> states)

Record the set states and immediately mark all states as having been uploaded.

Does not enforce any quota on uploading.

Parameters
states Collection