summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Lockwood <lockwood@android.com>2010-11-15 11:27:47 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2010-11-15 11:27:47 -0800
commit160b977c81ce1b3edc7c310a661c31e3d5183768 (patch)
treeada5c62705d13ffe490eef3329740530a5e1f156
parentb763fa1d7c7de7ee33ab359e3105accafe5a2fdc (diff)
parent3159991e586f9e243f60d65a9554828328b00521 (diff)
downloadframeworks_base-160b977c81ce1b3edc7c310a661c31e3d5183768.zip
frameworks_base-160b977c81ce1b3edc7c310a661c31e3d5183768.tar.gz
frameworks_base-160b977c81ce1b3edc7c310a661c31e3d5183768.tar.bz2
Merge "MTP: Fix time values returned via GetObjectPropValue and GetObjectPropList"
-rw-r--r--media/java/android/media/MtpDatabase.java12
-rw-r--r--media/jni/android_media_MtpDatabase.cpp14
2 files changed, 16 insertions, 10 deletions
diff --git a/media/java/android/media/MtpDatabase.java b/media/java/android/media/MtpDatabase.java
index 0d09d4c..42d068f 100644
--- a/media/java/android/media/MtpDatabase.java
+++ b/media/java/android/media/MtpDatabase.java
@@ -30,7 +30,6 @@ import android.provider.MediaStore.Files;
import android.provider.MediaStore.Images;
import android.provider.MediaStore.MediaColumns;
import android.provider.Mtp;
-import android.text.format.Time;
import android.util.Log;
import java.io.File;
@@ -504,14 +503,6 @@ public class MtpDatabase {
return path.substring(start, end);
}
- private String formatDateTime(long seconds) {
- Time time = new Time(Time.TIMEZONE_UTC);
- time.set(seconds * 1000);
- String result = time.format("%Y-%m-%dT%H:%M:%SZ");
- Log.d(TAG, "formatDateTime returning " + result);
- return result;
- }
-
private MtpPropertyList getObjectPropertyList(int handle, int format, int property,
int groupCode, int depth) {
// FIXME - implement group support
@@ -683,7 +674,7 @@ public class MtpDatabase {
case MtpConstants.PROPERTY_DATE_MODIFIED:
case MtpConstants.PROPERTY_DATE_ADDED:
// convert from seconds to DateTime
- result.setProperty(index, handle, property, formatDateTime(c.getInt(1)));
+ result.setProperty(index, handle, property, format_date_time(c.getInt(1)));
break;
case MtpConstants.PROPERTY_ORIGINAL_RELEASE_DATE:
// release date is stored internally as just the year
@@ -1029,4 +1020,5 @@ public class MtpDatabase {
private native final void native_setup();
private native final void native_finalize();
+ private native String format_date_time(long seconds);
}
diff --git a/media/jni/android_media_MtpDatabase.cpp b/media/jni/android_media_MtpDatabase.cpp
index aa29de8..5377af6 100644
--- a/media/jni/android_media_MtpDatabase.cpp
+++ b/media/jni/android_media_MtpDatabase.cpp
@@ -1037,11 +1037,25 @@ android_media_MtpDatabase_finalize(JNIEnv *env, jobject thiz)
#endif
}
+static jstring
+android_media_MtpDatabase_format_date_time(JNIEnv *env, jobject thiz, jlong seconds)
+{
+#ifdef HAVE_ANDROID_OS
+ char date[20];
+ formatDateTime(seconds, date, sizeof(date));
+ return env->NewStringUTF(date);
+#else
+ return NULL;
+#endif
+}
+
// ----------------------------------------------------------------------------
static JNINativeMethod gMethods[] = {
{"native_setup", "()V", (void *)android_media_MtpDatabase_setup},
{"native_finalize", "()V", (void *)android_media_MtpDatabase_finalize},
+ {"format_date_time", "(J)Ljava/lang/String;",
+ (void *)android_media_MtpDatabase_format_date_time},
};
static const char* const kClassPathName = "android/media/MtpDatabase";