use of android.content.ComponentName in project platform_frameworks_base by android.
the class LaunchTest method testClearTopWhileResumed.
@LargeTest
public void testClearTopWhileResumed() throws Exception {
mIntent.putExtra("component", new ComponentName(getContext(), ClearTop.class));
mIntent.putExtra(ClearTop.WAIT_CLEAR_TASK, true);
runLaunchpad(LaunchpadActivity.LAUNCH);
}
use of android.content.ComponentName in project platform_frameworks_base by android.
the class KeyChain method bindAsUser.
/**
* @hide
*/
@WorkerThread
public static KeyChainConnection bindAsUser(@NonNull Context context, UserHandle user) throws InterruptedException {
if (context == null) {
throw new NullPointerException("context == null");
}
ensureNotOnMainThread(context);
final BlockingQueue<IKeyChainService> q = new LinkedBlockingQueue<IKeyChainService>(1);
ServiceConnection keyChainServiceConnection = new ServiceConnection() {
volatile boolean mConnectedAtLeastOnce = false;
@Override
public void onServiceConnected(ComponentName name, IBinder service) {
if (!mConnectedAtLeastOnce) {
mConnectedAtLeastOnce = true;
try {
q.put(IKeyChainService.Stub.asInterface(service));
} catch (InterruptedException e) {
// will never happen, since the queue starts with one available slot
}
}
}
@Override
public void onServiceDisconnected(ComponentName name) {
}
};
Intent intent = new Intent(IKeyChainService.class.getName());
ComponentName comp = intent.resolveSystemService(context.getPackageManager(), 0);
intent.setComponent(comp);
if (comp == null || !context.bindServiceAsUser(intent, keyChainServiceConnection, Context.BIND_AUTO_CREATE, user)) {
throw new AssertionError("could not bind to KeyChainService");
}
return new KeyChainConnection(context, keyChainServiceConnection, q.take());
}
use of android.content.ComponentName in project platform_frameworks_base by android.
the class NekoActivationActivity method onStart.
@Override
public void onStart() {
super.onStart();
final PackageManager pm = getPackageManager();
final ComponentName cn = new ComponentName(this, NekoTile.class);
if (pm.getComponentEnabledSetting(cn) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED) {
if (NekoLand.DEBUG) {
Log.v("Neko", "Disabling tile.");
}
pm.setComponentEnabledSetting(cn, PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);
MetricsLogger.histogram(this, "egg_neko_enable", 0);
toastUp("🚫");
} else {
if (NekoLand.DEBUG) {
Log.v("Neko", "Enabling tile.");
}
pm.setComponentEnabledSetting(cn, PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);
MetricsLogger.histogram(this, "egg_neko_enable", 1);
toastUp("🐱");
}
finish();
}
use of android.content.ComponentName in project platform_frameworks_base by android.
the class SettingsDrawerActivity method isTopLevelTile.
private boolean isTopLevelTile(Intent intent) {
final ComponentName componentName = intent.getComponent();
if (componentName == null) {
return false;
}
// Look for a tile that has the same component as incoming intent
final List<DashboardCategory> categories = getDashboardCategories();
for (DashboardCategory category : categories) {
for (Tile tile : category.tiles) {
if (TextUtils.equals(tile.intent.getComponent().getClassName(), componentName.getClassName())) {
if (DEBUG) {
Log.d(TAG, "intent is for top level tile: " + tile.title);
}
return true;
}
}
}
if (DEBUG) {
Log.d(TAG, "Intent is not for top level settings " + intent);
}
return false;
}
use of android.content.ComponentName in project platform_frameworks_base by android.
the class DreamBackend method getDreamInfos.
public List<DreamInfo> getDreamInfos() {
logd("getDreamInfos()");
ComponentName activeDream = getActiveDream();
PackageManager pm = mContext.getPackageManager();
Intent dreamIntent = new Intent(DreamService.SERVICE_INTERFACE);
List<ResolveInfo> resolveInfos = pm.queryIntentServices(dreamIntent, PackageManager.GET_META_DATA);
List<DreamInfo> dreamInfos = new ArrayList<>(resolveInfos.size());
for (ResolveInfo resolveInfo : resolveInfos) {
if (resolveInfo.serviceInfo == null)
continue;
DreamInfo dreamInfo = new DreamInfo();
dreamInfo.caption = resolveInfo.loadLabel(pm);
dreamInfo.icon = resolveInfo.loadIcon(pm);
dreamInfo.componentName = getDreamComponentName(resolveInfo);
dreamInfo.isActive = dreamInfo.componentName.equals(activeDream);
dreamInfo.settingsComponentName = getSettingsComponentName(pm, resolveInfo);
dreamInfos.add(dreamInfo);
}
Collections.sort(dreamInfos, mComparator);
return dreamInfos;
}
Aggregations