android.view.Display#getDisplayId ( )源码实例Demo

下面列出了android.view.Display#getDisplayId ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public void onRoutePresentationDisplayChanged(Object routeObj) {
    int index = findSystemRouteRecord(routeObj);
    if (index >= 0) {
        SystemRouteRecord record = mSystemRouteRecords.get(index);
        Display newPresentationDisplay =
                MediaRouterJellybeanMr1.RouteInfo.getPresentationDisplay(routeObj);
        int newPresentationDisplayId = (newPresentationDisplay != null
                ? newPresentationDisplay.getDisplayId() : -1);
        if (newPresentationDisplayId
                != record.mRouteDescriptor.getPresentationDisplayId()) {
            record.mRouteDescriptor =
                    new MediaRouteDescriptor.Builder(record.mRouteDescriptor)
                    .setPresentationDisplayId(newPresentationDisplayId)
                    .build();
            publishRoutes();
        }
    }
}
 
源代码2 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public Context createDisplayContext(Display display) {
    if (display == null) {
        throw new IllegalArgumentException("display must not be null");
    }

    int displayId = display.getDisplayId();

    ContextImpl context = new ContextImpl();
    context.init(mPackageInfo, null, mMainThread);
    context.mDisplay = display;
    DisplayAdjustments daj = getDisplayAdjustments(displayId);
    context.mResources = mResourcesManager.getTopLevelResources(mPackageInfo.getResDir(),
            displayId, null, daj.getCompatibilityInfo(), null);
    return context;
}
 
源代码3 项目: libvlc-sdk-android   文件: DisplayManager.java
private SecondaryDisplay createPresentation() {
    if (mMediaRouter == null) return null;
    final MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO);
    final Display presentationDisplay = route != null ? route.getPresentationDisplay() : null;
    if (presentationDisplay != null) {
        if (BuildConfig.DEBUG)
            Log.i(TAG, "Showing presentation on display: " + presentationDisplay);
        final SecondaryDisplay presentation = new SecondaryDisplay(mActivity, presentationDisplay);
        presentation.setOnDismissListener(mOnDismissListener);
        try {
            presentation.show();
            mPresentationId = presentationDisplay.getDisplayId();
            return presentation;
        } catch (WindowManager.InvalidDisplayException ex) {
            if (BuildConfig.DEBUG)
                Log.w(TAG, "Couldn't show presentation!  Display was removed in " + "the meantime.", ex);
            mPresentationId = -1;
        }
    } else if (BuildConfig.DEBUG) Log.i(TAG, "No secondary display detected");
    return null;
}
 
源代码4 项目: 365browser   文件: DisplayAndroidManager.java
private void initialize() {
    mIdMap = new SparseArray<>();
    Display display;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
        mBackend = new DisplayListenerBackendImpl();
        // Make sure the display map contains the built-in primary display.
        // The primary display is never removed.
        display = getDisplayManager().getDisplay(Display.DEFAULT_DISPLAY);

        // Android documentation on Display.DEFAULT_DISPLAY suggests that the above
        // method might return null. In that case we retrieve the default display
        // from the application context and take it as the primary display.
        if (display == null) display = getDefaultDisplayForContext(getContext());
    } else {
        mBackend = new DisplayListenerAPI16();
        display = getDefaultDisplayForContext(getContext());
    }

    mMainSdkDisplayId = display.getDisplayId();
    addDisplay(display); // Note this display is never removed.

    mBackend.startListening();
}
 
源代码5 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public Context createDisplayContext(Display display) {
    if (display == null) {
        throw new IllegalArgumentException("display must not be null");
    }

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

    final int displayId = display.getDisplayId();
    context.setResources(createResources(mActivityToken, mPackageInfo, mSplitName, displayId,
            null, getDisplayAdjustments(displayId).getCompatibilityInfo()));
    context.mDisplay = display;
    return context;
}
 
源代码6 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public Context createDisplayContext(Display display) {
    if (display == null) {
        throw new IllegalArgumentException("display must not be null");
    }

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

    final int displayId = display.getDisplayId();
    context.setResources(createResources(mActivityToken, mPackageInfo, mSplitName, displayId,
            null, getDisplayAdjustments(displayId).getCompatibilityInfo()));
    context.mDisplay = display;
    return context;
}
 
