android.content.res.CompatibilityInfo Java Examples

The following examples show how to use android.content.res.CompatibilityInfo. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
public Context createDisplayContext(Display display) {
    if (display == null) {
        throw new IllegalArgumentException("display must not be null");
    }

    int displayId = display.getDisplayId();
    CompatibilityInfo ci = CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;
    CompatibilityInfoHolder cih = getCompatibilityInfo(displayId);
    if (cih != null) {
        ci = cih.get();
    }

    ContextImpl context = new ContextImpl();
    context.init(mPackageInfo, null, mMainThread);
    context.mDisplay = display;
    context.mResources = mMainThread.getTopLevelResources(
            mPackageInfo.getResDir(), displayId, null, ci);
    return context;
}
 
Example #2
Source File: ActivityThread.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
public ContextImpl getSystemContext() {
    synchronized (this) {
        if (mSystemContext == null) {
            ContextImpl context =
                ContextImpl.createSystemContext(this);
            LoadedApk info = new LoadedApk(this, "android", context, null,
                    CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO);
            context.init(info, null, this);
            context.getResources().updateConfiguration(
                    getConfiguration(), getDisplayMetricsLocked(
                            CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, false));
            mSystemContext = context;
            //Slog.i(TAG, "Created system resources " + context.getResources()
            //        + ": " + context.getResources().getConfiguration());
        }
    }
    return mSystemContext;
}
 
Example #3
Source File: ActivityThread.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
public ContextImpl getSystemContext() {
    synchronized (this) {
        if (mSystemContext == null) {
            ContextImpl context =
                ContextImpl.createSystemContext(this);
            LoadedApk info = new LoadedApk(this, "android", context, null,
                    CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO);
            context.init(info, null, this);
            context.getResources().updateConfiguration(
                    getConfiguration(), getDisplayMetricsLocked(
                            CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO, false));
            mSystemContext = context;
            //Slog.i(TAG, "Created system resources " + context.getResources()
            //        + ": " + context.getResources().getConfiguration());
        }
    }
    return mSystemContext;
}
 
Example #4
Source File: LaunchActivityItem.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private static void setValues(LaunchActivityItem instance, Intent intent, int ident,
        ActivityInfo info, Configuration curConfig, Configuration overrideConfig,
        CompatibilityInfo compatInfo, String referrer, IVoiceInteractor voiceInteractor,
        int procState, Bundle state, PersistableBundle persistentState,
        List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents,
        boolean isForward, ProfilerInfo profilerInfo) {
    instance.mIntent = intent;
    instance.mIdent = ident;
    instance.mInfo = info;
    instance.mCurConfig = curConfig;
    instance.mOverrideConfig = overrideConfig;
    instance.mCompatInfo = compatInfo;
    instance.mReferrer = referrer;
    instance.mVoiceInteractor = voiceInteractor;
    instance.mProcState = procState;
    instance.mState = state;
    instance.mPersistentState = persistentState;
    instance.mPendingResults = pendingResults;
    instance.mPendingNewIntents = pendingNewIntents;
    instance.mIsForward = isForward;
    instance.mProfilerInfo = profilerInfo;
}
 
Example #5
Source File: ActivityThread.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
public final LoadedApk getPackageInfo(ApplicationInfo ai, CompatibilityInfo compatInfo,
        int flags) {
    boolean includeCode = (flags&Context.CONTEXT_INCLUDE_CODE) != 0;
    boolean securityViolation = includeCode && ai.uid != 0
            && ai.uid != Process.SYSTEM_UID && (mBoundApplication != null
                    ? !UserId.isSameApp(ai.uid, mBoundApplication.appInfo.uid)
                    : true);
    if ((flags&(Context.CONTEXT_INCLUDE_CODE
            |Context.CONTEXT_IGNORE_SECURITY))
            == Context.CONTEXT_INCLUDE_CODE) {
        if (securityViolation) {
            String msg = "Requesting code from " + ai.packageName
                    + " (with uid " + ai.uid + ")";
            if (mBoundApplication != null) {
                msg = msg + " to be run in process "
                    + mBoundApplication.processName + " (with uid "
                    + mBoundApplication.appInfo.uid + ")";
            }
            throw new SecurityException(msg);
        }
    }
    return getPackageInfo(ai, compatInfo, null, securityViolation, includeCode);
}
 
