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

Commit 07abb66e authored by Guang Zhu's avatar Guang Zhu
Browse files

make success explicit in BT instrumentation util

Change-Id: I6c8eb8cdb7928fa6a7c1bc96b374667d1d6ae6a1
parent 77718147
Loading
Loading
Loading
Loading
+9 −6
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ public class BluetoothInstrumentation extends Instrumentation {
    private BluetoothTestUtils mUtils = null;
    private BluetoothTestUtils mUtils = null;
    private BluetoothAdapter mAdapter = null;
    private BluetoothAdapter mAdapter = null;
    private Bundle mArgs = null;
    private Bundle mArgs = null;
    private Bundle mSuccessResult = null;


    private BluetoothTestUtils getBluetoothTestUtils() {
    private BluetoothTestUtils getBluetoothTestUtils() {
        if (mUtils == null) {
        if (mUtils == null) {
@@ -46,6 +47,9 @@ public class BluetoothInstrumentation extends Instrumentation {
    public void onCreate(Bundle arguments) {
    public void onCreate(Bundle arguments) {
        super.onCreate(arguments);
        super.onCreate(arguments);
        mArgs = arguments;
        mArgs = arguments;
        // create the default result response, but only use it in success code path
        mSuccessResult = new Bundle();
        mSuccessResult.putString("result", "SUCCESS");
        start();
        start();
    }
    }


@@ -67,24 +71,23 @@ public class BluetoothInstrumentation extends Instrumentation {


    public void enable() {
    public void enable() {
        getBluetoothTestUtils().enable(getBluetoothAdapter());
        getBluetoothTestUtils().enable(getBluetoothAdapter());
        finish(null);
        finish(mSuccessResult);
    }
    }


    public void disable() {
    public void disable() {
        getBluetoothTestUtils().disable(getBluetoothAdapter());
        getBluetoothTestUtils().disable(getBluetoothAdapter());
        finish(null);
        finish(mSuccessResult);
    }
    }


    public void unpairAll() {
    public void unpairAll() {
        getBluetoothTestUtils().unpairAll(getBluetoothAdapter());
        getBluetoothTestUtils().unpairAll(getBluetoothAdapter());
        finish(null);
        finish(mSuccessResult);
    }
    }


    public void getName() {
    public void getName() {
        String name = getBluetoothAdapter().getName();
        String name = getBluetoothAdapter().getName();
        Bundle bundle = new Bundle();
        mSuccessResult.putString("name", name);
        bundle.putString("name", name);
        finish(mSuccessResult);
        finish(bundle);
    }
    }


    public void finish(Bundle result) {
    public void finish(Bundle result) {