Merge "Launch subscreens with the correct user" into rvc-dev am: 0c99ecaec1
am: f1801907d8
Change-Id: Iddf2bda7005bffe799b76f9a21d8937925fee693
This commit is contained in:
@@ -24,6 +24,7 @@ import android.app.settings.SettingsEnums;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
|
|
||||||
import androidx.core.text.BidiFormatter;
|
import androidx.core.text.BidiFormatter;
|
||||||
@@ -183,12 +184,16 @@ public class AppChannelsBypassingDndPreferenceController extends NotificationPre
|
|||||||
channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mAppRow.pkg);
|
channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, mAppRow.pkg);
|
||||||
channelArgs.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
|
channelArgs.putString(Settings.EXTRA_CHANNEL_ID, channel.getId());
|
||||||
channelArgs.putBoolean(ARG_FROM_SETTINGS, true);
|
channelArgs.putBoolean(ARG_FROM_SETTINGS, true);
|
||||||
channelPreference.setIntent(new SubSettingLauncher(mContext)
|
channelPreference.setOnPreferenceClickListener(preference -> {
|
||||||
.setDestination(ChannelNotificationSettings.class.getName())
|
new SubSettingLauncher(mContext)
|
||||||
.setArguments(channelArgs)
|
.setDestination(ChannelNotificationSettings.class.getName())
|
||||||
.setTitleRes(com.android.settings.R.string.notification_channel_title)
|
.setArguments(channelArgs)
|
||||||
.setSourceMetricsCategory(SettingsEnums.DND_APPS_BYPASSING)
|
.setUserHandle(UserHandle.of(mAppRow.userId))
|
||||||
.toIntent());
|
.setTitleRes(com.android.settings.R.string.notification_channel_title)
|
||||||
|
.setSourceMetricsCategory(SettingsEnums.DND_APPS_BYPASSING)
|
||||||
|
.launch();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
mPreferenceCategory.addPreference(channelPreference);
|
mPreferenceCategory.addPreference(channelPreference);
|
||||||
}
|
}
|
||||||
mAllNotificationsToggle.setChecked(areAllChannelsBypassing());
|
mAllNotificationsToggle.setChecked(areAllChannelsBypassing());
|
||||||
|
@@ -21,6 +21,7 @@ import android.content.Context;
|
|||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.pm.ShortcutInfo;
|
import android.content.pm.ShortcutInfo;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.UserHandle;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.notification.ConversationChannelWrapper;
|
import android.service.notification.ConversationChannelWrapper;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -97,7 +98,10 @@ public abstract class ConversationListPreferenceController extends AbstractPrefe
|
|||||||
conversation.getPkg(), conversation.getUid(),
|
conversation.getPkg(), conversation.getUid(),
|
||||||
conversation.getNotificationChannel().isImportantConversation()));
|
conversation.getNotificationChannel().isImportantConversation()));
|
||||||
pref.setKey(conversation.getNotificationChannel().getId());
|
pref.setKey(conversation.getNotificationChannel().getId());
|
||||||
pref.setIntent(getIntent(conversation, pref.getTitle()));
|
pref.setOnPreferenceClickListener(preference -> {
|
||||||
|
getSubSettingLauncher(conversation, pref.getTitle()).launch();
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
return pref;
|
return pref;
|
||||||
}
|
}
|
||||||
@@ -116,7 +120,8 @@ public abstract class ConversationListPreferenceController extends AbstractPrefe
|
|||||||
: conversation.getNotificationChannel().getName();
|
: conversation.getNotificationChannel().getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent getIntent(ConversationChannelWrapper conversation, CharSequence title) {
|
SubSettingLauncher getSubSettingLauncher(ConversationChannelWrapper conversation,
|
||||||
|
CharSequence title) {
|
||||||
Bundle channelArgs = new Bundle();
|
Bundle channelArgs = new Bundle();
|
||||||
channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, conversation.getUid());
|
channelArgs.putInt(AppInfoBase.ARG_PACKAGE_UID, conversation.getUid());
|
||||||
channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, conversation.getPkg());
|
channelArgs.putString(AppInfoBase.ARG_PACKAGE_NAME, conversation.getPkg());
|
||||||
@@ -129,9 +134,9 @@ public abstract class ConversationListPreferenceController extends AbstractPrefe
|
|||||||
.setDestination(ChannelNotificationSettings.class.getName())
|
.setDestination(ChannelNotificationSettings.class.getName())
|
||||||
.setArguments(channelArgs)
|
.setArguments(channelArgs)
|
||||||
.setExtras(channelArgs)
|
.setExtras(channelArgs)
|
||||||
|
.setUserHandle(UserHandle.getUserHandleForUid(conversation.getUid()))
|
||||||
.setTitleText(title)
|
.setTitleText(title)
|
||||||
.setSourceMetricsCategory(SettingsEnums.NOTIFICATION_CONVERSATION_LIST_SETTINGS)
|
.setSourceMetricsCategory(SettingsEnums.NOTIFICATION_CONVERSATION_LIST_SETTINGS);
|
||||||
.toIntent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Comparator<ConversationChannelWrapper> mConversationComparator =
|
protected Comparator<ConversationChannelWrapper> mConversationComparator =
|
||||||
|
@@ -20,6 +20,7 @@ import android.app.Application;
|
|||||||
import android.app.settings.SettingsEnums;
|
import android.app.settings.SettingsEnums;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.UserHandle;
|
||||||
|
|
||||||
import androidx.annotation.VisibleForTesting;
|
import androidx.annotation.VisibleForTesting;
|
||||||
import androidx.core.text.BidiFormatter;
|
import androidx.core.text.BidiFormatter;
|
||||||
@@ -137,6 +138,7 @@ public class ZenModeAllBypassingAppsPreferenceController extends AbstractPrefere
|
|||||||
new SubSettingLauncher(mContext)
|
new SubSettingLauncher(mContext)
|
||||||
.setDestination(AppChannelsBypassingDndSettings.class.getName())
|
.setDestination(AppChannelsBypassingDndSettings.class.getName())
|
||||||
.setArguments(args)
|
.setArguments(args)
|
||||||
|
.setUserHandle(UserHandle.getUserHandleForUid(app.info.uid))
|
||||||
.setResultListener(mHostFragment, 0)
|
.setResultListener(mHostFragment, 0)
|
||||||
.setSourceMetricsCategory(
|
.setSourceMetricsCategory(
|
||||||
SettingsEnums.NOTIFICATION_ZEN_MODE_OVERRIDING_APP)
|
SettingsEnums.NOTIFICATION_ZEN_MODE_OVERRIDING_APP)
|
||||||
|
@@ -191,7 +191,7 @@ public class ConversationListPreferenceControllerTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetIntent() {
|
public void testGetSubSettingLauncher() {
|
||||||
ConversationChannelWrapper ccw = new ConversationChannelWrapper();
|
ConversationChannelWrapper ccw = new ConversationChannelWrapper();
|
||||||
NotificationChannel channel = new NotificationChannel("a", "child", 2);
|
NotificationChannel channel = new NotificationChannel("a", "child", 2);
|
||||||
channel.setConversationId("parent", "convo id");
|
channel.setConversationId("parent", "convo id");
|
||||||
@@ -199,7 +199,7 @@ public class ConversationListPreferenceControllerTest {
|
|||||||
ccw.setPkg("pkg");
|
ccw.setPkg("pkg");
|
||||||
ccw.setUid(1);
|
ccw.setUid(1);
|
||||||
ccw.setParentChannelLabel("parent label");
|
ccw.setParentChannelLabel("parent label");
|
||||||
Intent intent = mController.getIntent(ccw, "title");
|
Intent intent = mController.getSubSettingLauncher(ccw, "title").toIntent();
|
||||||
|
|
||||||
Bundle extras = intent.getExtras();
|
Bundle extras = intent.getExtras();
|
||||||
assertThat(extras.getString(AppInfoBase.ARG_PACKAGE_NAME)).isEqualTo(ccw.getPkg());
|
assertThat(extras.getString(AppInfoBase.ARG_PACKAGE_NAME)).isEqualTo(ccw.getPkg());
|
||||||
|
Reference in New Issue
Block a user