Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

pandora specific modifications

  • Loading branch information...
commit 62dc28ce08dfb8f36f535731d0c9a612ccfc57f7 1 parent ef6cecd
@crowriot crowriot authored
View
11 README
@@ -28,6 +28,8 @@ apkenv with the apk file as its argument. To use it, type:
apkenv --install /path/to/your.apk
+please not that installing is not support on the pandora port yet.
+
softfp vs. hardfp
=================
@@ -35,6 +37,7 @@ softfp vs. hardfp
Android is softfp.
Maemo 5 is softfp.
MeeGo 1.2 Harmattan is hardfp.
+Pandora is softfp.
softfp and hardfp differ in the way functions with floating point arguments
get called. Trying to call a hardfp function with the softfp calling
@@ -122,3 +125,11 @@ compat/hooks.c, compat/pthread_wrapper.c:
pthread wrapper implementation based on code from libhybris
Copyright (C) 2012 Carsten Munk
+
+Pandora Port
+============
+
+All code written by me (crowriot) for apkenv's pandora port is
+licensed under same conditions as the apkenv itself.
+
+
View
53 apkenv.c
@@ -37,6 +37,8 @@
#include <SDL/SDL.h>
#ifdef FREMANTLE
# include <SDL/SDL_gles.h>
+#elif defined(PANDORA)
+# include "pandora/glesinit.h"
#endif
#include <SDL/SDL_syswm.h>
@@ -178,8 +180,11 @@ void install_overrides(struct SupportModule *module)
void
usage()
{
- printf("Usage: %s [--install] <file.apk>\n",
- global.apkenv_executable);
+#if !defined(LOCAL_SHARE_APPLICATIONS)
+ printf("Usage: %s <file.apk>\n",global.apkenv_executable);
+#else
+ printf("Usage: %s [--install] <file.apk>\n",global.apkenv_executable);
+#endif
exit(1);
}
@@ -215,11 +220,10 @@ recursive_mkdir(const char *directory)
free(tmp);
}
-#define LOCAL_SHARE_APPLICATIONS "/home/user/.local/share/applications/"
-
void
operation(const char *operation, const char *filename)
{
+#if defined(LOCAL_SHARE_APPLICATIONS)
if (strcmp(operation, "--install") == 0) {
char apkenv_absolute[PATH_MAX];
char apk_absolute[PATH_MAX];
@@ -265,7 +269,7 @@ operation(const char *operation, const char *filename)
}
char desktop_filename[PATH_MAX];
- recursive_mkdir(LOCAL_SHARE_APPLICATIONS);
+ recursive_mkdir();
sprintf(desktop_filename, "%s/%s.desktop", LOCAL_SHARE_APPLICATIONS,
app_name);
@@ -286,10 +290,14 @@ operation(const char *operation, const char *filename)
}
usage();
+#endif
}
#define MEEGOTOUCH_BORDER 16
+//#define NOSDL
+
+
int main(int argc, char **argv)
{
char **tmp;
@@ -317,24 +325,26 @@ int main(int argc, char **argv)
global.lookup_symbol = lookup_symbol_impl;
global.foreach_file = foreach_file_impl;
global.read_file = read_file_impl;
+
jnienv_init(&global);
javavm_init(&global);
global.apk_filename = strdup(argv[argc-1]);
global.apklib_handle = apk_open(global.apk_filename);
global.support_modules = NULL;
+
const char *shlib = apk_get_shared_library(global.apklib_handle);
if (shlib == NULL) {
printf("Not a native APK.\n");
return 0;
}
+ SDL_Surface* screen;
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO | SDL_INIT_JOYSTICK) < 0) {
printf("SDL Init failed.\n");
return 0;
}
- SDL_Surface *screen;
/**
* The following block looks scary, but it just creates an SDL surface
@@ -343,6 +353,14 @@ int main(int argc, char **argv)
* (where the GLES features are integrated directly into libSDL), only
* SDL is used.
**/
+#ifdef PANDORA
+ screen = SDL_SetVideoMode(SCREEN_WIDTH,SCREEN_HEIGHT,0,SDL_FULLSCREEN);
+ void* gles = GLES_Init(1);
+ if (!gles) {
+ fprintf(stderr,"ERROR: GLES_Init failed.\n");
+ return 0;
+ }
+#else
#ifdef FREMANTLE
#ifdef APKENV_GLES2
SDL_GLES_Init(SDL_GLES_VERSION_2_0);
@@ -359,10 +377,11 @@ int main(int argc, char **argv)
#endif /* APKENV_GLES2 */
screen = SDL_SetVideoMode(0, 0, 0, SDL_OPENGLES | SDL_FULLSCREEN);
#endif /* FREMANTLE */
+#endif /* PANDORA */
SDL_ShowCursor(0);
-#ifndef FREMANTLE
+#if !defined(FREMANTLE) && !defined(PANDORA)
/* Set up swipe lock (left and right) */
SDL_SysWMinfo wm;
SDL_VERSION(&wm.version);
@@ -388,7 +407,8 @@ int main(int argc, char **argv)
}
load_modules(".");
- load_modules("/opt/apkenv/modules");
+ load_modules(MODULE_DIRECTORY_BASE);
+
if (global.support_modules == NULL) {
printf("No support modules found.\n");
}
@@ -425,9 +445,16 @@ int main(int argc, char **argv)
module->init(module, screen->w, screen->h, data_directory);
while (1) {
+
SDL_Event e;
while (SDL_PollEvent(&e)) {
- if (e.type == SDL_MOUSEBUTTONDOWN) {
+ if (e.type == SDL_KEYDOWN) {
+ if (e.key.keysym.sym==SDLK_ESCAPE) {
+ module->deinit(module);
+ goto finish;
+ }
+ }
+ else if (e.type == SDL_MOUSEBUTTONDOWN) {
module->input(module, ACTION_DOWN, e.button.x, e.button.y, e.button.which);
} else if (e.type == SDL_MOUSEBUTTONUP) {
module->input(module, ACTION_UP, e.button.x, e.button.y, e.button.which);
@@ -455,7 +482,9 @@ int main(int argc, char **argv)
}
}
module->update(module);
-#ifdef FREMANTLE
+#ifdef PANDORA
+ GLES_SwapBuffers(gles);
+#elif defined(FREMANTLE)
SDL_GLES_SwapBuffers();
#else
SDL_GL_SwapBuffers();
@@ -470,6 +499,10 @@ int main(int argc, char **argv)
free(global.method_table);
apk_close(global.apklib_handle);
+#ifdef PANDORA
+ GLES_Exit(gles);
+#endif
+
return 0;
}
View
17 apkenv.h
@@ -93,7 +93,22 @@ struct GlobalState {
#define VM(global_ptr) (&((global_ptr)->vm))
#define ENV(global_ptr) (&((global_ptr)->env))
+#if defined(PANDORA)
+#define DATA_DIRECTORY_BASE "./data/"
+#else
#define DATA_DIRECTORY_BASE "/home/user/.apkenv/"
+#endif
+
+
+#if defined(PANDORA)
+#define MODULE_DIRECTORY_BASE "./modules/"
+#undef LOCAL_SHARE_APPLICATIONS
+#else
+#define MODULE_DIRECTORY_BASE "/opt/apkenv/modules/"
+#define LOCAL_SHARE_APPLICATIONS "/home/user/.local/share/applications/"
+#endif
+
+
/* Android MotionEvent */
#define ACTION_DOWN 0
@@ -104,7 +119,7 @@ struct GlobalState {
* Attribute for softfp-calling-style functions
* (only on Harmattan - Fremantle *is* softfp)
**/
-#ifdef FREMANTLE
+#if defined(FREMANTLE) || defined(PANDORA)
# define SOFTFP
#else
# define SOFTFP __attribute__((pcs("aapcs")))
View
20 apklib/apklib.c
@@ -38,6 +38,9 @@
#include "apklib.h"
+
+#define DBG(msg) fprintf(stderr,"%s(%d): %s\n",__FILE__,__LINE__,#msg)
+
AndroidApk *
apk_open(const char *filename)
{
@@ -51,7 +54,7 @@ apk_get_shared_library(AndroidApk *apk)
{
assert(apk != NULL);
- char filename[PATH_MAX];
+ char filename[PATH_MAX], tmpname[PATH_MAX];
FILE *result = NULL;
char buf[64*1024];
int read;
@@ -61,13 +64,21 @@ apk_get_shared_library(AndroidApk *apk)
}
do {
- if (unzGetCurrentFileInfo(apk->zip, NULL, filename, sizeof(filename),
- NULL, 0, NULL, 0) == UNZ_OK) {
+ if (unzGetCurrentFileInfo(apk->zip, NULL, filename, sizeof(filename), NULL, 0, NULL, 0) == UNZ_OK) {
if (memcmp(filename, "lib/armeabi", 11) == 0) {
if (unzOpenCurrentFile(apk->zip) == UNZ_OK) {
+
+
+
+#if !defined(PANDORA)
strcpy(filename, "/home/user/.apkenv-XXXXXX");
int fd = mkstemp(filename);
result = fdopen(fd, "w+b");
+#else
+ sprintf(filename,"./%s",strdup(filename));
+ recursive_mkdir(filename);
+ result = fopen(filename, "w+b");
+#endif
while (!unzeof(apk->zip)) {
read = unzReadCurrentFile(apk->zip, buf, sizeof(buf));
if (read) {
@@ -76,6 +87,9 @@ apk_get_shared_library(AndroidApk *apk)
}
fclose(result);
unzCloseCurrentFile(apk->zip);
+#if defined(PANDORA)
+ sync();
+#endif
return strdup(filename);
}
break;
View
5 linker/dlfcn.c
@@ -60,6 +60,7 @@ void *android_dlopen(const char *filename, int flag)
pthread_mutex_lock(&dl_lock);
ret = find_library(filename);
+
if (unlikely(ret == NULL)) {
set_dlerror(DL_ERR_CANNOT_LOAD_LIBRARY);
} else {
@@ -85,7 +86,7 @@ void *android_dlsym(void *handle, const char *symbol)
pthread_mutex_lock(&dl_lock);
- if(unlikely(handle == 0)) {
+ if(unlikely(handle == 0)) {
set_dlerror(DL_ERR_INVALID_LIBRARY_HANDLE);
goto err;
}
@@ -271,4 +272,4 @@ soinfo libdl_info = {
bucket: libdl_buckets,
chain: libdl_chains,
};
-
+
View
11 linker/linker.c
@@ -588,12 +588,21 @@ static void dump(soinfo *si)
}
#endif
+#if defined(PANDORA)
+static const char *sopaths[] = {
+ "./vendor/lib/",
+ "./system/lib/",
+ "./lib/",
+ 0
+};
+#else
static const char *sopaths[] = {
"/vendor/lib",
"/system/lib",
"/opt/apkenv/bionic/",
0
};
+#endif
static int _open_lib(const char *name)
{
@@ -1698,7 +1707,7 @@ static int link_image(soinfo *si, unsigned wr_offset)
if (si->flags & (FLAG_EXE | FLAG_LINKER)) {
/* Locate the needed program segments (DYNAMIC/ARM_EXIDX) for
- * linkage info if this is the executable or the linker itself.
+ * linkage info if this is the executable or the linker itself.
* If this was a dynamic lib, that would have been done at load time.
*
* TODO: It's unfortunate that small pieces of this are
Please sign in to comment.
Something went wrong with that request. Please try again.