@Override
public Display getDisplay(int displayId) {
    Display display = mWindowManager.getDefaultDisplay();
    if (display.getDisplayId() == displayId) {
        return display;
    }
    return null;
}
 
源代码8 项目: AndroidComponentPlugin   文件: ContextImpl.java
@Override
public Context createDisplayContext(Display display) {
    if (display == null) {
        throw new IllegalArgumentException("display must not be null");
    }

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

    final int displayId = display.getDisplayId();
    context.setResources(createResources(mActivityToken, mPackageInfo, mSplitName, displayId,
            null, getDisplayAdjustments(displayId).getCompatibilityInfo()));
    context.mDisplay = display;
    return context;
}
 
源代码9 项目: CodenameOne   文件: DisplayManagerCompat.java
@Override
public Display getDisplay(int displayId) {
    Display display = mWindowManager.getDefaultDisplay();
    if (display.getDisplayId() == displayId) {
        return display;
    }
    return null;
}
 
@Override
public Display getDisplay(int displayId) {
    Display display = mWindowManager.getDefaultDisplay();
    if (display.getDisplayId() == displayId) {
        return display;
    }
    return null;
}
 
源代码11 项目: 365browser   文件: DisplayAndroidManager.java
DisplayAndroid getDisplayAndroid(Display display) {
    int sdkDisplayId = display.getDisplayId();
    DisplayAndroid displayAndroid = mIdMap.get(sdkDisplayId);
    if (displayAndroid == null) {
        displayAndroid = addDisplay(display);
    }
    return displayAndroid;
}
 
源代码12 项目: V.FlyoutTest   文件: DisplayManagerCompat.java
@Override
public Display getDisplay(int displayId) {
    Display display = mWindowManager.getDefaultDisplay();
    if (display.getDisplayId() == displayId) {
        return display;
    }
    return null;
}
 
源代码13 项目: guideshow   文件: DisplayManagerCompat.java
@Override
public Display getDisplay(int displayId) {
    Display display = mWindowManager.getDefaultDisplay();
    if (display.getDisplayId() == displayId) {
        return display;
    }
    return null;
}
 
源代码14 项目: MiBandDecompiled   文件: b.java
public Display getDisplay(int i)
{
    Display display = a.getDefaultDisplay();
    if (display.getDisplayId() == i)
    {
        return display;
    } else
    {
        return null;
    }
}
 
源代码15 项目: android_9.0.0_r45   文件: ContextImpl.java
@Override
public Context createDisplayContext(Display display) {
    if (display == null) {
        throw new IllegalArgumentException("display must not be null");
    }

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

    final int displayId = display.getDisplayId();
    context.setResources(createResources(mActivityToken, mPackageInfo, mSplitName, displayId,
            null, getDisplayAdjustments(displayId).getCompatibilityInfo()));
    context.mDisplay = display;
    return context;
}
 
源代码16 项目: VCL-Android   文件: VideoPlayerActivity.java
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void createPresentation() {
    if (mMediaRouter == null || mEnableCloneMode)
        return;

    // Get the current route and its presentation display.
    MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute(
        MediaRouter.ROUTE_TYPE_LIVE_VIDEO);

    Display presentationDisplay = route != null ? route.getPresentationDisplay() : null;

    if (presentationDisplay != null) {
        // Show a new presentation if possible.
        Log.i(TAG, "Showing presentation on display: " + presentationDisplay);
        mPresentation = new SecondaryDisplay(this, LibVLC(), presentationDisplay);
        mPresentation.setOnDismissListener(mOnDismissListener);
        try {
            mPresentation.show();
            mPresentationDisplayId = presentationDisplay.getDisplayId();
        } catch (WindowManager.InvalidDisplayException ex) {
            Log.w(TAG, "Couldn't show presentation!  Display was removed in "
                    + "the meantime.", ex);
            mPresentation = null;
        }
    } else
        Log.i(TAG, "No secondary display detected");
}
 
源代码17 项目: AndroidComponentPlugin   文件: ContextImpl.java
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);
}
 
