Changeset 1871 for trunk/autoquest-androidmonitor/src/main/java/de/ugoe/cs/autoquest/androidmonitor/AndroidMonitorLogFile.java
- Timestamp:
- 02/03/15 12:37:19 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/autoquest-androidmonitor/src/main/java/de/ugoe/cs/autoquest/androidmonitor/AndroidMonitorLogFile.java
r1842 r1871 90 90 */ 91 91 public AndroidMonitorLogFile(Activity activity) { 92 93 AndroidMonitorLogFile.currentLoggedComponents = new ArrayList<Integer>();94 95 AndroidMonitorLogFile.appName = getAppLable(activity);96 97 92 createFile(activity); 98 93 } … … 111 106 112 107 /** 113 * Get application name as defined in Package Name 108 * Get application name as defined in Package Name and write it to appName. 114 109 * 115 110 * @param pContext … … 121 116 // http://stackoverflow.com/questions/11229219/android-get-application-name-not-package-name 122 117 // (last call 2014-09-04) 118 String appLabel; 123 119 PackageManager lPackageManager = pContext.getPackageManager(); 124 120 ApplicationInfo lApplicationInfo = null; … … 127 123 lPackageManager.getApplicationInfo(pContext.getApplicationInfo().packageName, 0); 128 124 } 129 catch (final NameNotFoundException e) {} 130 return (String) (lApplicationInfo != null ? lPackageManager 125 catch (final NameNotFoundException e) { 126 127 } 128 appLabel = (String) (lApplicationInfo != null ? lPackageManager 131 129 .getApplicationLabel(lApplicationInfo) : "Unknown"); 130 return appLabel; 132 131 } 133 132 … … 269 268 serializer.startTag("", "component"); 270 269 /* 271 * (non-Javadoc) TODO find a way in that the hash code is unique over time and target 270 * (non-Javadoc) 271 * TODO find a way in that the hash code is unique over time and target 272 272 * 273 273 * view.getId() seems to be unique over time and targets but there is a problem. In some 274 274 * cases there is no ID (value: -1). 275 275 * 276 * view.getId() is not unique in every case. E.g. in the application timerdroid the id 277 * of the list elements changes when calling home button. 276 * view.getId() returns different values in case of some identical components. 277 * E.g. in the application timerdroid the id of the list elements 278 * changes when calling home button. 278 279 */ 279 280 serializer.attribute("", "hash", "" + view.hashCode()); 280 281 currentLoggedComponents.add(view.hashCode()); 281 282 283 /* 284 * (non-Javadoc) 285 * http://developer.android.com/reference/android/view/View.html#getId() 286 * Returns this view's identifier. 287 */ 282 288 serializer.startTag("", "param"); 283 289 serializer.attribute("", "name", "id"); … … 296 302 serializer.startTag("", "param"); 297 303 serializer.attribute("", "name", "title"); 298 299 300 304 serializer.attribute("", "value", "image:" ); 301 305 serializer.endTag("", "param"); … … 316 320 serializer.attribute("", "name", "parent"); 317 321 /* 318 * (non-Javadoc) Problem in using view.getParent().hashCode(): 322 * (non-Javadoc) 323 * Problem in using view.getParent().hashCode(): 319 324 * http://developer.android.com/reference/android/view/View.html#getParent() tells: 320 325 * "... parent is a ViewParent and not necessarily a View." ViewParent does not have a … … 487 492 */ 488 493 private void createFile(Activity activity) { 489 494 495 AndroidMonitorLogFile.appName = getAppLable(activity); 490 496 AndroidMonitorLogFile.name = 491 497 "androidLogFile_" + AndroidMonitorLogFile.appName + System.currentTimeMillis() + ".log"; … … 494 500 new File(activity.getFilesDir(), AndroidMonitorLogFile.name); 495 501 if (AndroidMonitorLogFile.file.exists() && !AndroidMonitorLogFile.file.isDirectory()) { 496 createFile(activity, 0); 502 createFile(activity, 0); 497 503 } 498 504 else { 505 AndroidMonitorLogFile.currentLoggedComponents = new ArrayList<Integer>(); 499 506 writeHeaderToFile(activity); 507 500 508 } 501 509 } … … 521 529 "androidLogFile_" + count + "_" + AndroidMonitorLogFile.appName + 522 530 System.currentTimeMillis() + ".log"; 531 523 532 try { 524 533 AndroidMonitorLogFile.file =
Note: See TracChangeset
for help on using the changeset viewer.