Skip to content

Commit

Permalink
Tentative fix for Project Fi.
Browse files Browse the repository at this point in the history
  • Loading branch information
francoiscampbell committed Apr 26, 2016
1 parent 5b0d4e2 commit d835625
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions app/src/main/java/android/net/NetworkTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ public abstract class NetworkTemplate {
public static NetworkTemplate buildTemplateMobileAll(String subscriberId) {
throw new StubClassNotShadowedError();
}

public static NetworkTemplate normalize(NetworkTemplate template, String[] merged) {
throw new StubClassNotShadowedError();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import android.net.INetworkStatsService
import android.net.NetworkPolicy
import android.net.NetworkPolicyManager
import android.net.NetworkTemplate
import android.os.Build
import android.telephony.TelephonyManager
import de.robv.android.xposed.XposedHelpers
import javax.inject.Inject
import javax.inject.Named

Expand Down Expand Up @@ -51,7 +53,16 @@ class DataUsageFetcherImpl

private fun getCurrentNetworkTemplate(): NetworkTemplate? {
val subscriberId = telephonyManager.subscriberId ?: return null
return NetworkTemplate.buildTemplateMobileAll(subscriberId)
var template = NetworkTemplate.buildTemplateMobileAll(subscriberId)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
val mergedSubscriberIds = XposedHelpers.callMethod(telephonyManager, "getMergedSubscriberIds")
if (mergedSubscriberIds != null) {
@Suppress("UNCHECKED_CAST")
return NetworkTemplate.normalize(template, mergedSubscriberIds as Array<String>)
}
}
return template

}

private fun getPolicyForTemplate(networkTemplate: NetworkTemplate): NetworkPolicy? {
Expand Down

0 comments on commit d835625

Please sign in to comment.