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

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

Snap for 10865348 from 0b51df88 to 24Q1-release

Change-Id: Icf2a0fee0acc35a7405c37dd39584dc3777d9936
parents 49be9676 0b51df88
Loading
Loading
Loading
Loading
+4 −0
Original line number Original line Diff line number Diff line
@@ -93,6 +93,10 @@ on late-init
    chmod 0666 /sys/kernel/tracing/events/binder/binder_unlock/enable
    chmod 0666 /sys/kernel/tracing/events/binder/binder_unlock/enable
    chmod 0666 /sys/kernel/debug/tracing/events/binder/binder_set_priority/enable
    chmod 0666 /sys/kernel/debug/tracing/events/binder/binder_set_priority/enable
    chmod 0666 /sys/kernel/tracing/events/binder/binder_set_priority/enable
    chmod 0666 /sys/kernel/tracing/events/binder/binder_set_priority/enable
    chmod 0666 /sys/kernel/debug/tracing/events/binder/binder_command/enable
    chmod 0666 /sys/kernel/tracing/events/binder/binder_command/enable
    chmod 0666 /sys/kernel/debug/tracing/events/binder/binder_return/enable
    chmod 0666 /sys/kernel/tracing/events/binder/binder_return/enable
    chmod 0666 /sys/kernel/debug/tracing/events/i2c/enable
    chmod 0666 /sys/kernel/debug/tracing/events/i2c/enable
    chmod 0666 /sys/kernel/tracing/events/i2c/enable
    chmod 0666 /sys/kernel/tracing/events/i2c/enable
    chmod 0666 /sys/kernel/debug/tracing/events/i2c/i2c_read/enable
    chmod 0666 /sys/kernel/debug/tracing/events/i2c/i2c_read/enable

include/ftl/OWNERS

0 → 100644
+1 −0
Original line number Original line Diff line number Diff line
include platform/frameworks/native:/services/surfaceflinger/OWNERS
 No newline at end of file
+30 −0
Original line number Original line Diff line number Diff line
@@ -1441,6 +1441,36 @@ TEST_F(BinderLibTest, HangingServices) {
    EXPECT_GE(epochMsAfter, epochMsBefore + delay);
    EXPECT_GE(epochMsAfter, epochMsBefore + delay);
}
}


TEST_F(BinderLibTest, BinderProxyCount) {
    Parcel data, reply;
    sp<IBinder> server = addServer();
    ASSERT_NE(server, nullptr);

    uint32_t initialCount = BpBinder::getBinderProxyCount();
    size_t iterations = 100;
    {
        uint32_t count = initialCount;
        std::vector<sp<IBinder> > proxies;
        sp<IBinder> proxy;
        // Create binder proxies and verify the count.
        for (size_t i = 0; i < iterations; i++) {
            ASSERT_THAT(server->transact(BINDER_LIB_TEST_CREATE_BINDER_TRANSACTION, data, &reply),
                        StatusEq(NO_ERROR));
            proxies.push_back(reply.readStrongBinder());
            EXPECT_EQ(BpBinder::getBinderProxyCount(), ++count);
        }
        // Remove every other one and verify the count.
        auto it = proxies.begin();
        for (size_t i = 0; it != proxies.end(); i++) {
            if (i % 2 == 0) {
                it = proxies.erase(it);
                EXPECT_EQ(BpBinder::getBinderProxyCount(), --count);
            }
        }
    }
    EXPECT_EQ(BpBinder::getBinderProxyCount(), initialCount);
}

