Moving some tests to robolectric
> Adding support for simulating model load
Bug: 130562632
Change-Id: I1de8c0abe2e74d4e7e47e18914316c339920609a
diff --git a/src/com/android/launcher3/LauncherProvider.java b/src/com/android/launcher3/LauncherProvider.java
index 42927ea..67fe038 100644
--- a/src/com/android/launcher3/LauncherProvider.java
+++ b/src/com/android/launcher3/LauncherProvider.java
@@ -484,8 +484,6 @@
*/
private AutoInstallsLayout createWorkspaceLoaderFromAppRestriction(AppWidgetHost widgetHost) {
Context ctx = getContext();
- InvariantDeviceProfile grid = LauncherAppState.getIDP(ctx);
-
String authority = Settings.Secure.getString(ctx.getContentResolver(),
"launcher3.layout.provider");
if (TextUtils.isEmpty(authority)) {
@@ -497,13 +495,7 @@
Log.e(TAG, "No provider found for authority " + authority);
return null;
}
- Uri uri = new Uri.Builder().scheme("content").authority(authority).path("launcher_layout")
- .appendQueryParameter("version", "1")
- .appendQueryParameter("gridWidth", Integer.toString(grid.numColumns))
- .appendQueryParameter("gridHeight", Integer.toString(grid.numRows))
- .appendQueryParameter("hotseatSize", Integer.toString(grid.numHotseatIcons))
- .build();
-
+ Uri uri = getLayoutUri(authority, ctx);
try (InputStream in = ctx.getContentResolver().openInputStream(uri)) {
// Read the full xml so that we fail early in case of any IO error.
String layout = new String(IOUtils.toByteArray(in));
@@ -520,6 +512,16 @@
}
}
+ public static Uri getLayoutUri(String authority, Context ctx) {
+ InvariantDeviceProfile grid = LauncherAppState.getIDP(ctx);
+ return new Uri.Builder().scheme("content").authority(authority).path("launcher_layout")
+ .appendQueryParameter("version", "1")
+ .appendQueryParameter("gridWidth", Integer.toString(grid.numColumns))
+ .appendQueryParameter("gridHeight", Integer.toString(grid.numRows))
+ .appendQueryParameter("hotseatSize", Integer.toString(grid.numHotseatIcons))
+ .build();
+ }
+
private DefaultLayoutParser getDefaultLayoutParser(AppWidgetHost widgetHost) {
InvariantDeviceProfile idp = LauncherAppState.getIDP(getContext());
int defaultLayout = idp.defaultLayoutId;