use of android.printservice.PrintServiceInfo in project android_frameworks_base by crdroidandroid.
the class PrintActivity method onLoadFinished.
@Override
public void onLoadFinished(Loader<List<PrintServiceInfo>> loader, List<PrintServiceInfo> services) {
ComponentName newAdvancedPrintOptionsActivity = null;
if (mCurrentPrinter != null && services != null) {
final int numServices = services.size();
for (int i = 0; i < numServices; i++) {
PrintServiceInfo service = services.get(i);
if (service.getComponentName().equals(mCurrentPrinter.getId().getServiceName())) {
String advancedOptionsActivityName = service.getAdvancedOptionsActivityName();
if (!TextUtils.isEmpty(advancedOptionsActivityName)) {
newAdvancedPrintOptionsActivity = new ComponentName(service.getComponentName().getPackageName(), advancedOptionsActivityName);
break;
}
}
}
}
if (!Objects.equals(newAdvancedPrintOptionsActivity, mAdvancedPrintOptionsActivity)) {
mAdvancedPrintOptionsActivity = newAdvancedPrintOptionsActivity;
updateOptionsUi();
}
boolean newArePrintServicesEnabled = services != null && !services.isEmpty();
if (mArePrintServicesEnabled != newArePrintServicesEnabled) {
mArePrintServicesEnabled = newArePrintServicesEnabled;
// reads that in DestinationAdapter#getMoreItemTitle
if (mDestinationSpinnerAdapter != null) {
mDestinationSpinnerAdapter.notifyDataSetChanged();
}
}
}
use of android.printservice.PrintServiceInfo in project android_frameworks_base by crdroidandroid.
the class UserState method setPrintServiceEnabled.
public void setPrintServiceEnabled(@NonNull ComponentName serviceName, boolean isEnabled) {
synchronized (mLock) {
boolean isChanged = false;
if (isEnabled) {
isChanged = mDisabledServices.remove(serviceName);
} else {
// Make sure to only disable services that are currently installed
final int numServices = mInstalledServices.size();
for (int i = 0; i < numServices; i++) {
PrintServiceInfo service = mInstalledServices.get(i);
if (service.getComponentName().equals(serviceName)) {
mDisabledServices.add(serviceName);
isChanged = true;
break;
}
}
}
if (isChanged) {
writeDisabledPrintServicesLocked(mDisabledServices);
onConfigurationChangedLocked();
}
}
}
Aggregations