Skip to content

Commit 46b9bbb

Browse files
committed
Flashing - get permissions before checking still paired
1 parent 6f064b0 commit 46b9bbb

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

app/src/main/java/com/samsung/microbit/ui/activity/ProjectActivity.java

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
893893
if(resultCode == Activity.RESULT_OK) {
894894
if(mActivityState == FlashActivityState.STATE_ENABLE_BT_INTERNAL_FLASH_REQUEST ||
895895
mActivityState == FlashActivityState.STATE_ENABLE_BT_EXTERNAL_FLASH_REQUEST) {
896-
flashingChecks();
896+
proceedAfterBlePermissionGrantedAndBleEnabled();
897897
} else if(mActivityState == FlashActivityState.STATE_ENABLE_BT_FOR_CONNECT) {
898898
setActivityState(FlashActivityState.STATE_IDLE);
899899
toggleConnection();
@@ -921,12 +921,9 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
921921
private boolean startBluetoothForFlashing() {
922922
Log.v(TAG, "startBluetoothForFlashing");
923923

924-
if ( launchPairingIfNoCurrentMicrobit())
925-
return false;
926-
927924
if ( havePermissionsFlashing()) {
928925
if( BluetoothChecker.getInstance().isBluetoothON()) {
929-
flashingChecks();
926+
proceedAfterBlePermissionGrantedAndBleEnabled();
930927
return true;
931928
}
932929
enableBluetooth();
@@ -946,6 +943,18 @@ private void proceedAfterBlePermissionGranted() {
946943
enableBluetooth();
947944
return;
948945
}
946+
proceedAfterBlePermissionGrantedAndBleEnabled();
947+
}
948+
949+
/**
950+
* Provides actions after BLE permission has been granted:
951+
* check if bluetooth is disabled then enable it and
952+
* start the flashing steps.
953+
*/
954+
private void proceedAfterBlePermissionGrantedAndBleEnabled() {
955+
if (launchPairingIfNoCurrentMicrobit())
956+
return;
957+
949958
flashingChecks();
950959
}
951960

0 commit comments

Comments
 (0)