Android Framework禁用手势上滑及按钮进多任务的功能
安卓手势多任务
安卓手势多任务是指在安卓系统中,通过特定的手势操作来实现多任务管理的功能。
以下是一些常见的安卓手势多任务操作:
- 从屏幕底部上滑:这是最常见的安卓手势多任务操作之一。在大多数安卓手机上,从屏幕底部向上滑动一段距离,然后停留片刻,即可进入多任务视图。在多任务视图中,可以看到最近使用的应用程序的卡片,通过左右滑动可以切换应用程序,向上滑动可以关闭应用程序。
- 从屏幕底部上滑并停顿:在一些安卓手机上,从屏幕底部向上滑动一段距离后停顿片刻,可以直接进入多任务视图,而无需停留。
- 从屏幕两侧向内滑动:在一些安卓手机上,从屏幕两侧向内滑动一段距离,然后停留片刻,也可以进入多任务视图。
- 双击屏幕:在一些安卓手机上,双击屏幕可以唤醒屏幕或进入多任务视图。具体的操作方式可能因手机品牌和型号而异。
- 按手势导航按钮
不同的安卓手机可能会有不同的手势多任务操作方式,具体的操作方式可以参考手机的用户手册或在设置中查找相关的手势设置。
需求
禁用上滑进多任务的功能, 上滑不再显示多任务界面.
分析
- 要禁用手势导航按键的多任务要改SystemUI
- 要禁用上滑多任务要改Launcher
实现
禁用上滑进多任务的功能
packages/apps/Launcher3/quickstep/recents_ui_overrides/src/com/android/quickstep/BaseSwipeUpHandlerV2.java
@UiThread
private void handleNormalGestureEnd(float endVelocity, boolean isFling, PointF velocity,
boolean isCancel) {
// 省略......
if (endTarget == HOME) {
setShelfState(ShelfAnimState.CANCEL, LINEAR, 0);
duration = Math.max(MIN_OVERSHOOT_DURATION, duration);
mContext.sendBroadcast(new Intent("android.intent.action.power.to.home"));
} else if (endTarget == RECENTS) {
//注释掉下面这段代码
/*
LiveTileOverlay.INSTANCE.startIconAnimation();
if (mRecentsView != null) {
int nearestPage = mRecentsView.getPageNearestToCenterOfScreen();
if (mRecentsView.getNextPage() != nearestPage) {
// We shouldn't really scroll to the next page when swiping up to recents.
// Only allow settling on the next page if it's nearest to the center.
mRecentsView.snapToPage(nearestPage, Math.toIntExact(duration));
}
if (mRecentsView.getScroller().getDuration() > MAX_SWIPE_DURATION) {
mRecentsView.snapToPage(mRecentsView.getNextPage(), (int) MAX_SWIPE_DURATION);
}
duration = Math.max(duration, mRecentsView.getScroller().getDuration());
}
if (mDeviceState.isFullyGesturalNavMode()) {
setShelfState(ShelfAnimState.OVERVIEW, interpolator, duration);
}
*/
Log.d("", "手势上滑多任务已禁用");
}
禁用手势导航多任务按键
frameworks/base/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyRecentsImpl.java
@Override
public void toggleRecentApps() {
// 注释掉toggleRecentApps函数中的所有代码, 就可禁用
/*
// If connected to launcher service, let it handle the toggle logic
IOverviewProxy overviewProxy = mOverviewProxyService.getProxy();
if (overviewProxy != null) {
final Runnable toggleRecents = () -> {
try {
if (mOverviewProxyService.getProxy() != null) {
mOverviewProxyService.getProxy().onOverviewToggle();
mOverviewProxyService.notifyToggleRecentApps();
}
} catch (RemoteException e) {
Log.e(TAG, "Cannot send toggle recents through proxy service.", e);
}
};
// Preload only if device for current user is unlocked
if (mStatusBarLazy != null && mStatusBarLazy.get().isKeyguardShowing()) {
mStatusBarLazy.get().executeRunnableDismissingKeyguard(() -> {
// Flush trustmanager before checking device locked per user
mTrustManager.reportKeyguardShowingChanged();
mHandler.post(toggleRecents);
}, null, true , false ,
true);
} else {
toggleRecents.run();
}
return;
} else {
// Do nothing
}
*/
}
作者:帅得不敢出门
原文地址:https://blog.csdn.net/zmlovelx/article/details/142765960
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!