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

Commit 529fa06f authored by Carlos Martinez Romero's avatar Carlos Martinez Romero
Browse files

Bufferstreams test app.

Used to test out BufferQueues and BufferStreams.

Test: Ran the app.
Bug: 296272152
Change-Id: Ie1192658bf7db49b2ccc216433585fbd1cd1bff7
parent ad16bf27
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
// Copyright (C) 2023 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.

android_app {
    name: "BufferStreamsDemoApp",
    srcs: ["java/**/*.java"],
    sdk_version: "current",

    jni_uses_platform_apis: true,
    jni_libs: ["libbufferstreamdemoapp"],
    use_embedded_native_libs: true,

    static_libs: [
        "androidx.appcompat_appcompat",
    ],
}
+25 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.android.graphics.bufferstreamsdemoapp"
    xmlns:tools="http://schemas.android.com/tools">

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.AppCompat.Light"
        tools:targetApi="34">
        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
 No newline at end of file
+39 −0
Original line number Diff line number Diff line
// Copyright (C) 2023 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.graphics.bufferstreamsdemoapp;

import android.os.Bundle;
import android.widget.TextView;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {
    // Used to load the 'bufferstreamsdemoapp' library on application startup.
    static { System.loadLibrary("bufferstreamdemoapp"); }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        RunBufferQueue();
        System.out.println("stringFromJNI: " + stringFromJNI());
    }

    /**
     * A native method that is implemented by the 'bufferstreamsdemoapp' native
     * library, which is packaged with this application.
     */
    public native String stringFromJNI();
    public native void RunBufferQueue();
}
 No newline at end of file
+28 −0
Original line number Diff line number Diff line
// Copyright (C) 2023 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.

cc_library_shared {
    name: "libbufferstreamdemoapp",
    cflags: [
        "-Werror",
        "-Wno-error=unused-parameter",
    ],
    shared_libs: [
        "libgui",
        "libbase",
        "libutils",
    ],
    header_libs: ["jni_headers"],
    srcs: ["*.cpp"],
}
+37 −0
Original line number Diff line number Diff line
// Copyright (C) 2023 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.

#include <jni.h>

#include <gui/BufferQueue.h>

extern "C"
{
    JNIEXPORT jstring JNICALL
    Java_com_android_graphics_bufferstreamsdemoapp_MainActivity_stringFromJNI(
            JNIEnv *env,
            jobject /* this */) {
        const char* hello = "Hello from C++";
        return env->NewStringUTF(hello);
    }

    JNIEXPORT void JNICALL
    Java_com_android_graphics_bufferstreamsdemoapp_MainActivity_RunBufferQueue(
            JNIEnv *env,
            jobject /* this */) {
        android::sp<android::IGraphicBufferProducer> producer;
        android::sp<android::IGraphicBufferConsumer> consumer;
        android::BufferQueue::createBufferQueue(&producer, &consumer);
    }
}
 No newline at end of file
Loading