Example #6
Source File: ContextImpl.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private static Resources createResources(IBinder activityToken, LoadedApk pi, String splitName,
        int displayId, Configuration overrideConfig, CompatibilityInfo compatInfo) {
    final String[] splitResDirs;
    final ClassLoader classLoader;
    try {
        splitResDirs = pi.getSplitPaths(splitName);
        classLoader = pi.getSplitClassLoader(splitName);
    } catch (NameNotFoundException e) {
        throw new RuntimeException(e);
    }
    return ResourcesManager.getInstance().getResources(activityToken,
            pi.getResDir(),
            splitResDirs,
            pi.getOverlayDirs(),
            pi.getApplicationInfo().sharedLibraryFiles,
            displayId,
            overrideConfig,
            compatInfo,
            classLoader);
}
 
Example #7
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
private static Resources createResources(IBinder activityToken, LoadedApk pi, String splitName,
        int displayId, Configuration overrideConfig, CompatibilityInfo compatInfo) {
    final String[] splitResDirs;
    final ClassLoader classLoader;
    try {
        splitResDirs = pi.getSplitPaths(splitName);
        classLoader = pi.getSplitClassLoader(splitName);
    } catch (NameNotFoundException e) {
        throw new RuntimeException(e);
    }
    return ResourcesManager.getInstance().getResources(activityToken,
            pi.getResDir(),
            splitResDirs,
            pi.getOverlayDirs(),
            pi.getApplicationInfo().sharedLibraryFiles,
            displayId,
            overrideConfig,
            compatInfo,
            classLoader);
}
 
Example #8
Source File: ActivityThread.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
public final LoadedApk getPackageInfo(ApplicationInfo ai, CompatibilityInfo compatInfo,
        int flags) {
    boolean includeCode = (flags&Context.CONTEXT_INCLUDE_CODE) != 0;
    boolean securityViolation = includeCode && ai.uid != 0
            && ai.uid != Process.SYSTEM_UID && (mBoundApplication != null
                    ? ai.uid != mBoundApplication.appInfo.uid : true);
    if ((flags&(Context.CONTEXT_INCLUDE_CODE
            |Context.CONTEXT_IGNORE_SECURITY))
            == Context.CONTEXT_INCLUDE_CODE) {
        if (securityViolation) {
            String msg = "Requesting code from " + ai.packageName
                    + " (with uid " + ai.uid + ")";
            if (mBoundApplication != null) {
                msg = msg + " to be run in process "
                    + mBoundApplication.processName + " (with uid "
                    + mBoundApplication.appInfo.uid + ")";
            }
            throw new SecurityException(msg);
        }
    }
    return getPackageInfo(ai, compatInfo, null, securityViolation, includeCode);
}
 
Example #9
Source File: LaunchActivityItem.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/** Obtain an instance initialized with provided params. */
public static LaunchActivityItem obtain(Intent intent, int ident, ActivityInfo info,
        Configuration curConfig, Configuration overrideConfig, CompatibilityInfo compatInfo,
        String referrer, IVoiceInteractor voiceInteractor, int procState, Bundle state,
        PersistableBundle persistentState, List<ResultInfo> pendingResults,
        List<ReferrerIntent> pendingNewIntents, boolean isForward, ProfilerInfo profilerInfo) {
    LaunchActivityItem instance = ObjectPool.obtain(LaunchActivityItem.class);
    if (instance == null) {
        instance = new LaunchActivityItem();
    }
    setValues(instance, intent, ident, info, curConfig, overrideConfig, compatInfo, referrer,
            voiceInteractor, procState, state, persistentState, pendingResults,
            pendingNewIntents, isForward, profilerInfo);

    return instance;
}
 
Example #10
Source File: DisplayInfo.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
private void getMetricsWithSize(DisplayMetrics outMetrics, CompatibilityInfo compatInfo,
        Configuration configuration, int width, int height) {
    outMetrics.densityDpi = outMetrics.noncompatDensityDpi = logicalDensityDpi;
    outMetrics.density = outMetrics.noncompatDensity =
            logicalDensityDpi * DisplayMetrics.DENSITY_DEFAULT_SCALE;
    outMetrics.scaledDensity = outMetrics.noncompatScaledDensity = outMetrics.density;
    outMetrics.xdpi = outMetrics.noncompatXdpi = physicalXDpi;
    outMetrics.ydpi = outMetrics.noncompatYdpi = physicalYDpi;

    final Rect appBounds = configuration != null
            ? configuration.windowConfiguration.getAppBounds() : null;
    width = appBounds != null ? appBounds.width() : width;
    height = appBounds != null ? appBounds.height() : height;

    outMetrics.noncompatWidthPixels  = outMetrics.widthPixels = width;
    outMetrics.noncompatHeightPixels = outMetrics.heightPixels = height;

    if (!compatInfo.equals(CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO)) {
        compatInfo.applyToDisplayMetrics(outMetrics);
    }
}
 
