Java 类android.hardware.display.DisplayManager 实例源码

项目:africhat-platform-0.1    文件:AndroidMessenger.java   
private boolean isScreenOn() {
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
        boolean screenOn = false;
        for (Display display : dm.getDisplays()) {
            if (display.getState() != Display.STATE_OFF) {
                screenOn = true;
            }
        }
        return screenOn;
    } else {
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        //noinspection deprecation
        return pm.isScreenOn();
    }
}
项目:pc-android-controller-android    文件:ScreenCaptureService.java   
/**
 * 将录屏服务的内容显示到Image面板上.
 */
private void initVirtualDisplay() {

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        DisplayManager mDisplayManager = (DisplayManager) this.getSystemService(Context.DISPLAY_SERVICE);
        if (mDisplayManager == null) {
            L.e(" 获取 播放管理器失败 ... ");
        }
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
            L.d("当前安卓 版本 " + Build.VERSION.SDK_INT + " 进入到图片展示 ");
            mVirtualDisplay = mDisplayManager.createVirtualDisplay("Remote Droid", mScreenWidth,
                    mScreenHeight, mScreenDensity,
                    mImageReader.getSurface(),
                    DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE);
        }
    } else {
        if (mMediaProjection == null) {
            L.e("mMediaProjection is null ...");
            return;
        } else {
            mVirtualDisplay = mMediaProjection.createVirtualDisplay("screen-mirror",
                    mScreenWidth, mScreenHeight, mScreenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
                    mImageReader.getSurface(), null, null);
        }
    }
}
项目:pc-android-controller-android    文件:ScreenCaptureSocket.java   
/**
 * 将录屏服务的内容显示到Image面板上.
 */
