From 3c12a7c6d727fd5cd7cccbf999bdb380a95cde79 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Thu, 1 Oct 2015 15:14:57 -0700 Subject: Hold wake-lock during copy operations. If the CPU goes to sleep during the copy, certain devices will collapse the USB OTG power domain, which can cause user data loss. Bug: 24574575 Change-Id: I8e26caac8784490d2dee324b38e6085cd55eb8bb --- packages/DocumentsUI/AndroidManifest.xml | 1 + .../DocumentsUI/src/com/android/documentsui/CopyService.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) (limited to 'packages/DocumentsUI') diff --git a/packages/DocumentsUI/AndroidManifest.xml b/packages/DocumentsUI/AndroidManifest.xml index 382b2d0..ff14f94 100644 --- a/packages/DocumentsUI/AndroidManifest.xml +++ b/packages/DocumentsUI/AndroidManifest.xml @@ -3,6 +3,7 @@ + srcs = intent.getParcelableArrayListExtra(EXTRA_SRC_LIST); final DocumentStack stack = intent.getParcelableExtra(EXTRA_STACK); try { + wakeLock.acquire(); + // Acquire content providers. mSrcClient = DocumentsApplication.acquireUnstableProviderOrThrow(getContentResolver(), srcs.get(0).authority); @@ -151,6 +158,8 @@ public class CopyService extends IntentService { ContentProviderClient.releaseQuietly(mSrcClient); ContentProviderClient.releaseQuietly(mDstClient); + wakeLock.release(); + // Dismiss the ongoing copy notification when the copy is done. mNotificationManager.cancel(mJobId, 0); @@ -179,7 +188,8 @@ public class CopyService extends IntentService { @Override public void onCreate() { super.onCreate(); - mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); + mPowerManager = getSystemService(PowerManager.class); + mNotificationManager = getSystemService(NotificationManager.class); } /** -- cgit v1.1