Example #11
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
private static Resources createResources(IBinder activityToken, LoadedApk pi, String splitName,
        int displayId, Configuration overrideConfig, CompatibilityInfo compatInfo) {
    final String[] splitResDirs;
    final ClassLoader classLoader;
    try {
        splitResDirs = pi.getSplitPaths(splitName);
        classLoader = pi.getSplitClassLoader(splitName);
    } catch (NameNotFoundException e) {
        throw new RuntimeException(e);
    }
    return ResourcesManager.getInstance().getResources(activityToken,
            pi.getResDir(),
            splitResDirs,
            pi.getOverlayDirs(),
            pi.getApplicationInfo().sharedLibraryFiles,
            displayId,
            overrideConfig,
            compatInfo,
            classLoader);
}
 
Example #12
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
@Override
public Context createDisplayContext(Display display) {
    if (display == null) {
        throw new IllegalArgumentException("display must not be null");
    }

    int displayId = display.getDisplayId();
    CompatibilityInfo ci = CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;
    CompatibilityInfoHolder cih = getCompatibilityInfo(displayId);
    if (cih != null) {
        ci = cih.get();
    }

    ContextImpl context = new ContextImpl();
    context.init(mPackageInfo, null, mMainThread);
    context.mDisplay = display;
    context.mResources = mMainThread.getTopLevelResources(
            mPackageInfo.getResDir(), displayId, null, ci);
    return context;
}
 
Example #13
Source File: ActivityRecord.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
void showStartingWindow(ActivityRecord prev, boolean newTask, boolean taskSwitch,
        boolean fromRecents) {
    if (mWindowContainerController == null) {
        return;
    }
    if (mTaskOverlay) {
        // We don't show starting window for overlay activities.
        return;
    }

    final CompatibilityInfo compatInfo =
            service.compatibilityInfoForPackageLocked(info.applicationInfo);
    final boolean shown = mWindowContainerController.addStartingWindow(packageName, theme,
            compatInfo, nonLocalizedLabel, labelRes, icon, logo, windowFlags,
            prev != null ? prev.appToken : null, newTask, taskSwitch, isProcessRunning(),
            allowTaskSnapshot(),
            mState.ordinal() >= RESUMED.ordinal() && mState.ordinal() <= STOPPED.ordinal(),
            fromRecents);
    if (shown) {
        mStartingWindowState = STARTING_WINDOW_SHOWN;
    }
}
 
Example #14
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
private static Resources createResources(IBinder activityToken, LoadedApk pi, String splitName,
        int displayId, Configuration overrideConfig, CompatibilityInfo compatInfo) {
    final String[] splitResDirs;
    final ClassLoader classLoader;
    try {
        splitResDirs = pi.getSplitPaths(splitName);
        classLoader = pi.getSplitClassLoader(splitName);
    } catch (NameNotFoundException e) {
        throw new RuntimeException(e);
    }
    return ResourcesManager.getInstance().getResources(activityToken,
            pi.getResDir(),
            splitResDirs,
            pi.getOverlayDirs(),
            pi.getApplicationInfo().sharedLibraryFiles,
            displayId,
            overrideConfig,
            compatInfo,
            classLoader);
}
 
