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

Commit a60c0cdb authored by Martin Brabham's avatar Martin Brabham Committed by Gerrit Code Review
Browse files

Merge "Clean up JNI"

parents d30c9b03 86fca420
Loading
Loading
Loading
Loading
+10 −9
Original line number Diff line number Diff line
@@ -64,10 +64,6 @@ public class HeadsetClientService extends ProfileService {

    public static final String HFP_CLIENT_STOP_TAG = "hfp_client_stop_tag";

    static {
        NativeInterface.classInitNative();
    }

    @Override
    public IProfileServiceBinder initBinder() {
        return new BluetoothHeadsetClientBinder(this);
@@ -78,8 +74,15 @@ public class HeadsetClientService extends ProfileService {
        if (DBG) {
            Log.d(TAG, "start()");
        }
        if (sHeadsetClientService != null) {
            Log.w(TAG, "start(): start called without stop");
            return false;
        }

        // Setup the JNI service
        NativeInterface.initializeNative();
        mNativeInterface = new NativeInterface();
        mNativeInterface.initializeNative();

        mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

        mSmFactory = new HeadsetClientStateMachineFactory();
@@ -88,8 +91,6 @@ public class HeadsetClientService extends ProfileService {
        IntentFilter filter = new IntentFilter(AudioManager.VOLUME_CHANGED_ACTION);
        registerReceiver(mBroadcastReceiver, filter);

        mNativeInterface = new NativeInterface();

        // Start the HfpClientConnectionService to create connection with telecom when HFP
        // connection is available.
        Intent startIntent = new Intent(this, HfpClientConnectionService.class);
@@ -125,13 +126,13 @@ public class HeadsetClientService extends ProfileService {
        Intent stopIntent = new Intent(this, HfpClientConnectionService.class);
        stopIntent.putExtra(HFP_CLIENT_STOP_TAG, true);
        startService(stopIntent);
        mNativeInterface = null;

        // Stop the handler thread
        mSmThread.quit();
        mSmThread = null;

        NativeInterface.cleanupNative();
        mNativeInterface.cleanupNative();
        mNativeInterface = null;

        return true;
    }
+6 −2
Original line number Diff line number Diff line
@@ -28,14 +28,18 @@ class NativeInterface {
    private static final String TAG = "NativeInterface";
    private static final boolean DBG = false;

    static {
        classInitNative();
    }

    NativeInterface() {}

    // Native methods that call into the JNI interface
    static native void classInitNative();

    static native void initializeNative();
    native void initializeNative();

    static native void cleanupNative();
    native void cleanupNative();

    static native boolean connectNative(byte[] address);