diff options
Diffstat (limited to 'native')
-rw-r--r-- | native/android/Android.mk | 1 | ||||
-rw-r--r-- | native/android/asset_manager.cpp | 2 | ||||
-rw-r--r-- | native/android/configuration.cpp | 202 | ||||
-rw-r--r-- | native/copy-to-ndk.sh | 55 | ||||
-rw-r--r-- | native/include/android/asset_manager.h | 10 | ||||
-rw-r--r-- | native/include/android/asset_manager_jni.h | 40 | ||||
-rw-r--r-- | native/include/android/configuration.h | 319 | ||||
-rw-r--r-- | native/include/android/native_activity.h | 10 | ||||
-rw-r--r-- | native/include/android/native_window.h | 11 |
9 files changed, 638 insertions, 12 deletions
diff --git a/native/android/Android.mk b/native/android/Android.mk index 950a1e9..bd2b27a 100644 --- a/native/android/Android.mk +++ b/native/android/Android.mk @@ -7,6 +7,7 @@ include $(CLEAR_VARS) # LOCAL_SRC_FILES:= \ asset_manager.cpp \ + configuration.cpp \ input.cpp \ looper.cpp \ native_activity.cpp \ diff --git a/native/android/asset_manager.cpp b/native/android/asset_manager.cpp index 36c381e..3f7c1b6 100644 --- a/native/android/asset_manager.cpp +++ b/native/android/asset_manager.cpp @@ -17,7 +17,7 @@ #define LOG_TAG "NAsset" #include <utils/Log.h> -#include <android/asset_manager.h> +#include <android/asset_manager_jni.h> #include <utils/AssetManager.h> #include <utils/AssetDir.h> #include <utils/Asset.h> diff --git a/native/android/configuration.cpp b/native/android/configuration.cpp new file mode 100644 index 0000000..d76164f --- /dev/null +++ b/native/android/configuration.cpp @@ -0,0 +1,202 @@ +/* + * Copyright (C) 2010 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 "Configuration" +#include <utils/Log.h> + +#include <utils/AssetManager.h> + +#include <android_runtime/android_content_res_Configuration.h> + +using namespace android; + +AConfiguration* AConfiguration_new() { + AConfiguration* config = new AConfiguration; + memset(config, 0, sizeof(AConfiguration)); + return config; +} + +void AConfiguration_delete(AConfiguration* config) { + delete config; +} + +void AConfiguration_fromAssetManager(AConfiguration* out, AAssetManager* am) { + ((AssetManager*)am)->getConfiguration(out); +} + +void AConfiguration_copy(AConfiguration* dest, AConfiguration* src) { + *dest = *src; +} + +int32_t AConfiguration_getMcc(AConfiguration* config) { + return config->mcc; +} + +int32_t AConfiguration_getMnc(AConfiguration* config) { + return config->mnc; +} + +void AConfiguration_getLanguage(AConfiguration* config, char* outLanguage) { + outLanguage[0] = config->language[0]; + outLanguage[1] = config->language[1]; +} + +void AConfiguration_getCountry(AConfiguration* config, char* outCountry) { + outCountry[0] = config->country[0]; + outCountry[1] = config->country[1]; +} + +int32_t AConfiguration_getOrientation(AConfiguration* config) { + return config->orientation; +} + +int32_t AConfiguration_getTouchscreen(AConfiguration* config) { + return config->touchscreen; +} + +int32_t AConfiguration_getDensity(AConfiguration* config) { + return config->density; +} + +int32_t AConfiguration_getKeyboard(AConfiguration* config) { + return config->keyboard; +} + +int32_t AConfiguration_getNavigation(AConfiguration* config) { + return config->navigation; +} + +int32_t AConfiguration_getKeysHidden(AConfiguration* config) { + return config->inputFlags&ResTable_config::MASK_KEYSHIDDEN; +} + +int32_t AConfiguration_getNavHidden(AConfiguration* config) { + return (config->inputFlags&ResTable_config::MASK_NAVHIDDEN) + >> ResTable_config::SHIFT_NAVHIDDEN; +} + +int32_t AConfiguration_getSdkVersion(AConfiguration* config) { + return config->sdkVersion; +} + +int32_t AConfiguration_getScreenSize(AConfiguration* config) { + return config->screenLayout&ResTable_config::MASK_SCREENSIZE; +} + +int32_t AConfiguration_getScreenLong(AConfiguration* config) { + return (config->screenLayout&ResTable_config::MASK_SCREENLONG) + >> ResTable_config::SHIFT_SCREENLONG; +} + +int32_t AConfiguration_getUiModeType(AConfiguration* config) { + return config->uiMode&ResTable_config::MASK_UI_MODE_TYPE; +} + +int32_t AConfiguration_getUiModeNight(AConfiguration* config) { + return (config->uiMode&ResTable_config::MASK_UI_MODE_NIGHT) + >> ResTable_config::SHIFT_UI_MODE_NIGHT; + +} + +// ---------------------------------------------------------------------- + +void AConfiguration_setMcc(AConfiguration* config, int32_t mcc) { + config->mcc = mcc; +} + +void AConfiguration_setMnc(AConfiguration* config, int32_t mnc) { + config->mnc = mnc; +} + +void AConfiguration_setLanguage(AConfiguration* config, const char* language) { + config->language[0] = language[0]; + config->language[1] = language[1]; +} + +void AConfiguration_setCountry(AConfiguration* config, const char* country) { + config->country[0] = country[0]; + config->country[1] = country[1]; +} + +void AConfiguration_setOrientation(AConfiguration* config, int32_t orientation) { + config->orientation = orientation; +} + +void AConfiguration_setTouchscreen(AConfiguration* config, int32_t touchscreen) { + config->touchscreen = touchscreen; +} + +void AConfiguration_setDensity(AConfiguration* config, int32_t density) { + config->density = density; +} + +void AConfiguration_setKeyboard(AConfiguration* config, int32_t keyboard) { + config->keyboard = keyboard; +} + +void AConfiguration_setNavigation(AConfiguration* config, int32_t navigation) { + config->navigation = navigation; +} + +void AConfiguration_setKeysHidden(AConfiguration* config, int32_t keysHidden) { + config->inputFlags = (config->inputFlags&~ResTable_config::MASK_KEYSHIDDEN) + | (keysHidden&ResTable_config::MASK_KEYSHIDDEN); +} + +void AConfiguration_setNavHidden(AConfiguration* config, int32_t navHidden) { + config->inputFlags = (config->inputFlags&~ResTable_config::MASK_NAVHIDDEN) + | ((navHidden<<ResTable_config::SHIFT_NAVHIDDEN)&ResTable_config::MASK_NAVHIDDEN); +} + +void AConfiguration_setSdkVersion(AConfiguration* config, int32_t sdkVersion) { + config->sdkVersion = sdkVersion; +} + +void AConfiguration_setScreenSize(AConfiguration* config, int32_t screenSize) { + config->screenLayout = (config->screenLayout&~ResTable_config::MASK_SCREENSIZE) + | (screenSize&ResTable_config::MASK_SCREENSIZE); +} + +void AConfiguration_setScreenLong(AConfiguration* config, int32_t screenLong) { + config->screenLayout = (config->screenLayout&~ResTable_config::MASK_SCREENLONG) + | ((screenLong<<ResTable_config::SHIFT_SCREENLONG)&ResTable_config::MASK_SCREENLONG); +} + +void AConfiguration_setUiModeType(AConfiguration* config, int32_t uiModeType) { + config->uiMode = (config->uiMode&~ResTable_config::MASK_UI_MODE_TYPE) + | (uiModeType&ResTable_config::MASK_UI_MODE_TYPE); +} + +void AConfiguration_setUiModeNight(AConfiguration* config, int32_t uiModeNight) { + config->uiMode = (config->uiMode&~ResTable_config::MASK_UI_MODE_NIGHT) + | ((uiModeNight<<ResTable_config::SHIFT_UI_MODE_NIGHT)&ResTable_config::MASK_UI_MODE_NIGHT); + +} + +// ---------------------------------------------------------------------- + +int32_t AConfiguration_diff(AConfiguration* config1, AConfiguration* config2) { + return (config1->diff(*config2)); +} + +int32_t AConfiguration_match(AConfiguration* base, AConfiguration* requested) { + return base->match(*requested); +} + +int32_t AConfiguration_isBetterThan(AConfiguration* base, AConfiguration* test, + AConfiguration* requested) { + return base->isBetterThan(*test, requested); +} diff --git a/native/copy-to-ndk.sh b/native/copy-to-ndk.sh new file mode 100644 index 0000000..4f5a16a --- /dev/null +++ b/native/copy-to-ndk.sh @@ -0,0 +1,55 @@ +# Take care of copying current header files over to the correct +# location in the NDK. + +copyndkheaders() { + local CURR_PLATFORM=android-9 + local ALL_PLATFORMS="$CURR_PLATFORM android-8 android-5 android-4 android-3" + + local SRC_HEADERS=$ANDROID_BUILD_TOP/frameworks/base/native/include/android + local NDK_PLATFORMS=$ANDROID_BUILD_TOP/development/ndk/platforms + local DST_HEADERS=$NDK_PLATFORMS/$CURR_PLATFORM + + local SRC_LIB_ANDROID=$ANDROID_PRODUCT_OUT/system/lib/libandroid.so + local DST_LIB_ANDROID=$NDK_PLATFORMS/$CURR_PLATFORM/arch-arm/usr/lib/libandroid.so + + local didsomething="" + + #echo "SRC_HEADERS: $SRC_HEADERS" + + for i in $(cd $SRC_HEADERS; ls *.h); do + local src=$SRC_HEADERS/$i + local changed="" + for j in $ALL_PLATFORMS; do + local dst=$NDK_PLATFORMS/$j/arch-arm/usr/include/android/$i + if [ "$changed" == "" -a -e $dst ]; then + #echo "Exists: $dst" + if diff $src $dst >/dev/null; then + echo "$i: has not changed from $j" >/dev/null + changed="false" + else + changed="true" + echo "$i: has changed from $j" >/dev/null + fi + fi + done + if [ "$changed" == "true" -o "$changed" == "" ]; then + echo "Updating: $i" + cp $src $NDK_PLATFORMS/$CURR_PLATFORM/arch-arm/usr/include/android/$i + didsomething="true" + fi + done + + if diff $SRC_LIB_ANDROID $DST_LIB_ANDROID >/dev/null; then + echo "libandroid.so: has not changed" >/dev/null + else + echo "Updating: $DST_LIB_ANDROID" + cp $SRC_LIB_ANDROID $DST_LIB_ANDROID + didsomething="true" + fi + if [ "$didsomething" != "" ]; then + echo "Headers changed... rebuilding platforms." + sh $ANDROID_BUILD_TOP/ndk/build/tools/build-platforms.sh + fi +} + +copyndkheaders diff --git a/native/include/android/asset_manager.h b/native/include/android/asset_manager.h index 89989f8..4fa0ef3 100644 --- a/native/include/android/asset_manager.h +++ b/native/include/android/asset_manager.h @@ -18,8 +18,6 @@ #ifndef ANDROID_ASSET_MANAGER_H #define ANDROID_ASSET_MANAGER_H -#include <jni.h> - #ifdef __cplusplus extern "C" { #endif @@ -43,14 +41,6 @@ enum { /** - * Given a Dalvik AssetManager object, obtain the corresponding native AAssetManager - * object. Note that the caller is responsible for obtaining and holding a VM reference - * to the jobject to prevent its being garbage collected while the native object is - * in use. - */ -AAssetManager* AAssetManager_fromJava(JNIEnv* env, jobject assetManager); - -/** * Open the named directory within the asset hierarchy. The directory can then * be inspected with the AAssetDir functions. To open the top-level directory, * pass in "" as the dirName. diff --git a/native/include/android/asset_manager_jni.h b/native/include/android/asset_manager_jni.h new file mode 100644 index 0000000..aec2d3c --- /dev/null +++ b/native/include/android/asset_manager_jni.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2010 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_ASSET_MANAGER_JNI_H +#define ANDROID_ASSET_MANAGER_JNI_H + +#include <android/asset_manager.h> +#include <jni.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * Given a Dalvik AssetManager object, obtain the corresponding native AAssetManager + * object. Note that the caller is responsible for obtaining and holding a VM reference + * to the jobject to prevent its being garbage collected while the native object is + * in use. + */ +AAssetManager* AAssetManager_fromJava(JNIEnv* env, jobject assetManager); + +#ifdef __cplusplus +}; +#endif + +#endif // ANDROID_ASSET_MANAGER_JNI_H diff --git a/native/include/android/configuration.h b/native/include/android/configuration.h new file mode 100644 index 0000000..79b9b1e --- /dev/null +++ b/native/include/android/configuration.h @@ -0,0 +1,319 @@ +/* + * Copyright (C) 2010 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_CONFIGURATION_H +#define ANDROID_CONFIGURATION_H + +#include <android/asset_manager.h> + +#ifdef __cplusplus +extern "C" { +#endif + +struct AConfiguration; +typedef struct AConfiguration AConfiguration; + +enum { + ACONFIGURATION_ORIENTATION_ANY = 0x0000, + ACONFIGURATION_ORIENTATION_PORT = 0x0001, + ACONFIGURATION_ORIENTATION_LAND = 0x0002, + ACONFIGURATION_ORIENTATION_SQUARE = 0x0003, + + ACONFIGURATION_TOUCHSCREEN_ANY = 0x0000, + ACONFIGURATION_TOUCHSCREEN_NOTOUCH = 0x0001, + ACONFIGURATION_TOUCHSCREEN_STYLUS = 0x0002, + ACONFIGURATION_TOUCHSCREEN_FINGER = 0x0003, + + ACONFIGURATION_DENSITY_DEFAULT = 0, + ACONFIGURATION_DENSITY_LOW = 120, + ACONFIGURATION_DENSITY_MEDIUM = 160, + ACONFIGURATION_DENSITY_HIGH = 240, + ACONFIGURATION_DENSITY_NONE = 0xffff, + + ACONFIGURATION_KEYBOARD_ANY = 0x0000, + ACONFIGURATION_KEYBOARD_NOKEYS = 0x0001, + ACONFIGURATION_KEYBOARD_QWERTY = 0x0002, + ACONFIGURATION_KEYBOARD_12KEY = 0x0003, + + ACONFIGURATION_NAVIGATION_ANY = 0x0000, + ACONFIGURATION_NAVIGATION_NONAV = 0x0001, + ACONFIGURATION_NAVIGATION_DPAD = 0x0002, + ACONFIGURATION_NAVIGATION_TRACKBALL = 0x0003, + ACONFIGURATION_NAVIGATION_WHEEL = 0x0004, + + ACONFIGURATION_KEYSHIDDEN_ANY = 0x0000, + ACONFIGURATION_KEYSHIDDEN_NO = 0x0001, + ACONFIGURATION_KEYSHIDDEN_YES = 0x0002, + ACONFIGURATION_KEYSHIDDEN_SOFT = 0x0003, + + ACONFIGURATION_NAVHIDDEN_ANY = 0x0000, + ACONFIGURATION_NAVHIDDEN_NO = 0x0001, + ACONFIGURATION_NAVHIDDEN_YES = 0x0002, + + ACONFIGURATION_SCREENSIZE_ANY = 0x00, + ACONFIGURATION_SCREENSIZE_SMALL = 0x01, + ACONFIGURATION_SCREENSIZE_NORMAL = 0x02, + ACONFIGURATION_SCREENSIZE_LARGE = 0x03, + ACONFIGURATION_SCREENSIZE_XLARGE = 0x04, + + ACONFIGURATION_SCREENLONG_ANY = 0x00, + ACONFIGURATION_SCREENLONG_NO = 0x1, + ACONFIGURATION_SCREENLONG_YES = 0x2, + + ACONFIGURATION_UI_MODE_TYPE_ANY = 0x00, + ACONFIGURATION_UI_MODE_TYPE_NORMAL = 0x01, + ACONFIGURATION_UI_MODE_TYPE_DESK = 0x02, + ACONFIGURATION_UI_MODE_TYPE_CAR = 0x03, + + ACONFIGURATION_UI_MODE_NIGHT_ANY = 0x00, + ACONFIGURATION_UI_MODE_NIGHT_NO = 0x10, + ACONFIGURATION_UI_MODE_NIGHT_YES = 0x20, + + ACONFIGURATION_MCC = 0x0001, + ACONFIGURATION_MNC = 0x0002, + ACONFIGURATION_LOCALE = 0x0004, + ACONFIGURATION_TOUCHSCREEN = 0x0008, + ACONFIGURATION_KEYBOARD = 0x0010, + ACONFIGURATION_KEYBOARD_HIDDEN = 0x0020, + ACONFIGURATION_NAVIGATION = 0x0040, + ACONFIGURATION_ORIENTATION = 0x0080, + ACONFIGURATION_DENSITY = 0x0100, + ACONFIGURATION_SCREEN_SIZE = 0x0200, + ACONFIGURATION_VERSION = 0x0400, + ACONFIGURATION_SCREEN_LAYOUT = 0x0800, + ACONFIGURATION_UI_MODE = 0x1000, +}; + +/** + * Create a new AConfiguration, initialized with no values set. + */ +AConfiguration* AConfiguration_new(); + +/** + * Free an AConfiguration that was previously created with + * AConfiguration_new(). + */ +void AConfiguration_delete(AConfiguration* config); + +/** + * Create and return a new AConfiguration based on the current configuration in + * use in the given AssetManager. + */ +void AConfiguration_fromAssetManager(AConfiguration* out, AAssetManager* am); + +/** + * Copy the contents of 'src' to 'dest'. + */ +void AConfiguration_copy(AConfiguration* dest, AConfiguration* src); + +/** + * Return the current MCC set in the configuration. 0 if not set. + */ +int32_t AConfiguration_getMcc(AConfiguration* config); + +/** + * Set the current MCC in the configuration. 0 to clear. + */ +void AConfiguration_setMcc(AConfiguration* config, int32_t mcc); + +/** + * Return the current MNC set in the configuration. 0 if not set. + */ +int32_t AConfiguration_getMnc(AConfiguration* config); + +/** + * Set the current MNC in the configuration. 0 to clear. + */ +void AConfiguration_setMnc(AConfiguration* config, int32_t mnc); + +/** + * Return the current language code set in the configuration. The output will + * be filled with an array of two characters. They are not 0-terminated. If + * a language is not set, they will be 0. + */ +void AConfiguration_getLanguage(AConfiguration* config, char* outLanguage); + +/** + * Set the current language code in the configuration, from the first two + * characters in the string. + */ +void AConfiguration_setLanguage(AConfiguration* config, const char* language); + +/** + * Return the current country code set in the configuration. The output will + * be filled with an array of two characters. They are not 0-terminated. If + * a country is not set, they will be 0. + */ +void AConfiguration_getCountry(AConfiguration* config, char* outCountry); + +/** + * Set the current country code in the configuration, from the first two + * characters in the string. + */ +void AConfiguration_setCountry(AConfiguration* config, const char* country); + +/** + * Return the current ACONFIGURATION_ORIENTATION_* set in the configuration. + */ +int32_t AConfiguration_getOrientation(AConfiguration* config); + +/** + * Set the current orientation in the configuration. + */ +void AConfiguration_setOrientation(AConfiguration* config, int32_t orientation); + +/** + * Return the current ACONFIGURATION_TOUCHSCREEN_* set in the configuration. + */ +int32_t AConfiguration_getTouchscreen(AConfiguration* config); + +/** + * Set the current touchscreen in the configuration. + */ +void AConfiguration_setTouchscreen(AConfiguration* config, int32_t touchscreen); + +/** + * Return the current ACONFIGURATION_DENSITY_* set in the configuration. + */ +int32_t AConfiguration_getDensity(AConfiguration* config); + +/** + * Set the current density in the configuration. + */ +void AConfiguration_setDensity(AConfiguration* config, int32_t density); + +/** + * Return the current ACONFIGURATION_KEYBOARD_* set in the configuration. + */ +int32_t AConfiguration_getKeyboard(AConfiguration* config); + +/** + * Set the current keyboard in the configuration. + */ +void AConfiguration_setKeyboard(AConfiguration* config, int32_t keyboard); + +/** + * Return the current ACONFIGURATION_NAVIGATION_* set in the configuration. + */ +int32_t AConfiguration_getNavigation(AConfiguration* config); + +/** + * Set the current navigation in the configuration. + */ +void AConfiguration_setNavigation(AConfiguration* config, int32_t navigation); + +/** + * Return the current ACONFIGURATION_KEYSHIDDEN_* set in the configuration. + */ +int32_t AConfiguration_getKeysHidden(AConfiguration* config); + +/** + * Set the current keys hidden in the configuration. + */ +void AConfiguration_setKeysHidden(AConfiguration* config, int32_t keysHidden); + +/** + * Return the current ACONFIGURATION_NAVHIDDEN_* set in the configuration. + */ +int32_t AConfiguration_getNavHidden(AConfiguration* config); + +/** + * Set the current nav hidden in the configuration. + */ +void AConfiguration_setNavHidden(AConfiguration* config, int32_t navHidden); + +/** + * Return the current SDK (API) version set in the configuration. + */ +int32_t AConfiguration_getSdkVersion(AConfiguration* config); + +/** + * Set the current SDK version in the configuration. + */ +void AConfiguration_setSdkVersion(AConfiguration* config, int32_t sdkVersion); + +/** + * Return the current ACONFIGURATION_SCREENSIZE_* set in the configuration. + */ +int32_t AConfiguration_getScreenSize(AConfiguration* config); + +/** + * Set the current screen size in the configuration. + */ +void AConfiguration_setScreenSize(AConfiguration* config, int32_t screenSize); + +/** + * Return the current ACONFIGURATION_SCREENLONG_* set in the configuration. + */ +int32_t AConfiguration_getScreenLong(AConfiguration* config); + +/** + * Set the current screen long in the configuration. + */ +void AConfiguration_setScreenLong(AConfiguration* config, int32_t screenLong); + +/** + * Return the current ACONFIGURATION_UI_MODE_TYPE_* set in the configuration. + */ +int32_t AConfiguration_getUiModeType(AConfiguration* config); + +/** + * Set the current UI mode type in the configuration. + */ +void AConfiguration_setUiModeType(AConfiguration* config, int32_t uiModeType); + +/** + * Return the current ACONFIGURATION_UI_MODE_NIGHT_* set in the configuration. + */ +int32_t AConfiguration_getUiModeNight(AConfiguration* config); + +/** + * Set the current UI mode night in the configuration. + */ +void AConfiguration_setUiModeNight(AConfiguration* config, int32_t uiModeNight); + +/** + * Perform a diff between two configurations. Returns a bit mask of + * ACONFIGURATION_* constants, each bit set meaning that configuration element + * is different between them. + */ +int32_t AConfiguration_diff(AConfiguration* config1, AConfiguration* config2); + +/** + * Determine whether 'base' is a valid configuration for use within the + * environment 'requested'. Returns 0 if there are any values in 'base' + * that conflict with 'requested'. Returns 1 if it does not conflict. + */ +int32_t AConfiguration_match(AConfiguration* base, AConfiguration* requested); + +/** + * Determine whether the configuration in 'test' is better than the existing + * configuration in 'base'. If 'requested' is non-NULL, this decision is based + * on the overall configuration given there. If it is NULL, this decision is + * simply based on which configuration is more specific. Returns non-0 if + * 'test' is better than 'base'. + * + * This assumes you have already filtered the configurations with + * AConfiguration_match(). + */ +int32_t AConfiguration_isBetterThan(AConfiguration* base, AConfiguration* test, + AConfiguration* requested); + +#ifdef __cplusplus +}; +#endif + +#endif // ANDROID_CONFIGURATION_H diff --git a/native/include/android/native_activity.h b/native/include/android/native_activity.h index ee4204d..d74e1ce 100644 --- a/native/include/android/native_activity.h +++ b/native/include/android/native_activity.h @@ -197,6 +197,12 @@ typedef struct ANativeActivityCallbacks { void (*onContentRectChanged)(ANativeActivity* activity, const ARect* rect); /** + * The current device AConfiguration has changed. The new configuration can + * be retrieved from assetManager. + */ + void (*onConfigurationChanged)(ANativeActivity* activity); + + /** * The system is running low on memory. Use this callback to release * resources you do not need, to help the system avoid killing more * important processes. @@ -208,7 +214,9 @@ typedef struct ANativeActivityCallbacks { * This is the function that must be in the native code to instantiate the * application's native activity. It is called with the activity instance (see * above); if the code is being instantiated from a previously saved instance, - * the savedState will be non-NULL and point to the saved data. + * the savedState will be non-NULL and point to the saved data. You must make + * any copy of this data you need -- it will be released after you return from + * this function. */ typedef void ANativeActivity_createFunc(ANativeActivity* activity, void* savedState, size_t savedStateSize); diff --git a/native/include/android/native_window.h b/native/include/android/native_window.h index 7599d7e..ad03d0e 100644 --- a/native/include/android/native_window.h +++ b/native/include/android/native_window.h @@ -36,12 +36,23 @@ struct ANativeWindow; typedef struct ANativeWindow ANativeWindow; typedef struct ANativeWindow_Buffer { + // The number of pixels that are show horizontally. int32_t width; + + // The number of pixels that are shown vertically. int32_t height; + + // The number of *pixels* that a line in the buffer takes in + // memory. This may be >= width. int32_t stride; + + // The format of the buffer. One of WINDOW_FORMAT_* int32_t format; + + // The actual bits. void* bits; + // Do not touch. uint32_t reserved[6]; } ANativeWindow_Buffer; |