Java Code Examples for android.view.Display#DEFAULT_DISPLAY

The following examples show how to use android.view.Display#DEFAULT_DISPLAY . 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 createApplicationContext(ApplicationInfo application, int flags)
        throws NameNotFoundException {
    LoadedApk pi = mMainThread.getPackageInfo(application, mResources.getCompatibilityInfo(),
            flags | CONTEXT_REGISTER_PACKAGE);
    if (pi != null) {
        ContextImpl c = new ContextImpl(this, mMainThread, pi, null, mActivityToken,
                new UserHandle(UserHandle.getUserId(application.uid)), flags, null);

        final int displayId = mDisplay != null
                ? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;

        c.setResources(createResources(mActivityToken, pi, null, displayId, null,
                getDisplayAdjustments(displayId).getCompatibilityInfo()));
        if (c.mResources != null) {
            return c;
        }
    }

    throw new PackageManager.NameNotFoundException(
            "Application package " + application.packageName + " not found");
}
 
Example 2
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public Context createPackageContextAsUser(String packageName, int flags, UserHandle user)
        throws NameNotFoundException {
    if (packageName.equals("system") || packageName.equals("android")) {
        // The system resources are loaded in every application, so we can safely copy
        // the context without reloading Resources.
        return new ContextImpl(this, mMainThread, mPackageInfo, null, mActivityToken, user,
                flags, null);
    }

    LoadedApk pi = mMainThread.getPackageInfo(packageName, mResources.getCompatibilityInfo(),
            flags | CONTEXT_REGISTER_PACKAGE, user.getIdentifier());
    if (pi != null) {
        ContextImpl c = new ContextImpl(this, mMainThread, pi, null, mActivityToken, user,
                flags, null);

        final int displayId = mDisplay != null
                ? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;

        c.setResources(createResources(mActivityToken, pi, null, displayId, null,
                getDisplayAdjustments(displayId).getCompatibilityInfo()));
        if (c.mResources != null) {
            return c;
        }
    }

    // Should be a better exception.
    throw new PackageManager.NameNotFoundException(
            "Application package " + packageName + " not found");
}
 
Example 3
Source File: ContextImpl.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public Context createConfigurationContext(Configuration overrideConfiguration) {
    if (overrideConfiguration == null) {
        throw new IllegalArgumentException("overrideConfiguration must not be null");
    }

    ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, mSplitName,
            mActivityToken, mUser, mFlags, mClassLoader);

    final int displayId = mDisplay != null ? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;
    context.setResources(createResources(mActivityToken, mPackageInfo, mSplitName, displayId,
            overrideConfiguration, getDisplayAdjustments(displayId).getCompatibilityInfo()));
    return context;
}
 
Example 4
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public Context createConfigurationContext(Configuration overrideConfiguration) {
    if (overrideConfiguration == null) {
        throw new IllegalArgumentException("overrideConfiguration must not be null");
    }

    ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, mSplitName,
            mActivityToken, mUser, mFlags, mClassLoader);

    final int displayId = mDisplay != null ? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;
    context.setResources(createResources(mActivityToken, mPackageInfo, mSplitName, displayId,
            overrideConfiguration, getDisplayAdjustments(displayId).getCompatibilityInfo()));
    return context;
}
 
Example 5
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 5 votes vote down vote up
@Override
public Context createContextForSplit(String splitName) throws NameNotFoundException {
    if (!mPackageInfo.getApplicationInfo().requestsIsolatedSplitLoading()) {
        // All Splits are always loaded.
        return this;
    }

    final ClassLoader classLoader = mPackageInfo.getSplitClassLoader(splitName);
    final String[] paths = mPackageInfo.getSplitPaths(splitName);

    final ContextImpl context = new ContextImpl(this, mMainThread, mPackageInfo, splitName,
            mActivityToken, mUser, mFlags, classLoader);

    final int displayId = mDisplay != null
            ? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;

    context.setResources(ResourcesManager.getInstance().getResources(
            mActivityToken,
            mPackageInfo.getResDir(),
            paths,
            mPackageInfo.getOverlayDirs(),
            mPackageInfo.getApplicationInfo().sharedLibraryFiles,
            displayId,
            null,
            mPackageInfo.getCompatibilityInfo(),
            classLoader));
    return context;
}
 
