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

Commit d914995a authored by Svetoslav Ganov's avatar Svetoslav Ganov Committed by Android (Google) Code Review
Browse files

Merge "Printing from secondary user not working." into klp-dev

parents 188d0953 4a82b455
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -474,7 +474,8 @@ public final class PrintManagerService extends IPrintManager.Stub {
                    ComponentName component = new ComponentName(serviceInfo.packageName,
                            serviceInfo.name);
                    String label = serviceInfo.loadLabel(mContext.getPackageManager()).toString();
                    showEnableInstalledPrintServiceNotification(component, label);
                    showEnableInstalledPrintServiceNotification(component, label,
                            getChangingUserId());
                }
            }

@@ -622,12 +623,14 @@ public final class PrintManagerService extends IPrintManager.Stub {
    }

    private void showEnableInstalledPrintServiceNotification(ComponentName component,
            String label) {
            String label, int userId) {
        UserHandle userHandle = new UserHandle(userId);

        Intent intent = new Intent(Settings.ACTION_PRINT_SETTINGS);
        intent.putExtra(EXTRA_PRINT_SERVICE_COMPONENT_NAME, component.flattenToString());

        PendingIntent pendingIntent = PendingIntent.getActivity(mContext, 0, intent,
                PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT, null);
        PendingIntent pendingIntent = PendingIntent.getActivityAsUser(mContext, 0, intent,
                PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_CANCEL_CURRENT, null, userHandle);

        Notification.Builder builder = new Notification.Builder(mContext)
                .setSmallIcon(R.drawable.ic_print)
@@ -642,6 +645,7 @@ public final class PrintManagerService extends IPrintManager.Stub {
                .getSystemService(Context.NOTIFICATION_SERVICE);

        String notificationTag = getClass().getName() + ":" + component.flattenToString();
        notificationManager.notify(notificationTag, 0, builder.build());
        notificationManager.notifyAsUser(notificationTag, 0, builder.build(),
                userHandle);
    }
}
+4 −2
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.os.Looper;
import android.os.Message;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.UserHandle;
import android.print.IPrintDocumentAdapter;
import android.print.IPrintJobStateChangeListener;
import android.print.IPrinterDiscoveryObserver;
@@ -199,9 +200,10 @@ final class UserState implements PrintSpoolerCallbacks, PrintServiceCallbacks {
            intent.putExtra(PrintManager.EXTRA_PRINT_JOB, printJob);
            intent.putExtra(DocumentsContract.EXTRA_PACKAGE_NAME, packageName);

            IntentSender intentSender = PendingIntent.getActivity(
            IntentSender intentSender = PendingIntent.getActivityAsUser(
                    mContext, 0, intent, PendingIntent.FLAG_ONE_SHOT
                    | PendingIntent.FLAG_CANCEL_CURRENT).getIntentSender();
                    | PendingIntent.FLAG_CANCEL_CURRENT, null, new UserHandle(mUserId))
                    .getIntentSender();

            Bundle result = new Bundle();
            result.putParcelable(PrintManager.EXTRA_PRINT_JOB, printJob);