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

Commit 6230bf1f authored by Jason Chiu's avatar Jason Chiu Committed by Automerger Merge Worker
Browse files

Merge "[Large screen] Make slice deep linking to Settings show in 2-pane" into...

Merge "[Large screen] Make slice deep linking to Settings show in 2-pane" into sc-v2-dev am: e1ec69fa

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Settings/+/15926633

Change-Id: I2b407cb2d53996f9432e6770ce586358e5c44b7d
parents 31ec8a91 e1ec69fa
Loading
Loading
Loading
Loading
+37 −13
Original line number Diff line number Diff line
@@ -129,7 +129,6 @@
        <uses-library android:name="androidx.window.sidecar" android:required="false"/>

        <!-- Settings -->

        <activity android:name=".homepage.SettingsHomepageActivity"
                  android:label="@string/settings_label_launcher"
                  android:theme="@style/Theme.Settings.Home"
@@ -145,18 +144,15 @@
                       android:value="true" />
        </activity>

        <activity android:name=".network.telephony.MobileNetworkActivity"
                  android:label="@string/network_settings_title"
                  android:exported="true"
                  android:launchMode="singleTask">
            <intent-filter android:priority="1">
                <!-- Displays the MobileNetworkActivity and opt-in dialog for capability discovery. -->
                <action android:name="android.telephony.ims.action.SHOW_CAPABILITY_DISCOVERY_OPT_IN" />
                <action android:name="android.settings.NETWORK_OPERATOR_SETTINGS" />
                <action android:name="android.settings.DATA_ROAMING_SETTINGS" />
                <action android:name="android.settings.MMS_MESSAGE_SETTING" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        <activity android:name=".homepage.SliceDeepLinkHomepageActivity"
                  android:label="@string/settings_label_launcher"
                  android:theme="@style/Theme.Settings.Home"
                  android:taskAffinity=""
                  android:launchMode="singleTask"
                  android:exported="false"
                  android:configChanges="orientation|keyboard|keyboardHidden|screenSize|screenLayout">
            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
                       android:value="true" />
        </activity>

        <!-- Alias for launcher activity only, as this belongs to each profile. -->
@@ -234,6 +230,20 @@
                android:value="true" />
        </activity>

        <activity android:name=".network.telephony.MobileNetworkActivity"
                  android:label="@string/network_settings_title"
                  android:exported="true"
                  android:launchMode="singleTask">
            <intent-filter android:priority="1">
                <!-- Displays the MobileNetworkActivity and opt-in dialog for capability discovery. -->
                <action android:name="android.telephony.ims.action.SHOW_CAPABILITY_DISCOVERY_OPT_IN" />
                <action android:name="android.settings.NETWORK_OPERATOR_SETTINGS" />
                <action android:name="android.settings.DATA_ROAMING_SETTINGS" />
                <action android:name="android.settings.MMS_MESSAGE_SETTING" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity android:name=".Settings$MobileNetworkListActivity"
                  android:exported="true"
                  android:label="@string/network_settings_title">
@@ -2546,6 +2556,8 @@
            </intent-filter>
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                android:value="com.android.settings.fuelgauge.batterysaver.BatterySaverSettings" />
            <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
                       android:value="@string/menu_key_battery"/>
            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
                android:value="true" />
        </activity>
@@ -2571,6 +2583,8 @@
            </intent-filter>
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                android:value="com.android.settings.accounts.AccountSyncSettings" />
            <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
                       android:value="@string/menu_key_accounts"/>
            <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED"
                android:value="true" />
        </activity>
@@ -2585,6 +2599,8 @@
            </intent-filter>
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                android:value="com.android.settings.accounts.ManagedProfileSettings" />
            <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
                       android:value="@string/menu_key_accounts"/>
        </activity>

        <activity
@@ -2605,6 +2621,8 @@
            android:configChanges="orientation|keyboardHidden|screenSize">
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                       android:value="com.android.settings.accounts.ChooseAccountFragment" />
            <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
                       android:value="@string/menu_key_accounts"/>
        </activity>

        <activity android:name=".CryptKeeper"
