Search in sources :

Example 91 with Configuration

use of android.content.res.Configuration in project android_frameworks_base by DirtyUnicorns.

the class BasePrintTest method tearDown.

@Override
public void tearDown() throws Exception {
    if (!supportsPrinting()) {
        return;
    }
    // Done with the activity.
    getActivity().finish();
    enableImes();
    // Restore the locale if needed.
    if (mOldLocale != null) {
        Resources resources = getInstrumentation().getTargetContext().getResources();
        DisplayMetrics displayMetrics = resources.getDisplayMetrics();
        Configuration newConfiguration = new Configuration(resources.getConfiguration());
        newConfiguration.setLocales(mOldLocale);
        mOldLocale = null;
        resources.updateConfiguration(newConfiguration, displayMetrics);
    }
    // Make sure the spooler is cleaned, this also un-approves all services
    clearPrintSpoolerData();
    super.tearDown();
}
Also used : Configuration(android.content.res.Configuration) Resources(android.content.res.Resources) DisplayMetrics(android.util.DisplayMetrics)

Example 92 with Configuration

use of android.content.res.Configuration in project android_frameworks_base by DirtyUnicorns.

the class Am method runGetConfig.

private void runGetConfig() throws Exception {
    int days = 14;
    String option = nextOption();
    if (option != null) {
        if (!option.equals("--days")) {
            throw new IllegalArgumentException("unrecognized option " + option);
        }
        days = Integer.parseInt(nextArgRequired());
        if (days <= 0) {
            throw new IllegalArgumentException("--days must be a positive integer");
        }
    }
    try {
        Configuration config = mAm.getConfiguration();
        if (config == null) {
            System.err.println("Activity manager has no configuration");
            return;
        }
        System.out.println("config: " + Configuration.resourceQualifierString(config));
        System.out.println("abi: " + TextUtils.join(",", Build.SUPPORTED_ABIS));
        final List<Configuration> recentConfigs = getRecentConfigurations(days);
        final int recentConfigSize = recentConfigs.size();
        if (recentConfigSize > 0) {
            System.out.println("recentConfigs:");
        }
        for (int i = 0; i < recentConfigSize; i++) {
            System.out.println("  config: " + Configuration.resourceQualifierString(recentConfigs.get(i)));
        }
    } catch (RemoteException e) {
    }
}
Also used : Configuration(android.content.res.Configuration) RemoteException(android.os.RemoteException)

Example 93 with Configuration

use of android.content.res.Configuration in project android_frameworks_base by DirtyUnicorns.

the class Am method runSupportsMultiwindow.

private void runSupportsMultiwindow() throws Exception {
    // system resources does not contain all the device configuration, construct it manually.
    Configuration config = mAm.getConfiguration();
    if (config == null) {
        throw new AndroidException("Activity manager has no configuration");
    }
    final DisplayMetrics metrics = new DisplayMetrics();
    metrics.setToDefaults();
    Resources res = new Resources(AssetManager.getSystem(), metrics, config);
    System.out.println(res.getBoolean(com.android.internal.R.bool.config_supportsMultiWindow));
}
Also used : AndroidException(android.util.AndroidException) Configuration(android.content.res.Configuration) Resources(android.content.res.Resources) DisplayMetrics(android.util.DisplayMetrics)

Example 94 with Configuration

use of android.content.res.Configuration in project android_frameworks_base by DirtyUnicorns.

the class ActionBarPolicy method hasEmbeddedTabs.

public boolean hasEmbeddedTabs() {
    final int targetSdk = mContext.getApplicationInfo().targetSdkVersion;
    if (targetSdk >= Build.VERSION_CODES.JELLY_BEAN) {
        return mContext.getResources().getBoolean(R.bool.action_bar_embed_tabs);
    }
    // The embedded tabs policy changed in Jellybean; give older apps the old policy
    // so they get what they expect.
    final Configuration configuration = mContext.getResources().getConfiguration();
    final int width = configuration.screenWidthDp;
    final int height = configuration.screenHeightDp;
    return configuration.orientation == Configuration.ORIENTATION_LANDSCAPE || width >= 480 || (width >= 640 && height >= 480);
}
Also used : Configuration(android.content.res.Configuration)

Example 95 with Configuration

use of android.content.res.Configuration in project android_frameworks_base by DirtyUnicorns.

the class InputMethodUtilsTest method createTargetContextWithLocales.

private Context createTargetContextWithLocales(final LocaleList locales) {
    final Configuration resourceConfiguration = new Configuration();
    resourceConfiguration.setLocales(locales);
    return getInstrumentation().getTargetContext().createConfigurationContext(resourceConfiguration);
}
Also used : Configuration(android.content.res.Configuration)

Aggregations

Configuration (android.content.res.Configuration)824 RemoteException (android.os.RemoteException)158 Resources (android.content.res.Resources)152 Locale (java.util.Locale)112 DisplayMetrics (android.util.DisplayMetrics)88 Intent (android.content.Intent)76 IOException (java.io.IOException)69 Context (android.content.Context)64 Point (android.graphics.Point)48 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)40 Rect (android.graphics.Rect)37 ArrayList (java.util.ArrayList)37 Test (org.junit.Test)29 AndroidRuntimeException (android.util.AndroidRuntimeException)28 View (android.view.View)27 ComponentName (android.content.ComponentName)25 Bundle (android.os.Bundle)25 IBinder (android.os.IBinder)24 WindowManager (android.view.WindowManager)24 Nullable (android.annotation.Nullable)22