Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a0ef1048 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android Git Automerger
Browse files

am d473a144: Merge "Hold wake-lock during copy operations." into mnc-dr-dev

* commit 'd473a144':
  Hold wake-lock during copy operations.
parents edc3585f d473a144
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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"
+11 −1
Original line number Diff line number Diff line
@@ -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);
    }

    /**