Example #15
Source File: LaunchActivityItem.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
private static void setValues(LaunchActivityItem instance, Intent intent, int ident,
        ActivityInfo info, Configuration curConfig, Configuration overrideConfig,
        CompatibilityInfo compatInfo, String referrer, IVoiceInteractor voiceInteractor,
        int procState, Bundle state, PersistableBundle persistentState,
        List<ResultInfo> pendingResults, List<ReferrerIntent> pendingNewIntents,
        boolean isForward, ProfilerInfo profilerInfo) {
    instance.mIntent = intent;
    instance.mIdent = ident;
    instance.mInfo = info;
    instance.mCurConfig = curConfig;
    instance.mOverrideConfig = overrideConfig;
    instance.mCompatInfo = compatInfo;
    instance.mReferrer = referrer;
    instance.mVoiceInteractor = voiceInteractor;
    instance.mProcState = procState;
    instance.mState = state;
    instance.mPersistentState = persistentState;
    instance.mPendingResults = pendingResults;
    instance.mPendingNewIntents = pendingNewIntents;
    instance.mIsForward = isForward;
    instance.mProfilerInfo = profilerInfo;
}
 
Example #16
Source File: LaunchActivityItem.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
/** Obtain an instance initialized with provided params. */
public static LaunchActivityItem obtain(Intent intent, int ident, ActivityInfo info,
        Configuration curConfig, Configuration overrideConfig, CompatibilityInfo compatInfo,
        String referrer, IVoiceInteractor voiceInteractor, int procState, Bundle state,
        PersistableBundle persistentState, List<ResultInfo> pendingResults,
        List<ReferrerIntent> pendingNewIntents, boolean isForward, ProfilerInfo profilerInfo) {
    LaunchActivityItem instance = ObjectPool.obtain(LaunchActivityItem.class);
    if (instance == null) {
        instance = new LaunchActivityItem();
    }
    setValues(instance, intent, ident, info, curConfig, overrideConfig, compatInfo, referrer,
            voiceInteractor, procState, state, persistentState, pendingResults,
            pendingNewIntents, isForward, profilerInfo);

    return instance;
}
 
Example #17
Source File: CompatModePackages.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
public void handlePackageAddedLocked(String packageName, boolean updated) {
    ApplicationInfo ai = null;
    try {
        ai = AppGlobals.getPackageManager().getApplicationInfo(packageName, 0, 0);
    } catch (RemoteException e) {
    }
    if (ai == null) {
        return;
    }
    CompatibilityInfo ci = compatibilityInfoForPackageLocked(ai);
    final boolean mayCompat = !ci.alwaysSupportsScreen()
            && !ci.neverSupportsScreen();

    if (updated) {
        // Update -- if the app no longer can run in compat mode, clear
        // any current settings for it.
        if (!mayCompat && mPackages.containsKey(packageName)) {
            mPackages.remove(packageName);
            scheduleWrite();
        }
    }
}
 
Example #18
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
private static Resources createResources(IBinder activityToken, LoadedApk pi, String splitName,
        int displayId, Configuration overrideConfig, CompatibilityInfo compatInfo) {
    final String[] splitResDirs;
    final ClassLoader classLoader;
    try {
        splitResDirs = pi.getSplitPaths(splitName);
        classLoader = pi.getSplitClassLoader(splitName);
    } catch (NameNotFoundException e) {
        throw new RuntimeException(e);
    }
    return ResourcesManager.getInstance().getResources(activityToken,
            pi.getResDir(),
            splitResDirs,
            pi.getOverlayDirs(),
            pi.getApplicationInfo().sharedLibraryFiles,
            displayId,
            overrideConfig,
            compatInfo,
            classLoader);
}
 
Example #19
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 6 votes vote down vote up
private static Resources createResources(IBinder activityToken, LoadedApk pi, String splitName,
        int displayId, Configuration overrideConfig, CompatibilityInfo compatInfo) {
    final String[] splitResDirs;
    final ClassLoader classLoader;
    try {
        splitResDirs = pi.getSplitPaths(splitName);
        classLoader = pi.getSplitClassLoader(splitName);
    } catch (NameNotFoundException e) {
        throw new RuntimeException(e);
    }
    return ResourcesManager.getInstance().getResources(activityToken,
            pi.getResDir(),
            splitResDirs,
            pi.getOverlayDirs(),
            pi.getApplicationInfo().sharedLibraryFiles,
            displayId,
            overrideConfig,
            compatInfo,
            classLoader);
}
 
