Class ShadowToneGenerator
Records all tones that were passed to the class.
This class uses _static_ state to store the tones that were passed to it. This is because users of the original class are expected to instantiate new instances of ToneGenerator on demand and clean up the instance after use. This makes it messy to grab the correct instance of ToneGenerator to properly shadow.
Additionally, there is a maximum number of tones that this class can support. Tones are stored in a first-in-first-out basis.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Stores data about a tone played by the ToneGenerator -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.common.collect.ImmutableList<ShadowToneGenerator.Tone>
This function returns the list of tones that the application requested to be played.static void
reset()
protected boolean
startTone
(int toneType, int durationMs) This method will intercept calls to startTone and record the played tone into a static list.
-
Constructor Details
-
ShadowToneGenerator
public ShadowToneGenerator()
-
-
Method Details
-
startTone
This method will intercept calls to startTone and record the played tone into a static list.Note in the original
ToneGenerator
, this function will start a tone. Subsequent calls to this function will cancel the currently playing tone and play a new tone instead. Since no tone is actually played and no process is started, this tone cannot be interrupted. -
getPlayedTones
This function returns the list of tones that the application requested to be played. Note that this will return all tones requested by all ToneGenerators.- Returns:
- A defensive copy of the list of tones played by all tone generators.
-
reset
-