am d914995a: Merge "Printing from secondary user not working." into klp-dev
* commit 'd914995aad23371cfa24c83608d78214ea7abf1f': Printing from secondary user not working.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user