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

Commit 85cfec81 authored by Winson Chung's avatar Winson Chung
Browse files

Fixing potential crash when attemping to read null thumbnail (Bug. 16289301)

- Refactoring to remove unnecessary updates of RecentsConfiguration
- Removing unused logs

Change-Id: If427e565ab7260009ffb9be8ca45ba833c8262af
parent 44583d35
Loading
Loading
Loading
Loading
+5 −37
Original line number Original line Diff line number Diff line
@@ -64,11 +64,9 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta


    Context mContext;
    Context mContext;
    SystemServicesProxy mSystemServicesProxy;
    SystemServicesProxy mSystemServicesProxy;

    // Recents service binding
    Handler mHandler;
    Handler mHandler;
    boolean mBootCompleted = false;
    boolean mBootCompleted;
    boolean mStartAnimationTriggered = false;
    boolean mStartAnimationTriggered;


    // Task launching
    // Task launching
    RecentsConfiguration mConfig;
    RecentsConfiguration mConfig;
@@ -95,9 +93,7 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
    }
    }


    public void onStart() {
    public void onStart() {
        if (Console.Enabled) {
        // Do nothing
            Console.log(Constants.Log.App.RecentsComponent, "[RecentsComponent|start]");
        }
    }
    }


    public void onBootCompleted() {
    public void onBootCompleted() {
@@ -106,9 +102,6 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta


    /** Shows the recents */
    /** Shows the recents */
    public void onShowRecents(boolean triggeredFromAltTab, View statusBarView) {
    public void onShowRecents(boolean triggeredFromAltTab, View statusBarView) {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.RecentsComponent, "[RecentsComponent|showRecents]");
        }
        mStatusBarView = statusBarView;
        mStatusBarView = statusBarView;
        mTriggeredFromAltTab = triggeredFromAltTab;
        mTriggeredFromAltTab = triggeredFromAltTab;


@@ -121,10 +114,6 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta


    /** Hides the recents */
    /** Hides the recents */
    public void onHideRecents(boolean triggeredFromAltTab) {
    public void onHideRecents(boolean triggeredFromAltTab) {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.RecentsComponent, "[RecentsComponent|hideRecents]");
        }

        if (mBootCompleted) {
        if (mBootCompleted) {
            if (isRecentsTopMost(getTopMostTask(), null)) {
            if (isRecentsTopMost(getTopMostTask(), null)) {
                // Notify recents to hide itself
                // Notify recents to hide itself
@@ -139,13 +128,6 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta


    /** Toggles the alternate recents activity */
    /** Toggles the alternate recents activity */
    public void onToggleRecents(View statusBarView) {
    public void onToggleRecents(View statusBarView) {
        if (Console.Enabled) {
            Console.logStartTracingTime(Constants.Log.App.TimeRecentsStartup,
                    Constants.Log.App.TimeRecentsStartupKey);
            Console.logStartTracingTime(Constants.Log.App.TimeRecentsLaunchTask,
                    Constants.Log.App.TimeRecentsLaunchKey);
            Console.log(Constants.Log.App.RecentsComponent, "[RecentsComponent|toggleRecents]", "");
        }
        mStatusBarView = statusBarView;
        mStatusBarView = statusBarView;
        mTriggeredFromAltTab = false;
        mTriggeredFromAltTab = false;


@@ -223,14 +205,6 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
            intent.setPackage(mContext.getPackageName());
            intent.setPackage(mContext.getPackageName());
            intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
            intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
            mContext.sendBroadcast(intent);
            mContext.sendBroadcast(intent);

            // Time this path
            if (Console.Enabled) {
                Console.logTraceTime(Constants.Log.App.TimeRecentsStartup,
                        Constants.Log.App.TimeRecentsStartupKey, "receivedToggleRecents");
                Console.logTraceTime(Constants.Log.App.TimeRecentsLaunchTask,
                        Constants.Log.App.TimeRecentsLaunchKey, "receivedToggleRecents");
            }
            mLastToggleTime = System.currentTimeMillis();
            mLastToggleTime = System.currentTimeMillis();
            return;
            return;
        } else {
        } else {
@@ -395,11 +369,6 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
                startAlternateRecentsActivity(topTask, opts, null);
                startAlternateRecentsActivity(topTask, opts, null);
            }
            }
        }
        }

        if (Console.Enabled) {
            Console.logTraceTime(Constants.Log.App.TimeRecentsStartup,
                    Constants.Log.App.TimeRecentsStartupKey, "startRecentsActivity");
        }
        mLastToggleTime = System.currentTimeMillis();
        mLastToggleTime = System.currentTimeMillis();
    }
    }


@@ -417,10 +386,9 @@ public class AlternateRecentsComponent implements ActivityOptions.OnAnimationSta
        intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, mTriggeredFromAltTab);
        intent.putExtra(EXTRA_TRIGGERED_FROM_ALT_TAB, mTriggeredFromAltTab);
        intent.putExtra(EXTRA_TRIGGERED_FROM_TASK_ID, (topTask != null) ? topTask.id : -1);
        intent.putExtra(EXTRA_TRIGGERED_FROM_TASK_ID, (topTask != null) ? topTask.id : -1);
        if (opts != null) {
        if (opts != null) {
            mContext.startActivityAsUser(intent, opts.toBundle(), new UserHandle(
            mContext.startActivityAsUser(intent, opts.toBundle(), UserHandle.CURRENT);
                    UserHandle.USER_CURRENT));
        } else {
        } else {
            mContext.startActivityAsUser(intent, new UserHandle(UserHandle.USER_CURRENT));
            mContext.startActivityAsUser(intent, UserHandle.CURRENT);
        }
        }
    }
    }


