Merge "Check if tracing is on before generating strings" into tm-qpr-dev

This commit is contained in:
Peter Kalauskas
2022-11-03 15:34:33 +00:00
committed by Android (Google) Code Review
5 changed files with 60 additions and 21 deletions

View File

@@ -291,8 +291,10 @@ public class KeyButtonRipple extends Drawable {
} }
private void endAnimations(String reason, boolean cancel) { private void endAnimations(String reason, boolean cancel) {
Trace.beginSection("KeyButtonRipple.endAnim: reason=" + reason + " cancel=" + cancel); if (Trace.isEnabled()) {
Trace.endSection(); Trace.instant(Trace.TRACE_TAG_APP,
"KeyButtonRipple.endAnim: reason=" + reason + " cancel=" + cancel);
}
mVisible = false; mVisible = false;
mTmpArray.addAll(mRunningAnimations); mTmpArray.addAll(mRunningAnimations);
int size = mTmpArray.size(); int size = mTmpArray.size();
@@ -502,20 +504,23 @@ public class KeyButtonRipple extends Drawable {
@Override @Override
public void onAnimationStart(Animator animation) { public void onAnimationStart(Animator animation) {
Trace.beginSection("KeyButtonRipple.start." + mName); if (Trace.isEnabled()) {
Trace.endSection(); Trace.instant(Trace.TRACE_TAG_APP, "KeyButtonRipple.start." + mName);
}
} }
@Override @Override
public void onAnimationCancel(Animator animation) { public void onAnimationCancel(Animator animation) {
Trace.beginSection("KeyButtonRipple.cancel." + mName); if (Trace.isEnabled()) {
Trace.endSection(); Trace.instant(Trace.TRACE_TAG_APP, "KeyButtonRipple.cancel." + mName);
}
} }
@Override @Override
public void onAnimationEnd(Animator animation) { public void onAnimationEnd(Animator animation) {
Trace.beginSection("KeyButtonRipple.end." + mName); if (Trace.isEnabled()) {
Trace.endSection(); Trace.instant(Trace.TRACE_TAG_APP, "KeyButtonRipple.end." + mName);
}
} }
} }

View File

@@ -278,7 +278,11 @@ public class SystemUIApplication extends Application implements
} }
private static void notifyBootCompleted(CoreStartable coreStartable) { private static void notifyBootCompleted(CoreStartable coreStartable) {
Trace.beginSection(coreStartable.getClass().getSimpleName() + ".onBootCompleted()"); if (Trace.isEnabled()) {
Trace.traceBegin(
Trace.TRACE_TAG_APP,
coreStartable.getClass().getSimpleName() + ".onBootCompleted()");
}
coreStartable.onBootCompleted(); coreStartable.onBootCompleted();
Trace.endSection(); Trace.endSection();
} }
@@ -300,14 +304,18 @@ public class SystemUIApplication extends Application implements
private static CoreStartable startAdditionalStartable(String clsName) { private static CoreStartable startAdditionalStartable(String clsName) {
CoreStartable startable; CoreStartable startable;
if (DEBUG) Log.d(TAG, "loading: " + clsName); if (DEBUG) Log.d(TAG, "loading: " + clsName);
if (Trace.isEnabled()) {
Trace.traceBegin(
Trace.TRACE_TAG_APP, clsName + ".newInstance()");
}
try { try {
Trace.beginSection(clsName + ".newInstance()");
startable = (CoreStartable) Class.forName(clsName).newInstance(); startable = (CoreStartable) Class.forName(clsName).newInstance();
Trace.endSection();
} catch (ClassNotFoundException } catch (ClassNotFoundException
| IllegalAccessException | IllegalAccessException
| InstantiationException ex) { | InstantiationException ex) {
throw new RuntimeException(ex); throw new RuntimeException(ex);
} finally {
Trace.endSection();
} }
return startStartable(startable); return startStartable(startable);
@@ -315,7 +323,10 @@ public class SystemUIApplication extends Application implements
private static CoreStartable startStartable(String clsName, Provider<CoreStartable> provider) { private static CoreStartable startStartable(String clsName, Provider<CoreStartable> provider) {
if (DEBUG) Log.d(TAG, "loading: " + clsName); if (DEBUG) Log.d(TAG, "loading: " + clsName);
Trace.beginSection("Provider<" + clsName + ">.get()"); if (Trace.isEnabled()) {
Trace.traceBegin(
Trace.TRACE_TAG_APP, "Provider<" + clsName + ">.get()");
}
CoreStartable startable = provider.get(); CoreStartable startable = provider.get();
Trace.endSection(); Trace.endSection();
return startStartable(startable); return startStartable(startable);
@@ -323,7 +334,10 @@ public class SystemUIApplication extends Application implements
private static CoreStartable startStartable(CoreStartable startable) { private static CoreStartable startStartable(CoreStartable startable) {
if (DEBUG) Log.d(TAG, "running: " + startable); if (DEBUG) Log.d(TAG, "running: " + startable);
Trace.beginSection(startable.getClass().getSimpleName() + ".start()"); if (Trace.isEnabled()) {
Trace.traceBegin(
Trace.TRACE_TAG_APP, startable.getClass().getSimpleName() + ".start()");
}
startable.start(); startable.start();
Trace.endSection(); Trace.endSection();
@@ -364,15 +378,22 @@ public class SystemUIApplication extends Application implements
public void onConfigurationChanged(Configuration newConfig) { public void onConfigurationChanged(Configuration newConfig) {
if (mServicesStarted) { if (mServicesStarted) {
ConfigurationController configController = mSysUIComponent.getConfigurationController(); ConfigurationController configController = mSysUIComponent.getConfigurationController();
Trace.beginSection( if (Trace.isEnabled()) {
configController.getClass().getSimpleName() + ".onConfigurationChanged()"); Trace.traceBegin(
Trace.TRACE_TAG_APP,
configController.getClass().getSimpleName() + ".onConfigurationChanged()");
}
configController.onConfigurationChanged(newConfig); configController.onConfigurationChanged(newConfig);
Trace.endSection(); Trace.endSection();
int len = mServices.length; int len = mServices.length;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
if (mServices[i] != null) { if (mServices[i] != null) {
Trace.beginSection( if (Trace.isEnabled()) {
mServices[i].getClass().getSimpleName() + ".onConfigurationChanged()"); Trace.traceBegin(
Trace.TRACE_TAG_APP,
mServices[i].getClass().getSimpleName()
+ ".onConfigurationChanged()");
}
mServices[i].onConfigurationChanged(newConfig); mServices[i].onConfigurationChanged(newConfig);
Trace.endSection(); Trace.endSection();
} }

View File

@@ -127,7 +127,10 @@ open class UserBroadcastDispatcher(
action, action,
userId, userId,
{ {
Trace.beginSection("registerReceiver act=$action user=$userId") if (Trace.isEnabled()) {
Trace.traceBegin(
Trace.TRACE_TAG_APP, "registerReceiver act=$action user=$userId")
}
context.registerReceiverAsUser( context.registerReceiverAsUser(
this, this,
UserHandle.of(userId), UserHandle.of(userId),
@@ -141,7 +144,11 @@ open class UserBroadcastDispatcher(
}, },
{ {
try { try {
Trace.beginSection("unregisterReceiver act=$action user=$userId") if (Trace.isEnabled()) {
Trace.traceBegin(
Trace.TRACE_TAG_APP,
"unregisterReceiver act=$action user=$userId")
}
context.unregisterReceiver(this) context.unregisterReceiver(this)
Trace.endSection() Trace.endSection()
logger.logContextReceiverUnregistered(userId, action) logger.logContextReceiverUnregistered(userId, action)

View File

@@ -171,7 +171,10 @@ public class DozeScreenBrightness extends BroadcastReceiver implements DozeMachi
@Override @Override
public void onSensorChanged(SensorEvent event) { public void onSensorChanged(SensorEvent event) {
Trace.beginSection("DozeScreenBrightness.onSensorChanged" + event.values[0]); if (Trace.isEnabled()) {
Trace.traceBegin(
Trace.TRACE_TAG_APP, "DozeScreenBrightness.onSensorChanged" + event.values[0]);
}
try { try {
if (mRegistered) { if (mRegistered) {
mLastSensorValue = (int) event.values[0]; mLastSensorValue = (int) event.values[0];

View File

@@ -118,7 +118,10 @@ public final class DeviceStateRotationLockSettingController
private void updateDeviceState(int state) { private void updateDeviceState(int state) {
Log.v(TAG, "updateDeviceState [state=" + state + "]"); Log.v(TAG, "updateDeviceState [state=" + state + "]");
Trace.beginSection("updateDeviceState [state=" + state + "]"); if (Trace.isEnabled()) {
Trace.traceBegin(
Trace.TRACE_TAG_APP, "updateDeviceState [state=" + state + "]");
}
try { try {
if (mDeviceState == state) { if (mDeviceState == state) {
return; return;