Display "Android Auto" in Connected Devices summary text.
Android Auto will be exposing a Settings tile under Connected Devices -> Connection Preferences. If the Setting tile is available, then the summary text will reflect that. Tested with additional unit tests and manually validated the scenarios by flashing crosshatch-eng and disabling/enabling the relevant features. Fix: 153896447 Test: Added unit coverage for new scenarios Test: make RunSettingsRoboTests Test: manually verified by flashing crosshatch-eng and disabling/enabling relevant components Change-Id: I05e0bca1b4c05939114703f868b1c71b76410532
This commit is contained in:
@@ -15,7 +15,10 @@
|
||||
*/
|
||||
package com.android.settings.connecteddevice;
|
||||
|
||||
import static com.android.settingslib.drawer.TileUtils.IA_SETTINGS_ACTION;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.Settings;
|
||||
|
||||
import androidx.annotation.VisibleForTesting;
|
||||
@@ -31,6 +34,7 @@ public class AdvancedConnectedDeviceController extends BasePreferenceController
|
||||
|
||||
private static final String DRIVING_MODE_SETTINGS_ENABLED =
|
||||
"gearhead:driving_mode_settings_enabled";
|
||||
private static final String GEARHEAD_PACKAGE = "com.google.android.projection.gearhead";
|
||||
|
||||
public AdvancedConnectedDeviceController(Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
@@ -55,7 +59,7 @@ public class AdvancedConnectedDeviceController extends BasePreferenceController
|
||||
new NfcPreferenceController(context, NfcPreferenceController.KEY_TOGGLE_NFC);
|
||||
|
||||
return getConnectedDevicesSummaryResourceId(nfcPreferenceController,
|
||||
isDrivingModeAvailable(context));
|
||||
isDrivingModeAvailable(context), isAndroidAutoSettingAvailable(context));
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
@@ -64,26 +68,57 @@ public class AdvancedConnectedDeviceController extends BasePreferenceController
|
||||
getInt(context.getContentResolver(), DRIVING_MODE_SETTINGS_ENABLED, 0) == 1;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static boolean isAndroidAutoSettingAvailable(Context context) {
|
||||
final Intent intent = new Intent(IA_SETTINGS_ACTION);
|
||||
intent.setPackage(GEARHEAD_PACKAGE);
|
||||
return intent.resolveActivity(context.getPackageManager()) != null;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
static int getConnectedDevicesSummaryResourceId(NfcPreferenceController
|
||||
nfcPreferenceController, boolean isDrivingModeAvailable) {
|
||||
nfcPreferenceController,
|
||||
boolean isDrivingModeAvailable,
|
||||
boolean isAndroidAutoAvailable) {
|
||||
final int resId;
|
||||
|
||||
if (nfcPreferenceController.isAvailable()) {
|
||||
if (isDrivingModeAvailable) {
|
||||
// NFC available, driving mode available
|
||||
resId = R.string.connected_devices_dashboard_summary;
|
||||
if (isAndroidAutoAvailable) {
|
||||
if (nfcPreferenceController.isAvailable()) {
|
||||
if (isDrivingModeAvailable) {
|
||||
// NFC available, driving mode available
|
||||
resId = R.string.connected_devices_dashboard_android_auto_summary;
|
||||
} else {
|
||||
// NFC available, driving mode not available
|
||||
resId =
|
||||
R.string.connected_devices_dashboard_android_auto_no_driving_mode_summary;
|
||||
}
|
||||
} else {
|
||||
// NFC available, driving mode not available
|
||||
resId = R.string.connected_devices_dashboard_no_driving_mode_summary;
|
||||
if (isDrivingModeAvailable) {
|
||||
// NFC not available, driving mode available
|
||||
resId = R.string.connected_devices_dashboard_android_auto_no_nfc_summary;
|
||||
} else {
|
||||
// NFC not available, driving mode not available
|
||||
resId =
|
||||
R.string.connected_devices_dashboard_android_auto_no_nfc_no_driving_mode;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isDrivingModeAvailable) {
|
||||
// NFC not available, driving mode available
|
||||
resId = R.string.connected_devices_dashboard_no_nfc_summary;
|
||||
if (nfcPreferenceController.isAvailable()) {
|
||||
if (isDrivingModeAvailable) {
|
||||
// NFC available, driving mode available
|
||||
resId = R.string.connected_devices_dashboard_summary;
|
||||
} else {
|
||||
// NFC available, driving mode not available
|
||||
resId = R.string.connected_devices_dashboard_no_driving_mode_summary;
|
||||
}
|
||||
} else {
|
||||
// NFC not available, driving mode not available
|
||||
resId = R.string.connected_devices_dashboard_no_driving_mode_no_nfc_summary;
|
||||
if (isDrivingModeAvailable) {
|
||||
// NFC not available, driving mode available
|
||||
resId = R.string.connected_devices_dashboard_no_nfc_summary;
|
||||
} else {
|
||||
// NFC not available, driving mode not available
|
||||
resId = R.string.connected_devices_dashboard_no_driving_mode_no_nfc_summary;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user