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

Commit 353baafb authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12491918 from cb46ee62 to 25Q1-release

Change-Id: Ie56cfb45af000a29311cb174ac7cc7a6ad9e76d5
parents 77470a12 cb46ee62
Loading
Loading
Loading
Loading
+3 −7
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ package com.android.launcher3.icons.cache;

import android.content.ComponentName;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.graphics.drawable.Drawable;
import android.os.UserHandle;

@@ -29,10 +28,8 @@ import com.android.launcher3.icons.IconProvider;

/**
 * A simple interface to represent an object which can be added to icon cache
 *
 * @param <T> Any subclass of the icon cache with which this object is associated
 */
public interface CachedObject<T extends BaseIconCache> {
public interface CachedObject {

    /**
     * Returns the component name for the underlying object
@@ -47,13 +44,13 @@ public interface CachedObject<T extends BaseIconCache> {
    /**
     * Loads the user visible label for the provided object
     */
    @Nullable CharSequence getLabel(PackageManager pm);
    @Nullable CharSequence getLabel();

    /**
     * Loads the user visible icon for the provided object
     */
    @Nullable
    default Drawable getFullResIcon(@NonNull T cache) {
    default Drawable getFullResIcon(@NonNull BaseIconCache cache) {
        return null;
    }

@@ -63,7 +60,6 @@ public interface CachedObject<T extends BaseIconCache> {
    @Nullable
    ApplicationInfo getApplicationInfo();


    /**
     * Returns a persistable string that can be used to indicate indicate the correctness of the
     * cache for the provided item
+8 −15
Original line number Diff line number Diff line
@@ -24,30 +24,23 @@ import com.android.launcher3.icons.BitmapInfo
import com.android.launcher3.icons.IconProvider

/** Caching logic for ComponentWithLabelAndIcon */
class CachedObjectCachingLogic<T : BaseIconCache>(context: Context) :
    CachingLogic<CachedObject<T>> {
object CachedObjectCachingLogic : CachingLogic<CachedObject> {

    private val pm = context.packageManager
    override fun getComponent(info: CachedObject): ComponentName = info.component

    override fun getComponent(info: CachedObject<T>): ComponentName = info.component
    override fun getUser(info: CachedObject): UserHandle = info.user

    override fun getUser(info: CachedObject<T>): UserHandle = info.user
    override fun getLabel(info: CachedObject): CharSequence? = info.label

    override fun getLabel(info: CachedObject<T>): CharSequence? = info.getLabel(pm)

    override fun loadIcon(
        context: Context,
        cache: BaseIconCache,
        info: CachedObject<T>,
    ): BitmapInfo {
        val d = info.getFullResIcon(cache as T) ?: return BitmapInfo.LOW_RES_INFO
    override fun loadIcon(context: Context, cache: BaseIconCache, info: CachedObject): BitmapInfo {
        val d = info.getFullResIcon(cache) ?: return BitmapInfo.LOW_RES_INFO
        cache.iconFactory.use { li ->
            return li.createBadgedIconBitmap(d, IconOptions().setUser(info.user))
        }
    }

    override fun getApplicationInfo(info: CachedObject<T>) = info.applicationInfo
    override fun getApplicationInfo(info: CachedObject) = info.applicationInfo

    override fun getFreshnessIdentifier(item: CachedObject<T>, provider: IconProvider): String? =
    override fun getFreshnessIdentifier(item: CachedObject, provider: IconProvider): String? =
        item.getFreshnessIdentifier(provider)
}
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2024 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.google.android.msdl.domain

import com.google.android.msdl.data.model.FeedbackLevel
import com.google.android.msdl.data.model.MSDLToken
import com.google.android.msdl.logging.MSDLEvent

/** An empty [MSDLPlayer] that was created without a [android.os.Vibrator] */
internal class EmptyMSDLPlayer : MSDLPlayer {
    override fun getSystemFeedbackLevel(): FeedbackLevel = FeedbackLevel.NO_FEEDBACK

    override fun playToken(token: MSDLToken, properties: InteractionProperties?) {}

    override fun getHistory(): List<MSDLEvent> = listOf()

    override fun toString(): String = "Empty MSDL player without a vibrator."
}
+10 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
package com.google.android.msdl.domain

import android.os.Vibrator
import android.util.Log
import com.google.android.msdl.data.model.FeedbackLevel
import com.google.android.msdl.data.model.HapticComposition
import com.google.android.msdl.data.model.MSDLToken
@@ -73,10 +74,18 @@ interface MSDLPlayer {
         *   created using the support information from the given vibrator.
         */
        fun createPlayer(
            vibrator: Vibrator,
            vibrator: Vibrator?,
            executor: Executor = Executors.newSingleThreadExecutor(),
            useHapticFeedbackForToken: Map<MSDLToken, Boolean>? = null,
        ): MSDLPlayer {
            // Return an empty player if no vibrator is available
            if (vibrator == null) {
                Log.w(
                    "MSDLPlayer",
                    "A null vibrator was used to create a MSDLPlayer. An empty player was created",
                )
                return EmptyMSDLPlayer()
            }

            // Create repository
            val repository = MSDLRepositoryImpl()
+8 −0
Original line number Diff line number Diff line
@@ -106,6 +106,14 @@ internal class MSDLPlayerImpl(

    override fun getHistory(): List<MSDLEvent> = historyLogger.getHistory()

    override fun toString(): String =
        """
            Default MSDL player implementation.
            Vibrator: $vibrator
            Repository: $repository
        """
            .trimIndent()

    companion object {
        val REQUIRED_PRIMITIVES =
            listOf(
Loading