Loading android/app/src/com/android/bluetooth/btservice/CompanionManager.java +60 −27 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothGatt; import android.content.Context; import android.content.SharedPreferences; import android.os.SystemProperties; import android.util.Log; import androidx.annotation.VisibleForTesting; Loading Loading @@ -69,61 +70,93 @@ public class CompanionManager { @VisibleForTesting static final String COMPANION_DEVICE_KEY = "companion_device"; @VisibleForTesting static final String COMPANION_TYPE_KEY = "companion_type"; static final String PROPERTY_HIGH_MIN_INTERVAL = "bluetooth.gatt.high_priority.min_interval"; static final String PROPERTY_HIGH_MAX_INTERVAL = "bluetooth.gatt.high_priority.max_interval"; static final String PROPERTY_HIGH_LATENCY = "bluetooth.gatt.high_priority.latency"; static final String PROPERTY_BALANCED_MIN_INTERVAL = "bluetooth.gatt.balanced_priority.min_interval"; static final String PROPERTY_BALANCED_MAX_INTERVAL = "bluetooth.gatt.balanced_priority.max_interval"; static final String PROPERTY_BALANCED_LATENCY = "bluetooth.gatt.balanced_priority.latency"; static final String PROPERTY_LOW_MIN_INTERVAL = "bluetooth.gatt.low_priority_min.interval"; static final String PROPERTY_LOW_MAX_INTERVAL = "bluetooth.gatt.low_priority_max.interval"; static final String PROPERTY_LOW_LATENCY = "bluetooth.gatt.low_priority.latency"; static final String PROPERTY_SUFFIX_PRIMARY = ".primary"; static final String PROPERTY_SUFFIX_SECONDARY = ".secondary"; private final AdapterService mAdapterService; private final BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter(); private final Set<BluetoothDevice> mMetadataListeningDevices = new HashSet<>(); public CompanionManager(AdapterService service, ServiceFactory factory) { mAdapterService = service; mGattConnHighDefault = new int[] { service.getResources().getInteger(R.integer.gatt_high_priority_min_interval), service.getResources().getInteger(R.integer.gatt_high_priority_max_interval), service.getResources().getInteger(R.integer.gatt_high_priority_latency)}; getGattConfig(PROPERTY_HIGH_MIN_INTERVAL, R.integer.gatt_high_priority_min_interval), getGattConfig(PROPERTY_HIGH_MAX_INTERVAL, R.integer.gatt_high_priority_max_interval), getGattConfig(PROPERTY_HIGH_LATENCY, R.integer.gatt_high_priority_latency)}; mGattConnBalanceDefault = new int[] { service.getResources().getInteger(R.integer.gatt_balanced_priority_min_interval), service.getResources().getInteger(R.integer.gatt_balanced_priority_max_interval), service.getResources().getInteger(R.integer.gatt_balanced_priority_latency)}; getGattConfig(PROPERTY_BALANCED_MIN_INTERVAL, R.integer.gatt_balanced_priority_min_interval), getGattConfig(PROPERTY_BALANCED_MAX_INTERVAL, R.integer.gatt_balanced_priority_max_interval), getGattConfig(PROPERTY_BALANCED_LATENCY, R.integer.gatt_balanced_priority_latency)}; mGattConnLowDefault = new int[] { service.getResources().getInteger(R.integer.gatt_low_power_min_interval), service.getResources().getInteger(R.integer.gatt_low_power_max_interval), service.getResources().getInteger(R.integer.gatt_low_power_latency)}; getGattConfig(PROPERTY_LOW_MIN_INTERVAL, R.integer.gatt_low_power_min_interval), getGattConfig(PROPERTY_LOW_MAX_INTERVAL, R.integer.gatt_low_power_max_interval), getGattConfig(PROPERTY_LOW_LATENCY, R.integer.gatt_low_power_latency)}; mGattConnHighPrimary = new int[] { service.getResources().getInteger( getGattConfig(PROPERTY_HIGH_MIN_INTERVAL + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_high_priority_min_interval_primary), service.getResources().getInteger( getGattConfig(PROPERTY_HIGH_MAX_INTERVAL + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_high_priority_max_interval_primary), service.getResources().getInteger( getGattConfig(PROPERTY_HIGH_LATENCY + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_high_priority_latency_primary)}; mGattConnBalancePrimary = new int[] { service.getResources().getInteger( getGattConfig(PROPERTY_BALANCED_MIN_INTERVAL + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_balanced_priority_min_interval_primary), service.getResources().getInteger( getGattConfig(PROPERTY_BALANCED_MAX_INTERVAL + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_balanced_priority_max_interval_primary), service.getResources().getInteger( getGattConfig(PROPERTY_BALANCED_LATENCY + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_balanced_priority_latency_primary)}; mGattConnLowPrimary = new int[] { service.getResources().getInteger(R.integer.gatt_low_power_min_interval_primary), service.getResources().getInteger(R.integer.gatt_low_power_max_interval_primary), service.getResources().getInteger(R.integer.gatt_low_power_latency_primary)}; getGattConfig(PROPERTY_LOW_MIN_INTERVAL + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_low_power_min_interval_primary), getGattConfig(PROPERTY_LOW_MAX_INTERVAL + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_low_power_max_interval_primary), getGattConfig(PROPERTY_LOW_LATENCY + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_low_power_latency_primary)}; mGattConnHighSecondary = new int[] { service.getResources().getInteger( getGattConfig(PROPERTY_HIGH_MIN_INTERVAL + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_high_priority_min_interval_secondary), service.getResources().getInteger( getGattConfig(PROPERTY_HIGH_MAX_INTERVAL + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_high_priority_max_interval_secondary), service.getResources().getInteger(R.integer.gatt_high_priority_latency_secondary)}; getGattConfig(PROPERTY_HIGH_LATENCY + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_high_priority_latency_secondary)}; mGattConnBalanceSecondary = new int[] { service.getResources().getInteger( getGattConfig(PROPERTY_BALANCED_MIN_INTERVAL + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_balanced_priority_min_interval_secondary), service.getResources().getInteger( getGattConfig(PROPERTY_BALANCED_MAX_INTERVAL + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_balanced_priority_max_interval_secondary), service.getResources().getInteger( getGattConfig(PROPERTY_BALANCED_LATENCY + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_balanced_priority_latency_secondary)}; mGattConnLowSecondary = new int[] { service.getResources().getInteger(R.integer.gatt_low_power_min_interval_secondary), service.getResources().getInteger(R.integer.gatt_low_power_max_interval_secondary), service.getResources().getInteger(R.integer.gatt_low_power_latency_secondary)}; getGattConfig(PROPERTY_LOW_MIN_INTERVAL + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_low_power_min_interval_secondary), getGattConfig(PROPERTY_LOW_MAX_INTERVAL + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_low_power_max_interval_secondary), getGattConfig(PROPERTY_LOW_LATENCY + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_low_power_latency_secondary)}; } private int getGattConfig(String property, int resId) { return SystemProperties.getInt(property, mAdapterService.getResources().getInteger(resId)); } void loadCompanionInfo() { Loading Loading
android/app/src/com/android/bluetooth/btservice/CompanionManager.java +60 −27 Original line number Diff line number Diff line Loading @@ -21,6 +21,7 @@ import android.bluetooth.BluetoothDevice; import android.bluetooth.BluetoothGatt; import android.content.Context; import android.content.SharedPreferences; import android.os.SystemProperties; import android.util.Log; import androidx.annotation.VisibleForTesting; Loading Loading @@ -69,61 +70,93 @@ public class CompanionManager { @VisibleForTesting static final String COMPANION_DEVICE_KEY = "companion_device"; @VisibleForTesting static final String COMPANION_TYPE_KEY = "companion_type"; static final String PROPERTY_HIGH_MIN_INTERVAL = "bluetooth.gatt.high_priority.min_interval"; static final String PROPERTY_HIGH_MAX_INTERVAL = "bluetooth.gatt.high_priority.max_interval"; static final String PROPERTY_HIGH_LATENCY = "bluetooth.gatt.high_priority.latency"; static final String PROPERTY_BALANCED_MIN_INTERVAL = "bluetooth.gatt.balanced_priority.min_interval"; static final String PROPERTY_BALANCED_MAX_INTERVAL = "bluetooth.gatt.balanced_priority.max_interval"; static final String PROPERTY_BALANCED_LATENCY = "bluetooth.gatt.balanced_priority.latency"; static final String PROPERTY_LOW_MIN_INTERVAL = "bluetooth.gatt.low_priority_min.interval"; static final String PROPERTY_LOW_MAX_INTERVAL = "bluetooth.gatt.low_priority_max.interval"; static final String PROPERTY_LOW_LATENCY = "bluetooth.gatt.low_priority.latency"; static final String PROPERTY_SUFFIX_PRIMARY = ".primary"; static final String PROPERTY_SUFFIX_SECONDARY = ".secondary"; private final AdapterService mAdapterService; private final BluetoothAdapter mAdapter = BluetoothAdapter.getDefaultAdapter(); private final Set<BluetoothDevice> mMetadataListeningDevices = new HashSet<>(); public CompanionManager(AdapterService service, ServiceFactory factory) { mAdapterService = service; mGattConnHighDefault = new int[] { service.getResources().getInteger(R.integer.gatt_high_priority_min_interval), service.getResources().getInteger(R.integer.gatt_high_priority_max_interval), service.getResources().getInteger(R.integer.gatt_high_priority_latency)}; getGattConfig(PROPERTY_HIGH_MIN_INTERVAL, R.integer.gatt_high_priority_min_interval), getGattConfig(PROPERTY_HIGH_MAX_INTERVAL, R.integer.gatt_high_priority_max_interval), getGattConfig(PROPERTY_HIGH_LATENCY, R.integer.gatt_high_priority_latency)}; mGattConnBalanceDefault = new int[] { service.getResources().getInteger(R.integer.gatt_balanced_priority_min_interval), service.getResources().getInteger(R.integer.gatt_balanced_priority_max_interval), service.getResources().getInteger(R.integer.gatt_balanced_priority_latency)}; getGattConfig(PROPERTY_BALANCED_MIN_INTERVAL, R.integer.gatt_balanced_priority_min_interval), getGattConfig(PROPERTY_BALANCED_MAX_INTERVAL, R.integer.gatt_balanced_priority_max_interval), getGattConfig(PROPERTY_BALANCED_LATENCY, R.integer.gatt_balanced_priority_latency)}; mGattConnLowDefault = new int[] { service.getResources().getInteger(R.integer.gatt_low_power_min_interval), service.getResources().getInteger(R.integer.gatt_low_power_max_interval), service.getResources().getInteger(R.integer.gatt_low_power_latency)}; getGattConfig(PROPERTY_LOW_MIN_INTERVAL, R.integer.gatt_low_power_min_interval), getGattConfig(PROPERTY_LOW_MAX_INTERVAL, R.integer.gatt_low_power_max_interval), getGattConfig(PROPERTY_LOW_LATENCY, R.integer.gatt_low_power_latency)}; mGattConnHighPrimary = new int[] { service.getResources().getInteger( getGattConfig(PROPERTY_HIGH_MIN_INTERVAL + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_high_priority_min_interval_primary), service.getResources().getInteger( getGattConfig(PROPERTY_HIGH_MAX_INTERVAL + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_high_priority_max_interval_primary), service.getResources().getInteger( getGattConfig(PROPERTY_HIGH_LATENCY + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_high_priority_latency_primary)}; mGattConnBalancePrimary = new int[] { service.getResources().getInteger( getGattConfig(PROPERTY_BALANCED_MIN_INTERVAL + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_balanced_priority_min_interval_primary), service.getResources().getInteger( getGattConfig(PROPERTY_BALANCED_MAX_INTERVAL + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_balanced_priority_max_interval_primary), service.getResources().getInteger( getGattConfig(PROPERTY_BALANCED_LATENCY + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_balanced_priority_latency_primary)}; mGattConnLowPrimary = new int[] { service.getResources().getInteger(R.integer.gatt_low_power_min_interval_primary), service.getResources().getInteger(R.integer.gatt_low_power_max_interval_primary), service.getResources().getInteger(R.integer.gatt_low_power_latency_primary)}; getGattConfig(PROPERTY_LOW_MIN_INTERVAL + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_low_power_min_interval_primary), getGattConfig(PROPERTY_LOW_MAX_INTERVAL + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_low_power_max_interval_primary), getGattConfig(PROPERTY_LOW_LATENCY + PROPERTY_SUFFIX_PRIMARY, R.integer.gatt_low_power_latency_primary)}; mGattConnHighSecondary = new int[] { service.getResources().getInteger( getGattConfig(PROPERTY_HIGH_MIN_INTERVAL + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_high_priority_min_interval_secondary), service.getResources().getInteger( getGattConfig(PROPERTY_HIGH_MAX_INTERVAL + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_high_priority_max_interval_secondary), service.getResources().getInteger(R.integer.gatt_high_priority_latency_secondary)}; getGattConfig(PROPERTY_HIGH_LATENCY + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_high_priority_latency_secondary)}; mGattConnBalanceSecondary = new int[] { service.getResources().getInteger( getGattConfig(PROPERTY_BALANCED_MIN_INTERVAL + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_balanced_priority_min_interval_secondary), service.getResources().getInteger( getGattConfig(PROPERTY_BALANCED_MAX_INTERVAL + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_balanced_priority_max_interval_secondary), service.getResources().getInteger( getGattConfig(PROPERTY_BALANCED_LATENCY + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_balanced_priority_latency_secondary)}; mGattConnLowSecondary = new int[] { service.getResources().getInteger(R.integer.gatt_low_power_min_interval_secondary), service.getResources().getInteger(R.integer.gatt_low_power_max_interval_secondary), service.getResources().getInteger(R.integer.gatt_low_power_latency_secondary)}; getGattConfig(PROPERTY_LOW_MIN_INTERVAL + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_low_power_min_interval_secondary), getGattConfig(PROPERTY_LOW_MAX_INTERVAL + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_low_power_max_interval_secondary), getGattConfig(PROPERTY_LOW_LATENCY + PROPERTY_SUFFIX_SECONDARY, R.integer.gatt_low_power_latency_secondary)}; } private int getGattConfig(String property, int resId) { return SystemProperties.getInt(property, mAdapterService.getResources().getInteger(resId)); } void loadCompanionInfo() { Loading