Search in sources :

Example 66 with ComponentName

use of android.content.ComponentName in project android_frameworks_base by ParanoidAndroid.

the class SubActivityTest method testRemoteResult.

public void testRemoteResult() throws Exception {
    mIntent.putExtra("component", new ComponentName(getContext(), RemoteSubActivityScreen.class));
    mIntent.putExtra("mode", SubActivityScreen.RESULT_MODE);
    runLaunchpad(LaunchpadActivity.LAUNCH);
}
Also used : ComponentName(android.content.ComponentName)

Example 67 with ComponentName

use of android.content.ComponentName in project android_frameworks_base by ParanoidAndroid.

the class SubActivityTest method testResult.

public void testResult() throws Exception {
    mIntent.putExtra("component", new ComponentName(getContext(), SubActivityScreen.class));
    mIntent.putExtra("mode", SubActivityScreen.RESULT_MODE);
    runLaunchpad(LaunchpadActivity.LAUNCH);
}
Also used : ComponentName(android.content.ComponentName)

Example 68 with ComponentName

use of android.content.ComponentName in project android_frameworks_base by ParanoidAndroid.

the class SubActivityTest method testNoResult.

public void testNoResult() throws Exception {
    mIntent.putExtra("component", new ComponentName(getContext(), SubActivityScreen.class));
    mIntent.putExtra("mode", SubActivityScreen.NO_RESULT_MODE);
    runLaunchpad(LaunchpadActivity.LAUNCH);
}
Also used : ComponentName(android.content.ComponentName)

Example 69 with ComponentName

use of android.content.ComponentName in project android_frameworks_base by ParanoidAndroid.

the class SearchView method createVoiceAppSearchIntent.

/**
     * Create and return an Intent that can launch the voice search activity, perform a specific
     * voice transcription, and forward the results to the searchable activity.
     *
     * @param baseIntent The voice app search intent to start from
     * @return A completely-configured intent ready to send to the voice search activity
     */
private Intent createVoiceAppSearchIntent(Intent baseIntent, SearchableInfo searchable) {
    ComponentName searchActivity = searchable.getSearchActivity();
    // create the necessary intent to set up a search-and-forward operation
    // in the voice search system.   We have to keep the bundle separate,
    // because it becomes immutable once it enters the PendingIntent
    Intent queryIntent = new Intent(Intent.ACTION_SEARCH);
    queryIntent.setComponent(searchActivity);
    PendingIntent pending = PendingIntent.getActivity(getContext(), 0, queryIntent, PendingIntent.FLAG_ONE_SHOT);
    // Now set up the bundle that will be inserted into the pending intent
    // when it's time to do the search.  We always build it here (even if empty)
    // because the voice search activity will always need to insert "QUERY" into
    // it anyway.
    Bundle queryExtras = new Bundle();
    if (mAppSearchData != null) {
        queryExtras.putParcelable(SearchManager.APP_DATA, mAppSearchData);
    }
    // Now build the intent to launch the voice search.  Add all necessary
    // extras to launch the voice recognizer, and then all the necessary extras
    // to forward the results to the searchable activity
    Intent voiceIntent = new Intent(baseIntent);
    // Add all of the configuration options supplied by the searchable's metadata
    String languageModel = RecognizerIntent.LANGUAGE_MODEL_FREE_FORM;
    String prompt = null;
    String language = null;
    int maxResults = 1;
    Resources resources = getResources();
    if (searchable.getVoiceLanguageModeId() != 0) {
        languageModel = resources.getString(searchable.getVoiceLanguageModeId());
    }
    if (searchable.getVoicePromptTextId() != 0) {
        prompt = resources.getString(searchable.getVoicePromptTextId());
    }
    if (searchable.getVoiceLanguageId() != 0) {
        language = resources.getString(searchable.getVoiceLanguageId());
    }
    if (searchable.getVoiceMaxResults() != 0) {
        maxResults = searchable.getVoiceMaxResults();
    }
    voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE_MODEL, languageModel);
    voiceIntent.putExtra(RecognizerIntent.EXTRA_PROMPT, prompt);
    voiceIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, language);
    voiceIntent.putExtra(RecognizerIntent.EXTRA_MAX_RESULTS, maxResults);
    voiceIntent.putExtra(RecognizerIntent.EXTRA_CALLING_PACKAGE, searchActivity == null ? null : searchActivity.flattenToShortString());
    // Add the values that configure forwarding the results
    voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT, pending);
    voiceIntent.putExtra(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE, queryExtras);
    return voiceIntent;
}
Also used : Bundle(android.os.Bundle) ComponentName(android.content.ComponentName) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) RecognizerIntent(android.speech.RecognizerIntent) PendingIntent(android.app.PendingIntent) SuggestionsAdapter.getColumnString(android.widget.SuggestionsAdapter.getColumnString) Resources(android.content.res.Resources)

Example 70 with ComponentName

use of android.content.ComponentName in project android_frameworks_base by ParanoidAndroid.

the class AccessibilityInjectorTest method enableAccessibilityAndMockAccessibilityService.

/**
     * Enable accessibility and the mock accessibility service.
     */
private void enableAccessibilityAndMockAccessibilityService() {
    // make sure the manager is instantiated so the system initializes it
    AccessibilityManager.getInstance(getActivity());
    // enable accessibility and the mock accessibility service
    Settings.Secure.putInt(getActivity().getContentResolver(), Settings.Secure.ACCESSIBILITY_ENABLED, 1);
    String enabledServices = new ComponentName(getActivity().getPackageName(), MockAccessibilityService.class.getName()).flattenToShortString();
    Settings.Secure.putString(getActivity().getContentResolver(), Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES, enabledServices);
    // poll within a timeout and let be interrupted in case of success
    long incrementStep = TIMEOUT_ENABLE_ACCESSIBILITY_AND_MOCK_SERVICE / 5;
    long start = SystemClock.uptimeMillis();
    while (SystemClock.uptimeMillis() - start < TIMEOUT_ENABLE_ACCESSIBILITY_AND_MOCK_SERVICE && !sIsAccessibilityServiceReady) {
        synchronized (sTestLock) {
            try {
                sTestLock.wait(incrementStep);
            } catch (InterruptedException ie) {
            /* ignore */
            }
        }
    }
    if (!sIsAccessibilityServiceReady) {
        throw new IllegalStateException("MockAccessibilityService not ready. Did you add " + "tests and forgot to update AccessibilityInjectorTest#TEST_CASE_COUNT?");
    }
}
Also used : ComponentName(android.content.ComponentName)

Aggregations

ComponentName (android.content.ComponentName)2524 Intent (android.content.Intent)941 ResolveInfo (android.content.pm.ResolveInfo)375 RemoteException (android.os.RemoteException)317 PackageManager (android.content.pm.PackageManager)266 PendingIntent (android.app.PendingIntent)248 ActivityInfo (android.content.pm.ActivityInfo)243 ArrayList (java.util.ArrayList)240 ShortcutInfo (android.content.pm.ShortcutInfo)152 Point (android.graphics.Point)145 Bundle (android.os.Bundle)137 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)130 IBinder (android.os.IBinder)128 IOException (java.io.IOException)124 ServiceConnection (android.content.ServiceConnection)96 ServiceInfo (android.content.pm.ServiceInfo)95 UserHandle (android.os.UserHandle)86 ArraySet (android.util.ArraySet)73 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)69 Uri (android.net.Uri)66