android5.1 长按home键一键清理白名单 滑动添加白名单

方法一:弊端:滑动时名单消失没有真正删除;再次长按home键 依然显示在待清理task中

目录 frameworksI\baseI\packagesI\SystemUI\src\com\android\systemui\recents\views\RecentsView.java  onTaskViewDismissed()

  1.  @Override
  2.     public void onTaskViewDismissed(Task t) {
  3.         // Remove any stored data from the loader.  We currently don't bother notifying the views
  4.         // that the data has been unloaded because at the point we call onTaskViewDismissed(), the views
  5.         // either don't need to be updated, or have already been removed.
  6.         RecentsTaskLoader loader = RecentsTaskLoader.getInstance();
  7.         loader.deleteTaskData(t, false);
  8.         // Remove the old task from activity manager
  9.         /*添加滑动不能删除白名单 com.android.mms settings 为白名单 wanchengguo   20180803 begin*/
  10.         //loader.getSystemServicesProxy().removeTask(t.key.id);    
  11.         Boolean isapp = t.toString().contains("com.android.mms")||t.toString().contains("com.android.settings");
  12.         if(!isapp) {
  13.         loader.getSystemServicesProxy().removeTask(t.key.id);    //删除task
  14.         }
  15.         /*添加滑动不能删除白名单 com.android.mms settings 为白名单 wanchengguo   end*/
  16.         
  17.     }
  • 方法二:白名单目录滑动失效;不能滑动删除
  • 目录 frameworksI\baseI\packagesI\SystemUI\src\com\android\systemui\recents\views\SwipeHelper.java  endSwipe()方法
  1.     private void endSwipe(VelocityTracker velocityTracker) {
  2.         velocityTracker.computeCurrentVelocity(1000 /* px/sec */);
  3.         float velocity = getVelocity(velocityTracker);
  4.         float perpendicularVelocity = getPerpendicularVelocity(velocityTracker);
  5.         float escapeVelocity = SWIPE_ESCAPE_VELOCITY * mDensityScale;
  6.         float translation = getTranslation(mCurrView);
  7.         // Decide whether to dismiss the current view
  8.         boolean childSwipedFarEnough = DISMISS_IF_SWIPED_FAR_ENOUGH &&
  9.                 Math.abs(translation) > 0.6 * getSize(mCurrView);
  10.         boolean childSwipedFastEnough = (Math.abs(velocity) > escapeVelocity) &&
  11.                 (Math.abs(velocity) > Math.abs(perpendicularVelocity)) &&
  12.                 (velocity > 0) == (translation > 0);
  13.         boolean dismissChild = mCallback.canChildBeDismissed(mCurrView)
  14.                 && isValidSwipeDirection(translation)
  15.                 && (childSwipedFastEnough || childSwipedFarEnough);
  16.         if (dismissChild) {
  17.             // flingadingy
  18.             /*当滑动删除时删除的task在白名单中时 则滑动无效wanchengguo 20180803 begin*/
  19.             //dismissChild(mCurrView, childSwipedFastEnough ? velocity : 0f);
  20.             
  21.             TaskView tv = (TaskView) mCurrView ;
  22.             if(tv.getTask().toString().contains("com.android.mms")||tv.getTask().toString().contains("com.android.settings")) {
  23.                 mCallback.onDragCancelled(mCurrView);
  24.                 snapChild(mCurrView, velocity);
  25.             }else {
  26.                 dismissChild(mCurrView, childSwipedFastEnough ? velocity : 0f);
  27.             }
  28.             /*当滑动删除时删除的task在白名单中时 则滑动无效wanchengguo  20180803 end*/
  29.         } else {
  30.             // snappity
  31.             mCallback.onDragCancelled(mCurrView);
  32.             snapChild(mCurrView, velocity);
  33.         }
  34.     }

你可能感兴趣的:(系统源码)