Search in sources :

Example 81 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class DpmTestBase method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    mRealTestContext = super.getContext();
    mMockContext = new DpmMockContext(mRealTestContext, new File(mRealTestContext.getCacheDir(), "test-data"));
    admin1 = new ComponentName(mRealTestContext, DummyDeviceAdmins.Admin1.class);
    admin2 = new ComponentName(mRealTestContext, DummyDeviceAdmins.Admin2.class);
    admin3 = new ComponentName(mRealTestContext, DummyDeviceAdmins.Admin3.class);
    adminNoPerm = new ComponentName(mRealTestContext, DummyDeviceAdmins.AdminNoPerm.class);
}
Also used : ComponentName(android.content.ComponentName) File(java.io.File)

Example 82 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

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();
        }
    }
}
Also used : PrintServiceInfo(android.printservice.PrintServiceInfo) ComponentName(android.content.ComponentName)

Example 83 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class PrintSpoolerService method setPrintJobState.

public boolean setPrintJobState(PrintJobId printJobId, int state, String error) {
    boolean success = false;
    synchronized (mLock) {
        PrintJobInfo printJob = getPrintJobInfo(printJobId, PrintManager.APP_ID_ANY);
        if (printJob != null) {
            final int oldState = printJob.getState();
            if (oldState == state) {
                return false;
            }
            success = true;
            printJob.setState(state);
            printJob.setStatus(error);
            printJob.setCancelling(false);
            if (DEBUG_PRINT_JOB_LIFECYCLE) {
                Slog.i(LOG_TAG, "[STATE CHANGED] " + printJob);
            }
            MetricsLogger.histogram(this, "print_job_state", state);
            switch(state) {
                case PrintJobInfo.STATE_COMPLETED:
                case PrintJobInfo.STATE_CANCELED:
                    mPrintJobs.remove(printJob);
                    removePrintJobFileLocked(printJob.getId());
                case PrintJobInfo.STATE_FAILED:
                    {
                        PrinterId printerId = printJob.getPrinterId();
                        if (printerId != null) {
                            ComponentName service = printerId.getServiceName();
                            if (!hasActivePrintJobsForServiceLocked(service)) {
                                sendOnAllPrintJobsForServiceHandled(service);
                            }
                        }
                    }
                    break;
                case PrintJobInfo.STATE_QUEUED:
                    {
                        sendOnPrintJobQueued(new PrintJobInfo(printJob));
                    }
                    break;
            }
            if (shouldPersistPrintJob(printJob)) {
                mPersistanceManager.writeStateLocked();
            }
            if (!hasActivePrintJobsLocked()) {
                notifyOnAllPrintJobsHandled();
            }
            notifyPrintJobUpdated(printJob);
        }
    }
    return success;
}
Also used : PrintJobInfo(android.print.PrintJobInfo) ComponentName(android.content.ComponentName) PrinterId(android.print.PrinterId)

Example 84 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class TileServices method updateStatusIcon.

@Override
public void updateStatusIcon(IBinder token, Icon icon, String contentDescription) {
    CustomTile customTile = getTileForToken(token);
    if (customTile != null) {
        verifyCaller(customTile);
        try {
            ComponentName componentName = customTile.getComponent();
            String packageName = componentName.getPackageName();
            UserHandle userHandle = getCallingUserHandle();
            PackageInfo info = mContext.getPackageManager().getPackageInfoAsUser(packageName, 0, userHandle.getIdentifier());
            if (info.applicationInfo.isSystemApp()) {
                final StatusBarIcon statusIcon = icon != null ? new StatusBarIcon(userHandle, packageName, icon, 0, 0, contentDescription) : null;
                mMainHandler.post(new Runnable() {

                    @Override
                    public void run() {
                        StatusBarIconController iconController = mHost.getIconController();
                        iconController.setIcon(componentName.getClassName(), statusIcon);
                        iconController.setExternalIcon(componentName.getClassName());
                    }
                });
            }
        } catch (PackageManager.NameNotFoundException e) {
        }
    }
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo) UserHandle(android.os.UserHandle) ComponentName(android.content.ComponentName) StatusBarIcon(com.android.internal.statusbar.StatusBarIcon) StatusBarIconController(com.android.systemui.statusbar.phone.StatusBarIconController)

Example 85 with ComponentName

use of android.content.ComponentName in project platform_frameworks_base by android.

the class SystemServicesProxy method getHomeActivityPackageName.

/** Returns the package name of the home activity. */
public String getHomeActivityPackageName() {
    if (mPm == null)
        return null;
    if (RecentsDebugFlags.Static.EnableMockTasks)
        return null;
    ArrayList<ResolveInfo> homeActivities = new ArrayList<>();
    ComponentName defaultHomeActivity = mPm.getHomeActivities(homeActivities);
    if (defaultHomeActivity != null) {
        return defaultHomeActivity.getPackageName();
    } else if (homeActivities.size() == 1) {
        ResolveInfo info = homeActivities.get(0);
        if (info.activityInfo != null) {
            return info.activityInfo.packageName;
        }
    }
    return null;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName)

Aggregations

ComponentName (android.content.ComponentName)2548 Intent (android.content.Intent)959 ResolveInfo (android.content.pm.ResolveInfo)375 RemoteException (android.os.RemoteException)317 PackageManager (android.content.pm.PackageManager)269 PendingIntent (android.app.PendingIntent)252 ActivityInfo (android.content.pm.ActivityInfo)243 ArrayList (java.util.ArrayList)242 ShortcutInfo (android.content.pm.ShortcutInfo)152 Point (android.graphics.Point)145 Bundle (android.os.Bundle)139 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)132 IBinder (android.os.IBinder)128 IOException (java.io.IOException)125 ServiceConnection (android.content.ServiceConnection)96 ServiceInfo (android.content.pm.ServiceInfo)96 UserHandle (android.os.UserHandle)86 ArraySet (android.util.ArraySet)73 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)69 Uri (android.net.Uri)68