diff --git a/Android.mk b/Android.mk index fc69de5..68b9d3d 100644 --- a/Android.mk +++ b/Android.mk @@ -74,14 +74,3 @@ LOCAL_SHARED_LIBRARIES := \ libcutils \ libutils include $(BUILD_EXECUTABLE) - -# Include the Android.mk files below will override LOCAL_PATH so we -# have to take a copy of it here. -TMP_PATH := $(LOCAL_PATH) - -# The compositor and launcher have their own Android.mk in their subfolders -# as they should not depend on any other anbox sources. -# include $(LOCAL_PATH)/android/shared_compositor/Android.mk -include $(TMP_PATH)/android/launcher/Android.mk -include $(TMP_PATH)/android/shared_compositor/Android.mk -include $(TMP_PATH)/android/bootanimation/Android.mk diff --git a/android/CMakeLists.txt b/android/CMakeLists.txt index 1e872b6..fd48ec3 100644 --- a/android/CMakeLists.txt +++ b/android/CMakeLists.txt @@ -28,13 +28,6 @@ target_link_libraries(anboxd set_target_properties(anboxd PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) -set(ANBOX_SHARED_COMPOSITOR - shared_compositor/main.cpp - shared_compositor/surface_composer.cpp) -add_executable(anbox_shared_compositor ${ANBOX_SHARED_COMPOSITOR}) -set_target_properties(anbox_shared_compositor - PROPERTIES EXCLUDE_FROM_ALL 1 EXCLUDE_FROM_DEFAULT_BUILD 1) - set(TEST_PLATFORM_SERVICE service/test_platform_service.cpp) diff --git a/android/bootanimation/Android.mk b/android/bootanimation/Android.mk deleted file mode 100644 index 7f2daaf..0000000 --- a/android/bootanimation/Android.mk +++ /dev/null @@ -1,53 +0,0 @@ -LOCAL_PATH:= $(call my-dir) -include $(CLEAR_VARS) - -LOCAL_SRC_FILES:= \ - bootanimation_main.cpp \ - BootAnimation.cpp - -LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES -DEGL_EGLEXT_PROTOTYPES - -LOCAL_C_INCLUDES += external/tinyalsa/include - -LOCAL_SHARED_LIBRARIES := \ - libcutils \ - liblog \ - libandroidfw \ - libutils \ - libbinder \ - libui \ - libskia \ - libEGL \ - libGLESv1_CM \ - libgui \ - libtinyalsa - -LOCAL_MODULE := anbox_bootanimation - -LOCAL_OVERRIDES_PACKAGES := bootanimation - -ifdef TARGET_32_BIT_SURFACEFLINGER -LOCAL_32_BIT_ONLY := true -endif - -include $(BUILD_EXECUTABLE) - -# -# Add symlink to bootanimation -# - -ALL_TOOLS:= bootanimation -SYMLINKS := $(addprefix $(TARGET_OUT)/bin/,$(ALL_TOOLS)) -$(SYMLINKS): TOOLBOX_BINARY := $(LOCAL_MODULE) -$(SYMLINKS): $(LOCAL_INSTALLED_MODULE) $(LOCAL_PATH)/Android.mk - @echo "Symlink: $@ -> $(TOOLBOX_BINARY)" - @mkdir -p $(dir $@) - @rm -rf $@ - $(hide) ln -sf $(TOOLBOX_BINARY) $@ - -ALL_DEFAULT_INSTALLED_MODULES += $(SYMLINKS) - -# We need this so that the installed files could be picked up based on the -# local module name -ALL_MODULES.$(LOCAL_MODULE).INSTALLED := \ - $(ALL_MODULES.$(LOCAL_MODULE).INSTALLED) $(SYMLINKS) diff --git a/android/bootanimation/BootAnimation.cpp b/android/bootanimation/BootAnimation.cpp deleted file mode 100644 index 898e17e..0000000 --- a/android/bootanimation/BootAnimation.cpp +++ /dev/null @@ -1,323 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#define LOG_NDEBUG 0 -#define LOG_TAG "BootAnimation" - -#include -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include - -#include - -#include -#include - -#include "BootAnimation.h" - -#define EXIT_PROP_NAME "service.bootanim.exit" - -#ifndef D -# define D(...) do{}while(0) -#endif - -extern "C" int clock_nanosleep(clockid_t clock_id, int flags, - const struct timespec *request, - struct timespec *remain); - -namespace android { - -static const int ANIM_ENTRY_NAME_MAX = 256; - -// --------------------------------------------------------------------------- - -BootAnimation::BootAnimation() : Thread(false) -{ - mSession = new SurfaceComposerClient(); -} - -BootAnimation::~BootAnimation() { -} - -void BootAnimation::onFirstRef() { - status_t err = mSession->linkToComposerDeath(this); - ALOGE_IF(err, "linkToComposerDeath failed (%s) ", strerror(-err)); - if (err == NO_ERROR) { - run("BootAnimation", PRIORITY_DISPLAY); - } -} - -sp BootAnimation::session() const { - return mSession; -} - - -void BootAnimation::binderDied(const wp&) -{ - // woah, surfaceflinger died! - ALOGD("SurfaceFlinger died, exiting..."); - - // calling requestExit() is not enough here because the Surface code - // might be blocked on a condition variable that will never be updated. - kill( getpid(), SIGKILL ); - requestExit(); -} - -status_t BootAnimation::initTexture(Texture* texture, void* imageData, size_t size) -{ - SkBitmap bitmap; - - SkImageDecoder::DecodeMemory(imageData, size, - &bitmap, kUnknown_SkColorType, SkImageDecoder::kDecodePixels_Mode); - - // ensure we can call getPixels(). No need to call unlock, since the - // bitmap will go out of scope when we return from this method. - bitmap.lockPixels(); - - const int w = bitmap.width(); - const int h = bitmap.height(); - const void* p = bitmap.getPixels(); - - GLint crop[4] = { 0, h, w, -h }; - texture->w = w; - texture->h = h; - - glGenTextures(1, &texture->name); - glBindTexture(GL_TEXTURE_2D, texture->name); - - switch (bitmap.colorType()) { - case kAlpha_8_SkColorType: - glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, w, h, 0, GL_ALPHA, - GL_UNSIGNED_BYTE, p); - break; - case kARGB_4444_SkColorType: - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, - GL_UNSIGNED_SHORT_4_4_4_4, p); - break; - case kN32_SkColorType: - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, - GL_UNSIGNED_BYTE, p); - break; - case kRGB_565_SkColorType: - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, w, h, 0, GL_RGB, - GL_UNSIGNED_SHORT_5_6_5, p); - break; - default: - break; - } - - glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop); - glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); - glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); - glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameterx(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - return NO_ERROR; -} - -status_t BootAnimation::readyToRun() { - mAssets.addDefaultAssets(); - - sp dtoken(SurfaceComposerClient::getBuiltInDisplay( - ISurfaceComposer::eDisplayIdMain)); - DisplayInfo dinfo; - status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo); - if (status) - return -1; - - // create the native surface - sp control = session()->createSurface(String8("BootAnimation"), - dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565); - - SurfaceComposerClient::openGlobalTransaction(); - control->setLayer(0x40000000); - SurfaceComposerClient::closeGlobalTransaction(); - - sp s = control->getSurface(); - - // initialize opengl and egl - const EGLint attribs[] = { - EGL_RED_SIZE, 8, - EGL_GREEN_SIZE, 8, - EGL_BLUE_SIZE, 8, - EGL_DEPTH_SIZE, 0, - EGL_NONE - }; - EGLint w, h, dummy; - EGLint numConfigs; - EGLConfig config; - EGLSurface surface; - EGLContext context; - - EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY); - - eglInitialize(display, 0, 0); - eglChooseConfig(display, attribs, &config, 1, &numConfigs); - surface = eglCreateWindowSurface(display, config, s.get(), NULL); - context = eglCreateContext(display, config, NULL, NULL); - eglQuerySurface(display, surface, EGL_WIDTH, &w); - eglQuerySurface(display, surface, EGL_HEIGHT, &h); - - if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) - return NO_INIT; - - mDisplay = display; - mContext = context; - mSurface = surface; - mWidth = w; - mHeight = h; - mFlingerSurfaceControl = control; - mFlingerSurface = s; - - return NO_ERROR; -} - -bool BootAnimation::threadLoop() -{ - bool r; - r = android(); - - eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - eglDestroyContext(mDisplay, mContext); - eglDestroySurface(mDisplay, mSurface); - mFlingerSurface.clear(); - mFlingerSurfaceControl.clear(); - eglTerminate(mDisplay); - IPCThreadState::self()->stopProcess(); - return r; -} - -bool BootAnimation::android() -{ - int fd = qemu_pipe_open("anbox:bootanimation"); - if(!fd) { - return false; - } - - qemud_channel_send(fd, "retrieve-icon", -1); - - unsigned long current_size = 0; - unsigned long bytes_received = 0; - void *buffer = 0; - do - { - current_size += 4096; - buffer = realloc(buffer, current_size); - int t = read(fd, buffer + bytes_received, 4096); - if (t <= 0) - break; - printf("received %d bytes\n", t); - bytes_received += t; - } while(1); - - close(fd); - - if (bytes_received == 0) { - return false; - } - - initTexture(&mAndroid[0], buffer, bytes_received); - - // clear screen - glShadeModel(GL_FLAT); - glDisable(GL_DITHER); - glDisable(GL_SCISSOR_TEST); - glClearColor(0,0,0,1); - glClear(GL_COLOR_BUFFER_BIT); - eglSwapBuffers(mDisplay, mSurface); - - glEnable(GL_TEXTURE_2D); - glTexEnvx(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - - const GLint xc = (mWidth - mAndroid[0].w) / 2; - const GLint yc = (mHeight - mAndroid[0].h) / 2; - const Rect updateRect(xc, yc, xc + mAndroid[0].w, yc + mAndroid[0].h); - - glScissor(updateRect.left, mHeight - updateRect.bottom, updateRect.width(), - updateRect.height()); - - const nsecs_t startTime = systemTime(); - do { - nsecs_t now = systemTime(); - double time = now - startTime; - - glClear(GL_COLOR_BUFFER_BIT); - glDisable(GL_SCISSOR_TEST); - glDisable(GL_BLEND); - - glEnable(GL_BLEND); - - glBindTexture(GL_TEXTURE_2D, mAndroid[0].name); - glDrawTexiOES(xc, yc, 0, mAndroid[0].w, mAndroid[0].h); - - EGLBoolean res = eglSwapBuffers(mDisplay, mSurface); - if (res == EGL_FALSE) - break; - - // 12fps: don't animate too fast to preserve CPU - const nsecs_t sleepTime = 83333 - ns2us(systemTime() - now); - if (sleepTime > 0) - usleep(sleepTime); - - checkExit(); - } while (!exitPending()); - - glDeleteTextures(1, &mAndroid[0].name); - return false; -} - - -void BootAnimation::checkExit() { - // Allow surface flinger to gracefully request shutdown - char value[PROPERTY_VALUE_MAX]; - property_get(EXIT_PROP_NAME, value, "0"); - int exitnow = atoi(value); - if (exitnow) { - requestExit(); - } -} - -// --------------------------------------------------------------------------- - -} -; // namespace android diff --git a/android/bootanimation/BootAnimation.h b/android/bootanimation/BootAnimation.h deleted file mode 100644 index 0eb243f..0000000 --- a/android/bootanimation/BootAnimation.h +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#ifndef ANDROID_BOOTANIMATION_H -#define ANDROID_BOOTANIMATION_H - -#include -#include - -#include -#include - -#include -#include - -class SkBitmap; - -namespace android { - -class Surface; -class SurfaceComposerClient; -class SurfaceControl; - -// --------------------------------------------------------------------------- - -class BootAnimation : public Thread, public IBinder::DeathRecipient -{ -public: - BootAnimation(); - virtual ~BootAnimation(); - - sp session() const; - -private: - virtual bool threadLoop(); - virtual status_t readyToRun(); - virtual void onFirstRef(); - virtual void binderDied(const wp& who); - - struct Texture { - GLint w; - GLint h; - GLuint name; - }; - - struct Animation { - struct Frame { - String8 name; - FileMap* map; - mutable GLuint tid; - bool operator < (const Frame& rhs) const { - return name < rhs.name; - } - }; - struct Part { - int count; - int pause; - String8 path; - SortedVector frames; - bool playUntilComplete; - float backgroundColor[3]; - FileMap* audioFile; - }; - int fps; - int width; - int height; - Vector parts; - }; - - status_t initTexture(Texture* texture, void *buffer, size_t size); - bool android(); - bool movie(); - - void checkExit(); - - sp mSession; - AssetManager mAssets; - Texture mAndroid[2]; - int mWidth; - int mHeight; - EGLDisplay mDisplay; - EGLDisplay mContext; - EGLDisplay mSurface; - sp mFlingerSurfaceControl; - sp mFlingerSurface; - ZipFileRO *mZip; -}; - -// --------------------------------------------------------------------------- - -}; // namespace android - -#endif // ANDROID_BOOTANIMATION_H diff --git a/android/bootanimation/bootanimation_main.cpp b/android/bootanimation/bootanimation_main.cpp deleted file mode 100644 index 2a1dee6..0000000 --- a/android/bootanimation/bootanimation_main.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2007 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. - */ - -#define LOG_TAG "BootAnimation" - -#include - -#include -#include -#include - -#include -#include - -#if defined(HAVE_PTHREADS) -# include -# include -#endif - -#include "BootAnimation.h" - -#include -#include - -using namespace android; - -#ifndef D -# define D(...) do{}while(0) -#endif - - -// --------------------------------------------------------------------------- - -int main(int argc, char** argv) -{ -#if defined(HAVE_PTHREADS) - setpriority(PRIO_PROCESS, 0, ANDROID_PRIORITY_DISPLAY); -#endif - - char value[PROPERTY_VALUE_MAX]; - property_get("debug.sf.nobootanimation", value, "0"); - int noBootAnimation = atoi(value); - ALOGI_IF(noBootAnimation, "boot animation disabled"); - if (!noBootAnimation) { - - sp proc(ProcessState::self()); - ProcessState::self()->startThreadPool(); - - // create the boot animation object - sp boot = new BootAnimation(); - - IPCThreadState::self()->joinThreadPool(); - - } - return 0; -} diff --git a/android/launcher/Android.mk b/android/launcher/Android.mk deleted file mode 100644 index b6395c0..0000000 --- a/android/launcher/Android.mk +++ /dev/null @@ -1,10 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE_TAGS := optional -LOCAL_SRC_FILES := $(call all-java-files-under, src) -LOCAL_PACKAGE_NAME := AnboxLauncher -LOCAL_CERTIFICATE := platform -LOCAL_PRIVILEGED_MODULE := true -LOCAL_OVERRIDES_PACKAGES := Home -include $(BUILD_PACKAGE) diff --git a/android/launcher/AndroidManifest.xml b/android/launcher/AndroidManifest.xml deleted file mode 100644 index 49c514c..0000000 --- a/android/launcher/AndroidManifest.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/android/launcher/res/layout/activity_launcher.xml b/android/launcher/res/layout/activity_launcher.xml deleted file mode 100644 index a614816..0000000 --- a/android/launcher/res/layout/activity_launcher.xml +++ /dev/null @@ -1,6 +0,0 @@ - - diff --git a/android/launcher/res/values/strings.xml b/android/launcher/res/values/strings.xml deleted file mode 100644 index b191504..0000000 --- a/android/launcher/res/values/strings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - Anbox Launcher - diff --git a/android/launcher/src/org/anbox/launcher/Launcher.java b/android/launcher/src/org/anbox/launcher/Launcher.java deleted file mode 100644 index ede0cd0..0000000 --- a/android/launcher/src/org/anbox/launcher/Launcher.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (C) 2016 Simon Fels - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - * - */ - -package org.anbox.launcher; - -import android.app.Activity; -import android.os.Bundle; -import android.provider.Settings; - -/** - * Default launcher application. - */ -public final class Launcher extends Activity { - static final String TAG = "Launcher"; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // Make sure the screen stays on forever - Settings.System.putInt( - getContentResolver(), - Settings.System.SCREEN_OFF_TIMEOUT, - Integer.MAX_VALUE); - - setContentView(R.layout.activity_launcher); - } -} diff --git a/android/launcher/src/org/anbox/launcher/LauncherApplication.java b/android/launcher/src/org/anbox/launcher/LauncherApplication.java deleted file mode 100644 index 686f9f7..0000000 --- a/android/launcher/src/org/anbox/launcher/LauncherApplication.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (C) 2016 Simon Fels - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - * - */ - -package org.anbox.launcher; - -import android.app.Application; -import android.util.Log; - -public class LauncherApplication extends Application { - static final String TAG = "LauncherApplication"; - - @Override - public void onCreate() { - super.onCreate(); - } -} diff --git a/android/shared_compositor/Android.mk b/android/shared_compositor/Android.mk deleted file mode 100644 index bf71b20..0000000 --- a/android/shared_compositor/Android.mk +++ /dev/null @@ -1,25 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE_TAGS := optional -LOCAL_MODULE_CLASS := EXECUTABLES -LOCAL_MODULE := anbox_shared_compositor -LOCAL_SRC_FILES := \ - main.cpp \ - surface_composer.cpp -LOCAL_SHARED_LIBRARIES := \ - libcutils \ - liblog \ - libdl \ - libhardware \ - libutils \ - libEGL \ - libGLESv1_CM \ - libGLESv2 \ - libbinder \ - libui \ - libgui -LOCAL_CFLAGS := \ - -fexceptions \ - -std=c++1y -include $(BUILD_EXECUTABLE) diff --git a/android/shared_compositor/main.cpp b/android/shared_compositor/main.cpp deleted file mode 100644 index b096216..0000000 --- a/android/shared_compositor/main.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2016 Simon Fels - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - * - */ - -#include -#include - -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "surface_composer.h" - -using namespace android; - -int main(int, char**) { - ProcessState::self()->setThreadPoolMaxThreadCount(4); - - sp ps(ProcessState::self()); - ps->startThreadPool(); - - setpriority(PRIO_PROCESS, 0, PRIORITY_URGENT_DISPLAY); - set_sched_policy(0, SP_FOREGROUND); - - anbox::android::SurfaceComposer::instantiate(); - - IPCThreadState::self()->joinThreadPool(); - - return EXIT_SUCCESS; -} diff --git a/android/shared_compositor/surface_composer.cpp b/android/shared_compositor/surface_composer.cpp deleted file mode 100644 index d6ca98f..0000000 --- a/android/shared_compositor/surface_composer.cpp +++ /dev/null @@ -1,285 +0,0 @@ -/* - * Copyright (C) 2016 Simon Fels - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - * - */ - -#include "surface_composer.h" - -#define LOG_TAG "AnboxSurfaceComposer" -#include - -#include - -#include -#include -#include -#include - -#include -#include - -#include - -namespace { -class DisplayDevice { -public: - enum DisplayType { - DISPLAY_ID_INVALID = -1, - DISPLAY_PRIMARY = HWC_DISPLAY_PRIMARY, - DISPLAY_EXTERNAL = HWC_DISPLAY_EXTERNAL, - DISPLAY_VIRTUAL = HWC_DISPLAY_VIRTUAL, - NUM_BUILTIN_DISPLAY_TYPES = HWC_NUM_PHYSICAL_DISPLAY_TYPES, - }; -}; - -class DisplayEventConnection : public BnDisplayEventConnection { -public: - DisplayEventConnection() : - mChannel(new BitTube) { - } - - status_t postEvent(const DisplayEventReceiver::Event& event) { - return OK; - } - -private: - virtual void setVsyncRate(uint32_t count) { - } - - virtual void requestNextVsync() { - } - - virtual void onFirstRef() { - } - - virtual sp getDataChannel() const { - return mChannel; - } - -private: - sp const mChannel; -}; - -class Surface { -public: - Surface() { - BufferQueue::createBufferQueue(&producer, &consumer); - } - - sp producer; - sp consumer; -}; - -class Client : public BnSurfaceComposerClient { -public: - Client() { } - ~Client() { } - - status_t initCheck() const { - return OK; - } - -private: - virtual status_t createSurface( - const String8& name, - uint32_t w, uint32_t h,PixelFormat format, uint32_t flags, - sp* handle, - sp* gbp) { - return OK; - } - - virtual status_t destroySurface(const sp& handle) { - return OK; - } - - virtual status_t clearLayerFrameStats(const sp& handle) const { - return OK; - } - - virtual status_t getLayerFrameStats(const sp& handle, FrameStats* outStats) const { - return OK; - } - - virtual status_t onTransact(uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { - return OK; - } -}; -} - -namespace anbox { -namespace android { -SurfaceComposer::SurfaceComposer() : - mPrimaryDisplay(new BBinder) { - - hw_module_t const* module; - int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &module); - if (err != 0) { - ALOGE("%s module not found", GRALLOC_HARDWARE_MODULE_ID); - return; - } - framebuffer_open(module, &mFbDev); -} - -SurfaceComposer::~SurfaceComposer() { - if (mFbDev) - framebuffer_close(mFbDev); -} - -void SurfaceComposer::binderDied(const wp&) { - ALOGI("%s", __PRETTY_FUNCTION__); -} - -sp SurfaceComposer::createConnection() { - ALOGI("%s", __PRETTY_FUNCTION__); - sp bclient; - sp client(new Client); - status_t err = client->initCheck(); - if (err == NO_ERROR) { - bclient = client; - } - return bclient; -} - -sp SurfaceComposer::createGraphicBufferAlloc() { - ALOGI("%s", __PRETTY_FUNCTION__); - return nullptr; -} - -sp SurfaceComposer::createDisplayEventConnection() { - ALOGI("%s", __PRETTY_FUNCTION__); - return new DisplayEventConnection; -} - -sp SurfaceComposer::createDisplay(const String8& displayName, bool secure) { - ALOGI("%s", __PRETTY_FUNCTION__); - return nullptr; -} - -void SurfaceComposer::destroyDisplay(const sp& display) { - ALOGI("%s", __PRETTY_FUNCTION__); -} - -sp SurfaceComposer::getBuiltInDisplay(int32_t id) { - if (id != DisplayDevice::DISPLAY_PRIMARY) - return nullptr; - - return mPrimaryDisplay; -} - -void SurfaceComposer::setTransactionState(const Vector& state, - const Vector& displays, uint32_t flags) { - ALOGI("%s", __PRETTY_FUNCTION__); -} - -void SurfaceComposer::bootFinished() { - ALOGI("%s", __PRETTY_FUNCTION__); - - // wait patiently for the window manager death - const String16 name("window"); - sp window(defaultServiceManager()->getService(name)); - if (window != 0) { - window->linkToDeath(static_cast(this)); - } - - // stop boot animation - // formerly we would just kill the process, but we now ask it to exit so it - // can choose where to stop the animation. - property_set("service.bootanim.exit", "1"); -} - -bool SurfaceComposer::authenticateSurfaceTexture(const sp& surface) const { - ALOGI("%s", __PRETTY_FUNCTION__); - return true; -} - -void SurfaceComposer::setPowerMode(const sp& display, int mode) { - ALOGI("%s", __PRETTY_FUNCTION__); -} - -status_t SurfaceComposer::getDisplayConfigs(const sp& display, Vector* configs) { - ALOGI("%s", __PRETTY_FUNCTION__); - - configs->clear(); - - class Density { - static int getDensityFromProperty(char const* propName) { - char property[PROPERTY_VALUE_MAX]; - int density = 0; - if (property_get(propName, property, NULL) > 0) { - density = atoi(property); - } - return density; - } - public: - static int getBuildDensity() { - return getDensityFromProperty("ro.sf.lcd_density"); } - }; - - float density = Density::getBuildDensity() / 160.0f; - - // We will provide a single display configuration element here which is - // the framebuffer we're based on. No further display configurations - // are needed in our case. - DisplayInfo info = DisplayInfo(); - info.density = density; - info.w = mFbDev->width; - info.h = mFbDev->height; - info.xdpi = mFbDev->xdpi; - info.ydpi = mFbDev->ydpi; - info.fps = mFbDev->fps; - info.secure = true; - configs->push_back(info); - - return OK; -} - -status_t SurfaceComposer::getDisplayStats(const sp& display, DisplayStatInfo* stats) { - ALOGI("%s", __PRETTY_FUNCTION__); - return NO_ERROR; -} - -int SurfaceComposer::getActiveConfig(const sp& display) { - ALOGI("%s", __PRETTY_FUNCTION__); - - // We only provide one so it will be always our default - return 0; -} - -status_t SurfaceComposer::setActiveConfig(const sp& display, int id) { - ALOGI("%s", __PRETTY_FUNCTION__); - return OK; -} - -status_t SurfaceComposer::captureScreen(const sp& display, - const sp& producer, - Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, - uint32_t minLayerZ, uint32_t maxLayerZ, - bool useIdentityTransform, - Rotation rotation) { - ALOGI("%s", __PRETTY_FUNCTION__); - return OK; -} - -status_t SurfaceComposer::clearAnimationFrameStats() { - ALOGI("%s", __PRETTY_FUNCTION__); - return OK; -} - -status_t SurfaceComposer::getAnimationFrameStats(FrameStats* outStats) const { - ALOGI("%s", __PRETTY_FUNCTION__); - return OK; -} -} // namespace android -} // namespace anbox diff --git a/android/shared_compositor/surface_composer.h b/android/shared_compositor/surface_composer.h deleted file mode 100644 index 84c7239..0000000 --- a/android/shared_compositor/surface_composer.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright (C) 2016 Simon Fels - * - * This program is free software: you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 3, as published - * by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranties of - * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR - * PURPOSE. See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see . - * - */ - -#ifndef ANBOX_ANDROID_SURFACE_COMPOSER_H_ -#define ANBOX_ANDROID_SURFACE_COMPOSER_H_ - -#include -#include -#include -#include -#include - -using namespace android; - -struct framebuffer_device_t; - -namespace anbox { -namespace android { -class Framebuffer; -class SurfaceComposer : public BinderService, - public BnSurfaceComposer, - public IBinder::DeathRecipient { -public: - static char const *getServiceName() { return "SurfaceFlinger"; } - - SurfaceComposer(); - virtual ~SurfaceComposer(); - - void binderDied(const wp& who) override; - - sp createConnection(); - sp createGraphicBufferAlloc(); - sp createDisplayEventConnection(); - sp createDisplay(const String8& displayName, bool secure); - void destroyDisplay(const sp& display); - sp getBuiltInDisplay(int32_t id); - void setTransactionState(const Vector& state, - const Vector& displays, uint32_t flags); - void bootFinished(); - bool authenticateSurfaceTexture(const sp& surface) const; - void setPowerMode(const sp& display, int mode); - status_t getDisplayConfigs(const sp& display, Vector* configs); - status_t getDisplayStats(const sp& display, DisplayStatInfo* stats); - int getActiveConfig(const sp& display); - status_t setActiveConfig(const sp& display, int id); - status_t captureScreen(const sp& display, - const sp& producer, - Rect sourceCrop, uint32_t reqWidth, uint32_t reqHeight, - uint32_t minLayerZ, uint32_t maxLayerZ, - bool useIdentityTransform, - Rotation rotation = eRotateNone); - status_t clearAnimationFrameStats(); - status_t getAnimationFrameStats(FrameStats* outStats) const; - -private: - sp mPrimaryDisplay; - framebuffer_device_t *mFbDev; -}; -} // namespace android -} // namespace anbox - -#endif