Merge "Resolve setContentIntent to single code path" am: 2fbb619b53
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2443102 Change-Id: I00d6ce5f81ba21192117e8efb6f87ffa3b5e26bd Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
@@ -1650,15 +1650,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
mContext, 0, snoozeIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
|
mContext, 0, snoozeIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
|
||||||
|
|
||||||
final Intent viewIntent = buildViewDataUsageIntent(res, policy.template);
|
final Intent viewIntent = buildViewDataUsageIntent(res, policy.template);
|
||||||
// TODO: Resolve to single code path.
|
setContentIntent(builder, viewIntent);
|
||||||
if (UserManager.isHeadlessSystemUserMode()) {
|
|
||||||
builder.setContentIntent(PendingIntent.getActivityAsUser(
|
|
||||||
mContext, 0, viewIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE,
|
|
||||||
/* options= */ null, UserHandle.CURRENT));
|
|
||||||
} else {
|
|
||||||
builder.setContentIntent(PendingIntent.getActivity(
|
|
||||||
mContext, 0, viewIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TYPE_LIMIT: {
|
case TYPE_LIMIT: {
|
||||||
@@ -1679,15 +1671,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
builder.setSmallIcon(R.drawable.stat_notify_disabled_data);
|
builder.setSmallIcon(R.drawable.stat_notify_disabled_data);
|
||||||
|
|
||||||
final Intent intent = buildNetworkOverLimitIntent(res, policy.template);
|
final Intent intent = buildNetworkOverLimitIntent(res, policy.template);
|
||||||
// TODO: Resolve to single code path.
|
setContentIntent(builder, intent);
|
||||||
if (UserManager.isHeadlessSystemUserMode()) {
|
|
||||||
builder.setContentIntent(PendingIntent.getActivityAsUser(
|
|
||||||
mContext, 0, intent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE,
|
|
||||||
/* options= */ null, UserHandle.CURRENT));
|
|
||||||
} else {
|
|
||||||
builder.setContentIntent(PendingIntent.getActivity(
|
|
||||||
mContext, 0, intent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TYPE_LIMIT_SNOOZED: {
|
case TYPE_LIMIT_SNOOZED: {
|
||||||
@@ -1711,15 +1695,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
builder.setChannelId(SystemNotificationChannels.NETWORK_STATUS);
|
builder.setChannelId(SystemNotificationChannels.NETWORK_STATUS);
|
||||||
|
|
||||||
final Intent intent = buildViewDataUsageIntent(res, policy.template);
|
final Intent intent = buildViewDataUsageIntent(res, policy.template);
|
||||||
// TODO: Resolve to single code path.
|
setContentIntent(builder, intent);
|
||||||
if (UserManager.isHeadlessSystemUserMode()) {
|
|
||||||
builder.setContentIntent(PendingIntent.getActivityAsUser(
|
|
||||||
mContext, 0, intent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE,
|
|
||||||
/* options= */ null, UserHandle.CURRENT));
|
|
||||||
} else {
|
|
||||||
builder.setContentIntent(PendingIntent.getActivity(
|
|
||||||
mContext, 0, intent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TYPE_RAPID: {
|
case TYPE_RAPID: {
|
||||||
@@ -1739,15 +1715,7 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
mContext, 0, snoozeIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
|
mContext, 0, snoozeIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
|
||||||
|
|
||||||
final Intent viewIntent = buildViewDataUsageIntent(res, policy.template);
|
final Intent viewIntent = buildViewDataUsageIntent(res, policy.template);
|
||||||
// TODO: Resolve to single code path.
|
setContentIntent(builder, viewIntent);
|
||||||
if (UserManager.isHeadlessSystemUserMode()) {
|
|
||||||
builder.setContentIntent(PendingIntent.getActivityAsUser(
|
|
||||||
mContext, 0, viewIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE,
|
|
||||||
/* options= */ null, UserHandle.CURRENT));
|
|
||||||
} else {
|
|
||||||
builder.setContentIntent(PendingIntent.getActivity(
|
|
||||||
mContext, 0, viewIntent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
@@ -1765,6 +1733,17 @@ public class NetworkPolicyManagerService extends INetworkPolicyManager.Stub {
|
|||||||
mActiveNotifs.add(notificationId);
|
mActiveNotifs.add(notificationId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setContentIntent(Notification.Builder builder, Intent intent) {
|
||||||
|
if (UserManager.isHeadlessSystemUserMode()) {
|
||||||
|
builder.setContentIntent(PendingIntent.getActivityAsUser(
|
||||||
|
mContext, 0, intent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE,
|
||||||
|
/* options= */ null, UserHandle.CURRENT));
|
||||||
|
} else {
|
||||||
|
builder.setContentIntent(PendingIntent.getActivity(
|
||||||
|
mContext, 0, intent, FLAG_UPDATE_CURRENT | FLAG_IMMUTABLE));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void cancelNotification(NotificationId notificationId) {
|
private void cancelNotification(NotificationId notificationId) {
|
||||||
mContext.getSystemService(NotificationManager.class).cancel(notificationId.getTag(),
|
mContext.getSystemService(NotificationManager.class).cancel(notificationId.getTag(),
|
||||||
notificationId.getId());
|
notificationId.getId());
|
||||||
|
|||||||
Reference in New Issue
Block a user