What I did (philosophy):

libGDX is based on singletons (Gdx.app etc), moreover user can implement
his own singletons and it just works when libGDX is used to make desktop
applications, android activities etc. Live Wallpaper backend was
designed in wrong way (from libGDX point of view), this design tried to
force libGDX to work in environment it was not designed to. There should
be only one instance of libGDX singletons in application, but libgdx
wallpapers work on many engines with many SurfaceHolders..

I just moved things to (in my opinion) right direction: I forced live
wallpapers API to create environment libGDX is designed to. Redesigned
AndroidLiveWallpaperService stops all this madness linked with switching
wallpaper 'engines' by itself. Rest of user application, libGDX
internals etc. works normally and exactly the same as in other types of
applications (there is only one instantion of ApplicationListener,
AndroidGraphicsLiveWallpaper, GLSurfaceView etc). It should be possible
to run any of existing libgdx apps as wallpaper now (perhaps after
solving few little issues - I'm new in libGDX:)).

All lifecycle issues was resolved. With this LW backend user can switch
wallpapers as fast as he want, can sleep phone in live wallpaper
preview, it now runs without problems on devices on which it crashed
before. No null gl contexts inside render() method.
Much faster wallpaper loading (ex in preview)
Much faster resuming after phone was in sleep mode.
Most of code duplicated for LW backend is no longer used and can be
deleted.

If end developer want to implement custom application behavior in
wallpaper preview, there is additional interface called
AndroidWallpaperListener, he should implement it in his application
listener and respond for event called when preview is opened/closed (see
modified LiveWallpaper test).



What I did (technically):

+ Completely new implementation of AndroidLiveWallpaperService. There
can be many engines in runtime, and any of them is linked with own
SurfaceHolder on wallpaper should draw. But.. only one engine is active
at specific time. Wallpaper service switches smartly between them and
update GLSurfaceView to use currently active SurfaceHolder and render on
it. This is transparent for rest of application, and for GLSurfaceView
itself too! I just simulates events called when surface holder is lost
or restored. GLSurfaceView 'think' its surface was lost and restored,
but really it was just switched to another surface holder (linked with
active wallpaper engine).

+ AndroidGraphicsLiveWallpaper now uses GLSurfaceView and
GLSurfaceViewCapcake as original AndroidGraphics (with slight
modifications). GL..SurfaceViewLW classes are deprecated, not used, and
can be removed completely.

+ AndroidGraphisLiveWallpaper synchronized with current AndroidGraphics
and AndroidGraphicsDaydream (now it is near mirror copy of original
AndroidGraphics, I think you should merge this three classes in near
feature before they will be resynchronized again, it shouldn't be hard
to do)

+ AndroidWallpaperListener, interface that can be implemented in
addition to ApplicationListener in libgdx application to autimatically
add support for live wallpaper specific events

+ updated LiveWallpaper test
+ added synchronization to AndroidGraphicsLiveWallpaper.resume (as in
pause, destroy etc)
+ synchronization in AndroidGraphicsLiveWallpaper.resume
+ fixed synchronization of lifecycle methods in
AndroidGraphicsLiveWallpaper (waiting threads was notified too early and
on some devices it caused errors while rotating device in LWP
preview:
A/libc(1274): Fatal signal 11 (SIGSEGV) at 0x0000003c (code=1), thread
1291 (Thread-153)
+ more logging
+ WallpaperService onDispose improved: GLThread is killed now and audio
is disposed
- disabled logging
+ optimized number of calls to logger (less logging! when pausing /
restoring live wallpaper - which can occur very often in contrast to
regular applications)
+ some cleaning of commented code etc
~ input created without help of AndroidInputFactory - it causes errors
when obfuscated because of reflection relying on plain class names
+ more fixes for lifecycle - pausing of lwp was broken
crashing again..
+ bugfix: "Fatal Signal 11" on some devices when rotating lwp in preview
application listener pause will not be called anymore!
+ fix for surfaceChanged event
disabled logging
Merge branch 'master' of https://github.com/libgdx/libgdx into misc
+ Mesh constructor with optimizations for dynamic meshes
VertexBufferObjestSubData restored to original
Merge branch 'master', remote-tracking branch 'origin/master'
add minimized pause
modify structure and add sync
addressed @bitiotic comment to use local variable