Example #20
Source File: ActivityThread.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
public final void bindApplication(String processName,
        ApplicationInfo appInfo, List<ProviderInfo> providers,
        ComponentName instrumentationName, String profileFile,
        ParcelFileDescriptor profileFd, boolean autoStopProfiler,
        Bundle instrumentationArgs, IInstrumentationWatcher instrumentationWatcher,
        int debugMode, boolean enableOpenGlTrace, boolean isRestrictedBackupMode,
        boolean persistent, Configuration config, CompatibilityInfo compatInfo,
        Map<String, IBinder> services, Bundle coreSettings) {

    if (services != null) {
        // Setup the service cache in the ServiceManager
        ServiceManager.initServiceCache(services);
    }

    setCoreSettings(coreSettings);

    AppBindData data = new AppBindData();
    data.processName = processName;
    data.appInfo = appInfo;
    data.providers = providers;
    data.instrumentationName = instrumentationName;
    data.instrumentationArgs = instrumentationArgs;
    data.instrumentationWatcher = instrumentationWatcher;
    data.debugMode = debugMode;
    data.enableOpenGlTrace = enableOpenGlTrace;
    data.restrictedBackupMode = isRestrictedBackupMode;
    data.persistent = persistent;
    data.config = config;
    data.compatInfo = compatInfo;
    data.initProfileFile = profileFile;
    data.initProfileFd = profileFd;
    data.initAutoStopProfiler = false;
    queueOrSendMessage(H.BIND_APPLICATION, data);
}
 
Example #21
Source File: ActivityThread.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
Configuration applyConfigCompatMainThread(Configuration config, CompatibilityInfo compat) {
    if (config == null) {
        return null;
    }
    if (compat != null && !compat.supportsScreen()) {
        mMainThreadConfig.setTo(config);
        config = mMainThreadConfig;
        compat.applyToConfiguration(config);
    }
    return config;
}
 
Example #22
Source File: LaunchActivityItem.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
/** Read from Parcel. */
private LaunchActivityItem(Parcel in) {
    setValues(this, in.readTypedObject(Intent.CREATOR), in.readInt(),
            in.readTypedObject(ActivityInfo.CREATOR), in.readTypedObject(Configuration.CREATOR),
            in.readTypedObject(Configuration.CREATOR),
            in.readTypedObject(CompatibilityInfo.CREATOR), in.readString(),
            IVoiceInteractor.Stub.asInterface(in.readStrongBinder()), in.readInt(),
            in.readBundle(getClass().getClassLoader()),
            in.readPersistableBundle(getClass().getClassLoader()),
            in.createTypedArrayList(ResultInfo.CREATOR),
            in.createTypedArrayList(ReferrerIntent.CREATOR), in.readBoolean(),
            in.readTypedObject(ProfilerInfo.CREATOR));
}
 
Example #23
Source File: ActivityThread.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
private LoadedApk getPackageInfo(ApplicationInfo aInfo, CompatibilityInfo compatInfo,
        ClassLoader baseLoader, boolean securityViolation, boolean includeCode) {
    synchronized (mPackages) {
        WeakReference<LoadedApk> ref;
        if (includeCode) {
            ref = mPackages.get(aInfo.packageName);
        } else {
            ref = mResourcePackages.get(aInfo.packageName);
        }
        LoadedApk packageInfo = ref != null ? ref.get() : null;
        if (packageInfo == null || (packageInfo.mResources != null
                && !packageInfo.mResources.getAssets().isUpToDate())) {
            if (localLOGV) Slog.v(TAG, (includeCode ? "Loading code package "
                    : "Loading resource-only package ") + aInfo.packageName
                    + " (in " + (mBoundApplication != null
                            ? mBoundApplication.processName : null)
                    + ")");
            packageInfo =
                new LoadedApk(this, aInfo, compatInfo, this, baseLoader,
                        securityViolation, includeCode &&
                        (aInfo.flags&ApplicationInfo.FLAG_HAS_CODE) != 0);
            if (includeCode) {
                mPackages.put(aInfo.packageName,
                        new WeakReference<LoadedApk>(packageInfo));
            } else {
                mResourcePackages.put(aInfo.packageName,
                        new WeakReference<LoadedApk>(packageInfo));
            }
        }
        return packageInfo;
    }
}
 