private void initVirtualDisplay() {

    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        DisplayManager mDisplayManager = (DisplayManager) mContext.getSystemService(Context.DISPLAY_SERVICE);
        if (mDisplayManager == null) {
            L.e(" 获取 播放管理器失败 ... ");
        }
        if (Build.VERSION.SDK_INT > Build.VERSION_CODES.KITKAT) {
            L.d("当前安卓 版本 " + Build.VERSION.SDK_INT + " 进入到图片展示 ");
            mVirtualDisplay = mDisplayManager.createVirtualDisplay("Remote Droid", mScreenWidth,
                    mScreenHeight, mScreenDensity,
                    mImageReader.getSurface(),
                    DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE);
        }
    } else {
        if (mMediaProjection == null) {
            L.e("mMediaProjection is null ...");
            return;
        } else {
            mVirtualDisplay = mMediaProjection.createVirtualDisplay("screen-mirror",
                    mScreenWidth, mScreenHeight, mScreenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
                    mImageReader.getSurface(), null, null);
        }
    }
}
项目:Hotspot-master-devp    文件:ScreenRecorder.java   
@SuppressLint("NewApi")
@Override
public void run() {
    try {
        try {
            prepareEncoder();
            mMuxer = new MediaMuxer(mDstPath, MediaMuxer.OutputFormat.MUXER_OUTPUT_MPEG_4);

        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        mVirtualDisplay = mMediaProjection.createVirtualDisplay(TAG + "-display",
                mWidth, mHeight, mDpi, DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC,
                mSurface, null, null);
        Log.d(TAG, "created virtual display: " + mVirtualDisplay);
        recordVirtualDisplay();

    } finally {
        release();
    }
}
项目:EasyScreenRecorder    文件:MediaScreenEncoder.java   
@Override
protected void onStart() {
    if (DEBUG) Log.d(TAG,"mScreenCaptureTask#onStart:");
    mDrawer = new GLDrawer2D(true);
    mTexId = mDrawer.initTex();
    mSourceTexture = new SurfaceTexture(mTexId);
    mSourceTexture.setDefaultBufferSize(mWidth, mHeight);   // これを入れないと映像が取れない
    mSourceSurface = new Surface(mSourceTexture);
    mSourceTexture.setOnFrameAvailableListener(mOnFrameAvailableListener, mHandler);
    mEncoderSurface = getEgl().createFromSurface(mSurface);

    if (DEBUG) Log.d(TAG,"setup VirtualDisplay");
    intervals = (long)(1000f / fps);
    display = mMediaProjection.createVirtualDisplay(
        "Capturing Display",
        mWidth, mHeight, mDensity,
        DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
        mSourceSurface, mCallback, mHandler);
    if (DEBUG) Log.v(TAG,  "screen capture loop:display=" + display);
    // 録画タスクを起床
    queueEvent(mDrawTask);
}
项目:ScreenRecordCaptureMaster    文件:CaptureScreenImage.java   
public void initCapture(Context context, MediaProjection mediaProjection, final String path, final IRecordShotCallback callback){
    int screenWidth = context.getResources().getDisplayMetrics().widthPixels;
    int screenHeight = context.getResources().getDisplayMetrics().heightPixels;

    // thread for image checking
    mCheckThread = new HandlerThread("CheckHandler");
    mCheckThread.start();
    mCheckHandler = new Handler(mCheckThread.getLooper());

    try {
        mImageReader = ImageReader.newInstance(screenWidth, screenHeight, PixelFormat.RGBA_8888, 2);
        mImageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
            @Override
            public void onImageAvailable(ImageReader reader) {
                imageAvailable(reader, path, callback);
            }
        }, mCheckHandler);
        mSurface = mImageReader.getSurface();
    }finally {

    }
    mVirtualDisplay = mediaProjection.createVirtualDisplay("mediaprojection", screenWidth, screenHeight,
            1, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR, mSurface, null, null);
}
项目:android_packages_apps_tv    文件:DvrPlaybackOverlayFragment.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    if (DEBUG) Log.d(TAG, "onCreate");
    super.onCreate(savedInstanceState);
    mExtraPaddingNoRelatedRow = getActivity().getResources()
            .getDimensionPixelOffset(R.dimen.dvr_playback_fragment_extra_padding_top);
    mDvrDataManager = TvApplication.getSingletons(getActivity()).getDvrDataManager();
    mContentRatingsManager = TvApplication.getSingletons(getContext())
            .getTvInputManagerHelper().getContentRatingsManager();
    mProgram = getProgramFromIntent(getActivity().getIntent());
    if (mProgram == null) {
        Toast.makeText(getActivity(), getString(R.string.dvr_program_not_found),
                Toast.LENGTH_SHORT).show();
        getActivity().finish();
        return;
    }
    Point size = new Point();
    ((DisplayManager) getContext().getSystemService(Context.DISPLAY_SERVICE))
            .getDisplay(Display.DEFAULT_DISPLAY).getSize(size);
    mWindowWidth = size.x;
    mWindowHeight = size.y;
    mWindowAspectRatio = mAppliedAspectRatio = (float) mWindowWidth / mWindowHeight;
    setBackgroundType(PlaybackOverlayFragment.BG_LIGHT);
    setFadingEnabled(true);
}
项目:android_packages_apps_tv    文件:MainActivity.java   
private void applyDisplayRefreshRate(float videoFrameRate) {
    boolean is24Fps = Math.abs(videoFrameRate - FRAME_RATE_FOR_FILM) < FRAME_RATE_EPSILON;
    if (mIsFilmModeSet && !is24Fps) {
        setPreferredRefreshRate(mDefaultRefreshRate);
        mIsFilmModeSet = false;
    } else if (!mIsFilmModeSet && is24Fps) {
        DisplayManager displayManager = (DisplayManager) getSystemService(
                Context.DISPLAY_SERVICE);
        Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY);

        float[] refreshRates = display.getSupportedRefreshRates();
        for (float refreshRate : refreshRates) {
            // Be conservative and set only when the display refresh rate supports 24fps.
            if (Math.abs(videoFrameRate - refreshRate) < REFRESH_RATE_EPSILON) {
                setPreferredRefreshRate(refreshRate);
                mIsFilmModeSet = true;
                return;
            }
        }
    }
}
项目:castscreen    文件:ProjectionManager.java   
/**
 * @param view the SurfaceView on which to draw user's screen
 */
