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

Add DW profile check on every notification #172 #177

Merged
merged 1 commit into from
Apr 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -103,44 +103,47 @@ public void onReceive(Context context, Intent intent) {
return;
}

currentlyActiveProfile = b.getString("PROFILE_NAME");
String notificationType = b.getString(ZebraDwIntents.DW_NOTIFICATION_TYPE_EXTRA);
if (notificationType != null) {
switch (notificationType) {
case ZebraDwIntents.DW_NOTIFICATION_CHANGE_STATUS:
String status = b.getString("STATUS");
Log.d(LOG_TAG, "SCANNER_STATUS: status: " + status + ", profileName: " + b.getString("PROFILE_NAME"));
Log.d(LOG_TAG, "SCANNER_STATUS: status: " + status + ", profileName: " + currentlyActiveProfile);
if (this.statusCb != null && status != null) {
this.statusCb.onStatusChanged(this, ZebraDwHelpers.getStatus(status));
}
break;

case ZebraDwIntents.DW_NOTIFICATION_CHANGE_PROFILE:
Log.i(LOG_TAG, "PROFILE_SWITCH: profileName: " + b.getString("PROFILE_NAME") + ", profileEnabled: " + b.getBoolean("PROFILE_ENABLED"));
currentlyActiveProfile = b.getString("PROFILE_NAME");
Log.i(LOG_TAG, "PROFILE_SWITCH: profileName: " + currentlyActiveProfile + ", profileEnabled: " + b.getBoolean("PROFILE_ENABLED"));
if (currentConfig != null && profileName.equals(currentlyActiveProfile)) {
Log.d(LOG_TAG, "Correct profile, configuring symbologies");
configureSymbologies();
}
if (!paused && !profileName.equals(currentlyActiveProfile)) {
// DW will change the profile between activities and apps. We must check each time a switch is done.
Log.d(LOG_TAG, "Incorrect profile " + currentlyActiveProfile + ", requesting profile change to " + profileName);
switchToOurProfile();
}
break;

case ZebraDwIntents.DW_NOTIFICATION_CHANGE_CONFIGURATION:
Log.i(LOG_TAG, "CONFIGURATION_UPDATE: status: " + b.getString("STATUS") + ", profileName: " + b.getString("PROFILE_NAME"));
Log.i(LOG_TAG, "CONFIGURATION_UPDATE: status: " + b.getString("STATUS") + ", profileName: " + currentlyActiveProfile);
break;

case ZebraDwIntents.DW_NOTIFICATION_CHANGE_WORKFLOW:
Log.d(LOG_TAG, "WORKFLOW_STATUS: status: " + b.getString("STATUS") + ", profileName: " + b.getString("PROFILE_NAME"));
Log.d(LOG_TAG, "WORKFLOW_STATUS: status: " + b.getString("STATUS") + ", profileName: " + currentlyActiveProfile);
break;

default:
Log.d(LOG_TAG, "Other notification: " + notificationType + " - status: " + b.getString("STATUS") + ", profileName: " + b.getString("PROFILE_NAME"));
Log.d(LOG_TAG, "Other notification: " + notificationType + " - status: " + b.getString("STATUS") + ", profileName: " + currentlyActiveProfile);
break;
}
}

if (currentlyActiveProfile != null && !profileName.equals(currentlyActiveProfile)) {
// DW will change the profile between activities and apps.
// Sometimes for some reason this may happen silently without a DW_NOTIFICATION_CHANGE_PROFILE.
// So we must check the active profile on *every notification* as long as our app is active (not paused).
Log.i(LOG_TAG, "Incorrect notification profile '" + currentlyActiveProfile + "', requesting profile change to '" + profileName + "'");
switchToOurProfile();
}
}
}

Expand Down
Loading