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);
}
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();
}
}
}
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;
}
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) {
}
}
}
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;
}
Aggregations