class BinderLibRpcTestBase : public BinderLibTest {
class BinderLibRpcTestBase : public BinderLibTest {
public:
public:
    void SetUp() override {
    void SetUp() override {
+18 −5
Original line number Original line Diff line number Diff line
@@ -12,13 +12,26 @@
// See the License for the specific language governing permissions and
// See the License for the specific language governing permissions and
// limitations under the License.
// limitations under the License.


rust_library {
rust_defaults {
    name: "libbufferstreams",
    name: "libbufferstreams_defaults",
    crate_name: "bufferstreams",
    srcs: ["src/lib.rs"],
    srcs: ["src/lib.rs"],
    edition: "2021",
    rustlibs: [
    rlibs: [
        "libanyhow",
        "libnativewindow_rs",
        "libnativewindow_rs",
    ],
    ],
    edition: "2021",
}

rust_library {
    name: "libbufferstreams",
    crate_name: "bufferstreams",
    defaults: ["libbufferstreams_defaults"],
    min_sdk_version: "30",
    min_sdk_version: "30",
}
}

rust_test {
    name: "libbufferstreams-internal_test",
    crate_name: "bufferstreams",
    defaults: ["libbufferstreams_defaults"],
    test_suites: ["general-tests"],
}
+138 −42
Original line number Original line Diff line number Diff line
@@ -14,8 +14,14 @@


//! libbufferstreams: Reactive Streams for Graphics Buffers
//! libbufferstreams: Reactive Streams for Graphics Buffers


pub mod publishers;
mod stream_config;
pub mod subscribers;
pub mod subscriptions;

pub use stream_config::*;

use nativewindow::*;
use nativewindow::*;
use std::sync::{Arc, Weak};
use std::time::Instant;
use std::time::Instant;


/// This function will print Hello World.
/// This function will print Hello World.
@@ -50,9 +56,11 @@ pub extern "C" fn hello() -> bool {
/// * A Publisher MAY support multiple Subscribers and decides whether each
/// * A Publisher MAY support multiple Subscribers and decides whether each
/// Subscription is unicast or multicast.
/// Subscription is unicast or multicast.
pub trait BufferPublisher {
pub trait BufferPublisher {
    /// Returns the StreamConfig of buffers that publisher creates.
    fn get_publisher_stream_config(&self) -> StreamConfig;
    /// This function will create the subscription between the publisher and
    /// This function will create the subscription between the publisher and
    /// the subscriber.
    /// the subscriber.
    fn subscribe(&self, subscriber: Weak<dyn BufferSubscriber>);
    fn subscribe(&mut self, subscriber: impl BufferSubscriber + 'static);
}
}


/// BufferSubscribers can subscribe to BufferPublishers. They can request Frames
/// BufferSubscribers can subscribe to BufferPublishers. They can request Frames
@@ -82,14 +90,16 @@ pub trait BufferPublisher {
/// * A Publisher MAY support multiple Subscribers and decides whether each
/// * A Publisher MAY support multiple Subscribers and decides whether each
/// Subscription is unicast or multicast.
/// Subscription is unicast or multicast.
pub trait BufferSubscriber {
pub trait BufferSubscriber {
    /// The StreamConfig of buffers that this subscriber expects.
    fn get_subscriber_stream_config(&self) -> StreamConfig;
    /// This function will be called at the beginning of the subscription.
    /// This function will be called at the beginning of the subscription.
    fn on_subscribe(&self, subscription: Arc<dyn BufferSubscription>);
    fn on_subscribe(&mut self, subscription: Box<dyn BufferSubscription>);
    /// This function will be called for buffer that comes in.
    /// This function will be called for buffer that comes in.
    fn on_next(&self, frame: Frame);
    fn on_next(&mut self, frame: Frame);
    /// This function will be called in case of an error.
    /// This function will be called in case of an error.
    fn on_error(&self, error: BufferError);
    fn on_error(&mut self, error: BufferError);
    /// This function will be called on finite streams when done.
    /// This function will be called on finite streams when done.
    fn on_complete(&self);
    fn on_complete(&mut self);
}
}


/// BufferSubscriptions serve as the bridge between BufferPublishers and
/// BufferSubscriptions serve as the bridge between BufferPublishers and
@@ -142,8 +152,9 @@ pub trait BufferSubscription {
    /// cancel
    /// cancel
    fn cancel(&self);
    fn cancel(&self);
}
}

/// Type used to describe errors produced by subscriptions.
/// Type used to describe errors produced by subscriptions.
type BufferError = Box<dyn std::error::Error + Send + Sync + 'static>;
pub type BufferError = anyhow::Error;


/// Struct used to contain the buffer.
/// Struct used to contain the buffer.
pub struct Frame {
pub struct Frame {
@@ -154,3 +165,88 @@ pub struct Frame {
    /// A fence used for reading/writing safely.
    /// A fence used for reading/writing safely.
    pub fence: i32,
    pub fence: i32,
}
}

#[cfg(test)]
mod test {
    #![allow(warnings, unused)]
    use super::*;

    use anyhow::anyhow;
    use std::borrow::BorrowMut;
    use std::error::Error;
    use std::ops::Add;
    use std::sync::Arc;
    use std::time::Duration;

    use crate::publishers::testing::*;
    use crate::subscribers::{testing::*, SharedSubscriber};

    const STREAM_CONFIG: StreamConfig = StreamConfig {
        width: 1,
        height: 1,
        layers: 1,
        format: AHardwareBuffer_Format::AHARDWAREBUFFER_FORMAT_R8G8B8A8_UNORM,
        usage: AHardwareBuffer_UsageFlags::AHARDWAREBUFFER_USAGE_CPU_READ_OFTEN,
        stride: 0,
    };

    fn make_frame() -> Frame {
        Frame {
            buffer: STREAM_CONFIG
                .create_hardware_buffer()
                .expect("Unable to create hardware buffer for test"),
            present_time: Instant::now() + Duration::from_secs(1),
            fence: 0,
        }
    }

    #[test]
    fn test_test_implementations_next() {
        let subscriber = SharedSubscriber::new(TestSubscriber::new(STREAM_CONFIG));
        let mut publisher = TestPublisher::new(STREAM_CONFIG);

        publisher.subscribe(subscriber.clone());
        assert!(subscriber.map_inner(|s| s.has_subscription()));
        assert!(publisher.has_subscriber());

        publisher.send_frame(make_frame());
        let events = subscriber.map_inner_mut(|s| s.take_events());
        assert!(!matches!(events.last().unwrap(), TestingSubscriberEvent::Next(_)));

        subscriber.map_inner(|s| s.request(1));
        assert_eq!(publisher.pending_requests(), 1);

        publisher.send_frame(make_frame());
        let events = subscriber.map_inner_mut(|s| s.take_events());
        assert!(matches!(events.last().unwrap(), TestingSubscriberEvent::Next(_)));
        assert_eq!(publisher.pending_requests(), 0);
    }

    #[test]
    fn test_test_implementations_complete() {
        let subscriber = SharedSubscriber::new(TestSubscriber::new(STREAM_CONFIG));
        let mut publisher = TestPublisher::new(STREAM_CONFIG);

        publisher.subscribe(subscriber.clone());
        assert!(subscriber.map_inner(|s| s.has_subscription()));
        assert!(publisher.has_subscriber());

        publisher.send_complete();
        let events = subscriber.map_inner_mut(|s| s.take_events());
        assert!(matches!(events.last().unwrap(), TestingSubscriberEvent::Complete));
    }

    #[test]
    fn test_test_implementations_error() {
        let subscriber = SharedSubscriber::new(TestSubscriber::new(STREAM_CONFIG));
        let mut publisher = TestPublisher::new(STREAM_CONFIG);

        publisher.subscribe(subscriber.clone());
        assert!(subscriber.map_inner(|s| s.has_subscription()));
        assert!(publisher.has_subscriber());

        publisher.send_error(anyhow!("error"));
        let events = subscriber.map_inner_mut(|s| s.take_events());
        assert!(matches!(events.last().unwrap(), TestingSubscriberEvent::Error(_)));
    }
}
Loading