[Safer intents] Notifications
To avoid implicit intents, make intents launch explicitly. Test: build Bug: 323061508 Change-Id: I68624ca7c913c473490f371409ae35acbb4f6fb2
This commit is contained in:
@@ -56,6 +56,7 @@ public class BubbleCategoryPreferenceController extends NotificationPreferenceCo
|
|||||||
|
|
||||||
if (mAppRow != null) {
|
if (mAppRow != null) {
|
||||||
final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_BUBBLE_SETTINGS);
|
final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_BUBBLE_SETTINGS);
|
||||||
|
intent.setPackage(mContext.getPackageName());
|
||||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, mAppRow.pkg);
|
intent.putExtra(Settings.EXTRA_APP_PACKAGE, mAppRow.pkg);
|
||||||
intent.putExtra(Settings.EXTRA_APP_UID, mAppRow.uid);
|
intent.putExtra(Settings.EXTRA_APP_UID, mAppRow.uid);
|
||||||
preference.setIntent(intent);
|
preference.setIntent(intent);
|
||||||
|
@@ -56,6 +56,7 @@ public class BubbleLinkPreferenceController extends NotificationPreferenceContro
|
|||||||
|
|
||||||
if (mAppRow != null) {
|
if (mAppRow != null) {
|
||||||
final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_BUBBLE_SETTINGS);
|
final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_BUBBLE_SETTINGS);
|
||||||
|
intent.setPackage(mContext.getPackageName());
|
||||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, mAppRow.pkg);
|
intent.putExtra(Settings.EXTRA_APP_PACKAGE, mAppRow.pkg);
|
||||||
intent.putExtra(Settings.EXTRA_APP_UID, mAppRow.uid);
|
intent.putExtra(Settings.EXTRA_APP_UID, mAppRow.uid);
|
||||||
preference.setIntent(intent);
|
preference.setIntent(intent);
|
||||||
|
@@ -77,6 +77,7 @@ public class BubbleSummaryPreferenceController extends NotificationPreferenceCon
|
|||||||
|
|
||||||
if (mAppRow != null) {
|
if (mAppRow != null) {
|
||||||
final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_BUBBLE_SETTINGS);
|
final Intent intent = new Intent(Settings.ACTION_APP_NOTIFICATION_BUBBLE_SETTINGS);
|
||||||
|
intent.setPackage(mContext.getPackageName());
|
||||||
intent.putExtra(Settings.EXTRA_APP_PACKAGE, mAppRow.pkg);
|
intent.putExtra(Settings.EXTRA_APP_PACKAGE, mAppRow.pkg);
|
||||||
intent.putExtra(Settings.EXTRA_APP_UID, mAppRow.uid);
|
intent.putExtra(Settings.EXTRA_APP_UID, mAppRow.uid);
|
||||||
preference.setIntent(intent);
|
preference.setIntent(intent);
|
||||||
|
@@ -38,6 +38,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|||||||
|
|
||||||
import com.android.internal.logging.UiEventLogger;
|
import com.android.internal.logging.UiEventLogger;
|
||||||
import com.android.settings.R;
|
import com.android.settings.R;
|
||||||
|
import com.android.settings.Utils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -87,6 +88,7 @@ public class NotificationHistoryAdapter extends
|
|||||||
mUiEventLogger.logWithPosition(NotificationHistoryActivity.NotificationHistoryEvent
|
mUiEventLogger.logWithPosition(NotificationHistoryActivity.NotificationHistoryEvent
|
||||||
.NOTIFICATION_HISTORY_OLDER_ITEM_CLICK, hn.getUid(), hn.getPackage(), position);
|
.NOTIFICATION_HISTORY_OLDER_ITEM_CLICK, hn.getUid(), hn.getPackage(), position);
|
||||||
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
||||||
|
.setPackage(Utils.SETTINGS_PACKAGE_NAME)
|
||||||
.putExtra(EXTRA_APP_PACKAGE, hn.getPackage())
|
.putExtra(EXTRA_APP_PACKAGE, hn.getPackage())
|
||||||
.putExtra(EXTRA_CHANNEL_ID, hn.getChannelId())
|
.putExtra(EXTRA_CHANNEL_ID, hn.getChannelId())
|
||||||
.putExtra(EXTRA_CONVERSATION_ID, hn.getConversationId());
|
.putExtra(EXTRA_CONVERSATION_ID, hn.getConversationId());
|
||||||
|
@@ -130,6 +130,7 @@ public class NotificationSbnAdapter extends
|
|||||||
mUiEventLogger);
|
mUiEventLogger);
|
||||||
holder.itemView.setOnLongClickListener(v -> {
|
holder.itemView.setOnLongClickListener(v -> {
|
||||||
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
||||||
|
.setPackage(mContext.getPackageName())
|
||||||
.putExtra(EXTRA_APP_PACKAGE, sbn.getPackageName())
|
.putExtra(EXTRA_APP_PACKAGE, sbn.getPackageName())
|
||||||
.putExtra(EXTRA_CHANNEL_ID, sbn.getNotification().getChannelId())
|
.putExtra(EXTRA_CHANNEL_ID, sbn.getNotification().getChannelId())
|
||||||
.putExtra(EXTRA_CONVERSATION_ID, sbn.getNotification().getShortcutId());
|
.putExtra(EXTRA_CONVERSATION_ID, sbn.getNotification().getShortcutId());
|
||||||
|
@@ -751,6 +751,7 @@ public class NotificationStation extends SettingsPreferenceFragment {
|
|||||||
@Override
|
@Override
|
||||||
public void performClick() {
|
public void performClick() {
|
||||||
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
Intent intent = new Intent(Settings.ACTION_CHANNEL_NOTIFICATION_SETTINGS)
|
||||||
|
.setPackage(mContext.getPackageName())
|
||||||
.putExtra(EXTRA_APP_PACKAGE, mInfo.pkg)
|
.putExtra(EXTRA_APP_PACKAGE, mInfo.pkg)
|
||||||
.putExtra(EXTRA_CHANNEL_ID,
|
.putExtra(EXTRA_CHANNEL_ID,
|
||||||
mInfo.channel != null ? mInfo.channel.getId() : mInfo.channelId);
|
mInfo.channel != null ? mInfo.channel.getId() : mInfo.channelId);
|
||||||
|
@@ -28,20 +28,18 @@ import android.content.pm.ActivityInfo;
|
|||||||
import android.content.pm.ComponentInfo;
|
import android.content.pm.ComponentInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.content.pm.ServiceInfo;
|
import android.content.pm.ServiceInfo;
|
||||||
import android.os.Binder;
|
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
import android.service.notification.ConditionProviderService;
|
import android.service.notification.ConditionProviderService;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Slog;
|
|
||||||
|
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
|
|
||||||
|
import com.android.settings.Utils;
|
||||||
import com.android.settings.core.PreferenceControllerMixin;
|
import com.android.settings.core.PreferenceControllerMixin;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
abstract public class AbstractZenModeAutomaticRulePreferenceController extends
|
abstract public class AbstractZenModeAutomaticRulePreferenceController extends
|
||||||
AbstractZenModePreferenceController implements PreferenceControllerMixin {
|
AbstractZenModePreferenceController implements PreferenceControllerMixin {
|
||||||
@@ -85,6 +83,7 @@ abstract public class AbstractZenModeAutomaticRulePreferenceController extends
|
|||||||
intent.setComponent(configurationActivity);
|
intent.setComponent(configurationActivity);
|
||||||
} else {
|
} else {
|
||||||
intent.setAction(settingsAction);
|
intent.setAction(settingsAction);
|
||||||
|
intent.setPackage(Utils.SETTINGS_PACKAGE_NAME);
|
||||||
}
|
}
|
||||||
return intent;
|
return intent;
|
||||||
}
|
}
|
||||||
|
@@ -116,7 +116,8 @@ public class ZenOnboardingActivity extends Activity {
|
|||||||
|
|
||||||
public void launchSettings(View button) {
|
public void launchSettings(View button) {
|
||||||
mMetrics.action(SettingsEnums.ACTION_ZEN_ONBOARDING_SETTINGS);
|
mMetrics.action(SettingsEnums.ACTION_ZEN_ONBOARDING_SETTINGS);
|
||||||
Intent settings = new Intent(Settings.ACTION_ZEN_MODE_SETTINGS);
|
Intent settings = new Intent(Settings.ACTION_ZEN_MODE_SETTINGS)
|
||||||
|
.setPackage(getPackageName());
|
||||||
settings.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
settings.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
startActivity(settings);
|
startActivity(settings);
|
||||||
}
|
}
|
||||||
|
@@ -95,6 +95,11 @@ public class ZenPrioritySendersHelper {
|
|||||||
mNotificationBackend = notificationBackend;
|
mNotificationBackend = notificationBackend;
|
||||||
mSelectorClickListener = clickListener;
|
mSelectorClickListener = clickListener;
|
||||||
|
|
||||||
|
String contactsPackage = context.getString(R.string.config_contacts_package_name);
|
||||||
|
ALL_CONTACTS_INTENT.setPackage(contactsPackage);
|
||||||
|
STARRED_CONTACTS_INTENT.setPackage(contactsPackage);
|
||||||
|
FALLBACK_INTENT.setPackage(contactsPackage);
|
||||||
|
|
||||||
mPackageManager = mContext.getPackageManager();
|
mPackageManager = mContext.getPackageManager();
|
||||||
if (!FALLBACK_INTENT.hasCategory(Intent.CATEGORY_APP_CONTACTS)) {
|
if (!FALLBACK_INTENT.hasCategory(Intent.CATEGORY_APP_CONTACTS)) {
|
||||||
FALLBACK_INTENT.addCategory(Intent.CATEGORY_APP_CONTACTS);
|
FALLBACK_INTENT.addCategory(Intent.CATEGORY_APP_CONTACTS);
|
||||||
|
@@ -25,6 +25,7 @@ import android.service.notification.ZenPolicy;
|
|||||||
import androidx.preference.Preference;
|
import androidx.preference.Preference;
|
||||||
import androidx.preference.PreferenceScreen;
|
import androidx.preference.PreferenceScreen;
|
||||||
|
|
||||||
|
import com.android.settings.R;
|
||||||
import com.android.settingslib.core.lifecycle.Lifecycle;
|
import com.android.settingslib.core.lifecycle.Lifecycle;
|
||||||
|
|
||||||
public class ZenRuleStarredContactsPreferenceController extends
|
public class ZenRuleStarredContactsPreferenceController extends
|
||||||
@@ -43,10 +44,13 @@ public class ZenRuleStarredContactsPreferenceController extends
|
|||||||
mPriorityCategory = priorityCategory;
|
mPriorityCategory = priorityCategory;
|
||||||
mPackageManager = mContext.getPackageManager();
|
mPackageManager = mContext.getPackageManager();
|
||||||
|
|
||||||
|
String contactsPackage = context.getString(R.string.config_contacts_package_name);
|
||||||
mStarredContactsIntent = new Intent(Contacts.Intents.UI.LIST_STARRED_ACTION)
|
mStarredContactsIntent = new Intent(Contacts.Intents.UI.LIST_STARRED_ACTION)
|
||||||
|
.setPackage(contactsPackage)
|
||||||
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
|
|
||||||
mFallbackIntent = new Intent(Intent.ACTION_MAIN);
|
mFallbackIntent = new Intent(Intent.ACTION_MAIN);
|
||||||
|
mFallbackIntent.setPackage(contactsPackage);
|
||||||
mFallbackIntent.addCategory(Intent.CATEGORY_APP_CONTACTS);
|
mFallbackIntent.addCategory(Intent.CATEGORY_APP_CONTACTS);
|
||||||
mFallbackIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
mFallbackIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
|
||||||
}
|
}
|
||||||
|
@@ -12,11 +12,13 @@ public class ZenSuggestionActivity extends Activity {
|
|||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
// start up zen settings activity
|
// start up zen settings activity
|
||||||
Intent settingsIntent = new Intent(Settings.ACTION_ZEN_MODE_SETTINGS);
|
Intent settingsIntent = new Intent(Settings.ACTION_ZEN_MODE_SETTINGS)
|
||||||
|
.setPackage(getPackageName());
|
||||||
startActivity(settingsIntent);
|
startActivity(settingsIntent);
|
||||||
|
|
||||||
// start up onboarding activity
|
// start up onboarding activity
|
||||||
Intent onboardingActivity = new Intent(Settings.ZEN_MODE_ONBOARDING);
|
Intent onboardingActivity = new Intent(Settings.ZEN_MODE_ONBOARDING)
|
||||||
|
.setPackage(getPackageName());
|
||||||
startActivity(onboardingActivity);
|
startActivity(onboardingActivity);
|
||||||
|
|
||||||
finish();
|
finish();
|
||||||
|
Reference in New Issue
Block a user