Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3b0c1f3a authored by Andy Wickham's avatar Andy Wickham
Browse files

Allows multiple gesture blocking activities to be specified.

Bug: 148542211
Change-Id: Ie299359eb2df60f5f08d156dc6882fa133fab27c
parent 2d0f79b7
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -753,7 +753,7 @@ public class TouchInteractionService extends Service implements PluginListener<O

    protected boolean shouldNotifyBackGesture() {
        return mBackGestureNotificationCounter > 0 &&
                mDeviceState.getGestureBlockedActivityPackage() != null;
                !mDeviceState.getGestureBlockedActivityPackages().isEmpty();
    }

    @WorkerThread
@@ -762,8 +762,8 @@ public class TouchInteractionService extends Service implements PluginListener<O
            mBackGestureNotificationCounter--;
            Utilities.getDevicePrefs(this).edit()
                    .putInt(KEY_BACK_NOTIFICATION_COUNT, mBackGestureNotificationCounter).apply();
            sendBroadcast(new Intent(NOTIFY_ACTION_BACK).setPackage(
                    mDeviceState.getGestureBlockedActivityPackage()));
            mDeviceState.getGestureBlockedActivityPackages().forEach(blockedPackage ->
                    sendBroadcast(new Intent(NOTIFY_ACTION_BACK).setPackage(blockedPackage)));
        }
    }

+7 −5
Original line number Diff line number Diff line
@@ -13,11 +13,13 @@
     See the License for the specific language governing permissions and
     limitations under the License.
-->
<resources>
    <string name="task_overlay_factory_class" translatable="false"></string>
<resources xmlns:tools="http://schemas.android.com/tools">
    <string name="task_overlay_factory_class" translatable="false"/>

    <!-- Activity which blocks home gesture -->
    <string name="gesture_blocking_activity" translatable="false"></string>
    <!-- Activities which block home gesture -->
    <string-array name="gesture_blocking_activities" tools:ignore="InconsistentArrays">
        <item>com.android.launcher3/com.android.quickstep.interaction.BackGestureTutorialActivity</item>
    </string-array>

    <string name="stats_log_manager_class" translatable="false">com.android.quickstep.logging.StatsLogCompatManager</string>

@@ -32,5 +34,5 @@
    <integer name="assistant_gesture_min_time_threshold">200</integer>
    <integer name="assistant_gesture_corner_deg_threshold">20</integer>

    <string name="wellbeing_provider_pkg" translatable="false"></string>
    <string name="wellbeing_provider_pkg" translatable="false"/>
</resources>
+22 −11
Original line number Diff line number Diff line
@@ -66,6 +66,8 @@ import com.android.systemui.shared.system.SystemGestureExclusionListenerCompat;

import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/**
 * Manages the state of the system during a swipe up gesture.
@@ -107,7 +109,7 @@ public class RecentsAnimationDeviceState implements
    private Region mExclusionRegion;
    private SystemGestureExclusionListenerCompat mExclusionListener;

    private ComponentName mGestureBlockedActivity;
    private final List<ComponentName> mGestureBlockedActivities;

    public RecentsAnimationDeviceState(Context context) {
        final ContentResolver resolver = context.getContentResolver();
@@ -142,9 +144,19 @@ public class RecentsAnimationDeviceState implements
        runOnDestroy(() -> mSysUiNavMode.removeModeChangeListener(this));

        // Add any blocked activities
        String blockingActivity = context.getString(R.string.gesture_blocking_activity);
        String[] blockingActivities;
        try {
            blockingActivities =
                    context.getResources().getStringArray(R.array.gesture_blocking_activities);
        } catch (Resources.NotFoundException e) {
            blockingActivities = new String[0];
        }
        mGestureBlockedActivities = new ArrayList<>(blockingActivities.length);
        for (String blockingActivity : blockingActivities) {
            if (!TextUtils.isEmpty(blockingActivity)) {
            mGestureBlockedActivity = ComponentName.unflattenFromString(blockingActivity);
                mGestureBlockedActivities.add(
                        ComponentName.unflattenFromString(blockingActivity));
            }
        }
    }

@@ -272,17 +284,16 @@ public class RecentsAnimationDeviceState implements
     * @return whether the given running task info matches the gesture-blocked activity.
     */
    public boolean isGestureBlockedActivity(ActivityManager.RunningTaskInfo runningTaskInfo) {
        return runningTaskInfo != null && mGestureBlockedActivity != null
                && mGestureBlockedActivity.equals(runningTaskInfo.topActivity);
        return runningTaskInfo != null
                && mGestureBlockedActivities.contains(runningTaskInfo.topActivity);
    }

    /**
     * @return the package of the gesture-blocked activity or {@code null} if there is none.
     * @return the packages of gesture-blocked activities.
     */
    public String getGestureBlockedActivityPackage() {
        return (mGestureBlockedActivity != null)
                ? mGestureBlockedActivity.getPackageName()
                : null;
    public List<String> getGestureBlockedActivityPackages() {
        return mGestureBlockedActivities.stream().map(ComponentName::getPackageName)
                .collect(Collectors.toList());
    }

    /**