├── .gitignore ├── .idea ├── caches │ ├── build_file_checksums.ser │ └── gradle_models.ser ├── codeStyles │ └── Project.xml ├── compiler.xml ├── copyright │ └── profiles_settings.xml ├── gradle.xml ├── jarRepositories.xml ├── markdown-navigator.xml ├── markdown-navigator │ └── profiles_settings.xml ├── misc.xml ├── modules.xml ├── runConfigurations.xml └── vcs.xml ├── app ├── .gitignore ├── build.gradle ├── build │ └── outputs │ │ └── apk │ │ ├── app-debug.apk │ │ └── debug │ │ └── app-debug.apk ├── proguard-rules.pro └── src │ └── main │ ├── AndroidManifest.xml │ ├── java │ ├── DataCollectionIntentAPI_Guide.pdf │ ├── DataCollectionService.xml │ ├── intent_setups.png │ ├── intent_setups_eda50.png │ ├── readme.md │ └── sample │ │ └── honeywell │ │ └── com │ │ └── intentapisample │ │ ├── MainActivity.java │ │ └── SystemPropertyAccess.java │ └── res │ ├── layout │ └── activity_main.xml │ ├── mipmap-hdpi │ └── ic_launcher.png │ ├── mipmap-mdpi │ └── ic_launcher.png │ ├── mipmap-xhdpi │ └── ic_launcher.png │ ├── mipmap-xxhdpi │ └── ic_launcher.png │ ├── mipmap-xxxhdpi │ └── ic_launcher.png │ └── values │ ├── colors.xml │ ├── strings.xml │ └── styles.xml ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/workspace.xml 5 | /.idea/libraries 6 | .DS_Store 7 | /build 8 | /captures 9 | .externalNativeBuild 10 | -------------------------------------------------------------------------------- /.idea/caches/build_file_checksums.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hjgode/IntentAPISample/ca1bb2c550686e823a394984c7690f18f2839d25/.idea/caches/build_file_checksums.ser -------------------------------------------------------------------------------- /.idea/caches/gradle_models.ser: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hjgode/IntentAPISample/ca1bb2c550686e823a394984c7690f18f2839d25/.idea/caches/gradle_models.ser -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 |
7 | 8 | 9 | 10 | xmlns:android 11 | 12 | ^$ 13 | 14 | 15 | 16 |
17 |
18 | 19 | 20 | 21 | xmlns:.* 22 | 23 | ^$ 24 | 25 | 26 | BY_NAME 27 | 28 |
29 |
30 | 31 | 32 | 33 | .*:id 34 | 35 | http://schemas.android.com/apk/res/android 36 | 37 | 38 | 39 |
40 |
41 | 42 | 43 | 44 | .*:name 45 | 46 | http://schemas.android.com/apk/res/android 47 | 48 | 49 | 50 |
51 |
52 | 53 | 54 | 55 | name 56 | 57 | ^$ 58 | 59 | 60 | 61 |
62 |
63 | 64 | 65 | 66 | style 67 | 68 | ^$ 69 | 70 | 71 | 72 |
73 |
74 | 75 | 76 | 77 | .* 78 | 79 | ^$ 80 | 81 | 82 | BY_NAME 83 | 84 |
85 |
86 | 87 | 88 | 89 | .* 90 | 91 | http://schemas.android.com/apk/res/android 92 | 93 | 94 | ANDROID_ATTRIBUTE_ORDER 95 | 96 |
97 |
98 | 99 | 100 | 101 | .* 102 | 103 | .* 104 | 105 | 106 | BY_NAME 107 | 108 |
109 |
110 |
111 |
112 |
113 |
-------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | 24 | 25 | 29 | 30 | 34 | 35 | 39 | 40 | -------------------------------------------------------------------------------- /.idea/markdown-navigator.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 35 | 36 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /.idea/markdown-navigator/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 24 | 41 | 42 | 43 | 44 | 45 | 46 | 48 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion '26.0.2' 6 | defaultConfig { 7 | applicationId "sample.honeywell.com.intentapisample" 8 | minSdkVersion 17 9 | targetSdkVersion 23 10 | versionCode 1 11 | versionName "1.0" 12 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | compileOptions { 21 | sourceCompatibility JavaVersion.VERSION_1_8 22 | targetCompatibility JavaVersion.VERSION_1_8 23 | } 24 | } 25 | 26 | dependencies { 27 | compile fileTree(include: ['*.jar'], dir: 'libs') 28 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 29 | exclude group: 'com.android.support', module: 'support-annotations' 30 | }) 31 | compile 'com.android.support:appcompat-v7:23.4.0' 32 | compile 'com.android.support.constraint:constraint-layout:1.0.2' 33 | testCompile 'junit:junit:4.12' 34 | } 35 | -------------------------------------------------------------------------------- /app/build/outputs/apk/app-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hjgode/IntentAPISample/ca1bb2c550686e823a394984c7690f18f2839d25/app/build/outputs/apk/app-debug.apk -------------------------------------------------------------------------------- /app/build/outputs/apk/debug/app-debug.apk: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hjgode/IntentAPISample/ca1bb2c550686e823a394984c7690f18f2839d25/app/build/outputs/apk/debug/app-debug.apk -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in C:\android-sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Uncomment this to preserve the line number information for 20 | # debugging stack traces. 21 | #-keepattributes SourceFile,LineNumberTable 22 | 23 | # If you keep the line number information, uncomment this to 24 | # hide the original source file name. 25 | #-renamesourcefileattribute SourceFile 26 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /app/src/main/java/DataCollectionIntentAPI_Guide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hjgode/IntentAPISample/ca1bb2c550686e823a394984c7690f18f2839d25/app/src/main/java/DataCollectionIntentAPI_Guide.pdf -------------------------------------------------------------------------------- /app/src/main/java/DataCollectionService.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 1.0.1 5 | 6 | hsm.demo.totalfreedom/.DataEdit 7 |
8 |
9 | 150 10 | false 11 | off 12 | 40 13 | false 14 | 1 15 | false 16 | ISO-8859-1 17 | 1 18 | 4 19 | 100 20 | normal 21 | 60 22 | 1 23 | contextSensitive 24 | false 25 | 4 26 | 9,10 27 | false 28 | false 29 | false 30 | 97 31 | true 32 | 80 33 | false 34 | true 35 | false 36 | false 37 | 4800 38 | true 39 | false 40 | false 41 | false 42 | false 43 | false 44 | 50 45 | false 46 | 0 47 | true 48 | false 49 | 80 50 | false 51 | false 52 | false 53 | 54 | 4 55 | noCheck 56 | false 57 | false 58 | false 59 | centerWeighted 60 | false 61 | false 62 | 80 63 | 0 64 | true 65 | false 66 | noCheck 67 | false 68 | false 69 | 1 70 | 4 71 | false 72 | false 73 | 6000 74 | false 75 | 100 76 | 1 77 | 78 | 1024 79 | false 80 | false 81 | true 82 | 2750 83 | doubleDigitCheckAndStrip 84 | 2 85 | 1 86 | false 87 | 80 88 | false 89 | 90 | noCheck 91 | 4 92 | 0 93 | false 94 | true 95 | 96 | false 97 | false 98 | 80 99 | true 100 | 48 101 | true 102 | false 103 | 48 104 | false 105 | 300 106 | true 107 | false 108 | 2750 109 | 1 110 | 4 111 | 2 112 | 80 113 | true 114 | 80 115 | false 116 | false 117 | 48 118 | 0 119 | false 120 | 3116 121 | false 122 | true 123 | false 124 | false 125 | 300 126 | none 127 | false 128 | 60000 129 | 0 130 | 1,3,7,7,7,7,7,7,7,7,0 131 | 50 132 | false 133 | false 134 | 1 135 | 1 136 | true 137 | true 138 | 0 139 | 1 140 | 141 | 142 | true 143 | false 144 | 50 145 | none 146 | 80 147 | 0 148 | false 149 | true 150 | 1 151 | false 152 | false 153 | false 154 | 20 155 | true 156 | 48 157 | 50 158 | 159 | noCheck 160 | 0 161 | false 162 | true 163 | 7089 164 | false 165 | false 166 | 2048 167 | 80 168 | false 169 | 170 | autoControl 171 | false 172 | 5 173 | 3832 174 | 1 175 | false 176 | 2048 177 | false 178 | 1024 179 | 60 180 | false 181 | false 182 | false 183 | oneShot 184 | false 185 | false 186 |
187 | dcs.scanner.imager/DEFAULT; 188 |
189 |
190 |
191 | 150 192 | false 193 | off 194 | 40 195 | false 196 | 1 197 | false 198 | ISO-8859-1 199 | 1 200 | 4 201 | 100 202 | normal 203 | 60 204 | 1 205 | contextSensitive 206 | false 207 | false 208 | 4 209 | 9,10 210 | false 211 | false 212 | 97 213 | true 214 | 80 215 | true 216 | false 217 | false 218 | false 219 | 4800 220 | false 221 | true 222 | false 223 | false 224 | false 225 | false 226 | 50 227 | false 228 | 0 229 | false 230 | true 231 | 80 232 | false 233 | false 234 | false 235 | 236 | 4 237 | noCheck 238 | true 239 | false 240 | centerWeighted 241 | false 242 | false 243 | false 244 | 80 245 | 0 246 | true 247 | false 248 | noCheck 249 | false 250 | false 251 | 1 252 | 4 253 | false 254 | false 255 | false 256 | 6000 257 | 100 258 | 1 259 | 1024 260 | 261 | false 262 | false 263 | 2750 264 | true 265 | doubleDigitCheckAndStrip 266 | 2 267 | 1 268 | false 269 | 80 270 | false 271 | com.honeywell.sample.action.BARCODE_DATA 272 | noCheck 273 | false 274 | 0 275 | true 276 | 4 277 | 278 | false 279 | false 280 | 80 281 | true 282 | true 283 | 48 284 | false 285 | 48 286 | false 287 | 300 288 | true 289 | false 290 | 1 291 | 2750 292 | 4 293 | 2 294 | 80 295 | true 296 | 80 297 | false 298 | false 299 | 48 300 | 0 301 | false 302 | 3116 303 | false 304 | true 305 | false 306 | false 307 | 300 308 | none 309 | false 310 | 0 311 | 60000 312 | 1,3,7,7,7,7,7,7,7,7,0 313 | 50 314 | false 315 | false 316 | 1 317 | 1 318 | true 319 | true 320 | 0 321 | 1 322 | 323 | 324 | true 325 | 50 326 | false 327 | none 328 | 80 329 | 0 330 | false 331 | true 332 | false 333 | 1 334 | false 335 | false 336 | 20 337 | true 338 | 48 339 | 50 340 | 341 | 0 342 | noCheck 343 | false 344 | true 345 | 7089 346 | false 347 | false 348 | 2048 349 | 80 350 | false 351 | 352 | autoControl 353 | false 354 | 5 355 | 3832 356 | 1 357 | false 358 | 2048 359 | false 360 | 1024 361 | 60 362 | false 363 | false 364 | false 365 | false 366 | oneShot 367 | false 368 |
369 |
370 |
371 |
372 |
373 | -------------------------------------------------------------------------------- /app/src/main/java/intent_setups.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hjgode/IntentAPISample/ca1bb2c550686e823a394984c7690f18f2839d25/app/src/main/java/intent_setups.png -------------------------------------------------------------------------------- /app/src/main/java/intent_setups_eda50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hjgode/IntentAPISample/ca1bb2c550686e823a394984c7690f18f2839d25/app/src/main/java/intent_setups_eda50.png -------------------------------------------------------------------------------- /app/src/main/java/readme.md: -------------------------------------------------------------------------------- 1 | # Datacollection Intent API Sample 2 | 3 | This code does not need either "Scan to Intent" nor a "Data Intent" setup. 4 | 5 | ![No Intent setup](https://github.com/hjgode/IntentAPISample/raw/master/app/src/main/java/intent_setups.png) 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/java/sample/honeywell/com/intentapisample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package sample.honeywell.com.intentapisample; 2 | 3 | import android.content.BroadcastReceiver; 4 | import android.content.ComponentName; 5 | import android.content.Context; 6 | import android.content.Intent; 7 | import android.content.IntentFilter; 8 | import android.content.pm.PackageManager; 9 | import android.content.pm.ResolveInfo; 10 | import android.os.Build; 11 | import android.os.Handler; 12 | import android.support.v7.app.AppCompatActivity; 13 | import android.os.Bundle; 14 | import android.support.v7.view.menu.ActionMenuItemView; 15 | import android.util.Log; 16 | import android.view.View; 17 | import android.widget.Button; 18 | import android.widget.TextView; 19 | 20 | import java.util.List; 21 | 22 | public class MainActivity extends AppCompatActivity { 23 | private static final String TAG = "IntentApiSample"; 24 | private static final String ACTION_BARCODE_DATA = "com.honeywell.sample.action.MY_BARCODE_DATA"; 25 | //TODO: DO NOT USE THE sample string "com.honeywell.sample.action.BARCODE_DATA" 26 | //private static final String ACTION_BARCODE_DATA = "com.honeywell.sample.action.BARCODE_DATA"; 27 | 28 | /** 29 | * Honeywell DataCollection Intent API 30 | * Claim scanner 31 | * Package Permissions: 32 | * "com.honeywell.decode.permission.DECODE" 33 | */ 34 | private static final String ACTION_CLAIM_SCANNER = "com.honeywell.aidc.action.ACTION_CLAIM_SCANNER"; 35 | /** 36 | * Honeywell DataCollection Intent API 37 | * Release scanner claim 38 | * Permissions: 39 | * "com.honeywell.decode.permission.DECODE" 40 | */ 41 | private static final String ACTION_RELEASE_SCANNER = "com.honeywell.aidc.action.ACTION_RELEASE_SCANNER"; 42 | /** 43 | * Honeywell DataCollection Intent API 44 | * Optional. Sets the scanner to claim. If scanner is not available or if extra is not used, 45 | * DataCollection will choose an available scanner. 46 | * Values : String 47 | * "dcs.scanner.imager" : Uses the internal scanner 48 | * "dcs.scanner.ring" : Uses the external ring scanner 49 | */ 50 | private static final String EXTRA_SCANNER = "com.honeywell.aidc.extra.EXTRA_SCANNER"; 51 | /** 52 | * Honeywell DataCollection Intent API 53 | * Optional. Sets the profile to use. If profile is not available or if extra is not used, 54 | * the scanner will use factory default properties (not "DEFAULT" profile properties). 55 | * Values : String 56 | */ 57 | private static final String EXTRA_PROFILE = "com.honeywell.aidc.extra.EXTRA_PROFILE"; 58 | /** 59 | * Honeywell DataCollection Intent API 60 | * Optional. Overrides the profile properties (non-persistent) until the next scanner claim. 61 | * Values : Bundle 62 | */ 63 | private static final String EXTRA_PROPERTIES = "com.honeywell.aidc.extra.EXTRA_PROPERTIES"; 64 | 65 | private static final String EXTRA_CONTROL = "com.honeywell.aidc.action.ACTION_CONTROL_SCANNER"; 66 | /* 67 | Extras 68 | "com.honeywell.aidc.extra.EXTRA_SCAN" (boolean): Set to true to start or continue scanning. Set to false to stop scanning. Most scenarios only need this extra, however the scanner can be put into other states by adding from the following extras. 69 | "com.honeywell.aidc.extra.EXTRA_AIM" (boolean): Specify whether to turn the scanner aimer on or off. This is optional; the default value is the value of EXTRA_SCAN. 70 | "com.honeywell.aidc.extra.EXTRA_LIGHT" (boolean): Specify whether to turn the scanner illumination on or off. This is optional; the default value is the value of EXTRA_SCAN. 71 | "com.honeywell.aidc.extra.EXTRA_DECODE" (boolean): Specify whether to turn the decoding operation on or off. This is optional; the default value is the value of EXTRA_SCAN 72 | */ 73 | private static final String EXTRA_SCAN = "com.honeywell.aidc.extra.EXTRA_SCAN"; 74 | 75 | private TextView textView; 76 | Button button; 77 | int sdkVersion=0; 78 | 79 | 80 | private BroadcastReceiver barcodeDataReceiver = new BroadcastReceiver() { 81 | @Override 82 | public void onReceive(Context context, Intent intent) { 83 | Log.d("IntentApiSample: ","onReceive"); 84 | if (ACTION_BARCODE_DATA.equals(intent.getAction())) { 85 | /* 86 | These extras are available: 87 | "version" (int) = Data Intent Api version 88 | "aimId" (String) = The AIM Identifier 89 | "charset" (String) = The charset used to convert "dataBytes" to "data" string 90 | "codeId" (String) = The Honeywell Symbology Identifier 91 | "data" (String) = The barcode data as a string 92 | "dataBytes" (byte[]) = The barcode data as a byte array 93 | "timestamp" (String) = The barcode timestamp 94 | */ 95 | int version = intent.getIntExtra("version", 0); 96 | if (version >= 1) { 97 | String aimId = intent.getStringExtra("aimId"); 98 | String charset = intent.getStringExtra("charset"); 99 | String codeId = intent.getStringExtra("codeId"); 100 | String data = intent.getStringExtra("data"); 101 | byte[] dataBytes = intent.getByteArrayExtra("dataBytes"); 102 | String dataBytesStr=""; 103 | if(dataBytes!=null && dataBytes.length>0) 104 | dataBytesStr = bytesToHexString(dataBytes); 105 | String timestamp = intent.getStringExtra("timestamp"); 106 | String text = String.format( 107 | "Data:%s\n" + 108 | "Charset:%s\n" + 109 | "Bytes:%s\n" + 110 | "AimId:%s\n" + 111 | "CodeId:%s\n" + 112 | "Timestamp:%s\n", 113 | data, charset, dataBytesStr, aimId, codeId, timestamp); 114 | setText(text); 115 | } 116 | } 117 | } 118 | }; 119 | 120 | private static void sendImplicitBroadcast(Context ctxt, Intent i) { 121 | PackageManager pm = ctxt.getPackageManager(); 122 | List matches = pm.queryBroadcastReceivers(i, 0); 123 | if (matches.size() > 0) { 124 | for (ResolveInfo resolveInfo : matches) { 125 | Intent explicit = new Intent(i); 126 | ComponentName cn = 127 | new ComponentName(resolveInfo.activityInfo.applicationInfo.packageName, 128 | resolveInfo.activityInfo.name); 129 | 130 | explicit.setComponent(cn); 131 | ctxt.sendBroadcast(explicit); 132 | } 133 | 134 | } else{ 135 | // to be compatible with Android 9 and later version for dynamic receiver 136 | ctxt.sendBroadcast(i); 137 | } 138 | } 139 | 140 | private void mysendBroadcast(Intent intent){ 141 | if(sdkVersion<26) { 142 | sendBroadcast(intent); 143 | }else { 144 | //for Android O above "gives W/BroadcastQueue: Background execution not allowed: receiving Intent" 145 | //either set targetSDKversion to 25 or use implicit broadcast 146 | sendImplicitBroadcast(getApplicationContext(), intent); 147 | } 148 | 149 | } 150 | @Override 151 | protected void onCreate(Bundle savedInstanceState) { 152 | super.onCreate(savedInstanceState); 153 | setContentView(R.layout.activity_main); 154 | textView = (TextView) findViewById(R.id.textView); 155 | button = (Button)findViewById(R.id.button); 156 | button.setText("Start Scan"); 157 | 158 | sdkVersion = android.os.Build.VERSION.SDK_INT; 159 | Log.d(TAG, "sdkVersion=" + sdkVersion+"\n"); 160 | 161 | //JUST some code showing how to get Build version etc. 162 | //Log.i(TAG, SystemPropertyAccess.getCommonESversion(getApplicationContext())); 163 | StringBuilder sV=new StringBuilder().append("\n================================================\nService Pack: "+SystemPropertyAccess.getServicePack()+"\n"); 164 | sV.append(sV); 165 | sV.append("HSMVersionInfo: \n"+ SystemPropertyAccess.getHSMVersionInfo()+"\n"); 166 | 167 | sV.append("Build Number: " + android.os.Build.DISPLAY+"\n"); 168 | sV.append("\nPkgInfo: \n"+SystemPropertyAccess.getPkgInfo(getApplicationContext())+"\n"); 169 | 170 | sV.append ("\n================================================\n"); 171 | Log.i(TAG, "\n" + sV.toString()); 172 | 173 | Log.i(TAG, "SerialNumber: "+SystemPropertyAccess.getSerialNumber()); 174 | Log.i(TAG, "SerialNumber2: "+SystemPropertyAccess.getSerialNumber2()); 175 | 176 | button.setOnClickListener(new View.OnClickListener() { 177 | @Override 178 | public void onClick(View v) { 179 | Log.d(TAG, "light scanner"); 180 | mysendBroadcast(new Intent(EXTRA_CONTROL).putExtra(EXTRA_SCAN, true)); 181 | //software defined decode timeout! 182 | final Handler handler = new Handler(); 183 | handler.postDelayed(new Runnable() { 184 | @Override 185 | public void run() 186 | { 187 | mysendBroadcast(new Intent(EXTRA_CONTROL).putExtra(EXTRA_SCAN, false)); 188 | Log.d(TAG, "stop scanner"); 189 | } 190 | }, 3000); 191 | } 192 | }); 193 | Log.d("IntentApiSample: ", "onCreate"); 194 | } 195 | @Override 196 | protected void onResume() { 197 | super.onResume(); 198 | // IntentFilter intentFilter = new IntentFilter("hsm.RECVRBI"); 199 | IntentFilter intent=new IntentFilter(); 200 | intent.addAction(ACTION_BARCODE_DATA); 201 | //TODO: Honeywell needs the Category "android.intent.category.DEFAULT" 202 | intent.addCategory("android.intent.category.DEFAULT"); 203 | registerReceiver(barcodeDataReceiver, intent); 204 | claimScanner(); 205 | Log.d("IntentApiSample: ", "onResume"); 206 | } 207 | @Override 208 | protected void onPause() { 209 | super.onPause(); 210 | unregisterReceiver(barcodeDataReceiver); 211 | releaseScanner(); 212 | Log.d("IntentApiSample: ", "onPause"); 213 | } 214 | private void claimScanner() { 215 | Log.d("IntentApiSample: ", "claimScanner"); 216 | Bundle properties = new Bundle(); 217 | properties.putBoolean("DPR_DATA_INTENT", true); 218 | properties.putString("DPR_DATA_INTENT_ACTION", ACTION_BARCODE_DATA); 219 | 220 | properties.putInt("TRIG_AUTO_MODE_TIMEOUT", 2); 221 | properties.putString("TRIG_SCAN_MODE", "readOnRelease"); //This works for Hardware Trigger only! If scan is started from code, the code is responsible for a switching off the scanner before a decode 222 | 223 | mysendBroadcast(new Intent(ACTION_CLAIM_SCANNER) 224 | .putExtra(EXTRA_SCANNER, "dcs.scanner.imager") 225 | .putExtra(EXTRA_PROFILE, "DEFAULT")// "MyProfile1") 226 | .putExtra(EXTRA_PROPERTIES, properties) 227 | ); 228 | } 229 | private void releaseScanner() { 230 | Log.d("IntentApiSample: ", "releaseScanner"); 231 | mysendBroadcast(new Intent(ACTION_RELEASE_SCANNER)); 232 | } 233 | private void setText(final String text) { 234 | if (textView != null) { 235 | runOnUiThread(new Runnable() { 236 | @Override 237 | public void run() { 238 | textView.setText(text); 239 | } 240 | }); 241 | } 242 | } 243 | private String bytesToHexString(byte[] arr) { 244 | String s = "[]"; 245 | if (arr != null) { 246 | s = "["; 247 | for (int i = 0; i < arr.length; i++) { 248 | s += "0x" + Integer.toHexString(arr[i]) + ", "; 249 | } 250 | s = s.substring(0, s.length() - 2) + "]"; 251 | } 252 | return s; 253 | } 254 | } -------------------------------------------------------------------------------- /app/src/main/java/sample/honeywell/com/intentapisample/SystemPropertyAccess.java: -------------------------------------------------------------------------------- 1 | package sample.honeywell.com.intentapisample; 2 | 3 | import android.content.Context; 4 | import android.content.pm.PackageInfo; 5 | import android.os.Build; 6 | import android.util.Log; 7 | 8 | import java.util.List; 9 | import java.util.Locale; 10 | 11 | public final class SystemPropertyAccess { 12 | private static final String TAG = SystemPropertyAccess.class.getSimpleName(); 13 | 14 | public static String getProperty(String name, String defaultValue) { 15 | try { 16 | Class SystemProperties = Class.forName("android.os.SystemProperties"); 17 | String result = (String) SystemProperties.getMethod("get", new Class[]{String.class, String.class}).invoke(SystemProperties, new Object[]{name, defaultValue}); 18 | if (result.equals("")) { 19 | return "Not Supported"; 20 | } 21 | return result; 22 | } catch (Exception e) { 23 | Log.wtf(TAG, "Failed to get system property", e); 24 | return null; 25 | } 26 | } 27 | 28 | public static void setProperty(String name, String value) { 29 | try { 30 | Class SystemProperties = Class.forName("android.os.SystemProperties"); 31 | SystemProperties.getMethod("set", new Class[]{String.class, String.class}).invoke(SystemProperties, new Object[]{name, value}); 32 | } catch (Exception e) { 33 | Log.wtf(TAG, "Failed to set system property", e); 34 | } 35 | } 36 | 37 | public static String getHSMVersionInfo() { 38 | StringBuffer result = new StringBuffer(); 39 | for (int i = 0; i < PROPERTY_KEYWORDS.length; i++) { 40 | result.append(PROPERTY_KEYWORDS[i][1] + ": " + SystemPropertyAccess.getProperty(PROPERTY_KEYWORDS[i][0], null) + "\n"); 41 | } 42 | return result.toString(); 43 | } 44 | 45 | public static final String[][] PROPERTY_KEYWORDS; 46 | 47 | static { 48 | String[][] r0 = new String[30][]; 49 | r0[0] = new String[]{"ro.hsm.assembly.date", "ID_FINAL_ASSEMBLY_DATE"}; 50 | r0[1] = new String[]{"ro.hsm.asset.num", "ID_ASSET_NUMBER"}; 51 | r0[2] = new String[]{"ro.hsm.bt.addr", "ID_BLUETOOTH_DEVICE_ADDRESS"}; 52 | r0[3] = new String[]{"ro.hsm.cal.accel.zero_offset", "ID_CAL_ACCEL_ZERO_OFFSET"}; 53 | r0[4] = new String[]{"ro.hsm.cal.gyro.zero_offset", "ID_CAL_GYRO_ZERO_OFFSET"}; 54 | r0[5] = new String[]{"ro.hsm.calibration.accelerator", "ID_CALIBRATION_ACCELERATOR"}; 55 | r0[6] = new String[]{"ro.hsm.calibration.gyro", "ID_CALIBRATION_GYRO"}; 56 | r0[7] = new String[]{"ro.hsm.calibration.magnet", "ID_CALIBRATION_MAGNET"}; 57 | r0[8] = new String[]{"ro.hsm.camera.enable_stamp", "ID_CAMERA_ENABLE_STAMP"}; 58 | r0[9] = new String[]{"ro.hsm.extconf.num", "EXTCONFIG_NUM"}; 59 | r0[10] = new String[]{"ro.hsm.extpart.num", "EXTPART_NUM"}; 60 | r0[11] = new String[]{"ro.hsm.extserial.num", "EXTSERIAL_NUM"}; 61 | r0[12] = new String[]{"ro.hsm.file.id", "FILE_ID"}; 62 | r0[13] = new String[]{"ro.hsm.hw.has.gps", "HW_GPS"}; 63 | r0[14] = new String[]{"ro.hsm.hw.rev", "HW_REV"}; 64 | r0[15] = new String[]{"ro.hsm.mfg.ver", "MFG_VER"}; 65 | r0[16] = new String[]{"ro.hsm.mm.feature", "MM_FEATURE"}; 66 | r0[17] = new String[]{"ro.hsm.odm.num", "ODM_NUM"}; 67 | r0[18] = new String[]{"ro.hsm.reset.reason", "RESET_REASON"}; 68 | r0[19] = new String[]{"ro.hsm.imei.num", "ID_IMEI_NUMBER"}; 69 | r0[20] = new String[]{"ro.hsm.meid.num", "ID_ME_NUMBER"}; 70 | r0[21] = new String[]{"ro.hsm.model.num", "ID_MODEL_NUMBER"}; 71 | r0[22] = new String[]{"ro.hsm.extserial.num", "ID_EX_SERIAL_NUMBER"}; 72 | r0[23] = new String[]{"ro.hsm.extpart.num", "ID_EX_PART_NUMBER"}; 73 | r0[24] = new String[]{"ro.hsm.extconf.num", "ID_EX_CONFIGURATION_NUMBER"}; 74 | r0[25] = new String[]{"ro.hon.touch.ver.hw", "TOUCHSCREEN_HARDWARE_VER"}; 75 | r0[26] = new String[]{"ro.hon.touch.ver.fw", "TOUCHSCREEN_FIRMWARE_VER"}; 76 | r0[27] = new String[]{"ro.hon.touch.config", "TOUCHSCREEN_CONFIGURATION_VER"}; 77 | r0[28] = new String[]{"ro.hsm.wireless.feature", "WIRELESS_FEATURE"}; 78 | r0[29] = new String[]{"ro.hsm.wlan.addr", "ID_WLAN_MAC_ADDRESS"}; 79 | PROPERTY_KEYWORDS = r0; 80 | } 81 | 82 | public static final String PKG_DCS_PREFIX = "com.intermec"; 83 | public static final String PKG_DEMOS_PREFIX = "com.honeywell.demos"; 84 | public static final String PKG_HONEYWELL_PREFIX = "com.honeywell"; 85 | public static final String PKG_INTERMEC_PREFIX = "com.intermec"; 86 | public static final String PKG_LICENSE_SERVICE_PREFIX = "com.honeywell.licenseservice"; 87 | public static final String PKG_SYSTEM_TOOL_PREFIX = "com.honeywell.systemtools"; 88 | public static final String PKG_TOOLS_PREFIX = "com.honeywell.tools"; 89 | public static final String PKG_TOOL_SIP_PREFIX = "com.android.hsm"; 90 | 91 | public static String getCommonESversion(Context context){ 92 | String s="no EZConfig found"; 93 | List pkgInfo = context.getPackageManager().getInstalledPackages(0); 94 | for (int i = 0; i < pkgInfo.size(); i++) { 95 | PackageInfo info = (PackageInfo) pkgInfo.get(i); 96 | if (info.packageName.contains("com.honeywell.tools")) { 97 | if(info.packageName.endsWith("ezconfig")){ 98 | s = info.versionName; 99 | } 100 | } 101 | } 102 | return s; 103 | } 104 | 105 | public static String getSerialNumber(){ 106 | 107 | try { 108 | Class SystemProperties = Class.forName("android.os.SystemProperties"); 109 | String name="ro.hsm.extserial.num"; 110 | String defaultValue=null; 111 | String result = (String) SystemProperties.getMethod("get", new Class[]{String.class, String.class}).invoke(SystemProperties, new Object[]{name, defaultValue}); 112 | if (result.equals("")) { 113 | return "Not Supported"; 114 | } 115 | return result; 116 | } catch (Exception e) { 117 | Log.wtf(TAG, "Failed to get system property", e); 118 | return null; 119 | } 120 | 121 | 122 | } 123 | 124 | public static String getSerialNumber2(){ 125 | return Build.SERIAL; 126 | } 127 | 128 | public static String getPkgInfo(Context context) { 129 | StringBuffer result = new StringBuffer(); 130 | StringBuffer demosInfo = new StringBuffer().append("demosInfo\n"); 131 | StringBuffer toolsInfo = new StringBuffer().append("toolsInfo\n"); 132 | StringBuffer appsInfo = new StringBuffer().append("appsInfo\n"); 133 | List pkgInfo = context.getPackageManager().getInstalledPackages(0); 134 | for (int i = 0; i < pkgInfo.size(); i++) { 135 | PackageInfo info = (PackageInfo) pkgInfo.get(i); 136 | //Log.e("package name", info.packageName); 137 | if (info.packageName.contains(PKG_SYSTEM_TOOL_PREFIX)) { 138 | toolsInfo.append(getAppName(info.packageName, PKG_SYSTEM_TOOL_PREFIX.length() + 1) + ": " + info.versionName + "\n"); 139 | } else if (info.packageName.contains("com.honeywell.tools")) { 140 | String sippacakge = "com.honeywell.tools.nosip"; 141 | String carrierpackage = "com.honeywell.tools.carrierselection"; 142 | if (!(info.packageName.equals("com.honeywell.tools.reboot") || info.packageName.equals(carrierpackage) || info.packageName.equals(sippacakge))) { 143 | toolsInfo.append(getAppName(info.packageName, "com.honeywell.tools".length() + 1) + ": " + info.versionName + "\n"); 144 | } 145 | } else if (info.packageName.contains(PKG_TOOL_SIP_PREFIX)) { 146 | toolsInfo.append(getAppName(info.packageName, PKG_TOOL_SIP_PREFIX.length() + 1) + ": " + info.versionName + "\n"); 147 | } else if (info.packageName.contains("com.honeywell.demos")) { 148 | demosInfo.append(getAppName(info.packageName, "com.honeywell.demos".length() + 1) + ": " + info.versionName + "\n"); 149 | } else if (info.packageName.equals(PKG_LICENSE_SERVICE_PREFIX)) { 150 | toolsInfo.append(getAppName(info.packageName, PKG_HONEYWELL_PREFIX.length() + 1) + ": " + info.versionName + "\n"); 151 | } else if (info.packageName.startsWith("com.intermec")) { 152 | toolsInfo.append(getAppName(info.packageName, "com.intermec".length() + 1) + ": " + info.versionName + "\n"); 153 | } else { 154 | appsInfo.append(info.packageName + ": " + info.versionName + "\n"); 155 | } 156 | } 157 | result.append("\n\nPOWER TOOLS AND DEMOS INFO\n"); 158 | result.append("-------------------------\n"); 159 | result.append(toolsInfo); 160 | result.append(demosInfo); 161 | return result.toString(); 162 | } 163 | 164 | private static String getAppName(String pkgName, int subIndex) { 165 | if (pkgName == null || pkgName.length() == 0) { 166 | return "null"; 167 | } 168 | return pkgName.substring(subIndex).toUpperCase(Locale.ENGLISH); 169 | } 170 | public static String getServicePack() { 171 | if (Build.DISPLAY.contains(".SP")) { 172 | return Build.DISPLAY; 173 | } 174 | return "No Service Pack"; 175 | } 176 | 177 | public static String getBuilds(){ 178 | 179 | String sV ="\n\nSYSTEM INFO\n" + "-------------------------\nPRODUCT: " + Build.PRODUCT + "\nBRAND: " + Build.BRAND + "\nSERIAL NUMBER: " + Build.SERIAL + 180 | "\nMODEL: " + Build.MODEL + "\nTYPE: " + Build.TYPE + "\nCPU_ABI: " + Build.CPU_ABI + "\nBUILD NUMBER: " + Build.DISPLAY + "\nINCREMENTAL: " + Build.VERSION.INCREMENTAL + "\nSERVICE_PACK: " + 181 | getServicePack() + "\nRELEASE: " + Build.VERSION.RELEASE + "\n"; 182 | return sV; 183 | } 184 | } -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 18 | 19 |