去掉Google搜索栏
aosp/packages/apps/Launcher3/src_build_config/com/android/launcher3/BuildConfig.java
修改QSB_ON_FIRST_SCREEN为false
java
public static final boolean QSB_ON_FIRST_SCREEN = false;
去掉抽屉菜单,所有应用都放到桌面
增加控制变量
aosp/packages/apps/Launcher3/src_build_config/com/android/launcher3/BuildConfig.java
增加
java
public static final boolean REMOVE_DRAWER = true;
aosp/packages/apps/Launcher3/src/com/android/launcher3/config/FeatureFlags.java
增加
java
public static final boolean REMOVE_DRAWER = BuildConfig.REMOVE_DRAWER;
禁用上滑打开抽屉应用菜单
aosp/packages/apps/Launcher3/quickstep/src/com/android/launcher3/uioverrides/touchcontrollers/PortraitStatesTouchController.java
java
@Override
protected boolean canInterceptTouch(MotionEvent ev) {
if(FeatureFlags.REMOVE_DRAWER){
return false;
}
....
}
加载所有应用
aosp/packages/apps/Launcher3/src/com/android/launcher3/model/LoaderTask.java
java
public void run() {
...
Trace.beginSection("LoadAllApps");
List<LauncherActivityInfo> allActivityList;
try {
allActivityList = loadAllApps();
} finally {
Trace.endSection();
}
logASplit(logger, "loadAllApps");
// 增加
if (FeatureFlags.REMOVE_DRAWER){
getAllApplications();
}
verifyNotStopped();
mResults.bindAllApps();
logASplit(logger, "bindAllApps");
...
}
private void getAllApplications() {
Log.d(TAG,"getAllApplications");
final Context context =mApp.getContext();
ArrayList<Pair<ItemInfo,Object>> installQueue = new ArrayList<>();
final List<UserHandle> profiles =mUserManager.getUserProfiles();
for (UserHandle user : profiles) {
final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null,user);
ArrayList<ItemInstallQueue.PendingInstallShortcutInfo>added = new ArrayList<ItemInstallQueue.PendingInstallShortcutInfo>();
synchronized (this) {
for (LauncherActivityInfo app :apps) {
// if(app.getComponentName().getPackageName().equals("com.android.stk")||app.getComponentName().getPackageName().equals("com.android.fmradio")){
// continue;
// }
Log.d(TAG,"getAllApplications packageName: " + app.getComponentName().getPackageName());
ItemInstallQueue.PendingInstallShortcutInfo pendingInstallShortcutInfo
= new ItemInstallQueue.PendingInstallShortcutInfo(app.getActivityInfo().packageName, user);
added.add(pendingInstallShortcutInfo);
installQueue.add(pendingInstallShortcutInfo.getItemInfo(context));
}
}
if (!added.isEmpty()) {
mApp.getModel().addAndBindAddedWorkspaceItems(installQueue);
}
}
}
aosp/packages/apps/Launcher3/src/com/android/launcher3/model/ItemInstallQueue.java
java
// 修改private为public
public static class PendingInstallShortcutInfo extends ItemInfo {}
安装的app添加到workspace工作区
aosp/packages/apps/Launcher3/src/com/android/launcher3/model/PackageUpdatedTask.java
java
@Override
public void execute(@NonNull final LauncherAppState app, @NonNull final BgDataModel dataModel,
@NonNull final AllAppsList appsList) {
...
bindApplicationsIfNeeded();
// 增加
if(FeatureFlags.REMOVE_DRAWER){
updateToWorkSpace(context, app,appsList);
}
final IntSet removedShortcuts = new IntSet();
// Shortcuts to keep even if the corresponding app was removed
final IntSet forceKeepShortcuts = new IntSet();
...
}
//安装的app添加到workspace工作区
public void updateToWorkSpace(Context context, LauncherAppState app, AllAppsList appsList){
Log.d(TAG,"updateToWorkSpace");
ArrayList<Pair<ItemInfo,Object>> installQueue = new ArrayList<>();
UserManager mUserManager = app.getContext().getSystemService(UserManager.class);
final List<UserHandle> profiles = mUserManager.getUserProfiles();
ArrayList<ItemInstallQueue.PendingInstallShortcutInfo> added = new ArrayList<>();
LauncherApps mLauncherApps = app.getContext().getSystemService(LauncherApps.class);
for(UserHandle user : profiles){
final List<LauncherActivityInfo> apps = mLauncherApps.getActivityList(null,user);
synchronized (this){
for(LauncherActivityInfo info :apps){
for(AppInfo appInfo : appsList.data){
String packageName = info.getComponentName().getPackageName();
if(info.getComponentName().equals(appInfo.componentName)){
if(DEBUG){
Log.d(TAG,"updateToWorkSpace packageName: " + packageName);
}
ItemInstallQueue.PendingInstallShortcutInfo mPendingInstallShortcutInfo
= new ItemInstallQueue.PendingInstallShortcutInfo(packageName,user);
added.add(mPendingInstallShortcutInfo);
installQueue.add(mPendingInstallShortcutInfo.getItemInfo(context));
}
}
}
}
}
if(!added.isEmpty()){
app.getModel().addAndBindAddedWorkspaceItems(installQueue);
}
}
打开限制
清除数据重新加载还能加载图标
aosp/packages/apps/Launcher3/src/com/android/launcher3/model/AddWorkspaceItemsTask.java
java
public void execute(@NonNull final LauncherAppState app, @NonNull final BgDataModel dataModel,
@NonNull final AllAppsList apps) {
...
// b/139663018 Short-circuit this logic if the icon is a system app
if (PackageManagerHelper.isSystemApp(app.getContext(),
Objects.requireNonNull(item.getIntent()))) {
if (TestProtocol.sDebugTracing) {
Log.d(TestProtocol.MISSING_PROMISE_ICON,
LOG + " Item is a system app.");
}
if(!FeatureFlags.REMOVE_DRAWER){
continue;
}
}
...
}
这里不做修改的话如果清除所有数据,那么图标就不会加载
aosp/packages/apps/Launcher3/src/com/android/launcher3/model/BaseModelUpdateTask.java
java
@Override
public final void run() {
if (!Objects.requireNonNull(mModel).isModelLoaded()) {
if (DEBUG_TASKS) {
Log.d(TAG, "Ignoring model task since loader is pending=" + this);
}
// Loader has not yet run.
if(!FeatureFlags.REMOVE_DRAWER) {
return;
}
}
execute(mApp, mDataModel, mAllAppsList);
}
顶部菜单移除remove换成取消cancel,无法移除
remove变成cancel
aosp/packages/apps/Launcher3/src/com/android/launcher3/DeleteDropTarget.java
java
private boolean canRemove(ItemInfo item) {
// 增加
if(FeatureFlags.REMOVE_DRAWER) {
return false ;
}
return item.id != ItemInfo.NO_ID;
}
无法删除图标
aosp/packages/apps/Launcher3/src/com/android/launcher3/dragndrop/DragController.java
java
protected void drop(DropTarget dropTarget, Runnable flingAnimation) {
...
// Drop onto the target.
boolean accepted = false;
if (dropTarget != null) {
dropTarget.onDragExit(mDragObject);
if (dropTarget.acceptDrop(mDragObject)) {
if (flingAnimation != null) {
flingAnimation.run();
} else {
dropTarget.onDrop(mDragObject, mOptions);
}
accepted = true;
// 增加
if (FeatureFlags.REMOVE_DRAWER && dropTarget instanceof DeleteDropTarget
&& isNeedCancelDrag(mDragObject.dragInfo)
) {
cancelDrag();
}
}
}
final View dropTargetAsView = dropTarget instanceof View ? (View) dropTarget : null;
dispatchDropComplete(dropTargetAsView, accepted);
}
private boolean isNeedCancelDrag(ItemInfo item){
return (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION ||
item.itemType == LauncherSettings.Favorites.ITEM_TYPE_FOLDER);
}
Android 13.0 桌面改成单层桌面的代码记录
launcher3去掉抽屉菜单,所有用都放到桌面,无法拖拽删除图标,去除hotseat
Android11去除抽屉模式