Using a runtime generated layout for tests instead of defining xml

This allows support for easily setting up default layouts

Bug: 277345535
Test: Presubmit
Flag: N/A
Change-Id: I1c089d60ac3f8add8d7e1060d343e04d30afe094
This commit is contained in:
Sunny Goyal
2023-04-11 11:35:43 -07:00
parent 94f3b6329d
commit ab2f808196
15 changed files with 193 additions and 265 deletions

View File

@@ -218,29 +218,6 @@ public class DebugTestInformationHandler extends TestInformationHandler {
}
}
case TestProtocol.REQUEST_USE_TEST_WORKSPACE_LAYOUT: {
useTestWorkspaceLayout(
LauncherSettings.Settings.ARG_DEFAULT_WORKSPACE_LAYOUT_TEST);
return response;
}
case TestProtocol.REQUEST_USE_TEST2_WORKSPACE_LAYOUT: {
useTestWorkspaceLayout(
LauncherSettings.Settings.ARG_DEFAULT_WORKSPACE_LAYOUT_TEST2);
return response;
}
case TestProtocol.REQUEST_USE_TAPL_WORKSPACE_LAYOUT: {
useTestWorkspaceLayout(
LauncherSettings.Settings.ARG_DEFAULT_WORKSPACE_LAYOUT_TAPL);
return response;
}
case TestProtocol.REQUEST_USE_DEFAULT_WORKSPACE_LAYOUT: {
useTestWorkspaceLayout(null);
return response;
}
case TestProtocol.REQUEST_HOTSEAT_ICON_NAMES: {
return getLauncherUIProperty(Bundle::putStringArrayList, l -> {
ShortcutAndWidgetContainer hotseatIconsContainer =
@@ -278,20 +255,4 @@ public class DebugTestInformationHandler extends TestInformationHandler {
return super.call(method, arg, extras);
}
}
private void useTestWorkspaceLayout(String layout) {
final long identity = Binder.clearCallingIdentity();
try {
if (layout != null) {
LauncherSettings.Settings.call(mContext.getContentResolver(),
LauncherSettings.Settings.METHOD_SET_USE_TEST_WORKSPACE_LAYOUT_FLAG,
layout);
} else {
LauncherSettings.Settings.call(mContext.getContentResolver(),
LauncherSettings.Settings.METHOD_CLEAR_USE_TEST_WORKSPACE_LAYOUT_FLAG);
}
} finally {
Binder.restoreCallingIdentity(identity);
}
}
}