Cleanup old suppressions from suppressions.xml.

Limits CpuMonitor to supported Android versions.

Bug: webrtc:6597
Change-Id: I15fb4f5dff2511f578069dd70521728e9909bd15
Reviewed-on: https://webrtc-review.googlesource.com/21225
Reviewed-by: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20626}
This commit is contained in:
Sami Kalliomäki
2017-11-08 16:02:21 +01:00
committed by Commit Bot
parent 6d85252e9e
commit ec6cf2a94f
4 changed files with 26 additions and 12 deletions

View File

@ -364,8 +364,10 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
new RoomConnectionParameters(roomUri.toString(), roomId, loopback, urlParameters); new RoomConnectionParameters(roomUri.toString(), roomId, loopback, urlParameters);
// Create CPU monitor // Create CPU monitor
cpuMonitor = new CpuMonitor(this); if (cpuMonitor.isSupported()) {
hudFragment.setCpuMonitor(cpuMonitor); cpuMonitor = new CpuMonitor(this);
hudFragment.setCpuMonitor(cpuMonitor);
}
// Send intent arguments to fragments. // Send intent arguments to fragments.
callFragment.setArguments(intent.getExtras()); callFragment.setArguments(intent.getExtras());
@ -502,7 +504,9 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
if (peerConnectionClient != null && !screencaptureEnabled) { if (peerConnectionClient != null && !screencaptureEnabled) {
peerConnectionClient.stopVideoSource(); peerConnectionClient.stopVideoSource();
} }
cpuMonitor.pause(); if (cpuMonitor != null) {
cpuMonitor.pause();
}
} }
@Override @Override
@ -513,7 +517,9 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
if (peerConnectionClient != null && !screencaptureEnabled) { if (peerConnectionClient != null && !screencaptureEnabled) {
peerConnectionClient.startVideoSource(); peerConnectionClient.startVideoSource();
} }
cpuMonitor.resume(); if (cpuMonitor != null) {
cpuMonitor.resume();
}
} }
@Override @Override

View File

@ -10,10 +10,12 @@
package org.appspot.apprtc; package org.appspot.apprtc;
import android.annotation.TargetApi;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.os.BatteryManager; import android.os.BatteryManager;
import android.os.Build;
import android.os.SystemClock; import android.os.SystemClock;
import android.util.Log; import android.util.Log;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -71,6 +73,7 @@ import java.util.concurrent.TimeUnit;
* correct value, and then returns to back to correct reading. Both when * correct value, and then returns to back to correct reading. Both when
* jumping up and back down we might create faulty CPU load readings. * jumping up and back down we might create faulty CPU load readings.
*/ */
@TargetApi(Build.VERSION_CODES.KITKAT)
class CpuMonitor { class CpuMonitor {
private static final String TAG = "CpuMonitor"; private static final String TAG = "CpuMonitor";
private static final int MOVING_AVERAGE_SAMPLES = 5; private static final int MOVING_AVERAGE_SAMPLES = 5;
@ -153,7 +156,16 @@ class CpuMonitor {
} }
} }
public static boolean isSupported() {
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT
&& Build.VERSION.SDK_INT < Build.VERSION_CODES.N;
}
public CpuMonitor(Context context) { public CpuMonitor(Context context) {
if (!isSupported()) {
throw new RuntimeException("CpuMonitor is not supported on this Android version.");
}
Log.d(TAG, "CpuMonitor ctor."); Log.d(TAG, "CpuMonitor ctor.");
appContext = context.getApplicationContext(); appContext = context.getApplicationContext();
userCpuUsage = new MovingAverage(MOVING_AVERAGE_SAMPLES); userCpuUsage = new MovingAverage(MOVING_AVERAGE_SAMPLES);

View File

@ -18,6 +18,7 @@ import android.opengl.EGLContext;
import android.opengl.EGLDisplay; import android.opengl.EGLDisplay;
import android.opengl.EGLExt; import android.opengl.EGLExt;
import android.opengl.EGLSurface; import android.opengl.EGLSurface;
import android.os.Build;
import android.view.Surface; import android.view.Surface;
/** /**
@ -49,10 +50,10 @@ class EglBase14 extends EglBase {
@Override @Override
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public long getNativeEglContext() { public long getNativeEglContext() {
return CURRENT_SDK_VERSION >= android.os.Build.VERSION_CODES.LOLLIPOP return CURRENT_SDK_VERSION >= Build.VERSION_CODES.LOLLIPOP ? egl14Context.getNativeHandle()
? egl14Context.getNativeHandle() : egl14Context.getHandle();
: egl14Context.getHandle();
} }
public Context(android.opengl.EGLContext eglContext) { public Context(android.opengl.EGLContext eglContext) {

View File

@ -6,17 +6,12 @@
<!-- TODO(phoglund): make work with suppress.py or remove printout referring <!-- TODO(phoglund): make work with suppress.py or remove printout referring
to suppress.py. --> to suppress.py. -->
<!-- TODO(crbug.com/739746): Remove once platform-tools is updated. -->
<issue id="NewApi" severity="ignore"/>
<issue id="UseSparseArrays" severity="ignore"/> <issue id="UseSparseArrays" severity="ignore"/>
<issue id="LongLogTag" severity="ignore"/> <issue id="LongLogTag" severity="ignore"/>
<issue id="Registered" severity="ignore"/> <issue id="Registered" severity="ignore"/>
<issue id="MissingPermission" severity="ignore"/> <issue id="MissingPermission" severity="ignore"/>
<issue id="ApplySharedPref" severity="ignore"/> <issue id="ApplySharedPref" severity="ignore"/>
<!-- TODO(sakal): Remove once the lint tool is updated. -->
<issue id="CommitPrefEdits" severity="ignore"/>
<issue id="UnusedResources" severity="ignore"/> <issue id="UnusedResources" severity="ignore"/>
<issue id="IconColors" severity="ignore"/> <issue id="IconColors" severity="ignore"/>
<issue id="IconDipSize" severity="ignore"/> <issue id="IconDipSize" severity="ignore"/>