Allow specifying base for SandboxModelContext.

Flag: TEST_ONLY
Bug: 230027385
Test: go/testedequals
Change-Id: I2d6c90eda30cb80fd7124d35bab62b1af1b10902
This commit is contained in:
Brian Isganitis
2024-10-04 13:32:02 -07:00
parent bae6a107de
commit 4d6194f432
@@ -31,6 +31,7 @@ import static org.mockito.Mockito.spy;
import android.content.ContentProvider;
import android.content.ContentResolver;
import android.content.Context;
import android.content.pm.PackageInstaller;
import android.content.pm.PackageInstaller.SessionParams;
import android.content.pm.PackageManager;
@@ -250,15 +251,16 @@ public class LauncherModelHelper {
private final File mDbDir;
public SandboxModelContext() {
super(ApplicationProvider.getApplicationContext());
this(ApplicationProvider.getApplicationContext());
}
public SandboxModelContext(Context context) {
super(context);
// System settings cache content provider. Ensure that they are statically initialized
Settings.Secure.getString(
ApplicationProvider.getApplicationContext().getContentResolver(), "test");
Settings.System.getString(
ApplicationProvider.getApplicationContext().getContentResolver(), "test");
Settings.Global.getString(
ApplicationProvider.getApplicationContext().getContentResolver(), "test");
Settings.Secure.getString(context.getContentResolver(), "test");
Settings.System.getString(context.getContentResolver(), "test");
Settings.Global.getString(context.getContentResolver(), "test");
mPm = spy(getBaseContext().getPackageManager());
mDbDir = new File(getCacheDir(), UUID.randomUUID().toString());