Remove Winscope tracing QS development tile
This commit removes the obsolete QS development tile for Winscope tracing as now Winscope traces can be collected via Traceur. Bug: 295816837 Test: N/A Change-Id: I15bd011d8d44293c0407e00a5550cc9fbe5e561c
This commit is contained in:
@@ -4389,20 +4389,6 @@
|
||||
android:value="true"/>
|
||||
</service>
|
||||
|
||||
<service
|
||||
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:exported="true"
|
||||
android:enabled="false">
|
||||
<intent-filter>
|
||||
<action android:name="android.service.quicksettings.action.QS_TILE" />
|
||||
</intent-filter>
|
||||
<meta-data android:name="android.service.quicksettings.TOGGLEABLE_TILE"
|
||||
android:value="true"/>
|
||||
</service>
|
||||
|
||||
<service
|
||||
android:name=".development.qstile.DevelopmentTiles$SensorsOff"
|
||||
android:label="@string/sensors_off_quick_settings_title"
|
||||
|
@@ -1,29 +0,0 @@
|
||||
<!--
|
||||
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="M17.115,1.535L9.984,1.535C9.38,1.535 8.887,2.029 8.887,2.632L8.887,5.923L7.241,5.923C6.638,5.923 6.144,6.417 6.144,7.021l0,5.486c0,0.603 0.494,1.097 1.097,1.097l7.131,0c0.603,0 1.097,-0.494 1.097,-1.097l0,-3.291l1.646,0c0.603,0 1.097,-0.494 1.097,-1.097L18.212,2.632C18.212,2.029 17.718,1.535 17.115,1.535ZM14.372,12.506L7.241,12.506l0,-4.388l7.131,0zM17.115,8.118L15.469,8.118L15.469,7.021C15.469,6.417 14.976,5.923 14.372,5.923L9.984,5.923L9.984,3.729l7.131,0z"
|
||||
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>
|
||||
|
@@ -9939,9 +9939,6 @@
|
||||
<!-- [CHAR LIMIT=NONE] Setting summary explaining the disablement of the automatic adb authorization timeout. -->
|
||||
<string name="adb_authorization_timeout_summary">Disable automatic revocation of adb authorizations for systems that have not reconnected within the default (7 days) or user-configured (minimum 1 day) amount of time.</string>
|
||||
|
||||
<!-- [CHAR LIMIT=25] Title of developer tile to toggle winscope trace -->
|
||||
<string name="winscope_trace_quick_settings_title">Winscope Trace</string>
|
||||
|
||||
<!-- [CHAR LIMIT=25] Title of developer tile to toggle sensors -->
|
||||
<string name="sensors_off_quick_settings_title">Sensors Off</string>
|
||||
|
||||
|
@@ -29,9 +29,7 @@ import android.database.ContentObserver;
|
||||
import android.hardware.SensorPrivacyManager;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.IBinder;
|
||||
import android.os.Looper;
|
||||
import android.os.Parcel;
|
||||
import android.os.RemoteException;
|
||||
import android.os.ServiceManager;
|
||||
import android.os.SystemProperties;
|
||||
@@ -45,10 +43,7 @@ import android.view.ThreadedRenderer;
|
||||
import android.view.WindowManagerGlobal;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
|
||||
import com.android.internal.app.LocalePicker;
|
||||
import com.android.internal.inputmethod.ImeTracing;
|
||||
import com.android.internal.statusbar.IStatusBarService;
|
||||
import com.android.settings.development.WirelessDebuggingPreferenceController;
|
||||
import com.android.settings.overlay.FeatureFactory;
|
||||
@@ -203,173 +198,6 @@ public abstract class DevelopmentTiles extends TileService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tile to toggle Winscope trace which consists of Window and Layer traces.
|
||||
*/
|
||||
public static class WinscopeTrace extends DevelopmentTiles {
|
||||
@VisibleForTesting
|
||||
static final int SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE = 1025;
|
||||
@VisibleForTesting
|
||||
static final int SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE = 1026;
|
||||
private static final String VIEW_CAPTURE_ENABLED = "view_capture_enabled";
|
||||
private IBinder mSurfaceFlinger;
|
||||
private IWindowManager mWindowManager;
|
||||
private ImeTracing mImeTracing;
|
||||
private Toast mToast;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
mWindowManager = WindowManagerGlobal.getWindowManagerService();
|
||||
mSurfaceFlinger = ServiceManager.getService("SurfaceFlinger");
|
||||
mImeTracing = ImeTracing.getInstance();
|
||||
Context context = getApplicationContext();
|
||||
CharSequence text = "Trace files written to /data/misc/wmtrace";
|
||||
mToast = Toast.makeText(context, text, Toast.LENGTH_LONG);
|
||||
}
|
||||
|
||||
private boolean isWindowTraceEnabled() {
|
||||
try {
|
||||
return mWindowManager.isWindowTraceEnabled();
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG,
|
||||
"Could not get window trace status, defaulting to false." + e.toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isLayerTraceEnabled() {
|
||||
boolean layerTraceEnabled = false;
|
||||
Parcel reply = null;
|
||||
Parcel data = null;
|
||||
try {
|
||||
if (mSurfaceFlinger != null) {
|
||||
reply = Parcel.obtain();
|
||||
data = Parcel.obtain();
|
||||
data.writeInterfaceToken("android.ui.ISurfaceComposer");
|
||||
mSurfaceFlinger.transact(SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE,
|
||||
data, reply, 0 /* flags */);
|
||||
layerTraceEnabled = reply.readBoolean();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Could not get layer trace status, defaulting to false." + e.toString());
|
||||
} finally {
|
||||
if (data != null) {
|
||||
data.recycle();
|
||||
reply.recycle();
|
||||
}
|
||||
}
|
||||
return layerTraceEnabled;
|
||||
}
|
||||
|
||||
private boolean isSystemUiTracingEnabled() {
|
||||
try {
|
||||
final IStatusBarService statusBarService = IStatusBarService.Stub.asInterface(
|
||||
ServiceManager.checkService(Context.STATUS_BAR_SERVICE));
|
||||
if (statusBarService != null) {
|
||||
return statusBarService.isTracing();
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Could not get system ui tracing status." + e.toString());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean isImeTraceEnabled() {
|
||||
return mImeTracing.isEnabled();
|
||||
}
|
||||
|
||||
private boolean isViewCaptureEnabled() {
|
||||
// Add null checking to avoid test case failure.
|
||||
if (getApplicationContext() != null) {
|
||||
return Settings.Global.getInt(getApplicationContext().getContentResolver(),
|
||||
VIEW_CAPTURE_ENABLED, 0) != 0;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled() {
|
||||
return isWindowTraceEnabled() || isLayerTraceEnabled() || isSystemUiTracingEnabled()
|
||||
|| isImeTraceEnabled() || isViewCaptureEnabled();
|
||||
}
|
||||
|
||||
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) {
|
||||
data = Parcel.obtain();
|
||||
data.writeInterfaceToken("android.ui.ISurfaceComposer");
|
||||
data.writeInt(isEnabled ? 1 : 0);
|
||||
mSurfaceFlinger.transact(SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE,
|
||||
data, null, 0 /* flags */);
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Could not set layer tracing." + e.toString());
|
||||
} finally {
|
||||
if (data != null) {
|
||||
data.recycle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setSystemUiTracing(boolean isEnabled) {
|
||||
try {
|
||||
final IStatusBarService statusBarService = IStatusBarService.Stub.asInterface(
|
||||
ServiceManager.checkService(Context.STATUS_BAR_SERVICE));
|
||||
if (statusBarService != null) {
|
||||
if (isEnabled) {
|
||||
statusBarService.startTracing();
|
||||
} else {
|
||||
statusBarService.stopTracing();
|
||||
}
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
Log.e(TAG, "Could not set system ui tracing." + e.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void setImeTraceEnabled(boolean isEnabled) {
|
||||
if (isEnabled) {
|
||||
mImeTracing.startImeTrace();
|
||||
} else {
|
||||
mImeTracing.stopImeTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setViewCaptureEnabled(boolean isEnabled) {
|
||||
// Add null checking to avoid test case failure.
|
||||
if (getApplicationContext() != null) {
|
||||
Settings.Global.putInt(getApplicationContext()
|
||||
.getContentResolver(), VIEW_CAPTURE_ENABLED, isEnabled ? 1 : 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setIsEnabled(boolean isEnabled) {
|
||||
setWindowTraceEnabled(isEnabled);
|
||||
setLayerTraceEnabled(isEnabled);
|
||||
setSystemUiTracing(isEnabled);
|
||||
setImeTraceEnabled(isEnabled);
|
||||
setViewCaptureEnabled(isEnabled);
|
||||
if (!isEnabled) {
|
||||
mToast.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tile to toggle sensors off to control camera, mic, and sensors managed by the SensorManager.
|
||||
*/
|
||||
|
@@ -1,259 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.android.settings.development.qstile;
|
||||
|
||||
import static com.android.settings.development.qstile.DevelopmentTiles.WinscopeTrace.SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE;
|
||||
import static com.android.settings.development.qstile.DevelopmentTiles.WinscopeTrace.SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNull;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.mockito.Mockito.spy;
|
||||
import static org.mockito.Mockito.verify;
|
||||
import static org.mockito.Mockito.verifyNoMoreInteractions;
|
||||
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
import android.view.IWindowManager;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.test.core.app.ApplicationProvider;
|
||||
|
||||
import com.android.internal.inputmethod.ImeTracing;
|
||||
import com.android.settings.testutils.shadow.ShadowParcel;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.util.ReflectionHelpers;
|
||||
|
||||
@RunWith(RobolectricTestRunner.class)
|
||||
public class WinscopeTraceTest {
|
||||
|
||||
@Mock
|
||||
private IWindowManager mWindowManager;
|
||||
@Mock
|
||||
private ImeTracing mImeTracing;
|
||||
@Mock
|
||||
private IBinder mSurfaceFlinger;
|
||||
@Mock
|
||||
private Toast mToast;
|
||||
|
||||
private DevelopmentTiles.WinscopeTrace mWinscopeTrace;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
mWinscopeTrace = spy(new DevelopmentTiles.WinscopeTrace());
|
||||
doReturn(ApplicationProvider.getApplicationContext()).when(
|
||||
mWinscopeTrace).getApplicationContext();
|
||||
|
||||
ReflectionHelpers.setField(mWinscopeTrace, "mWindowManager", mWindowManager);
|
||||
ReflectionHelpers.setField(mWinscopeTrace, "mImeTracing", mImeTracing);
|
||||
ReflectionHelpers.setField(mWinscopeTrace, "mSurfaceFlinger", mSurfaceFlinger);
|
||||
ReflectionHelpers.setField(mWinscopeTrace, "mToast", mToast);
|
||||
}
|
||||
|
||||
@After
|
||||
public void teardown() {
|
||||
verifyNoMoreInteractions(mToast);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowParcel.class)
|
||||
public void wmReturnsTraceEnabled_shouldReturnEnabled() throws RemoteException {
|
||||
// Assume Surface Trace and Input Method Manager are disabled.
|
||||
ShadowParcel.sReadBoolResult = false;
|
||||
doReturn(true).when(mWindowManager).isWindowTraceEnabled();
|
||||
assertThat(mWinscopeTrace.isEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowParcel.class)
|
||||
public void sfReturnsTraceEnabled_shouldReturnEnabled() throws RemoteException {
|
||||
// Assume Window Trace and Input Method Manager are disabled.
|
||||
doReturn(false).when(mWindowManager).isWindowTraceEnabled();
|
||||
doReturn(false).when(mImeTracing).isEnabled();
|
||||
ShadowParcel.sReadBoolResult = true;
|
||||
assertThat(mWinscopeTrace.isEnabled()).isTrue();
|
||||
verify(mSurfaceFlinger)
|
||||
.transact(eq(SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE), any(), any(),
|
||||
eq(0 /* flags */));
|
||||
verifyNoMoreInteractions(mSurfaceFlinger);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowParcel.class)
|
||||
public void sfAndWmReturnsTraceEnabled_shouldReturnEnabled() throws RemoteException {
|
||||
ShadowParcel.sReadBoolResult = true;
|
||||
doReturn(true).when(mWindowManager).isWindowTraceEnabled();
|
||||
assertThat(mWinscopeTrace.isEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wmAndSfAndImmReturnTraceDisabled_shouldReturnDisabled() throws RemoteException {
|
||||
ShadowParcel.sReadBoolResult = false;
|
||||
doReturn(false).when(mWindowManager).isWindowTraceEnabled();
|
||||
doReturn(false).when(mImeTracing).isEnabled();
|
||||
assertThat(mWinscopeTrace.isEnabled()).isFalse();
|
||||
verify(mSurfaceFlinger)
|
||||
.transact(eq(SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE), any(), any(),
|
||||
eq(0 /* flags */));
|
||||
verifyNoMoreInteractions(mSurfaceFlinger);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void wmAndSfReturnTraceDisabled_immReturnsTraceEnabled_shouldReturnEnabled()
|
||||
throws RemoteException {
|
||||
ShadowParcel.sReadBoolResult = false;
|
||||
doReturn(false).when(mWindowManager).isWindowTraceEnabled();
|
||||
doReturn(true).when(mImeTracing).isEnabled();
|
||||
assertThat(mWinscopeTrace.isEnabled()).isTrue();
|
||||
verify(mSurfaceFlinger)
|
||||
.transact(eq(SURFACE_FLINGER_LAYER_TRACE_STATUS_CODE), any(), any(),
|
||||
eq(0 /* flags */));
|
||||
verifyNoMoreInteractions(mSurfaceFlinger);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowParcel.class)
|
||||
public void immReturnsTraceEnabled_shouldReturnEnabled() throws RemoteException {
|
||||
// Assume Window Manager and Surface Trace are disabled.
|
||||
ShadowParcel.sReadBoolResult = false;
|
||||
doReturn(true).when(mImeTracing).isEnabled();
|
||||
assertThat(mWinscopeTrace.isEnabled()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowParcel.class)
|
||||
public void immReturnsTraceDisabled_shouldReturnDisabled() throws RemoteException {
|
||||
// Assume Window Manager and Surface Trace are disabled.
|
||||
ShadowParcel.sReadBoolResult = false;
|
||||
doReturn(false).when(mImeTracing).isEnabled();
|
||||
assertThat(mWinscopeTrace.isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowParcel.class)
|
||||
public void wmThrowsRemoteExAndSfReturnsTraceDisabled_shouldReturnDisabled()
|
||||
throws RemoteException {
|
||||
ShadowParcel.sReadBoolResult = false;
|
||||
doThrow(new RemoteException("Unknown"))
|
||||
.when(mWindowManager).isWindowTraceEnabled();
|
||||
assertThat(mWinscopeTrace.isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sfUnavailableAndWmAndImmReturnTraceDisabled_shouldReturnDisabled()
|
||||
throws RemoteException {
|
||||
doReturn(false).when(mWindowManager).isWindowTraceEnabled();
|
||||
doReturn(false).when(mImeTracing).isEnabled();
|
||||
ReflectionHelpers.setField(mWinscopeTrace, "mSurfaceFlinger", null);
|
||||
assertThat(mWinscopeTrace.isEnabled()).isFalse();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setIsEnableTrue_shouldEnableWindowTrace() throws RemoteException {
|
||||
mWinscopeTrace.setIsEnabled(true);
|
||||
verify(mWindowManager).startWindowTrace();
|
||||
verifyNoMoreInteractions(mWindowManager);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setIsEnableTrue_shouldEnableImeTrace() throws RemoteException {
|
||||
mWinscopeTrace.setIsEnabled(true);
|
||||
verify(mImeTracing).startImeTrace();
|
||||
verifyNoMoreInteractions(mImeTracing);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowParcel.class)
|
||||
public void setIsEnableTrue_shouldEnableLayerTrace() throws RemoteException {
|
||||
mWinscopeTrace.setIsEnabled(true);
|
||||
assertThat(ShadowParcel.sWriteIntResult).isEqualTo(1);
|
||||
verify(mSurfaceFlinger)
|
||||
.transact(eq(SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE), any(), isNull(),
|
||||
eq(0 /* flags */));
|
||||
verifyNoMoreInteractions(mSurfaceFlinger);
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowParcel.class)
|
||||
public void setIsEnableFalse_shouldDisableWindowTrace() throws RemoteException {
|
||||
mWinscopeTrace.setIsEnabled(false);
|
||||
verify(mWindowManager).stopWindowTrace();
|
||||
verifyNoMoreInteractions(mWindowManager);
|
||||
verify(mToast).show();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowParcel.class)
|
||||
public void setIsEnableFalse_shouldDisableImeTrace() throws RemoteException {
|
||||
mWinscopeTrace.setIsEnabled(false);
|
||||
verify(mImeTracing).stopImeTrace();
|
||||
verifyNoMoreInteractions(mImeTracing);
|
||||
verify(mToast).show();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Config(shadows = ShadowParcel.class)
|
||||
public void setIsEnableFalse_shouldDisableLayerTrace() throws RemoteException {
|
||||
mWinscopeTrace.setIsEnabled(false);
|
||||
assertThat(ShadowParcel.sWriteIntResult).isEqualTo(0);
|
||||
verify(mSurfaceFlinger)
|
||||
.transact(eq(SURFACE_FLINGER_LAYER_TRACE_CONTROL_CODE), any(), isNull(),
|
||||
eq(0 /* flags */));
|
||||
verifyNoMoreInteractions(mSurfaceFlinger);
|
||||
verify(mToast).show();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setIsEnableFalse_shouldShowToast() {
|
||||
mWinscopeTrace.setIsEnabled(false);
|
||||
verify(mToast).show();
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify when window manager call throws a remote exception, it is handled without
|
||||
* re-throwing the exception.
|
||||
*/
|
||||
@Test
|
||||
public void setIsEnableAndWmThrowsRemoteException_shouldFailGracefully()
|
||||
throws RemoteException {
|
||||
doThrow(new RemoteException("Unknown")).when(mWindowManager).isWindowTraceEnabled();
|
||||
mWinscopeTrace.setIsEnabled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verify is surface flinger is not available not calls are made to it.
|
||||
*/
|
||||
@Test
|
||||
public void setIsEnableAndSfUnavailable_shouldFailGracefully() {
|
||||
ReflectionHelpers.setField(mWinscopeTrace, "mSurfaceFlinger", null);
|
||||
mWinscopeTrace.setIsEnabled(true);
|
||||
verifyNoMoreInteractions(mSurfaceFlinger);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user