Search in sources :

Example 66 with Display

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

the class TaskCardView method getStartingCardThumbnailRectForStartPosition.

private static Rect getStartingCardThumbnailRectForStartPosition(Context context, boolean hasFocus) {
    Resources res = context.getResources();
    int width = res.getDimensionPixelOffset(R.dimen.recents_tv_card_width);
    int totalSpacing = res.getDimensionPixelOffset(R.dimen.recents_tv_gird_card_spacing) * 2;
    if (hasFocus) {
        totalSpacing += res.getDimensionPixelOffset(R.dimen.recents_tv_gird_focused_card_delta);
    }
    int height = res.getDimensionPixelOffset(R.dimen.recents_tv_screenshot_height);
    int topMargin = res.getDimensionPixelOffset(R.dimen.recents_tv_gird_row_top_margin);
    int headerHeight = res.getDimensionPixelOffset(R.dimen.recents_tv_card_extra_badge_size) + res.getDimensionPixelOffset(R.dimen.recents_tv_icon_padding_bottom);
    WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int screenWidth = size.x;
    return new Rect(screenWidth / 2 + width / 2 + totalSpacing, topMargin + headerHeight, screenWidth / 2 + width / 2 + totalSpacing + width, topMargin + headerHeight + height);
}
Also used : Rect(android.graphics.Rect) Resources(android.content.res.Resources) Point(android.graphics.Point) Point(android.graphics.Point) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 67 with Display

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

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 68 with Display

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

the class FakeBackgroundService method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    mHandler.sendEmptyMessageDelayed(MSG_TICK, TICK_DELAY);
    final WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE);
    final Display display = wm.getDefaultDisplay();
    // Make a fake window that is always around eating graphics resources.
    FakeView view = new FakeView(this);
    Dialog dialog = new Dialog(this, android.R.style.Theme_Holo_Dialog);
    dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
    dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED, WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE | WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS | WindowManager.LayoutParams.FLAG_HARDWARE_ACCELERATED | WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    dialog.getWindow().setDimAmount(0);
    dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
    int maxSize = display.getMaximumSizeDimension();
    maxSize *= 2;
    lp.x = maxSize;
    lp.y = maxSize;
    lp.setTitle(getPackageName() + ":background");
    dialog.getWindow().setAttributes(lp);
    dialog.getWindow().setContentView(view);
    dialog.show();
}
Also used : Dialog(android.app.Dialog) WindowManager(android.view.WindowManager) Display(android.view.Display)

Example 69 with Display

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

the class KeyguardDisplayManager method updateDisplays.

protected void updateDisplays(boolean showing) {
    if (showing) {
        MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_REMOTE_DISPLAY);
        boolean useDisplay = route != null && route.getPlaybackType() == MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE;
        Display presentationDisplay = useDisplay ? route.getPresentationDisplay() : null;
        if (mPresentation != null && mPresentation.getDisplay() != presentationDisplay) {
            if (DEBUG)
                Slog.v(TAG, "Display gone: " + mPresentation.getDisplay());
            mPresentation.dismiss();
            mPresentation = null;
        }
        if (mPresentation == null && presentationDisplay != null) {
            if (DEBUG)
                Slog.i(TAG, "Keyguard enabled on display: " + presentationDisplay);
            mPresentation = new KeyguardPresentation(mContext, presentationDisplay, R.style.keyguard_presentation_theme);
            mPresentation.setOnDismissListener(mOnDismissListener);
            try {
                mPresentation.show();
            } catch (WindowManager.InvalidDisplayException ex) {
                Slog.w(TAG, "Invalid display:", ex);
                mPresentation = null;
            }
        }
    } else {
        if (mPresentation != null) {
            mPresentation.dismiss();
            mPresentation = null;
        }
    }
}
Also used : RouteInfo(android.media.MediaRouter.RouteInfo) MediaRouter(android.media.MediaRouter) Display(android.view.Display) WindowManager(android.view.WindowManager)

Example 70 with Display

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

the class ResourcesManager method getAdjustedDisplay.

/**
     * Returns an adjusted {@link Display} object based on the inputs or null if display isn't
     * available.
     *
     * @param displayId display Id.
     * @param displayAdjustments display adjustments.
     */
public Display getAdjustedDisplay(final int displayId, @Nullable DisplayAdjustments displayAdjustments) {
    final DisplayAdjustments displayAdjustmentsCopy = (displayAdjustments != null) ? new DisplayAdjustments(displayAdjustments) : new DisplayAdjustments();
    final Pair<Integer, DisplayAdjustments> key = Pair.create(displayId, displayAdjustmentsCopy);
    synchronized (this) {
        WeakReference<Display> wd = mDisplays.get(key);
        if (wd != null) {
            final Display display = wd.get();
            if (display != null) {
                return display;
            }
        }
        final DisplayManagerGlobal dm = DisplayManagerGlobal.getInstance();
        if (dm == null) {
            // may be null early in system startup
            return null;
        }
        final Display display = dm.getCompatibleDisplay(displayId, key.second);
        if (display != null) {
            mDisplays.put(key, new WeakReference<>(display));
        }
        return display;
    }
}
Also used : DisplayManagerGlobal(android.hardware.display.DisplayManagerGlobal) DisplayAdjustments(android.view.DisplayAdjustments) Display(android.view.Display)

Aggregations

Display (android.view.Display)697 Point (android.graphics.Point)356 WindowManager (android.view.WindowManager)349 DisplayMetrics (android.util.DisplayMetrics)126 View (android.view.View)57 TextView (android.widget.TextView)54 LinearLayout (android.widget.LinearLayout)45 SuppressLint (android.annotation.SuppressLint)43 Method (java.lang.reflect.Method)41 ImageView (android.widget.ImageView)39 Bitmap (android.graphics.Bitmap)38 Resources (android.content.res.Resources)36 Intent (android.content.Intent)34 Camera (android.hardware.Camera)31 Context (android.content.Context)26 Rect (android.graphics.Rect)25 IOException (java.io.IOException)24 ViewGroup (android.view.ViewGroup)23 Canvas (android.graphics.Canvas)22 RemoteException (android.os.RemoteException)22