summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorJosh Guilfoyle <jasta00@gmail.com>2011-01-20 13:31:49 -0800
committerJosh Guilfoyle <jasta00@gmail.com>2011-01-20 18:19:14 -0800
commitb58e5ae98ba80cdf7be6ec4e3df1b43d21d771cc (patch)
tree7ea590e0e5625e8752ebb7151c9e82b036adbb5b /include
parentcc45a6dc068d343137415b57f6545231c8282be3 (diff)
downloadframeworks_base-b58e5ae98ba80cdf7be6ec4e3df1b43d21d771cc.zip
frameworks_base-b58e5ae98ba80cdf7be6ec4e3df1b43d21d771cc.tar.gz
frameworks_base-b58e5ae98ba80cdf7be6ec4e3df1b43d21d771cc.tar.bz2
Asset redirections are now managed by a system service.
Adjusted the asset redirection design to use a common system service (AssetRedirectionManagerService) for synchronization and cache management. This replaces the old /data/res-cache design completely (nothing is written to disk now). This change also moves a large amount of code from the C++ layer to Java for parsing the theme meta data and redirection XML files, though the actual redirection still occurs at the native layer. Change-Id: I8820e39425135269f5e723534c4b9c8dc6841779
Diffstat (limited to 'include')
-rw-r--r--include/utils/AssetManager.h17
-rw-r--r--include/utils/FileLock.h79
-rw-r--r--include/utils/PackageRedirectionMap.h68
-rw-r--r--include/utils/ResourceTypes.h40
4 files changed, 75 insertions, 129 deletions
diff --git a/include/utils/AssetManager.h b/include/utils/AssetManager.h
index 01179ed..f374cae 100644
--- a/include/utils/AssetManager.h
+++ b/include/utils/AssetManager.h
@@ -23,6 +23,7 @@
#include <utils/Asset.h>
#include <utils/AssetDir.h>
+#include <utils/PackageRedirectionMap.h>
#include <utils/KeyedVector.h>
#include <utils/String8.h>
#include <utils/Vector.h>
@@ -218,9 +219,6 @@ public:
*/
void getLocales(Vector<String8>* locales) const;
- void setThemePackageInfo(const char* packageName, uint32_t styleId);
- const char* getThemePackageName();
-
/*
* Remove existing source for assets.
*
@@ -231,6 +229,8 @@ public:
bool removeAssetPath(const String8 &packageName, void *cookie);
bool updateWithAssetPath(const String8& path, void** cookie);
void dumpRes();
+ void addRedirections(PackageRedirectionMap* resMap);
+ void clearRedirections();
private:
struct asset_path
@@ -239,12 +239,6 @@ private:
FileType type;
};
- SharedBuffer* generateRedirections(SharedBuffer* entriesByTypeBuf, ResTable* rt,
- const char* themePackageName, const char16_t* resPackageName);
- bool generateAndWriteRedirections(ResTable* rt, const char* themePackageName,
- uint32_t themeStyleId, const char16_t* resPackageName, const char* redirPath,
- bool isFramework) const;
- void loadRedirectionMappings(ResTable* rt) const;
void updateResTableFromAssetPath(ResTable* rt, const asset_path& ap, void* cookie) const;
Asset* openInPathLocked(const char* fileName, AccessMode mode,
const asset_path& path);
@@ -362,11 +356,6 @@ private:
char* mLocale;
char* mVendor;
- // If non-null, represents the theme package from which to construct the
- // resource redirection map used by ResTable.
- char* mThemePackageName;
- uint32_t mThemeStyleId;
-
mutable ResTable* mResources;
ResTable_config* mConfig;
diff --git a/include/utils/FileLock.h b/include/utils/FileLock.h
deleted file mode 100644
index 2253cc2..0000000
--- a/include/utils/FileLock.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2010, T-Mobile USA, 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.
- */
-
-#ifndef __LIBS_FILE_LOCK_H
-#define __LIBS_FILE_LOCK_H
-
-#include <fcntl.h>
-
-namespace android {
-
-/*
- * Object oriented interface for flock. Implements reference counting so that
- * multiple levels of locks on the same object instance is possible.
- */
-class FileLock {
-public:
- FileLock(const char* fileName);
-
- /*
- * Lock the file. A balanced call to unlock is required even if the lock
- * fails.
- */
- bool lock(int openFlags=O_RDWR, mode_t fileCreateMode=0755) {
- mRefCount++;
- if (mFd == -1) {
- return doLock(openFlags, fileCreateMode);
- } else {
- return true;
- }
- }
-
- /*
- * Call this when mapping is no longer needed.
- */
- void unlock(void) {
- if (--mRefCount <= 0) {
- delete this;
- }
- }
-
- /*
- * Return the name of the file this map came from, if known.
- */
- const char* getFileName(void) const { return mFileName; }
-
- /*
- * Return the open file descriptor, if locked; -1 otherwise.
- */
- int getFileDescriptor(void) const { return mFd; }
-
-protected:
- // don't delete objects; call unlock()
- ~FileLock(void);
-
- bool doLock(int openFlags, mode_t fileCreateMode);
-
-private:
-
- int mRefCount; // reference count
- int mFd; // file descriptor, if locked
- char* mFileName; // original file name, if known
-};
-
-}; // namespace android
-
-#endif // __LIBS_FILE_LOCK_H
diff --git a/include/utils/PackageRedirectionMap.h b/include/utils/PackageRedirectionMap.h
new file mode 100644
index 0000000..9e6435b
--- /dev/null
+++ b/include/utils/PackageRedirectionMap.h
@@ -0,0 +1,68 @@
+/*
+ * 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_PACKAGEREDIRECTIONMAP_H
+#define ANDROID_PACKAGEREDIRECTIONMAP_H
+
+#include <binder/Parcel.h>
+
+// ---------------------------------------------------------------------------
+
+namespace android {
+
+class PackageRedirectionMap
+{
+public:
+ PackageRedirectionMap();
+ ~PackageRedirectionMap();
+
+ bool addRedirection(uint32_t fromIdent, uint32_t toIdent);
+ uint32_t lookupRedirection(uint32_t fromIdent);
+
+ // If there are no redirections present in this map, this method will
+ // return -1.
+ int getPackage();
+
+ // Usage of the following methods is intended to be used only by the JNI
+ // methods for the purpose of parceling.
+ size_t getNumberOfTypes();
+ size_t getNumberOfUsedTypes();
+
+ size_t getNumberOfEntries(int type);
+ size_t getNumberOfUsedEntries(int type);
+
+ // Similar to lookupRedirection, but with no sanity checking.
+ uint32_t getEntry(int type, int entry);
+
+private:
+ int mPackage;
+
+ /*
+ * Sparse array organized into two layers: first by type, then by entry.
+ * The result of each lookup will be a qualified resource ID in the theme
+ * package scope.
+ *
+ * Underneath each layer is a SharedBuffer which
+ * indicates the array size.
+ */
+ uint32_t** mEntriesByType;
+};
+
+} // namespace android
+
+// ---------------------------------------------------------------------------
+
+#endif // ANDROID_PACKAGEREDIRECTIONMAP_H
diff --git a/include/utils/ResourceTypes.h b/include/utils/ResourceTypes.h
index abdc00b..bae6b92 100644
--- a/include/utils/ResourceTypes.h
+++ b/include/utils/ResourceTypes.h
@@ -24,6 +24,7 @@
#include <utils/Asset.h>
#include <utils/ByteOrder.h>
#include <utils/Errors.h>
+#include <utils/PackageRedirectionMap.h>
#include <utils/String16.h>
#include <utils/Vector.h>
@@ -1741,7 +1742,7 @@ public:
bool copyData=false);
status_t add(ResTable* src);
- status_t addRedirections(int package, const char* dataPath);
+ void addRedirections(PackageRedirectionMap* resMap);
void clearRedirections();
status_t getError() const;
@@ -2031,43 +2032,10 @@ private:
// package array.
uint8_t mPackageMap[256];
- // Represents the resource lookup table for a specific package.
- class PackageResMap {
- public:
- ~PackageResMap();
-
- int package;
-
- // Do the heavy lifting to read from a specific package resource map
- // file.
- static PackageResMap* createFromCache(int package, const char* cachePath);
-
- // Returns 0 if the lookup finds no mapping.
- uint32_t lookup(int type, int entry);
-
- // Inserts a SharedBuffer array into the res map structure.
- void insert(int type, const uint32_t* entries);
-
- private:
- PackageResMap();
-
- bool parseMap(const unsigned char* basePtr,
- const unsigned char* endPtr);
-
- uint32_t* parseMapType(const unsigned char* basePtr,
- const unsigned char* endPtr);
-
- // Sparse array representing all entries, organized into two layers:
- // first by type, then by entry id. The result of each lookup will be
- // a qualified resource ID in the theme package scope. Underneath is a
- // SharedBuffer on both layers which indicates the size.
- uint32_t** mEntriesByType;
- };
-
// Resource redirection mapping provided by the applied theme (if there is
- // any). Resources requested which are found in this map will be
+ // one). Resources requested which are found in this map will be
// automatically redirected to the appropriate themed value.
- Vector<PackageResMap*> mRedirectionMap;
+ Vector<PackageRedirectionMap*> mRedirectionMap;
};
} // namespace android