Example 6
Source File: NotificationService.java    From SecondScreen with Apache License 2.0 5 votes vote down vote up
@Override
public void onDisplayRemoved(int displayId) {
    DisplayManager dm = (DisplayManager) getSystemService(DISPLAY_SERVICE);
    Display[] displays = dm.getDisplays();

    try {
        if(displays[displays.length - 1].getDisplayId() == Display.DEFAULT_DISPLAY) {
            Intent serviceIntent = new Intent(NotificationService.this, TempBacklightOnService.class);
            U.startService(NotificationService.this, serviceIntent);

            SharedPreferences prefMain = U.getPrefMain(NotificationService.this);
            ActivityManager manager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
            boolean displayConnectionServiceRunning = false;

            for(ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
                if(DisplayConnectionService.class.getName().equals(service.service.getClassName()))
                    displayConnectionServiceRunning = true;
            }

            if(prefMain.getBoolean("inactive", true) && !displayConnectionServiceRunning) {
                Intent turnOffIntent = new Intent(NotificationService.this, TurnOffActivity.class);
                turnOffIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(turnOffIntent);
            }
        }
    } catch (ArrayIndexOutOfBoundsException e) { /* Gracefully fail */ }
}
 
Example 7
Source File: U.java    From SecondScreen with Apache License 2.0 5 votes vote down vote up
public static boolean isDesktopModeActive(Context context) {
    boolean desktopModePrefEnabled;

    try {
        desktopModePrefEnabled = Settings.Global.getInt(context.getContentResolver(), "force_desktop_mode_on_external_displays") == 1;
    } catch (Settings.SettingNotFoundException e) {
        desktopModePrefEnabled = false;
    }

    return desktopModePrefEnabled && getExternalDisplayID(context) != Display.DEFAULT_DISPLAY;
}
 
Example 8
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
private ContextImpl(ContextImpl container, ActivityThread mainThread,
        LoadedApk packageInfo, IBinder activityToken, UserHandle user, boolean restricted,
        Display display, Configuration overrideConfiguration, int createDisplayWithId) {
    mOuterContext = this;

    mMainThread = mainThread;
    mActivityToken = activityToken;
    mRestricted = restricted;

    if (user == null) {
        user = Process.myUserHandle();
    }
    mUser = user;

    mPackageInfo = packageInfo;
    mResourcesManager = ResourcesManager.getInstance();

    final int displayId = (createDisplayWithId != Display.INVALID_DISPLAY)
            ? createDisplayWithId
            : (display != null) ? display.getDisplayId() : Display.DEFAULT_DISPLAY;

    CompatibilityInfo compatInfo = null;
    if (container != null) {
        compatInfo = container.getDisplayAdjustments(displayId).getCompatibilityInfo();
    }
    if (compatInfo == null) {
        compatInfo = (displayId == Display.DEFAULT_DISPLAY)
                ? packageInfo.getCompatibilityInfo()
                : CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;
    }
    mDisplayAdjustments.setCompatibilityInfo(compatInfo);
    mDisplayAdjustments.setConfiguration(overrideConfiguration);

    mDisplay = (createDisplayWithId == Display.INVALID_DISPLAY) ? display
            : ResourcesManager.getInstance().getAdjustedDisplay(displayId, mDisplayAdjustments);

    Resources resources = packageInfo.getResources(mainThread);
    if (resources != null) {
        if (displayId != Display.DEFAULT_DISPLAY
                || overrideConfiguration != null
                || (compatInfo != null && compatInfo.applicationScale
                        != resources.getCompatibilityInfo().applicationScale)) {
            resources = mResourcesManager.getTopLevelResources(packageInfo.getResDir(),
                    packageInfo.getSplitResDirs(), packageInfo.getOverlayDirs(),
                    packageInfo.getApplicationInfo().sharedLibraryFiles, displayId,
                    overrideConfiguration, compatInfo);
        }
    }
    mResources = resources;

    if (container != null) {
        mBasePackageName = container.mBasePackageName;
        mOpPackageName = container.mOpPackageName;
    } else {
        mBasePackageName = packageInfo.mPackageName;
        ApplicationInfo ainfo = packageInfo.getApplicationInfo();
        if (ainfo.uid == Process.SYSTEM_UID && ainfo.uid != Process.myUid()) {
            // Special case: system components allow themselves to be loaded in to other
            // processes.  For purposes of app ops, we must then consider the context as
            // belonging to the package of this process, not the system itself, otherwise
            // the package+uid verifications in app ops will fail.
            mOpPackageName = ActivityThread.currentPackageName();
        } else {
            mOpPackageName = mBasePackageName;
        }
    }

    mContentResolver = new ApplicationContentResolver(this, mainThread, user);
}
 
