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

Commit 83c988b1 authored by Juan Sebastian Martinez's avatar Juan Sebastian Martinez
Browse files

Setting min sdk of MSDL lib to 31.

This change allows an easier integration with Launcher and adds a
backwards compatibility functionality to vibrate without any vibration
attributes.

Test: presubmit
Flag: NONE usage of the library is flagged elsewhere
Bug: 344654090
Change-Id: Ib2e3c39f5ef9fc7a74938181375332ede84295f6
parent 10e452e3
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -21,7 +21,7 @@ android_library {
    name: "msdl",
    manifest: "AndroidManifest.xml",
    sdk_version: "system_current",
    min_sdk_version: "33",
    min_sdk_version: "31",
    static_libs: [
        "kotlinx_coroutines_android",
        "androidx.annotation_annotation",
+15 −8
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package com.google.android.msdl.domain

import android.os.Build
import android.os.VibrationAttributes
import android.os.VibrationEffect
import android.os.Vibrator
@@ -87,15 +88,21 @@ internal class MSDLPlayerImpl(
                    }
                }

            // 2. Deliver the haptics with attributes
            // 2. Deliver the haptics with or without attributes
            if (effect == null || !vibrator.hasVibrator()) return
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
                val attributes =
                    if (properties?.vibrationAttributes != null) {
                        properties.vibrationAttributes
                    } else {
                    VibrationAttributes.Builder().setUsage(VibrationAttributes.USAGE_TOUCH).build()
                        VibrationAttributes.Builder()
                            .setUsage(VibrationAttributes.USAGE_TOUCH)
                            .build()
                    }
                executor.execute { vibrator.vibrate(effect, attributes) }
            } else {
                executor.execute { vibrator.vibrate(effect) }
            }

            // 3. Log the event
            historyLogger.addEvent(MSDLEvent(token, properties))