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

Commit f4e995fd authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "AdapterService: Do not call System.exit() on onUnbind"

parents 241ac1af ebacd74e
Loading
Loading
Loading
Loading
+0 −14
Original line number Diff line number Diff line
@@ -638,10 +638,6 @@ public class AdapterService extends Service {
        if (mCallbacks !=null) {
            mCallbacks.kill();
        }

        if (!isMock()) {
            System.exit(0);
        }
    }

    private static final int MESSAGE_PROFILE_SERVICE_STATE_CHANGED =1;
@@ -2295,14 +2291,4 @@ public class AdapterService extends Service {
            }
        }
    }

    // Returns if this is a mock object. This is currently used in testing so that we may not call
    // System.exit() while finalizing the object. Otherwise GC of mock objects unfortunately ends up
    // calling finalize() which in turn calls System.exit() and the process crashes.
    //
    // Mock this in your testing framework to return true to avoid the mentioned behavior. In
    // production this has no effect.
    public boolean isMock() {
        return false;
    }
}
+0 −12
Original line number Diff line number Diff line
@@ -91,9 +91,6 @@ public class PhonePolicyTest extends AndroidTestCase {
        // Mock the looper
        when(mockAdapterService.getMainLooper()).thenReturn(mHandlerThread.getLooper());

        // Tell the adapterservice that it is a mock (see isMock documentation)
        when(mockAdapterService.isMock()).thenReturn(true);

        PhonePolicy phPol = new PhonePolicy(mockAdapterService, mockServiceFactory);

        // Get the broadcast receiver to inject events.
@@ -150,8 +147,6 @@ public class PhonePolicyTest extends AndroidTestCase {
        // Mock the looper
        when(mockAdapterService.getMainLooper()).thenReturn(mHandlerThread.getLooper());

        // Tell the adapterservice that it is a mock (see isMock documentation)
        when(mockAdapterService.isMock()).thenReturn(true);
        PhonePolicy phPol = new PhonePolicy(mockAdapterService, mockServiceFactory);

        // Get the broadcast receiver to inject events
@@ -200,8 +195,6 @@ public class PhonePolicyTest extends AndroidTestCase {
        // Mock the looper
        when(mockAdapterService.getMainLooper()).thenReturn(mHandlerThread.getLooper());

        // Tell the adapterservice that it is a mock (see isMock documentation)
        when(mockAdapterService.isMock()).thenReturn(true);
        PhonePolicy phPol = new PhonePolicy(mockAdapterService, mockServiceFactory);

        // Get the broadcast receiver to inject events
@@ -261,8 +254,6 @@ public class PhonePolicyTest extends AndroidTestCase {
        // Mock the looper
        when(mockAdapterService.getMainLooper()).thenReturn(mHandlerThread.getLooper());

        // Tell the adapterservice that it is a mock (see isMock documentation)
        when(mockAdapterService.isMock()).thenReturn(true);
        PhonePolicy phPol = new PhonePolicy(mockAdapterService, mockServiceFactory);

        // Get the broadcast receiver to inject events
@@ -322,9 +313,6 @@ public class PhonePolicyTest extends AndroidTestCase {
        // Mock the looper
        when(mockAdapterService.getMainLooper()).thenReturn(mHandlerThread.getLooper());

        // Tell the adapterservice that it is a mock (see isMock documentation)
        when(mockAdapterService.isMock()).thenReturn(true);

        PhonePolicy phPol = new PhonePolicy(mockAdapterService, mockServiceFactory);

        // Get the broadcast receiver to inject events.