Unify the default template and title

On AppDataUsage page, using single source of truth to calculate the
default template, and set title base on the current template.

Fix: 213266028
Fix: 234104784
Test: visual - on AppDataUsage
Test: unit test
Change-Id: I80facca0b000964e901905af51a344a4bc9f498b
This commit is contained in:
Chaohui Wang
2023-10-09 17:43:32 +08:00
parent b7f8c15ff0
commit 6395cf8d30
8 changed files with 119 additions and 94 deletions

View File

@@ -17,7 +17,6 @@ package com.android.settings.datausage;
import static android.content.pm.PackageManager.FEATURE_ETHERNET;
import static android.content.pm.PackageManager.FEATURE_USB_HOST;
import static android.content.pm.PackageManager.FEATURE_WIFI;
import static android.telephony.TelephonyManager.SIM_STATE_READY;
import android.app.usage.NetworkStats.Bucket;
import android.app.usage.NetworkStatsManager;
@@ -49,7 +48,6 @@ import java.util.Optional;
public final class DataUsageUtils {
static final boolean TEST_RADIOS = false;
static final String TEST_RADIOS_PROP = "test.radios";
private static final boolean LOGD = false;
private static final String ETHERNET = "ethernet";
private static final String TAG = "DataUsageUtils";
@@ -106,44 +104,6 @@ public final class DataUsageUtils {
return tele.isDataCapable();
}
/**
* Test if device has a mobile data radio with SIM in ready state.
*/
public static boolean hasReadyMobileRadio(Context context) {
if (DataUsageUtils.TEST_RADIOS) {
return SystemProperties.get(DataUsageUtils.TEST_RADIOS_PROP).contains("mobile");
}
final List<SubscriptionInfo> subInfoList =
ProxySubscriptionManager.getInstance(context)
.getActiveSubscriptionsInfo();
// No activated Subscriptions
if (subInfoList == null) {
if (LOGD) {
Log.d(TAG, "hasReadyMobileRadio: subInfoList=null");
}
return false;
}
final TelephonyManager tele = context.getSystemService(TelephonyManager.class);
// require both supported network and ready SIM
boolean isReady = true;
for (SubscriptionInfo subInfo : subInfoList) {
isReady = isReady & tele.getSimState(subInfo.getSimSlotIndex()) == SIM_STATE_READY;
if (LOGD) {
Log.d(TAG, "hasReadyMobileRadio: subInfo=" + subInfo);
}
}
final boolean isDataCapable = tele.isDataCapable();
final boolean retVal = isDataCapable && isReady;
if (LOGD) {
Log.d(TAG, "hasReadyMobileRadio:"
+ " telephonManager.isDataCapable()="
+ isDataCapable
+ " isReady=" + isReady);
}
return retVal;
}
/**
* Whether device has a Wi-Fi data radio.
*/