Search in sources :

Example 66 with Configuration

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

the class LocalePicker method updateLocales.

/**
     * Requests the system to update the list of system locales.
     * Note that the system looks halted for a while during the Locale migration,
     * so the caller need to take care of it.
     */
public static void updateLocales(LocaleList locales) {
    try {
        final IActivityManager am = ActivityManagerNative.getDefault();
        final Configuration config = am.getConfiguration();
        config.setLocales(locales);
        config.userSetLocale = true;
        am.updatePersistentConfiguration(config);
        // Trigger the dirty bit for the Settings Provider.
        BackupManager.dataChanged("com.android.providers.settings");
    } catch (RemoteException e) {
    // Intentionally left blank
    }
}
Also used : Configuration(android.content.res.Configuration) RemoteException(android.os.RemoteException) IActivityManager(android.app.IActivityManager)

Example 67 with Configuration

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

the class ActivityManagerTest method testGetDeviceConfigurationInfo.

@SmallTest
public void testGetDeviceConfigurationInfo() throws Exception {
    ConfigurationInfo config = mActivityManager.getDeviceConfigurationInfo();
    assertNotNull(config);
    // Validate values against configuration retrieved from resources
    Configuration vconfig = mContext.getResources().getConfiguration();
    assertNotNull(vconfig);
    assertEquals(config.reqKeyboardType, vconfig.keyboard);
    assertEquals(config.reqTouchScreen, vconfig.touchscreen);
    assertEquals(config.reqNavigation, vconfig.navigation);
    if (vconfig.navigation == Configuration.NAVIGATION_NONAV) {
        assertNotNull(config.reqInputFeatures & ConfigurationInfo.INPUT_FEATURE_FIVE_WAY_NAV);
    }
    if (vconfig.keyboard != Configuration.KEYBOARD_UNDEFINED) {
        assertNotNull(config.reqInputFeatures & ConfigurationInfo.INPUT_FEATURE_HARD_KEYBOARD);
    }
}
Also used : Configuration(android.content.res.Configuration) ConfigurationInfo(android.content.pm.ConfigurationInfo) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Example 68 with Configuration

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

the class RecentsActivity method onCreate.

/** Called with the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mFinishedOnStartup = false;
    // In the case that the activity starts up before the Recents component has initialized
    // (usually when debugging/pushing the SysUI apk), just finish this activity.
    SystemServicesProxy ssp = Recents.getSystemServices();
    if (ssp == null) {
        mFinishedOnStartup = true;
        finish();
        return;
    }
    // Register this activity with the event bus
    EventBus.getDefault().register(this, EVENT_BUS_PRIORITY);
    // Initialize the package monitor
    mPackageMonitor = new RecentsPackageMonitor();
    mPackageMonitor.register(this);
    // Set the Recents layout
    setContentView(R.layout.recents);
    takeKeyEvents(true);
    mRecentsView = (RecentsView) findViewById(R.id.recents_view);
    mRecentsView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION);
    mScrimViews = new SystemBarScrimViews(this);
    getWindow().getAttributes().privateFlags |= WindowManager.LayoutParams.PRIVATE_FLAG_FORCE_DECOR_VIEW_VISIBILITY;
    Configuration appConfiguration = Utilities.getAppConfiguration(this);
    mLastDeviceOrientation = appConfiguration.orientation;
    mLastDisplayDensity = appConfiguration.densityDpi;
    mFocusTimerDuration = getResources().getInteger(R.integer.recents_auto_advance_duration);
    mIterateTrigger = new DozeTrigger(mFocusTimerDuration, new Runnable() {

        @Override
        public void run() {
            dismissRecentsToFocusedTask(MetricsEvent.OVERVIEW_SELECT_TIMEOUT);
        }
    });
    // Set the window background
    getWindow().setBackgroundDrawable(mRecentsView.getBackgroundScrim());
    // Create the home intent runnable
    mHomeIntent = new Intent(Intent.ACTION_MAIN, null);
    mHomeIntent.addCategory(Intent.CATEGORY_HOME);
    mHomeIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
    // Register the broadcast receiver to handle messages when the screen is turned off
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    filter.addAction(Intent.ACTION_TIME_CHANGED);
    registerReceiver(mSystemBroadcastReceiver, filter);
    getWindow().addPrivateFlags(LayoutParams.PRIVATE_FLAG_NO_MOVE_ANIMATION);
    // Reload the stack view
    reloadStackView();
    try {
        RecentsView mRecentsView = (RecentsView) getObjectField(this, "mRecentsView");
        mRecentsActivityRootView = (FrameLayout) mRecentsView.getParent();
        Bitmap lastBlurredBitmap = BlurTask.getLastBlurredBitmap();
        if ((mBlurredRecentAppsEnabled) && (lastBlurredBitmap != null)) {
            BitmapDrawable blurredDrawable = new BitmapDrawable(lastBlurredBitmap);
            blurredDrawable.setColorFilter(mColorFilter);
            mRecentsActivityRootView.setBackground(blurredDrawable);
        }
    } catch (Exception e) {
    }
}
Also used : SystemServicesProxy(com.android.systemui.recents.misc.SystemServicesProxy) IntentFilter(android.content.IntentFilter) SystemBarScrimViews(com.android.systemui.recents.views.SystemBarScrimViews) Configuration(android.content.res.Configuration) DozeTrigger(com.android.systemui.recents.misc.DozeTrigger) RecentsPackageMonitor(com.android.systemui.recents.model.RecentsPackageMonitor) RecentsView(com.android.systemui.recents.views.RecentsView) Intent(android.content.Intent) BitmapDrawable(android.graphics.drawable.BitmapDrawable)

Example 69 with Configuration

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

the class ActionBarPolicy method getMaxActionButtons.

/**
     * Returns the maximum number of action buttons that should be permitted within an action
     * bar/action mode. This will be used to determine how many showAsAction="ifRoom" items can fit.
     * "always" items can override this.
     */
public int getMaxActionButtons() {
    final Configuration config = mContext.getResources().getConfiguration();
    final int width = config.screenWidthDp;
    final int height = config.screenHeightDp;
    final int smallest = config.smallestScreenWidthDp;
    if (smallest > 600 || (width > 960 && height > 720) || (width > 720 && height > 960)) {
        // For values-w600dp, values-sw600dp and values-xlarge.
        return 5;
    } else if (width >= 500 || (width > 640 && height > 480) || (width > 480 && height > 640)) {
        // For values-w500dp and values-large.
        return 4;
    } else if (width >= 360) {
        // For values-w360dp.
        return 3;
    } else {
        return 2;
    }
}
Also used : Configuration(android.content.res.Configuration)

Example 70 with Configuration

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

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)

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