Skip to content

Commit 026248a

Browse files
committed
Updated managed configuration settings
1 parent 1820592 commit 026248a

File tree

6 files changed

+136
-5
lines changed

6 files changed

+136
-5
lines changed

AI_MutliBarcodes_Capture/src/main/java/com/zebra/ai_multibarcodes_capture/EntryChoiceActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public void onReceive(Context context, Intent intent) {
105105
public void run() {
106106
loadPreferences();
107107
Toast.makeText(EntryChoiceActivity.this,
108-
"Settings updated by administrator", Toast.LENGTH_SHORT).show();
108+
getString(R.string.managed_configuration_updated), Toast.LENGTH_SHORT).show();
109109
}
110110
});
111111
}

AI_MutliBarcodes_Capture/src/main/java/com/zebra/ai_multibarcodes_capture/java/CameraXLivePreviewActivity.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,13 @@ public void onReceive(Context context, Intent intent) {
107107
@Override
108108
public void run() {
109109
Toast.makeText(CameraXLivePreviewActivity.this,
110-
"Barcode settings updated by administrator - returning to main screen",
110+
getString(R.string.managed_configuration_updated),
111111
Toast.LENGTH_LONG).show();
112+
113+
// Restart the activity to apply new settings
114+
Intent restartIntent = getIntent();
112115
finish();
116+
startActivity(restartIntent);
113117
}
114118
});
115119
}

AI_MutliBarcodes_Capture/src/main/java/com/zebra/ai_multibarcodes_capture/managedconfig/ManagedConfigurationReceiver.java

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,20 @@ private void updateSharedPreferences(Context context, Bundle restrictions) {
8888
}
8989
}
9090

91+
// Update advanced settings from nested bundle
92+
if (restrictions.containsKey("advanced_settings")) {
93+
Bundle advancedSettings = restrictions.getBundle("advanced_settings");
94+
if (advancedSettings != null) {
95+
updateAdvancedSettings(editor, advancedSettings);
96+
}
97+
}
98+
9199
// Apply all changes atomically
92100
editor.apply();
93101
LogUtils.d(TAG, "Successfully updated SharedPreferences with managed configuration");
94102

95-
// Notify SettingsActivity if it's currently open (will only be received if registered)
96-
LogUtils.d(TAG, "Sending reload preferences intent to SettingsActivity");
103+
// Notify SettingsActivity and CameraXLivePreviewActivity if they're currently open (will only be received if registered)
104+
LogUtils.d(TAG, "Sending reload preferences intent to registered activities");
97105
Intent reloadIntent = new Intent(ACTION_RELOAD_PREFERENCES);
98106
context.sendBroadcast(reloadIntent);
99107

@@ -173,6 +181,24 @@ private void updateBarcodeSymbologies(SharedPreferences.Editor editor, Bundle ba
173181
updateBooleanSetting(editor, barcodeSymbologies, "TRIOPTIC39", Constants.SHARED_PREFERENCES_TRIOPTIC39);
174182
}
175183