Example 9
Source File: MiracastWidgetProvider.java    From miracast-widget with Apache License 2.0 4 votes vote down vote up
@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
       final int length = appWidgetIds.length;

       for (int i = 0; i < length; i++) {
           int appWidgetId = appWidgetIds[i];

           Intent intent = new Intent(context, MainActivity.class);
           intent.putExtra(MainActivity.EXTRA_WIDGET_LAUNCH, true);
           PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
                                                   intent, PendingIntent.FLAG_UPDATE_CURRENT);

           final RemoteViews views = new RemoteViews(context.getPackageName(), R.layout.miracast_widget);
           views.setOnClickPendingIntent(R.id.widget_layout_parent, pendingIntent);
           final DisplayManager displayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);

           Display[] displays = displayManager.getDisplays();
           boolean displaySet = false;
           int currentDisplay = -1;
           for(int j = 0; j < displays.length; j++){
           	Display display = displays[j];
           	if(display.getDisplayId() != Display.DEFAULT_DISPLAY){
                   views.setTextViewText(R.id.widget_text, display.getName());
                   views.setTextColor(R.id.widget_text, context.getResources().getColor(android.R.color.holo_blue_bright));
                   currentDisplay = display.getDisplayId();
                   displaySet = true;

                   // Track this
                   MiracastApplication application
                           = (MiracastApplication) context.getApplicationContext();
                   Tracker tracker = application.getDefaultTracker();
                   sendEventDisplayFound(tracker);
           	}
           }
           
           if(!displaySet){
               views.setTextViewText(R.id.widget_text, "Cast Screen");
               views.setTextColor(R.id.widget_text, context.getResources().getColor(android.R.color.white));
           }

           MiracastDisplayListener displayListener = new MiracastDisplayListener(currentDisplay, views, displayManager, appWidgetManager, appWidgetId, context);
           displayManager.registerDisplayListener(displayListener, null);

           // Tell the AppWidgetManager to perform an update on the current app widget
           appWidgetManager.updateAppWidget(appWidgetId, views);
       }
   }
 
Example 10
Source File: NonRootUtils.java    From SecondScreen with Apache License 2.0 4 votes vote down vote up
private static int getDisplayID(String[] commandArgs) {
    if(commandArgs.length < 5 || !commandArgs[commandArgs.length - 2].equals("-d"))
        return Display.DEFAULT_DISPLAY;

    return Integer.parseInt(commandArgs[commandArgs.length - 1]);
}
 
Example 11
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
private int getDisplayId() {
    return mDisplay != null ? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;
}
 
