Java Code Examples for android.content.res.CompatibilityInfo

The following are top voted examples for showing how to use android.content.res.CompatibilityInfo. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: droidel   File: ActivityThread.java   View source code 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
                    ? !UserHandle.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 2
Project: droidel   File: ActivityThread.java   View source code 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(mResourcesManager.getConfiguration(),
                    mResourcesManager.getDisplayMetricsLocked(Display.DEFAULT_DISPLAY));
            mSystemContext = context;
            //Slog.i(TAG, "Created system resources " + context.getResources()
            //        + ": " + context.getResources().getConfiguration());
        }
    }
    return mSystemContext;
}
 
Example 3
Project: Chameleon   File: ChameleonResourcesManager.java   View source code 5 votes vote down vote up
@Override
public Resources getTopLevelResources(String resDir, String[] splitResDirs, String[] overlayDirs,
                                      String[] libDirs, int displayId,
                                      Configuration overrideConfiguration,
                                      CompatibilityInfo compatInfo, IBinder token) {
    Resources resources = super.getTopLevelResources(resDir, splitResDirs, overlayDirs, libDirs,
            displayId, overrideConfiguration, compatInfo, token);
    return getTopLevelResources(resources);
}
 
Example 4
Project: droidel   File: ActivityThread.java   View source code 5 votes vote down vote up
public final void scheduleLaunchActivity(Intent intent, IBinder token, int ident,
        ActivityInfo info, Configuration curConfig, CompatibilityInfo compatInfo,
        int procState, Bundle state, List<ResultInfo> pendingResults,
        List<Intent> pendingNewIntents, boolean notResumed, boolean isForward,
        String profileName, ParcelFileDescriptor profileFd, boolean autoStopProfiler) {

    updateProcessState(procState, false);

    ActivityClientRecord r = new ActivityClientRecord();

    r.token = token;
    r.ident = ident;
    r.intent = intent;
    r.activityInfo = info;
    r.compatInfo = compatInfo;
    r.state = state;

    r.pendingResults = pendingResults;
    r.pendingIntents = pendingNewIntents;

    r.startsNotResumed = notResumed;
    r.isForward = isForward;

    r.profileFile = profileName;
    r.profileFd = profileFd;
    r.autoStopProfiler = autoStopProfiler;

    updatePendingConfiguration(curConfig);

    sendMessage(H.LAUNCH_ACTIVITY, r);
}
 
Example 5
Project: droidel   File: ActivityThread.java   View source code 5 votes vote down vote up
public final void scheduleReceiver(Intent intent, ActivityInfo info,
        CompatibilityInfo compatInfo, int resultCode, String data, Bundle extras,
        boolean sync, int sendingUser, int processState) {
    updateProcessState(processState, false);
    ReceiverData r = new ReceiverData(intent, resultCode, data, extras,
            sync, false, mAppThread.asBinder(), sendingUser);
    r.info = info;
    r.compatInfo = compatInfo;
    sendMessage(H.RECEIVER, r);
}
 
Example 6
Project: droidel   File: ActivityThread.java   View source code 5 votes vote down vote up
public final void scheduleCreateBackupAgent(ApplicationInfo app,
        CompatibilityInfo compatInfo, int backupMode) {
    CreateBackupAgentData d = new CreateBackupAgentData();
    d.appInfo = app;
    d.compatInfo = compatInfo;
    d.backupMode = backupMode;

    sendMessage(H.CREATE_BACKUP_AGENT, d);
}
 
Example 7
Project: droidel   File: ActivityThread.java   View source code 5 votes vote down vote up
public final void scheduleDestroyBackupAgent(ApplicationInfo app,
        CompatibilityInfo compatInfo) {
    CreateBackupAgentData d = new CreateBackupAgentData();
    d.appInfo = app;
    d.compatInfo = compatInfo;

    sendMessage(H.DESTROY_BACKUP_AGENT, d);
}
 
Example 8
Project: droidel   File: ActivityThread.java   View source code 5 votes vote down vote up
public final void scheduleCreateService(IBinder token,
        ServiceInfo info, CompatibilityInfo compatInfo, int processState) {
    updateProcessState(processState, false);
    CreateServiceData s = new CreateServiceData();
    s.token = token;
    s.info = info;
    s.compatInfo = compatInfo;

    sendMessage(H.CREATE_SERVICE, s);
}
 
Example 9
Project: droidel   File: ActivityThread.java   View source code 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,
        IUiAutomationConnection instrumentationUiConnection, 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.instrumentationUiAutomationConnection = instrumentationUiConnection;
    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;
    sendMessage(H.BIND_APPLICATION, data);
}
 
Example 10
Project: droidel   File: ActivityThread.java   View source code 5 votes vote down vote up
Configuration applyConfigCompatMainThread(int displayDensity, Configuration config,
        CompatibilityInfo compat) {
    if (config == null) {
        return null;
    }
    if (!compat.supportsScreen()) {
        mMainThreadConfig.setTo(config);
        config = mMainThreadConfig;
        compat.applyToConfiguration(displayDensity, config);
    }
    return config;
}
 
