Merge "[Stability]: fix system_server crash issue caused by fd leak." into oc-dev
This commit is contained in:
@@ -16,12 +16,10 @@
|
||||
|
||||
package android.hardware;
|
||||
|
||||
import android.Manifest;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.MemoryFile;
|
||||
@@ -51,8 +49,9 @@ import java.util.Map;
|
||||
*/
|
||||
public class SystemSensorManager extends SensorManager {
|
||||
//TODO: disable extra logging before release
|
||||
private static boolean DEBUG_DYNAMIC_SENSOR = true;
|
||||
private static int MIN_DIRECT_CHANNEL_BUFFER_SIZE = 104;
|
||||
private static final boolean DEBUG_DYNAMIC_SENSOR = true;
|
||||
private static final int MIN_DIRECT_CHANNEL_BUFFER_SIZE = 104;
|
||||
private static final int MAX_LISTENER_COUNT = 128;
|
||||
|
||||
private static native void nativeClassInit();
|
||||
private static native long nativeCreate(String opPackageName);
|
||||
@@ -157,6 +156,11 @@ public class SystemSensorManager extends SensorManager {
|
||||
Log.e(TAG, "maxBatchReportLatencyUs and delayUs should be non-negative");
|
||||
return false;
|
||||
}
|
||||
if (mSensorListeners.size() >= MAX_LISTENER_COUNT) {
|
||||
throw new IllegalStateException("register failed, " +
|
||||
"the sensor listeners size has exceeded the maximum limit " +
|
||||
MAX_LISTENER_COUNT);
|
||||
}
|
||||
|
||||
// Invariants to preserve:
|
||||
// - one Looper per SensorEventListener
|
||||
@@ -216,6 +220,12 @@ public class SystemSensorManager extends SensorManager {
|
||||
|
||||
if (sensor.getReportingMode() != Sensor.REPORTING_MODE_ONE_SHOT) return false;
|
||||
|
||||
if (mTriggerListeners.size() >= MAX_LISTENER_COUNT) {
|
||||
throw new IllegalStateException("request failed, " +
|
||||
"the trigger listeners size has exceeded the maximum limit " +
|
||||
MAX_LISTENER_COUNT);
|
||||
}
|
||||
|
||||
synchronized (mTriggerListeners) {
|
||||
TriggerEventQueue queue = mTriggerListeners.get(listener);
|
||||
if (queue == null) {
|
||||
|
||||
Reference in New Issue
Block a user