public void drawOnSurfaceView(SurfaceView view) {
    if (mDisplay != null) mDisplay.release();

    Surface surface = view.getHolder().getSurface();
    mDisplay = mProjection.createVirtualDisplay(
        VIRTUAL_DISPLAY_NAME,
        view.getWidth(),
        view.getHeight(),
        mDensity,
        DisplayManager.VIRTUAL_DISPLAY_FLAG_OWN_CONTENT_ONLY,
        surface,
        null,
        null
    );
}
项目:mdkdisplay    文件:MainActivity.java   
/**
 * Select a picture to show on remote presentation view
 */
private void selectPhoto() {
    if (checkSelfPermission("android.permission.READ_EXTERNAL_STORAGE")
            != PackageManager.PERMISSION_GRANTED) {
        requestPermissions(new String[]{"android.permission.READ_EXTERNAL_STORAGE"},
                REQUEST_STORAGE_PERMISSION);
    } else {
        DisplayManager displayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
        Display[] presentationDisplays = displayManager.getDisplays(DisplayManager.DISPLAY_CATEGORY_PRESENTATION);
        if (presentationDisplays.length > 0) {
            Intent i = new Intent(Intent.ACTION_PICK,
                    android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
            i.setType("image/*");
            i.setAction(Intent.ACTION_GET_CONTENT);
            startActivityForResult(Intent.createChooser(i,
                    getString(R.string.select_picture)), SELECT_PHOTO);
        } else {
            AlertDialog.Builder alert = new AlertDialog.Builder(this);
            alert.setMessage(getString(R.string.external_display_not_available));
            alert.setPositiveButton(android.R.string.ok, null);
            alert.show();
        }
    }
}
项目:Superuser-UI    文件:SuReceiver.java   
private boolean isScreenOn(Context context) {

        if (Build.VERSION.SDK_INT >= 20) {
            DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);

            for (Display display : dm.getDisplays()) {
                if (display.getState() != Display.STATE_OFF)
                    return true;
            }

            return false;

        } else {
            PowerManager powerManager = (PowerManager) context.getSystemService(POWER_SERVICE);
            return (powerManager.isScreenOn());
        }
    }
