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

Commit afb5771b authored by Beverly Tai's avatar Beverly Tai Committed by Automerger Merge Worker
Browse files

Merge "Use SystemUI config to easily adjust udfps haptics" into sc-v2-dev am:...

Merge "Use SystemUI config to easily adjust udfps haptics" into sc-v2-dev am: c546f6e0 am: c13ab099

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/16323198

Change-Id: I85bc722d5c34a2693a62813b3abbbb980861efbf
parents c71f19f0 c13ab099
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -597,6 +597,17 @@
        280
    </integer>

    <!-- Haptic feedback intensity for ticks used for the udfps dwell time -->
    <item name="config_udfpsTickIntensity" translatable="false" format="float"
          type="dimen">.5</item>

    <!-- Haptic feedback delay between ticks used for udfps dwell time -->
    <integer name="config_udfpsTickDelay" translatable="false">25</integer>

    <!-- Haptic feedback tick type - if true, uses VibrationEffect.Composition.PRIMITIVE_LOW_TICK
         else uses VibrationEffect.Composition.PRIMITIVE_TICK -->
    <bool name="config_udfpsUseLowTick">true</bool>

    <!-- package name of a built-in camera app to use to restrict implicit intent resolution
         when the double-press power gesture is used. Ignored if empty. -->
    <string translatable="false" name="config_cameraGesturePackage"></string>
+24 −12
Original line number Diff line number Diff line
@@ -163,7 +163,10 @@ public class UdfpsController implements DozeReceiver {
    private boolean mOnFingerDown;
    private boolean mAttemptedToDismissKeyguard;
    private Set<Callback> mCallbacks = new HashSet<>();
    private final VibrationEffect mLowTick;

    // by default, use low tick
    private int mPrimitiveTick = VibrationEffect.Composition.PRIMITIVE_LOW_TICK;
    private final VibrationEffect mTick;

    @VisibleForTesting
    public static final VibrationAttributes VIBRATION_ATTRIBUTES =
@@ -571,7 +574,7 @@ public class UdfpsController implements DozeReceiver {
        mConfigurationController = configurationController;
        mSystemClock = systemClock;
        mUnlockedScreenOffAnimationController = unlockedScreenOffAnimationController;
        mLowTick = lowTick();
        mTick = lowTick();

        mSensorProps = findFirstUdfps();
        // At least one UDFPS sensor exists
@@ -607,22 +610,31 @@ public class UdfpsController implements DozeReceiver {
    }

    private VibrationEffect lowTick() {
        boolean useLowTickDefault = mContext.getResources()
                .getBoolean(R.bool.config_udfpsUseLowTick);
        if (Settings.Global.getFloat(
                mContext.getContentResolver(),
                "tick-low", useLowTickDefault ? 1 : 0) == 0) {
            mPrimitiveTick = VibrationEffect.Composition.PRIMITIVE_TICK;
        }
        float tickIntensity = Settings.Global.getFloat(
                mContext.getContentResolver(), "low-tick-intensity", .5f);
        VibrationEffect.Composition composition = VibrationEffect.startComposition();
        composition.addPrimitive(VibrationEffect.Composition.PRIMITIVE_LOW_TICK,
                tickIntensity, 0);
                mContext.getContentResolver(),
                "tick-intensity",
                mContext.getResources().getFloat(R.dimen.config_udfpsTickIntensity));
        int tickDelay = Settings.Global.getInt(
                mContext.getContentResolver(), "low-tick-delay", 25);
                mContext.getContentResolver(),
                "tick-delay",
                mContext.getResources().getInteger(R.integer.config_udfpsTickDelay));

        VibrationEffect.Composition composition = VibrationEffect.startComposition();
        composition.addPrimitive(mPrimitiveTick, tickIntensity, 0);
        int primitives = 1000 / tickDelay;
        float[] rampUp = new float[]{.48f, .58f, .69f, .83f};
        for (int i = 0; i < rampUp.length; i++) {
            composition.addPrimitive(VibrationEffect.Composition.PRIMITIVE_LOW_TICK,
                    tickIntensity * rampUp[i], tickDelay);
            composition.addPrimitive(mPrimitiveTick, tickIntensity * rampUp[i], tickDelay);
        }
        for (int i = rampUp.length; i < primitives; i++) {
            composition.addPrimitive(VibrationEffect.Composition.PRIMITIVE_LOW_TICK,
                    tickIntensity, tickDelay);
            composition.addPrimitive(mPrimitiveTick, tickIntensity, tickDelay);
        }
        return composition.compose();
    }
@@ -636,7 +648,7 @@ public class UdfpsController implements DozeReceiver {
            mVibrator.vibrate(
                    Process.myUid(),
                    mContext.getOpPackageName(),
                    mLowTick,
                    mTick,
                    "udfps-onStart-tick",
                    VIBRATION_ATTRIBUTES);
        }