Example 12
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
static ContextImpl createActivityContext(ActivityThread mainThread,
        LoadedApk packageInfo, ActivityInfo activityInfo, IBinder activityToken, int displayId,
        Configuration overrideConfiguration) {
    if (packageInfo == null) throw new IllegalArgumentException("packageInfo");

    String[] splitDirs = packageInfo.getSplitResDirs();
    ClassLoader classLoader = packageInfo.getClassLoader();

    if (packageInfo.getApplicationInfo().requestsIsolatedSplitLoading()) {
        Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, "SplitDependencies");
        try {
            classLoader = packageInfo.getSplitClassLoader(activityInfo.splitName);
            splitDirs = packageInfo.getSplitPaths(activityInfo.splitName);
        } catch (NameNotFoundException e) {
            // Nothing above us can handle a NameNotFoundException, better crash.
            throw new RuntimeException(e);
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_RESOURCES);
        }
    }

    ContextImpl context = new ContextImpl(null, mainThread, packageInfo, activityInfo.splitName,
            activityToken, null, 0, classLoader);

    // Clamp display ID to DEFAULT_DISPLAY if it is INVALID_DISPLAY.
    displayId = (displayId != Display.INVALID_DISPLAY) ? displayId : Display.DEFAULT_DISPLAY;

    final CompatibilityInfo compatInfo = (displayId == Display.DEFAULT_DISPLAY)
            ? packageInfo.getCompatibilityInfo()
            : CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;

    final ResourcesManager resourcesManager = ResourcesManager.getInstance();

    // Create the base resources for which all configuration contexts for this Activity
    // will be rebased upon.
    context.setResources(resourcesManager.createBaseActivityResources(activityToken,
            packageInfo.getResDir(),
            splitDirs,
            packageInfo.getOverlayDirs(),
            packageInfo.getApplicationInfo().sharedLibraryFiles,
            displayId,
            overrideConfiguration,
            compatInfo,
            classLoader));
    context.mDisplay = resourcesManager.getAdjustedDisplay(displayId,
            context.getResources());
    return context;
}
 
Example 13
Source File: DisplayManagerService.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private void handleLogicalDisplayChanged(int displayId, @NonNull LogicalDisplay display) {
    if (displayId == Display.DEFAULT_DISPLAY) {
        recordTopInsetLocked(display);
    }
    sendDisplayEventLocked(displayId, DisplayManagerGlobal.EVENT_DISPLAY_CHANGED);
}
 
Example 14
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
private int getDisplayId() {
    return mDisplay != null ? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;
}
 
Example 15
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
@UnsupportedAppUsage
static ContextImpl createActivityContext(ActivityThread mainThread,
        LoadedApk packageInfo, ActivityInfo activityInfo, IBinder activityToken, int displayId,
        Configuration overrideConfiguration) {
    if (packageInfo == null) throw new IllegalArgumentException("packageInfo");

    String[] splitDirs = packageInfo.getSplitResDirs();
    ClassLoader classLoader = packageInfo.getClassLoader();

    if (packageInfo.getApplicationInfo().requestsIsolatedSplitLoading()) {
        Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, "SplitDependencies");
        try {
            classLoader = packageInfo.getSplitClassLoader(activityInfo.splitName);
            splitDirs = packageInfo.getSplitPaths(activityInfo.splitName);
        } catch (NameNotFoundException e) {
            // Nothing above us can handle a NameNotFoundException, better crash.
            throw new RuntimeException(e);
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_RESOURCES);
        }
    }

    ContextImpl context = new ContextImpl(null, mainThread, packageInfo, activityInfo.splitName,
            activityToken, null, 0, classLoader, null);

    // Clamp display ID to DEFAULT_DISPLAY if it is INVALID_DISPLAY.
    displayId = (displayId != Display.INVALID_DISPLAY) ? displayId : Display.DEFAULT_DISPLAY;

    final CompatibilityInfo compatInfo = (displayId == Display.DEFAULT_DISPLAY)
            ? packageInfo.getCompatibilityInfo()
            : CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;

    final ResourcesManager resourcesManager = ResourcesManager.getInstance();

    // Create the base resources for which all configuration contexts for this Activity
    // will be rebased upon.
    context.setResources(resourcesManager.createBaseActivityResources(activityToken,
            packageInfo.getResDir(),
            splitDirs,
            packageInfo.getOverlayDirs(),
            packageInfo.getApplicationInfo().sharedLibraryFiles,
            displayId,
            overrideConfiguration,
            compatInfo,
            classLoader));
    context.mDisplay = resourcesManager.getAdjustedDisplay(displayId,
            context.getResources());
    return context;
}
 
