Search in sources :

Example 16 with Display

use of android.view.Display in project android_frameworks_base by ParanoidAndroid.

the class FakeApp method onCreate.

@Override
public void onCreate() {
    String processName = ActivityThread.currentProcessName();
    Slog.i("FakeOEMFeatures", "Creating app in process: " + processName);
    if (!getApplicationInfo().packageName.equals(processName)) {
        // our extra overhead stuff.
        return;
    }
    final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    final Display display = wm.getDefaultDisplay();
    // is a user build, WARN!  Do not want!
    if ("user".equals(android.os.Build.TYPE)) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Should not be on user build");
        builder.setMessage("The app Fake OEM Features should not be installed on a " + "user build.  Please remove this .apk before shipping this build to " + " your customers!");
        builder.setCancelable(false);
        builder.setPositiveButton("I understand", null);
        Dialog dialog = builder.create();
        dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
        dialog.show();
    }
    // Make a fake window that is always around eating graphics resources.
    FakeView view = new FakeView(this);
    WindowManager.LayoutParams lp = new WindowManager.LayoutParams(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
    if (ActivityManager.isHighEndGfx()) {
        lp.flags |= WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED;
    }
    lp.width = ViewGroup.LayoutParams.MATCH_PARENT;
    lp.height = ViewGroup.LayoutParams.MATCH_PARENT;
    int maxSize = display.getMaximumSizeDimension();
    maxSize *= 2;
    lp.x = maxSize;
    lp.y = maxSize;
    lp.setTitle(getPackageName());
    wm.addView(view, lp);
    // Bind to a fake service we want to keep running in another process.
    bindService(new Intent(this, FakeCoreService.class), mServiceConnection, Context.BIND_AUTO_CREATE);
    bindService(new Intent(this, FakeCoreService2.class), mServiceConnection2, Context.BIND_AUTO_CREATE);
    bindService(new Intent(this, FakeCoreService3.class), mServiceConnection3, Context.BIND_AUTO_CREATE);
    // Start to a fake service that should run in the background of
    // another process.
    mHandler.sendEmptyMessage(MSG_TICK);
    // Make a fake allocation to consume some RAM.
    mStuffing = new int[STUFFING_SIZE_INTS];
    for (int i = 0; i < STUFFING_SIZE_BYTES / PAGE_SIZE; i++) {
        // Fill each page with a unique value.
        final int VAL = i * 2 + 100;
        final int OFF = (i * PAGE_SIZE) / 4;
        for (int j = 0; j < (PAGE_SIZE / 4); j++) {
            mStuffing[OFF + j] = VAL;
        }
    }
}
Also used : AlertDialog(android.app.AlertDialog) Intent(android.content.Intent) WindowManager(android.view.WindowManager) Dialog(android.app.Dialog) AlertDialog(android.app.AlertDialog) Display(android.view.Display)

Example 17 with Display

use of android.view.Display in project android_frameworks_base by ParanoidAndroid.

the class KeyguardTargets method isScreenLarge.

public boolean isScreenLarge() {
    DisplayMetrics dm = new DisplayMetrics();
    WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    display.getMetrics(dm);
    int shortSize = Math.min(dm.heightPixels, dm.widthPixels);
    int shortSizeDp = shortSize * DisplayMetrics.DENSITY_DEFAULT / DisplayMetrics.DENSITY_DEVICE;
    if (shortSizeDp >= 600) {
        return true;
    }
    return false;
}
Also used : DisplayMetrics(android.util.DisplayMetrics) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 18 with Display

use of android.view.Display in project android_frameworks_base by ParanoidAndroid.

the class AppWidgetServiceImpl method computeMaximumWidgetBitmapMemory.

void computeMaximumWidgetBitmapMemory() {
    WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getRealSize(size);
    // Cap memory usage at 1.5 times the size of the display
    // 1.5 * 4 bytes/pixel * w * h ==> 6 * w * h
    mMaxWidgetBitmapMemory = 6 * size.x * size.y;
}
Also used : Point(android.graphics.Point) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 19 with Display

use of android.view.Display in project android_frameworks_base by ParanoidAndroid.

the class WindowManagerService method handleDisplayAddedLocked.

private void handleDisplayAddedLocked(int displayId) {
    final Display display = mDisplayManager.getDisplay(displayId);
    if (display != null) {
        createDisplayContentLocked(display);
        displayReady(displayId);
    }
}
Also used : Display(android.view.Display)

Example 20 with Display