+0 −37
Original line number Original line Diff line number Diff line
@@ -52,43 +52,6 @@ public class Constants {
        }
        }
    }
    }


    public static class Log {
        public static class App {
            public static final String TimeRecentsStartupKey = "startup";
            public static final String TimeRecentsLaunchKey = "launchTask";
            public static final String TimeRecentsScreenshotTransitionKey = "screenshot";
            public static final boolean TimeRecentsStartup = false;
            public static final boolean TimeRecentsLaunchTask = false;
            public static final boolean TimeRecentsScreenshotTransition = false;


            public static final boolean RecentsComponent = false;
            public static final boolean TaskDataLoader = false;
            public static final boolean SystemUIHandshake = false;
            public static final boolean TimeSystemCalls = false;
            public static final boolean Memory = false;
            public static final boolean Search = false;
        }

        public static class UI {
            public static final boolean Draw = false;
            public static final boolean ClickEvents = false;
            public static final boolean TouchEvents = false;
            public static final boolean MeasureAndLayout = false;
            public static final boolean HwLayers = false;
            public static final boolean Focus = false;
        }

        public static class TaskStack {
            public static final boolean SynchronizeViewsWithModel = false;
        }

        public static class ViewPool {
            public static final boolean PoolCallbacks = false;
        }
    }

    /** XXX: We are going to move almost all of these into a resource once they are nailed down. */
    public static class Values {
    public static class Values {
        public static class App {
        public static class App {
            public static int AppWidgetHostId = 1024;
            public static int AppWidgetHostId = 1024;
+100 −179

File changed.

Preview size limit exceeded, changes collapsed.

+7 −0
Original line number Original line Diff line number Diff line
@@ -33,6 +33,7 @@ public class RecentsAppWidgetHost extends AppWidgetHost {
    Context mContext;
    Context mContext;
    RecentsAppWidgetHostCallbacks mCb;
    RecentsAppWidgetHostCallbacks mCb;
    RecentsConfiguration mConfig;
    RecentsConfiguration mConfig;
    boolean mIsListening;


    public RecentsAppWidgetHost(Context context, int hostId) {
    public RecentsAppWidgetHost(Context context, int hostId) {
        super(context, hostId);
        super(context, hostId);
@@ -42,6 +43,7 @@ public class RecentsAppWidgetHost extends AppWidgetHost {


    public void startListening(RecentsAppWidgetHostCallbacks cb) {
    public void startListening(RecentsAppWidgetHostCallbacks cb) {
        mCb = cb;
        mCb = cb;
        mIsListening = true;
        super.startListening();
        super.startListening();
    }
    }


@@ -51,6 +53,11 @@ public class RecentsAppWidgetHost extends AppWidgetHost {
        // Ensure that we release any references to the callbacks
        // Ensure that we release any references to the callbacks
        mCb = null;
        mCb = null;
        mContext = null;
        mContext = null;
        mIsListening = false;
    }

    public boolean isListening() {
        return mIsListening;
    }
    }


    @Override
    @Override
+7 −10
Original line number Original line Diff line number Diff line
@@ -35,6 +35,7 @@ import com.android.systemui.recents.misc.Console;
 * NOTE: We should not hold any references to a Context from a static instance */
 * NOTE: We should not hold any references to a Context from a static instance */
public class RecentsConfiguration {
public class RecentsConfiguration {
    static RecentsConfiguration sInstance;
    static RecentsConfiguration sInstance;
    static int sPrevConfigurationHashCode;


    DisplayMetrics mDisplayMetrics;
    DisplayMetrics mDisplayMetrics;


@@ -138,7 +139,11 @@ public class RecentsConfiguration {
        if (sInstance == null) {
        if (sInstance == null) {
            sInstance = new RecentsConfiguration(context);
            sInstance = new RecentsConfiguration(context);
        }
        }
        int configHashCode = context.getResources().getConfiguration().hashCode();
        if (sPrevConfigurationHashCode != configHashCode) {
            sInstance.update(context);
            sInstance.update(context);
            sPrevConfigurationHashCode = configHashCode;
        }
        return sInstance;
        return sInstance;
    }
    }


@@ -179,10 +184,8 @@ public class RecentsConfiguration {
        transposeRecentsLayoutWithOrientation =
        transposeRecentsLayoutWithOrientation =
                res.getBoolean(R.bool.recents_transpose_layout_with_orientation);
                res.getBoolean(R.bool.recents_transpose_layout_with_orientation);


        // Search bar
        // Search Bar
        searchBarSpaceHeightPx = res.getDimensionPixelSize(R.dimen.recents_search_bar_space_height);
        searchBarSpaceHeightPx = res.getDimensionPixelSize(R.dimen.recents_search_bar_space_height);

        // Update the search widget id
        searchBarAppWidgetId = settings.getInt(Constants.Values.App.Key_SearchAppWidgetId, -1);
        searchBarAppWidgetId = settings.getInt(Constants.Values.App.Key_SearchAppWidgetId, -1);


        // Task stack
        // Task stack
@@ -242,12 +245,6 @@ public class RecentsConfiguration {
        // Nav bar scrim
        // Nav bar scrim
        navBarScrimEnterDuration =
        navBarScrimEnterDuration =
                res.getInteger(R.integer.recents_nav_bar_scrim_enter_duration);
                res.getInteger(R.integer.recents_nav_bar_scrim_enter_duration);

        if (Console.Enabled) {
            Console.log(Constants.Log.UI.MeasureAndLayout,
                    "[RecentsConfiguration|orientation]", isLandscape ? "Landscape" : "Portrait",
                    Console.AnsiGreen);
        }
    }
    }


    /** Updates the system insets */
    /** Updates the system insets */
Loading