Revert "Replaced android::Vector with std::vector."

b/19148482

This reverts commit 93d6bc872b7d9fba63abfa7513d56b38d9c3d371.

I also made some changes to Make it work with HEAD.

Change-Id: I5e516976ec1d85ffe1cf388c01795348a9441982
diff --git a/rsCppUtils.h b/rsCppUtils.h
index 8b49056..1f792bc 100644
--- a/rsCppUtils.h
+++ b/rsCppUtils.h
@@ -19,6 +19,8 @@
 
 #if !defined(RS_SERVER) && !defined(RS_COMPATIBILITY_LIB)
 #include <utils/Log.h>
+#include <utils/String8.h>
+#include <utils/Vector.h>
 #include <cutils/atomic.h>
 #endif
 
@@ -52,6 +54,96 @@
 #define ALOGV(...) \
     __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__);
 
+namespace android {
+
+    // server has no Vector or String8 classes; implement on top of STL
+    class String8: public std::string {
+    public:
+    String8(const char *ptr) : std::string(ptr) {
+
+        }
+    String8(const char *ptr, size_t len) : std::string(ptr, len) {
+
+        }
+    String8() : std::string() {
+
+        }
+
+        const char* string() const {
+            return this->c_str();
+        }
+
+        void setTo(const char* str, ssize_t len) {
+            this->assign(str, len);
+        }
+        void setTo(const char* str) {
+            this->assign(str);
+        }
+        String8 getPathDir(void) const {
+            const char* cp;
+            const char*const str = this->c_str();
+
+            cp = strrchr(str, OS_PATH_SEPARATOR);
+            if (cp == NULL)
+                return String8("");
+            else
+                return String8(str, cp - str);
+        }
+    };
+
+    template <class T> class Vector: public std::vector<T> {
+    public:
+        void push(T obj) {
+            this->push_back(obj);
+        }
+        void removeAt(uint32_t index) {
+            this->erase(this->begin() + index);
+        }
+        ssize_t add(const T& obj) {
+            this->push_back(obj);
+            return this->size() - 1;
+        }
+        void setCapacity(ssize_t capacity) {
+            this->resize(capacity);
+        }
+
+        T* editArray() {
+            return (T*)(this->begin());
+        }
+
+        const T* array() {
+            return (const T*)(this->begin());
+        }
+
+    };
+
+    template<> class Vector<bool>: public std::vector<char> {
+    public:
+        void push(bool obj) {
+            this->push_back(obj);
+        }
+        void removeAt(uint32_t index) {
+            this->erase(this->begin() + index);
+        }
+        ssize_t add(const bool& obj) {
+            this->push_back(obj);
+            return this->size() - 1;
+        }
+        void setCapacity(ssize_t capacity) {
+            this->resize(capacity);
+        }
+
+        bool* editArray() {
+            return (bool*)(this->begin());
+        }
+
+        const bool* array() {
+            return (const bool*)(this->begin());
+        }
+    };
+
+}
+
 typedef int64_t nsecs_t;  // nano-seconds
 
 enum {
@@ -194,3 +286,5 @@
 }
 
 #endif //ANDROID_RS_OBJECT_BASE_H
+
+