Merge Coral/Flame into AOSP master

Bug: 141248619
Change-Id: I3850f512dadd5e2c6d51af3c8abab1fa5dbc86ad
Merged-In: I46ad5cff3809191483b48fe292dba220a0d699c6
This commit is contained in:
Xin Li
2019-10-25 10:28:05 -07:00
424 changed files with 48167 additions and 39668 deletions

View File

@@ -17,8 +17,11 @@
package com.android.settings.wifi;
import android.content.Context;
import android.content.res.Resources;
import android.provider.Settings;
import android.telephony.SubscriptionManager;
import com.android.internal.annotations.VisibleForTesting;
import com.android.settings.core.TogglePreferenceController;
/**
@@ -33,7 +36,7 @@ public class CellularFallbackPreferenceController extends TogglePreferenceContro
@Override
public int getAvailabilityStatus() {
return !avoidBadWifiConfig() ? AVAILABLE : UNSUPPORTED_ON_DEVICE;
return avoidBadWifiConfig() ? UNSUPPORTED_ON_DEVICE : AVAILABLE;
}
@Override
@@ -49,12 +52,28 @@ public class CellularFallbackPreferenceController extends TogglePreferenceContro
}
private boolean avoidBadWifiConfig() {
return mContext.getResources().getInteger(
com.android.internal.R.integer.config_networkAvoidBadWifi) == 1;
final int activeDataSubscriptionId = getActiveDataSubscriptionId();
if (activeDataSubscriptionId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
return true;
}
final Resources resources = getResourcesForSubId(activeDataSubscriptionId);
return resources.getInteger(com.android.internal.R.integer.config_networkAvoidBadWifi) == 1;
}
@VisibleForTesting
int getActiveDataSubscriptionId() {
return SubscriptionManager.getActiveDataSubscriptionId();
}
@VisibleForTesting
Resources getResourcesForSubId(int subscriptionId) {
return SubscriptionManager.getResourcesForSubId(mContext, subscriptionId,
false /* useRootLocale */);
}
private boolean avoidBadWifiCurrentSettings() {
return "1".equals(Settings.Global.getString(mContext.getContentResolver(),
Settings.Global.NETWORK_AVOID_BAD_WIFI));
}
}
}

View File

@@ -696,7 +696,11 @@ public class WifiDetailPreferenceController extends AbstractPreferenceController
}
mMacAddressPref.setVisible(true);
mMacAddressPref.setSummary(macAddress);
if (macAddress.equals(WifiInfo.DEFAULT_MAC_ADDRESS)) {
mMacAddressPref.setSummary(R.string.device_info_not_available);
} else {
mMacAddressPref.setSummary(macAddress);
}
}
private String getMacAddress() {

View File

@@ -85,7 +85,7 @@ public class TetherService extends Service {
public void onCreate() {
super.onCreate();
if (DEBUG) Log.d(TAG, "Creating TetherService");
String provisionResponse = getResourceForDefaultDataSubId().getString(
String provisionResponse = getResourceForActiveDataSubId().getString(
com.android.internal.R.string.config_mobile_hotspot_provision_response);
registerReceiver(mReceiver, new IntentFilter(provisionResponse),
android.Manifest.permission.TETHER_PRIVILEGED, null);
@@ -105,7 +105,7 @@ public class TetherService extends Service {
if (intent.hasExtra(EXTRA_SUBID)) {
final int tetherSubId = intent.getIntExtra(EXTRA_SUBID,
SubscriptionManager.INVALID_SUBSCRIPTION_ID);
final int subId = getTetherServiceWrapper().getDefaultDataSubscriptionId();
final int subId = getTetherServiceWrapper().getActiveDataSubscriptionId();
if (tetherSubId != subId) {
Log.e(TAG, "This Provisioning request is outdated, current subId: " + subId);
if (!mInProvisionCheck) {
@@ -273,11 +273,13 @@ public class TetherService extends Service {
}
private Intent getProvisionBroadcastIntent(int index) {
String provisionAction = getResourceForDefaultDataSubId().getString(
String provisionAction = getResourceForActiveDataSubId().getString(
com.android.internal.R.string.config_mobile_hotspot_provision_app_no_ui);
final int subId = getTetherServiceWrapper().getActiveDataSubscriptionId();
Intent intent = new Intent(provisionAction);
int type = mCurrentTethers.get(index);
intent.putExtra(TETHER_CHOICE, type);
intent.putExtra(SubscriptionManager.EXTRA_SUBSCRIPTION_INDEX, subId);
intent.setFlags(Intent.FLAG_RECEIVER_FOREGROUND
| Intent.FLAG_RECEIVER_INCLUDE_BACKGROUND);
@@ -309,7 +311,7 @@ public class TetherService extends Service {
PendingIntent pendingIntent = PendingIntent.getService(this, 0, intent, 0);
AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
int period = getResourceForDefaultDataSubId().getInteger(
int period = getResourceForActiveDataSubId().getInteger(
com.android.internal.R.integer.config_mobile_hotspot_provision_check_period);
long periodMs = period * MS_PER_HOUR;
long firstTime = SystemClock.elapsedRealtime() + periodMs;
@@ -362,7 +364,7 @@ public class TetherService extends Service {
@Override
public void onReceive(Context context, Intent intent) {
if (DEBUG) Log.d(TAG, "Got provision result " + intent);
String provisionResponse = getResourceForDefaultDataSubId().getString(
String provisionResponse = getResourceForActiveDataSubId().getString(
com.android.internal.R.string.config_mobile_hotspot_provision_response);
if (provisionResponse.equals(intent.getAction())) {
@@ -429,14 +431,14 @@ public class TetherService extends Service {
mUsageStatsManager.setAppInactive(packageName, isInactive);
}
int getDefaultDataSubscriptionId() {
return SubscriptionManager.getDefaultDataSubscriptionId();
int getActiveDataSubscriptionId() {
return SubscriptionManager.getActiveDataSubscriptionId();
}
}
@VisibleForTesting
Resources getResourceForDefaultDataSubId() {
final int subId = getTetherServiceWrapper().getDefaultDataSubscriptionId();
Resources getResourceForActiveDataSubId() {
final int subId = getTetherServiceWrapper().getActiveDataSubscriptionId();
return Utils.getResourcesForSubId(this, subId);
}
}