Allow _DELETE_FILE trigger to delete files in /data/media

Change-Id: I8a3f620cd6633f2be47ac05e17ea642f00b71e91
Signed-off-by: Mike Lockwood <lockwood@android.com>
diff --git a/android/sqlite3_android.cpp b/android/sqlite3_android.cpp
index 11de1f7..ab52c5c 100644
--- a/android/sqlite3_android.cpp
+++ b/android/sqlite3_android.cpp
@@ -26,6 +26,7 @@
 #include <unicode/ustring.h>
 #include <unicode/utypes.h>
 #include <cutils/log.h>
+#include <cutils/properties.h>
 
 #include "sqlite3_android.h"
 #include "PhoneNumberUtils.h"
@@ -190,13 +191,17 @@
     }
 
     char const * path = (char const *)sqlite3_value_text(argv[0]);
+    char media_storage[PROPERTY_VALUE_MAX];
     char const * external_storage = getenv("EXTERNAL_STORAGE");
-    if (path == NULL || external_storage == NULL) {
+    if (path == NULL) {
         sqlite3_result_null(context);
         return;
     }
 
-    if (strncmp(external_storage, path, strlen(external_storage)) != 0) {
+    property_get("ro.media.storage", media_storage, "");
+    // path must match either ro.media.storage or EXTERNAL_STORAGE directory
+    if ( !(media_storage[0] && strncmp(media_storage, path, strlen(media_storage)) == 0) &&
+         !(external_storage && strncmp(external_storage, path, strlen(external_storage)) == 0)) {
         sqlite3_result_null(context);
         return;
     }
diff --git a/dist/Android.mk b/dist/Android.mk
index 7537b0d..3a666cc 100644
--- a/dist/Android.mk
+++ b/dist/Android.mk
@@ -34,7 +34,8 @@
 LOCAL_SHARED_LIBRARIES += liblog \
             libicuuc \
             libicui18n \
-            libutils
+            libutils \
+            libcutils
 
 # include android specific methods
 LOCAL_WHOLE_STATIC_LIBRARIES := libsqlite3_android