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

Commit 0c99ecae authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Launch subscreens with the correct user" into rvc-dev

parents 158bbe17 e3cb4f09
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;

import androidx.core.text.BidiFormatter;
@@ -183,12 +184,16 @@ public class AppChannelsBypassingDndPreferenceController extends NotificationPre
            channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mAppRow.pkg);
            channelArgs.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
            channelArgs.putBoolean(ARG_FROM_SETTINGS, true);
            channelPreference.setIntent(new SubSettingLauncher(mContext)
            channelPreference.setOnPreferenceClickListener(preference -> {
                new SubSettingLauncher(mContext)
                        .setDestination(ChannelNotificationSettings.class.getName())
                        .setArguments(channelArgs)
                        .setUserHandle(UserHandle.of(mAppRow.userId))
                        .setTitleRes(com.android.settings.R.string.notification_channel_title)
                        .setSourceMetricsCategory(SettingsEnums.DND_APPS_BYPASSING)
                    .toIntent());
                        .launch();
                return true;
            });
            mPreferenceCategory.addPreference(channelPreference);
        }
        mAllNotificationsToggle.setChecked(areAllChannelsBypassing());
+9 −4
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.Intent;
import android.content.pm.ShortcutInfo;
import android.os.Bundle;
import android.os.UserHandle;
import android.provider.Settings;
import android.service.notification.ConversationChannelWrapper;
import android.text.TextUtils;
@@ -97,7 +98,10 @@ public abstract class ConversationListPreferenceController extends AbstractPrefe
                conversation.getPkg(), conversation.getUid(),
                conversation.getNotificationChannel().isImportantConversation()));
        pref.setKey(conversation.getNotificationChannel().getId());
        pref.setIntent(getIntent(conversation, pref.getTitle()));
        pref.setOnPreferenceClickListener(preference -> {
            getSubSettingLauncher(conversation, pref.getTitle()).launch();
            return true;
        });

        return pref;
    }
@@ -116,7 +120,8 @@ public abstract class ConversationListPreferenceController extends AbstractPrefe
                : conversation.getNotificationChannel().getName();
    }

    Intent getIntent(ConversationChannelWrapper conversation, CharSequence title) {
    SubSettingLauncher getSubSettingLauncher(ConversationChannelWrapper conversation,
            CharSequence title) {
        Bundle channelArgs = new Bundle();
        channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, conversation.getUid());
        channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, conversation.getPkg());
@@ -129,9 +134,9 @@ public abstract class ConversationListPreferenceController extends AbstractPrefe
                .setDestination(ChannelNotificationSettings.class.getName())
                .setArguments(channelArgs)
                .setExtras(channelArgs)
                .setUserHandle(UserHandle.getUserHandleForUid(conversation.getUid()))
                .setTitleText(title)
                .setSourceMetricsCategory(SettingsEnums.NOTIFICATION_CONVERSATION_LIST_SETTINGS)
                .toIntent();
                .setSourceMetricsCategory(SettingsEnums.NOTIFICATION_CONVERSATION_LIST_SETTINGS);
    }

    protected Comparator<ConversationChannelWrapper> mConversationComparator =
+2 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import android.app.Application;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.os.Bundle;
import android.os.UserHandle;

import androidx.annotation.VisibleForTesting;
import androidx.core.text.BidiFormatter;
@@ -137,6 +138,7 @@ public class ZenModeAllBypassingAppsPreferenceController extends AbstractPrefere
                        new SubSettingLauncher(mContext)
                                .setDestination(AppChannelsBypassingDndSettings.class.getName())
                                .setArguments(args)
                                .setUserHandle(UserHandle.getUserHandleForUid(app.info.uid))
                                .setResultListener(mHostFragment, 0)
                                .setSourceMetricsCategory(
                                        SettingsEnums.NOTIFICATION_ZEN_MODE_OVERRIDING_APP)
+2 −2
Original line number Diff line number Diff line
@@ -191,7 +191,7 @@ public class ConversationListPreferenceControllerTest {
    }

    @Test
    public void testGetIntent() {
    public void testGetSubSettingLauncher() {
        ConversationChannelWrapper ccw = new ConversationChannelWrapper();
        NotificationChannel channel = new NotificationChannel("a", "child", 2);
        channel.setConversationId("parent", "convo id");
@@ -199,7 +199,7 @@ public class ConversationListPreferenceControllerTest {
        ccw.setPkg("pkg");
        ccw.setUid(1);
        ccw.setParentChannelLabel("parent label");
        Intent intent = mController.getIntent(ccw, "title");
        Intent intent = mController.getSubSettingLauncher(ccw, "title").toIntent();

        Bundle extras = intent.getExtras();
        assertThat(extras.getString(AppInfoBase.ARG_PACKAGE_NAME)).isEqualTo(ccw.getPkg());