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

Commit a206e580 authored by Vishnu Nair's avatar Vishnu Nair Committed by Android (Google) Code Review
Browse files

Merge "Simplify Window/Surface trace by using one QS Tile"

parents d8073139 74100b3a
Loading
Loading
Loading
Loading
+3 −13
Original line number Diff line number Diff line
@@ -3213,19 +3213,9 @@
            </intent-filter>
        </service>
        <service
            android:name=".development.qstile.DevelopmentTiles$WindowTrace"
            android:label="@string/window_trace_quick_settings_title"
            android:icon="@drawable/tile_icon_window_trace"
            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
            android:enabled="false">
            <intent-filter>
                <action android:name="android.service.quicksettings.action.QS_TILE" />
            </intent-filter>
        </service>
        <service
            android:name=".development.qstile.DevelopmentTiles$LayerTrace"
            android:label="@string/layer_trace_quick_settings_title"
            android:icon="@drawable/tile_icon_layer_trace"
            android:name=".development.qstile.DevelopmentTiles$WinscopeTrace"
            android:label="@string/winscope_trace_quick_settings_title"
            android:icon="@drawable/tile_icon_winscope_trace"
            android:permission="android.permission.BIND_QUICK_SETTINGS_TILE"
            android:enabled="false">
            <intent-filter>
+0 −29
Original line number Diff line number Diff line
<!--
    Copyright (C) 2018 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:width="24dp"
        android:height="24dp"
        android:viewportWidth="24.0"
        android:viewportHeight="24.0"
        android:tint="?android:attr/colorControlNormal">
    <path
        android:pathData="M11.709,11.712 L7.061,8.098 6.039,8.893l5.676,4.415 5.676,-4.415 -1.028,-0.801zM11.716,10.11 L16.357,6.496 17.392,5.695 11.716,1.281 6.039,5.695 7.067,6.496Z"
        android:fillColor="#FFFFFFFF"/>
    <path
        android:pathData="m20.27,15.235c0,0.82 -0.671,1.491 -1.491,1.491 -0.134,0 -0.261,-0.015 -0.38,-0.052l-2.654,2.646C15.782,19.439 15.797,19.573 15.797,19.708c0,0.82 -0.671,1.491 -1.491,1.491 -0.82,0 -1.491,-0.671 -1.491,-1.491 0,-0.134 0.015,-0.268 0.052,-0.388L10.966,17.419C10.847,17.456 10.713,17.471 10.579,17.471 10.444,17.471 10.31,17.456 10.191,17.419L6.799,20.818C6.836,20.938 6.851,21.064 6.851,21.199 6.851,22.019 6.18,22.689 5.36,22.689 4.54,22.689 3.869,22.019 3.869,21.199c0,-0.82 0.671,-1.491 1.491,-1.491 0.134,0 0.261,0.015 0.38,0.052L9.14,16.368C9.103,16.249 9.088,16.114 9.088,15.98 9.088,15.16 9.759,14.489 10.579,14.489c0.82,0 1.491,0.671 1.491,1.491 0,0.134 -0.015,0.268 -0.052,0.388l1.901,1.901C14.038,18.232 14.172,18.217 14.306,18.217c0.134,0 0.268,0.015 0.388,0.052L17.34,15.615C17.303,15.496 17.288,15.369 17.288,15.235c0,-0.82 0.671,-1.491 1.491,-1.491 0.82,0 1.491,0.671 1.491,1.491z"
        android:fillColor="#FFFFFFFF"/>
</vector>
+2 −5
Original line number Diff line number Diff line
@@ -8898,11 +8898,8 @@
    <!-- [CHAR LIMIT=60] Name of dev option to enable extra quick settings tiles -->
    <string name="quick_settings_developer_tiles">Quick settings developer tiles</string>
    <!-- [CHAR LIMIT=25] Title of developer tile to toggle window trace -->
    <string name="window_trace_quick_settings_title">Window Trace</string>
    <!-- [CHAR LIMIT=25] Title of developer tile to toggle layer trace -->
    <string name="layer_trace_quick_settings_title">Surface Trace</string>
    <!-- [CHAR LIMIT=25] Title of developer tile to toggle winscope trace -->
    <string name="winscope_trace_quick_settings_title">Winscope Trace</string>
    <!-- Template for formatting country and language. eg Canada - French [CHAR LIMIT=NONE]-->
    <string name="support_country_format"><xliff:g id="country" example="Canada">%1$s</xliff:g> - <xliff:g id="language" example="French">%2$s</xliff:g></string>
