Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 48a10a56 authored by Winson Chung's avatar Winson Chung
Browse files

Change API to return thumbnail size instead of individual dimensions. (Bug 17295512)

- Fixing issue where we were pulling the thumbnail dimensions too early in AMS. (Bug 17286904)
- Simplifying the Recents code between start & configuration change

Change-Id: I6d667cbf37b844939e5fc466da613bb78ca05082
parent e193455e
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -3608,8 +3608,7 @@ package android.app {
    method public int addAppTask(android.app.Activity, android.content.Intent, android.app.ActivityManager.TaskDescription, android.graphics.Bitmap);
    method public boolean clearApplicationUserData();
    method public void dumpPackageState(java.io.FileDescriptor, java.lang.String);
    method public int getAppTaskThumbnailHeight();
    method public int getAppTaskThumbnailWidth();
    method public android.util.Size getAppTaskThumbnailSize();
    method public java.util.List<android.app.ActivityManager.AppTask> getAppTasks();
    method public android.content.pm.ConfigurationInfo getDeviceConfigurationInfo();
    method public int getLargeMemoryClass();
+7 −17
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import android.os.SystemProperties;
import android.os.UserHandle;
import android.text.TextUtils;
import android.util.DisplayMetrics;
import android.util.Size;
import android.util.Slog;

import java.io.FileDescriptor;
@@ -1026,24 +1027,13 @@ public class ActivityManager {
    }

    /**
     * Return the current design width for {@link AppTask} thumbnails, for use
     * Return the current design dimensions for {@link AppTask} thumbnails, for use
     * with {@link #addAppTask}.
     */
    public int getAppTaskThumbnailWidth() {
    public Size getAppTaskThumbnailSize() {
        synchronized (this) {
            ensureAppTaskThumbnailSizeLocked();
            return mAppTaskThumbnailSize.x;
        }
    }

    /**
     * Return the current design height for {@link AppTask} thumbnails, for use
     * with {@link #addAppTask}.
     */
    public int getAppTaskThumbnailHeight() {
        synchronized (this) {
            ensureAppTaskThumbnailSizeLocked();
            return mAppTaskThumbnailSize.y;
            return new Size(mAppTaskThumbnailSize.x, mAppTaskThumbnailSize.y);
        }
    }

@@ -1072,9 +1062,9 @@ public class ActivityManager {
     * set on it.
     * @param description Optional additional description information.
     * @param thumbnail Thumbnail to use for the recents entry.  Should be the size given by
     * {@link #getAppTaskThumbnailWidth()} and {@link #getAppTaskThumbnailHeight()}.  If the
     * bitmap is not that exact size, it will be recreated in your process, probably in a way
     * you don't like, before the recents entry is added.
     * {@link #getAppTaskThumbnailSize()}.  If the bitmap is not that exact size, it will be
     * recreated in your process, probably in a way you don't like, before the recents entry
     * is added.
     *
     * @return Returns the task id of the newly added app task, or -1 if the add failed.  The
     * most likely cause of failure is that there is no more room for more tasks for your app.
+3 −0
Original line number Diff line number Diff line
@@ -58,6 +58,9 @@
    <!-- Size of fading edge for scrolling -->
    <dimen name="status_bar_recents_scroll_fading_edge_length">10dip</dimen>

    <!-- The radius of the rounded corners on a task view. -->
    <dimen name="recents_task_view_rounded_corners_radius">3dp</dimen>

    <!-- Where to place the app icon over the thumbnail -->
    <dimen name="status_bar_recents_app_icon_left_margin">0dp</dimen>
    <dimen name="status_bar_recents_app_icon_top_margin">8dp</dimen>
+20 −30
Original line number Diff line number Diff line
@@ -72,6 +72,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
    static RecentsComponent.Callbacks sRecentsComponentCallbacks;

    Context mContext;
    LayoutInflater mInflater;
    SystemServicesProxy mSystemServicesProxy;
    Handler mHandler;
    boolean mBootCompleted;
@@ -98,32 +99,20 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta

    public AlternateRecentsComponent(Context context) {
        RecentsTaskLoader.initialize(context);
        Resources res = context.getResources();
        mInflater = LayoutInflater.from(context);
        mContext = context;
        mSystemServicesProxy = new SystemServicesProxy(context);
        mHandler = new Handler();
        mConfig = RecentsConfiguration.reinitialize(context, mSystemServicesProxy);
        mWindowRect = mSystemServicesProxy.getWindowRect();
        mTaskStackBounds = new Rect();
        mStatusBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
        mNavBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height);
        mNavBarWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width);
        mConfig.getTaskStackBounds(mWindowRect.width(), mWindowRect.height(), mStatusBarHeight,
                mNavBarWidth, mTaskStackBounds);
        if (mConfig.isLandscape && mConfig.transposeRecentsLayoutWithOrientation) {
            mSystemInsets.set(0, mStatusBarHeight, mNavBarWidth, 0);
        } else {
            mSystemInsets.set(0, mStatusBarHeight, 0, mNavBarHeight);
        }
    }

    public void onStart() {
    public void onStart() {}

    public void onBootCompleted() {
        // Initialize some static datastructures
        TaskStackViewLayoutAlgorithm.initializeCurve();
        // Load the header bar layout
        reloadHeaderBarLayout();
    }

    public void onBootCompleted() {
        mBootCompleted = true;
    }

@@ -235,9 +224,19 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
    }

    public void onConfigurationChanged(Configuration newConfig) {
        reloadHeaderBarLayout();
        sLastScreenshot = null;
    }

    /** Prepares the header bar layout. */
    void reloadHeaderBarLayout() {
        Resources res = mContext.getResources();
        mWindowRect = mSystemServicesProxy.getWindowRect();
        mStatusBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.status_bar_height);
        mNavBarHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_height);
        mNavBarWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.navigation_bar_width);
        mConfig = RecentsConfiguration.reinitialize(mContext, mSystemServicesProxy);
        mConfig.updateOnConfigurationChange();
        mWindowRect = mSystemServicesProxy.getWindowRect();
        mConfig.getTaskStackBounds(mWindowRect.width(), mWindowRect.height(), mStatusBarHeight,
                mNavBarWidth, mTaskStackBounds);
        if (mConfig.isLandscape && mConfig.transposeRecentsLayoutWithOrientation) {
@@ -245,14 +244,8 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
        } else {
            mSystemInsets.set(0, mStatusBarHeight, 0, mNavBarHeight);
        }
        sLastScreenshot = null;
        reloadHeaderBarLayout();
    }

    /** Prepares the header bar layout. */
    void reloadHeaderBarLayout() {
        // Inflate the header bar layout so that we can rebind and draw it for the transition
        Resources res = mContext.getResources();
        TaskStack stack = new TaskStack();
        mDummyStackView = new TaskStackView(mContext, stack);
        TaskStackViewLayoutAlgorithm algo = mDummyStackView.getStackAlgorithm();
@@ -261,8 +254,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
        algo.computeRects(mWindowRect.width(), mWindowRect.height(), taskStackBounds);
        Rect taskViewSize = algo.getUntransformedTaskViewSize();
        int taskBarHeight = res.getDimensionPixelSize(R.dimen.recents_task_bar_height);
        LayoutInflater inflater = LayoutInflater.from(mContext);
        mHeaderBar = (TaskViewHeader) inflater.inflate(R.layout.recents_task_view_header, null,
        mHeaderBar = (TaskViewHeader) mInflater.inflate(R.layout.recents_task_view_header, null,
                false);
        mHeaderBar.measure(
                View.MeasureSpec.makeMeasureSpec(taskViewSize.width(), View.MeasureSpec.EXACTLY),
@@ -419,10 +411,6 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
            return null;
        }

        // Get the stack
        mDummyStackView.updateMinMaxScrollForStack(stack, mTriggeredFromAltTab, isTopTaskHome);
        mDummyStackView.getScroller().setStackScrollToInitialState();

        // Find the running task in the TaskStack
        Task task = null;
        ArrayList<Task> tasks = stack.getTasks();
@@ -444,6 +432,8 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
        }

        // Get the transform for the running task
        mDummyStackView.updateMinMaxScrollForStack(stack, mTriggeredFromAltTab, isTopTaskHome);
        mDummyStackView.getScroller().setStackScrollToInitialState();
        mTmpTransform = mDummyStackView.getStackAlgorithm().getStackTransform(task,
                mDummyStackView.getScroller().getStackScroll(), mTmpTransform, null);
        return mTmpTransform;
+14 −9
Original line number Diff line number Diff line
@@ -1198,11 +1198,12 @@ public final class ActivityManagerService extends ActivityManagerNative
     */
    private boolean mUserIsMonkey;
    /** Flag whether the device has a recents UI */
    final boolean mHasRecents;
    /** Flag whether the device has a Recents UI */
    boolean mHasRecents;
    final int mThumbnailWidth;
    final int mThumbnailHeight;
    /** The dimensions of the thumbnails in the Recents UI. */
    int mThumbnailWidth;
    int mThumbnailHeight;
    final ServiceThread mHandlerThread;
    final MainHandler mHandler;
@@ -2257,11 +2258,6 @@ public final class ActivityManagerService extends ActivityManagerNative
        mConfigurationSeq = mConfiguration.seq = 1;
        mProcessCpuTracker.init();
        final Resources res = mContext.getResources();
        mHasRecents = res.getBoolean(com.android.internal.R.bool.config_hasRecents);
        mThumbnailWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_width);
        mThumbnailHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_height);
        mCompatModePackages = new CompatModePackages(this, systemDir, mHandler);
        mIntentFirewall = new IntentFirewall(new IntentFirewallInterface(), mHandler);
        mStackSupervisor = new ActivityStackSupervisor(this);
@@ -10680,6 +10676,14 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
    }
    /** Loads resources after the current configuration has been set. */
    private void loadResourcesOnSystemReady() {
        final Resources res = mContext.getResources();
        mHasRecents = res.getBoolean(com.android.internal.R.bool.config_hasRecents);
        mThumbnailWidth = res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_width);
        mThumbnailHeight = res.getDimensionPixelSize(com.android.internal.R.dimen.thumbnail_height);
    }
    public boolean testIsSystemReady() {
        // no need to synchronize(this) just to read & return the value
        return mSystemReady;
@@ -10961,6 +10965,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        }
        retrieveSettings();
        loadResourcesOnSystemReady();
        synchronized (this) {
            readGrantedUriPermissionsLocked();
Loading