Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
55752cf8
Commit
55752cf8
authored
5 years ago
by
Chiachang Wang
Committed by
Gerrit Code Review
5 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Get resource based on subId for multi-SIM"
parents
4204a601
5f8ac27d
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/java/android/net/util/MultinetworkPolicyTracker.java
+26
-9
26 additions, 9 deletions
core/java/android/net/util/MultinetworkPolicyTracker.java
with
26 additions
and
9 deletions
core/java/android/net/util/MultinetworkPolicyTracker.java
+
26
−
9
View file @
55752cf8
...
...
@@ -16,28 +16,31 @@
package
android.net.util
;
import
static
android
.
provider
.
Settings
.
Global
.
NETWORK_AVOID_BAD_WIFI
;
import
static
android
.
provider
.
Settings
.
Global
.
NETWORK_METERED_MULTIPATH_PREFERENCE
;
import
android.annotation.NonNull
;
import
android.content.BroadcastReceiver
;
import
android.content.ContentResolver
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.IntentFilter
;
import
android.content.res.Resources
;
import
android.database.ContentObserver
;
import
android.net.ConnectivityManager
;
import
android.net.Uri
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.os.UserHandle
;
import
android.provider.Settings
;
import
android.telephony.PhoneStateListener
;
import
android.telephony.SubscriptionManager
;
import
android.telephony.TelephonyManager
;
import
android.util.Slog
;
import
java.util.Arrays
;
import
java.util.List
;
import
com.android.internal.annotations.VisibleForTesting
;
import
com.android.internal.R
;
import
com.android.internal.annotations.VisibleForTesting
;
import
static
android
.
provider
.
Settings
.
Global
.
NETWORK_AVOID_BAD_WIFI
;
import
static
android
.
provider
.
Settings
.
Global
.
NETWORK_METERED_MULTIPATH_PREFERENCE
;
import
java.util.Arrays
;
import
java.util.List
;
/**
* A class to encapsulate management of the "Smart Networking" capability of
...
...
@@ -69,6 +72,7 @@ public class MultinetworkPolicyTracker {
private
volatile
boolean
mAvoidBadWifi
=
true
;
private
volatile
int
mMeteredMultipathPreference
;
private
int
mActiveSubId
=
SubscriptionManager
.
INVALID_SUBSCRIPTION_ID
;
public
MultinetworkPolicyTracker
(
Context
ctx
,
Handler
handler
)
{
this
(
ctx
,
handler
,
null
);
...
...
@@ -95,6 +99,14 @@ public class MultinetworkPolicyTracker {
}
};
TelephonyManager
.
from
(
ctx
).
listen
(
new
PhoneStateListener
()
{
@Override
public
void
onActiveDataSubscriptionIdChanged
(
int
subId
)
{
mActiveSubId
=
subId
;
reevaluate
();
}
},
PhoneStateListener
.
LISTEN_ACTIVE_DATA_SUBSCRIPTION_ID_CHANGE
);
updateAvoidBadWifi
();
updateMeteredMultipathPreference
();
}
...
...
@@ -131,7 +143,12 @@ public class MultinetworkPolicyTracker {
* Whether the device or carrier configuration disables avoiding bad wifi by default.
*/
public
boolean
configRestrictsAvoidBadWifi
()
{
return
(
mContext
.
getResources
().
getInteger
(
R
.
integer
.
config_networkAvoidBadWifi
)
==
0
);
return
(
getResourcesForActiveSubId
().
getInteger
(
R
.
integer
.
config_networkAvoidBadWifi
)
==
0
);
}
@NonNull
private
Resources
getResourcesForActiveSubId
()
{
return
SubscriptionManager
.
getResourcesForSubId
(
mContext
,
mActiveSubId
);
}
/**
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment