diff options
author | Maunik Shah <mshah@codeaurora.org> | 2013-08-15 17:09:43 +0530 |
---|---|---|
committer | Steve Kondik <steve@cyngn.com> | 2015-10-31 14:36:08 -0700 |
commit | 9a8daaa85f0d95e23b39c787546133ed3be96d99 (patch) | |
tree | 0923ab4c1e2a49cf3c7937241ab9fc0aa9757820 /src/com/android/providers | |
parent | 0d9f1ba7ce1affb8ef2035944a0c0ea1c57704fe (diff) | |
download | android_packages_providers_MediaProvider-9a8daaa85f0d95e23b39c787546133ed3be96d99.tar.gz android_packages_providers_MediaProvider-9a8daaa85f0d95e23b39c787546133ed3be96d99.tar.bz2 android_packages_providers_MediaProvider-9a8daaa85f0d95e23b39c787546133ed3be96d99.zip |
Screenshots info is not updated when device is plugged in MTP mode
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
Diffstat (limited to 'src/com/android/providers')
-rw-r--r-- | src/com/android/providers/media/IMtpService.aidl | 1 | ||||
-rwxr-xr-x | 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 28960d53..5ebb541c 100755 --- a/src/com/android/providers/media/MediaProvider.java +++ b/src/com/android/providers/media/MediaProvider.java @@ -2853,6 +2853,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); @@ -4391,6 +4404,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: @@ -4435,6 +4453,11 @@ public class MediaProvider extends ContentProvider { } } } + if (count > 0) { + helper.mNumQueries++; + notifyMtpUpdated(sGetTableAndWhereParam.table, db, + sGetTableAndWhereParam.where, whereArgs); + } } break; @@ -4457,6 +4480,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; } } @@ -4468,6 +4496,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 b226f4bf..ca9c8119 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 |