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

Commit 0f457e6f authored by Matt Pietal's avatar Matt Pietal
Browse files

Sharesheet - Resolve crash when no targets are present

After the sharesheet closes, a timeout message propagates to a handler
for processing, which causes an NPE

Bug: 129137525
Test: atest ChooserActivityTest
Change-Id: I200b068b74998ce9d22d85ad3574c130f959de4f
parent f81337ad
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -237,7 +237,7 @@ public class ChooserActivity extends ResolverActivity {
                    if (DEBUG) {
                        Log.d(TAG, "CHOOSER_TARGET_SERVICE_WATCHDOG_TIMEOUT; unbinding services");
                    }
                    if (isDestroyed()) {
                    if (mChooserListAdapter == null || isDestroyed()) {
                        break;
                    }
                    unbindRemainingServices();
@@ -822,6 +822,7 @@ public class ChooserActivity extends ResolverActivity {
            mRefinementResultReceiver = null;
        }
        unbindRemainingServices();
        mChooserHandler.removeMessages(CHOOSER_TARGET_SERVICE_WATCHDOG_TIMEOUT);
        mChooserHandler.removeMessages(CHOOSER_TARGET_SERVICE_RESULT);
        if (USE_PREDICTION_MANAGER_FOR_DIRECT_TARGETS) {
            mAppPredictor.unregisterPredictionUpdates(mAppPredictorCallback);
+2 −2
Original line number Diff line number Diff line
@@ -599,7 +599,7 @@ public class ChooserActivityTest {

        mActivityRule.launchActivity(Intent.createChooser(sendIntent, null));
        waitForIdle();
        verify(mockLogger, Mockito.times(2)).write(logMakerCaptor.capture());
        verify(mockLogger, Mockito.times(3)).write(logMakerCaptor.capture());
        // First invocation is from onCreate
        assertThat(logMakerCaptor.getAllValues().get(1).getCategory(),
                is(MetricsEvent.ACTION_SHARE_WITH_PREVIEW));
@@ -629,7 +629,7 @@ public class ChooserActivityTest {
        ArgumentCaptor<LogMaker> logMakerCaptor = ArgumentCaptor.forClass(LogMaker.class);
        mActivityRule.launchActivity(Intent.createChooser(sendIntent, null));
        waitForIdle();
        verify(mockLogger, Mockito.times(2)).write(logMakerCaptor.capture());
        verify(mockLogger, Mockito.times(3)).write(logMakerCaptor.capture());
        // First invocation is from onCreate
        assertThat(logMakerCaptor.getAllValues().get(1).getCategory(),
                is(MetricsEvent.ACTION_SHARE_WITH_PREVIEW));