Revert "Support toggling Taskbar All Apps with 3P Launcher."

This reverts commit 176f186a6d.

Reason for revert: DroidMonitor: Potential culprit for http://b/331438065 - verifying through ABTD before revert submission. This is part of the standard investigation process, and does not mean your CL will be reverted.

Change-Id: Ie375277ad2f65199749f0211ab50037d4b37e664
Merged-In: Ie375277ad2f65199749f0211ab50037d4b37e664
This commit is contained in:
Liana Kazanova authored and Brian Isganitis committed 2024-03-26 20:34:09 +00:00
1 parent 176f186a6d
commit 036a83cd99
7 files changed
+47 -229

No files matched your search

@@ -1,90 +0,0 @@
/*
* Copyright (C) 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.quickstep
import android.accessibilityservice.AccessibilityService.GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS
import android.app.PendingIntent
import android.app.RemoteAction
import android.content.Context
import android.graphics.drawable.Icon
import android.view.accessibility.AccessibilityManager
import com.android.launcher3.R
import java.util.concurrent.Executor
/**
* Registers a [RemoteAction] for toggling All Apps if needed.
*
* We need this action when either [isHomeAndOverviewSame] or [isTaskbarPresent] is `true`. When
* home and overview are the same, we can control Launcher's or Taskbar's All Apps tray. If they are
* not the same, but Taskbar is present, we can only control Taskbar's tray.
*/
class AllAppsActionManager(
private val context: Context,
private val bgExecutor: Executor,
private val createAllAppsPendingIntent: () -> PendingIntent,
) {
/** `true` if home and overview are the same Activity. */
var isHomeAndOverviewSame = false
set(value) {
field = value
updateSystemAction()
}
/** `true` if Taskbar is enabled. */
var isTaskbarPresent = false
set(value) {
field = value
updateSystemAction()
}
/** `true` if the action should be registered. */
var isActionRegistered = false
private set
private fun updateSystemAction() {
val shouldRegisterAction = isHomeAndOverviewSame || isTaskbarPresent
if (isActionRegistered == shouldRegisterAction) return
isActionRegistered = shouldRegisterAction
bgExecutor.execute {
val accessibilityManager =
context.getSystemService(AccessibilityManager::class.java) ?: return@execute
if (shouldRegisterAction) {
accessibilityManager.registerSystemAction(
RemoteAction(
Icon.createWithResource(context, R.drawable.ic_apps),
context.getString(R.string.all_apps_label),
context.getString(R.string.all_apps_label),
createAllAppsPendingIntent(),
),
GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS,
)
} else {
accessibilityManager.unregisterSystemAction(GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS)
}
}
}
fun onDestroy() {
context
.getSystemService(AccessibilityManager::class.java)
?.unregisterSystemAction(
GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS,
)
}
}
@@ -31,7 +31,6 @@ import static com.android.launcher3.MotionEventsUtils.isTrackpadMotionEvent;
import static com.android.launcher3.MotionEventsUtils.isTrackpadMultiFingerSwipe;
import static com.android.launcher3.config.FeatureFlags.ENABLE_TRACKPAD_GESTURE;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import static com.android.launcher3.util.OnboardingPrefs.HOME_BOUNCE_SEEN;
import static com.android.launcher3.util.window.WindowManagerProxy.MIN_TABLET_WIDTH;
import static com.android.quickstep.GestureState.DEFAULT_STATE;
@@ -60,12 +59,14 @@ import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_SP
import static com.android.wm.shell.sysui.ShellSharedConstants.KEY_EXTRA_SHELL_STARTING_WINDOW;
import android.app.PendingIntent;
import android.app.RemoteAction;
import android.app.Service;
import android.content.IIntentReceiver;
import android.content.IIntentSender;
import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Region;
import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Looper;
@@ -76,6 +77,7 @@ import android.view.Choreographer;
import android.view.InputDevice;
import android.view.InputEvent;
import android.view.MotionEvent;
import android.view.accessibility.AccessibilityManager;
import androidx.annotation.BinderThread;
import androidx.annotation.NonNull;
@@ -86,6 +88,7 @@ import com.android.launcher3.BaseDraggingActivity;
import com.android.launcher3.ConstantItem;
import com.android.launcher3.EncryptionType;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.R;
import com.android.launcher3.anim.AnimatedFloat;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.provider.RestoreDbTask;
@@ -98,6 +101,7 @@ import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.uioverrides.flags.FlagsFactory;
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.Executors;
import com.android.launcher3.util.LockedUserState;
import com.android.launcher3.util.SafeCloseable;
import com.android.launcher3.util.ScreenOnTracker;
@@ -484,7 +488,6 @@ public class TouchInteractionService extends Service {
private TaskbarManager mTaskbarManager;
private Function<GestureState, AnimatedFloat> mSwipeUpProxyProvider = i -> null;
private AllAppsActionManager mAllAppsActionManager;
@Override
public void onCreate() {
@@ -494,9 +497,7 @@ public class TouchInteractionService extends Service {
mMainChoreographer = Choreographer.getInstance();
mAM = ActivityManagerWrapper.getInstance();
mDeviceState = new RecentsAnimationDeviceState(this, true);
mAllAppsActionManager = new AllAppsActionManager(
this, UI_HELPER_EXECUTOR, this::createAllAppsPendingIntent);
mTaskbarManager = new TaskbarManager(this, mAllAppsActionManager);
mTaskbarManager = new TaskbarManager(this);
mRotationTouchHelper = mDeviceState.getRotationTouchHelper();
mInputConsumer = InputConsumerController.getRecentsAnimationInputConsumer();
BootAwarePreloader.start(this);
@@ -589,7 +590,16 @@ public class TouchInteractionService extends Service {
}
private void onOverviewTargetChange(boolean isHomeAndOverviewSame) {
mAllAppsActionManager.setHomeAndOverviewSame(isHomeAndOverviewSame);
Executors.UI_HELPER_EXECUTOR.execute(() -> {
AccessibilityManager am = getSystemService(AccessibilityManager.class);
if (isHomeAndOverviewSame) {
am.registerSystemAction(
createAllAppsAction(), GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS);
} else {
am.unregisterSystemAction(GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS);
}
});
StatefulActivity newOverviewActivity = mOverviewComponentObserver.getActivityInterface()
.getCreatedActivity();
@@ -599,12 +609,13 @@ public class TouchInteractionService extends Service {
mTISBinder.onOverviewTargetChange();
}
private PendingIntent createAllAppsPendingIntent() {
private RemoteAction createAllAppsAction() {
final Intent homeIntent = new Intent(mOverviewComponentObserver.getHomeIntent())
.setAction(INTENT_ACTION_ALL_APPS_TOGGLE);
final PendingIntent actionPendingIntent;
if (FeatureFlags.ENABLE_ALL_APPS_SEARCH_IN_TASKBAR.get()) {
return new PendingIntent(new IIntentSender.Stub() {
actionPendingIntent = new PendingIntent(new IIntentSender.Stub() {
@Override
public void send(int code, Intent intent, String resolvedType,
IBinder allowlistToken, IIntentReceiver finishedReceiver,
@@ -613,12 +624,18 @@ public class TouchInteractionService extends Service {
}
});
} else {
return PendingIntent.getActivity(
actionPendingIntent = PendingIntent.getActivity(
this,
GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS,
homeIntent,
PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_IMMUTABLE);
}
return new RemoteAction(
Icon.createWithResource(this, R.drawable.ic_apps),
getString(R.string.all_apps_label),
getString(R.string.all_apps_label),
actionPendingIntent);
}
@UiThread
@@ -661,7 +678,8 @@ public class TouchInteractionService extends Service {
mDeviceState.destroy();
SystemUiProxy.INSTANCE.get(this).clearProxy();
mAllAppsActionManager.onDestroy();
getSystemService(AccessibilityManager.class)
.unregisterSystemAction(GLOBAL_ACTION_ACCESSIBILITY_ALL_APPS);
mTaskbarManager.destroy();
sConnected = false;