Add IME tracing to data gathered in WinscopeTrace

This change starts and stops IME tracing together with the other traces
gathered when the WinscopeTrace tile is used. The data is saved along
the other traces in /data/misc/wmtrace/.

Bug: 154348613
Bug: 167948910
Test: flash a device together with the other change in this topic
      enable the WinscopeTrace tile and do some actions
      disable the WinscopeTrace tile
      do a bugreport and visualise contents in Winscope
      or just check contents of /data/misc/wmtrace/ through adb
Change-Id: If0b16dd5c19aa8bb33174abe2fe242fc8e6bdd90
This commit is contained in:
Ioana Stefan
2020-11-03 17:12:52 +00:00
parent f24dc017ef
commit a218bc05e6
2 changed files with 98 additions and 6 deletions

View File

@@ -49,6 +49,7 @@ import androidx.annotation.VisibleForTesting;
import com.android.internal.app.LocalePicker;
import com.android.internal.statusbar.IStatusBarService;
import com.android.internal.view.IInputMethodManager;
import com.android.settings.R;
import com.android.settings.development.WirelessDebuggingPreferenceController;
import com.android.settings.overlay.FeatureFactory;
@@ -197,6 +198,7 @@ public abstract class DevelopmentTiles extends TileService {
static final int SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE = 1026;
private IBinder mSurfaceFlinger;
private IWindowManager mWindowManager;
private IInputMethodManager mInputMethodManager;
private Toast mToast;
@Override
@@ -204,6 +206,8 @@ public abstract class DevelopmentTiles extends TileService {
super.onCreate();
mWindowManager = WindowManagerGlobal.getWindowManagerService();
mSurfaceFlinger = ServiceManager.getService("SurfaceFlinger");
mInputMethodManager = IInputMethodManager.Stub.asInterface(
ServiceManager.getService("input_method"));
Context context = getApplicationContext();
CharSequence text = "Trace files written to /data/misc/wmtrace";
mToast = Toast.makeText(context, text, Toast.LENGTH_LONG);
@@ -256,9 +260,19 @@ public abstract class DevelopmentTiles extends TileService {
return false;
}
private boolean isImeTraceEnabled() {
try {
return mInputMethodManager.isImeTraceEnabled();
} catch (RemoteException e) {
Log.e(TAG, "Could not get ime trace status, defaulting to false.", e);
}
return false;
}
@Override
protected boolean isEnabled() {
return isWindowTraceEnabled() || isLayerTraceEnabled() || isSystemUiTracingEnabled();
return isWindowTraceEnabled() || isLayerTraceEnabled() || isSystemUiTracingEnabled()
|| isImeTraceEnabled();
}
private void setWindowTraceEnabled(boolean isEnabled) {
@@ -308,11 +322,24 @@ public abstract class DevelopmentTiles extends TileService {
}
}
private void setImeTraceEnabled(boolean isEnabled) {
try {
if (isEnabled) {
mInputMethodManager.startImeTrace();
} else {
mInputMethodManager.stopImeTrace();
}
} catch (RemoteException e) {
Log.e(TAG, "Could not set ime trace status." + e.toString());
}
}
@Override
protected void setIsEnabled(boolean isEnabled) {
setWindowTraceEnabled(isEnabled);
setLayerTraceEnabled(isEnabled);
setSystemUiTracing(isEnabled);
setImeTraceEnabled(isEnabled);
if (!isEnabled) {
mToast.show();
}