Search in sources :

Example 6 with DisplayAdjustments

use of android.view.DisplayAdjustments in project android_frameworks_base by AOSPA.

the class ResourcesManager method createResourcesImpl.

@Nullable
private ResourcesImpl createResourcesImpl(@NonNull ResourcesKey key) {
    final DisplayAdjustments daj = new DisplayAdjustments(key.mOverrideConfiguration);
    daj.setCompatibilityInfo(key.mCompatInfo);
    final AssetManager assets = createAssetManager(key);
    if (assets == null) {
        return null;
    }
    final DisplayMetrics dm = getDisplayMetrics(key.mDisplayId, daj);
    final Configuration config = generateConfig(key, dm);
    final ResourcesImpl impl = new ResourcesImpl(assets, dm, config, daj);
    if (DEBUG) {
        Slog.d(TAG, "- creating impl=" + impl + " with key: " + key);
    }
    return impl;
}
Also used : AssetManager(android.content.res.AssetManager) Configuration(android.content.res.Configuration) DisplayAdjustments(android.view.DisplayAdjustments) ResourcesImpl(android.content.res.ResourcesImpl) DisplayMetrics(android.util.DisplayMetrics) Nullable(android.annotation.Nullable)

Example 7 with DisplayAdjustments

use of android.view.DisplayAdjustments in project android_frameworks_base by AOSPA.

the class ResourcesManager method getAdjustedDisplay.

/**
     * Returns an adjusted {@link Display} object based on the inputs or null if display isn't
     * available.
     *
     * @param displayId display Id.
     * @param displayAdjustments display adjustments.
     */
public Display getAdjustedDisplay(final int displayId, @Nullable DisplayAdjustments displayAdjustments) {
    final DisplayAdjustments displayAdjustmentsCopy = (displayAdjustments != null) ? new DisplayAdjustments(displayAdjustments) : new DisplayAdjustments();
    final Pair<Integer, DisplayAdjustments> key = Pair.create(displayId, displayAdjustmentsCopy);
    synchronized (this) {
        WeakReference<Display> wd = mDisplays.get(key);
        if (wd != null) {
            final Display display = wd.get();
            if (display != null) {
                return display;
            }
        }
        final DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance();
        if (dm == null) {
            // may be null early in system startup
            return null;
        }
        final Display display = dm.getCompatibleDisplay(displayId, key.second);
        if (display != null) {
            mDisplays.put(key, new WeakReference<>(display));
        }
        return display;
    }
}
Also used : DisplayManagerGlobal(android.hardware.display.DisplayManagerGlobal) DisplayAdjustments(android.view.DisplayAdjustments) Display(android.view.Display)

Example 8 with DisplayAdjustments

use of android.view.DisplayAdjustments in project android_frameworks_base by AOSPA.

the class ResourcesManagerTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    mDisplayMetrics = new DisplayMetrics();
    mDisplayMetrics.setToDefaults();
    // Override defaults (which take device specific properties).
    mDisplayMetrics.density = 1.0f;
    mDisplayMetrics.densityDpi = DisplayMetrics.DENSITY_DEFAULT;
    mDisplayMetrics.xdpi = DisplayMetrics.DENSITY_DEFAULT;
    mDisplayMetrics.ydpi = DisplayMetrics.DENSITY_DEFAULT;
    mDisplayMetrics.noncompatDensity = mDisplayMetrics.density;
    mDisplayMetrics.noncompatDensityDpi = mDisplayMetrics.densityDpi;
    mDisplayMetrics.noncompatXdpi = DisplayMetrics.DENSITY_DEFAULT;
    mDisplayMetrics.noncompatYdpi = DisplayMetrics.DENSITY_DEFAULT;
    mResourcesManager = new ResourcesManager() {

        @Override
        protected AssetManager createAssetManager(@NonNull ResourcesKey key) {
            return new AssetManager();
        }

        @Override
        protected DisplayMetrics getDisplayMetrics(int displayId, DisplayAdjustments daj) {
            return mDisplayMetrics;
        }
    };
}
Also used : ResourcesManager(android.app.ResourcesManager) DisplayAdjustments(android.view.DisplayAdjustments) DisplayMetrics(android.util.DisplayMetrics)

Example 9 with DisplayAdjustments

use of android.view.DisplayAdjustments in project android_frameworks_base by ResurrectionRemix.

the class ResourcesManagerTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    mDisplayMetrics = new DisplayMetrics();
    mDisplayMetrics.setToDefaults();
    // Override defaults (which take device specific properties).
    mDisplayMetrics.density = 1.0f;
    mDisplayMetrics.densityDpi = DisplayMetrics.DENSITY_DEFAULT;
    mDisplayMetrics.xdpi = DisplayMetrics.DENSITY_DEFAULT;
    mDisplayMetrics.ydpi = DisplayMetrics.DENSITY_DEFAULT;
    mDisplayMetrics.noncompatDensity = mDisplayMetrics.density;
    mDisplayMetrics.noncompatDensityDpi = mDisplayMetrics.densityDpi;
    mDisplayMetrics.noncompatXdpi = DisplayMetrics.DENSITY_DEFAULT;
    mDisplayMetrics.noncompatYdpi = DisplayMetrics.DENSITY_DEFAULT;
    mResourcesManager = new ResourcesManager() {

        @Override
        protected AssetManager createAssetManager(@NonNull ResourcesKey key) {
            return new AssetManager();
        }

        @Override
        protected DisplayMetrics getDisplayMetrics(int displayId, DisplayAdjustments daj) {
            return mDisplayMetrics;
        }
    };
}
Also used : ResourcesManager(android.app.ResourcesManager) DisplayAdjustments(android.view.DisplayAdjustments) DisplayMetrics(android.util.DisplayMetrics)

Example 10 with DisplayAdjustments

use of android.view.DisplayAdjustments in project android_frameworks_base by ResurrectionRemix.

the class ResourcesManager method createResourcesImpl.

@Nullable
private ResourcesImpl createResourcesImpl(@NonNull ResourcesKey key) {
    final DisplayAdjustments daj = new DisplayAdjustments(key.mOverrideConfiguration);
    daj.setCompatibilityInfo(key.mCompatInfo);
    final AssetManager assets = createAssetManager(key);
    if (assets == null) {
        return null;
    }
    final DisplayMetrics dm = getDisplayMetrics(key.mDisplayId, daj);
    final Configuration config = generateConfig(key, dm);
    final ResourcesImpl impl = new ResourcesImpl(assets, dm, config, daj);
    if (DEBUG) {
        Slog.d(TAG, "- creating impl=" + impl + " with key: " + key);
    }
    return impl;
}
Also used : AssetManager(android.content.res.AssetManager) Configuration(android.content.res.Configuration) DisplayAdjustments(android.view.DisplayAdjustments) ResourcesImpl(android.content.res.ResourcesImpl) DisplayMetrics(android.util.DisplayMetrics) Nullable(android.annotation.Nullable)

Aggregations

DisplayAdjustments (android.view.DisplayAdjustments)20 DisplayMetrics (android.util.DisplayMetrics)15 Configuration (android.content.res.Configuration)10 ResourcesImpl (android.content.res.ResourcesImpl)10 Nullable (android.annotation.Nullable)5 ResourcesManager (android.app.ResourcesManager)5 AssetManager (android.content.res.AssetManager)5 ResourcesKey (android.content.res.ResourcesKey)5 DisplayManagerGlobal (android.hardware.display.DisplayManagerGlobal)5 Display (android.view.Display)5