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

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

Snap for 13197820 from db07eb01 to 25Q2-release

Change-Id: I33610b115b11017c166a8d27df0ab846200a8d38
parents a75b63e8 db07eb01
Loading
Loading
Loading
Loading

displaylib/Android.bp

0 → 100644
+30 −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"],
}

java_library {
    name: "displaylib",
    manifest: "AndroidManifest.xml",
    static_libs: [
        "kotlinx_coroutines_android",
        "dagger2",
        "jsr330",
        "//frameworks/libs/systemui:tracinglib-platform",
    ],
    plugins: ["dagger2-compiler"],
    srcs: ["src/**/*.kt"],
}
+20 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
     Copyright 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.app.displaylib">
</manifest>

displaylib/README.MD

0 → 100644
+4 −0
Original line number Diff line number Diff line
# displaylib

This library contains utilities that make the management of multiple displays easier, more
performant and elegant.
 No newline at end of file
+7 −0
Original line number Diff line number Diff line
{
  "presubmit": [
    {
      "name": "displaylib_tests"
    }
  ]
}
+72 −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

import android.hardware.display.DisplayManager
import android.os.Handler
import dagger.Binds
import dagger.BindsInstance
import dagger.Component
import dagger.Module
import javax.inject.Singleton
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope

/**
 * Component that creates all classes in displaylib.
 *
 * Each user of this library will bind the required element in the factory constructor. It's advised
 * to use this component through [createDisplayLibComponent], which wraps the dagger generated
 * method.
 */
@Component(modules = [DisplayLibModule::class])
@Singleton
interface DisplayLibComponent {

    @Component.Factory
    interface Factory {
        fun create(
            @BindsInstance displayManager: DisplayManager,
            @BindsInstance bgHandler: Handler,
            @BindsInstance bgApplicationScope: CoroutineScope,
            @BindsInstance backgroundCoroutineDispatcher: CoroutineDispatcher,
        ): DisplayLibComponent
    }

    val displayRepository: DisplayRepository
}

@Module
interface DisplayLibModule {
    @Binds fun bindDisplayManagerImpl(impl: DisplayRepositoryImpl): DisplayRepository
}

/**
 * Just a wrapper to make the generated code to create the component more explicit.
 *
 * This should be called only once per process. Note that [bgHandler], [bgApplicationScope] and
 * [backgroundCoroutineDispatcher] are expected to be backed by background threads. In the future
 * this might throw an exception if they are tied to the main thread!
 */
fun createDisplayLibComponent(
    displayManager: DisplayManager,
    bgHandler: Handler,
    bgApplicationScope: CoroutineScope,
    backgroundCoroutineDispatcher: CoroutineDispatcher,
): DisplayLibComponent {
    return DaggerDisplayLibComponent.factory()
        .create(displayManager, bgHandler, bgApplicationScope, backgroundCoroutineDispatcher)
}
Loading