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

Commit d0f119f8 authored by Philip P. Moltmann's avatar Philip P. Moltmann Committed by Android (Google) Code Review
Browse files

Merge "Create print job when print activity starts"

parents e06975dd e65a9b8e
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.printspooler.model;

import static android.content.Context.BIND_AUTO_CREATE;

import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -32,7 +34,7 @@ public class PrintSpoolerProvider implements ServiceConnection {
        mContext = context;
        mCallback = callback;
        Intent intent = new Intent(mContext, PrintSpoolerService.class);
        mContext.bindService(intent, this, 0);
        mContext.bindService(intent, this, BIND_AUTO_CREATE);
    }

    public PrintSpoolerService getSpooler() {
+16 −13
Original line number Diff line number Diff line
@@ -306,17 +306,20 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
        // This will take just a few milliseconds, so just wait to
        // bind to the local service before showing the UI.
        mSpoolerProvider = new PrintSpoolerProvider(this,
                new Runnable() {
            @Override
            public void run() {
                () -> {
                    if (isFinishing() || isDestroyed()) {
                    // onPause might have not been able to cancel the job, see PrintActivity#onPause
                        if (savedInstanceState != null) {
                            // onPause might have not been able to cancel the job, see
                            // PrintActivity#onPause
                            // To be sure, cancel the job again. Double canceling does no harm.
                            mSpoolerProvider.getSpooler().setPrintJobState(mPrintJob.getId(),
                                    PrintJobInfo.STATE_CANCELED, null);
                        }
                    } else {
                    onConnectedToPrintSpooler(adapter);
                        if (savedInstanceState == null) {
                            mSpoolerProvider.getSpooler().createPrintJob(mPrintJob);
                        }
                        onConnectedToPrintSpooler(adapter);
                    }
                });

+0 −10
Original line number Diff line number Diff line
@@ -38,7 +38,6 @@ import android.content.pm.ParceledListSlice;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.Icon;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Binder;
import android.os.Bundle;
import android.os.Handler;
@@ -236,15 +235,6 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks,
            return null;
        }

        // Spin the spooler to add the job and show the config UI.
        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {
                mSpooler.createPrintJob(printJob);
                return null;
            }
        }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, (Void[]) null);

        final long identity = Binder.clearCallingIdentity();
        try {
            Intent intent = new Intent(PrintManager.ACTION_PRINT_DIALOG);