+41 −54
Original line number Diff line number Diff line
@@ -142,26 +142,29 @@ public abstract class DevelopmentTiles extends TileService {
    }

    /**
     * Tile to toggle Window Trace.
     * Tile to toggle Winscope trace which consists of Window and Layer traces.
     */
    public static class WindowTrace extends DevelopmentTiles {
    public static class WinscopeTrace extends DevelopmentTiles {
        @VisibleForTesting
        IWindowManagerWrapper mWindowManager;
        static final int SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE = 1025;
        @VisibleForTesting
        Toast mToast;
        static final int SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE = 1026;
        private IBinder mSurfaceFlinger;
        private IWindowManagerWrapper mWindowManager;
        private Toast mToast;

        @Override
        public void onCreate() {
            super.onCreate();
            mWindowManager = new IWindowManagerWrapper(WindowManagerGlobal
                    .getWindowManagerService());
            mSurfaceFlinger = ServiceManager.getService("SurfaceFlinger");
            Context context = getApplicationContext();
            CharSequence text = "Trace written to /data/misc/wmtrace/wm_trace.pb";
            CharSequence text = "Trace files written to /data/misc/wmtrace";
            mToast = Toast.makeText(context, text, Toast.LENGTH_LONG);
        }

        @Override
        protected boolean isEnabled() {
        private boolean isWindowTraceEnabled() {
            try {
                return mWindowManager.isWindowTraceEnabled();
            } catch (RemoteException e) {
@@ -171,46 +174,8 @@ public abstract class DevelopmentTiles extends TileService {
            return false;
        }

        @Override
        protected void setIsEnabled(boolean isEnabled) {
            try {
                if (isEnabled) {
                    mWindowManager.startWindowTrace();
                } else {
                    mWindowManager.stopWindowTrace();
                    mToast.show();
                }
            } catch (RemoteException e) {
                Log.e(TAG, "Could not set window trace status." + e.toString());
            }
        }
    }

    /**
     * Tile to toggle Layer Trace.
     */
    public static class LayerTrace extends DevelopmentTiles {
        @VisibleForTesting
        static final int SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE = 1025;
        @VisibleForTesting
        static final int SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE = 1026;
        @VisibleForTesting
        IBinder mSurfaceFlinger;
        @VisibleForTesting
        Toast mToast;

        @Override
        public void onCreate() {
            super.onCreate();
            mSurfaceFlinger = ServiceManager.getService("SurfaceFlinger");
            Context context = getApplicationContext();
            CharSequence text = "Trace written to /data/misc/wmtrace/layers_trace.pb";
            mToast = Toast.makeText(context, text, Toast.LENGTH_LONG);
        }

        @Override
        protected boolean isEnabled() {
            boolean surfaceTraceEnabled = false;
        private boolean isLayerTraceEnabled() {
            boolean layerTraceEnabled = false;
            Parcel reply = null;
            Parcel data = null;
            try {
@@ -220,7 +185,7 @@ public abstract class DevelopmentTiles extends TileService {
                    data.writeInterfaceToken("android.ui.ISurfaceComposer");
                    mSurfaceFlinger.transact(SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE,
                            data, reply, 0 /* flags */);
                    surfaceTraceEnabled = reply.readBoolean();
                    layerTraceEnabled = reply.readBoolean();
                }
            } catch (RemoteException e) {
                Log.e(TAG, "Could not get layer trace status, defaulting to false." + e.toString());
@@ -230,11 +195,27 @@ public abstract class DevelopmentTiles extends TileService {
                    reply.recycle();
                }
            }
            return surfaceTraceEnabled;
            return layerTraceEnabled;
        }

        @Override
        protected void setIsEnabled(boolean isEnabled) {
        protected boolean isEnabled() {
            return isWindowTraceEnabled() || isLayerTraceEnabled();
        }

        private void setWindowTraceEnabled(boolean isEnabled) {
            try {
                if (isEnabled) {
                    mWindowManager.startWindowTrace();
                } else {
                    mWindowManager.stopWindowTrace();
                }
            } catch (RemoteException e) {
                Log.e(TAG, "Could not set window trace status." + e.toString());
            }
        }

        private void setLayerTraceEnabled(boolean isEnabled) {
            Parcel data = null;
            try {
                if (mSurfaceFlinger != null) {
@@ -243,9 +224,6 @@ public abstract class DevelopmentTiles extends TileService {
                    data.writeInt(isEnabled ? 1 : 0);
                    mSurfaceFlinger.transact(SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE,
                            data, null, 0 /* flags */);
                    if (!isEnabled){
                        mToast.show();
                    }
                }
            } catch (RemoteException e) {
                Log.e(TAG, "Could not set layer tracing." + e.toString());
@@ -255,5 +233,14 @@ public abstract class DevelopmentTiles extends TileService {
                }
            }
        }

        @Override
        protected void setIsEnabled(boolean isEnabled) {
            setWindowTraceEnabled(isEnabled);
            setLayerTraceEnabled(isEnabled);
            if (!isEnabled) {
                mToast.show();
            }
        }
    }
}
 No newline at end of file
Loading