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);
// Create CPU monitor
if (cpuMonitor.isSupported()) {
cpuMonitor = new CpuMonitor(this);
hudFragment.setCpuMonitor(cpuMonitor);
}
// Send intent arguments to fragments.
callFragment.setArguments(intent.getExtras());
@ -502,8 +504,10 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
if (peerConnectionClient != null && !screencaptureEnabled) {
peerConnectionClient.stopVideoSource();
}
if (cpuMonitor != null) {
cpuMonitor.pause();
}
}
@Override
public void onStart() {
@ -513,8 +517,10 @@ public class CallActivity extends Activity implements AppRTCClient.SignalingEven
if (peerConnectionClient != null && !screencaptureEnabled) {
peerConnectionClient.startVideoSource();
}
if (cpuMonitor != null) {
cpuMonitor.resume();
}
}
@Override
protected void onDestroy() {

View File

@ -10,10 +10,12 @@
package org.appspot.apprtc;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.BatteryManager;
import android.os.Build;
import android.os.SystemClock;
import android.util.Log;
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
* jumping up and back down we might create faulty CPU load readings.
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
class CpuMonitor {
private static final String TAG = "CpuMonitor";
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) {
if (!isSupported()) {
throw new RuntimeException("CpuMonitor is not supported on this Android version.");
}
Log.d(TAG, "CpuMonitor ctor.");
appContext = context.getApplicationContext();
userCpuUsage = new MovingAverage(MOVING_AVERAGE_SAMPLES);

View File

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

View File

@ -6,17 +6,12 @@
<!-- TODO(phoglund): make work with suppress.py or remove printout referring
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="LongLogTag" severity="ignore"/>
<issue id="Registered" severity="ignore"/>
<issue id="MissingPermission" 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="IconColors" severity="ignore"/>
<issue id="IconDipSize" severity="ignore"/>