ndktest

annotate src/android_native_app_glue.c @ 1:fe78cf853157

fixed the build files
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 24 Apr 2015 03:20:17 +0300
parents
children
rev   line source
nuclear@0 1 /*
nuclear@0 2 * Copyright (C) 2010 The Android Open Source Project
nuclear@0 3 *
nuclear@0 4 * Licensed under the Apache License, Version 2.0 (the "License");
nuclear@0 5 * you may not use this file except in compliance with the License.
nuclear@0 6 * You may obtain a copy of the License at
nuclear@0 7 *
nuclear@0 8 * http://www.apache.org/licenses/LICENSE-2.0
nuclear@0 9 *
nuclear@0 10 * Unless required by applicable law or agreed to in writing, software
nuclear@0 11 * distributed under the License is distributed on an "AS IS" BASIS,
nuclear@0 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
nuclear@0 13 * See the License for the specific language governing permissions and
nuclear@0 14 * limitations under the License.
nuclear@0 15 *
nuclear@0 16 */
nuclear@0 17
nuclear@0 18 #include <jni.h>
nuclear@0 19
nuclear@0 20 #include <errno.h>
nuclear@0 21 #include <string.h>
nuclear@0 22 #include <unistd.h>
nuclear@0 23 #include <sys/resource.h>
nuclear@0 24
nuclear@0 25 #include "android_native_app_glue.h"
nuclear@0 26 #include <android/log.h>
nuclear@0 27
nuclear@0 28 #define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "threaded_app", __VA_ARGS__))
nuclear@0 29 #define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "threaded_app", __VA_ARGS__))
nuclear@0 30
nuclear@0 31 /* For debug builds, always enable the debug traces in this library */
nuclear@0 32 #ifndef NDEBUG
nuclear@0 33 # define LOGV(...) ((void)__android_log_print(ANDROID_LOG_VERBOSE, "threaded_app", __VA_ARGS__))
nuclear@0 34 #else
nuclear@0 35 # define LOGV(...) ((void)0)
nuclear@0 36 #endif
nuclear@0 37
nuclear@0 38 static void free_saved_state(struct android_app* android_app) {
nuclear@0 39 pthread_mutex_lock(&android_app->mutex);
nuclear@0 40 if (android_app->savedState != NULL) {
nuclear@0 41 free(android_app->savedState);
nuclear@0 42 android_app->savedState = NULL;
nuclear@0 43 android_app->savedStateSize = 0;
nuclear@0 44 }
nuclear@0 45 pthread_mutex_unlock(&android_app->mutex);
nuclear@0 46 }
nuclear@0 47
nuclear@0 48 int8_t android_app_read_cmd(struct android_app* android_app) {
nuclear@0 49 int8_t cmd;
nuclear@0 50 if (read(android_app->msgread, &cmd, sizeof(cmd)) == sizeof(cmd)) {
nuclear@0 51 switch (cmd) {
nuclear@0 52 case APP_CMD_SAVE_STATE:
nuclear@0 53 free_saved_state(android_app);
nuclear@0 54 break;
nuclear@0 55 }
nuclear@0 56 return cmd;
nuclear@0 57 } else {
nuclear@0 58 LOGE("No data on command pipe!");
nuclear@0 59 }
nuclear@0 60 return -1;
nuclear@0 61 }
nuclear@0 62
nuclear@0 63 static void print_cur_config(struct android_app* android_app) {
nuclear@0 64 char lang[2], country[2];
nuclear@0 65 AConfiguration_getLanguage(android_app->config, lang);
nuclear@0 66 AConfiguration_getCountry(android_app->config, country);
nuclear@0 67
nuclear@0 68 LOGV("Config: mcc=%d mnc=%d lang=%c%c cnt=%c%c orien=%d touch=%d dens=%d "
nuclear@0 69 "keys=%d nav=%d keysHid=%d navHid=%d sdk=%d size=%d long=%d "
nuclear@0 70 "modetype=%d modenight=%d",
nuclear@0 71 AConfiguration_getMcc(android_app->config),
nuclear@0 72 AConfiguration_getMnc(android_app->config),
nuclear@0 73 lang[0], lang[1], country[0], country[1],
nuclear@0 74 AConfiguration_getOrientation(android_app->config),
nuclear@0 75 AConfiguration_getTouchscreen(android_app->config),
nuclear@0 76 AConfiguration_getDensity(android_app->config),
nuclear@0 77 AConfiguration_getKeyboard(android_app->config),
nuclear@0 78 AConfiguration_getNavigation(android_app->config),
nuclear@0 79 AConfiguration_getKeysHidden(android_app->config),
nuclear@0 80 AConfiguration_getNavHidden(android_app->config),
nuclear@0 81 AConfiguration_getSdkVersion(android_app->config),
nuclear@0 82 AConfiguration_getScreenSize(android_app->config),
nuclear@0 83 AConfiguration_getScreenLong(android_app->config),
nuclear@0 84 AConfiguration_getUiModeType(android_app->config),
nuclear@0 85 AConfiguration_getUiModeNight(android_app->config));
nuclear@0 86 }
nuclear@0 87
nuclear@0 88 void android_app_pre_exec_cmd(struct android_app* android_app, int8_t cmd) {
nuclear@0 89 switch (cmd) {
nuclear@0 90 case APP_CMD_INPUT_CHANGED:
nuclear@0 91 LOGV("APP_CMD_INPUT_CHANGED\n");
nuclear@0 92 pthread_mutex_lock(&android_app->mutex);
nuclear@0 93 if (android_app->inputQueue != NULL) {
nuclear@0 94 AInputQueue_detachLooper(android_app->inputQueue);
nuclear@0 95 }
nuclear@0 96 android_app->inputQueue = android_app->pendingInputQueue;
nuclear@0 97 if (android_app->inputQueue != NULL) {
nuclear@0 98 LOGV("Attaching input queue to looper");
nuclear@0 99 AInputQueue_attachLooper(android_app->inputQueue,
nuclear@0 100 android_app->looper, LOOPER_ID_INPUT, NULL,
nuclear@0 101 &android_app->inputPollSource);
nuclear@0 102 }
nuclear@0 103 pthread_cond_broadcast(&android_app->cond);
nuclear@0 104 pthread_mutex_unlock(&android_app->mutex);
nuclear@0 105 break;
nuclear@0 106
nuclear@0 107 case APP_CMD_INIT_WINDOW:
nuclear@0 108 LOGV("APP_CMD_INIT_WINDOW\n");
nuclear@0 109 pthread_mutex_lock(&android_app->mutex);
nuclear@0 110 android_app->window = android_app->pendingWindow;
nuclear@0 111 pthread_cond_broadcast(&android_app->cond);
nuclear@0 112 pthread_mutex_unlock(&android_app->mutex);
nuclear@0 113 break;
nuclear@0 114
nuclear@0 115 case APP_CMD_TERM_WINDOW:
nuclear@0 116 LOGV("APP_CMD_TERM_WINDOW\n");
nuclear@0 117 pthread_cond_broadcast(&android_app->cond);
nuclear@0 118 break;
nuclear@0 119
nuclear@0 120 case APP_CMD_RESUME:
nuclear@0 121 case APP_CMD_START:
nuclear@0 122 case APP_CMD_PAUSE:
nuclear@0 123 case APP_CMD_STOP:
nuclear@0 124 LOGV("activityState=%d\n", cmd);
nuclear@0 125 pthread_mutex_lock(&android_app->mutex);
nuclear@0 126 android_app->activityState = cmd;
nuclear@0 127 pthread_cond_broadcast(&android_app->cond);
nuclear@0 128 pthread_mutex_unlock(&android_app->mutex);
nuclear@0 129 break;
nuclear@0 130
nuclear@0 131 case APP_CMD_CONFIG_CHANGED:
nuclear@0 132 LOGV("APP_CMD_CONFIG_CHANGED\n");
nuclear@0 133 AConfiguration_fromAssetManager(android_app->config,
nuclear@0 134 android_app->activity->assetManager);
nuclear@0 135 print_cur_config(android_app);
nuclear@0 136 break;
nuclear@0 137
nuclear@0 138 case APP_CMD_DESTROY:
nuclear@0 139 LOGV("APP_CMD_DESTROY\n");
nuclear@0 140 android_app->destroyRequested = 1;
nuclear@0 141 break;
nuclear@0 142 }
nuclear@0 143 }
nuclear@0 144
nuclear@0 145 void android_app_post_exec_cmd(struct android_app* android_app, int8_t cmd) {
nuclear@0 146 switch (cmd) {
nuclear@0 147 case APP_CMD_TERM_WINDOW:
nuclear@0 148 LOGV("APP_CMD_TERM_WINDOW\n");
nuclear@0 149 pthread_mutex_lock(&android_app->mutex);
nuclear@0 150 android_app->window = NULL;
nuclear@0 151 pthread_cond_broadcast(&android_app->cond);
nuclear@0 152 pthread_mutex_unlock(&android_app->mutex);
nuclear@0 153 break;
nuclear@0 154
nuclear@0 155 case APP_CMD_SAVE_STATE:
nuclear@0 156 LOGV("APP_CMD_SAVE_STATE\n");
nuclear@0 157 pthread_mutex_lock(&android_app->mutex);
nuclear@0 158 android_app->stateSaved = 1;
nuclear@0 159 pthread_cond_broadcast(&android_app->cond);
nuclear@0 160 pthread_mutex_unlock(&android_app->mutex);
nuclear@0 161 break;
nuclear@0 162
nuclear@0 163 case APP_CMD_RESUME:
nuclear@0 164 free_saved_state(android_app);
nuclear@0 165 break;
nuclear@0 166 }
nuclear@0 167 }
nuclear@0 168
nuclear@0 169 void app_dummy() {
nuclear@0 170
nuclear@0 171 }
nuclear@0 172
nuclear@0 173 static void android_app_destroy(struct android_app* android_app) {
nuclear@0 174 LOGV("android_app_destroy!");
nuclear@0 175 free_saved_state(android_app);
nuclear@0 176 pthread_mutex_lock(&android_app->mutex);
nuclear@0 177 if (android_app->inputQueue != NULL) {
nuclear@0 178 AInputQueue_detachLooper(android_app->inputQueue);
nuclear@0 179 }
nuclear@0 180 AConfiguration_delete(android_app->config);
nuclear@0 181 android_app->destroyed = 1;
nuclear@0 182 pthread_cond_broadcast(&android_app->cond);
nuclear@0 183 pthread_mutex_unlock(&android_app->mutex);
nuclear@0 184 // Can't touch android_app object after this.
nuclear@0 185 }
nuclear@0 186
nuclear@0 187 static void process_input(struct android_app* app, struct android_poll_source* source) {
nuclear@0 188 AInputEvent* event = NULL;
nuclear@0 189 while (AInputQueue_getEvent(app->inputQueue, &event) >= 0) {
nuclear@0 190 LOGV("New input event: type=%d\n", AInputEvent_getType(event));
nuclear@0 191 if (AInputQueue_preDispatchEvent(app->inputQueue, event)) {
nuclear@0 192 continue;
nuclear@0 193 }
nuclear@0 194 int32_t handled = 0;
nuclear@0 195 if (app->onInputEvent != NULL) handled = app->onInputEvent(app, event);
nuclear@0 196 AInputQueue_finishEvent(app->inputQueue, event, handled);
nuclear@0 197 }
nuclear@0 198 }
nuclear@0 199
nuclear@0 200 static void process_cmd(struct android_app* app, struct android_poll_source* source) {
nuclear@0 201 int8_t cmd = android_app_read_cmd(app);
nuclear@0 202 android_app_pre_exec_cmd(app, cmd);
nuclear@0 203 if (app->onAppCmd != NULL) app->onAppCmd(app, cmd);
nuclear@0 204 android_app_post_exec_cmd(app, cmd);
nuclear@0 205 }
nuclear@0 206
nuclear@0 207 static void* android_app_entry(void* param) {
nuclear@0 208 struct android_app* android_app = (struct android_app*)param;
nuclear@0 209
nuclear@0 210 android_app->config = AConfiguration_new();
nuclear@0 211 AConfiguration_fromAssetManager(android_app->config, android_app->activity->assetManager);
nuclear@0 212
nuclear@0 213 print_cur_config(android_app);
nuclear@0 214
nuclear@0 215 android_app->cmdPollSource.id = LOOPER_ID_MAIN;
nuclear@0 216 android_app->cmdPollSource.app = android_app;
nuclear@0 217 android_app->cmdPollSource.process = process_cmd;
nuclear@0 218 android_app->inputPollSource.id = LOOPER_ID_INPUT;
nuclear@0 219 android_app->inputPollSource.app = android_app;
nuclear@0 220 android_app->inputPollSource.process = process_input;
nuclear@0 221
nuclear@0 222 ALooper* looper = ALooper_prepare(ALOOPER_PREPARE_ALLOW_NON_CALLBACKS);
nuclear@0 223 ALooper_addFd(looper, android_app->msgread, LOOPER_ID_MAIN, ALOOPER_EVENT_INPUT, NULL,
nuclear@0 224 &android_app->cmdPollSource);
nuclear@0 225 android_app->looper = looper;
nuclear@0 226
nuclear@0 227 pthread_mutex_lock(&android_app->mutex);
nuclear@0 228 android_app->running = 1;
nuclear@0 229 pthread_cond_broadcast(&android_app->cond);
nuclear@0 230 pthread_mutex_unlock(&android_app->mutex);
nuclear@0 231
nuclear@0 232 android_main(android_app);
nuclear@0 233
nuclear@0 234 android_app_destroy(android_app);
nuclear@0 235 return NULL;
nuclear@0 236 }
nuclear@0 237
nuclear@0 238 // --------------------------------------------------------------------
nuclear@0 239 // Native activity interaction (called from main thread)
nuclear@0 240 // --------------------------------------------------------------------
nuclear@0 241
nuclear@0 242 static struct android_app* android_app_create(ANativeActivity* activity,
nuclear@0 243 void* savedState, size_t savedStateSize) {
nuclear@0 244 struct android_app* android_app = (struct android_app*)malloc(sizeof(struct android_app));
nuclear@0 245 memset(android_app, 0, sizeof(struct android_app));
nuclear@0 246 android_app->activity = activity;
nuclear@0 247
nuclear@0 248 pthread_mutex_init(&android_app->mutex, NULL);
nuclear@0 249 pthread_cond_init(&android_app->cond, NULL);
nuclear@0 250
nuclear@0 251 if (savedState != NULL) {
nuclear@0 252 android_app->savedState = malloc(savedStateSize);
nuclear@0 253 android_app->savedStateSize = savedStateSize;
nuclear@0 254 memcpy(android_app->savedState, savedState, savedStateSize);
nuclear@0 255 }
nuclear@0 256
nuclear@0 257 int msgpipe[2];
nuclear@0 258 if (pipe(msgpipe)) {
nuclear@0 259 LOGE("could not create pipe: %s", strerror(errno));
nuclear@0 260 return NULL;
nuclear@0 261 }
nuclear@0 262 android_app->msgread = msgpipe[0];
nuclear@0 263 android_app->msgwrite = msgpipe[1];
nuclear@0 264
nuclear@0 265 pthread_attr_t attr;
nuclear@0 266 pthread_attr_init(&attr);
nuclear@0 267 pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
nuclear@0 268 pthread_create(&android_app->thread, &attr, android_app_entry, android_app);
nuclear@0 269
nuclear@0 270 // Wait for thread to start.
nuclear@0 271 pthread_mutex_lock(&android_app->mutex);
nuclear@0 272 while (!android_app->running) {
nuclear@0 273 pthread_cond_wait(&android_app->cond, &android_app->mutex);
nuclear@0 274 }
nuclear@0 275 pthread_mutex_unlock(&android_app->mutex);
nuclear@0 276
nuclear@0 277 return android_app;
nuclear@0 278 }
nuclear@0 279
nuclear@0 280 static void android_app_write_cmd(struct android_app* android_app, int8_t cmd) {
nuclear@0 281 if (write(android_app->msgwrite, &cmd, sizeof(cmd)) != sizeof(cmd)) {
nuclear@0 282 LOGE("Failure writing android_app cmd: %s\n", strerror(errno));
nuclear@0 283 }
nuclear@0 284 }
nuclear@0 285
nuclear@0 286 static void android_app_set_input(struct android_app* android_app, AInputQueue* inputQueue) {
nuclear@0 287 pthread_mutex_lock(&android_app->mutex);
nuclear@0 288 android_app->pendingInputQueue = inputQueue;
nuclear@0 289 android_app_write_cmd(android_app, APP_CMD_INPUT_CHANGED);
nuclear@0 290 while (android_app->inputQueue != android_app->pendingInputQueue) {
nuclear@0 291 pthread_cond_wait(&android_app->cond, &android_app->mutex);
nuclear@0 292 }
nuclear@0 293 pthread_mutex_unlock(&android_app->mutex);
nuclear@0 294 }
nuclear@0 295
nuclear@0 296 static void android_app_set_window(struct android_app* android_app, ANativeWindow* window) {
nuclear@0 297 pthread_mutex_lock(&android_app->mutex);
nuclear@0 298 if (android_app->pendingWindow != NULL) {
nuclear@0 299 android_app_write_cmd(android_app, APP_CMD_TERM_WINDOW);
nuclear@0 300 }
nuclear@0 301 android_app->pendingWindow = window;
nuclear@0 302 if (window != NULL) {
nuclear@0 303 android_app_write_cmd(android_app, APP_CMD_INIT_WINDOW);
nuclear@0 304 }
nuclear@0 305 while (android_app->window != android_app->pendingWindow) {
nuclear@0 306 pthread_cond_wait(&android_app->cond, &android_app->mutex);
nuclear@0 307 }
nuclear@0 308 pthread_mutex_unlock(&android_app->mutex);
nuclear@0 309 }
nuclear@0 310
nuclear@0 311 static void android_app_set_activity_state(struct android_app* android_app, int8_t cmd) {
nuclear@0 312 pthread_mutex_lock(&android_app->mutex);
nuclear@0 313 android_app_write_cmd(android_app, cmd);
nuclear@0 314 while (android_app->activityState != cmd) {
nuclear@0 315 pthread_cond_wait(&android_app->cond, &android_app->mutex);
nuclear@0 316 }
nuclear@0 317 pthread_mutex_unlock(&android_app->mutex);
nuclear@0 318 }
nuclear@0 319
nuclear@0 320 static void android_app_free(struct android_app* android_app) {
nuclear@0 321 pthread_mutex_lock(&android_app->mutex);
nuclear@0 322 android_app_write_cmd(android_app, APP_CMD_DESTROY);
nuclear@0 323 while (!android_app->destroyed) {
nuclear@0 324 pthread_cond_wait(&android_app->cond, &android_app->mutex);
nuclear@0 325 }
nuclear@0 326 pthread_mutex_unlock(&android_app->mutex);
nuclear@0 327
nuclear@0 328 close(android_app->msgread);
nuclear@0 329 close(android_app->msgwrite);
nuclear@0 330 pthread_cond_destroy(&android_app->cond);
nuclear@0 331 pthread_mutex_destroy(&android_app->mutex);
nuclear@0 332 free(android_app);
nuclear@0 333 }
nuclear@0 334
nuclear@0 335 static void onDestroy(ANativeActivity* activity) {
nuclear@0 336 LOGV("Destroy: %p\n", activity);
nuclear@0 337 android_app_free((struct android_app*)activity->instance);
nuclear@0 338 }
nuclear@0 339
nuclear@0 340 static void onStart(ANativeActivity* activity) {
nuclear@0 341 LOGV("Start: %p\n", activity);
nuclear@0 342 android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_START);
nuclear@0 343 }
nuclear@0 344
nuclear@0 345 static void onResume(ANativeActivity* activity) {
nuclear@0 346 LOGV("Resume: %p\n", activity);
nuclear@0 347 android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_RESUME);
nuclear@0 348 }
nuclear@0 349
nuclear@0 350 static void* onSaveInstanceState(ANativeActivity* activity, size_t* outLen) {
nuclear@0 351 struct android_app* android_app = (struct android_app*)activity->instance;
nuclear@0 352 void* savedState = NULL;
nuclear@0 353
nuclear@0 354 LOGV("SaveInstanceState: %p\n", activity);
nuclear@0 355 pthread_mutex_lock(&android_app->mutex);
nuclear@0 356 android_app->stateSaved = 0;
nuclear@0 357 android_app_write_cmd(android_app, APP_CMD_SAVE_STATE);
nuclear@0 358 while (!android_app->stateSaved) {
nuclear@0 359 pthread_cond_wait(&android_app->cond, &android_app->mutex);
nuclear@0 360 }
nuclear@0 361
nuclear@0 362 if (android_app->savedState != NULL) {
nuclear@0 363 savedState = android_app->savedState;
nuclear@0 364 *outLen = android_app->savedStateSize;
nuclear@0 365 android_app->savedState = NULL;
nuclear@0 366 android_app->savedStateSize = 0;
nuclear@0 367 }
nuclear@0 368
nuclear@0 369 pthread_mutex_unlock(&android_app->mutex);
nuclear@0 370
nuclear@0 371 return savedState;
nuclear@0 372 }
nuclear@0 373
nuclear@0 374 static void onPause(ANativeActivity* activity) {
nuclear@0 375 LOGV("Pause: %p\n", activity);
nuclear@0 376 android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_PAUSE);
nuclear@0 377 }
nuclear@0 378
nuclear@0 379 static void onStop(ANativeActivity* activity) {
nuclear@0 380 LOGV("Stop: %p\n", activity);
nuclear@0 381 android_app_set_activity_state((struct android_app*)activity->instance, APP_CMD_STOP);
nuclear@0 382 }
nuclear@0 383
nuclear@0 384 static void onConfigurationChanged(ANativeActivity* activity) {
nuclear@0 385 struct android_app* android_app = (struct android_app*)activity->instance;
nuclear@0 386 LOGV("ConfigurationChanged: %p\n", activity);
nuclear@0 387 android_app_write_cmd(android_app, APP_CMD_CONFIG_CHANGED);
nuclear@0 388 }
nuclear@0 389
nuclear@0 390 static void onLowMemory(ANativeActivity* activity) {
nuclear@0 391 struct android_app* android_app = (struct android_app*)activity->instance;
nuclear@0 392 LOGV("LowMemory: %p\n", activity);
nuclear@0 393 android_app_write_cmd(android_app, APP_CMD_LOW_MEMORY);
nuclear@0 394 }
nuclear@0 395
nuclear@0 396 static void onWindowFocusChanged(ANativeActivity* activity, int focused) {
nuclear@0 397 LOGV("WindowFocusChanged: %p -- %d\n", activity, focused);
nuclear@0 398 android_app_write_cmd((struct android_app*)activity->instance,
nuclear@0 399 focused ? APP_CMD_GAINED_FOCUS : APP_CMD_LOST_FOCUS);
nuclear@0 400 }
nuclear@0 401
nuclear@0 402 static void onNativeWindowCreated(ANativeActivity* activity, ANativeWindow* window) {
nuclear@0 403 LOGV("NativeWindowCreated: %p -- %p\n", activity, window);
nuclear@0 404 android_app_set_window((struct android_app*)activity->instance, window);
nuclear@0 405 }
nuclear@0 406
nuclear@0 407 static void onNativeWindowDestroyed(ANativeActivity* activity, ANativeWindow* window) {
nuclear@0 408 LOGV("NativeWindowDestroyed: %p -- %p\n", activity, window);
nuclear@0 409 android_app_set_window((struct android_app*)activity->instance, NULL);
nuclear@0 410 }
nuclear@0 411
nuclear@0 412 static void onInputQueueCreated(ANativeActivity* activity, AInputQueue* queue) {
nuclear@0 413 LOGV("InputQueueCreated: %p -- %p\n", activity, queue);
nuclear@0 414 android_app_set_input((struct android_app*)activity->instance, queue);
nuclear@0 415 }
nuclear@0 416
nuclear@0 417 static void onInputQueueDestroyed(ANativeActivity* activity, AInputQueue* queue) {
nuclear@0 418 LOGV("InputQueueDestroyed: %p -- %p\n", activity, queue);
nuclear@0 419 android_app_set_input((struct android_app*)activity->instance, NULL);
nuclear@0 420 }
nuclear@0 421
nuclear@0 422 void ANativeActivity_onCreate(ANativeActivity* activity,
nuclear@0 423 void* savedState, size_t savedStateSize) {
nuclear@0 424 LOGV("Creating: %p\n", activity);
nuclear@0 425 activity->callbacks->onDestroy = onDestroy;
nuclear@0 426 activity->callbacks->onStart = onStart;
nuclear@0 427 activity->callbacks->onResume = onResume;
nuclear@0 428 activity->callbacks->onSaveInstanceState = onSaveInstanceState;
nuclear@0 429 activity->callbacks->onPause = onPause;
nuclear@0 430 activity->callbacks->onStop = onStop;
nuclear@0 431 activity->callbacks->onConfigurationChanged = onConfigurationChanged;
nuclear@0 432 activity->callbacks->onLowMemory = onLowMemory;
nuclear@0 433 activity->callbacks->onWindowFocusChanged = onWindowFocusChanged;
nuclear@0 434 activity->callbacks->onNativeWindowCreated = onNativeWindowCreated;
nuclear@0 435 activity->callbacks->onNativeWindowDestroyed = onNativeWindowDestroyed;
nuclear@0 436 activity->callbacks->onInputQueueCreated = onInputQueueCreated;
nuclear@0 437 activity->callbacks->onInputQueueDestroyed = onInputQueueDestroyed;
nuclear@0 438
nuclear@0 439 activity->instance = android_app_create(activity, savedState, savedStateSize);
nuclear@0 440 }