diff options
| author | Maunik Shah <mshah@codeaurora.org> | 2013-08-15 17:09:43 +0530 |
|---|---|---|
| committer | LorDClockaN <davor@losinj.com> | 2015-07-21 15:18:48 +0200 |
| commit | 0ddbcef8deb27ddc48726ca20cefcc3c2e4296ee (patch) | |
| tree | 27fa351b0d9ee25638ff12134153f96aafa20c29 | |
| parent | 7030376e763cd2a970f9d38c7756a695c3d87765 (diff) | |
Screenshots info is not updated when device is plugged in MTP modelp5.1
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 | ||||
| -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 b79b38a4..e62be25d 100755 --- a/src/com/android/providers/media/MediaProvider.java +++ b/src/com/android/providers/media/MediaProvider.java @@ -2863,6 +2863,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); @@ -4410,6 +4423,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: @@ -4454,6 +4472,11 @@ public class MediaProvider extends ContentProvider { } } } + if (count > 0) { + helper.mNumQueries++; + notifyMtpUpdated(sGetTableAndWhereParam.table, db, + sGetTableAndWhereParam.where, whereArgs); + } } break; @@ -4476,6 +4499,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; } } @@ -4487,6 +4515,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 7f61d8ba..912db9bc 100644 --- a/src/com/android/providers/media/MtpService.java +++ b/src/com/android/providers/media/MtpService.java @@ -229,6 +229,14 @@ public class MtpService extends Service { } } } + + public void sendObjectUpdated(int objectHandle) { + synchronized (mBinder) { + if (mServer != null) { + mServer.sendObjectUpdated(objectHandle); + } + } + } }; @Override |
