Methods Summary |
---|
public void | addPrintJobStateChangeListener(android.print.IPrintJobStateChangeListener listener, int appId)
synchronized (mLock) {
throwIfDestroyedLocked();
if (mPrintJobStateChangeListenerRecords == null) {
mPrintJobStateChangeListenerRecords =
new ArrayList<PrintJobStateChangeListenerRecord>();
}
mPrintJobStateChangeListenerRecords.add(
new PrintJobStateChangeListenerRecord(listener, appId) {
@Override
public void onBinderDied() {
mPrintJobStateChangeListenerRecords.remove(this);
}
});
}
|
private void | addServiceLocked(RemotePrintService service)
mActiveServices.put(service.getComponentName(), service);
if (mPrinterDiscoverySession != null) {
mPrinterDiscoverySession.onServiceAddedLocked(service);
}
|
public void | cancelPrintJob(android.print.PrintJobId printJobId, int appId)
PrintJobInfo printJobInfo = mSpooler.getPrintJobInfo(printJobId, appId);
if (printJobInfo == null) {
return;
}
// Take a note that we are trying to cancel the job.
mSpooler.setPrintJobCancelling(printJobId, true);
if (printJobInfo.getState() != PrintJobInfo.STATE_FAILED) {
ComponentName printServiceName = printJobInfo.getPrinterId().getServiceName();
RemotePrintService printService = null;
synchronized (mLock) {
printService = mActiveServices.get(printServiceName);
}
if (printService == null) {
return;
}
printService.onRequestCancelPrintJob(printJobInfo);
} else {
// If the print job is failed we do not need cooperation
// from the print service.
mSpooler.setPrintJobState(printJobId, PrintJobInfo.STATE_CANCELED, null);
}
|
public void | createPrinterDiscoverySession(android.print.IPrinterDiscoveryObserver observer)
synchronized (mLock) {
throwIfDestroyedLocked();
if (mActiveServices.isEmpty()) {
return;
}
if (mPrinterDiscoverySession == null) {
// If we do not have a session, tell all service to create one.
mPrinterDiscoverySession = new PrinterDiscoverySessionMediator(mContext) {
@Override
public void onDestroyed() {
mPrinterDiscoverySession = null;
}
};
// Add the observer to the brand new session.
mPrinterDiscoverySession.addObserverLocked(observer);
} else {
// If services have created session, just add the observer.
mPrinterDiscoverySession.addObserverLocked(observer);
}
}
|
public void | destroyLocked()
throwIfDestroyedLocked();
mSpooler.destroy();
for (RemotePrintService service : mActiveServices.values()) {
service.destroy();
}
mActiveServices.clear();
mInstalledServices.clear();
mEnabledServices.clear();
if (mPrinterDiscoverySession != null) {
mPrinterDiscoverySession.destroyLocked();
mPrinterDiscoverySession = null;
}
mDestroyed = true;
|
public void | destroyPrinterDiscoverySession(android.print.IPrinterDiscoveryObserver observer)
synchronized (mLock) {
// Already destroyed - nothing to do.
if (mPrinterDiscoverySession == null) {
return;
}
// Remove this observer.
mPrinterDiscoverySession.removeObserverLocked(observer);
}
|
public void | dump(java.io.FileDescriptor fd, java.io.PrintWriter pw, java.lang.String prefix)
pw.append(prefix).append("user state ").append(String.valueOf(mUserId)).append(":");
pw.println();
String tab = " ";
pw.append(prefix).append(tab).append("installed services:").println();
final int installedServiceCount = mInstalledServices.size();
for (int i = 0; i < installedServiceCount; i++) {
PrintServiceInfo installedService = mInstalledServices.get(i);
String installedServicePrefix = prefix + tab + tab;
pw.append(installedServicePrefix).append("service:").println();
ResolveInfo resolveInfo = installedService.getResolveInfo();
ComponentName componentName = new ComponentName(
resolveInfo.serviceInfo.packageName,
resolveInfo.serviceInfo.name);
pw.append(installedServicePrefix).append(tab).append("componentName=")
.append(componentName.flattenToString()).println();
pw.append(installedServicePrefix).append(tab).append("settingsActivity=")
.append(installedService.getSettingsActivityName()).println();
pw.append(installedServicePrefix).append(tab).append("addPrintersActivity=")
.append(installedService.getAddPrintersActivityName()).println();
pw.append(installedServicePrefix).append(tab).append("avancedOptionsActivity=")
.append(installedService.getAdvancedOptionsActivityName()).println();
}
pw.append(prefix).append(tab).append("enabled services:").println();
for (ComponentName enabledService : mEnabledServices) {
String enabledServicePrefix = prefix + tab + tab;
pw.append(enabledServicePrefix).append("service:").println();
pw.append(enabledServicePrefix).append(tab).append("componentName=")
.append(enabledService.flattenToString());
pw.println();
}
pw.append(prefix).append(tab).append("active services:").println();
final int activeServiceCount = mActiveServices.size();
for (int i = 0; i < activeServiceCount; i++) {
RemotePrintService activeService = mActiveServices.valueAt(i);
activeService.dump(pw, prefix + tab + tab);
pw.println();
}
pw.append(prefix).append(tab).append("cached print jobs:").println();
mPrintJobForAppCache.dump(pw, prefix + tab + tab);
pw.append(prefix).append(tab).append("discovery mediator:").println();
if (mPrinterDiscoverySession != null) {
mPrinterDiscoverySession.dump(pw, prefix + tab + tab);
}
pw.append(prefix).append(tab).append("print spooler:").println();
mSpooler.dump(fd, pw, prefix + tab + tab);
pw.println();
|
private void | enableSystemPrintServicesLocked()
// Load enabled and installed services.
readEnabledPrintServicesLocked();
readInstalledPrintServicesLocked();
// Load the system services once enabled on first boot.
Set<ComponentName> enabledOnFirstBoot = new HashSet<ComponentName>();
readPrintServicesFromSettingLocked(
Settings.Secure.ENABLED_ON_FIRST_BOOT_SYSTEM_PRINT_SERVICES,
enabledOnFirstBoot);
StringBuilder builder = new StringBuilder();
final int serviceCount = mInstalledServices.size();
for (int i = 0; i < serviceCount; i++) {
ServiceInfo serviceInfo = mInstalledServices.get(i).getResolveInfo().serviceInfo;
// Enable system print services if we never did that and are not enabled.
if ((serviceInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
ComponentName serviceName = new ComponentName(
serviceInfo.packageName, serviceInfo.name);
if (!mEnabledServices.contains(serviceName)
&& !enabledOnFirstBoot.contains(serviceName)) {
if (builder.length() > 0) {
builder.append(":");
}
builder.append(serviceName.flattenToString());
}
}
}
// Nothing to be enabled - done.
if (builder.length() <= 0) {
return;
}
String servicesToEnable = builder.toString();
// Update the enabled services setting.
String enabledServices = Settings.Secure.getStringForUser(
mContext.getContentResolver(), Settings.Secure.ENABLED_PRINT_SERVICES, mUserId);
if (TextUtils.isEmpty(enabledServices)) {
enabledServices = servicesToEnable;
} else {
enabledServices = enabledServices + ":" + servicesToEnable;
}
Settings.Secure.putStringForUser(mContext.getContentResolver(),
Settings.Secure.ENABLED_PRINT_SERVICES, enabledServices, mUserId);
// Update the enabled on first boot services setting.
String enabledOnFirstBootServices = Settings.Secure.getStringForUser(
mContext.getContentResolver(),
Settings.Secure.ENABLED_ON_FIRST_BOOT_SYSTEM_PRINT_SERVICES, mUserId);
if (TextUtils.isEmpty(enabledOnFirstBootServices)) {
enabledOnFirstBootServices = servicesToEnable;
} else {
enabledOnFirstBootServices = enabledOnFirstBootServices + ":" + enabledServices;
}
Settings.Secure.putStringForUser(mContext.getContentResolver(),
Settings.Secure.ENABLED_ON_FIRST_BOOT_SYSTEM_PRINT_SERVICES,
enabledOnFirstBootServices, mUserId);
|
private void | failActivePrintJobsForService(android.content.ComponentName serviceName)
// Makes sure all active print jobs are failed since the service
// just died. Do this off the main thread since we do to allow
// calls into the spooler on the main thread.
if (Looper.getMainLooper().isCurrentThread()) {
BackgroundThread.getHandler().post(new Runnable() {
@Override
public void run() {
failScheduledPrintJobsForServiceInternal(serviceName);
}
});
} else {
failScheduledPrintJobsForServiceInternal(serviceName);
}
|
private void | failScheduledPrintJobsForServiceInternal(android.content.ComponentName serviceName)
List<PrintJobInfo> printJobs = mSpooler.getPrintJobInfos(serviceName,
PrintJobInfo.STATE_ANY_SCHEDULED, PrintManager.APP_ID_ANY);
if (printJobs == null) {
return;
}
final long identity = Binder.clearCallingIdentity();
try {
final int printJobCount = printJobs.size();
for (int i = 0; i < printJobCount; i++) {
PrintJobInfo printJob = printJobs.get(i);
mSpooler.setPrintJobState(printJob.getId(), PrintJobInfo.STATE_FAILED,
mContext.getString(R.string.reason_service_unavailable));
}
} finally {
Binder.restoreCallingIdentity(identity);
}
|
public java.util.List | getEnabledPrintServices()
synchronized (mLock) {
List<PrintServiceInfo> enabledServices = null;
final int installedServiceCount = mInstalledServices.size();
for (int i = 0; i < installedServiceCount; i++) {
PrintServiceInfo installedService = mInstalledServices.get(i);
ComponentName componentName = new ComponentName(
installedService.getResolveInfo().serviceInfo.packageName,
installedService.getResolveInfo().serviceInfo.name);
if (mActiveServices.containsKey(componentName)) {
if (enabledServices == null) {
enabledServices = new ArrayList<PrintServiceInfo>();
}
enabledServices.add(installedService);
}
}
return enabledServices;
}
|
public java.util.Set | getEnabledServices()
synchronized(mLock) {
throwIfDestroyedLocked();
return mEnabledServices;
}
|
public java.util.List | getInstalledPrintServices()
synchronized (mLock) {
return mInstalledServices;
}
|
public android.print.PrintJobInfo | getPrintJobInfo(android.print.PrintJobId printJobId, int appId)
PrintJobInfo printJob = mPrintJobForAppCache.getPrintJob(printJobId, appId);
if (printJob == null) {
printJob = mSpooler.getPrintJobInfo(printJobId, appId);
}
if (printJob != null) {
// Strip out the tag and the advanced print options.
// They are visible only to print services.
printJob.setTag(null);
printJob.setAdvancedOptions(null);
}
return printJob;
|
public java.util.List | getPrintJobInfos(int appId)
List<PrintJobInfo> cachedPrintJobs = mPrintJobForAppCache.getPrintJobs(appId);
// Note that the print spooler is not storing print jobs that
// are in a terminal state as it is non-trivial to properly update
// the spooler state for when to forget print jobs in terminal state.
// Therefore, we fuse the cached print jobs for running apps (some
// jobs are in a terminal state) with the ones that the print
// spooler knows about (some jobs are being processed).
ArrayMap<PrintJobId, PrintJobInfo> result =
new ArrayMap<PrintJobId, PrintJobInfo>();
// Add the cached print jobs for running apps.
final int cachedPrintJobCount = cachedPrintJobs.size();
for (int i = 0; i < cachedPrintJobCount; i++) {
PrintJobInfo cachedPrintJob = cachedPrintJobs.get(i);
result.put(cachedPrintJob.getId(), cachedPrintJob);
// Strip out the tag and the advanced print options.
// They are visible only to print services.
cachedPrintJob.setTag(null);
cachedPrintJob.setAdvancedOptions(null);
}
// Add everything else the spooler knows about.
List<PrintJobInfo> printJobs = mSpooler.getPrintJobInfos(null,
PrintJobInfo.STATE_ANY, appId);
if (printJobs != null) {
final int printJobCount = printJobs.size();
for (int i = 0; i < printJobCount; i++) {
PrintJobInfo printJob = printJobs.get(i);
result.put(printJob.getId(), printJob);
// Strip out the tag and the advanced print options.
// They are visible only to print services.
printJob.setTag(null);
printJob.setAdvancedOptions(null);
}
}
return new ArrayList<PrintJobInfo>(result.values());
|
private void | handleDispatchPrintJobStateChanged(android.print.PrintJobId printJobId, int appId)
final List<PrintJobStateChangeListenerRecord> records;
synchronized (mLock) {
if (mPrintJobStateChangeListenerRecords == null) {
return;
}
records = new ArrayList<PrintJobStateChangeListenerRecord>(
mPrintJobStateChangeListenerRecords);
}
final int recordCount = records.size();
for (int i = 0; i < recordCount; i++) {
PrintJobStateChangeListenerRecord record = records.get(i);
if (record.appId == PrintManager.APP_ID_ANY
|| record.appId == appId)
try {
record.listener.onPrintJobStateChanged(printJobId);
} catch (RemoteException re) {
Log.e(LOG_TAG, "Error notifying for print job state change", re);
}
}
|
public void | onAllPrintJobsForServiceHandled(android.content.ComponentName printService)
final RemotePrintService service;
synchronized (mLock) {
throwIfDestroyedLocked();
service = mActiveServices.get(printService);
}
if (service != null) {
service.onAllPrintJobsHandled();
}
|
private void | onConfigurationChangedLocked()
Set<ComponentName> installedComponents = new ArraySet<ComponentName>();
final int installedCount = mInstalledServices.size();
for (int i = 0; i < installedCount; i++) {
ResolveInfo resolveInfo = mInstalledServices.get(i).getResolveInfo();
ComponentName serviceName = new ComponentName(resolveInfo.serviceInfo.packageName,
resolveInfo.serviceInfo.name);
installedComponents.add(serviceName);
if (mEnabledServices.contains(serviceName)) {
if (!mActiveServices.containsKey(serviceName)) {
RemotePrintService service = new RemotePrintService(
mContext, serviceName, mUserId, mSpooler, this);
addServiceLocked(service);
}
} else {
RemotePrintService service = mActiveServices.remove(serviceName);
if (service != null) {
removeServiceLocked(service);
}
}
}
Iterator<Map.Entry<ComponentName, RemotePrintService>> iterator =
mActiveServices.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<ComponentName, RemotePrintService> entry = iterator.next();
ComponentName serviceName = entry.getKey();
RemotePrintService service = entry.getValue();
if (!installedComponents.contains(serviceName)) {
removeServiceLocked(service);
iterator.remove();
}
}
|
public void | onPrintJobQueued(android.print.PrintJobInfo printJob)
final RemotePrintService service;
synchronized (mLock) {
throwIfDestroyedLocked();
ComponentName printServiceName = printJob.getPrinterId().getServiceName();
service = mActiveServices.get(printServiceName);
}
if (service != null) {
service.onPrintJobQueued(printJob);
} else {
// The service for the job is no longer enabled, so just
// fail the job with the appropriate message.
mSpooler.setPrintJobState(printJob.getId(), PrintJobInfo.STATE_FAILED,
mContext.getString(R.string.reason_service_unavailable));
}
|
public void | onPrintJobStateChanged(android.print.PrintJobInfo printJob)
mPrintJobForAppCache.onPrintJobStateChanged(printJob);
mHandler.obtainMessage(UserStateHandler.MSG_DISPATCH_PRINT_JOB_STATE_CHANGED,
printJob.getAppId(), 0, printJob.getId()).sendToTarget();
|
public void | onPrintersAdded(java.util.List printers)
synchronized (mLock) {
throwIfDestroyedLocked();
// No services - nothing to do.
if (mActiveServices.isEmpty()) {
return;
}
// No session - nothing to do.
if (mPrinterDiscoverySession == null) {
return;
}
mPrinterDiscoverySession.onPrintersAddedLocked(printers);
}
|
public void | onPrintersRemoved(java.util.List printerIds)
synchronized (mLock) {
throwIfDestroyedLocked();
// No services - nothing to do.
if (mActiveServices.isEmpty()) {
return;
}
// No session - nothing to do.
if (mPrinterDiscoverySession == null) {
return;
}
mPrinterDiscoverySession.onPrintersRemovedLocked(printerIds);
}
|
public void | onServiceDied(RemotePrintService service)
synchronized (mLock) {
throwIfDestroyedLocked();
// No services - nothing to do.
if (mActiveServices.isEmpty()) {
return;
}
// Fail all print jobs.
failActivePrintJobsForService(service.getComponentName());
service.onAllPrintJobsHandled();
// No session - nothing to do.
if (mPrinterDiscoverySession == null) {
return;
}
mPrinterDiscoverySession.onServiceDiedLocked(service);
}
|
public android.os.Bundle | print(java.lang.String printJobName, android.print.IPrintDocumentAdapter adapter, android.print.PrintAttributes attributes, java.lang.String packageName, int appId)
// Create print job place holder.
final PrintJobInfo printJob = new PrintJobInfo();
printJob.setId(new PrintJobId());
printJob.setAppId(appId);
printJob.setLabel(printJobName);
printJob.setAttributes(attributes);
printJob.setState(PrintJobInfo.STATE_CREATED);
printJob.setCopies(1);
printJob.setCreationTime(System.currentTimeMillis());
// Track this job so we can forget it when the creator dies.
if (!mPrintJobForAppCache.onPrintJobCreated(adapter.asBinder(), appId,
printJob)) {
// Not adding a print job means the client is dead - done.
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);
intent.setData(Uri.fromParts("printjob", printJob.getId().flattenToString(), null));
intent.putExtra(PrintManager.EXTRA_PRINT_DOCUMENT_ADAPTER, adapter.asBinder());
intent.putExtra(PrintManager.EXTRA_PRINT_JOB, printJob);
intent.putExtra(DocumentsContract.EXTRA_PACKAGE_NAME, packageName);
IntentSender intentSender = PendingIntent.getActivityAsUser(
mContext, 0, intent, PendingIntent.FLAG_ONE_SHOT
| PendingIntent.FLAG_CANCEL_CURRENT, null, new UserHandle(mUserId))
.getIntentSender();
Bundle result = new Bundle();
result.putParcelable(PrintManager.EXTRA_PRINT_JOB, printJob);
result.putParcelable(PrintManager.EXTRA_PRINT_DIALOG_INTENT, intentSender);
return result;
} finally {
Binder.restoreCallingIdentity(identity);
}
|
private boolean | readConfigurationLocked()
boolean somethingChanged = false;
somethingChanged |= readInstalledPrintServicesLocked();
somethingChanged |= readEnabledPrintServicesLocked();
return somethingChanged;
|
private boolean | readEnabledPrintServicesLocked()
Set<ComponentName> tempEnabledServiceNameSet = new HashSet<ComponentName>();
readPrintServicesFromSettingLocked(Settings.Secure.ENABLED_PRINT_SERVICES,
tempEnabledServiceNameSet);
if (!tempEnabledServiceNameSet.equals(mEnabledServices)) {
mEnabledServices.clear();
mEnabledServices.addAll(tempEnabledServiceNameSet);
return true;
}
return false;
|
private boolean | readInstalledPrintServicesLocked()
Set<PrintServiceInfo> tempPrintServices = new HashSet<PrintServiceInfo>();
List<ResolveInfo> installedServices = mContext.getPackageManager()
.queryIntentServicesAsUser(mQueryIntent, PackageManager.GET_SERVICES
| PackageManager.GET_META_DATA, mUserId);
final int installedCount = installedServices.size();
for (int i = 0, count = installedCount; i < count; i++) {
ResolveInfo installedService = installedServices.get(i);
if (!android.Manifest.permission.BIND_PRINT_SERVICE.equals(
installedService.serviceInfo.permission)) {
ComponentName serviceName = new ComponentName(
installedService.serviceInfo.packageName,
installedService.serviceInfo.name);
Slog.w(LOG_TAG, "Skipping print service "
+ serviceName.flattenToShortString()
+ " since it does not require permission "
+ android.Manifest.permission.BIND_PRINT_SERVICE);
continue;
}
tempPrintServices.add(PrintServiceInfo.create(installedService, mContext));
}
boolean someServiceChanged = false;
if (tempPrintServices.size() != mInstalledServices.size()) {
someServiceChanged = true;
} else {
for (PrintServiceInfo newService: tempPrintServices) {
final int oldServiceIndex = mInstalledServices.indexOf(newService);
if (oldServiceIndex < 0) {
someServiceChanged = true;
break;
}
// PrintServiceInfo#equals compares only the id not all members,
// so we are also comparing the members coming from meta-data.
PrintServiceInfo oldService = mInstalledServices.get(oldServiceIndex);
if (!TextUtils.equals(oldService.getAddPrintersActivityName(),
newService.getAddPrintersActivityName())
|| !TextUtils.equals(oldService.getAdvancedOptionsActivityName(),
newService.getAdvancedOptionsActivityName())
|| !TextUtils.equals(oldService.getSettingsActivityName(),
newService.getSettingsActivityName())) {
someServiceChanged = true;
break;
}
}
}
if (someServiceChanged) {
mInstalledServices.clear();
mInstalledServices.addAll(tempPrintServices);
return true;
}
return false;
|
private void | readPrintServicesFromSettingLocked(java.lang.String setting, java.util.Set outServiceNames)
String settingValue = Settings.Secure.getStringForUser(mContext.getContentResolver(),
setting, mUserId);
if (!TextUtils.isEmpty(settingValue)) {
TextUtils.SimpleStringSplitter splitter = mStringColonSplitter;
splitter.setString(settingValue);
while (splitter.hasNext()) {
String string = splitter.next();
if (TextUtils.isEmpty(string)) {
continue;
}
ComponentName componentName = ComponentName.unflattenFromString(string);
if (componentName != null) {
outServiceNames.add(componentName);
}
}
}
|
public void | removeObsoletePrintJobs()
mSpooler.removeObsoletePrintJobs();
|
public void | removePrintJobStateChangeListener(android.print.IPrintJobStateChangeListener listener)
synchronized (mLock) {
throwIfDestroyedLocked();
if (mPrintJobStateChangeListenerRecords == null) {
return;
}
final int recordCount = mPrintJobStateChangeListenerRecords.size();
for (int i = 0; i < recordCount; i++) {
PrintJobStateChangeListenerRecord record =
mPrintJobStateChangeListenerRecords.get(i);
if (record.listener.asBinder().equals(listener.asBinder())) {
mPrintJobStateChangeListenerRecords.remove(i);
break;
}
}
if (mPrintJobStateChangeListenerRecords.isEmpty()) {
mPrintJobStateChangeListenerRecords = null;
}
}
|
private void | removeServiceLocked(RemotePrintService service)
// Fail all print jobs.
failActivePrintJobsForService(service.getComponentName());
// If discovery is in progress, tear down the service.
if (mPrinterDiscoverySession != null) {
mPrinterDiscoverySession.onServiceRemovedLocked(service);
} else {
// Otherwise, just destroy it.
service.destroy();
}
|
public void | restartPrintJob(android.print.PrintJobId printJobId, int appId)
PrintJobInfo printJobInfo = getPrintJobInfo(printJobId, appId);
if (printJobInfo == null || printJobInfo.getState() != PrintJobInfo.STATE_FAILED) {
return;
}
mSpooler.setPrintJobState(printJobId, PrintJobInfo.STATE_QUEUED, null);
|
public void | startPrinterDiscovery(android.print.IPrinterDiscoveryObserver observer, java.util.List printerIds)
synchronized (mLock) {
throwIfDestroyedLocked();
// No services - nothing to do.
if (mActiveServices.isEmpty()) {
return;
}
// No session - nothing to do.
if (mPrinterDiscoverySession == null) {
return;
}
// Kick of discovery.
mPrinterDiscoverySession.startPrinterDiscoveryLocked(observer,
printerIds);
}
|
public void | startPrinterStateTracking(android.print.PrinterId printerId)
synchronized (mLock) {
throwIfDestroyedLocked();
// No services - nothing to do.
if (mActiveServices.isEmpty()) {
return;
}
// No session - nothing to do.
if (mPrinterDiscoverySession == null) {
return;
}
// Request start tracking the printer.
mPrinterDiscoverySession.startPrinterStateTrackingLocked(printerId);
}
|
public void | stopPrinterDiscovery(android.print.IPrinterDiscoveryObserver observer)
synchronized (mLock) {
throwIfDestroyedLocked();
// No services - nothing to do.
if (mActiveServices.isEmpty()) {
return;
}
// No session - nothing to do.
if (mPrinterDiscoverySession == null) {
return;
}
// Kick of discovery.
mPrinterDiscoverySession.stopPrinterDiscoveryLocked(observer);
}
|
public void | stopPrinterStateTracking(android.print.PrinterId printerId)
synchronized (mLock) {
throwIfDestroyedLocked();
// No services - nothing to do.
if (mActiveServices.isEmpty()) {
return;
}
// No session - nothing to do.
if (mPrinterDiscoverySession == null) {
return;
}
// Request stop tracking the printer.
mPrinterDiscoverySession.stopPrinterStateTrackingLocked(printerId);
}
|
private void | throwIfDestroyedLocked()
if (mDestroyed) {
throw new IllegalStateException("Cannot interact with a destroyed instance.");
}
|
public void | updateIfNeededLocked()
throwIfDestroyedLocked();
if (readConfigurationLocked()) {
onConfigurationChangedLocked();
}
|
public void | validatePrinters(java.util.List printerIds)
synchronized (mLock) {
throwIfDestroyedLocked();
// No services - nothing to do.
if (mActiveServices.isEmpty()) {
return;
}
// No session - nothing to do.
if (mPrinterDiscoverySession == null) {
return;
}
// Request an updated.
mPrinterDiscoverySession.validatePrintersLocked(printerIds);
}
|