FakeSplitInstallManagerFactory
public
final
class
FakeSplitInstallManagerFactory
extends Object
java.lang.Object | |
↳ | com.google.android.play.core.splitinstall.testing.FakeSplitInstallManagerFactory |
Creates instances of FakeSplitInstallManager
.
Summary
Public methods | |
---|---|
static
FakeSplitInstallManager
|
create(Context context)
Creates a fake implementation of the |
static
FakeSplitInstallManager
|
create(Context context, File modulesDirectory)
Alternative version of |
static
FakeSplitInstallManager
|
createNewInstance(Context context, File modulesDirectory)
Same functionality as |
Inherited methods | |
---|---|
Public methods
create
public static FakeSplitInstallManager create (Context context)
Creates a fake implementation of the SplitInstallManager
.
This implementation is self-contained and obtains splits from a specified directory, which
can be populated passing the --local-testing
flag to bundletool build-apks
and
using bundletool install-apks
to install the app.
If you are not using --local-testing
, you should use the alternative factory method
and provide the local module directory explicitly.
It is provided for testing, e.g. checking sequences of events when installing dynamic features and additional languages. It is suitable for use in integration tests.
This fake supports just one install request at a time.
Network errors can be simulated using FakeSplitInstallManager.setShouldNetworkError(boolean)
.
SplitCompat
must be installed appropriately to use this class.
Installed splits are not persisted across application sessions: if you close and reopen an
app using FakeSplitInstallManager
, you need to request the splits again.
This method will always return the same FakeSplitInstallManager
instance. See createNewInstance(Context, File)
.
Parameters | |
---|---|
context |
Context |
Returns | |
---|---|
FakeSplitInstallManager |
create
public static FakeSplitInstallManager create (Context context, File modulesDirectory)
Alternative version of create(Context)
which allows for the splits directory to be set
explicitly.
The constructor receives the directory on the device where the split apks can be obtained.
The file name format is the same as the extracted output of bundletool build-apks
. The
apks in the directory must be signed by the same certificate as the app. If this directory is
missing, install requests will fail with SplitInstallErrorCode.API_NOT_AVAILABLE
.
In general, all configuration splits for the module that are present in the folder will be
included. Thus, consider pre-filtering them for the device - e.g. using appropriate bundletool build-apks
argument. However, since languages can change over time on the device,
there will be additional filtering of language splits, whereby only appropriate languages will
be included.
Prefer using create(Context)
with bundletool in local-testing mode and let
bundletool populate the default directory, unless there's a good reason to use a different
directory or filter the delivered APKs by hand.
This method will always return the same FakeSplitInstallManager
instance. It will
fail if called twice with different directories. See createNewInstance(Context, File)
.
Parameters | |
---|---|
context |
Context |
modulesDirectory |
File |
Returns | |
---|---|
FakeSplitInstallManager |
createNewInstance
public static FakeSplitInstallManager createNewInstance (Context context, File modulesDirectory)
Same functionality as create(Context, File)
but always creates a new instance of the
FakeSplitInstallManager
when called.
Parameters | |
---|---|
context |
Context |
modulesDirectory |
File |
Returns | |
---|---|
FakeSplitInstallManager |