Skip to content

Commit 7a90909

Browse files
committed
Merge remote-tracking branch 'origin/dev'
2 parents 0ecef54 + f52bada commit 7a90909

File tree

4 files changed

+3
-46
lines changed

4 files changed

+3
-46
lines changed

app/src/main/java/cc/calliope/mini/ProgressCollector.java

-27
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,6 @@ public class ProgressCollector extends ContextWrapper implements DefaultLifecycl
2828
private final Context context;
2929
private ProgressListener listener;
3030

31-
private final BroadcastReceiver bondStateReceiver = new BroadcastReceiver() {
32-
@Override
33-
public void onReceive(Context context, Intent intent) {
34-
final BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
35-
if (device == null) {
36-
return;
37-
}
38-
39-
final String action = intent.getAction();
40-
if (action == null) {
41-
return;
42-
}
43-
44-
// Take action depending on new bond state
45-
if (action.equals(ACTION_BOND_STATE_CHANGED)) {
46-
final int bondState = intent.getIntExtra(EXTRA_BOND_STATE, ERROR);
47-
final int previousBondState = intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, ERROR);
48-
listener.onBluetoothBondingStateChanged(device, bondState, previousBondState);
49-
}
50-
}
51-
};
52-
5331
private final BroadcastReceiver dfuServiceReceiver = new BroadcastReceiver() {
5432
@Override
5533
public void onReceive(Context context, Intent intent) {
@@ -119,10 +97,6 @@ public void registerReceivers() {
11997
if (listener == null) {
12098
return;
12199
}
122-
//BondStateReceiver
123-
IntentFilter bondStateFilter = new IntentFilter();
124-
bondStateFilter.addAction(ACTION_BOND_STATE_CHANGED);
125-
registerReceiver(bondStateReceiver, bondStateFilter);
126100

127101
//DfuService
128102
IntentFilter dfuServiceFilter = new IntentFilter();
@@ -137,7 +111,6 @@ public void registerReceivers() {
137111
}
138112

139113
public void unregisterReceivers() {
140-
unregisterReceiver(bondStateReceiver);
141114
LocalBroadcastManager.getInstance(context).unregisterReceiver(dfuServiceReceiver);
142115
LocalBroadcastManager.getInstance(context).unregisterReceiver(dfuControlServiceReceiver);
143116
}

app/src/main/java/cc/calliope/mini/ProgressListener.java

-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ public interface ProgressListener {
2121
void onDfuAttempt();
2222
void onDfuControlComplete();
2323
void onProgressUpdate(int progress);
24-
void onBluetoothBondingStateChanged(@NonNull BluetoothDevice device, @BondState int bondState, @BondState int previousBondState);
2524
void onConnectionFailed();
2625
void onError(int code, String message);
2726
}

app/src/main/java/cc/calliope/mini/activity/FlashingActivity.java

-5
Original file line numberDiff line numberDiff line change
@@ -167,11 +167,6 @@ public void onProgressUpdate(int progress) {
167167
// title.setText(String.format(getString(R.string.flashing_percent), progress));
168168
}
169169

170-
@Override
171-
public void onBluetoothBondingStateChanged(@NonNull BluetoothDevice device, int bondState, int previousBondState) {
172-
173-
}
174-
175170
@Override
176171
public void onConnectionFailed() {
177172

app/src/main/java/cc/calliope/mini/core/service/FlashingService.java

+3-13
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public class FlashingService extends LifecycleService implements ProgressListene
5858
private String currentPath;
5959
private int progress = -10;
6060

61-
private static final int CONNECTION_TIMEOUT = 10000; // 10 seconds
61+
private static final int CONNECTION_TIMEOUT = 3000; // 3 seconds
6262
private Handler handler;
6363
private Runnable timeoutRunnable;
6464

@@ -74,10 +74,8 @@ public void onChanged(State state) {
7474

7575
int type = state.getType();
7676

77-
if (type == State.STATE_READY ||
78-
type == State.STATE_FLASHING ||
79-
type == State.STATE_ERROR ||
80-
type == State.STATE_IDLE) {
77+
if (type == State.STATE_FLASHING ||
78+
type == State.STATE_ERROR) {
8179
handler.removeCallbacks(timeoutRunnable); // Remove the timeout callback
8280
}
8381
}
@@ -147,14 +145,6 @@ public void onDfuAttempt() {
147145
startDfuControlService();
148146
}
149147

150-
@Override
151-
public void onBluetoothBondingStateChanged(BluetoothDevice device, int bondState, int previousBondState) {
152-
if (!currentAddress.equals(device.getAddress())) {
153-
return;
154-
}
155-
Utils.log(Log.ASSERT, TAG, "Bond state: " + bondState + " previous: " + previousBondState);
156-
}
157-
158148

159149
@SuppressWarnings("MissingPermission")
160150
@Override

0 commit comments

Comments
 (0)