diff options
author | Maunik Shah <mshah@codeaurora.org> | 2013-08-15 17:09:43 +0530 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2016-10-02 00:39:21 -0700 |
commit | e6087480654cbeebdce350340258423af222a0cd (patch) | |
tree | 255857a73a969310953c8aa03c32ddbf44fa2d93 | |
parent | 019696ff078883aa08917aba0bc7b3f1b35f6d38 (diff) | |
download | android_packages_providers_MediaProvider-cm-14.0.tar.gz android_packages_providers_MediaProvider-cm-14.0.tar.bz2 android_packages_providers_MediaProvider-cm-14.0.zip |
Screenshots info is not updated when device is plugged in MTP modecm-14.0
When device is connected as MTP mode and user opens folder
/sdcard/Pictures/Screenshots/ in windows system and captures new
screenshot, image information is always shown as 0 KB
Issue: https://code.google.com/p/android/issues/detail?id=56204
Change-Id: I0e633efc7a5b213e519d4de6b137992c5bfe8738
-rw-r--r-- | src/com/android/providers/media/IMtpService.aidl | 1 | ||||
-rw-r--r-- | src/com/android/providers/media/MediaProvider.java | 42 | ||||
-rw-r--r-- | src/com/android/providers/media/MtpService.java | 8 |
3 files changed, 51 insertions, 0 deletions
diff --git a/src/com/android/providers/media/IMtpService.aidl b/src/com/android/providers/media/IMtpService.aidl index e599f7bb..f86c803e 100644 --- a/src/com/android/providers/media/IMtpService.aidl +++ b/src/com/android/providers/media/IMtpService.aidl @@ -20,4 +20,5 @@ interface IMtpService { void sendObjectAdded(int objectHandle); void sendObjectRemoved(int objectHandle); + void sendObjectUpdated(int objectHandle); } diff --git a/src/com/android/providers/media/MediaProvider.java b/src/com/android/providers/media/MediaProvider.java index ef14869f..f6b1f2d6 100644 --- a/src/com/android/providers/media/MediaProvider.java +++ b/src/com/android/providers/media/MediaProvider.java @@ -2875,6 +2875,19 @@ public class MediaProvider extends ContentProvider { } } + private void sendObjectUpdated(long objectHandle) { + synchronized (mMtpServiceConnection) { + if (mMtpService != null) { + try { + mMtpService.sendObjectUpdated((int)objectHandle); + } catch (RemoteException e) { + Log.e(TAG, "RemoteException in sendObjectUpdated", e); + mMtpService = null; + } + } + } + } + @Override public int bulkInsert(Uri uri, ContentValues values[]) { int match = URI_MATCHER.match(uri); @@ -4443,6 +4456,11 @@ public class MediaProvider extends ContentProvider { + count + " match = " + match); } } + if (count > 0) { + helper.mNumQueries++; + notifyMtpUpdated(sGetTableAndWhereParam.table, db, + sGetTableAndWhereParam.where, whereArgs); + } } break; case IMAGES_MEDIA: @@ -4487,6 +4505,11 @@ public class MediaProvider extends ContentProvider { } } } + if (count > 0) { + helper.mNumQueries++; + notifyMtpUpdated(sGetTableAndWhereParam.table, db, + sGetTableAndWhereParam.where, whereArgs); + } } break; @@ -4509,6 +4532,11 @@ public class MediaProvider extends ContentProvider { helper.mNumUpdates++; count = db.update(sGetTableAndWhereParam.table, initialValues, sGetTableAndWhereParam.where, whereArgs); + if (count > 0) { + helper.mNumQueries++; + notifyMtpUpdated(sGetTableAndWhereParam.table, db, + sGetTableAndWhereParam.where, whereArgs); + } break; } } @@ -4520,6 +4548,20 @@ public class MediaProvider extends ContentProvider { return count; } + private void notifyMtpUpdated(String table, SQLiteDatabase db, + String userWhere, String[] whereArgs) { + Cursor c = db.query(table, ID_PROJECTION, userWhere, whereArgs, null, null, null); + if (c != null) { + try { + while (c.moveToNext()) { + sendObjectUpdated(c.getLong(0)); + } + } finally { + c.close(); + } + } + } + private int movePlaylistEntry(DatabaseHelper helper, SQLiteDatabase db, long playlist, int from, int to) { if (from == to) { diff --git a/src/com/android/providers/media/MtpService.java b/src/com/android/providers/media/MtpService.java index f9e7a7f2..bce18c87 100644 --- a/src/com/android/providers/media/MtpService.java +++ b/src/com/android/providers/media/MtpService.java @@ -196,6 +196,14 @@ public class MtpService extends Service { } } } + + public void sendObjectUpdated(int objectHandle) { + synchronized (mBinder) { + if (mServer != null) { + mServer.sendObjectUpdated(objectHandle); + } + } + } }; @Override |