Example 16
Source File: DisplayPowerController.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
private void initialize() {
    // Initialize the power state object for the default display.
    // In the future, we might manage multiple displays independently.
    mPowerState = new DisplayPowerState(mBlanker,
            mColorFadeEnabled ? new ColorFade(Display.DEFAULT_DISPLAY) : null);

    if (mColorFadeEnabled) {
        mColorFadeOnAnimator = ObjectAnimator.ofFloat(
                mPowerState, DisplayPowerState.COLOR_FADE_LEVEL, 0.0f, 1.0f);
        mColorFadeOnAnimator.setDuration(COLOR_FADE_ON_ANIMATION_DURATION_MILLIS);
        mColorFadeOnAnimator.addListener(mAnimatorListener);

        mColorFadeOffAnimator = ObjectAnimator.ofFloat(
                mPowerState, DisplayPowerState.COLOR_FADE_LEVEL, 1.0f, 0.0f);
        mColorFadeOffAnimator.setDuration(COLOR_FADE_OFF_ANIMATION_DURATION_MILLIS);
        mColorFadeOffAnimator.addListener(mAnimatorListener);
    }

    mScreenBrightnessRampAnimator = new RampAnimator<DisplayPowerState>(
            mPowerState, DisplayPowerState.SCREEN_BRIGHTNESS);
    mScreenBrightnessRampAnimator.setListener(mRampAnimatorListener);

    // Initialize screen state for battery stats.
    try {
        mBatteryStats.noteScreenState(mPowerState.getScreenState());
        mBatteryStats.noteScreenBrightness(mPowerState.getScreenBrightness());
    } catch (RemoteException ex) {
        // same process
    }

    // Initialize all of the brightness tracking state
    final float brightness = convertToNits(mPowerState.getScreenBrightness());
    if (brightness >= 0.0f) {
        mBrightnessTracker.start(brightness);
    }

    mContext.getContentResolver().registerContentObserver(
            Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS),
            false /*notifyForDescendants*/, mSettingsObserver, UserHandle.USER_ALL);
    mContext.getContentResolver().registerContentObserver(
            Settings.System.getUriFor(Settings.System.SCREEN_BRIGHTNESS_FOR_VR),
            false /*notifyForDescendants*/, mSettingsObserver, UserHandle.USER_ALL);
    mContext.getContentResolver().registerContentObserver(
            Settings.System.getUriFor(Settings.System.SCREEN_AUTO_BRIGHTNESS_ADJ),
            false /*notifyForDescendants*/, mSettingsObserver, UserHandle.USER_ALL);
}
 
