summaryrefslogtreecommitdiffstats
path: root/FMRecord
diff options
context:
space:
mode:
authorSudhir Sharma <sudhshar@codeaurora.org>2014-08-18 13:05:00 -0700
committerSudhir Sharma <sudhshar@codeaurora.org>2014-08-19 10:21:45 -0700
commitbad3182db0209c81c5d3e095bb526f0ed6bafeff (patch)
tree6e4a94d65b354f405c787ef6cfa7441b7123bf2f /FMRecord
parent930dee890b4fe725da6f8d26e351ae7acf40aafd (diff)
parent5925b6976819451f9c7d9394f110713731163b12 (diff)
downloadandroid_hardware_qcom_fm-bad3182db0209c81c5d3e095bb526f0ed6bafeff.tar.gz
android_hardware_qcom_fm-bad3182db0209c81c5d3e095bb526f0ed6bafeff.tar.bz2
android_hardware_qcom_fm-bad3182db0209c81c5d3e095bb526f0ed6bafeff.zip
Merge tag 'AU_LINUX_ANDROID_KK.04.04.04.010.104' into HEAD
AU_LINUX_ANDROID_KK.04.04.04.010.104 based on quic/aosp/kk Change-Id: I90f866085d8b3a594478eaabf280517986821c91
Diffstat (limited to 'FMRecord')
-rw-r--r--FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java38
1 files changed, 37 insertions, 1 deletions
diff --git a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
index da55d8c..e101584 100644
--- a/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
+++ b/FMRecord/src/com/codeaurora/fmrecording/FMRecordingService.java
@@ -372,6 +372,7 @@ public class FMRecordingService extends Service {
Log.d(TAG, "In addToMediaDB");
Resources res = getResources();
ContentValues cv = new ContentValues();
+ int audioId = -1;
long current = System.currentTimeMillis();
long modDate = file.lastModified();
long recordDuration = stopTimerMs - startTimerMs;
@@ -393,6 +394,11 @@ public class FMRecordingService extends Service {
res.getString(R.string.audio_db_artist_name));
cv.put(MediaStore.Audio.Media.ALBUM,
res.getString(R.string.audio_db_album_name));
+ audioId = getFileIdInVideoDB(file);
+ if (audioId != -1) {//remove the record if it is already added into video table.
+ removeRecordInVideoDB(audioId);
+ Log.d(TAG, "Remove audio record " + audioId + " in video database");
+ }
Log.d(TAG, "Inserting audio record: " + cv.toString());
ContentResolver resolver = getContentResolver();
Uri base = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
@@ -405,7 +411,7 @@ public class FMRecordingService extends Service {
if (getPlaylistId(res) == -1) {
createPlaylist(res, resolver);
}
- int audioId = Integer.valueOf(result.getLastPathSegment());
+ audioId = Integer.valueOf(result.getLastPathSegment());
addToPlaylist(resolver, audioId, getPlaylistId(res));
// Notify those applications such as Music listening to the
@@ -414,6 +420,36 @@ public class FMRecordingService extends Service {
return result;
}
+ private int getFileIdInVideoDB(File file) {
+ int id = -1;
+ final String where = MediaStore.Video.Media.DATA + "=?";
+ final String[] args = new String[] { file.getAbsolutePath() };
+ final String[] ids = new String[] { MediaStore.Video.Media._ID };
+ Uri base = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
+
+ Cursor cursor = query(base, ids, where, args, null);
+ if (cursor == null) {
+ Log.v(TAG, "Data query returns null");
+ } else {
+ if (cursor.moveToNext() != false) {
+ id = cursor.getInt(0);
+ cursor.close();
+ }
+ }
+ return id;
+ }
+
+ private void removeRecordInVideoDB(int id) {
+ final String where = MediaStore.Video.Media._ID + "=" + id;
+ Uri base = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
+ ContentValues cv = new ContentValues();
+ ContentResolver resolver = getContentResolver();
+
+ cv.put(MediaStore.Video.Media.DATA, "null");
+ resolver.update(base, cv, where, null);
+ resolver.delete(base, where, null);
+ }
+
private int getPlaylistId(Resources res) {
Uri uri = MediaStore.Audio.Playlists.getContentUri("external");
final String[] ids = new String[] { MediaStore.Audio.Playlists._ID };