Search in sources :

Example 46 with Configuration

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

the class AppWindowToken method freezeBounds.

/**
     * Freezes the task bounds. The size of this task reported the app will be fixed to the bounds
     * freezed by {@link Task#prepareFreezingBounds} until {@link #unfreezeBounds} gets called, even
     * if they change in the meantime. If the bounds are already frozen, the bounds will be frozen
     * with a queue.
     */
private void freezeBounds() {
    mFrozenBounds.offer(new Rect(mTask.mPreparedFrozenBounds));
    if (mTask.mPreparedFrozenMergedConfig.equals(Configuration.EMPTY)) {
        // We didn't call prepareFreezingBounds on the task, so use the current value.
        final Configuration config = new Configuration(service.mCurConfiguration);
        config.updateFrom(mTask.mOverrideConfig);
        mFrozenMergedConfig.offer(config);
    } else {
        mFrozenMergedConfig.offer(new Configuration(mTask.mPreparedFrozenMergedConfig));
    }
    mTask.mPreparedFrozenMergedConfig.setToDefaults();
}
Also used : Rect(android.graphics.Rect) Configuration(android.content.res.Configuration)

Example 47 with Configuration

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

the class NavigationBarInflaterView method createInflaters.

private void createInflaters() {
    mLayoutInflater = LayoutInflater.from(mContext);
    Configuration landscape = new Configuration();
    landscape.setTo(mContext.getResources().getConfiguration());
    landscape.orientation = Configuration.ORIENTATION_LANDSCAPE;
    mLandscapeInflater = LayoutInflater.from(mContext.createConfigurationContext(landscape));
}
Also used : Configuration(android.content.res.Configuration)

Example 48 with Configuration

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

the class ToggleFontSizePreferenceFragment method createConfig.

@Override
protected Configuration createConfig(Configuration origConfig, int index) {
    // Populate the sample layouts.
    final Configuration config = new Configuration(origConfig);
    config.fontScale = mValues[index];
    return config;
}
Also used : Configuration(android.content.res.Configuration)

Example 49 with Configuration

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

the class ActivityThread method performConfigurationChanged.

/**
     * Decides whether to update an Activity's configuration and whether to tell the
     * Activity/Component about it.
     * @param cb The component callback to notify of configuration change.
     * @param activityToken The Activity binder token for which this configuration change happened.
     *                      If the change is global, this is null.
     * @param newConfig The new configuration.
     * @param amOverrideConfig The override config that differentiates the Activity's configuration
     *                       from the base global configuration.
     *                       This is supplied by ActivityManager.
     * @param reportToActivity Notify the Activity of the change.
     */
private void performConfigurationChanged(ComponentCallbacks2 cb, IBinder activityToken, Configuration newConfig, Configuration amOverrideConfig, boolean reportToActivity) {
    // Only for Activity objects, check that they actually call up to their
    // superclass implementation.  ComponentCallbacks2 is an interface, so
    // we check the runtime type and act accordingly.
    Activity activity = (cb instanceof Activity) ? (Activity) cb : null;
    if (activity != null) {
        activity.mCalled = false;
    }
    boolean shouldChangeConfig = false;
    if ((activity == null) || (activity.mCurrentConfig == null)) {
        shouldChangeConfig = true;
    } else {
        // If the new config is the same as the config this Activity is already
        // running with and the override config also didn't change, then don't
        // bother calling onConfigurationChanged.
        int diff = activity.mCurrentConfig.diff(newConfig);
        if (diff != 0 || !mResourcesManager.isSameResourcesOverrideConfig(activityToken, amOverrideConfig)) {
            // calling onConfigurationChanged as we're going to destroy it.
            if (!mUpdatingSystemConfig || (~activity.mActivityInfo.getRealConfigChanged() & diff) == 0 || !reportToActivity) {
                shouldChangeConfig = true;
            }
        }
    }
    if (shouldChangeConfig) {
        // Propagate the configuration change to the Activity and ResourcesManager.
        // ContextThemeWrappers may override the configuration for that context.
        // We must check and apply any overrides defined.
        Configuration contextThemeWrapperOverrideConfig = null;
        if (cb instanceof ContextThemeWrapper) {
            final ContextThemeWrapper contextThemeWrapper = (ContextThemeWrapper) cb;
            contextThemeWrapperOverrideConfig = contextThemeWrapper.getOverrideConfiguration();
        }
        // in {@link ComponentCallbacks2#onConfigurationChanged(Configuration)}.
        if (activityToken != null) {
            // Apply the ContextThemeWrapper override if necessary.
            // NOTE: Make sure the configurations are not modified, as they are treated
            // as immutable in many places.
            final Configuration finalOverrideConfig = createNewConfigAndUpdateIfNotNull(amOverrideConfig, contextThemeWrapperOverrideConfig);
            mResourcesManager.updateResourcesForActivity(activityToken, finalOverrideConfig);
        }
        if (reportToActivity) {
            // Apply the ContextThemeWrapper override if necessary.
            // NOTE: Make sure the configurations are not modified, as they are treated
            // as immutable in many places.
            final Configuration configToReport = createNewConfigAndUpdateIfNotNull(newConfig, contextThemeWrapperOverrideConfig);
            cb.onConfigurationChanged(configToReport);
        }
        if (activity != null) {
            if (reportToActivity && !activity.mCalled) {
                throw new SuperNotCalledException("Activity " + activity.getLocalClassName() + " did not call through to super.onConfigurationChanged()");
            }
            activity.mConfigChangeFlags = 0;
            activity.mCurrentConfig = new Configuration(newConfig);
        }
    }
}
Also used : Configuration(android.content.res.Configuration) ContextThemeWrapper(android.view.ContextThemeWrapper) SuperNotCalledException(android.util.SuperNotCalledException)