源代码18 项目: android_9.0.0_r45   文件: DragState.java
InputInterceptor(Display display) {
    InputChannel[] channels = InputChannel.openInputChannelPair("drag");
    mServerChannel = channels[0];
    mClientChannel = channels[1];
    mService.mInputManager.registerInputChannel(mServerChannel, null);
    mInputEventReceiver = new DragInputEventReceiver(mClientChannel,
            mService.mH.getLooper(), mDragDropController);

    mDragApplicationHandle = new InputApplicationHandle(null);
    mDragApplicationHandle.name = "drag";
    mDragApplicationHandle.dispatchingTimeoutNanos =
            WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;

    mDragWindowHandle = new InputWindowHandle(mDragApplicationHandle, null, null,
            display.getDisplayId());
    mDragWindowHandle.name = "drag";
    mDragWindowHandle.inputChannel = mServerChannel;
    mDragWindowHandle.layer = getDragLayerLocked();
    mDragWindowHandle.layoutParamsFlags = 0;
    mDragWindowHandle.layoutParamsType = WindowManager.LayoutParams.TYPE_DRAG;
    mDragWindowHandle.dispatchingTimeoutNanos =
            WindowManagerService.DEFAULT_INPUT_DISPATCHING_TIMEOUT_NANOS;
    mDragWindowHandle.visible = true;
    mDragWindowHandle.canReceiveKeys = false;
    mDragWindowHandle.hasFocus = true;
    mDragWindowHandle.hasWallpaper = false;
    mDragWindowHandle.paused = false;
    mDragWindowHandle.ownerPid = Process.myPid();
    mDragWindowHandle.ownerUid = Process.myUid();
    mDragWindowHandle.inputFeatures = 0;
    mDragWindowHandle.scaleFactor = 1.0f;

    // The drag window cannot receive new touches.
    mDragWindowHandle.touchableRegion.setEmpty();

    // The drag window covers the entire display
    mDragWindowHandle.frameLeft = 0;
    mDragWindowHandle.frameTop = 0;
    mDragWindowHandle.frameRight = mDisplaySize.x;
    mDragWindowHandle.frameBottom = mDisplaySize.y;

    // Pause rotations before a drag.
    if (DEBUG_ORIENTATION) {
        Slog.d(TAG_WM, "Pausing rotation during drag");
    }
    mService.pauseRotationLocked();
}
 
源代码19 项目: miracast-widget   文件: MiracastWidgetProvider.java
@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);
       }
   }
 
源代码20 项目: Taskbar   文件: U.java
public static DisplayInfo getDisplayInfo(Context context, boolean fromTaskbar) {
    context = getDisplayContext(context);
    int displayID = getTaskbarDisplayID(context);

    DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
    Display currentDisplay = null;

    for(Display display : dm.getDisplays()) {
        if(display.getDisplayId() == displayID) {
            currentDisplay = display;
            break;
        }
    }

    if(currentDisplay == null)
        return new DisplayInfo(0, 0, 0, 0);

    DisplayMetrics metrics = new DisplayMetrics();
    currentDisplay.getMetrics(metrics);

    DisplayMetrics realMetrics = new DisplayMetrics();
    currentDisplay.getRealMetrics(realMetrics);

    DisplayInfo info = new DisplayInfo(metrics.widthPixels, metrics.heightPixels, metrics.densityDpi, 0);

    if(isChromeOs(context)) {
        SharedPreferences pref = getSharedPreferences(context);
        if(!pref.getBoolean(PREF_CHROME_OS_CONTEXT_MENU_FIX, true)) {
            info.width = realMetrics.widthPixels;
            info.height = realMetrics.heightPixels;
        }

        return info;
    }

    // Workaround for incorrect display size on devices with notches in landscape mode
    if(fromTaskbar && getDisplayOrientation(context) == Configuration.ORIENTATION_LANDSCAPE)
        return info;

    boolean sameWidth = metrics.widthPixels == realMetrics.widthPixels;
    boolean sameHeight = metrics.heightPixels == realMetrics.heightPixels;

    if(sameWidth && !sameHeight) {
        info.width = realMetrics.widthPixels;
        info.height = realMetrics.heightPixels - getNavbarHeight(context);
    }

    if(!sameWidth && sameHeight) {
        info.width = realMetrics.widthPixels - getNavbarHeight(context);
        info.height = realMetrics.heightPixels;
    }

    return info;
}