android: drop bootanimation, launcher and share compositor
This commit is contained in:
parent
085e3c56a3
commit
cda160b3b3
16 changed files with 0 additions and 1125 deletions
11
Android.mk
11
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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -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 <stdint.h>
|
||||
#include <sys/types.h>
|
||||
#include <math.h>
|
||||
#include <fcntl.h>
|
||||
#include <utils/misc.h>
|
||||
#include <signal.h>
|
||||
|
||||
#include <cutils/properties.h>
|
||||
|
||||
#include <androidfw/AssetManager.h>
|
||||
#include <binder/IPCThreadState.h>
|
||||
#include <utils/Atomic.h>
|
||||
#include <utils/Errors.h>
|
||||
#include <utils/Log.h>
|
||||
|
||||
#include <ui/PixelFormat.h>
|
||||
#include <ui/Rect.h>
|
||||
#include <ui/Region.h>
|
||||
#include <ui/DisplayInfo.h>
|
||||
|
||||
#include <gui/ISurfaceComposer.h>
|
||||
#include <gui/Surface.h>
|
||||
#include <gui/SurfaceComposerClient.h>
|
||||
|
||||
#include <SkBitmap.h>
|
||||
#include <SkStream.h>
|
||||
#include <SkImageDecoder.h>
|
||||
|
||||
#include <GLES/gl.h>
|
||||
#include <GLES/glext.h>
|
||||
#include <EGL/eglext.h>
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include <hardware/qemu_pipe.h>
|
||||
#include <hardware/qemud.h>
|
||||
|
||||
#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<SurfaceComposerClient> BootAnimation::session() const {
|
||||
return mSession;
|
||||
}
|
||||
|
||||
|
||||
void BootAnimation::binderDied(const wp<IBinder>&)
|
||||
{
|
||||
// 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<IBinder> dtoken(SurfaceComposerClient::getBuiltInDisplay(
|
||||
ISurfaceComposer::eDisplayIdMain));
|
||||
DisplayInfo dinfo;
|
||||
status_t status = SurfaceComposerClient::getDisplayInfo(dtoken, &dinfo);
|
||||
if (status)
|
||||
return -1;
|
||||
|
||||
// create the native surface
|
||||
sp<SurfaceControl> control = session()->createSurface(String8("BootAnimation"),
|
||||
dinfo.w, dinfo.h, PIXEL_FORMAT_RGB_565);
|
||||
|
||||
SurfaceComposerClient::openGlobalTransaction();
|
||||
control->setLayer(0x40000000);
|
||||
SurfaceComposerClient::closeGlobalTransaction();
|
||||
|
||||
sp<Surface> 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
|
||||
|
|
@ -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 <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <androidfw/AssetManager.h>
|
||||
#include <utils/Thread.h>
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES/gl.h>
|
||||
|
||||
class SkBitmap;
|
||||
|
||||
namespace android {
|
||||
|
||||
class Surface;
|
||||
class SurfaceComposerClient;
|
||||
class SurfaceControl;
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class BootAnimation : public Thread, public IBinder::DeathRecipient
|
||||
{
|
||||
public:
|
||||
BootAnimation();
|
||||
virtual ~BootAnimation();
|
||||
|
||||
sp<SurfaceComposerClient> session() const;
|
||||
|
||||
private:
|
||||
virtual bool threadLoop();
|
||||
virtual status_t readyToRun();
|
||||
virtual void onFirstRef();
|
||||
virtual void binderDied(const wp<IBinder>& 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<Frame> frames;
|
||||
bool playUntilComplete;
|
||||
float backgroundColor[3];
|
||||
FileMap* audioFile;
|
||||
};
|
||||
int fps;
|
||||
int width;
|
||||
int height;
|
||||
Vector<Part> parts;
|
||||
};
|
||||
|
||||
status_t initTexture(Texture* texture, void *buffer, size_t size);
|
||||
bool android();
|
||||
bool movie();
|
||||
|
||||
void checkExit();
|
||||
|
||||
sp<SurfaceComposerClient> mSession;
|
||||
AssetManager mAssets;
|
||||
Texture mAndroid[2];
|
||||
int mWidth;
|
||||
int mHeight;
|
||||
EGLDisplay mDisplay;
|
||||
EGLDisplay mContext;
|
||||
EGLDisplay mSurface;
|
||||
sp<SurfaceControl> mFlingerSurfaceControl;
|
||||
sp<Surface> mFlingerSurface;
|
||||
ZipFileRO *mZip;
|
||||
};
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
}; // namespace android
|
||||
|
||||
#endif // ANDROID_BOOTANIMATION_H
|
||||
|
|
@ -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 <cutils/properties.h>
|
||||
|
||||
#include <binder/IPCThreadState.h>
|
||||
#include <binder/ProcessState.h>
|
||||
#include <binder/IServiceManager.h>
|
||||
|
||||
#include <utils/Log.h>
|
||||
#include <utils/threads.h>
|
||||
|
||||
#if defined(HAVE_PTHREADS)
|
||||
# include <pthread.h>
|
||||
# include <sys/resource.h>
|
||||
#endif
|
||||
|
||||
#include "BootAnimation.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
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<ProcessState> proc(ProcessState::self());
|
||||
ProcessState::self()->startThreadPool();
|
||||
|
||||
// create the boot animation object
|
||||
sp<BootAnimation> boot = new BootAnimation();
|
||||
|
||||
IPCThreadState::self()->joinThreadPool();
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.anbox.launcher">
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
|
||||
|
||||
<application
|
||||
android:name=".LauncherApplication"
|
||||
android:label="Anbox Launcher"
|
||||
android:hardwareAccelerated="true"
|
||||
android:largeHeap="false"
|
||||
android:supportsRtl="true">
|
||||
<activity
|
||||
android:name=".Launcher"
|
||||
android:launchMode="singleTask"
|
||||
android:clearTaskOnLaunch="true"
|
||||
android:stateNotNeeded="true"
|
||||
android:resumeWhilePausing="true"
|
||||
android:windowSoftInputMode="adjustPan"
|
||||
android:screenOrientation="nosensor">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.HOME" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.MONKEY"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
tools:context=".Launcher">
|
||||
</RelativeLayout>
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
<resources>
|
||||
<string name="app_name">Anbox Launcher</string>
|
||||
</resources>
|
||||
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
@ -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)
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <sys/resource.h>
|
||||
#include <cutils/sched_policy.h>
|
||||
|
||||
#include <binder/IPCThreadState.h>
|
||||
#include <binder/ProcessState.h>
|
||||
|
||||
#include <binder/IServiceManager.h>
|
||||
#include <binder/BinderService.h>
|
||||
#include <gui/ISurfaceComposer.h>
|
||||
#include <gui/IDisplayEventConnection.h>
|
||||
#include <binder/IPermissionController.h>
|
||||
#include <binder/MemoryHeapBase.h>
|
||||
|
||||
#include "surface_composer.h"
|
||||
|
||||
using namespace android;
|
||||
|
||||
int main(int, char**) {
|
||||
ProcessState::self()->setThreadPoolMaxThreadCount(4);
|
||||
|
||||
sp<ProcessState> 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;
|
||||
}
|
||||
|
|
@ -1,285 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "surface_composer.h"
|
||||
|
||||
#define LOG_TAG "AnboxSurfaceComposer"
|
||||
#include <cutils/log.h>
|
||||
|
||||
#include <ui/DisplayInfo.h>
|
||||
|
||||
#include <gui/DisplayEventReceiver.h>
|
||||
#include <gui/IDisplayEventConnection.h>
|
||||
#include <gui/BitTube.h>
|
||||
#include <gui/BufferQueue.h>
|
||||
|
||||
#include <hardware/hwcomposer_defs.h>
|
||||
#include <hardware/hardware.h>
|
||||
|
||||
#include <cutils/properties.h>
|
||||
|
||||
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<BitTube> getDataChannel() const {
|
||||
return mChannel;
|
||||
}
|
||||
|
||||
private:
|
||||
sp<BitTube> const mChannel;
|
||||
};
|
||||
|
||||
class Surface {
|
||||
public:
|
||||
Surface() {
|
||||
BufferQueue::createBufferQueue(&producer, &consumer);
|
||||
}
|
||||
|
||||
sp<IGraphicBufferProducer> producer;
|
||||
sp<IGraphicBufferConsumer> 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<IBinder>* handle,
|
||||
sp<IGraphicBufferProducer>* gbp) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
virtual status_t destroySurface(const sp<IBinder>& handle) {
|
||||
return OK;
|
||||
}
|
||||
|
||||
virtual status_t clearLayerFrameStats(const sp<IBinder>& handle) const {
|
||||
return OK;
|
||||
}
|
||||
|
||||
virtual status_t getLayerFrameStats(const sp<IBinder>& 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<IBinder>&) {
|
||||
ALOGI("%s", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
sp<ISurfaceComposerClient> SurfaceComposer::createConnection() {
|
||||
ALOGI("%s", __PRETTY_FUNCTION__);
|
||||
sp<ISurfaceComposerClient> bclient;
|
||||
sp<Client> client(new Client);
|
||||
status_t err = client->initCheck();
|
||||
if (err == NO_ERROR) {
|
||||
bclient = client;
|
||||
}
|
||||
return bclient;
|
||||
}
|
||||
|
||||
sp<IGraphicBufferAlloc> SurfaceComposer::createGraphicBufferAlloc() {
|
||||
ALOGI("%s", __PRETTY_FUNCTION__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
sp<IDisplayEventConnection> SurfaceComposer::createDisplayEventConnection() {
|
||||
ALOGI("%s", __PRETTY_FUNCTION__);
|
||||
return new DisplayEventConnection;
|
||||
}
|
||||
|
||||
sp<IBinder> SurfaceComposer::createDisplay(const String8& displayName, bool secure) {
|
||||
ALOGI("%s", __PRETTY_FUNCTION__);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void SurfaceComposer::destroyDisplay(const sp<IBinder>& display) {
|
||||
ALOGI("%s", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
sp<IBinder> SurfaceComposer::getBuiltInDisplay(int32_t id) {
|
||||
if (id != DisplayDevice::DISPLAY_PRIMARY)
|
||||
return nullptr;
|
||||
|
||||
return mPrimaryDisplay;
|
||||
}
|
||||
|
||||
void SurfaceComposer::setTransactionState(const Vector<ComposerState>& state,
|
||||
const Vector<DisplayState>& 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<IBinder> window(defaultServiceManager()->getService(name));
|
||||
if (window != 0) {
|
||||
window->linkToDeath(static_cast<IBinder::DeathRecipient*>(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<IGraphicBufferProducer>& surface) const {
|
||||
ALOGI("%s", __PRETTY_FUNCTION__);
|
||||
return true;
|
||||
}
|
||||
|
||||
void SurfaceComposer::setPowerMode(const sp<IBinder>& display, int mode) {
|
||||
ALOGI("%s", __PRETTY_FUNCTION__);
|
||||
}
|
||||
|
||||
status_t SurfaceComposer::getDisplayConfigs(const sp<IBinder>& display, Vector<DisplayInfo>* 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<IBinder>& display, DisplayStatInfo* stats) {
|
||||
ALOGI("%s", __PRETTY_FUNCTION__);
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
int SurfaceComposer::getActiveConfig(const sp<IBinder>& display) {
|
||||
ALOGI("%s", __PRETTY_FUNCTION__);
|
||||
|
||||
// We only provide one so it will be always our default
|
||||
return 0;
|
||||
}
|
||||
|
||||
status_t SurfaceComposer::setActiveConfig(const sp<IBinder>& display, int id) {
|
||||
ALOGI("%s", __PRETTY_FUNCTION__);
|
||||
return OK;
|
||||
}
|
||||
|
||||
status_t SurfaceComposer::captureScreen(const sp<IBinder>& display,
|
||||
const sp<IGraphicBufferProducer>& 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
|
||||
|
|
@ -1,76 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2016 Simon Fels <morphis@gravedo.de>
|
||||
*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef ANBOX_ANDROID_SURFACE_COMPOSER_H_
|
||||
#define ANBOX_ANDROID_SURFACE_COMPOSER_H_
|
||||
|
||||
#include <gui/IGraphicBufferProducer.h>
|
||||
#include <gui/IGraphicBufferConsumer.h>
|
||||
#include <gui/ISurfaceComposer.h>
|
||||
#include <ui/Rect.h>
|
||||
#include <binder/BinderService.h>
|
||||
|
||||
using namespace android;
|
||||
|
||||
struct framebuffer_device_t;
|
||||
|
||||
namespace anbox {
|
||||
namespace android {
|
||||
class Framebuffer;
|
||||
class SurfaceComposer : public BinderService<SurfaceComposer>,
|
||||
public BnSurfaceComposer,
|
||||
public IBinder::DeathRecipient {
|
||||
public:
|
||||
static char const *getServiceName() { return "SurfaceFlinger"; }
|
||||
|
||||
SurfaceComposer();
|
||||
virtual ~SurfaceComposer();
|
||||
|
||||
void binderDied(const wp<IBinder>& who) override;
|
||||
|
||||
sp<ISurfaceComposerClient> createConnection();
|
||||
sp<IGraphicBufferAlloc> createGraphicBufferAlloc();
|
||||
sp<IDisplayEventConnection> createDisplayEventConnection();
|
||||
sp<IBinder> createDisplay(const String8& displayName, bool secure);
|
||||
void destroyDisplay(const sp<IBinder>& display);
|
||||
sp<IBinder> getBuiltInDisplay(int32_t id);
|
||||
void setTransactionState(const Vector<ComposerState>& state,
|
||||
const Vector<DisplayState>& displays, uint32_t flags);
|
||||
void bootFinished();
|
||||
bool authenticateSurfaceTexture(const sp<IGraphicBufferProducer>& surface) const;
|
||||
void setPowerMode(const sp<IBinder>& display, int mode);
|
||||
status_t getDisplayConfigs(const sp<IBinder>& display, Vector<DisplayInfo>* configs);
|
||||
status_t getDisplayStats(const sp<IBinder>& display, DisplayStatInfo* stats);
|
||||
int getActiveConfig(const sp<IBinder>& display);
|
||||
status_t setActiveConfig(const sp<IBinder>& display, int id);
|
||||
status_t captureScreen(const sp<IBinder>& display,
|
||||
const sp<IGraphicBufferProducer>& 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<IBinder> mPrimaryDisplay;
|
||||
framebuffer_device_t *mFbDev;
|
||||
};
|
||||
} // namespace android
|
||||
} // namespace anbox
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue