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

Commit d27bf0e7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "MapClient: Handle remote exception at cleanup" am: 84351b4e am: 08dead49

Original change: https://android-review.googlesource.com/c/platform/packages/apps/Bluetooth/+/1665960

Change-Id: Ia16db6a95665cfd1ef6034b7fbd314b880d73295
parents b4449e1c 08dead49
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();