mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-02-11 06:44:00 +00:00
Adding new tracing call from SysUI
Bug: 144854916 Test: This change is only to ensure the changes build Change-Id: I62b247b45454861328b6062ed571c854a374aa34
This commit is contained in:
31
protos/launcher_trace.proto
Normal file
31
protos/launcher_trace.proto
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.
|
||||
*/
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
package com.android.launcher3.tracing;
|
||||
|
||||
option java_multiple_files = true;
|
||||
|
||||
message LauncherTraceProto {
|
||||
|
||||
optional TouchInteractionServiceProto touch_interaction_service = 1;
|
||||
}
|
||||
|
||||
message TouchInteractionServiceProto {
|
||||
|
||||
optional bool service_connected = 1;
|
||||
}
|
||||
49
protos/launcher_trace_file.proto
Normal file
49
protos/launcher_trace_file.proto
Normal file
@@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.
|
||||
*/
|
||||
|
||||
syntax = "proto2";
|
||||
|
||||
import "launcher_trace.proto";
|
||||
|
||||
package com.android.launcher3.tracing;
|
||||
|
||||
option java_multiple_files = true;
|
||||
|
||||
/* represents a file full of launcher trace entries.
|
||||
Encoded, it should start with 0x9 0x4C 0x4E 0x43 0x48 0x52 0x54 0x52 0x43 (.LNCHRTRC), such
|
||||
that they can be easily identified. */
|
||||
message LauncherTraceFileProto {
|
||||
|
||||
/* constant; MAGIC_NUMBER = (long) MAGIC_NUMBER_H << 32 | MagicNumber.MAGIC_NUMBER_L
|
||||
(this is needed because enums have to be 32 bits and there's no nice way to put 64bit
|
||||
constants into .proto files. */
|
||||
enum MagicNumber {
|
||||
INVALID = 0;
|
||||
MAGIC_NUMBER_L = 0x48434E4C; /* LNCH (little-endian ASCII) */
|
||||
MAGIC_NUMBER_H = 0x43525452; /* RTRC (little-endian ASCII) */
|
||||
}
|
||||
|
||||
optional fixed64 magic_number = 1; /* Must be the first field, set to value in MagicNumber */
|
||||
repeated LauncherTraceEntryProto entry = 2;
|
||||
}
|
||||
|
||||
/* one launcher trace entry. */
|
||||
message LauncherTraceEntryProto {
|
||||
/* required: elapsed realtime in nanos since boot of when this entry was logged */
|
||||
optional fixed64 elapsed_realtime_nanos = 1;
|
||||
|
||||
optional LauncherTraceProto launcher = 3;
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
|
||||
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_INPUT_MONITOR;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SYSUI_PROXY;
|
||||
import static com.android.systemui.shared.system.QuickStepContract.SYSUI_STATE_TRACING_ENABLED;
|
||||
import static com.android.systemui.shared.system.RemoteAnimationTargetCompat.ACTIVITY_TYPE_ASSISTANT;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
@@ -61,6 +62,8 @@ import com.android.launcher3.logging.UserEventDispatcher;
|
||||
import com.android.launcher3.model.AppLaunchTracker;
|
||||
import com.android.launcher3.provider.RestoreDbTask;
|
||||
import com.android.launcher3.testing.TestProtocol;
|
||||
import com.android.launcher3.tracing.nano.LauncherTraceProto;
|
||||
import com.android.launcher3.tracing.nano.TouchInteractionServiceProto;
|
||||
import com.android.launcher3.uioverrides.plugins.PluginManagerWrapper;
|
||||
import com.android.launcher3.util.TraceHelper;
|
||||
import com.android.quickstep.inputconsumers.AccessibilityInputConsumer;
|
||||
@@ -74,6 +77,7 @@ import com.android.quickstep.inputconsumers.ResetGestureInputConsumer;
|
||||
import com.android.quickstep.inputconsumers.ScreenPinnedInputConsumer;
|
||||
import com.android.quickstep.util.ActiveGestureLog;
|
||||
import com.android.quickstep.util.AssistantUtilities;
|
||||
import com.android.quickstep.util.ProtoTracer;
|
||||
import com.android.systemui.plugins.OverscrollPlugin;
|
||||
import com.android.systemui.plugins.PluginListener;
|
||||
import com.android.systemui.shared.recents.IOverviewProxy;
|
||||
@@ -83,6 +87,7 @@ import com.android.systemui.shared.system.InputChannelCompat.InputEventReceiver;
|
||||
import com.android.systemui.shared.system.InputConsumerController;
|
||||
import com.android.systemui.shared.system.InputMonitorCompat;
|
||||
import com.android.systemui.shared.system.RecentsAnimationListener;
|
||||
import com.android.systemui.shared.tracing.ProtoTraceable;
|
||||
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
@@ -111,7 +116,8 @@ class ArgList extends LinkedList<String> {
|
||||
* Service connected by system-UI for handling touch interaction.
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.Q)
|
||||
public class TouchInteractionService extends Service implements PluginListener<OverscrollPlugin> {
|
||||
public class TouchInteractionService extends Service implements PluginListener<OverscrollPlugin>,
|
||||
ProtoTraceable<LauncherTraceProto> {
|
||||
|
||||
private static final String TAG = "TouchInteractionService";
|
||||
|
||||
@@ -272,6 +278,7 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||
mDeviceState = new RecentsAnimationDeviceState(this);
|
||||
mDeviceState.addNavigationModeChangedCallback(this::onNavigationModeChanged);
|
||||
mDeviceState.runOnUserUnlocked(this::onUserUnlocked);
|
||||
ProtoTracer.INSTANCE.get(this).add(this);
|
||||
|
||||
sConnected = true;
|
||||
}
|
||||
@@ -378,6 +385,13 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||
SystemUiProxy.INSTANCE.get(this).setLastSystemUiStateFlags(
|
||||
mDeviceState.getSystemUiStateFlags());
|
||||
mOverviewComponentObserver.onSystemUiStateChanged();
|
||||
|
||||
// Update the tracing state
|
||||
if ((mDeviceState.getSystemUiStateFlags() & SYSUI_STATE_TRACING_ENABLED) != 0) {
|
||||
ProtoTracer.INSTANCE.get(TouchInteractionService.this).start();
|
||||
} else {
|
||||
ProtoTracer.INSTANCE.get(TouchInteractionService.this).stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -400,6 +414,8 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||
disposeEventHandlers();
|
||||
mDeviceState.destroy();
|
||||
SystemUiProxy.INSTANCE.get(this).setProxy(null);
|
||||
ProtoTracer.INSTANCE.get(TouchInteractionService.this).stop();
|
||||
ProtoTracer.INSTANCE.get(this).remove(this);
|
||||
|
||||
sConnected = false;
|
||||
super.onDestroy();
|
||||
@@ -718,6 +734,9 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||
pw.println(" ENABLE_HINTS_IN_OVERVIEW=" + ENABLE_HINTS_IN_OVERVIEW.get());
|
||||
pw.println(" FAKE_LANDSCAPE_UI=" + FAKE_LANDSCAPE_UI.get());
|
||||
ActiveGestureLog.INSTANCE.dump("", pw);
|
||||
pw.println("ProtoTrace:");
|
||||
pw.println(" file="
|
||||
+ ProtoTracer.INSTANCE.get(TouchInteractionService.this).getTraceFile());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -776,4 +795,13 @@ public class TouchInteractionService extends Service implements PluginListener<O
|
||||
public void onPluginDisconnected(OverscrollPlugin overscrollPlugin) {
|
||||
mOverscrollPlugin = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToProto(LauncherTraceProto proto) {
|
||||
if (proto.touchInteractionService == null) {
|
||||
proto.touchInteractionService = new TouchInteractionServiceProto();
|
||||
}
|
||||
proto.touchInteractionService.serviceConnected = true;
|
||||
proto.touchInteractionService.serviceConnected = true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.
|
||||
*/
|
||||
|
||||
package com.android.quickstep.util;
|
||||
|
||||
import static com.android.launcher3.tracing.nano.LauncherTraceFileProto.MagicNumber.MAGIC_NUMBER_H;
|
||||
import static com.android.launcher3.tracing.nano.LauncherTraceFileProto.MagicNumber.MAGIC_NUMBER_L;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.SystemClock;
|
||||
|
||||
import com.android.launcher3.tracing.nano.LauncherTraceProto;
|
||||
import com.android.launcher3.tracing.nano.LauncherTraceEntryProto;
|
||||
import com.android.launcher3.tracing.nano.LauncherTraceFileProto;
|
||||
import com.android.launcher3.util.MainThreadInitializedObject;
|
||||
import com.android.systemui.shared.tracing.FrameProtoTracer;
|
||||
import com.android.systemui.shared.tracing.FrameProtoTracer.ProtoTraceParams;
|
||||
import com.android.systemui.shared.tracing.ProtoTraceable;
|
||||
import com.google.protobuf.nano.MessageNano;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.PrintWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Queue;
|
||||
|
||||
|
||||
/**
|
||||
* Controller for coordinating winscope proto tracing.
|
||||
*/
|
||||
public class ProtoTracer implements ProtoTraceParams<MessageNano,
|
||||
LauncherTraceFileProto, LauncherTraceEntryProto, LauncherTraceProto> {
|
||||
|
||||
public static final MainThreadInitializedObject<ProtoTracer> INSTANCE =
|
||||
new MainThreadInitializedObject<>(ProtoTracer::new);
|
||||
|
||||
private static final String TAG = "ProtoTracer";
|
||||
private static final long MAGIC_NUMBER_VALUE = ((long) MAGIC_NUMBER_H << 32) | MAGIC_NUMBER_L;
|
||||
|
||||
private final Context mContext;
|
||||
private final FrameProtoTracer<MessageNano,
|
||||
LauncherTraceFileProto, LauncherTraceEntryProto, LauncherTraceProto> mProtoTracer;
|
||||
|
||||
public ProtoTracer(Context context) {
|
||||
mContext = context;
|
||||
mProtoTracer = new FrameProtoTracer<>(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public File getTraceFile() {
|
||||
return new File(mContext.getFilesDir(), "launcher_trace.pb");
|
||||
}
|
||||
|
||||
@Override
|
||||
public LauncherTraceFileProto getEncapsulatingTraceProto() {
|
||||
return new LauncherTraceFileProto();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LauncherTraceEntryProto updateBufferProto(LauncherTraceEntryProto reuseObj,
|
||||
ArrayList<ProtoTraceable<LauncherTraceProto>> traceables) {
|
||||
LauncherTraceEntryProto proto = reuseObj != null
|
||||
? reuseObj
|
||||
: new LauncherTraceEntryProto();
|
||||
proto.elapsedRealtimeNanos = SystemClock.elapsedRealtimeNanos();
|
||||
proto.launcher = proto.launcher != null ? proto.launcher : new LauncherTraceProto();
|
||||
for (ProtoTraceable t : traceables) {
|
||||
t.writeToProto(proto.launcher);
|
||||
}
|
||||
return proto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] serializeEncapsulatingProto(LauncherTraceFileProto encapsulatingProto,
|
||||
Queue<LauncherTraceEntryProto> buffer) {
|
||||
encapsulatingProto.magicNumber = MAGIC_NUMBER_VALUE;
|
||||
encapsulatingProto.entry = buffer.toArray(new LauncherTraceEntryProto[0]);
|
||||
return MessageNano.toByteArray(encapsulatingProto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] getProtoBytes(MessageNano proto) {
|
||||
return MessageNano.toByteArray(proto);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtoSize(MessageNano proto) {
|
||||
return proto.getCachedSize();
|
||||
}
|
||||
|
||||
public void start() {
|
||||
mProtoTracer.start();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
mProtoTracer.stop();
|
||||
}
|
||||
|
||||
public void add(ProtoTraceable<LauncherTraceProto> traceable) {
|
||||
mProtoTracer.add(traceable);
|
||||
}
|
||||
|
||||
public void remove(ProtoTraceable<LauncherTraceProto> traceable) {
|
||||
mProtoTracer.remove(traceable);
|
||||
}
|
||||
|
||||
public void scheduleFrameUpdate() {
|
||||
mProtoTracer.scheduleFrameUpdate();
|
||||
}
|
||||
|
||||
public void update() {
|
||||
mProtoTracer.update();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user