Example 17
Source File: InputConsumerImpl.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
InputConsumerImpl(WindowManagerService service, IBinder token, String name,
        InputChannel inputChannel, int clientPid, UserHandle clientUser) {
    mService = service;
    mToken = token;
    mName = name;
    mClientPid = clientPid;
    mClientUser = clientUser;

    InputChannel[] channels = InputChannel.openInputChannelPair(name);
    mServerChannel = channels[0];
    if (inputChannel != null) {
        channels[1].transferTo(inputChannel);
        channels[1].dispose();
        mClientChannel = inputChannel;
    } else {
        mClientChannel = channels[1];
    }
    mService.mInputManager.registerInputChannel(mServerChannel, null);

    mApplicationHandle = new InputApplicationHandle(null);
    mApplicationHandle.name = name;
    mApplicationHandle.dispatchingTimeoutNanos =
            WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;

    mWindowHandle = new InputWindowHandle(mApplicationHandle, null, null,
            Display.DEFAULT_DISPLAY);
    mWindowHandle.name = name;
    mWindowHandle.inputChannel = mServerChannel;
    mWindowHandle.layoutParamsType = WindowManager.LayoutParams.TYPE_INPUT_CONSUMER;
    mWindowHandle.layer = getLayerLw(mWindowHandle.layoutParamsType);
    mWindowHandle.layoutParamsFlags = 0;
    mWindowHandle.dispatchingTimeoutNanos =
            WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
    mWindowHandle.visible = true;
    mWindowHandle.canReceiveKeys = false;
    mWindowHandle.hasFocus = false;
    mWindowHandle.hasWallpaper = false;
    mWindowHandle.paused = false;
    mWindowHandle.ownerPid = Process.myPid();
    mWindowHandle.ownerUid = Process.myUid();
    mWindowHandle.inputFeatures = 0;
    mWindowHandle.scaleFactor = 1.0f;
}
 
Example 18
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
static ContextImpl createActivityContext(ActivityThread mainThread,
        LoadedApk packageInfo, ActivityInfo activityInfo, IBinder activityToken, int displayId,
        Configuration overrideConfiguration) {
    if (packageInfo == null) throw new IllegalArgumentException("packageInfo");

    String[] splitDirs = packageInfo.getSplitResDirs();
    ClassLoader classLoader = packageInfo.getClassLoader();

    if (packageInfo.getApplicationInfo().requestsIsolatedSplitLoading()) {
        Trace.traceBegin(Trace.TRACE_TAG_RESOURCES, "SplitDependencies");
        try {
            classLoader = packageInfo.getSplitClassLoader(activityInfo.splitName);
            splitDirs = packageInfo.getSplitPaths(activityInfo.splitName);
        } catch (NameNotFoundException e) {
            // Nothing above us can handle a NameNotFoundException, better crash.
            throw new RuntimeException(e);
        } finally {
            Trace.traceEnd(Trace.TRACE_TAG_RESOURCES);
        }
    }

    ContextImpl context = new ContextImpl(null, mainThread, packageInfo, activityInfo.splitName,
            activityToken, null, 0, classLoader);

    // Clamp display ID to DEFAULT_DISPLAY if it is INVALID_DISPLAY.
    displayId = (displayId != Display.INVALID_DISPLAY) ? displayId : Display.DEFAULT_DISPLAY;

    final CompatibilityInfo compatInfo = (displayId == Display.DEFAULT_DISPLAY)
            ? packageInfo.getCompatibilityInfo()
            : CompatibilityInfo.DEFAULT_COMPATIBILITY_INFO;

    final ResourcesManager resourcesManager = ResourcesManager.getInstance();

    // Create the base resources for which all configuration contexts for this Activity
    // will be rebased upon.
    context.setResources(resourcesManager.createBaseActivityResources(activityToken,
            packageInfo.getResDir(),
            splitDirs,
            packageInfo.getOverlayDirs(),
            packageInfo.getApplicationInfo().sharedLibraryFiles,
            displayId,
            overrideConfiguration,
            compatInfo,
            classLoader));
    context.mDisplay = resourcesManager.getAdjustedDisplay(displayId,
            context.getResources());
    return context;
}
 
Example 19
Source File: U.java    From Taskbar with Apache License 2.0 4 votes vote down vote up
public static boolean isDesktopModeActive(Context context) {
    return isDesktopModePrefEnabled(context) && getExternalDisplayID(context) != Display.DEFAULT_DISPLAY;
}
 
Example 20
Source File: ContextImpl.java    From AndroidComponentPlugin with Apache License 2.0 4 votes vote down vote up
private int getDisplayId() {
    return mDisplay != null ? mDisplay.getDisplayId() : Display.DEFAULT_DISPLAY;
}