diff options
Diffstat (limited to 'include/utils')
-rw-r--r-- | include/utils/AssetManager.h | 23 | ||||
-rw-r--r-- | include/utils/BackupHelpers.h | 158 | ||||
-rw-r--r-- | include/utils/ByteOrder.h | 32 | ||||
-rw-r--r-- | include/utils/Parcel.h | 18 | ||||
-rw-r--r-- | include/utils/ResourceTypes.h | 356 | ||||
-rw-r--r-- | include/utils/TimeUtils.h | 89 | ||||
-rw-r--r-- | include/utils/threads.h | 7 |
7 files changed, 470 insertions, 213 deletions
diff --git a/include/utils/AssetManager.h b/include/utils/AssetManager.h index e94c0e8..d8994e0 100644 --- a/include/utils/AssetManager.h +++ b/include/utils/AssetManager.h @@ -153,6 +153,18 @@ public: AssetDir* openDir(const char* dirName); /* + * Open a directory within a particular path of the asset manager. + * + * The contents of the directory are an amalgam of vendor-specific, + * locale-specific, and generic assets stored loosely or in asset + * packages. Depending on the cache setting and previous accesses, + * this call may incur significant disk overhead. + * + * To open the top-level directory, pass in "". + */ + AssetDir* openNonAssetDir(void* cookie, const char* dirName); + + /* * Get the type of a file in the asset hierarchy. They will either * be "regular" or "directory". [Currently only works for "regular".] * @@ -239,6 +251,9 @@ private: Asset* getResourceTableAsset(); Asset* setResourceTableAsset(Asset* asset); + ResTable* getResourceTable(); + ResTable* setResourceTable(ResTable* res); + bool isUpToDate(); protected: @@ -253,6 +268,7 @@ private: time_t mModWhen; Asset* mResourceTableAsset; + ResTable* mResourceTable; static Mutex gLock; static DefaultKeyedVector<String8, wp<SharedZip> > gOpen; @@ -276,8 +292,11 @@ private: */ ZipFileRO* getZip(const String8& path); - Asset* getZipResourceTable(const String8& path); - Asset* setZipResourceTable(const String8& path, Asset* asset); + Asset* getZipResourceTableAsset(const String8& path); + Asset* setZipResourceTableAsset(const String8& path, Asset* asset); + + ResTable* getZipResourceTable(const String8& path); + ResTable* setZipResourceTable(const String8& path, ResTable* res); // generate path, e.g. "common/en-US-noogle.zip" static String8 getPathName(const char* path); diff --git a/include/utils/BackupHelpers.h b/include/utils/BackupHelpers.h new file mode 100644 index 0000000..b1f5045 --- /dev/null +++ b/include/utils/BackupHelpers.h @@ -0,0 +1,158 @@ +/* + * Copyright (C) 2009 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 _UTILS_BACKUP_HELPERS_H +#define _UTILS_BACKUP_HELPERS_H + +#include <utils/Errors.h> +#include <utils/String8.h> +#include <utils/KeyedVector.h> + +namespace android { + +enum { + BACKUP_HEADER_ENTITY_V1 = 0x61746144, // Data (little endian) +}; + +typedef struct { + int type; // BACKUP_HEADER_ENTITY_V1 + int keyLen; // length of the key name, not including the null terminator + int dataSize; // size of the data, not including the padding, -1 means delete +} entity_header_v1; + +struct SnapshotHeader { + int magic0; + int fileCount; + int magic1; + int totalSize; +}; + +struct FileState { + int modTime_sec; + int modTime_nsec; + int mode; + int size; + int crc32; + int nameLen; +}; + +struct FileRec { + String8 file; + bool deleted; + FileState s; +}; + + +/** + * Writes the data. + * + * If an error occurs, it poisons this object and all write calls will fail + * with the error that occurred. + */ +class BackupDataWriter +{ +public: + BackupDataWriter(int fd); + // does not close fd + ~BackupDataWriter(); + + status_t WriteEntityHeader(const String8& key, size_t dataSize); + status_t WriteEntityData(const void* data, size_t size); + + void SetKeyPrefix(const String8& keyPrefix); + +private: + explicit BackupDataWriter(); + status_t write_padding_for(int n); + + int m_fd; + status_t m_status; + ssize_t m_pos; + int m_entityCount; + String8 m_keyPrefix; +}; + +/** + * Reads the data. + * + * If an error occurs, it poisons this object and all write calls will fail + * with the error that occurred. + */ +class BackupDataReader +{ +public: + BackupDataReader(int fd); + // does not close fd + ~BackupDataReader(); + + status_t Status(); + status_t ReadNextHeader(bool* done, int* type); + + bool HasEntities(); + status_t ReadEntityHeader(String8* key, size_t* dataSize); + status_t SkipEntityData(); // must be called with the pointer at the begining of the data. + ssize_t ReadEntityData(void* data, size_t size); + +private: + explicit BackupDataReader(); + status_t skip_padding(); + + int m_fd; + bool m_done; + status_t m_status; + ssize_t m_pos; + ssize_t m_dataEndPos; + int m_entityCount; + union { + int type; + entity_header_v1 entity; + } m_header; + String8 m_key; +}; + +int back_up_files(int oldSnapshotFD, BackupDataWriter* dataStream, int newSnapshotFD, + char const* const* files, char const* const *keys, int fileCount); + +class RestoreHelperBase +{ +public: + RestoreHelperBase(); + ~RestoreHelperBase(); + + status_t WriteFile(const String8& filename, BackupDataReader* in); + status_t WriteSnapshot(int fd); + +private: + void* m_buf; + bool m_loggedUnknownMetadata; + KeyedVector<String8,FileRec> m_files; +}; + +#define TEST_BACKUP_HELPERS 1 + +#if TEST_BACKUP_HELPERS +int backup_helper_test_empty(); +int backup_helper_test_four(); +int backup_helper_test_files(); +int backup_helper_test_null_base(); +int backup_helper_test_missing_file(); +int backup_helper_test_data_writer(); +int backup_helper_test_data_reader(); +#endif + +} // namespace android + +#endif // _UTILS_BACKUP_HELPERS_H diff --git a/include/utils/ByteOrder.h b/include/utils/ByteOrder.h index 4c06067..baa3a83 100644 --- a/include/utils/ByteOrder.h +++ b/include/utils/ByteOrder.h @@ -38,6 +38,16 @@ * intent is to allow us to avoid byte swapping on the device. */ +static inline uint32_t android_swap_long(uint32_t v) +{ + return (v<<24) | ((v<<8)&0x00FF0000) | ((v>>8)&0x0000FF00) | (v>>24); +} + +static inline uint16_t android_swap_short(uint16_t v) +{ + return (v<<8) | (v>>8); +} + #define DEVICE_BYTE_ORDER LITTLE_ENDIAN #if BYTE_ORDER == DEVICE_BYTE_ORDER @@ -49,16 +59,6 @@ #else -static inline uint32_t android_swap_long(uint32_t v) -{ - return (v<<24) | ((v<<8)&0x00FF0000) | ((v>>8)&0x0000FF00) | (v>>24); -} - -static inline uint16_t android_swap_short(uint16_t v) -{ - return (v<<8) | (v>>8); -} - #define dtohl(x) (android_swap_long(x)) #define dtohs(x) (android_swap_short(x)) #define htodl(x) (android_swap_long(x)) @@ -66,4 +66,16 @@ static inline uint16_t android_swap_short(uint16_t v) #endif +#if BYTE_ORDER == LITTLE_ENDIAN +#define fromlel(x) (x) +#define fromles(x) (x) +#define tolel(x) (x) +#define toles(x) (x) +#else +#define fromlel(x) (android_swap_long(x)) +#define fromles(x) (android_swap_short(x)) +#define tolel(x) (android_swap_long(x)) +#define toles(x) (android_swap_short(x)) +#endif + #endif // _LIBS_UTILS_BYTE_ORDER_H diff --git a/include/utils/Parcel.h b/include/utils/Parcel.h index 9087c44..af1490a 100644 --- a/include/utils/Parcel.h +++ b/include/utils/Parcel.h @@ -80,8 +80,11 @@ public: status_t writeStrongBinder(const sp<IBinder>& val); status_t writeWeakBinder(const wp<IBinder>& val); - // doesn't take ownership of the native_handle - status_t writeNativeHandle(const native_handle& handle); + // Place a native_handle into the parcel (the native_handle's file- + // descriptors are dup'ed, so it is safe to delete the native_handle + // when this function returns). + // Doesn't take ownership of the native_handle. + status_t writeNativeHandle(const native_handle* handle); // Place a file descriptor into the parcel. The given fd must remain // valid for the lifetime of the parcel. @@ -114,12 +117,11 @@ public: wp<IBinder> readWeakBinder() const; - // if alloc is NULL, native_handle is allocated with malloc(), otherwise - // alloc is used. If the function fails, the effects of alloc() must be - // reverted by the caller. - native_handle* readNativeHandle( - native_handle* (*alloc)(void* cookie, int numFds, int ints), - void* cookie) const; + // Retrieve native_handle from the parcel. This returns a copy of the + // parcel's native_handle (the caller takes ownership). The caller + // must free the native_handle with native_handle_close() and + // native_handle_delete(). + native_handle* readNativeHandle() const; // Retrieve a file descriptor from the parcel. This returns the raw fd diff --git a/include/utils/ResourceTypes.h b/include/utils/ResourceTypes.h index d01d83f..93bca4a 100644 --- a/include/utils/ResourceTypes.h +++ b/include/utils/ResourceTypes.h @@ -71,7 +71,7 @@ namespace android { * The relative sizes of the stretchy segments indicates the relative * amount of stretchiness of the regions bordered by the segments. For * example, regions 3, 7 and 11 above will take up more horizontal space - * than regions 1, 5 and 9 since the horizonal segment associated with + * than regions 1, 5 and 9 since the horizontal segment associated with * the first set of regions is larger than the other set of regions. The * ratios of the amount of horizontal (or vertical) space taken by any * two stretchable slices is exactly the ratio of their corresponding @@ -87,7 +87,7 @@ namespace android { * the leftmost slices always start at x=0 and the rightmost slices * always end at the end of the image. So, for example, the regions 0, * 4 and 8 (which are fixed along the X axis) start at x value 0 and - * go to xDiv[0] amd slices 2, 6 and 10 start at xDiv[1] and end at + * go to xDiv[0] and slices 2, 6 and 10 start at xDiv[1] and end at * xDiv[2]. * * The array pointed to by the colors field lists contains hints for @@ -626,25 +626,25 @@ public: event_code_t next(); // These are available for all nodes: - const int32_t getCommentID() const; + int32_t getCommentID() const; const uint16_t* getComment(size_t* outLen) const; - const uint32_t getLineNumber() const; + uint32_t getLineNumber() const; // This is available for TEXT: - const int32_t getTextID() const; + int32_t getTextID() const; const uint16_t* getText(size_t* outLen) const; ssize_t getTextValue(Res_value* outValue) const; // These are available for START_NAMESPACE and END_NAMESPACE: - const int32_t getNamespacePrefixID() const; + int32_t getNamespacePrefixID() const; const uint16_t* getNamespacePrefix(size_t* outLen) const; - const int32_t getNamespaceUriID() const; + int32_t getNamespaceUriID() const; const uint16_t* getNamespaceUri(size_t* outLen) const; // These are available for START_TAG and END_TAG: - const int32_t getElementNamespaceID() const; + int32_t getElementNamespaceID() const; const uint16_t* getElementNamespace(size_t* outLen) const; - const int32_t getElementNameID() const; + int32_t getElementNameID() const; const uint16_t* getElementName(size_t* outLen) const; // Remaining methods are for retrieving information about attributes @@ -653,14 +653,14 @@ public: size_t getAttributeCount() const; // Returns -1 if no namespace, -2 if idx out of range. - const int32_t getAttributeNamespaceID(size_t idx) const; + int32_t getAttributeNamespaceID(size_t idx) const; const uint16_t* getAttributeNamespace(size_t idx, size_t* outLen) const; - const int32_t getAttributeNameID(size_t idx) const; + int32_t getAttributeNameID(size_t idx) const; const uint16_t* getAttributeName(size_t idx, size_t* outLen) const; - const uint32_t getAttributeNameResID(size_t idx) const; + uint32_t getAttributeNameResID(size_t idx) const; - const int32_t getAttributeValueStringID(size_t idx) const; + int32_t getAttributeValueStringID(size_t idx) const; const uint16_t* getAttributeStringValue(size_t idx, size_t* outLen) const; int32_t getAttributeDataType(size_t idx) const; @@ -866,7 +866,7 @@ struct ResTable_config uint8_t keyboard; uint8_t navigation; uint8_t inputFlags; - uint8_t pad0; + uint8_t inputPad0; }; uint32_t input; }; @@ -905,6 +905,23 @@ struct ResTable_config uint32_t version; }; + enum { + SCREENLAYOUT_ANY = 0x0000, + SCREENLAYOUT_SMALL = 0x0001, + SCREENLAYOUT_NORMAL = 0x0002, + SCREENLAYOUT_LARGE = 0x0003, + }; + + union { + struct { + uint8_t screenLayout; + uint8_t screenConfigPad0; + uint8_t screenConfigPad1; + uint8_t screenConfigPad2; + }; + uint32_t screenConfig; + }; + inline void copyFromDeviceNoSwap(const ResTable_config& o) { const size_t size = dtohl(o.size); if (size >= sizeof(ResTable_config)) { @@ -950,6 +967,8 @@ struct ResTable_config diff = (int32_t)(screenSize - o.screenSize); if (diff != 0) return diff; diff = (int32_t)(version - o.version); + if (diff != 0) return diff; + diff = (int32_t)(screenLayout - o.screenLayout); return (int)diff; } @@ -967,7 +986,8 @@ struct ResTable_config CONFIG_ORIENTATION = 0x0080, CONFIG_DENSITY = 0x0100, CONFIG_SCREEN_SIZE = 0x0200, - CONFIG_VERSION = 0x0400 + CONFIG_VERSION = 0x0400, + CONFIG_SCREEN_LAYOUT = 0x0800 }; // Compare two configuration, returning CONFIG_* flags set for each value @@ -985,122 +1005,242 @@ struct ResTable_config if (navigation != o.navigation) diffs |= CONFIG_NAVIGATION; if (screenSize != o.screenSize) diffs |= CONFIG_SCREEN_SIZE; if (version != o.version) diffs |= CONFIG_VERSION; + if (screenLayout != o.screenLayout) diffs |= CONFIG_SCREEN_LAYOUT; return diffs; } - // Return true if 'this' is more specific than 'o'. Optionally, if - // 'requested' is null, then they will also be compared against the - // requested configuration and true will only be returned if 'this' - // is a better candidate than 'o' for the configuration. This assumes that - // match() has already been used to remove any configurations that don't - // match the requested configuration at all; if they are not first filtered, - // non-matching results can be considered better than matching ones. + // Return true if 'this' is more specific than 'o'. inline bool - isBetterThan(const ResTable_config& o, const ResTable_config* requested = NULL) const { + isMoreSpecificThan(const ResTable_config& o) const { // The order of the following tests defines the importance of one // configuration parameter over another. Those tests first are more // important, trumping any values in those following them. - if (imsi != 0 && (!requested || requested->imsi != 0)) { - if (mcc != 0 && (!requested || requested->mcc != 0)) { - if (o.mcc == 0) { - return true; - } + if (imsi || o.imsi) { + if (mcc != o.mcc) { + if (!mcc) return false; + if (!o.mcc) return true; } - if (mnc != 0 && (!requested || requested->mnc != 0)) { - if (o.mnc == 0) { - return true; - } + + if (mnc != o.mnc) { + if (!mnc) return false; + if (!o.mnc) return true; } } - if (locale != 0 && (!requested || requested->locale != 0)) { - if (language[0] != 0 && (!requested || requested->language[0] != 0)) { - if (o.language[0] == 0) { - return true; - } + + if (locale || o.locale) { + if (language[0] != o.language[0]) { + if (!language[0]) return false; + if (!o.language[0]) return true; } - if (country[0] != 0 && (!requested || requested->country[0] != 0)) { - if (o.country[0] == 0) { - return true; - } + + if (country[0] != o.country[0]) { + if (!country[0]) return false; + if (!o.country[0]) return true; } } - if (screenType != 0 && (!requested || requested->screenType != 0)) { - if (orientation != 0 && (!requested || requested->orientation != 0)) { - if (o.orientation == 0) { - return true; - } + + if (screenType || o.screenType) { + if (orientation != o.orientation) { + if (!orientation) return false; + if (!o.orientation) return true; } - if (density != 0 && (!requested || requested->density != 0)) { - if (o.density == 0) { - return true; - } + + // density is never 'more specific' + // as the default just equals 160 + + if (touchscreen != o.touchscreen) { + if (!touchscreen) return false; + if (!o.touchscreen) return true; } - if (touchscreen != 0 && (!requested || requested->touchscreen != 0)) { - if (o.touchscreen == 0) { - return true; - } + } + + if (input || o.input) { + if (inputFlags != o.inputFlags) { + if (!(inputFlags & MASK_KEYSHIDDEN)) return false; + if (!(o.inputFlags & MASK_KEYSHIDDEN)) return true; + } + + if (keyboard != o.keyboard) { + if (!keyboard) return false; + if (!o.keyboard) return true; + } + + if (navigation != o.navigation) { + if (!navigation) return false; + if (!o.navigation) return true; } } - if (input != 0 && (!requested || requested->input != 0)) { - const int keysHidden = inputFlags&MASK_KEYSHIDDEN; - const int reqKeysHidden = requested - ? requested->inputFlags&MASK_KEYSHIDDEN : 0; - if (keysHidden != 0 && reqKeysHidden != 0) { - const int oKeysHidden = o.inputFlags&MASK_KEYSHIDDEN; - //LOGI("isBetterThan keysHidden: cur=%d, given=%d, config=%d\n", - // keysHidden, oKeysHidden, reqKeysHidden); - if (oKeysHidden == 0) { - //LOGI("Better because 0!"); - return true; + + if (screenSize || o.screenSize) { + if (screenWidth != o.screenWidth) { + if (!screenWidth) return false; + if (!o.screenWidth) return true; + } + + if (screenHeight != o.screenHeight) { + if (!screenHeight) return false; + if (!o.screenHeight) return true; + } + } + + if (screenConfig || o.screenConfig) { + if (screenLayout != o.screenLayout) { + if (!screenLayout) return false; + if (!o.screenLayout) return true; + } + } + + if (version || o.version) { + if (sdkVersion != o.sdkVersion) { + if (!sdkVersion) return false; + if (!o.sdkVersion) return true; + } + + if (minorVersion != o.minorVersion) { + if (!minorVersion) return false; + if (!o.minorVersion) return true; + } + } + return false; + } + + // Return true if 'this' is a better match than 'o' for the 'requested' + // configuration. This assumes that match() has already been used to + // remove any configurations that don't match the requested configuration + // at all; if they are not first filtered, non-matching results can be + // considered better than matching ones. + // The general rule per attribute: if the request cares about an attribute + // (it normally does), if the two (this and o) are equal it's a tie. If + // they are not equal then one must be generic because only generic and + // '==requested' will pass the match() call. So if this is not generic, + // it wins. If this IS generic, o wins (return false). + inline bool + isBetterThan(const ResTable_config& o, + const ResTable_config* requested) const { + if (requested) { + if (imsi || o.imsi) { + if ((mcc != o.mcc) && requested->mcc) { + return (mcc); } - // For compatibility, we count KEYSHIDDEN_NO as being - // the same as KEYSHIDDEN_SOFT. Here we disambiguate these - // may making an exact match more specific. - if (keysHidden == reqKeysHidden && oKeysHidden != reqKeysHidden) { - // The current configuration is an exact match, and - // the given one is not, so the current one is better. - //LOGI("Better because other not same!"); - return true; + + if ((mnc != o.mnc) && requested->mnc) { + return (mnc); } } - if (keyboard != 0 && (!requested || requested->keyboard != 0)) { - if (o.keyboard == 0) { - return true; + + if (locale || o.locale) { + if ((language[0] != o.language[0]) && requested->language[0]) { + return (language[0]); + } + + if ((country[0] != o.country[0]) && requested->country[0]) { + return (country[0]); } } - if (navigation != 0 && (!requested || requested->navigation != 0)) { - if (o.navigation == 0) { - return true; + + if (screenType || o.screenType) { + if ((orientation != o.orientation) && requested->orientation) { + return (orientation); + } + + if (density != o.density) { + // density is tough. Any density is potentially useful + // because the system will scale it. Scaling down + // is generally better than scaling up. + // Default density counts as 160dpi (the system default) + // TODO - remove 160 constants + int h = (density?density:160); + int l = (o.density?o.density:160); + bool bImBigger = true; + if (l > h) { + int t = h; + h = l; + l = t; + bImBigger = false; + } + + int reqValue = (requested->density?requested->density:160); + if (reqValue >= h) { + // requested value higher than both l and h, give h + return bImBigger; + } + if (l >= reqValue) { + // requested value lower than both l and h, give l + return !bImBigger; + } + // saying that scaling down is 2x better than up + if (((2 * l) - reqValue) * h > reqValue * reqValue) { + return !bImBigger; + } else { + return bImBigger; + } + } + + if ((touchscreen != o.touchscreen) && requested->touchscreen) { + return (touchscreen); } } - } - if (screenSize != 0 && (!requested || requested->screenSize != 0)) { - if (screenWidth != 0 && (!requested || requested->screenWidth != 0)) { - if (o.screenWidth == 0) { - return true; + + if (input || o.input) { + const int keysHidden = inputFlags & MASK_KEYSHIDDEN; + const int oKeysHidden = o.inputFlags & MASK_KEYSHIDDEN; + if (keysHidden != oKeysHidden) { + const int reqKeysHidden = + requested->inputFlags & MASK_KEYSHIDDEN; + if (reqKeysHidden) { + + if (!keysHidden) return false; + if (!oKeysHidden) return true; + // For compatibility, we count KEYSHIDDEN_NO as being + // the same as KEYSHIDDEN_SOFT. Here we disambiguate + // these by making an exact match more specific. + if (reqKeysHidden == keysHidden) return true; + if (reqKeysHidden == oKeysHidden) return false; + } + } + + if ((keyboard != o.keyboard) && requested->keyboard) { + return (keyboard); + } + + if ((navigation != o.navigation) && requested->navigation) { + return (navigation); } } - if (screenHeight != 0 && (!requested || requested->screenHeight != 0)) { - if (o.screenHeight == 0) { - return true; + + if (screenSize || o.screenSize) { + if ((screenWidth != o.screenWidth) && requested->screenWidth) { + return (screenWidth); + } + + if ((screenHeight != o.screenHeight) && + requested->screenHeight) { + return (screenHeight); } } - } - if (version != 0 && (!requested || requested->version != 0)) { - if (sdkVersion != 0 && (!requested || requested->sdkVersion != 0)) { - if (o.sdkVersion == 0) { - return true; + + if (screenConfig || o.screenConfig) { + if ((screenLayout != o.screenLayout) && requested->screenLayout) { + return (screenLayout); } } - if (minorVersion != 0 && (!requested || requested->minorVersion != 0)) { - if (o.minorVersion == 0) { - return true; + + if (version || o.version) { + if ((sdkVersion != o.sdkVersion) && requested->sdkVersion) { + return (sdkVersion); + } + + if ((minorVersion != o.minorVersion) && + requested->minorVersion) { + return (minorVersion); } } + + return false; } - return false; + return isMoreSpecificThan(o); } - + // Return true if 'this' can be considered a match for the parameters in // 'settings'. // Note this is asymetric. A default piece of data will match every request @@ -1137,8 +1277,7 @@ struct ResTable_config && orientation != settings.orientation) { return false; } - // Density not taken into account, always match, no matter what - // density is specified for the resource + // density always matches - we can scale it. See isBetterThan if (settings.touchscreen != 0 && touchscreen != 0 && touchscreen != settings.touchscreen) { return false; @@ -1177,6 +1316,12 @@ struct ResTable_config return false; } } + if (screenConfig != 0) { + if (settings.screenLayout != 0 && screenLayout != 0 + && screenLayout != settings.screenLayout) { + return false; + } + } if (version != 0) { if (settings.sdkVersion != 0 && sdkVersion != 0 && sdkVersion != settings.sdkVersion) { @@ -1205,13 +1350,13 @@ struct ResTable_config String8 toString() const { char buf[200]; - sprintf(buf, "imsi=%d/%d lang=%c%c reg=%c%c orient=0x%02x touch=0x%02x dens=0x%02x " - "kbd=0x%02x nav=0x%02x input=0x%02x screenW=0x%04x screenH=0x%04x vers=%d.%d", + sprintf(buf, "imsi=%d/%d lang=%c%c reg=%c%c orient=%d touch=%d dens=%d " + "kbd=%d nav=%d input=%d scrnW=%d scrnH=%d layout=%d vers=%d.%d", mcc, mnc, language[0] ? language[0] : '-', language[1] ? language[1] : '-', country[0] ? country[0] : '-', country[1] ? country[1] : '-', orientation, touchscreen, density, keyboard, navigation, inputFlags, - screenWidth, screenHeight, sdkVersion, minorVersion); + screenWidth, screenHeight, screenLayout, sdkVersion, minorVersion); return String8(buf); } }; @@ -1296,7 +1441,7 @@ struct ResTable_type * This is the beginning of information about an entry in the resource * table. It holds the reference to the name of this entry, and is * immediately followed by one of: - * * A Res_value structures, if FLAG_COMPLEX is -not- set. + * * A Res_value structure, if FLAG_COMPLEX is -not- set. * * An array of ResTable_map structures, if FLAG_COMPLEX is set. * These supply a set of name/value mappings of data. */ @@ -1435,6 +1580,7 @@ public: bool copyData=false); status_t add(Asset* asset, void* cookie, bool copyData=false); + status_t add(ResTable* src); status_t getError() const; @@ -1676,7 +1822,7 @@ public: void getLocales(Vector<String8>* locales) const; #ifndef HAVE_ANDROID_OS - void print() const; + void print(bool inclValues) const; #endif private: @@ -1698,6 +1844,8 @@ private: status_t parsePackage( const ResTable_package* const pkg, const Header* const header); + void print_value(const Package* pkg, const Res_value& value) const; + mutable Mutex mLock; status_t mError; diff --git a/include/utils/TimeUtils.h b/include/utils/TimeUtils.h deleted file mode 100644 index b19e021..0000000 --- a/include/utils/TimeUtils.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (C) 2005 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_TIME_H -#define ANDROID_TIME_H - -#include <time.h> -#include <cutils/tztime.h> -#include <stdint.h> -#include <sys/types.h> -#include <sys/time.h> -#include <utils/String8.h> -#include <utils/String16.h> - -namespace android { - -/* - * This class is the core implementation of the android.util.Time java - * class. It doesn't implement some of the methods that are implemented - * in Java. They could be done here, but it's not expected that this class - * will be used. If that assumption is incorrect, feel free to update this - * file. The reason to do it here is to not mix the implementation of this - * class and the jni glue code. - */ -class Time -{ -public: - struct tm t; - - // this object doesn't own this string - const char *timezone; - - enum { - SEC = 1, - MIN = 2, - HOUR = 3, - MDAY = 4, - MON = 5, - YEAR = 6, - WDAY = 7, - YDAY = 8 - }; - - static int compare(Time& a, Time& b); - - Time(); - - void switchTimezone(const char *timezone); - String8 format(const char *format, const struct strftime_locale *locale) const; - void format2445(short* buf, bool hasTime) const; - String8 toString() const; - void setToNow(); - int64_t toMillis(bool ignoreDst); - void set(int64_t millis); - - inline void set(int sec, int min, int hour, int mday, int mon, int year, - int isdst) - { - this->t.tm_sec = sec; - this->t.tm_min = min; - this->t.tm_hour = hour; - this->t.tm_mday = mday; - this->t.tm_mon = mon; - this->t.tm_year = year; - this->t.tm_isdst = isdst; -#ifdef HAVE_TM_GMTOFF - this->t.tm_gmtoff = 0; -#endif - this->t.tm_wday = 0; - this->t.tm_yday = 0; - } -}; - -}; // namespace android - -#endif // ANDROID_TIME_H diff --git a/include/utils/threads.h b/include/utils/threads.h index 8d8d46a..b320915 100644 --- a/include/utils/threads.h +++ b/include/utils/threads.h @@ -79,6 +79,13 @@ enum { ANDROID_PRIORITY_LESS_FAVORABLE = +1, }; +enum { + ANDROID_TGROUP_DEFAULT = 0, + ANDROID_TGROUP_BG_NONINTERACT = 1, + ANDROID_TGROUP_FG_BOOST = 2, + ANDROID_TGROUP_MAX = ANDROID_TGROUP_FG_BOOST, +}; + // Create and run a new thread. extern int androidCreateThread(android_thread_func_t, void *); |