summaryrefslogtreecommitdiffstats
path: root/packages/DocumentsUI
diff options
context:
space:
mode:
authorJeff Sharkey <jsharkey@google.com>2015-10-08 17:09:29 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-10-08 17:09:29 +0000
commite0210648d82a4816218e057a6bf52ee946ee9530 (patch)
tree517ffe3353db2e8dde9958977a6cf4a5dcac9b90 /packages/DocumentsUI
parentd621ee11fa76d7dd803a802bf000baa591c84fbe (diff)
parenta0ef104882b1a0edd79badb2f327cc8722f76bb2 (diff)
downloadframeworks_base-e0210648d82a4816218e057a6bf52ee946ee9530.zip
frameworks_base-e0210648d82a4816218e057a6bf52ee946ee9530.tar.gz
frameworks_base-e0210648d82a4816218e057a6bf52ee946ee9530.tar.bz2
am a0ef1048: am d473a144: Merge "Hold wake-lock during copy operations." into mnc-dr-dev
* commit 'a0ef104882b1a0edd79badb2f327cc8722f76bb2': Hold wake-lock during copy operations.
Diffstat (limited to 'packages/DocumentsUI')
-rw-r--r--packages/DocumentsUI/AndroidManifest.xml1
-rw-r--r--packages/DocumentsUI/src/com/android/documentsui/CopyService.java12
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);
}
/**