diff options
author | Mathias Agopian <mathias@google.com> | 2009-05-22 01:27:01 -0700 |
---|---|---|
committer | Mathias Agopian <mathias@google.com> | 2009-05-22 02:16:08 -0700 |
commit | 310f8da0c3122ed5419db8f12a6e98d3188325b2 (patch) | |
tree | 0f3435d35e7fe8fca8dc2b347ff46276a8c351c8 /include | |
parent | 20f68782a4ea71c6a977d7f87d8288d3daa265ec (diff) | |
parent | bdbf6b094d61f694f162a5a5279caededcb1f0a5 (diff) | |
download | frameworks_native-310f8da0c3122ed5419db8f12a6e98d3188325b2.zip frameworks_native-310f8da0c3122ed5419db8f12a6e98d3188325b2.tar.gz frameworks_native-310f8da0c3122ed5419db8f12a6e98d3188325b2.tar.bz2 |
merge master to master_gl
Diffstat (limited to 'include')
-rw-r--r-- | include/binder/Binder.h (renamed from include/utils/Binder.h) | 2 | ||||
-rw-r--r-- | include/binder/BpBinder.h (renamed from include/utils/BpBinder.h) | 2 | ||||
-rw-r--r-- | include/binder/IBinder.h (renamed from include/utils/IBinder.h) | 0 | ||||
-rw-r--r-- | include/binder/IInterface.h (renamed from include/utils/IInterface.h) | 2 | ||||
-rw-r--r-- | include/binder/IMemory.h (renamed from include/utils/IMemory.h) | 2 | ||||
-rw-r--r-- | include/binder/IPCThreadState.h (renamed from include/utils/IPCThreadState.h) | 4 | ||||
-rw-r--r-- | include/binder/IPermissionController.h (renamed from include/utils/IPermissionController.h) | 2 | ||||
-rw-r--r-- | include/binder/IServiceManager.h (renamed from include/utils/IServiceManager.h) | 4 | ||||
-rw-r--r-- | include/binder/MemoryBase.h (renamed from include/utils/MemoryBase.h) | 2 | ||||
-rw-r--r-- | include/binder/MemoryDealer.h (renamed from include/utils/MemoryDealer.h) | 4 | ||||
-rw-r--r-- | include/binder/MemoryHeapBase.h (renamed from include/utils/MemoryHeapBase.h) | 2 | ||||
-rw-r--r-- | include/binder/MemoryHeapPmem.h (renamed from include/utils/MemoryHeapPmem.h) | 6 | ||||
-rw-r--r-- | include/binder/Parcel.h (renamed from include/utils/Parcel.h) | 0 | ||||
-rw-r--r-- | include/binder/ProcessState.h (renamed from include/utils/ProcessState.h) | 2 | ||||
-rw-r--r-- | include/private/binder/Static.h | 39 | ||||
-rw-r--r-- | include/private/binder/binder_module.h (renamed from include/private/utils/binder_module.h) | 0 | ||||
-rw-r--r-- | include/private/utils/Static.h | 23 | ||||
-rw-r--r-- | include/tts/TtsEngine.h | 167 | ||||
-rw-r--r-- | include/ui/CameraHardwareInterface.h | 2 | ||||
-rw-r--r-- | include/ui/ICamera.h | 6 | ||||
-rw-r--r-- | include/ui/ICameraClient.h | 6 | ||||
-rw-r--r-- | include/ui/ICameraService.h | 4 | ||||
-rw-r--r-- | include/ui/IOverlay.h | 2 | ||||
-rw-r--r-- | include/ui/ISurface.h | 2 | ||||
-rw-r--r-- | include/ui/ISurfaceComposer.h | 2 | ||||
-rw-r--r-- | include/ui/ISurfaceFlingerClient.h | 2 | ||||
-rw-r--r-- | include/ui/Overlay.h | 2 | ||||
-rw-r--r-- | include/ui/Region.h | 2 | ||||
-rw-r--r-- | include/utils/AssetManager.h | 12 | ||||
-rw-r--r-- | include/utils/backup_helpers.h | 79 |
30 files changed, 323 insertions, 61 deletions
diff --git a/include/utils/Binder.h b/include/binder/Binder.h index b5b8d98..c9b71fd 100644 --- a/include/utils/Binder.h +++ b/include/binder/Binder.h @@ -17,7 +17,7 @@ #ifndef ANDROID_BINDER_H #define ANDROID_BINDER_H -#include <utils/IBinder.h> +#include <binder/IBinder.h> // --------------------------------------------------------------------------- namespace android { diff --git a/include/utils/BpBinder.h b/include/binder/BpBinder.h index 7b96e29..067637e 100644 --- a/include/utils/BpBinder.h +++ b/include/binder/BpBinder.h @@ -17,7 +17,7 @@ #ifndef ANDROID_BPBINDER_H #define ANDROID_BPBINDER_H -#include <utils/IBinder.h> +#include <binder/IBinder.h> #include <utils/KeyedVector.h> #include <utils/threads.h> diff --git a/include/utils/IBinder.h b/include/binder/IBinder.h index 7370330..7370330 100644 --- a/include/utils/IBinder.h +++ b/include/binder/IBinder.h diff --git a/include/utils/IInterface.h b/include/binder/IInterface.h index 959722a..3b1e33b 100644 --- a/include/utils/IInterface.h +++ b/include/binder/IInterface.h @@ -18,7 +18,7 @@ #ifndef ANDROID_IINTERFACE_H #define ANDROID_IINTERFACE_H -#include <utils/Binder.h> +#include <binder/Binder.h> namespace android { diff --git a/include/utils/IMemory.h b/include/binder/IMemory.h index 35a3fd7..182792c 100644 --- a/include/utils/IMemory.h +++ b/include/binder/IMemory.h @@ -23,7 +23,7 @@ #include <utils/RefBase.h> #include <utils/Errors.h> -#include <utils/IInterface.h> +#include <binder/IInterface.h> namespace android { diff --git a/include/utils/IPCThreadState.h b/include/binder/IPCThreadState.h index 0490fd3..78306b2 100644 --- a/include/utils/IPCThreadState.h +++ b/include/binder/IPCThreadState.h @@ -18,8 +18,8 @@ #define ANDROID_IPC_THREAD_STATE_H #include <utils/Errors.h> -#include <utils/Parcel.h> -#include <utils/ProcessState.h> +#include <binder/Parcel.h> +#include <binder/ProcessState.h> #include <utils/Vector.h> #ifdef HAVE_WIN32_PROC diff --git a/include/utils/IPermissionController.h b/include/binder/IPermissionController.h index cb1dd34..f9d371b 100644 --- a/include/utils/IPermissionController.h +++ b/include/binder/IPermissionController.h @@ -18,7 +18,7 @@ #ifndef ANDROID_IPERMISSION_CONTROLLER_H #define ANDROID_IPERMISSION_CONTROLLER_H -#include <utils/IInterface.h> +#include <binder/IInterface.h> namespace android { diff --git a/include/utils/IServiceManager.h b/include/binder/IServiceManager.h index e3d99fe..ea149dd 100644 --- a/include/utils/IServiceManager.h +++ b/include/binder/IServiceManager.h @@ -18,8 +18,8 @@ #ifndef ANDROID_ISERVICE_MANAGER_H #define ANDROID_ISERVICE_MANAGER_H -#include <utils/IInterface.h> -#include <utils/IPermissionController.h> +#include <binder/IInterface.h> +#include <binder/IPermissionController.h> #include <utils/Vector.h> #include <utils/String16.h> diff --git a/include/utils/MemoryBase.h b/include/binder/MemoryBase.h index eb5a9d2..463e26d 100644 --- a/include/utils/MemoryBase.h +++ b/include/binder/MemoryBase.h @@ -20,7 +20,7 @@ #include <stdlib.h> #include <stdint.h> -#include <utils/IMemory.h> +#include <binder/IMemory.h> namespace android { diff --git a/include/utils/MemoryDealer.h b/include/binder/MemoryDealer.h index 79d7883..2080ea6 100644 --- a/include/utils/MemoryDealer.h +++ b/include/binder/MemoryDealer.h @@ -21,9 +21,9 @@ #include <stdint.h> #include <sys/types.h> -#include <utils/IMemory.h> +#include <binder/IMemory.h> #include <utils/threads.h> -#include <utils/MemoryHeapBase.h> +#include <binder/MemoryHeapBase.h> namespace android { // ---------------------------------------------------------------------------- diff --git a/include/utils/MemoryHeapBase.h b/include/binder/MemoryHeapBase.h index 574acf4..83c7283 100644 --- a/include/utils/MemoryHeapBase.h +++ b/include/binder/MemoryHeapBase.h @@ -20,7 +20,7 @@ #include <stdlib.h> #include <stdint.h> -#include <utils/IMemory.h> +#include <binder/IMemory.h> namespace android { diff --git a/include/utils/MemoryHeapPmem.h b/include/binder/MemoryHeapPmem.h index 60335ad..dbf26ff 100644 --- a/include/utils/MemoryHeapPmem.h +++ b/include/binder/MemoryHeapPmem.h @@ -20,9 +20,9 @@ #include <stdlib.h> #include <stdint.h> -#include <utils/MemoryDealer.h> -#include <utils/MemoryHeapBase.h> -#include <utils/IMemory.h> +#include <binder/MemoryDealer.h> +#include <binder/MemoryHeapBase.h> +#include <binder/IMemory.h> #include <utils/SortedVector.h> namespace android { diff --git a/include/utils/Parcel.h b/include/binder/Parcel.h index af1490a..af1490a 100644 --- a/include/utils/Parcel.h +++ b/include/binder/Parcel.h diff --git a/include/utils/ProcessState.h b/include/binder/ProcessState.h index 39584f4..feeb3c3 100644 --- a/include/utils/ProcessState.h +++ b/include/binder/ProcessState.h @@ -17,7 +17,7 @@ #ifndef ANDROID_PROCESS_STATE_H #define ANDROID_PROCESS_STATE_H -#include <utils/IBinder.h> +#include <binder/IBinder.h> #include <utils/KeyedVector.h> #include <utils/String8.h> #include <utils/String16.h> diff --git a/include/private/binder/Static.h b/include/private/binder/Static.h new file mode 100644 index 0000000..5b0f9fc --- /dev/null +++ b/include/private/binder/Static.h @@ -0,0 +1,39 @@ +/* + * Copyright (C) 2008 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. + */ + +// All static variables go here, to control initialization and +// destruction order in the library. + +#include <utils/threads.h> + +#include <binder/IBinder.h> +#include <binder/IMemory.h> +#include <binder/ProcessState.h> +#include <binder/IPermissionController.h> +#include <binder/IServiceManager.h> + +namespace android { + +// For ProcessState.cpp +extern Mutex gProcessMutex; +extern sp<ProcessState> gProcess; + +// For ServiceManager.cpp +extern Mutex gDefaultServiceManagerLock; +extern sp<IServiceManager> gDefaultServiceManager; +extern sp<IPermissionController> gPermissionController; + +} // namespace android diff --git a/include/private/utils/binder_module.h b/include/private/binder/binder_module.h index fdf327e..fdf327e 100644 --- a/include/private/utils/binder_module.h +++ b/include/private/binder/binder_module.h diff --git a/include/private/utils/Static.h b/include/private/utils/Static.h index f1439b7..d95ae0d 100644 --- a/include/private/utils/Static.h +++ b/include/private/utils/Static.h @@ -20,14 +20,6 @@ #include <utils/threads.h> #include <utils/KeyedVector.h> -#ifndef LIBUTILS_NATIVE -#include <utils/IBinder.h> -#include <utils/IMemory.h> -#include <utils/ProcessState.h> -#include <utils/IPermissionController.h> -#include <utils/IServiceManager.h> -#endif - namespace android { // For TextStream.cpp extern Vector<int32_t> gTextBuffers; @@ -40,19 +32,4 @@ extern void terminate_string8(); extern void initialize_string16(); extern void terminate_string16(); - - -#ifndef LIBUTILS_NATIVE - -// For ProcessState.cpp -extern Mutex gProcessMutex; -extern sp<ProcessState> gProcess; - -// For ServiceManager.cpp -extern Mutex gDefaultServiceManagerLock; -extern sp<IServiceManager> gDefaultServiceManager; -extern sp<IPermissionController> gPermissionController; - -#endif - } // namespace android diff --git a/include/tts/TtsEngine.h b/include/tts/TtsEngine.h new file mode 100644 index 0000000..06f3820 --- /dev/null +++ b/include/tts/TtsEngine.h @@ -0,0 +1,167 @@ +/* + * Copyright (C) 2009 Google Inc. + * + * 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. + */ +#include <media/AudioSystem.h> + +// This header defines the interface used by the Android platform +// to access Text-To-Speech functionality in shared libraries that implement speech +// synthesis and the management of resources associated with the synthesis. +// An example of the implementation of this interface can be found in +// FIXME: add path+name to implementation of default TTS engine +// Libraries implementing this interface are used in: +// frameworks/base/tts/jni/android_tts_SpeechSynthesis.cpp + +namespace android { + +// The callback is used by the implementation of this interface to notify its +// client, the Android TTS service, that the last requested synthesis has been +// completed. +// The callback for synthesis completed takes: +// void * - The userdata pointer set in the original synth call +// uint32_t - Track sampling rate in Hz +// audio_format - The AudioSystem::audio_format enum +// int - The number of channels +// int8_t * - A buffer of audio data only valid during the execution of the callback +// size_t - The size of the buffer +// Note about memory management: +// The implementation of TtsEngine is responsible for the management of the memory +// it allocates to store the synthesized speech. After the execution of the callback +// to hand the synthesized data to the client of TtsEngine, the TTS engine is +// free to reuse or free the previously allocated memory. +// This implies that the implementation of the "synthDoneCB" callback cannot use +// the pointer to the buffer of audio samples outside of the callback itself. +typedef void (synthDoneCB_t)(void *, uint32_t, AudioSystem::audio_format, int, int8_t *, size_t); + +class TtsEngine; +extern "C" TtsEngine* getTtsEngine(); + +enum tts_result { + TTS_SUCCESS = 0, + TTS_FAILURE = -1, + TTS_FEATURE_UNSUPPORTED = -2, + TTS_VALUE_INVALID = -3, + TTS_PROPERTY_UNSUPPORTED = -4, + TTS_PROPERTY_SIZE_TOO_SMALL = -5 +}; + +class TtsEngine +{ +public: + // Initialize the TTS engine and returns whether initialization succeeded. + // @param synthDoneCBPtr synthesis callback function pointer + // @return TTS_SUCCESS, or TTS_FAILURE + virtual tts_result init(synthDoneCB_t synthDoneCBPtr); + + // Shut down the TTS engine and releases all associated resources. + // @return TTS_SUCCESS, or TTS_FAILURE + virtual tts_result shutdown(); + + // Interrupt synthesis and flushes any synthesized data that hasn't been output yet. + // This will block until callbacks underway are completed. + // @return TTS_SUCCESS, or TTS_FAILURE + virtual tts_result stop(); + + // Load the resources associated with the specified language. The loaded language will + // only be used once a call to setLanguage() with the same language value is issued. + // Language values are based on the Android conventions for localization as described in + // the Android platform documentation on internationalization. This implies that language + // data is specified in the format xx-rYY, where xx is a two letter ISO 639-1 language code + // in lowercase and rYY is a two letter ISO 3166-1-alpha-2 language code in uppercase + // preceded by a lowercase "r". + // @param value pointer to the language value + // @param size length of the language value + // @return TTS_SUCCESS, or TTS_FAILURE + virtual tts_result loadLanguage(const char *value, const size_t size); + + // Signal the engine to use the specified language. This will force the language to be + // loaded if it wasn't loaded previously with loadLanguage(). + // See loadLanguage for the specification of the language. + // @param value pointer to the language value + // @param size length of the language value + // @return TTS_SUCCESS, or TTS_FAILURE + virtual tts_result setLanguage(const char *value, const size_t size); + + // Retrieve the currently set language, or an empty "value" if no language has + // been set. + // @param[out] value pointer to the retrieved language value + // @param[inout] iosize in: stores the size available to store the language value in *value + // out: stores the size required to hold the language value if + // getLanguage() returned TTS_PROPERTY_SIZE_TOO_SMALL, + // unchanged otherwise. + // @return TTS_SUCCESS, or TTS_PROPERTY_SIZE_TOO_SMALL, or TTS_FAILURE + virtual tts_result getLanguage(char *value, size_t *iosize); + + // Set a property for the the TTS engine + // "size" is the maximum size of "value" for properties "property" + // @param property pointer to the property name + // @param value pointer to the property value + // @param size maximum size required to store this type of property + // @return TTS_PROPERTY_UNSUPPORTED, or TTS_SUCCESS, or TTS_FAILURE, + // or TTS_VALUE_INVALID + virtual tts_result setProperty(const char *property, const char *value, const size_t size); + + // Retrieve a property from the TTS engine + // @param property pointer to the property name + // @param[out] value pointer to the retrieved language value + // @param[inout] iosize in: stores the size available to store the property value + // out: stores the size required to hold the language value if + // getLanguage() returned TTS_PROPERTY_SIZE_TOO_SMALL, + // unchanged otherwise. + // @return TTS_PROPERTY_UNSUPPORTED, or TTS_SUCCESS, or TTS_PROPERTY_SIZE_TOO_SMALL + virtual tts_result getProperty(const char *property, char *value, size_t *iosize); + + // Synthesize the text. + // When synthesis completes, the engine invokes the callback to notify the TTS framework. + // Note about the format of the input: the text parameter may use the following elements + // and their respective attributes as defined in the SSML 1.0 specification: + // * lang + // * say-as: + // o interpret-as + // * phoneme + // * voice: + // o gender, + // o age, + // o variant, + // o name + // * emphasis + // * break: + // o strength, + // o time + // * prosody: + // o pitch, + // o contour, + // o range, + // o rate, + // o duration, + // o volume + // * mark + // Differences between this text format and SSML are: + // * full SSML documents are not supported + // * namespaces are not supported + // Text is coded in UTF-8. + // @param text the UTF-8 text to synthesize + // @param userdata pointer to be returned when the call is invoked + // @return TTS_SUCCESS or TTS_FAILURE + virtual tts_result synthesizeText(const char *text, void *userdata); + + // Synthesize IPA text. When synthesis completes, the engine must call the given callback to notify the TTS API. + // @param ipa the IPA data to synthesize + // @param userdata pointer to be returned when the call is invoked + // @return TTS_FEATURE_UNSUPPORTED if IPA is not supported, otherwise TTS_SUCCESS or TTS_FAILURE + virtual tts_result synthesizeIpa(const char *ipa, void *userdata); +}; + +} // namespace android + diff --git a/include/ui/CameraHardwareInterface.h b/include/ui/CameraHardwareInterface.h index 73036f0..2cdcc06 100644 --- a/include/ui/CameraHardwareInterface.h +++ b/include/ui/CameraHardwareInterface.h @@ -17,7 +17,7 @@ #ifndef ANDROID_HARDWARE_CAMERA_HARDWARE_INTERFACE_H #define ANDROID_HARDWARE_CAMERA_HARDWARE_INTERFACE_H -#include <utils/IMemory.h> +#include <binder/IMemory.h> #include <utils/RefBase.h> #include <ui/CameraParameters.h> #include <ui/Overlay.h> diff --git a/include/ui/ICamera.h b/include/ui/ICamera.h index 241fb63..1df7914 100644 --- a/include/ui/ICamera.h +++ b/include/ui/ICamera.h @@ -18,10 +18,10 @@ #define ANDROID_HARDWARE_ICAMERA_H #include <utils/RefBase.h> -#include <utils/IInterface.h> -#include <utils/Parcel.h> +#include <binder/IInterface.h> +#include <binder/Parcel.h> #include <ui/ISurface.h> -#include <utils/IMemory.h> +#include <binder/IMemory.h> #include <utils/String8.h> #include <ui/Camera.h> diff --git a/include/ui/ICameraClient.h b/include/ui/ICameraClient.h index c4bdd07..f38a6aa 100644 --- a/include/ui/ICameraClient.h +++ b/include/ui/ICameraClient.h @@ -18,9 +18,9 @@ #define ANDROID_HARDWARE_ICAMERA_APP_H #include <utils/RefBase.h> -#include <utils/IInterface.h> -#include <utils/Parcel.h> -#include <utils/IMemory.h> +#include <binder/IInterface.h> +#include <binder/Parcel.h> +#include <binder/IMemory.h> namespace android { diff --git a/include/ui/ICameraService.h b/include/ui/ICameraService.h index c652c51..061681a 100644 --- a/include/ui/ICameraService.h +++ b/include/ui/ICameraService.h @@ -18,8 +18,8 @@ #define ANDROID_HARDWARE_ICAMERASERVICE_H #include <utils/RefBase.h> -#include <utils/IInterface.h> -#include <utils/Parcel.h> +#include <binder/IInterface.h> +#include <binder/Parcel.h> #include <ui/ICameraClient.h> #include <ui/ICamera.h> diff --git a/include/ui/IOverlay.h b/include/ui/IOverlay.h index 699b1b0..af3add1 100644 --- a/include/ui/IOverlay.h +++ b/include/ui/IOverlay.h @@ -21,7 +21,7 @@ #include <sys/types.h> #include <utils/Errors.h> -#include <utils/IInterface.h> +#include <binder/IInterface.h> #include <utils/RefBase.h> #include <ui/PixelFormat.h> diff --git a/include/ui/ISurface.h b/include/ui/ISurface.h index e47b753..adba45a 100644 --- a/include/ui/ISurface.h +++ b/include/ui/ISurface.h @@ -21,7 +21,7 @@ #include <sys/types.h> #include <utils/Errors.h> -#include <utils/IInterface.h> +#include <binder/IInterface.h> #include <utils/RefBase.h> #include <ui/PixelFormat.h> diff --git a/include/ui/ISurfaceComposer.h b/include/ui/ISurfaceComposer.h index fd5a473..ab6dd56 100644 --- a/include/ui/ISurfaceComposer.h +++ b/include/ui/ISurfaceComposer.h @@ -22,7 +22,7 @@ #include <utils/RefBase.h> #include <utils/Errors.h> -#include <utils/IInterface.h> +#include <binder/IInterface.h> #include <ui/PixelFormat.h> #include <ui/ISurfaceFlingerClient.h> diff --git a/include/ui/ISurfaceFlingerClient.h b/include/ui/ISurfaceFlingerClient.h index 8515e2e..e93a4fa 100644 --- a/include/ui/ISurfaceFlingerClient.h +++ b/include/ui/ISurfaceFlingerClient.h @@ -21,7 +21,7 @@ #include <sys/types.h> #include <utils/Errors.h> -#include <utils/IInterface.h> +#include <binder/IInterface.h> #include <utils/RefBase.h> #include <ui/ISurface.h> diff --git a/include/ui/Overlay.h b/include/ui/Overlay.h index 66514b4..9ba2f7b 100644 --- a/include/ui/Overlay.h +++ b/include/ui/Overlay.h @@ -21,7 +21,7 @@ #include <sys/types.h> #include <utils/Errors.h> -#include <utils/IInterface.h> +#include <binder/IInterface.h> #include <utils/RefBase.h> #include <utils/threads.h> diff --git a/include/ui/Region.h b/include/ui/Region.h index 849369d..e36dcb4 100644 --- a/include/ui/Region.h +++ b/include/ui/Region.h @@ -21,7 +21,7 @@ #include <sys/types.h> #include <utils/Vector.h> -#include <utils/Parcel.h> +#include <binder/Parcel.h> #include <ui/Rect.h> diff --git a/include/utils/AssetManager.h b/include/utils/AssetManager.h index e94c0e8..c11429e 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".] * diff --git a/include/utils/backup_helpers.h b/include/utils/backup_helpers.h index 73b9989..24b6c9e 100644 --- a/include/utils/backup_helpers.h +++ b/include/utils/backup_helpers.h @@ -22,11 +22,34 @@ namespace android { -int back_up_files(int oldSnapshotFD, int oldDataStream, int newSnapshotFD, - char const* fileBase, char const* const* files, int fileCount); +enum { + BACKUP_HEADER_APP_V1 = 0x31707041, // App1 (little endian) + BACKUP_HEADER_ENTITY_V1 = 0x61746144, // Data (little endian) + BACKUP_FOOTER_APP_V1 = 0x746f6f46, // Foot (little endian) +}; + +// the sizes of all of these match. +typedef struct { + int type; // == BACKUP_HEADER_APP_V1 + int packageLen; // length of the name of the package that follows, not including the null. + int cookie; +} app_header_v1; + +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; + +typedef struct { + int type; // BACKUP_FOOTER_APP_V1 + int entityCount; // the number of entities that were written + int cookie; +} app_footer_v1; + /** - * Reads the data. + * Writes the data. * * If an error occurs, it poisons this object and all write calls will fail * with the error that occurred. @@ -38,12 +61,12 @@ public: // does not close fd ~BackupDataWriter(); - status_t WriteAppHeader(const String8& packageName); + status_t WriteAppHeader(const String8& packageName, int cookie); status_t WriteEntityHeader(const String8& key, size_t dataSize); status_t WriteEntityData(const void* data, size_t size); - status_t WriteAppFooter(); + status_t WriteAppFooter(int cookie); private: explicit BackupDataWriter(); @@ -55,13 +78,57 @@ private: int m_entityCount; }; -#define TEST_BACKUP_HELPERS 0 +/** + * 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(int* type = NULL); + + status_t ReadAppHeader(String8* packageName, int* cookie); + 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. + status_t ReadEntityData(void* data, size_t size); + status_t ReadAppFooter(int* cookie); + +private: + explicit BackupDataReader(); + status_t skip_padding(); + + int m_fd; + status_t m_status; + ssize_t m_pos; + int m_entityCount; + union { + int type; + app_header_v1 app; + entity_header_v1 entity; + app_footer_v1 footer; + } m_header; +}; + +int back_up_files(int oldSnapshotFD, BackupDataWriter* dataStream, int newSnapshotFD, + char const* fileBase, char const* const* files, int fileCount); + + +#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_data_writer(); +int backup_helper_test_data_reader(); #endif } // namespace android |