Example #24
Source File: CompatModePackages.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public int computeCompatModeLocked(ApplicationInfo ai) {
    final boolean enabled = (getPackageFlags(ai.packageName)&COMPAT_FLAG_ENABLED) != 0;
    final Configuration globalConfig = mService.getGlobalConfiguration();
    final CompatibilityInfo info = new CompatibilityInfo(ai, globalConfig.screenLayout,
            globalConfig.smallestScreenWidthDp, enabled);
    if (info.alwaysSupportsScreen()) {
        return ActivityManager.COMPAT_MODE_NEVER;
    }
    if (info.neverSupportsScreen()) {
        return ActivityManager.COMPAT_MODE_ALWAYS;
    }
    return enabled ? ActivityManager.COMPAT_MODE_ENABLED
            : ActivityManager.COMPAT_MODE_DISABLED;
}
 
Example #25
Source File: ActivityThread.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
public void installSystemApplicationInfo(ApplicationInfo info) {
    synchronized (this) {
        ContextImpl context = getSystemContext();
        context.init(new LoadedApk(this, "android", context, info,
                CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO), null, this);

        // give ourselves a default profiler
        mProfiler = new Profiler();
    }
}
 
Example #26
Source File: LoadedApk.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
/**
 * Create information about a new .apk
 *
 * NOTE: This constructor is called with ActivityThread's lock held,
 * so MUST NOT call back out to the activity manager.
 */
public LoadedApk(ActivityThread activityThread, ApplicationInfo aInfo,
        CompatibilityInfo compatInfo, ClassLoader baseLoader,
        boolean securityViolation, boolean includeCode, boolean registerPackage) {

    mActivityThread = activityThread;
    setApplicationInfo(aInfo);
    mPackageName = aInfo.packageName;
    mBaseClassLoader = baseLoader;
    mSecurityViolation = securityViolation;
    mIncludeCode = includeCode;
    mRegisterPackage = registerPackage;
    mDisplayAdjustments.setCompatibilityInfo(compatInfo);
}
 
Example #27
Source File: DisplayAdjustments.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public void setCompatibilityInfo(CompatibilityInfo compatInfo) {
    if (this == DEFAULT_DISPLAY_ADJUSTMENTS) {
        throw new IllegalArgumentException(
                "setCompatbilityInfo: Cannot modify DEFAULT_DISPLAY_ADJUSTMENTS");
    }
    if (compatInfo != null && (compatInfo.isScalingRequired()
            || !compatInfo.supportsScreen())) {
        mCompatInfo = compatInfo;
    } else {
        mCompatInfo = CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;
    }
}
 
Example #28
Source File: DisplayContent.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
private int reduceCompatConfigWidthSize(int curSize, int rotation, int uiMode,
        DisplayMetrics dm, int dw, int dh, int displayId) {
    dm.noncompatWidthPixels = mService.mPolicy.getNonDecorDisplayWidth(dw, dh, rotation, uiMode,
            displayId, mDisplayInfo.displayCutout);
    dm.noncompatHeightPixels = mService.mPolicy.getNonDecorDisplayHeight(dw, dh, rotation,
            uiMode, displayId, mDisplayInfo.displayCutout);
    float scale = CompatibilityInfo.computeCompatibleScaling(dm, null);
    int size = (int)(((dm.noncompatWidthPixels / scale) / dm.density) + .5f);
    if (curSize == 0 || size < curSize) {
        curSize = size;
    }
    return curSize;
}
 
Example #29
Source File: SplashScreenStartingData.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
SplashScreenStartingData(WindowManagerService service, String pkg, int theme,
        CompatibilityInfo compatInfo, CharSequence nonLocalizedLabel, int labelRes, int icon,
        int logo, int windowFlags, Configuration mergedOverrideConfiguration) {
    super(service);
    mPkg = pkg;
    mTheme = theme;
    mCompatInfo = compatInfo;
    mNonLocalizedLabel = nonLocalizedLabel;
    mLabelRes = labelRes;
    mIcon = icon;
    mLogo = logo;
    mWindowFlags = windowFlags;
    mMergedOverrideConfiguration = mergedOverrideConfiguration;
}
 
Example #30
Source File: CompatModePackages.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public CompatibilityInfo compatibilityInfoForPackageLocked(ApplicationInfo ai) {
    final Configuration globalConfig = mService.getGlobalConfiguration();
    CompatibilityInfo ci = new CompatibilityInfo(ai, globalConfig.screenLayout,
            globalConfig.smallestScreenWidthDp,
            (getPackageFlags(ai.packageName)&COMPAT_FLAG_ENABLED) != 0);
    //Slog.i(TAG, "*********** COMPAT FOR PKG " + ai.packageName + ": " + ci);
    return ci;
}