项目:ScreenRecordingSample    文件:MediaScreenEncoder.java   
@Override
protected void onStart() {
    if (DEBUG) Log.d(TAG,"mScreenCaptureTask#onStart:");
    mDrawer = new GLDrawer2D(true);
    mTexId = mDrawer.initTex();
    mSourceTexture = new SurfaceTexture(mTexId);
    mSourceTexture.setDefaultBufferSize(mWidth, mHeight);   // これを入れないと映像が取れない
    mSourceSurface = new Surface(mSourceTexture);
    mSourceTexture.setOnFrameAvailableListener(mOnFrameAvailableListener, mHandler);
    mEncoderSurface = getEgl().createFromSurface(mSurface);

    if (DEBUG) Log.d(TAG,"setup VirtualDisplay");
    intervals = (long)(1000f / fps);
    display = mMediaProjection.createVirtualDisplay(
        "Capturing Display",
        mWidth, mHeight, mDensity,
        DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
        mSourceSurface, mCallback, mHandler);
    if (DEBUG) Log.v(TAG,  "screen capture loop:display=" + display);
    // 録画タスクを起床
    queueEvent(mDrawTask);
}
项目:LEHomeMobile_android    文件:ComUtil.java   
public static boolean isScreenOn(Context context) {
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
        boolean screenOn = false;
        for (Display display : dm.getDisplays()) {
            if (display.getState() != Display.STATE_OFF) {
                screenOn = true;
            }
        }
        return screenOn;
    } else {
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        //noinspection deprecation
        return pm.isScreenOn();
    }
}
项目:actor-platform    文件:AndroidMessenger.java   
private boolean isScreenOn() {
    if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
        boolean screenOn = false;
        for (Display display : dm.getDisplays()) {
            if (display.getState() != Display.STATE_OFF) {
                screenOn = true;
            }
        }
        return screenOn;
    } else {
        PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        //noinspection deprecation
        return pm.isScreenOn();
    }
}
项目:dslink-java-android    文件:ScreenProvider.java   
@Override
public void setup() {
    displayManager = (DisplayManager) LinkService.INSTANCE.getSystemService(Context.DISPLAY_SERVICE);
    displayListener = new DisplayManager.DisplayListener() {
        @Override
        public void onDisplayAdded(int i) {
        }

        @Override
        public void onDisplayRemoved(int i) {
        }

        @Override
        public void onDisplayChanged(int i) {
            final int state = displayManager.getDisplay(i).getState();

            update(new HashMap<String, Object>() {{
                put("On", state == Display.STATE_ON);
            }});
        }
    };
    displayManager.registerDisplayListener(displayListener, new Handler());
    setEnabled();
}
项目:RemoteDroid    文件:ServerService.java   
@TargetApi(19)
public void startDisplayManager() {
    DisplayManager mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
    Surface encoderInputSurface = null;
    try {
        encoderInputSurface = createDisplaySurface();
    } catch (IOException e) {
        e.printStackTrace();
    }
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        virtualDisplay = mDisplayManager.createVirtualDisplay("Remote Droid", CodecUtils.WIDTH, CodecUtils.HEIGHT, 50,
                encoderInputSurface,
                DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE);
    } else {
        if (MainActivity.mMediaProjection != null) {
            virtualDisplay = MainActivity.mMediaProjection.createVirtualDisplay("Remote Droid",
                    CodecUtils.WIDTH, CodecUtils.HEIGHT, 50,
                    DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
                    encoderInputSurface, null, null);
        } else {
            showToast("Something went wrong. Please restart the app.");
        }
    }

    encoder.start();
}
项目:SecondScreen    文件:NotificationService.java   
@Override
public void onDisplayAdded(int displayId) {
    Intent intent = new Intent();
    intent.setAction(U.SCREEN_CONNECT);
    LocalBroadcastManager.getInstance(NotificationService.this).sendBroadcast(intent);

    DisplayManager dm = (DisplayManager) getSystemService(DISPLAY_SERVICE);
    Display[] displays = dm.getDisplays();

    try {
        if(displays[displays.length - 2].getDisplayId() == Display.DEFAULT_DISPLAY) {
            Intent serviceIntent = new Intent(NotificationService.this, ScreenOnService.class);
            startService(serviceIntent);
        }
    } catch (ArrayIndexOutOfBoundsException e) { /* Gracefully fail */ }
}
项目:SecondScreen    文件:U.java   
public static boolean castScreenActive(Context context) {
    DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
    Display[] displays = dm.getDisplays();

    for(Display display : displays) {
        try {
            if(Class.forName("android.view.Display")
                    .getMethod("getOwnerPackageName")
                    .invoke(display)
                    .equals("com.google.android.gms"))
                return true;
        } catch (Exception e) { /* Gracefully fail */ }
    }

    return false;
}
项目:dslink-java-android    文件:ScreenProvider.java   
@Override
public void setup() {
    displayManager = (DisplayManager) LinkService.INSTANCE.getSystemService(Context.DISPLAY_SERVICE);
    displayListener = new DisplayManager.DisplayListener() {
        @Override
        public void onDisplayAdded(int i) {
        }

        @Override
        public void onDisplayRemoved(int i) {
        }

        @Override
        public void onDisplayChanged(int i) {
            final int state = displayManager.getDisplay(i).getState();

            update(new HashMap<String, Object>() {{
                put("On", state == Display.STATE_ON);
            }});
        }
    };
    displayManager.registerDisplayListener(displayListener, new Handler());
    setEnabled();
}
项目:sdl_android    文件:VirtualDisplayEncoder.java   
/**
 * Initialization method for VirtualDisplayEncoder object. MUST be called before start() or shutdown()
 * Will overwrite previously set videoWeight and videoHeight
 * @param context to create the virtual display
 * @param outputListener the listener that the video frames will be sent through
 * @param streamingParams parameters to create the virtual display and encoder
 * @throws Exception if the API level is <19 or supplied parameters were null
 */