Example 11
Project: droidel   File: ActivityThread.java   View source code 5 votes vote down vote up
private LoadedApk getPackageInfo(ApplicationInfo aInfo, CompatibilityInfo compatInfo,
        ClassLoader baseLoader, boolean securityViolation, boolean includeCode) {
    synchronized (mResourcesManager) {
        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 12
Project: droidel   File: ActivityThread.java   View source code 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 13
Project: droidel   File: ActivityThread.java   View source code 4 votes vote down vote up
public void updatePackageCompatibilityInfo(String pkg, CompatibilityInfo info) {
    UpdateCompatibilityData ucd = new UpdateCompatibilityData();
    ucd.pkg = pkg;
    ucd.info = info;
    sendMessage(H.UPDATE_PACKAGE_COMPATIBILITY_INFO, ucd);
}
 
Example 14
Project: droidel   File: ActivityThread.java   View source code 4 votes vote down vote up
public final LoadedApk getPackageInfo(String packageName, CompatibilityInfo compatInfo,
        int flags) {
    return getPackageInfo(packageName, compatInfo, flags, UserHandle.myUserId());
}
 
Example 15
Project: droidel   File: ActivityThread.java   View source code 4 votes vote down vote up
public final LoadedApk getPackageInfo(String packageName, CompatibilityInfo compatInfo,
        int flags, int userId) {
    synchronized (mResourcesManager) {
        WeakReference<LoadedApk> ref;
        if ((flags&Context.CONTEXT_INCLUDE_CODE) != 0) {
            ref = mPackages.get(packageName);
        } else {
            ref = mResourcePackages.get(packageName);
        }
        LoadedApk packageInfo = ref != null ? ref.get() : null;
        //Slog.i(TAG, "getPackageInfo " + packageName + ": " + packageInfo);
        //if (packageInfo != null) Slog.i(TAG, "isUptoDate " + packageInfo.mResDir
        //        + ": " + packageInfo.mResources.getAssets().isUpToDate());
        if (packageInfo != null && (packageInfo.mResources == null
                || packageInfo.mResources.getAssets().isUpToDate())) {
            if (packageInfo.isSecurityViolation()
                    && (flags&Context.CONTEXT_IGNORE_SECURITY) == 0) {
                throw new SecurityException(
                        "Requesting code from " + packageName
                        + " to be run in process "
                        + mBoundApplication.processName
                        + "/" + mBoundApplication.appInfo.uid);
            }
            return packageInfo;
        }
    }

    ApplicationInfo ai = null;
    try {
        ai = getPackageManager().getApplicationInfo(packageName,
                PackageManager.GET_SHARED_LIBRARY_FILES, userId);
    } catch (RemoteException e) {
        // Ignore
    }

    if (ai != null) {
        return getPackageInfo(ai, compatInfo, flags);
    }

    return null;
}
 
Example 16
Project: droidel   File: ActivityThread.java   View source code 4 votes vote down vote up
public final LoadedApk getPackageInfoNoCheck(ApplicationInfo ai,
        CompatibilityInfo compatInfo) {
    return getPackageInfo(ai, compatInfo, null, false, true);
}
 
Example 17
Project: droidel   File: ActivityThread.java   View source code 4 votes vote down vote up
final void handleConfigurationChanged(Configuration config, CompatibilityInfo compat) {

        int configDiff = 0;

        synchronized (mResourcesManager) {
            if (mPendingConfiguration != null) {
                if (!mPendingConfiguration.isOtherSeqNewer(config)) {
                    config = mPendingConfiguration;
                    mCurDefaultDisplayDpi = config.densityDpi;
                    updateDefaultDensity();
                }
                mPendingConfiguration = null;
            }

            if (config == null) {
                return;
            }
            
            if (DEBUG_CONFIGURATION) Slog.v(TAG, "Handle configuration changed: "
                    + config);

            mResourcesManager.applyConfigurationToResourcesLocked(config, compat);

            if (mConfiguration == null) {
                mConfiguration = new Configuration();
            }
            if (!mConfiguration.isOtherSeqNewer(config) && compat == null) {
                return;
            }
            configDiff = mConfiguration.diff(config);
            mConfiguration.updateFrom(config);
            config = applyCompatConfiguration(mCurDefaultDisplayDpi);
        }

        ArrayList<ComponentCallbacks2> callbacks = collectComponentCallbacks(false, config);

        // Cleanup hardware accelerated stuff
        WindowManagerGlobal.getInstance().trimLocalMemory();

        freeTextLayoutCachesIfNeeded(configDiff);

        if (callbacks != null) {
            final int N = callbacks.size();
            for (int i=0; i<N; i++) {
                performConfigurationChanged(callbacks.get(i), config);
            }
        }
    }