Search in sources :

Example 46 with ComponentName

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);
}
Also used : ComponentName(android.content.ComponentName) LargeTest(android.test.suitebuilder.annotation.LargeTest)

Example 47 with ComponentName

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());
}
Also used : ServiceConnection(android.content.ServiceConnection) IBinder(android.os.IBinder) ComponentName(android.content.ComponentName) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) LinkedBlockingQueue(java.util.concurrent.LinkedBlockingQueue) WorkerThread(android.annotation.WorkerThread)

Example 48 with ComponentName

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

Example 49 with ComponentName

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

Example 50 with ComponentName

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;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) ArrayList(java.util.ArrayList) ComponentName(android.content.ComponentName) Intent(android.content.Intent)

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