Xserver: show error message when server does not start
This commit is contained in:
@@ -11,4 +11,4 @@ tar -c -z --exclude-vcs --exclude="*.o" --exclude="*.d" --exclude="*.dep" \
|
||||
`find project/jni/application -maxdepth 1 -type f -o -type l` \
|
||||
project/jni/application/src \
|
||||
project/jni/application/`readlink project/jni/application/src` \
|
||||
project/AndroidManifest.xml project/src
|
||||
project/AndroidManifest.xml project/src "$@"
|
||||
|
||||
@@ -23,7 +23,7 @@ InhibitSuspend=n
|
||||
# If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir -
|
||||
# these files are put inside .apk package by build system
|
||||
# Also please avoid 'https://' URLs, many Android devices do not have trust certificates and will fail to connect to SF.net over HTTPS
|
||||
AppDataDownloadUrl="!!Data files|:data.tar.gz:http://10.0.0.99/dist-gimp-wheezy.tar.gz|:data.tar.gz:http://sourceforge.net/projects/libsdl-android/files/ubuntu/dist-gimp-wheezy.tar.gz/download^!!Data files|:busybox:busybox^!!Data files|:DroidSansMono.ttf:DroidSansMono.ttf"
|
||||
AppDataDownloadUrl="!!Data files|:data.tar.gz:http://sourceforge.net/projects/libsdl-android/files/ubuntu/dist-gimp-wheezy.tar.gz/download^!!Data files|:busybox:busybox^!!Data files|:DroidSansMono.ttf:DroidSansMono.ttf"
|
||||
|
||||
# Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only
|
||||
# with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32)
|
||||
|
||||
@@ -245,7 +245,7 @@ void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, i
|
||||
renderString(resStr[i*4+ii], VID_X/8 + (ii*VID_X/4), VID_Y/4 + (i*VID_Y/2));
|
||||
SDL_GetMouseState(&x, &y);
|
||||
renderString("X", x, y);
|
||||
SDL_Delay(200);
|
||||
SDL_Delay(150);
|
||||
SDL_Flip(SDL_GetVideoSurface());
|
||||
}
|
||||
//dpiScale = (float)resVal[res][0] / (float)*resolutionW;
|
||||
@@ -278,7 +278,7 @@ void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, i
|
||||
renderString(fontsStr[i*4+ii], VID_X/8 + (ii*VID_X/4), VID_Y/8 + (i*VID_Y/4));
|
||||
SDL_GetMouseState(&x, &y);
|
||||
renderString("X", x, y);
|
||||
SDL_Delay(200);
|
||||
SDL_Delay(150);
|
||||
SDL_Flip(SDL_GetVideoSurface());
|
||||
}
|
||||
*displayW = *displayW / fontsVal[dpi];
|
||||
@@ -351,15 +351,34 @@ void XSDL_generateBackground(const char * port, int showHelp)
|
||||
SDL_FreeSurface(surf);
|
||||
}
|
||||
|
||||
void XSDL_showServerLaunchErrorMessage()
|
||||
{
|
||||
showErrorMessage( "Error: X server failed to launch,\n"
|
||||
"because of stale Unix socket with non-existing path.\n\n"
|
||||
"Power off your device and power it on,\n"
|
||||
"and everything will work again.");
|
||||
}
|
||||
|
||||
void showErrorMessage(const char *msg)
|
||||
{
|
||||
SDL_Event event;
|
||||
const char * s;
|
||||
int y = VID_Y/3;
|
||||
SDL_FillRect(SDL_GetVideoSurface(), NULL, 0);
|
||||
renderString(msg, VID_X/2, VID_Y/2);
|
||||
for( s = msg; s && s[0]; s = strchr(s, '\n'), s += (s ? 1 : 0), y += 30 )
|
||||
{
|
||||
const char * s1 = strchr(s, '\n');
|
||||
int len = s1 ? s1 - s : strlen(s);
|
||||
char buf[512];
|
||||
strncpy(buf, s, len);
|
||||
buf[len] = 0;
|
||||
if( len > 0 )
|
||||
renderString(buf, VID_X/2, y);
|
||||
}
|
||||
SDL_Flip(SDL_GetVideoSurface());
|
||||
while (1)
|
||||
{
|
||||
while (SDL_PollEvent(&event))
|
||||
while (SDL_WaitEvent(&event))
|
||||
{
|
||||
switch (event.type)
|
||||
{
|
||||
|
||||
@@ -8,5 +8,6 @@ void XSDL_deinitSDL();
|
||||
void XSDL_unpackFiles();
|
||||
void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, int * displayH);
|
||||
void XSDL_generateBackground(const char * port, int showHelp);
|
||||
void XSDL_showServerLaunchErrorMessage();
|
||||
|
||||
#endif
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
extern int android_main( int argc, char *argv[], char *envp[] );
|
||||
|
||||
static void setupEnv(void);
|
||||
static void showError(void);
|
||||
|
||||
int main( int argc, char* argv[] )
|
||||
{
|
||||
@@ -131,6 +132,8 @@ int main( int argc, char* argv[] )
|
||||
for( i = 0; i < ARGNUM; i++ )
|
||||
__android_log_print(ANDROID_LOG_INFO, "XSDL", "> %s", args[i]);
|
||||
|
||||
// We should never quit. If that happens, then the server did not start - show error.
|
||||
atexit(&showError);
|
||||
return android_main( ARGNUM, args, envp );
|
||||
}
|
||||
|
||||
@@ -151,3 +154,10 @@ void setupEnv(void)
|
||||
setenv("USER_ID", buf, 1);
|
||||
setenv("USER", pwd->pw_name, 1);
|
||||
}
|
||||
|
||||
void showError(void)
|
||||
{
|
||||
XSDL_initSDL();
|
||||
XSDL_showServerLaunchErrorMessage();
|
||||
XSDL_deinitSDL();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user