public void init(Context context, IVideoStreamListener outputListener, VideoStreamingParameters streamingParams) throws Exception {
    if (android.os.Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        Log.e(TAG, "API level of 19 required for VirtualDisplayEncoder");
        throw new Exception("API level of 19 required");
    }

    if (context == null || outputListener == null || streamingParams == null || streamingParams.getResolution() == null || streamingParams.getFormat() == null) {
        Log.e(TAG, "init parameters cannot be null for VirtualDisplayEncoder");
        throw new Exception("init parameters cannot be null");
    }

    this.mDisplayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);

    this.streamingParams.update(streamingParams);

    mOutputListener = outputListener;

    initPassed = true;
}
项目:https-github.com-hyb1996-NoRootScriptDroid    文件:ScreenCapturer.java   
private void initVirtualDisplay(MediaProjectionManager manager, Intent data, int screenWidth, int screenHeight, int screenDensity) {
    mImageReader = ImageReader.newInstance(screenWidth, screenHeight, PixelFormat.RGBA_8888, 1);
    mMediaProjection = manager.getMediaProjection(Activity.RESULT_OK, data);
    mVirtualDisplay = mMediaProjection.createVirtualDisplay("screen-mirror",
            screenWidth, screenHeight, screenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
            mImageReader.getSurface(), null, null);
}
项目:NotifyTools    文件:CaptureHelper.java   
/**
     * 初始化截屏相关设置
     * MediaProjectionManager -> MediaProjection -> VirtualDisplay
     * */
    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    public void screenShotPrepare() {
        initLooper();
//        mediaProjection = MainApp.mediaProjection;
//        SysUtils.hideStatusBar(this);
        if(mediaProjection==null) {
            log.d("screenShotPrepare mediaProjection null ");
            return;
        }
        log.d("screenShotPrepare");
        Display display = ((WindowManager)cxt.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        metrics = new DisplayMetrics();
        display.getRealMetrics(metrics);
        Point point = new Point();
        display.getRealSize(point);
        width = point.x;
        height = point.y;

        //将屏幕画面放入ImageReader关联的Surface中
        imageReader = ImageReader.newInstance(width, height, PixelFormat.RGBA_8888, 1);
        log.d("screenShotPrepare2 "+imageReader);
//        imageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
//            @Override
//            public void onImageAvailable(ImageReader reader) {
//                log.d("onImageAvailable ");
//            }
//        },null);
        virtualDisplay = mediaProjection.createVirtualDisplay("ScreenShotDemo",
                width, height, metrics.densityDpi,
                DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
                imageReader.getSurface(),
                null, null/*Handler*/);
    }
项目:NotifyTools    文件:JumpService.java   
/**
     * 初始化截屏相关设置
     * MediaProjectionManager -> MediaProjection -> VirtualDisplay
     * */
    @TargetApi(Build.VERSION_CODES.LOLLIPOP)
    protected void screenShotPrepare() {
        initLooper();
//        mediaProjection = MainApp.mediaProjection;
//        SysUtils.hideStatusBar(this);
        if(mediaProjection==null) {
            log.d("screenShotPrepare mediaProjection null ");
            return;
        }
        log.d("screenShotPrepare");
        Display display = ((WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay();
        metrics = new DisplayMetrics();
        display.getRealMetrics(metrics);
        Point point = new Point();
        display.getRealSize(point);
        width = point.x;
        height = point.y;

        //将屏幕画面放入ImageReader关联的Surface中
        imageReader = ImageReader.newInstance(width, height, PixelFormat.RGBA_8888, 1);
        log.d("screenShotPrepare2 "+imageReader);
//        imageReader.setOnImageAvailableListener(new ImageReader.OnImageAvailableListener() {
//            @Override
//            public void onImageAvailable(ImageReader reader) {
//                log.d("onImageAvailable ");
//            }
//        },null);
        virtualDisplay = mediaProjection.createVirtualDisplay("ScreenShotDemo",
                width, height, metrics.densityDpi,
                DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
                imageReader.getSurface(),
                null, null/*Handler*/);
    }
项目:pc-android-controller-android    文件:ScreenRecodeService.java   
@TargetApi(19)
    public void startDisplayManager() {
        DisplayManager mDisplayManager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
        Surface encoderInputSurface = null;
        try {
            encoderInputSurface = createDisplaySurface();
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
            virtualDisplay = mDisplayManager.createVirtualDisplay("Remote Droid",
                    AccessConstants.PHONE_WIDTH, AccessConstants.PHONE_HEIGHT, 50,
                    encoderInputSurface,
                    DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC | DisplayManager.VIRTUAL_DISPLAY_FLAG_SECURE);
        } else {
            if (mMediaProjection != null) {
                virtualDisplay = mMediaProjection.createVirtualDisplay("Remote Droid",
                        AccessConstants.PHONE_WIDTH, AccessConstants.PHONE_HEIGHT, AccessConstants.DPI,
                        DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
                        encoderInputSurface, null, null);
            } else {
                Log.e(TAG, "Something went wrong. Please restart the app.");
            }
        }

//        sendData2();
        encoder.start();
    }
项目:LucaHome-AndroidApplication    文件:DisplayController.java   
public boolean IsScreenOn() {
    DisplayManager displayManager = (DisplayManager) _context.getSystemService(Context.DISPLAY_SERVICE);
    if (displayManager == null) {
        Logger.getInstance().Error(TAG, "displayManager is null!");
        return false;
    }

    for (Display display : displayManager.getDisplays()) {
        if (display.getState() != Display.STATE_OFF) {
            return true;
        }
    }
    return false;
}
项目:Bigbang    文件:ScreenCapture.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void virtualDisplay() {
    try {
        mVirtualDisplay = mMediaProjection.createVirtualDisplay("screen-mirror",
                windowWidth, windowHeight, mScreenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
                mImageReader.getSurface(), null, null);
        LogUtil.d(TAG, "virtual displayed");
    } catch (Exception e) {
        e.printStackTrace();
    }
}
项目:Auto.js    文件:ScreenCapturer.java   
private void initVirtualDisplay(MediaProjectionManager manager, Intent data, int screenWidth, int screenHeight, int screenDensity) {
    mImageReader = ImageReader.newInstance(screenWidth, screenHeight, PixelFormat.RGBA_8888, 2);
    mMediaProjection = manager.getMediaProjection(Activity.RESULT_OK, data);
    mVirtualDisplay = mMediaProjection.createVirtualDisplay("screen-mirror",
            screenWidth, screenHeight, screenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
            mImageReader.getSurface(), null, null);
}
项目:MTweaks-KernelAdiutorMOD    文件:Utils.java   
public static boolean isScreenOn(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
        for (Display display : dm.getDisplays()) {
            if (display.getState() != Display.STATE_OFF) {
                return true;
            }
        }
        return false;
    } else {
        PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        return powerManager.isScreenOn();
    }
}
项目:KernelAdiutor-Mod    文件:Utils.java   
public static boolean isScreenOn(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
        for (Display display : dm.getDisplays()) {
            if (display.getState() != Display.STATE_OFF) {
                return true;
            }
        }
        return false;
    } else {
        PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        return powerManager.isScreenOn();
    }
}
项目:Agora-Screen-Sharing-Android    文件:ScreenCapture.java   
private void startScreenCapture() {
    mVirtualDisplay = mMediaProjection.createVirtualDisplay("ScreenCapture",
            mWidth, mHeight, mScreenDensity, DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC, mSurface,
            null, null);

    mState.set(SCREEN_STATE_CAPTURING);
    Message msg = mMainHandler.obtainMessage(SCREEN_RECORD_STARTED, 0, 0);
    mMainHandler.sendMessage(msg);
}
项目:ScreenShotAnywhere    文件:ShotsService.java   
private void setUpVirtualDisplay() {
    Log.i(TAG, "Setting up a VirtualDisplay: " +
            windowWidth + "x" + windowHeight +
            " (" + mScreenDensity + ")");
    mImageReader = ImageReader.newInstance(windowWidth, windowHeight, 0x1, 2); //ImageFormat.RGB_565
    mVirtualDisplay = mMediaProjection.createVirtualDisplay("ScreenCapture",
            windowWidth, windowHeight, mScreenDensity,
            DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
            mImageReader.getSurface(), null, null);
}
项目:ScreenRecordCaptureMaster    文件:YixiaScreenEncoder.java   
public void startRecordVideo() {
    try {
        isStart = true;
        prepareEncoder();
        mVirtualDisplay = mMediaProjection.createVirtualDisplay(TAG + "-display",
                mWidth, mHeight, mDpi, DisplayManager.VIRTUAL_DISPLAY_FLAG_PUBLIC,
                mSurface, null, null);
        recordVirtualDisplay();
    } catch (Exception e) {
        stopRecordVideo();
    }
}
项目:accelerator-core-android    文件:ScreenSharingFragment.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void setUpVirtualDisplay() {

    mScreen = (ViewGroup) getActivity().getWindow().getDecorView().getRootView();

    // display metrics
    DisplayMetrics metrics = getResources().getDisplayMetrics();
    mDensity = metrics.densityDpi;
    Display mDisplay = getActivity().getWindowManager().getDefaultDisplay();

    Point size = new Point();
    mDisplay.getRealSize(size);
    mWidth = size.x;
    mHeight = size.y;

    // start capture reader
    mImageReader = ImageReader.newInstance(mWidth, mHeight, PixelFormat.RGBA_8888, 2);
    int flags = DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR;

    mVirtualDisplay = mMediaProjection.createVirtualDisplay("ScreenCapture", mWidth, mHeight, mDensity, flags, mImageReader.getSurface(), null, null);

    size.set(mWidth, mHeight);

    //create ScreenCapturer
    mScreenCapturer = new ScreenSharingCapturer(getActivity(), mScreen, mImageReader);

    mListener.onScreenCapturerReady();
}
项目:aosp_screen_stabilization    文件:Utils.java   
public static boolean isScreenOn(Context context)
{
    DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
    for (Display display : dm.getDisplays())
    {
        if (display.getState() != Display.STATE_OFF)
            return true;
    }
    return false;
}
项目:ScreenCapture    文件:MainActivity.java   
private VirtualDisplay createVirtualDisplay() {
    return mMediaProjection.createVirtualDisplay("MainActivity",
            DISPLAY_WIDTH, DISPLAY_HEIGHT, mScreenDensity,
            DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
            mMediaRecorder.getSurface(), null /*Callbacks*/, null
            /*Handler*/);
}
项目:AndroidScreenShot_SysApi    文件:Shotter.java   
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void virtualDisplay() {

    mVirtualDisplay = mMediaProjection.createVirtualDisplay("screen-mirror",
            getScreenWidth(),
            getScreenHeight(),
            Resources.getSystem().getDisplayMetrics().densityDpi,
            DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
            mImageReader.getSurface(), null, null);

}
项目:SCR-Screen-Recorder-app    文件:ProjectionThread.java   
public Orientation getOrientation() {
    Point s;
    try {
        DisplayManager displayManager = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
        Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
        s = new Point();
        display.getSize(s);
    } catch (Exception e) {
        Log.w(TAG, "Error retrieving screen orientation");
        EasyTracker.getTracker().sendException("projection", e, false);
        return Orientation.LANDSCAPE;
    }
    return s.x > s.y ? Orientation.LANDSCAPE : Orientation.PORTRAIT;
}
项目:android_packages_apps_tv    文件:ScaledLayout.java   
public ScaledLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);
    Point size = new Point();
    DisplayManager displayManager = (DisplayManager) getContext()
            .getSystemService(Context.DISPLAY_SERVICE);
    Display display = displayManager.getDisplay(Display.DEFAULT_DISPLAY);
    display.getRealSize(size);
    mMaxWidth = size.x;
    mMaxHeight = size.y;
}
项目:androidStreamer    文件:ScreenCaptureActivity.java   
private VirtualDisplay createVirtualDisplay() {
    return mMediaProjection.createVirtualDisplay("ScreenCaptureActivity",
            DISPLAY_WIDTH, DISPLAY_HEIGHT, mScreenDensity,
            DisplayManager.VIRTUAL_DISPLAY_FLAG_AUTO_MIRROR,
            mMediaRecorder.getSurface(), null /*Callbacks*/, null
            /*Handler*/);
}
项目:ForceDoze    文件:Utils.java   
public static boolean isScreenOn(Context context) {
    DisplayManager dm = (DisplayManager) context.getSystemService(Context.DISPLAY_SERVICE);
    for (Display display : dm.getDisplays()) {
        if (display.getState() == Display.STATE_ON
                || display.getState() == Display.STATE_UNKNOWN) {
            return true;
        }
    }
    return false;
}