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

Commit b98de291 authored by Yeabkal Wubshit's avatar Yeabkal Wubshit
Browse files

Remove Wear Specific Emergency Gesture Handling

Wear is moving to using SystemUI for handling emergency gestures, so
this change removes Wear specific logic that was added in the service
for emergency gesture handling in ag/15909986.

Bug: 293929749
Test: manually trigger emergency gesture
Test: atest GestureLauncherServiceTest
Change-Id: I94cc128b08e9226db9a94a936f8e6a4b63f95269
parent f87cf9e8
Loading
Loading
Loading
Loading
+0 −4
Original line number Diff line number Diff line
@@ -5565,10 +5565,6 @@
    <!-- pdp data reject retry delay in ms -->
    <integer name="config_pdp_reject_retry_delay_ms">-1</integer>

    <!-- Duration in milliseconds for device to vibrate on mash press on power
         button. -->
    <integer name="config_mashPressVibrateTimeOnPowerButton">0</integer>

    <!-- Whether or not to enable the binder heavy hitter watcher by default -->
    <bool name="config_defaultBinderHeavyHitterWatcherEnabled">false</bool>

+0 −2
Original line number Diff line number Diff line
@@ -4949,8 +4949,6 @@
  <java-symbol type="array" name="config_builtInDisplayIsRoundArray" />
  <java-symbol type="array" name="config_gnssParameters" />

  <java-symbol type="integer" name="config_mashPressVibrateTimeOnPowerButton" />

  <java-symbol type="string" name="config_systemGameService" />

  <java-symbol type="string" name="config_supervisedUserCreationPackage"/>
+0 −61
Original line number Diff line number Diff line
@@ -19,12 +19,10 @@ package com.android.server;
import android.app.ActivityManager;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.database.ContentObserver;
import android.hardware.Sensor;
@@ -40,8 +38,6 @@ import android.os.SystemClock;
import android.os.SystemProperties;
import android.os.Trace;
import android.os.UserHandle;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.provider.Settings;
import android.util.MutableBoolean;
import android.util.Slog;
@@ -113,19 +109,6 @@ public class GestureLauncherService extends SystemService {
     */
    private static final int CAMERA_POWER_TAP_COUNT_THRESHOLD = 2;

    /** Action for starting emergency alerts on Wear OS. */
    private static final String WEAR_LAUNCH_EMERGENCY_ACTION =
            "com.android.systemui.action.LAUNCH_EMERGENCY";

    /** Action for starting emergency alerts in retail mode on Wear OS. */
    private static final String WEAR_LAUNCH_EMERGENCY_RETAIL_ACTION =
            "com.android.systemui.action.LAUNCH_EMERGENCY_RETAIL";

    /**
     * Boolean extra for distinguishing intents coming from power button gesture.
     */
    private static final String EXTRA_LAUNCH_EMERGENCY_VIA_GESTURE = "launch_emergency_via_gesture";

    /** The listener that receives the gesture event. */
    private final GestureEventListener mGestureListener = new GestureEventListener();
    private final CameraLiftTriggerEventListener mCameraLiftTriggerListener =
@@ -198,7 +181,6 @@ public class GestureLauncherService extends SystemService {
    private final UiEventLogger mUiEventLogger;

    private boolean mHasFeatureWatch;
    private long mVibrateMilliSecondsForPanicGesture;

    @VisibleForTesting
    public enum GestureLauncherEvent implements UiEventLogger.UiEventEnum {
@@ -268,13 +250,6 @@ public class GestureLauncherService extends SystemService {

            mHasFeatureWatch =
                    mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_WATCH);
            mVibrateMilliSecondsForPanicGesture =
                    resources.getInteger(
                            com.android
                                    .internal
                                    .R
                                    .integer
                                    .config_mashPressVibrateTimeOnPowerButton);
        }
    }

@@ -714,11 +689,6 @@ public class GestureLauncherService extends SystemService {
                        userSetupComplete));
            }

            if (mHasFeatureWatch) {
                onEmergencyGestureDetectedOnWatch();
                return true;
            }

            StatusBarManagerInternal service = LocalServices.getService(
                    StatusBarManagerInternal.class);
            service.onEmergencyActionLaunchGestureDetected();
@@ -728,37 +698,6 @@ public class GestureLauncherService extends SystemService {
        }
    }

    private void onEmergencyGestureDetectedOnWatch() {
        Intent emergencyIntent =
                new Intent(
                        isInRetailMode()
                                ? WEAR_LAUNCH_EMERGENCY_RETAIL_ACTION
                                : WEAR_LAUNCH_EMERGENCY_ACTION);
        PackageManager pm = mContext.getPackageManager();
        ResolveInfo resolveInfo = pm.resolveActivity(emergencyIntent, /*flags=*/0);
        if (resolveInfo == null) {
            Slog.w(TAG, "Couldn't find an app to process the emergency intent "
                    + emergencyIntent.getAction());
            return;
        }

        Vibrator vibrator = mContext.getSystemService(Vibrator.class);
        vibrator.vibrate(VibrationEffect.createOneShot(mVibrateMilliSecondsForPanicGesture,
                VibrationEffect.DEFAULT_AMPLITUDE));

        emergencyIntent.setComponent(
                new ComponentName(
                        resolveInfo.activityInfo.packageName, resolveInfo.activityInfo.name));
        emergencyIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        emergencyIntent.putExtra(EXTRA_LAUNCH_EMERGENCY_VIA_GESTURE, true);
        mContext.startActivityAsUser(emergencyIntent, new UserHandle(mUserId));
    }

    private boolean isInRetailMode() {
        return Settings.Global.getInt(mContext.getContentResolver(),
                Settings.Global.DEVICE_DEMO_MODE, 0) == 1;
    }

    private boolean isUserSetupComplete() {
        return Settings.Secure.getIntForUser(mContext.getContentResolver(),
                Settings.Secure.USER_SETUP_COMPLETE, 0, UserHandle.USER_CURRENT) != 0;