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

Commit 7bb18852 authored by Winson Chung's avatar Winson Chung Committed by Android (Google) Code Review
Browse files

Merge "Wrapping console logs."

parents 430259a1 10f8139d
Loading
Loading
Loading
Loading
+32 −18
Original line number Diff line number Diff line
@@ -64,10 +64,12 @@ public class AlternateRecentsComponent {
                mSingleCountFirstTaskRect.offset(0, (int) statusBarHeight);
                mMultipleCountFirstTaskRect = replyData.getParcelable(KEY_MULTIPLE_TASK_STACK_RECT);
                mMultipleCountFirstTaskRect.offset(0, (int) statusBarHeight);
                if (Console.Enabled) {
                    Console.log(Constants.Log.App.RecentsComponent,
                            "[RecentsComponent|RecentsMessageHandler|handleMessage]",
                            "singleTaskRect: " + mSingleCountFirstTaskRect +
                            " multipleTaskRect: " + mMultipleCountFirstTaskRect);
                }

                // If we had the update the animation rects as a result of onServiceConnected, then
                // we check for whether we need to toggle the recents here.
@@ -83,9 +85,11 @@ public class AlternateRecentsComponent {
    class RecentsServiceConnection implements ServiceConnection {
        @Override
        public void onServiceConnected(ComponentName className, IBinder service) {
            if (Console.Enabled) {
                Console.log(Constants.Log.App.RecentsComponent,
                        "[RecentsComponent|ServiceConnection|onServiceConnected]",
                        "toggleRecents: " + mToggleRecentsUponServiceBound);
            }
            mService = new Messenger(service);
            mServiceIsBound = true;

@@ -103,8 +107,10 @@ public class AlternateRecentsComponent {

        @Override
        public void onServiceDisconnected(ComponentName className) {
            if (Console.Enabled) {
                Console.log(Constants.Log.App.RecentsComponent,
                        "[RecentsComponent|ServiceConnection|onServiceDisconnected]");
            }
            mService = null;
            mServiceIsBound = false;
        }
@@ -159,7 +165,9 @@ public class AlternateRecentsComponent {
    }

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

        // Try to create a long-running connection to the recents service
        bindToRecentsService(false);
@@ -167,7 +175,9 @@ public class AlternateRecentsComponent {

    /** Shows the recents */
    public void onShowRecents(boolean triggeredFromAltTab, View statusBarView) {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.RecentsComponent, "[RecentsComponent|showRecents]");
        }
        mStatusBarView = statusBarView;
        mTriggeredFromAltTab = triggeredFromAltTab;
        if (!mServiceIsBound) {
@@ -186,7 +196,9 @@ public class AlternateRecentsComponent {

    /** Hides the recents */
    public void onHideRecents(boolean triggeredFromAltTab) {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.RecentsComponent, "[RecentsComponent|hideRecents]");
        }
        if (mServiceIsBound) {
            // Notify recents to close it
            try {
@@ -202,12 +214,14 @@ public class AlternateRecentsComponent {

    /** Toggles the alternate recents activity */
    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]",
                    "serviceIsBound: " + mServiceIsBound);
        }
        mStatusBarView = statusBarView;
        mTriggeredFromAltTab = false;
        if (!mServiceIsBound) {
+3 −0
Original line number Diff line number Diff line
@@ -42,6 +42,9 @@ public class Console {
    public static final String AnsiCyan = "\u001B[36m";     // ClickEvents
    public static final String AnsiWhite = "\u001B[37m";

    // Console enabled state
    public static final boolean Enabled = false;

    /** Logs a key */
    public static void log(String key) {
        log(true, key, "", AnsiReset);
+66 −40
Original line number Diff line number Diff line
@@ -80,8 +80,10 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        @Override
        public void onReceive(Context context, Intent intent) {
            String action = intent.getAction();
            if (Console.Enabled) {
                Console.log(Constants.Log.App.SystemUIHandshake,
                        "[RecentsActivity|serviceBroadcast]", action, Console.AnsiRed);
            }
            if (action.equals(RecentsService.ACTION_HIDE_RECENTS_ACTIVITY)) {
                if (intent.getBooleanExtra(RecentsService.EXTRA_TRIGGERED_FROM_ALT_TAB, false)) {
                    // Dismiss recents, launching the focused task
@@ -164,21 +166,25 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
                    ssp.unbindSearchAppWidget(mAppWidgetHost, appWidgetId);
                    appWidgetId = -1;
                }
                if (Console.Enabled) {
                    Console.log(Constants.Log.App.SystemUIHandshake,
                            "[RecentsActivity|onCreate|settings|appWidgetId]",
                            "Id: " + appWidgetId,
                            Console.AnsiBlue);
                }
            }

            // If there is no id, then bind a new search app widget
            if (appWidgetId < 0) {
                Pair<Integer, AppWidgetProviderInfo> widgetInfo =
                        ssp.bindSearchAppWidget(mAppWidgetHost);
                if (widgetInfo != null) {
                    if (Console.Enabled) {
                        Console.log(Constants.Log.App.SystemUIHandshake,
                                "[RecentsActivity|onCreate|searchWidget]",
                                "Id: " + widgetInfo.first + " Info: " + widgetInfo.second,
                                Console.AnsiBlue);
                    }

                    // Save the app widget id into the settings
                    config.updateSearchBarAppWidgetId(this, widgetInfo.first);
@@ -194,10 +200,12 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
            RecentsConfiguration config = RecentsConfiguration.getInstance();
            int appWidgetId = config.searchBarAppWidgetId;
            if (appWidgetId >= 0) {
                if (Console.Enabled) {
                    Console.log(Constants.Log.App.SystemUIHandshake,
                            "[RecentsActivity|onCreate|addSearchAppWidgetView]",
                            "Id: " + appWidgetId,
                            Console.AnsiBlue);
                }
                mSearchAppWidgetHostView = mAppWidgetHost.createView(this, appWidgetId,
                        mSearchAppWidgetInfo);
                Bundle opts = new Bundle();
@@ -230,11 +238,13 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (Console.Enabled) {
            Console.logDivider(Constants.Log.App.SystemUIHandshake);
            Console.log(Constants.Log.App.SystemUIHandshake, "[RecentsActivity|onCreate]",
                    getIntent().getAction() + " visible: " + mVisible, Console.AnsiRed);
            Console.logTraceTime(Constants.Log.App.TimeRecentsStartup,
                    Constants.Log.App.TimeRecentsStartupKey, "onCreate");
        }

        // Initialize the loader and the configuration
        RecentsTaskLoader.initialize(this);
@@ -277,11 +287,13 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView
        // Reset the task launched flag if we encounter an onNewIntent() before onStop()
        mTaskLaunched = false;

        if (Console.Enabled) {
            Console.logDivider(Constants.Log.App.SystemUIHandshake);
            Console.log(Constants.Log.App.SystemUIHandshake, "[RecentsActivity|onNewIntent]",
                    intent.getAction() + " visible: " + mVisible, Console.AnsiRed);
            Console.logTraceTime(Constants.Log.App.TimeRecentsStartup,
                    Constants.Log.App.TimeRecentsStartupKey, "onNewIntent");
        }

        // Initialize the loader and the configuration
        RecentsTaskLoader.initialize(this);
@@ -296,8 +308,10 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView

    @Override
    protected void onStart() {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.SystemUIHandshake, "[RecentsActivity|onStart]", "",
                    Console.AnsiRed);
        }
        super.onStart();
        mAppWidgetHost.startListening();
        mVisible = true;
@@ -305,16 +319,20 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView

    @Override
    protected void onResume() {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.SystemUIHandshake, "[RecentsActivity|onResume]", "",
                    Console.AnsiRed);
        }
        super.onResume();
    }

    @Override
    public void onAttachedToWindow() {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.SystemUIHandshake,
                    "[RecentsActivity|onAttachedToWindow]", "",
                    Console.AnsiRed);
        }
        super.onAttachedToWindow();

        // Register the broadcast receiver to handle messages from our service
@@ -334,9 +352,11 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView

    @Override
    public void onDetachedFromWindow() {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.SystemUIHandshake,
                    "[RecentsActivity|onDetachedFromWindow]", "",
                    Console.AnsiRed);
        }
        super.onDetachedFromWindow();

        // Unregister any broadcast receivers we have registered
@@ -347,15 +367,19 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView

    @Override
    protected void onPause() {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.SystemUIHandshake, "[RecentsActivity|onPause]", "",
                    Console.AnsiRed);
        }
        super.onPause();
    }

    @Override
    protected void onStop() {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.SystemUIHandshake, "[RecentsActivity|onStop]", "",
                    Console.AnsiRed);
        }
        super.onStop();

        mAppWidgetHost.stopListening();
@@ -365,8 +389,10 @@ public class RecentsActivity extends Activity implements RecentsView.RecentsView

    @Override
    protected void onDestroy() {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.SystemUIHandshake, "[RecentsActivity|onDestroy]", "",
                    Console.AnsiRed);
        }
        super.onDestroy();
    }

+5 −3
Original line number Diff line number Diff line
@@ -95,9 +95,11 @@ public class RecentsConfiguration {
                Configuration.ORIENTATION_LANDSCAPE;
        transposeSearchLayoutWithOrientation =
                res.getBoolean(R.bool.recents_transpose_search_layout_with_orientation);
        if (Console.Enabled) {
            Console.log(Constants.Log.UI.MeasureAndLayout,
                    "[RecentsConfiguration|orientation]", isLandscape ? "Landscape" : "Portrait",
                    Console.AnsiGreen);
        }

        displayRect.set(0, 0, dm.widthPixels, dm.heightPixels);
        animationPxMovementPerSecond =
+19 −7
Original line number Diff line number Diff line
@@ -45,8 +45,10 @@ class SystemUIMessageHandler extends Handler {

    @Override
    public void handleMessage(Message msg) {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.SystemUIHandshake,
                    "[RecentsService|handleMessage]", msg);
        }

        Context context = mContext.get();
        if (context == null) return;
@@ -139,31 +141,41 @@ public class RecentsService extends Service {

    @Override
    public void onCreate() {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.SystemUIHandshake, "[RecentsService|onCreate]");
        }
        super.onCreate();
    }

    @Override
    public IBinder onBind(Intent intent) {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.SystemUIHandshake, "[RecentsService|onBind]");
        }
        return mSystemUIMessenger.getBinder();
    }

    @Override
    public boolean onUnbind(Intent intent) {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.SystemUIHandshake, "[RecentsService|onUnbind]");
        }
        return super.onUnbind(intent);
    }

    @Override
    public void onRebind(Intent intent) {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.SystemUIHandshake, "[RecentsService|onRebind]");
        }
        super.onRebind(intent);
    }

    @Override
    public void onDestroy() {
        if (Console.Enabled) {
            Console.log(Constants.Log.App.SystemUIHandshake, "[RecentsService|onDestroy]");
        }
        super.onDestroy();
    }

Loading