use of android.view.Display in project android_frameworks_base by ParanoidAndroid.

the class Session method performDrag.

public boolean performDrag(IWindow window, IBinder dragToken, float touchX, float touchY, float thumbCenterX, float thumbCenterY, ClipData data) {
    if (WindowManagerService.DEBUG_DRAG) {
        Slog.d(WindowManagerService.TAG, "perform drag: win=" + window + " data=" + data);
    }
    synchronized (mService.mWindowMap) {
        if (mService.mDragState == null) {
            Slog.w(WindowManagerService.TAG, "No drag prepared");
            throw new IllegalStateException("performDrag() without prepareDrag()");
        }
        if (dragToken != mService.mDragState.mToken) {
            Slog.w(WindowManagerService.TAG, "Performing mismatched drag");
            throw new IllegalStateException("performDrag() does not match prepareDrag()");
        }
        WindowState callingWin = mService.windowForClientLocked(null, window, false);
        if (callingWin == null) {
            Slog.w(WindowManagerService.TAG, "Bad requesting window " + window);
            // !!! TODO: throw here?
            return false;
        }
        // !!! TODO: if input is not still focused on the initiating window, fail
        // the drag initiation (e.g. an alarm window popped up just as the application
        // called performDrag()
        mService.mH.removeMessages(H.DRAG_START_TIMEOUT, window.asBinder());
        // !!! TODO: extract the current touch (x, y) in screen coordinates.  That
        // will let us eliminate the (touchX,touchY) parameters from the API.
        // !!! FIXME: put all this heavy stuff onto the mH looper, as well as
        // the actual drag event dispatch stuff in the dragstate
        Display display = callingWin.mDisplayContent.getDisplay();
        mService.mDragState.register(display);
        mService.mInputMonitor.updateInputWindowsLw(true);
        if (!mService.mInputManager.transferTouchFocus(callingWin.mInputChannel, mService.mDragState.mServerChannel)) {
            Slog.e(WindowManagerService.TAG, "Unable to transfer touch focus");
            mService.mDragState.unregister();
            mService.mDragState = null;
            mService.mInputMonitor.updateInputWindowsLw(true);
            return false;
        }
        mService.mDragState.mData = data;
        mService.mDragState.mCurrentX = touchX;
        mService.mDragState.mCurrentY = touchY;
        mService.mDragState.broadcastDragStartedLw(touchX, touchY);
        // remember the thumb offsets for later
        mService.mDragState.mThumbOffsetX = thumbCenterX;
        mService.mDragState.mThumbOffsetY = thumbCenterY;
        // Make the surface visible at the proper location
        final SurfaceControl surfaceControl = mService.mDragState.mSurfaceControl;
        if (WindowManagerService.SHOW_LIGHT_TRANSACTIONS)
            Slog.i(WindowManagerService.TAG, ">>> OPEN TRANSACTION performDrag");
        SurfaceControl.openTransaction();
        try {
            surfaceControl.setPosition(touchX - thumbCenterX, touchY - thumbCenterY);
            surfaceControl.setAlpha(.7071f);
            surfaceControl.setLayer(mService.mDragState.getDragLayerLw());
            surfaceControl.setLayerStack(display.getLayerStack());
            surfaceControl.show();
        } finally {
            SurfaceControl.closeTransaction();
            if (WindowManagerService.SHOW_LIGHT_TRANSACTIONS)
                Slog.i(WindowManagerService.TAG, "<<< CLOSE TRANSACTION performDrag");
        }
    }
    // success!
    return true;
}
Also used : SurfaceControl(android.view.SurfaceControl) Display(android.view.Display)

Aggregations

Display (android.view.Display)468 Point (android.graphics.Point)224 WindowManager (android.view.WindowManager)193 DisplayMetrics (android.util.DisplayMetrics)75 SuppressLint (android.annotation.SuppressLint)28 Resources (android.content.res.Resources)25 Bitmap (android.graphics.Bitmap)25 LinearLayout (android.widget.LinearLayout)25 Rect (android.graphics.Rect)23 View (android.view.View)23 RemoteException (android.os.RemoteException)22 Canvas (android.graphics.Canvas)21 Method (java.lang.reflect.Method)21 VirtualDisplay (android.hardware.display.VirtualDisplay)20 TextView (android.widget.TextView)18 Dialog (android.app.Dialog)17 Camera (android.hardware.Camera)17 Intent (android.content.Intent)16 ViewGroup (android.view.ViewGroup)16 ImageView (android.widget.ImageView)15