Example 50 with Configuration

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

the class ActivityThread method performLaunchActivity.

private Activity performLaunchActivity(ActivityClientRecord r, Intent customIntent) {
    // System.out.println("##### [" + System.currentTimeMillis() + "] ActivityThread.performLaunchActivity(" + r + ")");
    ActivityInfo aInfo = r.activityInfo;
    if (r.packageInfo == null) {
        r.packageInfo = getPackageInfo(aInfo.applicationInfo, r.compatInfo, Context.CONTEXT_INCLUDE_CODE);
    }
    ComponentName component = r.intent.getComponent();
    if (component == null) {
        component = r.intent.resolveActivity(mInitialApplication.getPackageManager());
        r.intent.setComponent(component);
    }
    if (r.activityInfo.targetActivity != null) {
        component = new ComponentName(r.activityInfo.packageName, r.activityInfo.targetActivity);
    }
    Activity activity = null;
    try {
        java.lang.ClassLoader cl = r.packageInfo.getClassLoader();
        activity = mInstrumentation.newActivity(cl, component.getClassName(), r.intent);
        StrictMode.incrementExpectedActivityCount(activity.getClass());
        r.intent.setExtrasClassLoader(cl);
        r.intent.prepareToEnterProcess();
        if (r.state != null) {
            r.state.setClassLoader(cl);
        }
    } catch (Exception e) {
        if (!mInstrumentation.onException(activity, e)) {
            throw new RuntimeException("Unable to instantiate activity " + component + ": " + e.toString(), e);
        }
    }
    try {
        Application app = r.packageInfo.makeApplication(false, mInstrumentation);
        if (localLOGV)
            Slog.v(TAG, "Performing launch of " + r);
        if (localLOGV)
            Slog.v(TAG, r + ": app=" + app + ", appName=" + app.getPackageName() + ", pkg=" + r.packageInfo.getPackageName() + ", comp=" + r.intent.getComponent().toShortString() + ", dir=" + r.packageInfo.getAppDir());
        if (activity != null) {
            Context appContext = createBaseContextForActivity(r, activity);
            CharSequence title = r.activityInfo.loadLabel(appContext.getPackageManager());
            Configuration config = new Configuration(mCompatConfiguration);
            if (r.overrideConfig != null) {
                config.updateFrom(r.overrideConfig);
            }
            if (DEBUG_CONFIGURATION)
                Slog.v(TAG, "Launching activity " + r.activityInfo.name + " with config " + config);
            Window window = null;
            if (r.mPendingRemoveWindow != null && r.mPreserveWindow) {
                window = r.mPendingRemoveWindow;
                r.mPendingRemoveWindow = null;
                r.mPendingRemoveWindowManager = null;
            }
            activity.attach(appContext, this, getInstrumentation(), r.token, r.ident, app, r.intent, r.activityInfo, title, r.parent, r.embeddedID, r.lastNonConfigurationInstances, config, r.referrer, r.voiceInteractor, window);
            if (customIntent != null) {
                activity.mIntent = customIntent;
            }
            r.lastNonConfigurationInstances = null;
            activity.mStartedActivity = false;
            int theme = r.activityInfo.getThemeResource();
            if (theme != 0) {
                activity.setTheme(theme);
            }
            activity.mCalled = false;
            if (r.isPersistable()) {
                mInstrumentation.callActivityOnCreate(activity, r.state, r.persistentState);
            } else {
                mInstrumentation.callActivityOnCreate(activity, r.state);
            }
            if (!activity.mCalled) {
                throw new SuperNotCalledException("Activity " + r.intent.getComponent().toShortString() + " did not call through to super.onCreate()");
            }
            r.activity = activity;
            r.stopped = true;
            if (!r.activity.mFinished) {
                activity.performStart();
                r.stopped = false;
            }
            if (!r.activity.mFinished) {
                if (r.isPersistable()) {
                    if (r.state != null || r.persistentState != null) {
                        mInstrumentation.callActivityOnRestoreInstanceState(activity, r.state, r.persistentState);
                    }
                } else if (r.state != null) {
                    mInstrumentation.callActivityOnRestoreInstanceState(activity, r.state);
                }
            }
            if (!r.activity.mFinished) {
                activity.mCalled = false;
                if (r.isPersistable()) {
                    mInstrumentation.callActivityOnPostCreate(activity, r.state, r.persistentState);
                } else {
                    mInstrumentation.callActivityOnPostCreate(activity, r.state);
                }
                if (!activity.mCalled) {
                    throw new SuperNotCalledException("Activity " + r.intent.getComponent().toShortString() + " did not call through to super.onPostCreate()");
                }
            }
        }
        r.paused = true;
        mActivities.put(r.token, r);
    } catch (SuperNotCalledException e) {
        throw e;
    } catch (Exception e) {
        if (!mInstrumentation.onException(activity, e)) {
            throw new RuntimeException("Unable to start activity " + component + ": " + e.toString(), e);
        }
    }
    return activity;
}
Also used : Context(android.content.Context) Window(android.view.Window) ActivityInfo(android.content.pm.ActivityInfo) Configuration(android.content.res.Configuration) RemoteException(android.os.RemoteException) IOException(java.io.IOException) ErrnoException(android.system.ErrnoException) AndroidRuntimeException(android.util.AndroidRuntimeException) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) SuperNotCalledException(android.util.SuperNotCalledException) TransactionTooLargeException(android.os.TransactionTooLargeException) AndroidRuntimeException(android.util.AndroidRuntimeException) ComponentName(android.content.ComponentName) SuperNotCalledException(android.util.SuperNotCalledException)

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