184+
/**
185+
* Updates advanced settings preferences from the nested bundle
186+
* @param editor SharedPreferences editor
187+
* @param advancedSettings Bundle containing advanced settings
188+
*/
189+
private void updateAdvancedSettings(SharedPreferences.Editor editor, Bundle advancedSettings) {
190+
LogUtils.d(TAG, "Updating advanced settings from managed configuration");
191+
192+
// Update model input size
193+
updateStringSetting(editor, advancedSettings, "model_input_size", Constants.SHARED_PREFERENCES_MODEL_INPUT_SIZE);
194+
195+
// Update camera resolution
196+
updateStringSetting(editor, advancedSettings, "camera_resolution", Constants.SHARED_PREFERENCES_CAMERA_RESOLUTION);
197+
198+
// Update inference type
199+
updateStringSetting(editor, advancedSettings, "inference_type", Constants.SHARED_PREFERENCES_INFERENCE_TYPE);
200+
}
201+
176202
/**
177203
* Helper method to update a boolean setting from managed configuration
178204
* @param editor SharedPreferences editor
@@ -189,6 +215,24 @@ private void updateBooleanSetting(SharedPreferences.Editor editor, Bundle bundle
189215
}
190216
}
191217

218+
/**
219+
* Helper method to update a string setting from managed configuration
220+
* @param editor SharedPreferences editor
221+
* @param bundle Bundle containing the managed configuration values
222+
* @param configKey Key in the managed configuration bundle
223+
* @param prefKey Key in SharedPreferences
224+
*/
225+
private void updateStringSetting(SharedPreferences.Editor editor, Bundle bundle,
226+
String configKey, String prefKey) {
227+
if (bundle.containsKey(configKey)) {
228+
String value = bundle.getString(configKey);
229+
if (value != null && !value.trim().isEmpty()) {
230+
editor.putString(prefKey, value);
231+
LogUtils.d(TAG, "Updated " + configKey + ": " + value);
232+
}
233+
}
234+
}
235+
192236
/**
193237
* Public method to manually apply managed configuration
194238
* This can be called during app startup to ensure current restrictions are applied

AI_MutliBarcodes_Capture/src/main/java/com/zebra/ai_multibarcodes_capture/settings/SettingsActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public void run() {
8787
loadPreferences();
8888
reloadLanguageSpinner();
8989
Toast.makeText(SettingsActivity.this,
90-
"Settings updated by administrator", Toast.LENGTH_SHORT).show();
90+
getString(R.string.managed_configuration_updated), Toast.LENGTH_SHORT).show();
9191
}
9292
});
9393
}

AI_MutliBarcodes_Capture/src/main/res/values/strings.xml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,4 +404,48 @@
404404
<item>zu</item>
405405
</string-array>
406406

407+
<!-- Model Input Size Arrays for Managed Configuration -->
408+
<string-array name="model_input_size_names">
409+
<item>Small (640x640)</item>
410+
<item>Medium (1280x1280)</item>
411+
<item>Large (1600x1600)</item>
412+
</string-array>
413+
414+
<string-array name="model_input_size_values">
415+
<item>SMALL</item>
416+
<item>MEDIUM</item>
417+
<item>LARGE</item>
418+
</string-array>
419+
420+
<!-- Camera Resolution Arrays for Managed Configuration -->
421+
<string-array name="camera_resolution_names">
422+
<item>1MP (1280 x 720)</item>
423+
<item>2MP (1920 x 1080)</item>
424+
<item>4MP (2688 x 1512)</item>
425+
<item>8MP (3840 x 2160)</item>
426+
</string-array>
427+
428+
<string-array name="camera_resolution_values">
429+
<item>MP_1</item>
430+
<item>MP_2</item>
431+
<item>MP_4</item>
432+
<item>MP_8</item>
433+
</string-array>
434+
435+
<!-- Inference Type Arrays for Managed Configuration -->
436+
<string-array name="inference_type_names">
437+
<item>DSP (Digital Signal Processor)</item>
438+
<item>GPU (Graphics Processing Unit)</item>
439+
<item>CPU (Central Processing Unit)</item>
440+
</string-array>
441+
442+
<string-array name="inference_type_values">
443+
<item>DSP</item>
444+
<item>GPU</item>
445+
<item>CPU</item>
446+
</string-array>
447+
448+
<!-- Managed Configuration Messages -->
449+
<string name="managed_configuration_updated">Settings updated by administrator</string>
450+
407451
</resources>

AI_MutliBarcodes_Capture/src/main/res/xml/app_restrictions.xml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,4 +322,43 @@
322322

323323
</restriction>
324324

325+
<!-- Advanced Settings Configuration (Nested Bundle) -->
326+
<restriction
327+
android:key="advanced_settings"
328+
android:title="Advanced Settings"
329+
description="Advanced configuration settings for AI model and camera parameters"
330+
android:restrictionType="bundle">
331+
332+
<!-- Model Input Size Configuration -->
333+
<restriction
334+
android:key="model_input_size"
335+
android:title="Model Input Size"
336+
description="Model input size is the resolution your image is resized to before AI analysis. Smaller sizes are faster and use less memory, while larger sizes can help detect smaller or more distant barcodes—but also uses more processing power and memory. Choose the input size to balance speed and accuracy for your needs. Note: Model Input Size can be customized in increments of 32 using the SDK. The options below represent some generic sizes."
337+
android:restrictionType="choice"
338+
android:defaultValue="MEDIUM"
339+
android:entries="@array/model_input_size_names"
340+
android:entryValues="@array/model_input_size_values" />
341+
342+
<!-- Camera Resolution Configuration -->
343+
<restriction
344+
android:key="camera_resolution"
345+
android:title="Camera Resolution"
346+
description="Camera resolution is the number of pixels in your photo (e.g., 1MP = 1280x720). Higher resolution captures more detail for small or distant text but uses more power and memory. Benefits are limited if the model input size is low."
347+
android:restrictionType="choice"
348+
android:defaultValue="MP_2"
349+
android:entries="@array/camera_resolution_names"
350+
android:entryValues="@array/camera_resolution_values" />
351+
352+
<!-- Inference Type Configuration -->
353+
<restriction
354+
android:key="inference_type"
355+
android:title="Inference Type"
356+
description="Choose the processing unit for AI inference. DSP (Digital Signal Processor) is the best choice for optimal performance. GPU and CPU options are available for trial use if DSP is not available."
357+
android:restrictionType="choice"
358+
android:defaultValue="DSP"
359+
android:entries="@array/inference_type_names"
360+
android:entryValues="@array/inference_type_values" />
361+
362+
</restriction>
363+
325364
</restrictions>

0 commit comments

Comments
 (0)