Use new API to get mergedSubscriberIds based on grouping.
In addition, make mMergedSubscriberIds a list to fit usage of multi-SIM devices. Bug: 135105735 Bug: 137137221 Test: manual Change-Id: I364262559789112f35b88f4c298463bf4af2e82a
This commit is contained in:
@@ -48,6 +48,7 @@ import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -481,17 +482,39 @@ public class NetworkTemplate implements Parcelable {
|
||||
* For example, given an incoming template matching B, and the currently
|
||||
* active merge set [A,B], we'd return a new template that primarily matches
|
||||
* A, but also matches B.
|
||||
* TODO: remove and use {@link #normalize(NetworkTemplate, List)}.
|
||||
*/
|
||||
@UnsupportedAppUsage
|
||||
public static NetworkTemplate normalize(NetworkTemplate template, String[] merged) {
|
||||
if (template.isMatchRuleMobile() && ArrayUtils.contains(merged, template.mSubscriberId)) {
|
||||
// Requested template subscriber is part of the merge group; return
|
||||
// a template that matches all merged subscribers.
|
||||
return new NetworkTemplate(template.mMatchRule, merged[0], merged,
|
||||
template.mNetworkId);
|
||||
} else {
|
||||
return template;
|
||||
return normalize(template, Arrays.<String[]>asList(merged));
|
||||
}
|
||||
|
||||
/**
|
||||
* Examine the given template and normalize if it refers to a "merged"
|
||||
* mobile subscriber. We pick the "lowest" merged subscriber as the primary
|
||||
* for key purposes, and expand the template to match all other merged
|
||||
* subscribers.
|
||||
*
|
||||
* There can be multiple merged subscriberIds for multi-SIM devices.
|
||||
*
|
||||
* <p>
|
||||
* For example, given an incoming template matching B, and the currently
|
||||
* active merge set [A,B], we'd return a new template that primarily matches
|
||||
* A, but also matches B.
|
||||
*/
|
||||
public static NetworkTemplate normalize(NetworkTemplate template, List<String[]> mergedList) {
|
||||
if (!template.isMatchRuleMobile()) return template;
|
||||
|
||||
for (String[] merged : mergedList) {
|
||||
if (ArrayUtils.contains(merged, template.mSubscriberId)) {
|
||||
// Requested template subscriber is part of the merge group; return
|
||||
// a template that matches all merged subscribers.
|
||||
return new NetworkTemplate(template.mMatchRule, merged[0], merged,
|
||||
template.mNetworkId);
|
||||
}
|
||||
}
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
@UnsupportedAppUsage
|
||||
|
||||
Reference in New Issue
Block a user