@Test public void testOnBootCompleted_AirplaneModeOn() { Settings.Global.putInt(mContentResolver, Settings.Global.AIRPLANE_MODE_ON, 1); when(mockBtAdapter.isEnabled()).thenReturn(false); mMediator.onBootCompleted(); verify(mockBtAdapter, never()).enable(); }
public void onBootCompleted() { IntentFilter aclIntentFilter = new IntentFilter(); aclIntentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); aclIntentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); mContext.registerReceiver(aclStateReceiver, aclIntentFilter); mContext.registerReceiver(stateChangeReceiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED)); mContext.registerReceiver(bondStateReceiver, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED)); mMainHandler.post(() -> { if (mAclConnected || mProxyConnected.get()) { return; } if (mAdapter.isEnabled()) { onAdapterEnabled(); } else { if (Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) == 0) { Log.w(TAG, "Enabling an unexpectedly disabled Bluetooth adapter."); mAdapter.enable(); } } }); }
WearBluetoothMediator implements
        CompanionProxyShard.Listener,
        CompanionTracker.Listener,
        UserAbsentRadiosOffObserver.Listener,
        PowerTracker.Listener,
        TimeOnlyMode.Listener { public void onBootCompleted() { IntentFilter aclIntentFilter = new IntentFilter(); aclIntentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); aclIntentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); mContext.registerReceiver(aclStateReceiver, aclIntentFilter); mContext.registerReceiver(stateChangeReceiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED)); mContext.registerReceiver(bondStateReceiver, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED)); mMainHandler.post(() -> { if (mAclConnected || mProxyConnected.get()) { return; } if (mAdapter.isEnabled()) { onAdapterEnabled(); } else { if (Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) == 0) { Log.w(TAG, "Enabling an unexpectedly disabled Bluetooth adapter."); mAdapter.enable(); } } }); } }
WearBluetoothMediator implements
        CompanionProxyShard.Listener,
        CompanionTracker.Listener,
        UserAbsentRadiosOffObserver.Listener,
        PowerTracker.Listener,
        TimeOnlyMode.Listener { public void onBootCompleted() { IntentFilter aclIntentFilter = new IntentFilter(); aclIntentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); aclIntentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); mContext.registerReceiver(aclStateReceiver, aclIntentFilter); mContext.registerReceiver(stateChangeReceiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED)); mContext.registerReceiver(bondStateReceiver, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED)); mMainHandler.post(() -> { if (mAclConnected || mProxyConnected.get()) { return; } if (mAdapter.isEnabled()) { onAdapterEnabled(); } else { if (Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) == 0) { Log.w(TAG, "Enabling an unexpectedly disabled Bluetooth adapter."); mAdapter.enable(); } } }); } WearBluetoothMediator(final Context context,
                                 final AlarmManager alarmManager,
                                 final BluetoothAdapter btAdapter,
                                 final BluetoothLogger btLogger,
                                 final BluetoothShardRunner shardRunner,
                                 final CompanionTracker companionTracker,
                                 final PowerTracker powerTracker,
                                 final UserAbsentRadiosOffObserver userAbsentRadiosOffObserver,
                                 final TimeOnlyMode timeOnlyMode); }
WearBluetoothMediator implements
        CompanionProxyShard.Listener,
        CompanionTracker.Listener,
        UserAbsentRadiosOffObserver.Listener,
        PowerTracker.Listener,
        TimeOnlyMode.Listener { public void onBootCompleted() { IntentFilter aclIntentFilter = new IntentFilter(); aclIntentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); aclIntentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); mContext.registerReceiver(aclStateReceiver, aclIntentFilter); mContext.registerReceiver(stateChangeReceiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED)); mContext.registerReceiver(bondStateReceiver, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED)); mMainHandler.post(() -> { if (mAclConnected || mProxyConnected.get()) { return; } if (mAdapter.isEnabled()) { onAdapterEnabled(); } else { if (Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) == 0) { Log.w(TAG, "Enabling an unexpectedly disabled Bluetooth adapter."); mAdapter.enable(); } } }); } WearBluetoothMediator(final Context context,
                                 final AlarmManager alarmManager,
                                 final BluetoothAdapter btAdapter,
                                 final BluetoothLogger btLogger,
                                 final BluetoothShardRunner shardRunner,
                                 final CompanionTracker companionTracker,
                                 final PowerTracker powerTracker,
                                 final UserAbsentRadiosOffObserver userAbsentRadiosOffObserver,
                                 final TimeOnlyMode timeOnlyMode); void onBootCompleted(); @Override void onTimeOnlyModeChanged(boolean timeOnlyMode); void updateActivityMode(boolean activeMode); @Override void onUserAbsentRadiosOffChanged(boolean isEnabled); @Override void onPowerSaveModeChanged(); @Override void onChargingStateChanged(); @Override void onDeviceIdleModeChanged(); @Override // CompanionProxyShard.Listener void onProxyConnectionChange(boolean isConnected, int proxyScore, boolean withInternet); boolean isProxyConnected(); @Override void onCompanionChanged(); void dump(@NonNull final IndentingPrintWriter ipw); }
WearBluetoothMediator implements
        CompanionProxyShard.Listener,
        CompanionTracker.Listener,
        UserAbsentRadiosOffObserver.Listener,
        PowerTracker.Listener,
        TimeOnlyMode.Listener { public void onBootCompleted() { IntentFilter aclIntentFilter = new IntentFilter(); aclIntentFilter.addAction(BluetoothDevice.ACTION_ACL_CONNECTED); aclIntentFilter.addAction(BluetoothDevice.ACTION_ACL_DISCONNECTED); mContext.registerReceiver(aclStateReceiver, aclIntentFilter); mContext.registerReceiver(stateChangeReceiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED)); mContext.registerReceiver(bondStateReceiver, new IntentFilter(BluetoothDevice.ACTION_BOND_STATE_CHANGED)); mMainHandler.post(() -> { if (mAclConnected || mProxyConnected.get()) { return; } if (mAdapter.isEnabled()) { onAdapterEnabled(); } else { if (Settings.Global.getInt(mContext.getContentResolver(), Settings.Global.AIRPLANE_MODE_ON, 0) == 0) { Log.w(TAG, "Enabling an unexpectedly disabled Bluetooth adapter."); mAdapter.enable(); } } }); } WearBluetoothMediator(final Context context,
                                 final AlarmManager alarmManager,
                                 final BluetoothAdapter btAdapter,
                                 final BluetoothLogger btLogger,
                                 final BluetoothShardRunner shardRunner,
                                 final CompanionTracker companionTracker,
                                 final PowerTracker powerTracker,
                                 final UserAbsentRadiosOffObserver userAbsentRadiosOffObserver,
                                 final TimeOnlyMode timeOnlyMode); void onBootCompleted(); @Override void onTimeOnlyModeChanged(boolean timeOnlyMode); void updateActivityMode(boolean activeMode); @Override void onUserAbsentRadiosOffChanged(boolean isEnabled); @Override void onPowerSaveModeChanged(); @Override void onChargingStateChanged(); @Override void onDeviceIdleModeChanged(); @Override // CompanionProxyShard.Listener void onProxyConnectionChange(boolean isConnected, int proxyScore, boolean withInternet); boolean isProxyConnected(); @Override void onCompanionChanged(); void dump(@NonNull final IndentingPrintWriter ipw);  }