Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 50c52c0b authored by Peng Xu's avatar Peng Xu Committed by Android (Google) Code Review
Browse files

Merge "Several code quality improvements" into nyc-dev

parents b01a0afb 4a4baef4
Loading
Loading
Loading
Loading
+8 −3
Original line number Diff line number Diff line
@@ -31,12 +31,15 @@ import android.util.SparseBooleanArray;
import android.util.SparseIntArray;
import dalvik.system.CloseGuard;

import com.android.internal.annotations.GuardedBy;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * Sensor manager implementation that communicates with the built-in
 * system sensors.
@@ -55,7 +58,9 @@ public class SystemSensorManager extends SensorManager {
    private static native boolean nativeIsDataInjectionEnabled(long nativeInstance);

    private static final Object sLock = new Object();
    private static boolean sSensorModuleInitialized = false;
    @GuardedBy("sLock")
    private static boolean sNativeClassInited = false;
    @GuardedBy("sLock")
    private static InjectEventQueue sInjectEventQueue = null;

    private final ArrayList<Sensor> mFullSensorsList = new ArrayList<>();
@@ -84,8 +89,8 @@ public class SystemSensorManager extends SensorManager {
    /** {@hide} */
    public SystemSensorManager(Context context, Looper mainLooper) {
        synchronized(sLock) {
            if (!sSensorModuleInitialized) {
                sSensorModuleInitialized = true;
            if (!sNativeClassInited) {
                sNativeClassInited = true;
                nativeClassInit();
            }
        }
+8 −8
Original line number Diff line number Diff line
@@ -36,15 +36,17 @@

#include "core_jni_helpers.h"

static struct {
namespace {

using namespace android;

struct {
    jclass clazz;
    jmethodID dispatchSensorEvent;
    jmethodID dispatchFlushCompleteEvent;
    jmethodID dispatchAdditionalInfoEvent;
} gBaseEventQueueClassInfo;

namespace android {

struct SensorOffsets
{
    jclass      clazz;
@@ -72,9 +74,9 @@ struct ListOffsets {
} gListOffsets;

/*
 * The method below are not thread-safe and not intended to be
 * nativeClassInit is not inteneded to be thread-safe. It should be called before other native...
 * functions (except nativeCreate).
 */

static void
nativeClassInit (JNIEnv *_env, jclass _this)
{
@@ -494,9 +496,7 @@ static const JNINativeMethod gBaseEventQueueMethods[] = {
            (void*)nativeInjectSensorData },
};

}; // namespace android

using namespace android;
} //unnamed namespace

int register_android_hardware_SensorManager(JNIEnv *env)
{