Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pre-scan verification for excessive scan #234

Merged

Conversation

dariuszseweryn
Copy link
Owner

#227
Android API 24 (7.0) introduced an undocomented “feature” that aims on applications that try to start too many scans (5+) in a short time window (30 seconds) by silently (log error only) not starting the scan. More info available here: https://blog.classycode.com/undocumented-android-7-ble-behavior-changes-d1a9bd87d983

#227
Android API 24 (7.0) introduced an undocomented “feature” that aims on applications that try to start too many scans (5+) in a short time window (30 seconds) by silently (log error only) not starting the scan. More info available here: https://blog.classycode.com/undocumented-android-7-ble-behavior-changes-d1a9bd87d983
@dariuszseweryn
Copy link
Owner Author

There is an alternative on how to check for this error but it would need to parse the log on the device. Probably not the most performant but an interesting idea though.

@passsy
Copy link
Contributor

passsy commented Jun 28, 2017

It's not possible to parse Logcat from the app

@dariuszseweryn
Copy link
Owner Author

dariuszseweryn commented Jun 28, 2017

It is possible but only to parse your own app logcat. Unfortunately the log about excessive scans comes from the system and is not reachable programmatically.

import android.support.annotation.Nullable;
import java.util.Date;

public class ExcessiveScanCheckerApi18 implements ExcessiveScanChecker {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think if the name would suggest what this class does? Basically that it's a pass through.


@Nullable
@Override
public Date suggestDateToRetry() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not obvious that the method returning a suggestion is also modifying the state of the checker. I think that this method should idempotent and there should be a method to alter the state.

return null;
}

private int getOldestCheckTimestampIndex() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something like a fixed size stack seems to be cool https://stackoverflow.com/a/16206356

@dariuszseweryn dariuszseweryn added this to the 1.4.0 milestone Jun 29, 2017
@dariuszseweryn dariuszseweryn merged commit b51eccd into develop Jun 29, 2017
@dariuszseweryn dariuszseweryn deleted the fix/issue_227_undocumented_excessive_scan_api_24 branch June 29, 2017 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants