Search in sources :

Example 16 with PrintServiceInfo

use of android.printservice.PrintServiceInfo in project android_frameworks_base by crdroidandroid.

the class UserState method dump.

public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @NonNull 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("disabled services:").println();
    for (ComponentName disabledService : mDisabledServices) {
        String disabledServicePrefix = prefix + tab + tab;
        pw.append(disabledServicePrefix).append("service:").println();
        pw.append(disabledServicePrefix).append(tab).append("componentName=").append(disabledService.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();
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PrintServiceInfo(android.printservice.PrintServiceInfo) ComponentName(android.content.ComponentName)

Example 17 with PrintServiceInfo

use of android.printservice.PrintServiceInfo in project android_frameworks_base by crdroidandroid.

the class UserState method readInstalledPrintServicesLocked.

private void readInstalledPrintServicesLocked() {
    Set<PrintServiceInfo> tempPrintServices = new HashSet<PrintServiceInfo>();
    List<ResolveInfo> installedServices = mContext.getPackageManager().queryIntentServicesAsUser(mQueryIntent, GET_SERVICES | GET_META_DATA | MATCH_DEBUG_TRIAGED_MISSING, 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));
    }
    mInstalledServices.clear();
    mInstalledServices.addAll(tempPrintServices);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PrintServiceInfo(android.printservice.PrintServiceInfo) ComponentName(android.content.ComponentName) HashSet(java.util.HashSet)

Example 18 with PrintServiceInfo

use of android.printservice.PrintServiceInfo in project android_frameworks_base by crdroidandroid.

the class UserState method getPrintServices.

@Nullable
public List<PrintServiceInfo> getPrintServices(int selectionFlags) {
    synchronized (mLock) {
        List<PrintServiceInfo> selectedServices = 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);
            // Update isEnabled under the same lock the final returned list is created
            installedService.setIsEnabled(mActiveServices.containsKey(componentName));
            if (installedService.isEnabled()) {
                if ((selectionFlags & PrintManager.ENABLED_SERVICES) == 0) {
                    continue;
                }
            } else {
                if ((selectionFlags & PrintManager.DISABLED_SERVICES) == 0) {
                    continue;
                }
            }
            if (selectedServices == null) {
                selectedServices = new ArrayList<>();
            }
            selectedServices.add(installedService);
        }
        return selectedServices;
    }
}
Also used : PrintServiceInfo(android.printservice.PrintServiceInfo) ComponentName(android.content.ComponentName) Nullable(android.annotation.Nullable)

Example 19 with PrintServiceInfo

use of android.printservice.PrintServiceInfo in project platform_frameworks_base by android.

the class SelectPrinterActivity method onLoadFinished.

@Override
public void onLoadFinished(Loader<List<PrintServiceInfo>> loader, List<PrintServiceInfo> services) {
    mEnabledPrintServices.clear();
    if (services != null && !services.isEmpty()) {
        final int numServices = services.size();
        for (int i = 0; i < numServices; i++) {
            PrintServiceInfo service = services.get(i);
            mEnabledPrintServices.put(service.getComponentName(), service);
        }
    }
    onPrintServicesUpdate();
}
Also used : PrintServiceInfo(android.printservice.PrintServiceInfo)

Example 20 with PrintServiceInfo

use of android.printservice.PrintServiceInfo in project platform_frameworks_base by android.

the class UserState method getPrintServices.

@Nullable
public List<PrintServiceInfo> getPrintServices(int selectionFlags) {
    synchronized (mLock) {
        List<PrintServiceInfo> selectedServices = 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);
            // Update isEnabled under the same lock the final returned list is created
            installedService.setIsEnabled(mActiveServices.containsKey(componentName));
            if (installedService.isEnabled()) {
                if ((selectionFlags & PrintManager.ENABLED_SERVICES) == 0) {
                    continue;
                }
            } else {
                if ((selectionFlags & PrintManager.DISABLED_SERVICES) == 0) {
                    continue;
                }
            }
            if (selectedServices == null) {
                selectedServices = new ArrayList<>();
            }
            selectedServices.add(installedService);
        }
        return selectedServices;
    }
}
Also used : PrintServiceInfo(android.printservice.PrintServiceInfo) ComponentName(android.content.ComponentName) Nullable(android.annotation.Nullable)

Aggregations

PrintServiceInfo (android.printservice.PrintServiceInfo)32 ComponentName (android.content.ComponentName)18 ResolveInfo (android.content.pm.ResolveInfo)9 DataSetObserver (android.database.DataSetObserver)5 PrintManager (android.print.PrintManager)5 PrinterInfo (android.print.PrinterInfo)5 View (android.view.View)5 OnClickListener (android.view.View.OnClickListener)5 AdapterView (android.widget.AdapterView)5 ImageView (android.widget.ImageView)5 ListView (android.widget.ListView)5 SearchView (android.widget.SearchView)5 TextView (android.widget.TextView)5 Nullable (android.annotation.Nullable)4 HashSet (java.util.HashSet)4 Intent (android.content.Intent)1