@@ -2663,6 +2681,8 @@
            </intent-filter>
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                android:value="com.android.settings.security.CryptKeeperSettings" />
            <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
                       android:value="@string/menu_key_security"/>
        </activity>

        <activity
@@ -2680,6 +2700,8 @@
            </intent-filter>
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                android:value="com.android.settings.datausage.DataUsageSummary" />
            <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
                       android:value="@string/menu_key_network"/>
        </activity>
        <activity
            android:name="Settings$MobileDataUsageListActivity"
@@ -2691,6 +2713,8 @@
            </intent-filter>
            <meta-data android:name="com.android.settings.FRAGMENT_CLASS"
                       android:value="com.android.settings.datausage.DataUsageList" />
            <meta-data android:name="com.android.settings.HIGHLIGHT_MENU_KEY"
                       android:value="@string/menu_key_network"/>
        </activity>

        <activity
+43 −7
Original line number Diff line number Diff line
@@ -16,6 +16,10 @@

package com.android.settings;

import static android.provider.Settings.ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY;
import static android.provider.Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY;
import static android.provider.Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI;

import static com.android.settings.applications.appinfo.AppButtonsPreferenceController.KEY_REMOVE_TASK_WHEN_FINISHING;

import android.app.ActionBar;
@@ -61,6 +65,7 @@ import com.android.settings.core.SubSettingLauncher;
import com.android.settings.core.gateway.SettingsGateway;
import com.android.settings.dashboard.DashboardFeatureProvider;
import com.android.settings.homepage.SettingsHomepageActivity;
import com.android.settings.homepage.SliceDeepLinkHomepageActivity;
import com.android.settings.homepage.TopLevelSettings;
import com.android.settings.overlay.FeatureFactory;
import com.android.settings.wfd.WifiDisplaySettings;
@@ -139,6 +144,12 @@ public class SettingsActivity extends SettingsBaseActivity
    public static final String EXTRA_SHOW_FRAGMENT_AS_SUBSETTING =
            ":settings:show_fragment_as_subsetting";

    /**
     * Additional extra of Settings#ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK.
     * Set true when the deep link intent is from a slice
     */
    public static final String EXTRA_IS_FROM_SLICE = "is_from_slice";

    /**
     * Personal or Work profile tab of {@link ProfileSelectFragment}
     * <p>0: Personal tab.
@@ -363,15 +374,34 @@ public class SettingsActivity extends SettingsBaseActivity
            return false;
        }

        final Intent detailIntent = new Intent(intent);
        // It's a deep link intent, SettingsHomepageActivity will set SplitPairRule and start it.
        final Intent trampolineIntent =
                new Intent(android.provider.Settings.ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY);
        trampolineIntent.replaceExtras(intent);
        trampolineIntent.putExtra(
                android.provider.Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI,
                intent.toUri(Intent.URI_INTENT_SCHEME));
        final Intent trampolineIntent = new Intent(ACTION_SETTINGS_EMBED_DEEP_LINK_ACTIVITY);

        trampolineIntent.replaceExtras(detailIntent);

        // Relay detail intent data to prevent failure of Intent#ParseUri.
        // If Intent#getData() is not null, Intent#toUri will return an Uri which has the scheme of
        // Intent#getData() and it may not be the scheme of an Intent.
        trampolineIntent.putExtra(
                android.provider.Settings.EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY,
                SettingsHomepageActivity.EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_DATA,
                detailIntent.getData());
        detailIntent.setData(null);

        trampolineIntent.putExtra(EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_INTENT_URI,
                detailIntent.toUri(Intent.URI_INTENT_SCHEME));

        if (detailIntent.getBooleanExtra(EXTRA_IS_FROM_SLICE, false)) {
            trampolineIntent.setClass(this, SliceDeepLinkHomepageActivity.class);
            // Get menu key for slice deep link case.
            final String highlightMenuKey = detailIntent.getStringExtra(
                    EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY);
            if (!TextUtils.isEmpty(highlightMenuKey)) {
                mHighlightMenuKey = highlightMenuKey;
            }
        }

        trampolineIntent.putExtra(EXTRA_SETTINGS_EMBEDDED_DEEP_LINK_HIGHLIGHT_MENU_KEY,
                mHighlightMenuKey);
        trampolineIntent.addFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
        startActivity(trampolineIntent);
@@ -391,6 +421,12 @@ public class SettingsActivity extends SettingsBaseActivity
            return false;
        }

        if (intent.getBooleanExtra(EXTRA_IS_FROM_SLICE, false)) {
            // Slice deep link starts the Intent using SubSettingLauncher. Returns true to show
            // 2-pane deep link.
            return true;
        }

        if (isSubSettings(intent)) {
            return false;
        }
+1 −6
Original line number Diff line number Diff line
@@ -128,11 +128,6 @@ public class ActivityEmbeddingRulesController {
                null /* intentAction */));
    }

    private void addActivityFilter(Set<ActivityFilter> activityFilters, Intent intent) {
        activityFilters.add(new ActivityFilter(new ComponentName("*" /* pkg */, "*" /* cls */),
                intent.getAction()));
    }

    private void addActivityFilter(Set<ActivityFilter> activityFilters,
            ComponentName componentName) {
        activityFilters.add(new ActivityFilter(componentName, null /* intentAction */));
+14 −1
Original line number Diff line number Diff line
@@ -61,9 +61,15 @@ public class SettingsHomepageActivity extends FragmentActivity implements

    private static final String TAG = "SettingsHomepageActivity";

    // Additional extra of Settings#ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK.
    // Put true value to the intent when startActivity for a deep link intent from this Activity.
    public static final String EXTRA_IS_FROM_SETTINGS_HOMEPAGE = "is_from_settings_homepage";

    // Additional extra of Settings#ACTION_SETTINGS_LARGE_SCREEN_DEEP_LINK.
    // Set & get Uri of the Intent separately to prevent failure of Intent#ParseUri.
    public static final String EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_DATA =
            "settings_large_screen_deep_link_intent_data";

    // An alias class name of SettingsHomepageActivity.
    public static final String ALIAS_DEEP_LINK = "com.android.settings.DeepLinkHomepageActivity";

@@ -232,10 +238,13 @@ public class SettingsHomepageActivity extends FragmentActivity implements
        targetIntent.replaceExtras(intent);

        targetIntent.putExtra(EXTRA_IS_FROM_SETTINGS_HOMEPAGE, true);
        targetIntent.putExtra(SettingsActivity.EXTRA_IS_FROM_SLICE, false);

        targetIntent.setData(intent.getParcelableExtra(
                SettingsHomepageActivity.EXTRA_SETTINGS_LARGE_SCREEN_DEEP_LINK_INTENT_DATA));
        // Set 2-pane pair rule for the deep link page.
        ActivityEmbeddingRulesController.registerTwoPanePairRule(this,
                new ComponentName(Utils.SETTINGS_PACKAGE_NAME, ALIAS_DEEP_LINK),
                getDeepLinkComponent(),
                targetComponentName,
                targetIntent.getAction(),
                true /* finishPrimaryWithSecondary */,
@@ -251,6 +260,10 @@ public class SettingsHomepageActivity extends FragmentActivity implements
        startActivity(targetIntent);
    }

    protected ComponentName getDeepLinkComponent() {
        return new ComponentName(Utils.SETTINGS_PACKAGE_NAME, ALIAS_DEEP_LINK);
    }

    private String getHighlightMenuKey() {
        final Intent intent = getIntent();
        if (intent != null && TextUtils.equals(intent.getAction(),
+27 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 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.settings.homepage;

import android.content.ComponentName;

/** Activity for Slices to launch Settings deep link page */
public class SliceDeepLinkHomepageActivity extends SettingsHomepageActivity {
    @Override
    protected ComponentName getDeepLinkComponent() {
        return new ComponentName(getApplicationContext(), getClass());
    }
}
Loading