diff options
author | Jeff Sharkey <jsharkey@google.com> | 2015-10-08 17:02:38 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2015-10-08 17:02:38 +0000 |
commit | a0ef104882b1a0edd79badb2f327cc8722f76bb2 (patch) | |
tree | 03fcc6d59996704c0387ee6499381cd598c75043 /packages/DocumentsUI | |
parent | edc3585ffd1ce17f12b808f0473ebc582e159132 (diff) | |
parent | d473a1446e520616c4079594bbcf3c6fbe88ed4f (diff) | |
download | frameworks_base-a0ef104882b1a0edd79badb2f327cc8722f76bb2.zip frameworks_base-a0ef104882b1a0edd79badb2f327cc8722f76bb2.tar.gz frameworks_base-a0ef104882b1a0edd79badb2f327cc8722f76bb2.tar.bz2 |
am d473a144: Merge "Hold wake-lock during copy operations." into mnc-dr-dev
* commit 'd473a1446e520616c4079594bbcf3c6fbe88ed4f':
Hold wake-lock during copy operations.
Diffstat (limited to 'packages/DocumentsUI')
-rw-r--r-- | packages/DocumentsUI/AndroidManifest.xml | 1 | ||||
-rw-r--r-- | packages/DocumentsUI/src/com/android/documentsui/CopyService.java | 12 |
2 files changed, 12 insertions, 1 deletions
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 @@ <uses-permission android:name="android.permission.MANAGE_DOCUMENTS" /> <uses-permission android:name="android.permission.REMOVE_TASKS" /> + <uses-permission android:name="android.permission.WAKE_LOCK" /> <application android:name=".DocumentsApplication" diff --git a/packages/DocumentsUI/src/com/android/documentsui/CopyService.java b/packages/DocumentsUI/src/com/android/documentsui/CopyService.java index 506ec58..f270d9e 100644 --- a/packages/DocumentsUI/src/com/android/documentsui/CopyService.java +++ b/packages/DocumentsUI/src/com/android/documentsui/CopyService.java @@ -32,6 +32,7 @@ import android.net.Uri; import android.os.CancellationSignal; import android.os.ParcelFileDescriptor; import android.os.Parcelable; +import android.os.PowerManager; import android.os.RemoteException; import android.os.SystemClock; import android.provider.DocumentsContract; @@ -65,6 +66,8 @@ public class CopyService extends IntentService { // TODO: Move it to a shared file when more operations are implemented. public static final int FAILURE_COPY = 1; + private PowerManager mPowerManager; + private NotificationManager mNotificationManager; private Notification.Builder mProgressBuilder; @@ -129,10 +132,14 @@ public class CopyService extends IntentService { return; } + final PowerManager.WakeLock wakeLock = mPowerManager + .newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG); final ArrayList<DocumentInfo> 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); } /** |