FakeSplitInstallManager
public
class
FakeSplitInstallManager
extends Object
implements
SplitInstallManager
java.lang.Object | |
↳ | com.google.android.play.core.splitinstall.testing.FakeSplitInstallManager |
A fake implementation of the SplitInstallManager
. See FakeSplitInstallManagerFactory
.
Installed splits are not persisted across application sessions: if you close and reopen an app
using FakeSplitInstallManager
, you need to request the splits again.
Summary
Constants | |
---|---|
String |
TAG
|
Public constructors | |
---|---|
FakeSplitInstallManager(Context context, File splitsDir)
This constructor is deprecated.
Please use |
Public methods | |
---|---|
Task<Void>
|
cancelInstall(int sessionId)
Starts a request to cancel a pending split install. |
Task<Void>
|
deferredInstall(List<String> moduleNames)
Not implemented. |
Task<Void>
|
deferredLanguageInstall(List<Locale> languages)
Not implemented. |
Task<Void>
|
deferredLanguageUninstall(List<Locale> languages)
Not implemented. |
Task<Void>
|
deferredUninstall(List<String> moduleNames)
Not implemented. |
Set<String>
|
getInstalledLanguages()
Returns the languages that are currently installed. |
Set<String>
|
getInstalledModules()
Returns the modules that are currently installed (excluding the base module). |
Task<SplitInstallSessionState>
|
getSessionState(int sessionId)
Returns the current state of a split install session. |
Task<List<SplitInstallSessionState>>
|
getSessionStates()
This fake implementation just support one session state. |
void
|
registerListener(SplitInstallStateUpdatedListener listener)
Registers a listener for your app that is alerted of state changes for module install requests. |
void
|
setShouldNetworkError(boolean shouldNetworkError)
Sets whether the next split install should terminate in a network error. |
boolean
|
startConfirmationDialogForResult(SplitInstallSessionState sessionState, IntentSenderForResultStarter starter, int requestCode)
Not implemented. |
boolean
|
startConfirmationDialogForResult(SplitInstallSessionState sessionState, ActivityResultLauncher<IntentSenderRequest> activityResultLauncher)
Not implemented. |
boolean
|
startConfirmationDialogForResult(SplitInstallSessionState sessionState, Activity activity, int requestCode)
Not implemented. |
Task<Integer>
|
startInstall(SplitInstallRequest request)
Initiates a request to download and install split APKs for additional features or language resources. |
void
|
unregisterListener(SplitInstallStateUpdatedListener listener)
Unregisters a listener you previously registered using |
Inherited methods | |
---|---|
Constants
Public constructors
FakeSplitInstallManager
public FakeSplitInstallManager (Context context, File splitsDir)
This constructor is deprecated.
Please use FakeSplitInstallManagerFactory.createNewInstance(Context, File)
instead. The returned manager might not work as expected unless SplitCompat is priorly
initiated using SplitCompat.install(Context)
.
Creates a fake instance of SplitInstallManager
which can be used for testing.
Parameters | |
---|---|
context |
Context |
splitsDir |
File |
See also:
Public methods
cancelInstall
public Task<Void> cancelInstall (int sessionId)
Starts a request to cancel a pending split install.
Cancelling
requests are best-effort. You can monitor the
request state to listening for the SplitInstallSessionStatus.CANCELED
state.
Parameters | |
---|---|
sessionId |
int : the sessionId of the request you would like to cancel
|
Returns | |
---|---|
Task<Void> |
deferredInstall
public Task<Void> deferredInstall (List<String> moduleNames)
Not implemented.
Parameters | |
---|---|
moduleNames |
List : the names of the modules you want to install in the background
|
Returns | |
---|---|
Task<Void> |
deferredLanguageInstall
public Task<Void> deferredLanguageInstall (List<Locale> languages)
Not implemented.
Parameters | |
---|---|
languages |
List : the languages you want to install in the background
|
Returns | |
---|---|
Task<Void> |
deferredLanguageUninstall
public Task<Void> deferredLanguageUninstall (List<Locale> languages)
Not implemented.
Parameters | |
---|---|
languages |
List : the languages you want to uninstall in the background
|
Returns | |
---|---|
Task<Void> |
deferredUninstall
public Task<Void> deferredUninstall (List<String> moduleNames)
Not implemented.
Parameters | |
---|---|
moduleNames |
List : the names of the modules you want to uninstall in the background
|
Returns | |
---|---|
Task<Void> |
getInstalledLanguages
public Set<String> getInstalledLanguages ()
Returns the languages that are currently installed.
The app's default language is not included in the returned set.
Returns an empty set if an error occurs.
For Instant Apps, this API is not supported and the return value is undefined.
Note: Languages are considered installed even when they are emulated by SplitCompat
because they are accessible to the app.
Note: This method does NOT work if you are deploying your bundle onto your device from Android Studio via `Run...` or if you test it via Gradle's `assemble[Debug|Release|...]` or `install[Debug|Release|...]`. In such situation, this method always returns an empty list. The recommended way to test this method is by uploading your bundle to Internal App Sharing.
Returns | |
---|---|
Set<String> |
the languages that are currently installed |
getInstalledModules
public Set<String> getInstalledModules ()
Returns the modules that are currently installed (excluding the base module).
To learn more, read Manage installed modules.
Note: Modules are considered installed even when they are emulated by SplitCompat
because they are accessible to the app.
Returns | |
---|---|
Set<String> |
getSessionState
public Task<SplitInstallSessionState> getSessionState (int sessionId)
Returns the current state of a split install session.
You should not use the session state to determine
whether a module is installed. Instead, please use getInstalledModules()
.
To learn more, read Monitor the request state.
Parameters | |
---|---|
sessionId |
int : the Id for the session you want to status for
|
Returns | |
---|---|
Task<SplitInstallSessionState> |
getSessionStates
public Task<List<SplitInstallSessionState>> getSessionStates ()
This fake implementation just support one session state.
Returns | |
---|---|
Task<List<SplitInstallSessionState>> |
registerListener
public void registerListener (SplitInstallStateUpdatedListener listener)
Registers a listener for your app that is alerted of state changes for module install requests.
You should unregister the listener using unregisterListener(SplitInstallStateUpdatedListener)
when the request is
resolved. To learn more, read Monitor the
request state.
Parameters | |
---|---|
listener |
SplitInstallStateUpdatedListener : the SplitInstallStateUpdatedListener you want to register for your app
|
setShouldNetworkError
public void setShouldNetworkError (boolean shouldNetworkError)
Sets whether the next split install should terminate in a network error.
Parameters | |
---|---|
shouldNetworkError |
boolean |
startConfirmationDialogForResult
public boolean startConfirmationDialogForResult (SplitInstallSessionState sessionState, IntentSenderForResultStarter starter, int requestCode)
Not implemented.
Parameters | |
---|---|
sessionState |
SplitInstallSessionState : a SplitInstallSessionState with status SplitInstallSessionStatus.REQUIRES_USER_CONFIRMATION |
starter |
IntentSenderForResultStarter : the intent IntentSenderForResultStarter |
requestCode |
int : the request code that will be used for ERROR(/Activity#onActivityResult) |
Returns | |
---|---|
boolean |
whether the session state is a valid and the dialog has been started |
Throws | |
---|---|
IntentSender.SendIntentException |
startConfirmationDialogForResult
public boolean startConfirmationDialogForResult (SplitInstallSessionState sessionState, ActivityResultLauncher<IntentSenderRequest> activityResultLauncher)
Not implemented.
Parameters | |
---|---|
sessionState |
SplitInstallSessionState : a SplitInstallSessionState with status SplitInstallSessionStatus.REQUIRES_USER_CONFIRMATION |
activityResultLauncher |
ActivityResultLauncher : an ActivityResultLauncher to launch the confirmation dialog. |
Returns | |
---|---|
boolean |
whether the session state is a valid and the dialog has been started |
startConfirmationDialogForResult
public boolean startConfirmationDialogForResult (SplitInstallSessionState sessionState, Activity activity, int requestCode)
Not implemented.
Parameters | |
---|---|
sessionState |
SplitInstallSessionState : a SplitInstallSessionState with status SplitInstallSessionStatus.REQUIRES_USER_CONFIRMATION |
activity |
Activity : the Activity that will be used for ERROR(/Activity#onActivityResult) |
requestCode |
int : the request code that will be used for ERROR(/Activity#onActivityResult) |
Returns | |
---|---|
boolean |
whether the session state is a valid and the dialog has been started |
Throws | |
---|---|
IntentSender.SendIntentException |
startInstall
public Task<Integer> startInstall (SplitInstallRequest request)
Initiates a request to download and install split APKs for additional features or language resources.
To learn more, read Request an on demand module or Download additional language resources.
Parameters | |
---|---|
request |
SplitInstallRequest : the SplitInstallRequest you built for the install request |
Returns | |
---|---|
Task<Integer> |
session id, which can be used to subsequently interact with the session after it is created. A session id of 0 indicates that the splits are already installed; in this case no session is generated. |
unregisterListener
public void unregisterListener (SplitInstallStateUpdatedListener listener)
Unregisters a listener you previously registered using registerListener(SplitInstallStateUpdatedListener)
.
Parameters | |
---|---|
listener |
SplitInstallStateUpdatedListener |