Add cache dir to context object.

Change-Id: Icc3220329fbaee7d453259fbe1cbf34d145d195c
diff --git a/rsContext.h b/rsContext.h
index 1c6fc58..dac276f 100644
--- a/rsContext.h
+++ b/rsContext.h
@@ -256,13 +256,35 @@
 
 #ifdef RS_COMPATIBILITY_LIB
     void setNativeLibDir(const char * libDir, uint32_t length) {
-        memcpy(nativeLibDir, libDir, length);
+        if (!hasSetNativeLibDir) {
+            if (length <= PATH_MAX) {
+                memcpy(nativeLibDir, libDir, length);
+                hasSetNativeLibDir = true;
+            } else {
+                setError(RS_ERROR_BAD_VALUE, "Invalid path");
+            }
+        }
     }
     const char * getNativeLibDir() {
         return nativeLibDir;
     }
 #endif
 
+    void setCacheDir(const char * cacheDir_arg, uint32_t length) {
+        if (!hasSetCacheDir) {
+            if (length <= PATH_MAX) {
+                memcpy(mCacheDir, cacheDir_arg, length);
+                hasSetCacheDir = true;
+            } else {
+                setError(RS_ERROR_BAD_VALUE, "Invalid path");
+            }
+        }
+    }
+    const char * getCacheDir() {
+        return mCacheDir;
+    }
+
+
 protected:
 
     uint32_t mTargetSdkVersion;
@@ -329,8 +351,11 @@
     uint64_t mAverageFPSStartTime;
     uint32_t mAverageFPS;
 #ifdef RS_COMPATIBILITY_LIB
+    bool hasSetNativeLibDir = false;
     char nativeLibDir[PATH_MAX+1];
 #endif
+    bool hasSetCacheDir = false;
+    char mCacheDir[PATH_MAX+1];
 };
 
 void LF_ObjDestroy_handcode(const Context *rsc, RsAsyncVoidPtr objPtr);