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

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

Snap for 13473899 from 47cb56a5 to 25Q3-release

Change-Id: I3c639bd2512d3bc7ca34ba464f31a0d68b8892f6
parents 23236ed5 47cb56a5
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -489,8 +489,10 @@ private sealed interface DisplayEvent {
 * upstream Flow.
 *
 * Useful for code that needs to compare the current value to the previous value.
 *
 * Note this has been taken from com.android.systemui.util.kotlin. It was copied to keep deps of
 * displaylib minimal (and avoid creating a new shared lib for it).
 */
// TODO b/401305290 - This should be moved to a shared lib, as it's also used by SystemUI.
fun <T, R> Flow<T>.pairwiseBy(transform: suspend (old: T, new: T) -> R): Flow<R> = flow {
    val noVal = Any()
    var previousValue: Any? = noVal
+45 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.android.app.displaylib.fakes

import com.android.app.displaylib.PerDisplayRepository
import java.util.function.Consumer

/** Fake version of [PerDisplayRepository], to be used in tests. */
class FakePerDisplayRepository<T> : PerDisplayRepository<T> {

    private val instances = mutableMapOf<Int, T>()

    fun add(displayId: Int, instance: T) {
        instances[displayId] = instance
    }

    fun remove(displayId: Int) {
        instances.remove(displayId)
    }

    override fun get(displayId: Int): T? {
        return instances[displayId]
    }

    override val debugName: String
        get() = "FakePerDisplayRepository"

    override fun forEach(createIfAbsent: Boolean, action: Consumer<T>) {
        instances.forEach { (_, t) -> action.accept(t) }
    }
}
+10 −6
Original line number Diff line number Diff line
@@ -19,9 +19,13 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import org.junit.runner.RunWith

@SmallTest
@RunWith(AndroidJUnit4::class)
class DisplayRepositoryTest {

    // TODO b/401305290 - Move tests from The SystemUI DisplayRepositoryImpl to here.
}
/**
 * Tests for display repository are in SystemUI:
 * frameworks/base/packages/SystemUI/multivalentTestsForDevice/src/com/android/systemui/display/data/repository/DisplayRepositoryTest.kt
 *
 * This is because the repository was initially there, and tests depend on kosmos for dependency
 * injection (which is sysui-specific).
 *
 * In case of changes, update tests in sysui.
 */
@SmallTest @RunWith(AndroidJUnit4::class) class DisplayRepositoryTest
+37 −0
Original line number Diff line number Diff line
// Copyright (C) 2025 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 {
    default_applicable_licenses: ["Android-Apache-2.0"],
    default_team: "trendy_team_motion",
}

android_library {
    name: "mechanics-compose",
    manifest: "AndroidManifest.xml",
    srcs: [
        "src/**/*.kt",
    ],
    static_libs: [
        "//frameworks/libs/systemui/mechanics:mechanics",
        "platform-test-annotations",
        "PlatformMotionTestingCompose",
        "androidx.compose.runtime_runtime",
        "androidx.compose.ui_ui-test-junit4",
        "testables",
        "truth",
    ],
    kotlincflags: ["-Xjvm-default=all"],
}
+20 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  ~ Copyright (C) 2025 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.
  -->

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.mechanics.compose">
</manifest>
Loading