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

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

Merge "MapClient: Handle remote exception at cleanup"

parents d4dee632 c32cc343
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -389,10 +389,13 @@ class MapClientContent {
     */
    void cleanUp() {
        clearMessages();
        try {
            mSubscriptionManager.removeSubscriptionInfoRecord(mDevice.getAddress(),
                    SubscriptionManager.SUBSCRIPTION_TYPE_REMOTE_SIM);
        } catch (Exception e) {
            Log.w(TAG, "cleanUp failed: " + e.toString());
        }
    }


    /**
     * clearMessages
+13 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.bluetooth.mapclient;

import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -324,6 +325,18 @@ public class MapClientContentTest {
        mMapClientContent.storeMessage(mTestMessage2, mTestMessage2Handle, mTestMessage1Timestamp);
    }

    /**
     * Test to validate that an exception in the Subscription manager won't crash Bluetooth during
     * disconnect.
     */
    @Test
    public void testCleanUpRemoteException() {
        mMapClientContent = new MapClientContent(mMockContext, mCallbacks, mTestDevice);
        doThrow(java.lang.NullPointerException.class).when(mMockSubscriptionManager)
                .removeSubscriptionInfoRecord(any(), anyInt());
        mMapClientContent.cleanUp();
    }

    void createTestMessages() {
        mOriginator = new VCardEntry();
        VCardProperty property = new VCardProperty();