Snap for 8983470 from 678f474423 to udc-release
Change-Id: Ia2e3ba51f1a696d834d87baad5dd1f78bc0d8120
This commit is contained in:
commit
f4e3b6aacc
30 files changed
+170
-332
No files matched your search
+21
-18
@@ -23,6 +23,7 @@ option java_outer_classname = "ViewCaptureData";
|
||||
message ExportedData {
|
||||
|
||||
repeated FrameData frameData = 1;
|
||||
repeated string classname = 2;
|
||||
}
|
||||
|
||||
message FrameData {
|
||||
@@ -31,26 +32,28 @@ message FrameData {
|
||||
}
|
||||
|
||||
message ViewNode {
|
||||
optional string classname = 1;
|
||||
optional string id = 2;
|
||||
optional int32 left = 3;
|
||||
optional int32 top = 4;
|
||||
optional int32 width = 5;
|
||||
optional int32 height = 6;
|
||||
optional int32 scrollX = 7;
|
||||
optional int32 scrollY = 8;
|
||||
optional int32 classname_index = 1;
|
||||
optional int32 hashcode = 2;
|
||||
|
||||
optional float translationX = 9;
|
||||
optional float translationY = 10;
|
||||
optional float scaleX = 11 [default = 1];
|
||||
optional float scaleY = 12 [default = 1];
|
||||
optional float alpha = 13 [default = 1];
|
||||
repeated ViewNode children = 3;
|
||||
|
||||
optional bool willNotDraw = 14;
|
||||
optional bool clipChildren = 15;
|
||||
optional int32 visibility = 16;
|
||||
optional string id = 4;
|
||||
optional int32 left = 5;
|
||||
optional int32 top = 6;
|
||||
optional int32 width = 7;
|
||||
optional int32 height = 8;
|
||||
optional int32 scrollX = 9;
|
||||
optional int32 scrollY = 10;
|
||||
|
||||
repeated ViewNode children = 17;
|
||||
optional float translationX = 11;
|
||||
optional float translationY = 12;
|
||||
optional float scaleX = 13 [default = 1];
|
||||
optional float scaleY = 14 [default = 1];
|
||||
optional float alpha = 15 [default = 1];
|
||||
|
||||
optional float elevation = 18;
|
||||
optional bool willNotDraw = 16;
|
||||
optional bool clipChildren = 17;
|
||||
optional int32 visibility = 18;
|
||||
|
||||
optional float elevation = 19;
|
||||
}
|
||||
@@ -68,7 +68,6 @@
|
||||
|
||||
<string name="hotseat_edu_message_migrate">Easily access your most-used apps right on the Home screen. Suggestions will change based on your routines. Apps on the bottom row will move up to your Home screen. </string>
|
||||
<string name="hotseat_edu_message_migrate_landscape">Easily access your most-used apps right on the Home screen. Suggestions will change based on your routines. Apps in favorites row will move to your Home screen. </string>
|
||||
<string name="hotseat_edu_message_migrate_alt">Easily access your most-used apps, right on the Home screen. Suggestions will change based on your routines. Apps on the bottom row will move to a new folder.</string>
|
||||
|
||||
<!-- Button text to opt in for fully predicted hotseat -->
|
||||
<string name="hotseat_edu_accept">Get app suggestions</string>
|
||||
|
||||
@@ -26,22 +26,17 @@ import android.view.View;
|
||||
import com.android.launcher3.BubbleTextView;
|
||||
import com.android.launcher3.CellLayout;
|
||||
import com.android.launcher3.Hotseat;
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.Workspace;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.model.data.FolderInfo;
|
||||
import com.android.launcher3.model.data.ItemInfo;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.util.GridOccupancy;
|
||||
import com.android.launcher3.util.IntArray;
|
||||
import com.android.launcher3.views.ArrowTipView;
|
||||
import com.android.launcher3.views.Snackbar;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.IntStream;
|
||||
@@ -74,101 +69,12 @@ public class HotseatEduController {
|
||||
*/
|
||||
void migrate() {
|
||||
HotseatRestoreHelper.createBackup(mLauncher);
|
||||
if (FeatureFlags.HOTSEAT_MIGRATE_TO_FOLDER.get()) {
|
||||
migrateToFolder();
|
||||
} else {
|
||||
migrateHotseatWhole();
|
||||
}
|
||||
migrateHotseatWhole();
|
||||
Snackbar.show(mLauncher, R.string.hotsaet_tip_prediction_enabled,
|
||||
R.string.hotseat_prediction_settings, null,
|
||||
() -> mLauncher.startActivity(getSettingsIntent()));
|
||||
}
|
||||
|
||||
/**
|
||||
* This migration places all non folder items in the hotseat into a folder and then moves
|
||||
* all folders in the hotseat to a workspace page that has enough empty spots.
|
||||
*
|
||||
* @return pageId that has accepted the items.
|
||||
*/
|
||||
private int migrateToFolder() {
|
||||
ArrayDeque<FolderInfo> folders = new ArrayDeque<>();
|
||||
ArrayList<WorkspaceItemInfo> putIntoFolder = new ArrayList<>();
|
||||
|
||||
//separate folders and items that can get in folders
|
||||
for (int i = 0; i < mLauncher.getDeviceProfile().numShownHotseatIcons; i++) {
|
||||
View view = mHotseat.getChildAt(i, 0);
|
||||
if (view == null) continue;
|
||||
ItemInfo info = (ItemInfo) view.getTag();
|
||||
if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER) {
|
||||
folders.add((FolderInfo) info);
|
||||
} else if (info instanceof WorkspaceItemInfo && info.container == LauncherSettings
|
||||
.Favorites.CONTAINER_HOTSEAT) {
|
||||
putIntoFolder.add((WorkspaceItemInfo) info);
|
||||
}
|
||||
}
|
||||
|
||||
// create a temp folder and add non folder items to it
|
||||
if (!putIntoFolder.isEmpty()) {
|
||||
ItemInfo firstItem = putIntoFolder.get(0);
|
||||
FolderInfo folderInfo = new FolderInfo();
|
||||
mLauncher.getModelWriter().addItemToDatabase(folderInfo, firstItem.container,
|
||||
firstItem.screenId, firstItem.cellX, firstItem.cellY);
|
||||
folderInfo.setTitle("", mLauncher.getModelWriter());
|
||||
folderInfo.contents.addAll(putIntoFolder);
|
||||
for (int i = 0; i < folderInfo.contents.size(); i++) {
|
||||
ItemInfo item = folderInfo.contents.get(i);
|
||||
item.rank = i;
|
||||
mLauncher.getModelWriter().moveItemInDatabase(item, folderInfo.id, 0,
|
||||
item.cellX, item.cellY);
|
||||
}
|
||||
folders.add(folderInfo);
|
||||
}
|
||||
mNewItems.addAll(folders);
|
||||
|
||||
return placeFoldersInWorkspace(folders);
|
||||
}
|
||||
|
||||
private int placeFoldersInWorkspace(ArrayDeque<FolderInfo> folders) {
|
||||
if (folders.isEmpty()) return 0;
|
||||
|
||||
Workspace<?> workspace = mLauncher.getWorkspace();
|
||||
InvariantDeviceProfile idp = mLauncher.getDeviceProfile().inv;
|
||||
|
||||
GridOccupancy[] occupancyList = new GridOccupancy[workspace.getChildCount()];
|
||||
for (int i = 0; i < occupancyList.length; i++) {
|
||||
occupancyList[i] = ((CellLayout) workspace.getChildAt(i)).cloneGridOccupancy();
|
||||
}
|
||||
//scan every screen to find available spots to place folders
|
||||
int occupancyIndex = 0;
|
||||
int[] itemXY = new int[2];
|
||||
while (occupancyIndex < occupancyList.length && !folders.isEmpty()) {
|
||||
GridOccupancy occupancy = occupancyList[occupancyIndex];
|
||||
if (occupancy.findVacantCell(itemXY, 1, 1)) {
|
||||
FolderInfo info = folders.poll();
|
||||
mLauncher.getModelWriter().moveItemInDatabase(info,
|
||||
LauncherSettings.Favorites.CONTAINER_DESKTOP,
|
||||
workspace.getScreenIdForPageIndex(occupancyIndex), itemXY[0], itemXY[1]);
|
||||
occupancy.markCells(info, true);
|
||||
} else {
|
||||
occupancyIndex++;
|
||||
}
|
||||
}
|
||||
if (folders.isEmpty()) return workspace.getScreenIdForPageIndex(occupancyIndex);
|
||||
int screenId = LauncherSettings.Settings.call(mLauncher.getContentResolver(),
|
||||
LauncherSettings.Settings.METHOD_NEW_SCREEN_ID)
|
||||
.getInt(LauncherSettings.Settings.EXTRA_VALUE);
|
||||
// if all screens are full and we still have folders left, put those on a new page
|
||||
FolderInfo folderInfo;
|
||||
int col = 0;
|
||||
while ((folderInfo = folders.poll()) != null) {
|
||||
mLauncher.getModelWriter().moveItemInDatabase(folderInfo,
|
||||
LauncherSettings.Favorites.CONTAINER_DESKTOP, screenId, col++,
|
||||
idp.numRows - 1);
|
||||
}
|
||||
mNewScreens = IntArray.wrap(screenId);
|
||||
return workspace.getPageCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* This migration option attempts to move the entire hotseat up to the first workspace that
|
||||
* has space to host items. If no such page is found, it moves items to a new page.
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package com.android.launcher3.hybridhotseat;
|
||||
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent
|
||||
.LAUNCHER_HOTSEAT_EDU_ACCEPT;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOTSEAT_EDU_ACCEPT;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOTSEAT_EDU_DENY;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOTSEAT_EDU_SEEN;
|
||||
|
||||
@@ -39,7 +38,6 @@ import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.Launcher;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.model.data.WorkspaceItemInfo;
|
||||
import com.android.launcher3.uioverrides.PredictedAppIcon;
|
||||
import com.android.launcher3.views.AbstractSlideInView;
|
||||
@@ -112,12 +110,6 @@ public class HotseatEduDialog extends AbstractSlideInView<Launcher> implements I
|
||||
((LinearLayout.LayoutParams) buttonContainer.getLayoutParams()).setMarginEnd(
|
||||
adjustedMarginEnd);
|
||||
}
|
||||
|
||||
// update ui to reflect which migration method is going to be used
|
||||
if (FeatureFlags.HOTSEAT_MIGRATE_TO_FOLDER.get()) {
|
||||
((TextView) findViewById(R.id.hotseat_edu_content)).setText(
|
||||
R.string.hotseat_edu_message_migrate_alt);
|
||||
}
|
||||
}
|
||||
|
||||
private void onAccept(View v) {
|
||||
|
||||
@@ -26,7 +26,6 @@ import static com.android.launcher3.LauncherState.NORMAL;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW;
|
||||
import static com.android.launcher3.LauncherState.OVERVIEW_MODAL_TASK;
|
||||
import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_WIDGET_APP_START;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP;
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.HINT_STATE_ORDINAL;
|
||||
import static com.android.launcher3.testing.shared.TestProtocol.HINT_STATE_TWO_BUTTON_ORDINAL;
|
||||
@@ -339,9 +338,7 @@ public class QuickstepLauncher extends BaseQuickstepLauncher {
|
||||
|
||||
protected LauncherAppWidgetHost createAppWidgetHost() {
|
||||
LauncherAppWidgetHost appWidgetHost = super.createAppWidgetHost();
|
||||
if (ENABLE_QUICKSTEP_WIDGET_APP_START.get()) {
|
||||
appWidgetHost.setInteractionHandler(new QuickstepInteractionHandler(this));
|
||||
}
|
||||
appWidgetHost.setInteractionHandler(new QuickstepInteractionHandler(this));
|
||||
return appWidgetHost;
|
||||
}
|
||||
|
||||
|
||||
+1
-2
@@ -25,7 +25,6 @@ import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS
|
||||
import static com.android.launcher3.allapps.AllAppsTransitionController.ALL_APPS_PULL_BACK_TRANSLATION;
|
||||
import static com.android.launcher3.anim.AnimatorListeners.forSuccessCallback;
|
||||
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_ALL_APPS_EDU;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
|
||||
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_HOME_GESTURE;
|
||||
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_RECENTS;
|
||||
@@ -106,7 +105,7 @@ public class NavBarToHomeTouchController implements TouchController,
|
||||
if (mStartState.overviewUi || mStartState == ALL_APPS) {
|
||||
return true;
|
||||
}
|
||||
int typeToClose = ENABLE_ALL_APPS_EDU.get() ? TYPE_ALL & ~TYPE_ALL_APPS_EDU : TYPE_ALL;
|
||||
int typeToClose = TYPE_ALL & ~TYPE_ALL_APPS_EDU;
|
||||
if (AbstractFloatingView.getTopOpenViewWithType(mLauncher, typeToClose) != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ import android.util.Xml;
|
||||
|
||||
import com.android.launcher3.AutoInstallsLayout;
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.logging.InstanceId;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
import com.android.launcher3.logging.StatsLogManager.StatsLogger;
|
||||
@@ -179,11 +178,9 @@ public class SettingsChangeLogger implements
|
||||
logger::log);
|
||||
|
||||
SharedPreferences prefs = getPrefs(mContext);
|
||||
if (FeatureFlags.ENABLE_THEMED_ICONS.get()) {
|
||||
logger.log(prefs.getBoolean(KEY_THEMED_ICONS, false)
|
||||
? LAUNCHER_THEMED_ICON_ENABLED
|
||||
: LAUNCHER_THEMED_ICON_DISABLED);
|
||||
}
|
||||
logger.log(prefs.getBoolean(KEY_THEMED_ICONS, false)
|
||||
? LAUNCHER_THEMED_ICON_ENABLED
|
||||
: LAUNCHER_THEMED_ICON_DISABLED);
|
||||
|
||||
mLoggablePrefs.forEach((key, lp) -> logger.log(() ->
|
||||
prefs.getBoolean(key, lp.defaultValue) ? lp.eventIdOn : lp.eventIdOff));
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.android.launcher3.LauncherState;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.Workspace;
|
||||
import com.android.launcher3.appprediction.AppsDividerView;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.hybridhotseat.HotseatPredictionController;
|
||||
import com.android.launcher3.statemanager.StateManager;
|
||||
import com.android.launcher3.statemanager.StateManager.StateListener;
|
||||
@@ -88,8 +87,7 @@ public class QuickstepOnboardingPrefs extends OnboardingPrefs<QuickstepLauncher>
|
||||
});
|
||||
}
|
||||
|
||||
if (DisplayController.getNavigationMode(launcher) == NO_BUTTON
|
||||
&& FeatureFlags.ENABLE_ALL_APPS_EDU.get()) {
|
||||
if (DisplayController.getNavigationMode(launcher) == NO_BUTTON) {
|
||||
stateManager.addStateListener(new StateListener<LauncherState>() {
|
||||
private static final int MAX_NUM_SWIPES_TO_TRIGGER_EDU = 3;
|
||||
|
||||
|
||||
@@ -20,7 +20,6 @@ import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
|
||||
import com.android.launcher3.accessibility.DragViewStateAnnouncer;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.dragndrop.DragOptions;
|
||||
import com.android.launcher3.dragndrop.DragView;
|
||||
import com.android.launcher3.dragndrop.DraggableView;
|
||||
@@ -82,11 +81,8 @@ public interface DropTarget {
|
||||
public final InstanceId logInstanceId = new InstanceIdSequence().newInstanceId();
|
||||
|
||||
public DragObject(Context context) {
|
||||
if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
|
||||
Executors.MODEL_EXECUTOR.post(() -> {
|
||||
folderNameProvider = FolderNameProvider.newInstance(context);
|
||||
});
|
||||
}
|
||||
Executors.MODEL_EXECUTOR.post(() ->
|
||||
folderNameProvider = FolderNameProvider.newInstance(context));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1491,9 +1491,9 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
if (FeatureFlags.CONTINUOUS_VIEW_TREE_CAPTURE.get()) {
|
||||
View root = getDragLayer().getRootView();
|
||||
if (mViewCapture != null) {
|
||||
root.getViewTreeObserver().removeOnDrawListener(mViewCapture);
|
||||
mViewCapture.detach();
|
||||
}
|
||||
mViewCapture = new ViewCapture(root);
|
||||
mViewCapture = new ViewCapture(getWindow());
|
||||
mViewCapture.attach();
|
||||
}
|
||||
}
|
||||
@@ -1501,6 +1501,10 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
@Override
|
||||
public void onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow();
|
||||
if (mViewCapture != null) {
|
||||
mViewCapture.detach();
|
||||
mViewCapture = null;
|
||||
}
|
||||
mOverlayManager.onDetachedFromWindow();
|
||||
closeContextMenu();
|
||||
}
|
||||
@@ -2981,6 +2985,7 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
*/
|
||||
@Override
|
||||
public void dump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args) {
|
||||
SafeCloseable viewDump = mViewCapture == null ? null : mViewCapture.beginDump(writer, fd);
|
||||
super.dump(prefix, fd, writer, args);
|
||||
|
||||
if (args.length > 0 && TextUtils.equals(args[0], "--all")) {
|
||||
@@ -3015,19 +3020,16 @@ public class Launcher extends StatefulActivity<LauncherState>
|
||||
writer.println(prefix + "\tmRotationHelper: " + mRotationHelper);
|
||||
writer.println(prefix + "\tmAppWidgetHost.isListening: " + mAppWidgetHost.isListening());
|
||||
|
||||
if (mViewCapture != null) {
|
||||
writer.print(prefix + "\tmViewCapture: ");
|
||||
writer.flush();
|
||||
mViewCapture.dump(fd);
|
||||
writer.println();
|
||||
}
|
||||
|
||||
// Extra logging for general debugging
|
||||
mDragLayer.dump(prefix, writer);
|
||||
mStateManager.dump(prefix, writer);
|
||||
mPopupDataProvider.dump(prefix, writer);
|
||||
mDeviceProfile.dump(this, prefix, writer);
|
||||
|
||||
if (viewDump != null) {
|
||||
viewDump.close();
|
||||
}
|
||||
|
||||
try {
|
||||
FileLog.flushAll(writer);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -19,7 +19,6 @@ package com.android.launcher3;
|
||||
import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_RESOURCE_UPDATED;
|
||||
|
||||
import static com.android.launcher3.Utilities.getDevicePrefs;
|
||||
import static com.android.launcher3.config.FeatureFlags.ENABLE_THEMED_ICONS;
|
||||
import static com.android.launcher3.util.Executors.MODEL_EXECUTOR;
|
||||
import static com.android.launcher3.util.SettingsCache.NOTIFICATION_BADGING_URI;
|
||||
|
||||
@@ -118,12 +117,10 @@ public class LauncherAppState implements SafeCloseable {
|
||||
observer, MODEL_EXECUTOR.getHandler());
|
||||
mOnTerminateCallback.add(iconChangeTracker::close);
|
||||
MODEL_EXECUTOR.execute(observer::verifyIconChanged);
|
||||
if (ENABLE_THEMED_ICONS.get()) {
|
||||
SharedPreferences prefs = Utilities.getPrefs(mContext);
|
||||
prefs.registerOnSharedPreferenceChangeListener(observer);
|
||||
mOnTerminateCallback.add(
|
||||
() -> prefs.unregisterOnSharedPreferenceChangeListener(observer));
|
||||
}
|
||||
SharedPreferences prefs = Utilities.getPrefs(mContext);
|
||||
prefs.registerOnSharedPreferenceChangeListener(observer);
|
||||
mOnTerminateCallback.add(
|
||||
() -> prefs.unregisterOnSharedPreferenceChangeListener(observer));
|
||||
|
||||
InstallSessionTracker installSessionTracker =
|
||||
InstallSessionHelper.INSTANCE.get(context).registerInstallTracker(mModel);
|
||||
|
||||
@@ -457,9 +457,6 @@ public class LauncherModel extends LauncherApps.Callback implements InstallSessi
|
||||
|
||||
@Override
|
||||
public void onSessionFailure(String packageName, UserHandle user) {
|
||||
if (!FeatureFlags.PROMISE_APPS_NEW_INSTALLS.get()) {
|
||||
return;
|
||||
}
|
||||
enqueueModelUpdateTask(new BaseModelUpdateTask() {
|
||||
@Override
|
||||
public void execute(LauncherAppState app, BgDataModel dataModel, AllAppsList apps) {
|
||||
|
||||
@@ -159,7 +159,7 @@ public class SecondaryDropTarget extends ButtonDropTarget implements OnAlarmList
|
||||
return RECONFIGURE;
|
||||
}
|
||||
return INVALID;
|
||||
} else if (FeatureFlags.ENABLE_PREDICTION_DISMISS.get() && info.isPredictedItem()) {
|
||||
} else if (info.isPredictedItem()) {
|
||||
return DISMISS_PREDICTION;
|
||||
}
|
||||
|
||||
|
||||
@@ -152,10 +152,6 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
|
||||
public static final int DEFAULT_PAGE = 0;
|
||||
|
||||
private static final int DEFAULT_SMARTSPACE_HEIGHT = 1;
|
||||
|
||||
private static final int EXPANDED_SMARTSPACE_HEIGHT = 2;
|
||||
|
||||
private LayoutTransition mLayoutTransition;
|
||||
@Thunk final WallpaperManager mWallpaperManager;
|
||||
|
||||
@@ -562,10 +558,8 @@ public class Workspace<T extends View & PageIndicator> extends PagedView<T>
|
||||
.inflate(R.layout.search_container_workspace, firstPage, false);
|
||||
}
|
||||
|
||||
int cellVSpan = FeatureFlags.EXPANDED_SMARTSPACE.get()
|
||||
? EXPANDED_SMARTSPACE_HEIGHT : DEFAULT_SMARTSPACE_HEIGHT;
|
||||
int cellHSpan = mLauncher.getDeviceProfile().inv.numSearchContainerColumns;
|
||||
CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, cellHSpan, cellVSpan);
|
||||
CellLayout.LayoutParams lp = new CellLayout.LayoutParams(0, 0, cellHSpan, 1);
|
||||
lp.canReorder = false;
|
||||
if (!firstPage.addViewToCellLayout(mQsb, 0, R.id.search_container_workspace, lp, true)) {
|
||||
Log.e(TAG, "Failed to add to item at (0, 0) to CellLayout");
|
||||
|
||||
@@ -67,11 +67,6 @@ public final class FeatureFlags {
|
||||
public static final BooleanFlag PROMISE_APPS_IN_ALL_APPS = getDebugFlag(
|
||||
"PROMISE_APPS_IN_ALL_APPS", false, "Add promise icon in all-apps");
|
||||
|
||||
// When enabled a promise icon is added to the home screen when install session is active.
|
||||
public static final BooleanFlag PROMISE_APPS_NEW_INSTALLS = getDebugFlag(
|
||||
"PROMISE_APPS_NEW_INSTALLS", true,
|
||||
"Adds a promise icon to the home screen for new install sessions.");
|
||||
|
||||
// TODO: b/206508141: Long pressing on some icons on home screen cause launcher to crash.
|
||||
public static final BooleanFlag ENABLE_LOCAL_COLOR_POPUPS = getDebugFlag(
|
||||
"ENABLE_LOCAL_COLOR_POPUPS", false, "Enable local color extraction for popups.");
|
||||
@@ -82,10 +77,6 @@ public final class FeatureFlags {
|
||||
public static final BooleanFlag ENABLE_QUICKSTEP_LIVE_TILE = getDebugFlag(
|
||||
"ENABLE_QUICKSTEP_LIVE_TILE", true, "Enable live tile in Quickstep overview");
|
||||
|
||||
public static final BooleanFlag ENABLE_QUICKSTEP_WIDGET_APP_START = getDebugFlag(
|
||||
"ENABLE_QUICKSTEP_WIDGET_APP_START", true,
|
||||
"Enable Quickstep animation when launching activities from an app widget");
|
||||
|
||||
public static final BooleanFlag ENABLE_DEVICE_SEARCH = new DeviceFlag(
|
||||
"ENABLE_DEVICE_SEARCH", true, "Allows on device search in all apps");
|
||||
|
||||
@@ -116,30 +107,14 @@ public final class FeatureFlags {
|
||||
"ENABLE_PEOPLE_TILE_PREVIEW", false,
|
||||
"Experimental: Shows conversation shortcuts on home screen as search results");
|
||||
|
||||
public static final BooleanFlag FOLDER_NAME_SUGGEST = new DeviceFlag(
|
||||
"FOLDER_NAME_SUGGEST", true,
|
||||
"Suggests folder names instead of blank text.");
|
||||
|
||||
public static final BooleanFlag FOLDER_NAME_MAJORITY_RANKING = getDebugFlag(
|
||||
"FOLDER_NAME_MAJORITY_RANKING", true,
|
||||
"Suggests folder names based on majority based ranking.");
|
||||
|
||||
public static final BooleanFlag ENABLE_PREDICTION_DISMISS = getDebugFlag(
|
||||
"ENABLE_PREDICTION_DISMISS", true, "Allow option to dimiss apps from predicted list");
|
||||
|
||||
public static final BooleanFlag ASSISTANT_GIVES_LAUNCHER_FOCUS = getDebugFlag(
|
||||
"ASSISTANT_GIVES_LAUNCHER_FOCUS", false,
|
||||
"Allow Launcher to handle nav bar gestures while Assistant is running over it");
|
||||
|
||||
public static final BooleanFlag HOTSEAT_MIGRATE_TO_FOLDER = getDebugFlag(
|
||||
"HOTSEAT_MIGRATE_TO_FOLDER", false, "Should move hotseat items into a folder");
|
||||
|
||||
public static final BooleanFlag ENABLE_DEEP_SHORTCUT_ICON_CACHE = getDebugFlag(
|
||||
"ENABLE_DEEP_SHORTCUT_ICON_CACHE", true, "R/W deep shortcut in IconCache");
|
||||
|
||||
public static final BooleanFlag ENABLE_THEMED_ICONS = getDebugFlag(
|
||||
"ENABLE_THEMED_ICONS", true, "Enable themed icons on workspace");
|
||||
|
||||
public static final BooleanFlag ENABLE_BULK_WORKSPACE_ICON_LOADING = getDebugFlag(
|
||||
"ENABLE_BULK_WORKSPACE_ICON_LOADING",
|
||||
true,
|
||||
@@ -181,10 +156,6 @@ public final class FeatureFlags {
|
||||
"ALWAYS_USE_HARDWARE_OPTIMIZATION_FOR_FOLDER_ANIMATIONS", false,
|
||||
"Always use hardware optimization for folder animations.");
|
||||
|
||||
public static final BooleanFlag ENABLE_ALL_APPS_EDU = getDebugFlag(
|
||||
"ENABLE_ALL_APPS_EDU", true,
|
||||
"Shows user a tutorial on how to get to All Apps after X amount of attempts.");
|
||||
|
||||
public static final BooleanFlag SEPARATE_RECENTS_ACTIVITY = getDebugFlag(
|
||||
"SEPARATE_RECENTS_ACTIVITY", false,
|
||||
"Uses a separate recents activity instead of using the integrated recents+Launcher UI");
|
||||
@@ -193,10 +164,6 @@ public final class FeatureFlags {
|
||||
"ENABLE_MINIMAL_DEVICE", false,
|
||||
"Allow user to toggle minimal device mode in launcher.");
|
||||
|
||||
public static final BooleanFlag EXPANDED_SMARTSPACE = new DeviceFlag(
|
||||
"EXPANDED_SMARTSPACE", false, "Expands smartspace height to two rows. "
|
||||
+ "Any apps occupying the first row will be removed from workspace.");
|
||||
|
||||
// TODO: b/172467144 Remove ENABLE_LAUNCHER_ACTIVITY_THEME_CROSSFADE feature flag.
|
||||
public static final BooleanFlag ENABLE_LAUNCHER_ACTIVITY_THEME_CROSSFADE = new DeviceFlag(
|
||||
"ENABLE_LAUNCHER_ACTIVITY_THEME_CROSSFADE", false, "Enables a "
|
||||
|
||||
@@ -368,9 +368,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
|
||||
public void startEditingFolderName() {
|
||||
post(() -> {
|
||||
if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
|
||||
showLabelSuggestions();
|
||||
}
|
||||
showLabelSuggestions();
|
||||
mFolderName.setHint("");
|
||||
mIsEditingName = true;
|
||||
});
|
||||
@@ -1080,8 +1078,7 @@ public class Folder extends AbstractFloatingView implements ClipPathView, DragSo
|
||||
if (!items.isEmpty()) {
|
||||
mLauncherDelegate.getModelWriter().moveItemsInDatabase(items, mInfo.id, 0);
|
||||
}
|
||||
if (FeatureFlags.FOLDER_NAME_SUGGEST.get() && !isBind
|
||||
&& total > 1 /* no need to update if there's one icon */) {
|
||||
if (!isBind && total > 1 /* no need to update if there's one icon */) {
|
||||
Executors.MODEL_EXECUTOR.post(() -> {
|
||||
FolderNameInfos nameInfos = new FolderNameInfos();
|
||||
FolderNameProvider fnp = FolderNameProvider.newInstance(getContext());
|
||||
|
||||
@@ -57,7 +57,6 @@ import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.Workspace;
|
||||
import com.android.launcher3.allapps.ActivityAllAppsContainerView;
|
||||
import com.android.launcher3.anim.Interpolators;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.dot.FolderDotInfo;
|
||||
import com.android.launcher3.dragndrop.BaseItemDragListener;
|
||||
import com.android.launcher3.dragndrop.DragLayer;
|
||||
@@ -418,35 +417,23 @@ public class FolderIcon extends FrameLayout implements FolderListener, IconLabel
|
||||
if (!itemAdded) mPreviewItemManager.hidePreviewItem(index, true);
|
||||
|
||||
FolderNameInfos nameInfos = new FolderNameInfos();
|
||||
if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
|
||||
Executors.MODEL_EXECUTOR.post(() -> {
|
||||
d.folderNameProvider.getSuggestedFolderName(
|
||||
getContext(), mInfo.contents, nameInfos);
|
||||
showFinalView(finalIndex, item, nameInfos, d.logInstanceId);
|
||||
});
|
||||
} else {
|
||||
showFinalView(finalIndex, item, nameInfos, d.logInstanceId);
|
||||
}
|
||||
Executors.MODEL_EXECUTOR.post(() -> {
|
||||
d.folderNameProvider.getSuggestedFolderName(
|
||||
getContext(), mInfo.contents, nameInfos);
|
||||
postDelayed(() -> {
|
||||
setLabelSuggestion(nameInfos, d.logInstanceId);
|
||||
invalidate();
|
||||
}, DROP_IN_ANIMATION_DURATION);
|
||||
});
|
||||
} else {
|
||||
addItem(item);
|
||||
}
|
||||
}
|
||||
|
||||
private void showFinalView(int finalIndex, final WorkspaceItemInfo item,
|
||||
FolderNameInfos nameInfos, InstanceId instanceId) {
|
||||
postDelayed(() -> {
|
||||
setLabelSuggestion(nameInfos, instanceId);
|
||||
invalidate();
|
||||
}, DROP_IN_ANIMATION_DURATION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the suggested folder name.
|
||||
*/
|
||||
public void setLabelSuggestion(FolderNameInfos nameInfos, InstanceId instanceId) {
|
||||
if (!FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
|
||||
return;
|
||||
}
|
||||
if (!mInfo.getLabelState().equals(LabelState.UNLABELED)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ import android.util.Log;
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.InvariantDeviceProfile.GridOption;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.util.Executors;
|
||||
|
||||
/**
|
||||
@@ -143,11 +142,9 @@ public class GridCustomizationsProvider extends ContentProvider {
|
||||
}
|
||||
case ICON_THEMED:
|
||||
case SET_ICON_THEMED: {
|
||||
if (FeatureFlags.ENABLE_THEMED_ICONS.get()) {
|
||||
getPrefs(getContext()).edit()
|
||||
.putBoolean(KEY_THEMED_ICONS, values.getAsBoolean(BOOLEAN_VALUE))
|
||||
.apply();
|
||||
}
|
||||
getPrefs(getContext()).edit()
|
||||
.putBoolean(KEY_THEMED_ICONS, values.getAsBoolean(BOOLEAN_VALUE))
|
||||
.apply();
|
||||
return 1;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -51,7 +51,6 @@ import androidx.core.util.Pair;
|
||||
import com.android.launcher3.InvariantDeviceProfile;
|
||||
import com.android.launcher3.LauncherFiles;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.icons.ComponentWithLabel.ComponentCachingLogic;
|
||||
import com.android.launcher3.icons.cache.BaseIconCache;
|
||||
import com.android.launcher3.icons.cache.CachingLogic;
|
||||
@@ -231,14 +230,8 @@ public class IconCache extends BaseIconCache {
|
||||
*/
|
||||
public <T extends ItemInfoWithIcon> void getShortcutIcon(T info, ShortcutInfo si,
|
||||
@NonNull Predicate<T> fallbackIconCheck) {
|
||||
BitmapInfo bitmapInfo;
|
||||
if (FeatureFlags.ENABLE_DEEP_SHORTCUT_ICON_CACHE.get()) {
|
||||
bitmapInfo = cacheLocked(ShortcutKey.fromInfo(si).componentName, si.getUserHandle(),
|
||||
() -> si, mShortcutCachingLogic, false, false).bitmap;
|
||||
} else {
|
||||
// If caching is disabled, load the full icon
|
||||
bitmapInfo = mShortcutCachingLogic.loadIcon(mContext, si);
|
||||
}
|
||||
BitmapInfo bitmapInfo = cacheLocked(ShortcutKey.fromInfo(si).componentName,
|
||||
si.getUserHandle(), () -> si, mShortcutCachingLogic, false, false).bitmap;
|
||||
if (bitmapInfo.isNullOrLowRes()) {
|
||||
bitmapInfo = getDefaultIcon(si.getUserHandle());
|
||||
}
|
||||
|
||||
@@ -31,7 +31,6 @@ import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.android.launcher3.LauncherAppState;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.icons.cache.CachingLogic;
|
||||
import com.android.launcher3.shortcuts.ShortcutKey;
|
||||
import com.android.launcher3.util.Themes;
|
||||
@@ -78,7 +77,7 @@ public class ShortcutCachingLogic implements CachingLogic<ShortcutInfo> {
|
||||
|
||||
@Override
|
||||
public long getLastUpdatedTime(ShortcutInfo shortcutInfo, PackageInfo info) {
|
||||
if (shortcutInfo == null || !FeatureFlags.ENABLE_DEEP_SHORTCUT_ICON_CACHE.get()) {
|
||||
if (shortcutInfo == null) {
|
||||
return info.lastUpdateTime;
|
||||
}
|
||||
return Math.max(shortcutInfo.getLastChangedTimestamp(), info.lastUpdateTime);
|
||||
|
||||
@@ -465,7 +465,7 @@ public class LoaderCursor extends CursorWrapper {
|
||||
// occupied (if the feature is enabled) in order to account for the search
|
||||
// container.
|
||||
int spanX = mIDP.numSearchContainerColumns;
|
||||
int spanY = FeatureFlags.EXPANDED_SMARTSPACE.get() ? 2 : 1;
|
||||
int spanY = 1;
|
||||
screen.markCells(0, 0, spanX, spanY, true);
|
||||
}
|
||||
occupied.put(item.screenId, screen);
|
||||
|
||||
@@ -256,12 +256,10 @@ public class LoaderTask implements Runnable {
|
||||
mApp.getModel()::onPackageIconsUpdated);
|
||||
logASplit(logger, "update icon cache");
|
||||
|
||||
if (FeatureFlags.ENABLE_DEEP_SHORTCUT_ICON_CACHE.get()) {
|
||||
verifyNotStopped();
|
||||
logASplit(logger, "save shortcuts in icon cache");
|
||||
updateHandler.updateIcons(allShortcuts, new ShortcutCachingLogic(),
|
||||
mApp.getModel()::onPackageIconsUpdated);
|
||||
}
|
||||
verifyNotStopped();
|
||||
logASplit(logger, "save shortcuts in icon cache");
|
||||
updateHandler.updateIcons(allShortcuts, new ShortcutCachingLogic(),
|
||||
mApp.getModel()::onPackageIconsUpdated);
|
||||
|
||||
// Take a break
|
||||
waitForIdle();
|
||||
@@ -276,12 +274,10 @@ public class LoaderTask implements Runnable {
|
||||
mResults.bindDeepShortcuts();
|
||||
logASplit(logger, "bindDeepShortcuts");
|
||||
|
||||
if (FeatureFlags.ENABLE_DEEP_SHORTCUT_ICON_CACHE.get()) {
|
||||
verifyNotStopped();
|
||||
logASplit(logger, "save deep shortcuts in icon cache");
|
||||
updateHandler.updateIcons(allDeepShortcuts,
|
||||
new ShortcutCachingLogic(), (pkgs, user) -> { });
|
||||
}
|
||||
verifyNotStopped();
|
||||
logASplit(logger, "save deep shortcuts in icon cache");
|
||||
updateHandler.updateIcons(allDeepShortcuts,
|
||||
new ShortcutCachingLogic(), (pkgs, user) -> { });
|
||||
|
||||
// Take a break
|
||||
waitForIdle();
|
||||
@@ -304,9 +300,7 @@ public class LoaderTask implements Runnable {
|
||||
logASplit(logger, "save widgets in icon cache");
|
||||
|
||||
// fifth step
|
||||
if (FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
|
||||
loadFolderNames();
|
||||
}
|
||||
loadFolderNames();
|
||||
|
||||
verifyNotStopped();
|
||||
updateHandler.finish();
|
||||
|
||||
@@ -30,7 +30,6 @@ import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.launcher3.LauncherSettings;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.folder.FolderNameInfos;
|
||||
import com.android.launcher3.logger.LauncherAtom;
|
||||
import com.android.launcher3.logger.LauncherAtom.Attribute;
|
||||
@@ -321,12 +320,6 @@ public class FolderInfo extends ItemInfo {
|
||||
return LauncherAtom.ToState.TO_STATE_UNSPECIFIED;
|
||||
}
|
||||
|
||||
if (!FeatureFlags.FOLDER_NAME_SUGGEST.get()) {
|
||||
return title.length() > 0
|
||||
? LauncherAtom.ToState.TO_CUSTOM_WITH_SUGGESTIONS_DISABLED
|
||||
: LauncherAtom.ToState.TO_EMPTY_WITH_SUGGESTIONS_DISABLED;
|
||||
}
|
||||
|
||||
// TODO: if suggestedFolderNames is null then it infrastructure issue, not
|
||||
// ranking issue. We should log these appropriately.
|
||||
if (suggestedFolderNames == null || !suggestedFolderNames.hasSuggestions()) {
|
||||
|
||||
@@ -225,14 +225,12 @@ public class InstallSessionHelper {
|
||||
void tryQueuePromiseAppIcon(PackageInstaller.SessionInfo sessionInfo) {
|
||||
if (TestProtocol.sDebugTracing) {
|
||||
Log.d(TestProtocol.MISSING_PROMISE_ICON, LOG + " tryQueuePromiseAppIcon"
|
||||
+ ", FeatureFlags=" + FeatureFlags.PROMISE_APPS_NEW_INSTALLS.get()
|
||||
+ ", SessionCommitReceiveEnabled" + SessionCommitReceiver.isEnabled(mAppContext)
|
||||
+ ", verifySessionInfo(sessionInfo)=" + verifySessionInfo(sessionInfo)
|
||||
+ ", !promiseIconAdded=" + (sessionInfo != null
|
||||
&& !promiseIconAddedForId(sessionInfo.getSessionId())));
|
||||
}
|
||||
if (FeatureFlags.PROMISE_APPS_NEW_INSTALLS.get()
|
||||
&& SessionCommitReceiver.isEnabled(mAppContext)
|
||||
if (SessionCommitReceiver.isEnabled(mAppContext)
|
||||
&& verifySessionInfo(sessionInfo)
|
||||
&& !promiseIconAddedForId(sessionInfo.getSessionId())) {
|
||||
FileLog.d(LOG, "Adding package name to install queue: "
|
||||
|
||||
@@ -16,7 +16,6 @@
|
||||
|
||||
package com.android.launcher3.shortcuts;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.Rect;
|
||||
@@ -24,7 +23,6 @@ import android.graphics.drawable.Drawable;
|
||||
import android.view.View;
|
||||
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.graphics.DragPreviewProvider;
|
||||
import com.android.launcher3.icons.BitmapRenderer;
|
||||
import com.android.launcher3.icons.FastBitmapDrawable;
|
||||
@@ -44,33 +42,13 @@ public class ShortcutDragPreviewProvider extends DragPreviewProvider {
|
||||
|
||||
@Override
|
||||
public Drawable createDrawable() {
|
||||
if (FeatureFlags.ENABLE_DEEP_SHORTCUT_ICON_CACHE.get()) {
|
||||
int size = ActivityContext.lookupContext(mView.getContext())
|
||||
.getDeviceProfile().iconSizePx;
|
||||
return new FastBitmapDrawable(
|
||||
BitmapRenderer.createHardwareBitmap(
|
||||
size + blurSizeOutline,
|
||||
size + blurSizeOutline,
|
||||
(c) -> drawDragViewOnBackground(c, size)));
|
||||
} else {
|
||||
return new FastBitmapDrawable(createDragBitmapLegacy());
|
||||
}
|
||||
}
|
||||
|
||||
private Bitmap createDragBitmapLegacy() {
|
||||
Drawable d = mView.getBackground();
|
||||
Rect bounds = getDrawableBounds(d);
|
||||
int size = ActivityContext.lookupContext(mView.getContext()).getDeviceProfile().iconSizePx;
|
||||
final Bitmap b = Bitmap.createBitmap(
|
||||
size + blurSizeOutline,
|
||||
size + blurSizeOutline,
|
||||
Bitmap.Config.ARGB_8888);
|
||||
Canvas canvas = new Canvas(b);
|
||||
canvas.translate(blurSizeOutline / 2, blurSizeOutline / 2);
|
||||
canvas.scale(((float) size) / bounds.width(), ((float) size) / bounds.height(), 0, 0);
|
||||
canvas.translate(bounds.left, bounds.top);
|
||||
d.draw(canvas);
|
||||
return b;
|
||||
int size = ActivityContext.lookupContext(mView.getContext())
|
||||
.getDeviceProfile().iconSizePx;
|
||||
return new FastBitmapDrawable(
|
||||
BitmapRenderer.createHardwareBitmap(
|
||||
size + blurSizeOutline,
|
||||
size + blurSizeOutline,
|
||||
(c) -> drawDragViewOnBackground(c, size)));
|
||||
}
|
||||
|
||||
private void drawDragViewOnBackground(Canvas canvas, float size) {
|
||||
|
||||
@@ -32,7 +32,6 @@ import android.util.TypedValue;
|
||||
|
||||
import com.android.launcher3.R;
|
||||
import com.android.launcher3.Utilities;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.icons.GraphicsUtils;
|
||||
|
||||
/**
|
||||
@@ -74,8 +73,7 @@ public class Themes {
|
||||
* Returns true if workspace icon theming is enabled
|
||||
*/
|
||||
public static boolean isThemedIconEnabled(Context context) {
|
||||
return FeatureFlags.ENABLE_THEMED_ICONS.get()
|
||||
&& Utilities.getPrefs(context).getBoolean(KEY_THEMED_ICONS, false);
|
||||
return Utilities.getPrefs(context).getBoolean(KEY_THEMED_ICONS, false);
|
||||
}
|
||||
|
||||
public static String getDefaultBodyFont(Context context) {
|
||||
|
||||
@@ -15,18 +15,23 @@
|
||||
*/
|
||||
package com.android.launcher3.util;
|
||||
|
||||
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
|
||||
import static java.util.stream.Collectors.toList;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.os.Trace;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Base64;
|
||||
import android.util.Base64OutputStream;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewTreeObserver.OnDrawListener;
|
||||
import android.view.Window;
|
||||
|
||||
import androidx.annotation.UiThread;
|
||||
import androidx.annotation.WorkerThread;
|
||||
@@ -38,7 +43,10 @@ import com.android.launcher3.view.ViewCaptureData.ViewNode;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
/**
|
||||
* Utility class for capturing view data every frame
|
||||
@@ -53,6 +61,7 @@ public class ViewCapture implements OnDrawListener {
|
||||
// Launcher. This allows the first free frames avoid object allocation during view capture.
|
||||
private static final int INIT_POOL_SIZE = 300;
|
||||
|
||||
private final Window mWindow;
|
||||
private final View mRoot;
|
||||
private final Resources mResources;
|
||||
|
||||
@@ -67,11 +76,12 @@ public class ViewCapture implements OnDrawListener {
|
||||
private ViewRef mPool = new ViewRef();
|
||||
|
||||
/**
|
||||
* @param root the root view for the capture data
|
||||
* @param window the window for the capture data
|
||||
*/
|
||||
public ViewCapture(View root) {
|
||||
mRoot = root;
|
||||
mResources = root.getResources();
|
||||
public ViewCapture(Window window) {
|
||||
mWindow = window;
|
||||
mRoot = mWindow.getDecorView();
|
||||
mResources = mRoot.getResources();
|
||||
mHandler = new Handler(UI_HELPER_EXECUTOR.getLooper(), this::captureViewPropertiesBg);
|
||||
}
|
||||
|
||||
@@ -82,6 +92,14 @@ public class ViewCapture implements OnDrawListener {
|
||||
mHandler.post(this::initPool);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a previously attached ViewCapture from the root
|
||||
*/
|
||||
public void detach() {
|
||||
mHandler.post(() -> MAIN_EXECUTOR.execute(
|
||||
() -> mRoot.getViewTreeObserver().removeOnDrawListener(this)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDraw() {
|
||||
Trace.beginSection("view_capture");
|
||||
@@ -139,7 +157,7 @@ public class ViewCapture implements OnDrawListener {
|
||||
}
|
||||
mNodesBg[mFrameIndexBg] = result;
|
||||
ViewRef end = last;
|
||||
Executors.MAIN_EXECUTOR.execute(() -> addToPool(start, end));
|
||||
MAIN_EXECUTOR.execute(() -> addToPool(start, end));
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -160,7 +178,7 @@ public class ViewCapture implements OnDrawListener {
|
||||
}
|
||||
|
||||
ViewRef end = current;
|
||||
Executors.MAIN_EXECUTOR.execute(() -> {
|
||||
MAIN_EXECUTOR.execute(() -> {
|
||||
addToPool(start, end);
|
||||
if (mRoot.isAttachedToWindow()) {
|
||||
mRoot.getViewTreeObserver().addOnDrawListener(this);
|
||||
@@ -168,38 +186,58 @@ public class ViewCapture implements OnDrawListener {
|
||||
});
|
||||
}
|
||||
|
||||
private String getName() {
|
||||
String title = mWindow.getAttributes().getTitle().toString();
|
||||
return TextUtils.isEmpty(title) ? mWindow.toString() : title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a proto of all the data captured so far.
|
||||
* Starts the dump process which is completed on closing the returned object.
|
||||
*/
|
||||
public void dump(FileDescriptor out) {
|
||||
public SafeCloseable beginDump(PrintWriter writer, FileDescriptor out) {
|
||||
Future<ExportedData> task = UI_HELPER_EXECUTOR.submit(this::dumpToProto);
|
||||
try (OutputStream os = new FileOutputStream(out)) {
|
||||
ExportedData data = task.get();
|
||||
Base64OutputStream encodedOS = new Base64OutputStream(os,
|
||||
Base64.NO_CLOSE | Base64.NO_PADDING | Base64.NO_WRAP);
|
||||
data.writeTo(encodedOS);
|
||||
encodedOS.close();
|
||||
os.flush();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error capturing proto", e);
|
||||
}
|
||||
|
||||
return () -> {
|
||||
writer.println();
|
||||
writer.println(" ContinuousViewCapture:");
|
||||
writer.println(" window " + getName() + ":");
|
||||
writer.println(" pkg:" + mRoot.getContext().getPackageName());
|
||||
writer.print(" data:");
|
||||
writer.flush();
|
||||
|
||||
try (OutputStream os = new FileOutputStream(out)) {
|
||||
ExportedData data = task.get();
|
||||
OutputStream encodedOS = new GZIPOutputStream(new Base64OutputStream(os,
|
||||
Base64.NO_CLOSE | Base64.NO_PADDING | Base64.NO_WRAP));
|
||||
data.writeTo(encodedOS);
|
||||
encodedOS.close();
|
||||
os.flush();
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG, "Error capturing proto", e);
|
||||
}
|
||||
writer.println();
|
||||
writer.println("--end--");
|
||||
};
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
private ExportedData dumpToProto() {
|
||||
ExportedData.Builder dataBuilder = ExportedData.newBuilder();
|
||||
Resources res = mResources;
|
||||
ArrayList<Class> classList = new ArrayList<>();
|
||||
|
||||
int size = (mNodesBg[MEMORY_SIZE - 1] == null) ? mFrameIndexBg + 1 : MEMORY_SIZE;
|
||||
for (int i = size - 1; i >= 0; i--) {
|
||||
int index = (MEMORY_SIZE + mFrameIndexBg - i) % MEMORY_SIZE;
|
||||
ViewNode.Builder nodeBuilder = ViewNode.newBuilder();
|
||||
mNodesBg[index].toProto(res, nodeBuilder);
|
||||
mNodesBg[index].toProto(res, classList, nodeBuilder);
|
||||
dataBuilder.addFrameData(FrameData.newBuilder()
|
||||
.setNode(nodeBuilder)
|
||||
.setTimestamp(mFrameTimesBg[index]));
|
||||
}
|
||||
return dataBuilder.build();
|
||||
return dataBuilder
|
||||
.addAllClassname(classList.stream().map(Class::getName).collect(toList()))
|
||||
.build();
|
||||
}
|
||||
|
||||
private ViewRef captureViewTree(View view, ViewRef start) {
|
||||
@@ -278,10 +316,10 @@ public class ViewCapture implements OnDrawListener {
|
||||
/**
|
||||
* Converts the data to the proto representation and returns the next property ref
|
||||
* at the end of the iteration.
|
||||
* @param res
|
||||
* @return
|
||||
*/
|
||||
public ViewPropertyRef toProto(Resources res, ViewNode.Builder outBuilder) {
|
||||
public ViewPropertyRef toProto(Resources res, ArrayList<Class> classList,
|
||||
ViewNode.Builder outBuilder) {
|
||||
String resolvedId;
|
||||
if (id >= 0) {
|
||||
try {
|
||||
@@ -292,7 +330,14 @@ public class ViewCapture implements OnDrawListener {
|
||||
} else {
|
||||
resolvedId = "NO_ID";
|
||||
}
|
||||
outBuilder.setClassname(clazz.getName() + "@" + hashCode)
|
||||
int classnameIndex = classList.indexOf(clazz);
|
||||
if (classnameIndex < 0) {
|
||||
classnameIndex = classList.size();
|
||||
classList.add(clazz);
|
||||
}
|
||||
outBuilder
|
||||
.setClassnameIndex(classnameIndex)
|
||||
.setHashcode(hashCode)
|
||||
.setId(resolvedId)
|
||||
.setLeft(left)
|
||||
.setTop(top)
|
||||
@@ -311,7 +356,7 @@ public class ViewCapture implements OnDrawListener {
|
||||
ViewPropertyRef result = next;
|
||||
for (int i = 0; (i < childCount) && (result != null); i++) {
|
||||
ViewNode.Builder childBuilder = ViewNode.newBuilder();
|
||||
result = result.toProto(res, childBuilder);
|
||||
result = result.toProto(res, classList, childBuilder);
|
||||
outBuilder.addChildren(childBuilder);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -527,6 +527,7 @@ public class TaplTestsLauncher3 extends AbstractLauncherUiTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenRecord // b/242163245
|
||||
public void getIconsPosition_afterIconRemoved_notContained() throws IOException {
|
||||
Point[] gridPositions = getCornersAndCenterPositions();
|
||||
createShortcutIfNotExist(STORE_APP_NAME, gridPositions[0]);
|
||||
|
||||
@@ -21,7 +21,7 @@ import static com.android.launcher3.allapps.AllAppsStore.DEFER_UPDATES_TEST;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import static org.junit.Assume.assumeTrue;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.android.launcher3.allapps.WorkEduCard;
|
||||
import com.android.launcher3.allapps.WorkPausedCard;
|
||||
import com.android.launcher3.allapps.WorkProfileManager;
|
||||
import com.android.launcher3.tapl.LauncherInstrumentation;
|
||||
import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
@@ -47,6 +48,7 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
|
||||
private static final int WORK_PAGE = ActivityAllAppsContainerView.AdapterHolder.WORK;
|
||||
|
||||
private int mProfileUserId;
|
||||
private boolean mWorkProfileSetupSuccessful;
|
||||
|
||||
@Before
|
||||
@Override
|
||||
@@ -56,7 +58,13 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
|
||||
mDevice.executeShellCommand(
|
||||
"pm create-user --profileOf 0 --managed TestProfile");
|
||||
Log.d("b/203817455", "pm create-user; output: " + output);
|
||||
assertTrue("Failed to create work profile", output.startsWith("Success"));
|
||||
|
||||
if (output.startsWith("Success")){
|
||||
assertTrue("Failed to create work profile", output.startsWith("Success"));
|
||||
mWorkProfileSetupSuccessful = true;
|
||||
} else {
|
||||
return; // no need to setup launcher since all tests will skip.
|
||||
}
|
||||
|
||||
String[] tokens = output.split("\\s+");
|
||||
mProfileUserId = Integer.parseInt(tokens[tokens.length - 1]);
|
||||
@@ -98,7 +106,9 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenRecord // b/242163855
|
||||
public void workTabExists() {
|
||||
assumeTrue(mWorkProfileSetupSuccessful);
|
||||
waitForLauncherCondition("Personal tab is missing",
|
||||
launcher -> launcher.getAppsView().isPersonalTabVisible(),
|
||||
LauncherInstrumentation.WAIT_TIME_MS);
|
||||
@@ -108,9 +118,10 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
@ScreenRecord // b/242163822
|
||||
public void toggleWorks() {
|
||||
assumeTrue(mWorkProfileSetupSuccessful);
|
||||
waitForWorkTabSetup();
|
||||
|
||||
executeOnLauncher(launcher -> {
|
||||
AllAppsPagedView pagedView = (AllAppsPagedView) launcher.getAppsView().getContentView();
|
||||
pagedView.setCurrentPage(WORK_PAGE);
|
||||
@@ -152,6 +163,7 @@ public class WorkProfileTest extends AbstractLauncherUiTest {
|
||||
|
||||
@Test
|
||||
public void testEdu() {
|
||||
assumeTrue(mWorkProfileSetupSuccessful);
|
||||
waitForWorkTabSetup();
|
||||
executeOnLauncher(l -> {
|
||||
l.getSharedPrefs().edit().putInt(WorkProfileManager.KEY_WORK_EDU_STEP, 0).commit();
|
||||
|
||||
@@ -33,6 +33,7 @@ import com.android.launcher3.tapl.Widgets;
|
||||
import com.android.launcher3.testcomponent.WidgetConfigActivity;
|
||||
import com.android.launcher3.ui.AbstractLauncherUiTest;
|
||||
import com.android.launcher3.ui.TestViewHelpers;
|
||||
import com.android.launcher3.util.rule.ScreenRecordRule.ScreenRecord;
|
||||
import com.android.launcher3.util.rule.ShellCommandRule;
|
||||
import com.android.launcher3.widget.LauncherAppWidgetProviderInfo;
|
||||
|
||||
@@ -72,6 +73,7 @@ public class AddConfigWidgetTest extends AbstractLauncherUiTest {
|
||||
|
||||
@Test
|
||||
@PortraitLandscape
|
||||
@ScreenRecord // b/206481237
|
||||
public void testConfigCancelled() throws Throwable {
|
||||
runTest(false);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user