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

Commit c749c370 authored by Matt Casey's avatar Matt Casey
Browse files

Remove SysUI Chooser

It's unused and stale. Starting to acquire a bit of a smell.

Bug: N/A
Test: Builds
Change-Id: Ia194833351cdf29bac6461393601af459f3f0436
parent 4b5f06df
Loading
Loading
Loading
Loading
+0 −16
Original line number Diff line number Diff line
@@ -767,22 +767,6 @@
            </intent-filter>
        </activity>

        <activity android:name=".chooser.ChooserActivity"
                android:theme="@*android:style/Theme.NoDisplay"
                android:finishOnCloseSystemDialogs="true"
                android:excludeFromRecents="true"
                android:documentLaunchMode="never"
                android:relinquishTaskIdentity="true"
                android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation|keyboard|keyboardHidden"
                android:process=":ui"
                android:visibleToInstantApps="true"
                android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.CHOOSER" />
                <category android:name="android.intent.category.VOICE" />
            </intent-filter>
        </activity>

        <activity android:name=".clipboardoverlay.EditTextActivity"
                  android:theme="@style/EditTextActivity"
                  android:exported="false"
+0 −35
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.chooser;

import android.app.Activity;
import android.os.Bundle;

/**
 * Activity for selecting which application ought to handle an ACTION_SEND intent.
 */
public final class ChooserActivity extends Activity {

    private static final String TAG = "ChooserActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ChooserHelper.onChoose(this);
        finish();
    }
}
+0 −55
Original line number Diff line number Diff line
/*
 * Copyright (C) 2017 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.chooser;

import android.app.Activity;
import android.app.ActivityTaskManager;
import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder;
import android.os.StrictMode;

/**
 * When a target is chosen from the SystemUI Chooser activity, unpack its arguments and
 * startActivityAsCaller to handle the now-chosen intent.
 */
public class ChooserHelper {

    private static final String TAG = "ChooserHelper";

    static void onChoose(Activity activity) {
        final Intent thisIntent = activity.getIntent();
        final Bundle thisExtras = thisIntent.getExtras();
        final Intent chosenIntent = thisIntent.getParcelableExtra(Intent.EXTRA_INTENT);
        final Bundle options = thisIntent.getParcelableExtra(ActivityTaskManager.EXTRA_OPTIONS);
        final IBinder permissionToken =
                thisExtras.getBinder(ActivityTaskManager.EXTRA_PERMISSION_TOKEN);
        final boolean ignoreTargetSecurity =
                thisIntent.getBooleanExtra(ActivityTaskManager.EXTRA_IGNORE_TARGET_SECURITY, false);
        final int userId = thisIntent.getIntExtra(Intent.EXTRA_USER_ID, -1);

        // We're dispatching intents that might be coming from legacy apps, so
        // (as in com.android.internal.app.ResolverActivity) exempt ourselves from death.
        StrictMode.disableDeathOnFileUriExposure();
        try {
            activity.startActivityAsCaller(
                    chosenIntent, options, permissionToken, ignoreTargetSecurity, userId);
        } finally {
            StrictMode.enableDeathOnFileUriExposure();
        }
    }
}
+0 −58
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.systemui.chooser;

import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyBoolean;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import android.app.Activity;
import android.app.ActivityTaskManager;
import android.content.Intent;
import android.os.Binder;
import android.test.suitebuilder.annotation.SmallTest;

import androidx.test.runner.AndroidJUnit4;

import com.android.systemui.SysuiTestCase;

import org.junit.Test;
import org.junit.runner.RunWith;

@SmallTest
@RunWith(AndroidJUnit4.class)
public class ChooserHelperTest extends SysuiTestCase {

    @Test
    public void testOnChoose_CallsStartActivityAsCallerWithToken() {
        final Intent intent = new Intent();
        final Binder token = new Binder();
        intent.putExtra(ActivityTaskManager.EXTRA_PERMISSION_TOKEN, token);

        final Activity mockActivity = mock(Activity.class);
        when(mockActivity.getIntent()).thenReturn(intent);

        ChooserHelper.onChoose(mockActivity);
        verify(mockActivity, times(1)).startActivityAsCaller(
                any(), any(), eq(token), anyBoolean(), anyInt());
    }
}