Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
anbox
提交
3ccf1d04
A
anbox
项目概览
openeuler
/
anbox
通知
24
Star
1
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
anbox
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3ccf1d04
编写于
7月 04, 2016
作者:
S
Simon Fels
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a copy of the boot animation service
Will show a app specific icon on boot.
上级
1879e634
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
551 addition
and
0 deletion
+551
-0
android/bootanimation/Android.mk
android/bootanimation/Android.mk
+53
-0
android/bootanimation/BootAnimation.cpp
android/bootanimation/BootAnimation.cpp
+323
-0
android/bootanimation/BootAnimation.h
android/bootanimation/BootAnimation.h
+106
-0
android/bootanimation/bootanimation_main.cpp
android/bootanimation/bootanimation_main.cpp
+69
-0
未找到文件。
android/bootanimation/Android.mk
0 → 100644
浏览文件 @
3ccf1d04
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)
android/bootanimation/BootAnimation.cpp
0 → 100644
浏览文件 @
3ccf1d04
/*
* 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
android/bootanimation/BootAnimation.h
0 → 100644
浏览文件 @
3ccf1d04
/*
* 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
android/bootanimation/bootanimation_main.cpp
0 → 100644
浏览文件 @
3ccf1d04
/*
* 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
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录