aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ant-glob-tests/.classpath8
-rw-r--r--ant-glob-tests/.gitignore6
-rw-r--r--ant-glob-tests/.project17
-rw-r--r--ant-glob-tests/src/org/apache/tools/ant/types/selectors/SelectorUtilsTest.java37
-rw-r--r--anttargetprint/.classpath7
-rw-r--r--anttargetprint/.project17
-rw-r--r--anttargetprint/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--anttargetprint/src/com/android/anttargetprint/BuildXmlHandler.java108
-rw-r--r--anttargetprint/src/com/android/anttargetprint/Main.java61
-rw-r--r--anttasks/.classpath11
-rw-r--r--anttasks/.gitignore2
-rw-r--r--anttasks/.project17
-rw-r--r--anttasks/.settings/README.txt2
-rw-r--r--anttasks/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--anttasks/Android.mk34
-rw-r--r--anttasks/NOTICE190
-rw-r--r--anttasks/etc/manifest.txt1
-rw-r--r--anttasks/src/anttasks.properties22
-rw-r--r--anttasks/src/com/android/ant/AaptExecTask.java793
-rw-r--r--anttasks/src/com/android/ant/AidlExecTask.java195
-rw-r--r--anttasks/src/com/android/ant/ApkBuilderTask.java393
-rw-r--r--anttasks/src/com/android/ant/BuildConfigTask.java76
-rw-r--r--anttasks/src/com/android/ant/BuildTypedTask.java63
-rw-r--r--anttasks/src/com/android/ant/CheckEnvTask.java105
-rw-r--r--anttasks/src/com/android/ant/ComputeDependencyTask.java283
-rw-r--r--anttasks/src/com/android/ant/ComputeProjectClasspathTask.java94
-rw-r--r--anttasks/src/com/android/ant/DependencyGraph.java441
-rw-r--r--anttasks/src/com/android/ant/DependencyHelper.java309
-rw-r--r--anttasks/src/com/android/ant/DexExecTask.java278
-rw-r--r--anttasks/src/com/android/ant/GetEmmaFilterTask.java95
-rw-r--r--anttasks/src/com/android/ant/GetLibraryPathTask.java208
-rw-r--r--anttasks/src/com/android/ant/GetProjectPathsTask.java70
-rw-r--r--anttasks/src/com/android/ant/GetTargetTask.java300
-rw-r--r--anttasks/src/com/android/ant/GetTypeTask.java109
-rw-r--r--anttasks/src/com/android/ant/GetUiTargetTask.java159
-rw-r--r--anttasks/src/com/android/ant/IfElseTask.java128
-rw-r--r--anttasks/src/com/android/ant/InputPath.java107
-rw-r--r--anttasks/src/com/android/ant/LintExecTask.java108
-rw-r--r--anttasks/src/com/android/ant/ManifestMergerTask.java169
-rw-r--r--anttasks/src/com/android/ant/MultiFilesTask.java197
-rw-r--r--anttasks/src/com/android/ant/PropertyByReplaceTask.java48
-rw-r--r--anttasks/src/com/android/ant/RenderScriptTask.java241
-rw-r--r--anttasks/src/com/android/ant/SignApkTask.java147
-rw-r--r--anttasks/src/com/android/ant/SingleDependencyTask.java168
-rw-r--r--anttasks/src/com/android/ant/SingleInputOutputTask.java78
-rw-r--r--anttasks/src/com/android/ant/TaskHelper.java161
-rw-r--r--anttasks/src/com/android/ant/XPathTask.java90
-rw-r--r--anttasks/src/com/android/ant/ZipAlignTask.java84
-rw-r--r--apigenerator/.classpath10
-rw-r--r--apigenerator/.gitignore2
-rw-r--r--apigenerator/.project17
-rw-r--r--apigenerator/src/com/android/apigenerator/AndroidJarReader.java253
-rw-r--r--apigenerator/src/com/android/apigenerator/ApiClass.java205
-rw-r--r--apigenerator/src/com/android/apigenerator/Main.java79
-rw-r--r--archquery/.classpath6
-rw-r--r--archquery/.gitignore1
-rw-r--r--archquery/.project17
-rw-r--r--archquery/Android.mk30
-rw-r--r--archquery/NOTICE190
-rw-r--r--archquery/etc/manifest.txt1
-rw-r--r--archquery/src/com/android/archquery/Main.java72
-rw-r--r--assetstudio/.classpath11
-rw-r--r--assetstudio/.gitignore2
-rw-r--r--assetstudio/.project17
-rw-r--r--assetstudio/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--assetstudio/Android.mk40
-rw-r--r--assetstudio/etc/manifest.txt1
-rw-r--r--build/sdk_only_whitelist.mk74
-rw-r--r--chimpchat/Android.mk18
-rw-r--r--chimpchat/MODULE_LICENSE_APACHE20
-rw-r--r--chimpchat/NOTICE190
-rw-r--r--chimpchat/src/Android.mk31
-rw-r--r--chimpchat/src/com/android/chimpchat/ChimpChat.java109
-rw-r--r--chimpchat/src/com/android/chimpchat/ChimpManager.java455
-rw-r--r--chimpchat/src/com/android/chimpchat/adb/AdbBackend.java148
-rw-r--r--chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java631
-rw-r--r--chimpchat/src/com/android/chimpchat/adb/AdbChimpImage.java47
-rw-r--r--chimpchat/src/com/android/chimpchat/adb/CommandOutputCapture.java42
-rw-r--r--chimpchat/src/com/android/chimpchat/adb/LinearInterpolator.java128
-rw-r--r--chimpchat/src/com/android/chimpchat/adb/LoggingOutputReceiver.java47
-rw-r--r--chimpchat/src/com/android/chimpchat/adb/image/CaptureRawAndConvertedImage.java108
-rw-r--r--chimpchat/src/com/android/chimpchat/adb/image/ImageUtils.java100
-rw-r--r--chimpchat/src/com/android/chimpchat/adb/image/SixteenBitColorModel.java95
-rw-r--r--chimpchat/src/com/android/chimpchat/adb/image/ThirtyTwoBitColorModel.java126
-rw-r--r--chimpchat/src/com/android/chimpchat/core/By.java46
-rw-r--r--chimpchat/src/com/android/chimpchat/core/ChimpException.java22
-rw-r--r--chimpchat/src/com/android/chimpchat/core/ChimpImageBase.java219
-rw-r--r--chimpchat/src/com/android/chimpchat/core/ChimpRect.java105
-rw-r--r--chimpchat/src/com/android/chimpchat/core/ChimpView.java201
-rw-r--r--chimpchat/src/com/android/chimpchat/core/IChimpBackend.java45
-rw-r--r--chimpchat/src/com/android/chimpchat/core/IChimpDevice.java247
-rw-r--r--chimpchat/src/com/android/chimpchat/core/IChimpImage.java36
-rw-r--r--chimpchat/src/com/android/chimpchat/core/IChimpView.java92
-rw-r--r--chimpchat/src/com/android/chimpchat/core/IMultiSelector.java29
-rw-r--r--chimpchat/src/com/android/chimpchat/core/ISelector.java29
-rw-r--r--chimpchat/src/com/android/chimpchat/core/MultiSelectorText.java75
-rw-r--r--chimpchat/src/com/android/chimpchat/core/PhysicalButton.java39
-rw-r--r--chimpchat/src/com/android/chimpchat/core/SelectorAccessibilityIds.java48
-rw-r--r--chimpchat/src/com/android/chimpchat/core/SelectorId.java42
-rw-r--r--chimpchat/src/com/android/chimpchat/core/TouchPressType.java49
-rw-r--r--chimpchat/src/com/android/chimpchat/hierarchyviewer/HierarchyViewer.java182
-rw-r--r--chimpchat/test/Android.mk23
-rw-r--r--chimpchat/test/com/android/chimpchat/AllTests.java49
-rw-r--r--chimpchat/test/com/android/chimpchat/ImageUtilsTest.java96
-rw-r--r--chimpchat/test/com/android/chimpchat/adb/AdbChimpDeviceTest.java59
-rw-r--r--chimpchat/test/com/android/chimpchat/adb/LinearInterpolatorTest.java138
-rw-r--r--chimpchat/test/resources/com/android/monkeyrunner/adb/instrument_result.txt10
-rw-r--r--chimpchat/test/resources/com/android/monkeyrunner/adb/multiline_instrument_result.txt15
-rw-r--r--chimpchat/test/resources/com/android/monkeyrunner/image1.pngbin184289 -> 0 bytes
-rw-r--r--chimpchat/test/resources/com/android/monkeyrunner/image1.rawbin307545 -> 0 bytes
-rw-r--r--chimpchat/test/resources/com/android/monkeyrunner/image2.pngbin82036 -> 0 bytes
-rw-r--r--chimpchat/test/resources/com/android/monkeyrunner/image2.rawbin1536345 -> 0 bytes
-rw-r--r--common/.classpath8
-rw-r--r--common/.gitignore3
-rw-r--r--common/.project17
-rw-r--r--common/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--common/.settings/org.moreunit.prefs4
-rw-r--r--common/Android.mk36
-rw-r--r--common/NOTICE190
-rw-r--r--common/README.txt14
-rw-r--r--common/manifest.txt1
-rw-r--r--ddms/.gitignore5
-rw-r--r--ddms/Android.mk5
-rw-r--r--ddms/MODULE_LICENSE_APACHE20
-rw-r--r--ddms/app/.classpath16
-rw-r--r--ddms/app/.project17
-rw-r--r--ddms/app/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--ddms/app/Android.mk32
-rw-r--r--ddms/app/NOTICE190
-rw-r--r--ddms/app/README75
-rw-r--r--ddms/app/etc/Android.mk8
-rwxr-xr-xddms/app/etc/ddms111
-rwxr-xr-xddms/app/etc/ddms.bat74
-rw-r--r--ddms/app/etc/manifest.txt3
-rw-r--r--ddms/app/src/com/android/ddms/AboutDialog.java158
-rw-r--r--ddms/app/src/com/android/ddms/DebugPortProvider.java164
-rw-r--r--ddms/app/src/com/android/ddms/DeviceCommandDialog.java441
-rw-r--r--ddms/app/src/com/android/ddms/DropdownSelectionListener.java80
-rw-r--r--ddms/app/src/com/android/ddms/Main.java171
-rw-r--r--ddms/app/src/com/android/ddms/PrefsDialog.java610
-rw-r--r--ddms/app/src/com/android/ddms/StaticPortConfigDialog.java395
-rw-r--r--ddms/app/src/com/android/ddms/StaticPortEditDialog.java334
-rw-r--r--ddms/app/src/com/android/ddms/UIThread.java1803
-rw-r--r--ddms/app/src/images/ddms-128.pngbin17692 -> 0 bytes
-rw-r--r--ddms/libs/Android.mk5
-rw-r--r--ddms/libs/ddmlib/.classpath7
-rw-r--r--ddms/libs/ddmlib/.project17
-rw-r--r--ddms/libs/ddmlib/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--ddms/libs/ddmlib/Android.mk32
-rw-r--r--ddms/libs/ddmlib/NOTICE190
-rw-r--r--ddms/libs/ddmuilib/.classpath15
-rw-r--r--ddms/libs/ddmuilib/.project17
-rw-r--r--ddms/libs/ddmuilib/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--ddms/libs/ddmuilib/Android.mk31
-rw-r--r--ddms/libs/ddmuilib/NOTICE190
-rw-r--r--ddms/libs/ddmuilib/README14
-rw-r--r--ddms/libs/ddmuilib/etc/manifest.txt1
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/AbstractBufferFindTarget.java117
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/Addr2Line.java355
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/AllocationPanel.java651
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/BackgroundThread.java50
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/BaseHeapPanel.java193
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/ClientDisplayPanel.java33
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/DdmUiPreferences.java79
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/DevicePanel.java784
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/EmulatorControlPanel.java1463
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/FindDialog.java142
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/HeapPanel.java1310
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/IFindTarget.java21
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/ITableFocusListener.java38
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/ImageLoader.java206
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/InfoPanel.java199
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/NativeHeapPanel.java1648
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/Panel.java49
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/PortFieldEditor.java73
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/ScreenShotDialog.java350
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/SelectionDependentPanel.java78
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/StackTracePanel.java223
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/SyncProgressHelper.java100
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/SyncProgressMonitor.java60
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/SysinfoPanel.java907
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/TableHelper.java209
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/TablePanel.java132
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/ThreadPanel.java573
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/actions/ICommonAction.java42
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/actions/ToolItemAction.java71
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/annotation/UiThread.java31
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/annotation/WorkerThread.java31
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/console/DdmConsole.java91
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/console/IDdmConsole.java47
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/explorer/DeviceContentProvider.java177
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/explorer/DeviceExplorer.java922
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/explorer/FileLabelProvider.java160
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/handler/BaseFileHandler.java184
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/handler/MethodProfilingHandler.java195
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapDataImporter.java222
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapDiffSnapshot.java65
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapLabelProvider.java112
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapPanel.java1150
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapProviderByAllocations.java90
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapProviderByLibrary.java92
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapSnapshot.java133
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeLibraryAllocationInfo.java135
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeStackContentProvider.java56
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeStackLabelProvider.java71
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeSymbolResolverTask.java306
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/location/CoordinateControls.java249
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/location/GpxParser.java373
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/location/KmlParser.java210
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/location/LocationPoint.java53
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/location/TrackContentProvider.java48
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/location/TrackLabelProvider.java87
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/location/TrackPoint.java34
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/location/WayPoint.java42
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/location/WayPointContentProvider.java46
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/location/WayPointLabelProvider.java79
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/BugReportImporter.java96
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplayFilteredLog.java55
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplayGraph.java422
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplayLog.java381
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplaySync.java304
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplaySyncHistogram.java181
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplaySyncPerf.java227
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventDisplay.java975
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventDisplayOptions.java961
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogImporter.java95
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogPanel.java938
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventValueSelector.java630
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/OccurrenceRenderer.java90
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/SyncCommon.java173
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/EditFilterDialog.java397
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/ILogCatBufferChangeListener.java33
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/ILogCatMessageSelectionListener.java26
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterContentProvider.java46
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterData.java81
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterLabelProvider.java63
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterSettingsDialog.java327
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterSettingsSerializer.java211
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatMessageList.java116
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java1607
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatReceiver.java151
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatReceiverFactory.java95
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatStackTraceParser.java81
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogColors.java27
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogFilter.java556
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogPanel.java1626
-rw-r--r--ddms/libs/ddmuilib/src/com/android/ddmuilib/net/NetworkPanel.java1125
-rw-r--r--ddms/libs/ddmuilib/src/images/add.pngbin146 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/android.pngbin3609 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/backward.pngbin136 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/capture.pngbin691 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/clear.pngbin217 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/d.pngbin638 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/debug-attach.pngbin156 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/debug-error.pngbin222 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/debug-wait.pngbin156 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/delete.pngbin107 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/device.pngbin135 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/diff.pngbin213 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/displayfilters.pngbin242 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/down.pngbin141 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/e.pngbin511 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/edit.pngbin223 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/empty.pngbin75 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/emulator.pngbin287 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/file.pngbin157 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/folder.pngbin123 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/forward.pngbin137 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/gc.pngbin165 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/groupby.pngbin413 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/halt.pngbin197 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/heap.pngbin222 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/hprof.pngbin317 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/i.pngbin498 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/importBug.pngbin191 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/load.pngbin163 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/pause.pngbin98 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/play.pngbin138 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/pull.pngbin329 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/push.pngbin228 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/save.pngbin240 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/scroll_lock.pngbin291 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/sort_down.pngbin102 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/sort_up.pngbin105 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/thread.pngbin121 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/tracing_start.pngbin227 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/tracing_stop.pngbin217 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/up.pngbin134 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/v.pngbin587 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/w.pngbin681 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/warning.pngbin147 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/src/images/zygote.pngbin345 -> 0 bytes
-rw-r--r--ddms/libs/ddmuilib/tests/.classpath11
-rw-r--r--ddms/libs/ddmuilib/tests/.project17
-rw-r--r--ddms/libs/ddmuilib/tests/Android.mk37
-rw-r--r--ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/BugReportParserTest.java188
-rw-r--r--ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/heap/NativeHeapDataImporterTest.java74
-rw-r--r--ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/logcat/LogCatFilterSettingsSerializerTest.java75
-rw-r--r--ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/logcat/LogCatStackTraceParserTest.java54
-rw-r--r--ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/logcat/RollingBufferFindTest.java108
-rw-r--r--device_validator/.gitignore1
-rw-r--r--device_validator/Android.mk5
-rw-r--r--device_validator/MODULE_LICENSE_APACHE20
-rw-r--r--device_validator/app/.classpath7
-rw-r--r--device_validator/app/.project17
-rw-r--r--device_validator/app/.settings/org.eclipse.jdt.ui.prefs3
-rw-r--r--device_validator/app/Android.mk31
-rw-r--r--device_validator/app/etc/Android.mk10
-rw-r--r--device_validator/app/etc/README19
-rwxr-xr-xdevice_validator/app/etc/device_validator79
-rw-r--r--device_validator/app/etc/manifest.txt3
-rw-r--r--device_validator/app/src/com/android/validator/DeviceValidator.java55
-rw-r--r--device_validator/dvlib/.classpath10
-rw-r--r--device_validator/dvlib/.gitignore2
-rw-r--r--device_validator/dvlib/.project17
-rw-r--r--device_validator/dvlib/Android.mk34
-rw-r--r--draw9patch/.gitignore3
-rw-r--r--draw9patch/Android.mk29
-rw-r--r--draw9patch/MODULE_LICENSE_APACHE20
-rw-r--r--draw9patch/NOTICE190
-rw-r--r--draw9patch/etc/Android.mk21
-rwxr-xr-xdraw9patch/etc/draw9patch63
-rwxr-xr-xdraw9patch/etc/draw9patch.bat46
-rw-r--r--draw9patch/etc/manifest.txt1
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/Application.java55
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/graphics/GraphicsUtilities.java96
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/ui/CorruptPatch.java100
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/ui/GradientPanel.java47
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/ui/ImageEditorPanel.java387
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/ui/ImageTransferHandler.java92
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/ui/ImageViewer.java1190
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/ui/MainFrame.java179
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/ui/OpenFilePanel.java51
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/ui/Pair.java32
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/ui/PatchInfo.java225
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/ui/PngFileFilter.java32
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/ui/StretchesViewer.java326
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/ui/action/BackgroundAction.java28
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/ui/action/ExitAction.java44
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/ui/action/OpenAction.java43
-rw-r--r--draw9patch/src/main/java/com/android/draw9patch/ui/action/SaveAction.java43
-rw-r--r--draw9patch/src/main/resources/images/checker.pngbin1889 -> 0 bytes
-rw-r--r--draw9patch/src/main/resources/images/drop.pngbin5479 -> 0 bytes
-rw-r--r--draw9patch/src/test/java/com/android/draw9patch/ui/PatchInfoTest.java129
-rw-r--r--hierarchyviewer2/.gitignore3
-rw-r--r--hierarchyviewer2/Android.mk17
-rw-r--r--hierarchyviewer2/MODULE_LICENSE_APACHE20
-rw-r--r--hierarchyviewer2/app/.classpath16
-rw-r--r--hierarchyviewer2/app/.gitignore1
-rw-r--r--hierarchyviewer2/app/.project17
-rw-r--r--hierarchyviewer2/app/.settings/README.txt2
-rw-r--r--hierarchyviewer2/app/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--hierarchyviewer2/app/Android.mk40
-rw-r--r--hierarchyviewer2/app/NOTICE190
-rwxr-xr-xhierarchyviewer2/app/README69
-rw-r--r--hierarchyviewer2/app/etc/Android.mk20
-rwxr-xr-xhierarchyviewer2/app/etc/hierarchyviewer114
-rwxr-xr-xhierarchyviewer2/app/etc/hierarchyviewer.bat75
-rw-r--r--hierarchyviewer2/app/etc/manifest.txt2
-rw-r--r--hierarchyviewer2/app/src/com/android/hierarchyviewer/AboutDialog.java72
-rw-r--r--hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplication.java942
-rw-r--r--hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplicationDirector.java84
-rw-r--r--hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/AboutAction.java65
-rw-r--r--hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/LoadAllViewsAction.java60
-rw-r--r--hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/QuitAction.java44
-rw-r--r--hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/ShowOverlayAction.java116
-rw-r--r--hierarchyviewer2/app/src/com/android/hierarchyviewer/util/ActionButton.java83
-rw-r--r--hierarchyviewer2/libs/Android.mk16
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/.classpath14
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/.gitignore1
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/.project17
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/.settings/README.txt2
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/Android.mk16
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/NOTICE190
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/manifest.txt1
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/Android.mk34
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/HierarchyViewerDirector.java722
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/CapturePSDAction.java62
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/DisplayViewAction.java62
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/DumpDisplayListAction.java56
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/ImageAction.java27
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/InspectScreenshotAction.java96
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/InvalidateAction.java58
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/LoadOverlayAction.java62
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/LoadViewHierarchyAction.java96
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/PixelPerfectAutoRefreshAction.java59
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/PixelPerfectEnabledAction.java82
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/ProfileNodesAction.java55
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshPixelPerfectAction.java58
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshPixelPerfectTreeAction.java58
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshViewAction.java58
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshWindowsAction.java59
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RequestLayoutAction.java58
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/SavePixelPerfectAction.java62
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/SaveTreeViewAction.java62
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/SelectedNodeEnabledAction.java62
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/TreeViewEnabledAction.java54
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/AbstractHvDevice.java67
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/DdmViewDebugDevice.java417
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/DeviceBridge.java695
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/DeviceConnection.java100
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/HvDeviceFactory.java57
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/IHvDevice.java62
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/ViewServerDevice.java169
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/WindowUpdater.java160
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/DeviceSelectionModel.java260
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/PixelPerfectModel.java360
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/TreeViewModel.java215
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/ViewNode.java369
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/Window.java117
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/CaptureDisplay.java218
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/DevicePropertyEditingSupport.java302
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/DeviceSelector.java342
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/InvokeMethodPrompt.java166
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/LayoutViewer.java372
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfect.java392
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectControls.java296
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectLoupe.java391
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectPixelPanel.java203
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectTree.java241
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PropertyViewer.java391
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/TreeView.java1086
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/TreeViewControls.java153
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/TreeViewOverview.java396
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/util/DrawableViewNode.java266
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/util/PsdFile.java508
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/util/TreeColumnResizer.java114
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/auto-refresh.pngbin541 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/capture-psd.pngbin339 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/device-view-selected.pngbin254 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/device-view.pngbin228 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/display.pngbin946 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/filtered.pngbin9242 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/green.pngbin302 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/inspect-screenshot.pngbin412 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/invalidate.pngbin391 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/load-all-views.pngbin728 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/load-overlay.pngbin549 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/load-view-hierarchy.pngbin288 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/not-selected.pngbin12468 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/on-black.pngbin157 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/on-white.pngbin158 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/picker.pngbin370 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/pixel-perfect-view-selected.pngbin734 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/pixel-perfect-view.pngbin733 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/profile.pngbin597 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/red.pngbin383 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/refresh-windows.pngbin872 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/request-layout.pngbin223 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/save.pngbin360 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/sdk-hierarchyviewer-128.pngbin17512 -> 0 bytes
-rwxr-xr-xhierarchyviewer2/libs/hierarchyviewerlib/src/images/sdk-hierarchyviewer-16.pngbin880 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected-filtered-small.pngbin5182 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected-filtered.pngbin9015 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected-small.pngbin12611 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected.pngbin12159 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/show-extras.pngbin330 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/show-overlay.pngbin958 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/tree-view-selected.pngbin276 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/tree-view.pngbin281 -> 0 bytes
-rw-r--r--hierarchyviewer2/libs/hierarchyviewerlib/src/images/yellow.pngbin255 -> 0 bytes
-rw-r--r--jobb/Android.mk29
-rw-r--r--jobb/NOTICE50
-rw-r--r--layoutlib_api/.classpath8
-rw-r--r--layoutlib_api/.gitignore3
-rw-r--r--layoutlib_api/.project17
-rw-r--r--layoutlib_api/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--layoutlib_api/Android.mk35
-rw-r--r--layoutlib_api/NOTICE190
-rw-r--r--layoutlib_api/README.txt16
-rw-r--r--layoutlib_api/sample/.classpath11
-rw-r--r--layoutlib_api/sample/.project17
-rw-r--r--layoutlib_api/sample/README.txt16
-rw-r--r--layoutlib_api/sample/src/com/example/android/render/Main.java164
-rw-r--r--layoutlib_api/sample/src/com/example/android/render/ProjectCallback.java112
-rw-r--r--layoutlib_api/sample/src/com/example/android/render/RenderService.java313
-rw-r--r--layoutlib_api/sample/src/com/example/android/render/RenderServiceFactory.java337
-rw-r--r--layoutlib_api/sample/src/com/example/android/render/StdOutLogger.java78
-rw-r--r--layoutlib_api/sample/src/com/example/android/render/XmlParser.java41
-rw-r--r--layoutlib_api/sample/testproject/AndroidManifest.xml15
-rw-r--r--layoutlib_api/sample/testproject/build.properties17
-rw-r--r--layoutlib_api/sample/testproject/build.xml79
-rw-r--r--layoutlib_api/sample/testproject/default.properties11
-rw-r--r--layoutlib_api/sample/testproject/proguard.cfg40
-rw-r--r--layoutlib_api/sample/testproject/res/drawable-hdpi/icon.pngbin4147 -> 0 bytes
-rw-r--r--layoutlib_api/sample/testproject/res/drawable-ldpi/icon.pngbin1723 -> 0 bytes
-rw-r--r--layoutlib_api/sample/testproject/res/drawable-mdpi/icon.pngbin2574 -> 0 bytes
-rw-r--r--layoutlib_api/sample/testproject/res/layout/main.xml14
-rw-r--r--layoutlib_api/sample/testproject/res/values/strings.xml4
-rw-r--r--layoutlib_api/sample/testproject/src/com/example/layoutlib/testproject/Main.java15
-rw-r--r--lint/.gitignore7
-rw-r--r--lint/Android.mk5
-rw-r--r--lint/MODULE_LICENSE_APACHE20
-rw-r--r--lint/cli/.classpath15
-rw-r--r--lint/cli/.project17
-rw-r--r--lint/cli/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--lint/cli/Android.mk42
-rw-r--r--lint/cli/NOTICE190
-rw-r--r--lint/cli/etc/Android.mk10
-rwxr-xr-xlint/cli/etc/lint72
-rwxr-xr-xlint/cli/etc/lint.bat58
-rw-r--r--lint/cli/etc/manifest.txt2
-rw-r--r--lint/cli/src/main/java/com/android/tools/lint/HtmlReporter.java773
-rw-r--r--lint/cli/src/main/java/com/android/tools/lint/LintCliXmlParser.java222
-rw-r--r--lint/cli/src/main/java/com/android/tools/lint/LombokParser.java150
-rw-r--r--lint/cli/src/main/java/com/android/tools/lint/Main.java1459
-rw-r--r--lint/cli/src/main/java/com/android/tools/lint/MultiProjectHtmlReporter.java246
-rw-r--r--lint/cli/src/main/java/com/android/tools/lint/Reporter.java259
-rw-r--r--lint/cli/src/main/java/com/android/tools/lint/TextReporter.java179
-rw-r--r--lint/cli/src/main/java/com/android/tools/lint/Warning.java91
-rw-r--r--lint/cli/src/main/java/com/android/tools/lint/XmlReporter.java189
-rw-r--r--lint/cli/src/main/java/com/android/tools/lint/default.css72
-rw-r--r--lint/cli/src/main/java/com/android/tools/lint/hololike.css175
-rw-r--r--lint/cli/src/main/java/com/android/tools/lint/lint-error.pngbin638 -> 0 bytes
-rw-r--r--lint/cli/src/main/java/com/android/tools/lint/lint-run.pngbin422 -> 0 bytes
-rw-r--r--lint/cli/src/main/java/com/android/tools/lint/lint-warning.pngbin337 -> 0 bytes
-rw-r--r--lint/cli/src/test/.classpath19
-rw-r--r--lint/cli/src/test/.project17
-rw-r--r--lint/cli/src/test/.settings/org.eclipse.core.resources.prefs5
-rw-r--r--lint/cli/src/test/.settings/org.moreunit.prefs4
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/LintCliXmlParserTest.java169
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/MainTest.java382
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/XmlReporterTest.java244
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/AbstractCheckTest.java452
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/AccessibilityDetectorTest.java43
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/AlwaysShowActionDetectorTest.java85
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/AnnotationDetectorTest.java66
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ApiDetectorTest.java900
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ApiLookupTest.java216
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ArraySizeDetectorTest.java71
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ButtonDetectorTest.java415
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ChildCountDetectorTest.java44
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/CleanupDetectorTest.java120
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ColorUsageDetectorTest.java44
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/CommentDetectorTest.java53
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/CutPasteDetectorTest.java55
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/DeprecationDetectorTest.java87
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/DetectMissingPrefixTest.java84
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/DosLineEndingDetectorTest.java49
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/DuplicateIdDetectorTest.java91
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/DuplicateResourceDetectorTest.java63
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ExtraTextDetectorTest.java37
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/FieldGetterDetectorTest.java135
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/FragmentDetectorTest.java60
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/GridLayoutDetectorTest.java37
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/HandlerDetectorTest.java46
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/HardcodedDebugModeDetectorTest.java43
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/HardcodedValuesDetectorTest.java73
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/IconDetectorTest.java461
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/InefficientWeightDetectorTest.java127
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/InvalidPackageDetectorTest.java56
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/JavaPerformanceDetectorTest.java106
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/LabelForDetectorTest.java78
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/LocaleDetectorTest.java76
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ManifestOrderDetectorTest.java323
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ManifestTypoDetectorTest.java184
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/MathDetectorTest.java67
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/MergeRootFrameLayoutDetectorTest.java69
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/MissingClassDetectorTest.java393
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/MissingIdDetectorTest.java37
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/NamespaceDetectorTest.java183
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/NestedScrollingWidgetDetectorTest.java37
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/NonInternationalizedSmsDetectorTest.java38
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ObsoleteLayoutParamsDetectorTest.java104
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/OnClickDetectorTest.java75
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/OverdrawDetectorTest.java102
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/OverrideDetectorTest.java47
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/PrivateKeyDetectorTest.java43
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/PrivateResourceDetectorTest.java37
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ProguardDetectorTest.java93
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/PxUsageDetectorTest.java89
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/RegistrationDetectorTest.java131
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/RequiredAttributeDetectorTest.java125
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ScrollViewChildDetectorTest.java37
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/SdCardDetectorTest.java98
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/SecureRandomDetectorTest.java64
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/SecurityDetectorTest.java213
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/SetJavaScriptEnabledDetectorTest.java38
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/SharedPrefsDetectorTest.java109
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/StateListDetectorTest.java55
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/StringFormatDetectorTest.java198
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/StyleCycleDetectorTest.java49
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/SystemPermissionsDetectorTest.java300
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/TextFieldDetectorTest.java127
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/TextViewDetectorTest.java102
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/TitleDetectorTest.java58
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ToastDetectorTest.java47
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/TooManyViewsDetectorTest.java47
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/TranslationDetectorTest.java223
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/TypoDetectorTest.java155
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/TypoLookupTest.java523
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/TypographyDetectorTest.java147
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/UnusedResourceDetectorTest.java277
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/UseCompoundDrawableDetectorTest.java51
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/UselessViewDetectorTest.java67
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/Utf8DetectorTest.java56
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ViewConstructorDetectorTest.java76
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ViewTagDetectorTest.java68
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/ViewTypeDetectorTest.java85
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/WakelockDetectorTest.java175
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/WrongCallDetectorTest.java58
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/WrongCaseDetectorTest.java46
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/WrongIdDetectorTest.java98
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/WrongImportDetectorTest.java40
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/WrongLocationDetectorTest.java43
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/AbstractActivity.java.txt6
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/AndroidManifest.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/allowbackup.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/allowbackup_ignore.xml25
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest.class.databin1750 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest.java.txt52
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest10.class.databin1292 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest10.java.txt45
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11$MyActivity.class.databin566 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11$MyLinear.class.databin810 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11.class.databin872 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11.java.txt50
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest12.class.databin1044 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest12.java.txt30
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest2.class.databin386 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest2.java.txt9
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest3.class.databin409 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest3.java.txt12
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$1.class.databin674 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass1$InnerInnerClass1.class.databin762 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass1.class.databin824 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass2.class.databin638 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4.class.databin854 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4.java.txt41
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.class.databin796 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.java.txt23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest6.class.databin512 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest6.java.txt10
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest7.class.databin596 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest7.java.txt14
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest8.class.databin426 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest8.java.txt10
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest9.class.databin732 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest9.java.txt19
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck.class.databin2133 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck.java.txt123
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck2.class.databin553 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck2.java.txt18
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest$LocalClass.class.databin798 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest.class.databin887 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest.java.txt42
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1$1.class.databin704 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1$2.class.databin704 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1.class.databin1059 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2.class.databin556 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2.java.txt39
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/CloseTest.class.databin511 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/CloseTest.java.txt9
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate$IntermediateCustomV.class.databin440 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate.class.databin383 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate.java.txt15
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/MyActivityImpl.class.databin512 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/MyActivityImpl.java.txt15
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest1.class.databin2775 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest1.java.txt137
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest2.class.databin898 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest2.java.txt25
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest3.class.databin901 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest3.java.txt25
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest4.class.databin550 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest4.java.txt21
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestEnum.class.databin4940 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestEnum.java.txt67
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestLint.class.databin829 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/android-support-v4.jar.databin385685 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/classpath8
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/colors.xml6
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/divider.xml37
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/holomanifest.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/layout.xml32
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/layout_targetapi.xml35
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk1.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk10.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk14.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk17.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk2.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk4.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/themes.xml16
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/unsupported.jar.databin1196 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/view.xml27
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/broken-manifest.xml18
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/broken-manifest2.xml28
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/.classpath8
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractActivity.class.databin295 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractActivity.java.txt6
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.class.databin334 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.java.txt9
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifest.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestReg.xml18
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestRegs.xml36
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestWrongRegs.xml21
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class1$Class4.class.databin368 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class1.class.databin812 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class2$Class3.class.databin457 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class2.class.databin942 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommentsActivity.class.databin303 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommentsActivity.java.txt6
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommitTest.class.databin3612 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommitTest.java.txt91
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView1.class.databin313 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView1.java.txt9
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView2.class.databin543 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView2.java.txt12
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView3.class.databin736 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView3.java.txt20
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomViewTest.class.databin390 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/DialogFragment.class.databin7113 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment1.class.databin373 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment2.class.databin460 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment3.class.databin377 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment4.class.databin406 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment5.class.databin471 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment6.class.databin487 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$NotAFragment.class.databin465 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$ValidFragment1.class.databin392 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest.class.databin774 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest.java.txt55
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.class.databin1291 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.jar.databin1298 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.java.txt59
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$1.class.databin629 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$Inner.class.databin599 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$StaticInner.class.databin532 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest.class.databin607 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest.java.txt24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LayoutTest.class.databin1312 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LayoutTest.java.txt66
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LocaleTest.class.databin2272 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LocaleTest.java.txt37
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/MathTest.class.databin847 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/MathTest.java.txt21
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/OnClickActivity.class.databin1282 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/OnClickActivity.java.txt48
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/PowerManagerFlagTest.class.databin862 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/PowerManagerFlagTest.java.txt18
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/RecycleTest.class.databin4321 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/RecycleTest.java.txt159
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/SecureRandomTest.class.databin1379 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/SecureRandomTest.java.txt42
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestFieldGetter.class.databin933 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestFieldGetter.java.txt36
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider.class.databin1401 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider.java.txt40
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider2.class.databin287 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider2.java.txt4
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver$1.class.databin748 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver.class.databin726 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver.java.txt21
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestService.class.databin441 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestService.java.txt14
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/ViewTagTest.class.databin1645 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/ViewTagTest.java.txt37
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity1.class.databin920 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity1.java.txt17
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity2.class.databin779 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity2.java.txt24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity3.class.databin1067 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity3.java.txt19
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity4.class.databin1238 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity4.java.txt27
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity5.class.databin1067 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity5.java.txt19
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity6.class.databin2129 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity6.java.txt71
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity7.class.databin798 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity7.java.txt17
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity8.class.databin1069 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity8.java.txt24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classes.jarbin3186 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classpath-jar8
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classpath-lib9
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/debuggable.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate-manifest-ignore.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate-manifest.xml22
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions1.xml21
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions2.xml18
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions3.xml18
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity0.xml19
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity1.xml32
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity2.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity3.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity4.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportprovider1.xml33
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportprovider2.xml39
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver0.xml19
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver1.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver2.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver3.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver4.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver5.xml20
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver6.xml43
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice1.xml25
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice2.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice3.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice4.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice5.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/gen/my/pkg/R.java.txt23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/gen/my/pkg/R2.java.txt5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/grantpermission.xml30
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/ignoremissing.xml6
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/illegal_version.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/minsdk5targetsdk14.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/minsdk5targetsdk9.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/missingmin.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/missingprefix.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/missingtarget.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/missingusessdk.xml21
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/multiplesdk.xml25
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/LibraryCode.java.txt7
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/MainCode.java.txt7
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/library-manifest.xml31
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/library.properties12
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main-manifest.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main-merge.properties13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main.properties12
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/strings.xml9
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/no_version.xml21
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/oldtarget.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/.classpath8
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/.project33
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/AndroidManifest.xml38
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/gen/test/pkg/BuildConfig.java.txt6
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/gen/test/pkg/R.java.txt34
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/project.properties11
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-hdpi/ic_launcher.pngbin4147 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-ldpi/ic_launcher.pngbin1723 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-mdpi/ic_launcher.pngbin2574 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable/custombg.xml5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable/custombg2.xml5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/fifth.xml13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/fourth.xml13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/main.xml13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/main_ignore.xml15
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/second.xml13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/sixth.xml13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/third.xml13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/values/strings.xml7
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/values/styles.xml25
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/FourthActivity.java.txt13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/OverdrawActivity.java.txt13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/SecondActivity.java.txt13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/ThirdActivity.java.txt14
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.cfg36
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.pro64
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.properties2
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties114
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties214
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties311
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties414
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/protectedpermissions.xml116
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/protectedpermissions2.xml32
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifest.xml29
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestInner.xml25
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestWrong.xml25
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestWrong2.xml25
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Bar.class.databin268 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Bar.java.txt8
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo$Bar.class.databin319 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo$Baz.class.databin388 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo.class.databin347 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo.java.txt10
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/appwidget_bg.9.pngbin2838 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/appwidget_bg_focus.9.pngbin3116 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/filled.pngbin4802 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/ic_launcher.pngbin4147 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/other.9.pngbin2838 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/unrelated.pngbin4147 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/frame.pngbin9020 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/ic_menu_add_clip_normal.pngbin687 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/sample_icon.gifbin1797 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/sample_icon.jpgbin2141 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/stat_notify_alarm.pngbin835 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-nodpi/frame.pngbin9020 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-xlarge-nodpi-v11/frame.pngbin9020 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/ic_launcher.pngbin2574 -> 0 bytes
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/ic_menu_help.xml5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states.xml7
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states2.xml7
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states3.xml49
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/accessibility.xml9
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/accessibility2.xml12
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/activity_item_two_pane.xml37
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights.xml41
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights2.xml40
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights3.xml39
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/breadcrumbs_in_fragment.xml5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/broken.xml8
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar.xml188
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar2.xml52
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar3.xml35
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar4.xml55
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar_suppressed.xml43
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/case.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts.xml19
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts2.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts3.xml19
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts4.xml19
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound.xml17
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound2.xml17
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound3.xml18
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/crcrlf.xml14
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/crcrlf_ignore.xml19
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customattrlayout.xml7
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customview.xml30
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customview2.xml20
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/default_item_badges.xml5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/deprecation.xml29
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/detailed_item.xml12
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/duplicate.xml8
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/edit_textview.xml94
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/edit_type.xml96
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/encoding.xml7
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/encoding2.xml1
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/fragment.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/fragment2.xml53
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/gridlayout.xml41
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/has_children.xml13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/has_children2.xml11
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/ignores.xml65
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight.xml60
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight2.xml22
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/labelfor.xml84
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/labelfor_ignore.xml16
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout1.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout1_ignore.xml26
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout2.xml23
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout3.xml19
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout4.xml19
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/listseparator.xml3
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace.xml7
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace2.xml29
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace3.xml17
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace4.xml18
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/nested_weights.xml40
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/nested_weights2.xml38
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/note_edit.xml78
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/now_playing_after.xml53
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/onclick.xml79
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/private.xml4
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/scrolling.xml19
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simple.xml7
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simple_ignore.xml8
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simpleinclude.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/size.xml27
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/size2.xml43
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/sizeincluded.xml5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/textsize.xml51
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/too_deep.xml85
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/too_many.xml413
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/unused_namespace.xml14
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless.xml89
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless2.xml26
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless3.xml5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong0dp.xml103
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_dimension.xml13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace2.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace3.xml24
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace4.xml27
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace5.xml10
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams.xml88
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams2.xml15
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams3.xml13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams4.xml13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams5.xml18
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams6.xml13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams_ignore.xml92
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions.xml62
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions2.xml62
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions2_ignore.xml64
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu/menu.xml16
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu/titles.xml15
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/private_key.pem18
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/arrays.xml9
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/strings.xml11
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/translatedarrays.xml4
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de-rDE/strings.xml12
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de/strings.xml4
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de/typos.xml14
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es-rUS/strings.xml5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/donottranslate.xml4
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/formatstrings.xml5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/formatstrings_ignore.xml5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings.xml18
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings_ignore.xml20
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings_locale.xml20
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-fr/strings.xml8
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-it/stringarrays.xml12
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/arrays.xml11
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/arrays_ignore.xml11
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/strings.xml21
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nb/typos.xml22
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nb/typos_locale.xml8
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nl-rNL/arrays.xml8
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nl-rNL/strings.xml13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/analytics.xml16
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/arrays.xml18
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/arrayusage.xml6
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/buttonbar-values.xml15
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/customattr.xml6
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings-version1.xml9
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings-version2.xml6
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings.xml7
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings2.xml6
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings3.xml4
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings4.xml10
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings5.xml4
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings_ignore.xml7
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/nontranslatable.xml5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/nontranslatable2.xml5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/plurals.xml8
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/pxsp.xml34
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/sizestyles.xml17
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/stringarrays.xml13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings.xml31
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings2.xml5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings3.xml10
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings4.xml4
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings_ignore.xml15
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/stylecycle.xml5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles.xml15
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles2.xml8
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/themes.xml8
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/themes2.xml10
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/translatedarrays.xml8
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/typography.xml30
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/typos.xml25
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/my/pkg/Test.java.txt10
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/pkg1/Class1.java.txt29
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/pkg2/Class2.java.txt33
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionBarTest.java.txt14
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest1.java.txt9
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest1_ignore.java.txt10
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest2.java.txt9
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/BadImport.java.txt9
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/CustomViewTest.java.txt6
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Foo.java.txt7
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Hidden.java.txt14
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ImportFrameActivity.java.txt13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/InflaterTest.java.txt65
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/JavaPerformanceTest.java.txt195
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/NonInternationalizedSmsDetectorTest.java.txt20
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/NotificationTest.java.txt39
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/PasteError.java.txt109
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SdCardTest.java.txt36
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SetJavaScriptEnabled.java.txt28
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest.java.txt66
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest2.java.txt19
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest3.java.txt15
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest4.java.txt15
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest5.java.txt54
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormat2.java.txt14
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormat3.java.txt20
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity.java.txt35
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity2.java.txt20
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity_ignore.java.txt27
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SuppressTest5.java.txt57
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ToastTest.java.txt41
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/UnusedReference.java.txt12
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Utf8BomTest.java.data5
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WorldWriteableFile.java.txt38
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongAnnotation.java.txt36
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity.java.txt16
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity2.java.txt15
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity3.java.txt11
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongColor.java.txt16
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_not_found.xml28
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_feature.xml28
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_feature2.xml28
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_library.xml28
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_library2.xml28
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_permission.xml28
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_permission2.xml28
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_sdk.xml28
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_sdk2.xml28
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/unusedR.java.txt14
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/ids.xml6
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/ignorelayout1.xml47
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/layout1.xml45
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/layout2.xml13
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/client/api/DefaultSdkInfoTest.java60
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/client/api/LintClientTest.java30
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/client/api/LintDriverTest.java52
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/client/api/ProjectTest.java60
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/detector/api/ClassContextTest.java40
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/detector/api/IssueTest.java222
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/detector/api/LintUtilsTest.java359
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/detector/api/LocationTest.java130
-rw-r--r--lint/cli/src/test/java/com/android/tools/lint/detector/api/ScopeTest.java57
-rw-r--r--lint/libs/Android.mk5
-rw-r--r--lint/libs/lint_api/.classpath13
-rw-r--r--lint/libs/lint_api/.project17
-rw-r--r--lint/libs/lint_api/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--lint/libs/lint_api/.settings/org.moreunit.prefs6
-rw-r--r--lint/libs/lint_api/Android.mk40
-rw-r--r--lint/libs/lint_api/NOTICE190
-rw-r--r--lint/libs/lint_checks/.classpath15
-rw-r--r--lint/libs/lint_checks/.project17
-rw-r--r--lint/libs/lint_checks/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--lint/libs/lint_checks/.settings/org.moreunit.prefs5
-rw-r--r--lint/libs/lint_checks/Android.mk43
-rw-r--r--manifmerger/.classpath10
-rw-r--r--manifmerger/.gitignore3
-rw-r--r--manifmerger/.project17
-rwxr-xr-xmanifmerger/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--manifmerger/Android.mk32
-rw-r--r--monkeyrunner/Android.mk19
-rw-r--r--monkeyrunner/MODULE_LICENSE_APACHE20
-rw-r--r--monkeyrunner/NOTICE190
-rw-r--r--monkeyrunner/etc/Android.mk21
-rw-r--r--monkeyrunner/etc/manifest.txt1
-rwxr-xr-xmonkeyrunner/etc/monkeyrunner99
-rw-r--r--monkeyrunner/etc/monkeyrunner.bat63
-rw-r--r--monkeyrunner/jython/test/MonkeyRunner_test.py54
-rw-r--r--monkeyrunner/jython/test/all_tests.py49
-rw-r--r--monkeyrunner/scripts/help.py48
-rw-r--r--monkeyrunner/scripts/monkey_playback.py70
-rw-r--r--monkeyrunner/scripts/monkey_recorder.py20
-rw-r--r--monkeyrunner/scripts/mr_pydoc.py43
-rw-r--r--monkeyrunner/src/Android.mk52
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/JythonUtils.java504
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/MonkeyDevice.java439
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/MonkeyFormatter.java116
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/MonkeyImage.java162
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/MonkeyRect.java85
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/MonkeyRunner.java242
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/MonkeyRunnerHelp.java274
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/MonkeyRunnerOptions.java186
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/MonkeyRunnerStarter.java194
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/MonkeyView.java167
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/ScriptRunner.java195
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/controller/MonkeyController.java58
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/controller/MonkeyControllerFrame.java164
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/controller/VariableFrame.java173
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/doc/MonkeyRunnerExported.java61
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/easy/By.java76
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/easy/EasyMonkeyDevice.java229
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/easy/README27
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/recorder/ActionListModel.java69
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/recorder/MonkeyRecorder.java80
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/recorder/MonkeyRecorderFrame.java434
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/recorder/actions/Action.java45
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/recorder/actions/DragAction.java83
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/recorder/actions/PressAction.java68
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/recorder/actions/PyDictUtilBuilder.java64
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/recorder/actions/TouchAction.java63
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/recorder/actions/TypeAction.java46
-rw-r--r--monkeyrunner/src/com/android/monkeyrunner/recorder/actions/WaitAction.java43
-rw-r--r--monkeyrunner/src/resources/com/android/monkeyrunner/html.cs27
-rw-r--r--monkeyrunner/src/resources/com/android/monkeyrunner/sdk-docs.cs28
-rw-r--r--monkeyrunner/src/resources/com/android/monkeyrunner/text.cs10
-rw-r--r--monkeyrunner/test/Android.mk23
-rw-r--r--monkeyrunner/test/com/android/monkeyrunner/AllTests.java46
-rw-r--r--monkeyrunner/test/com/android/monkeyrunner/JythonUtilsTest.java257
-rw-r--r--monkeyrunner/test/com/android/monkeyrunner/MonkeyRunnerOptionsTest.java69
-rw-r--r--monkeyrunner/test/resources/com/android/monkeyrunner/adb/instrument_result.txt10
-rw-r--r--monkeyrunner/test/resources/com/android/monkeyrunner/adb/multiline_instrument_result.txt15
-rw-r--r--monkeyrunner/test/resources/com/android/monkeyrunner/image1.pngbin184289 -> 0 bytes
-rw-r--r--monkeyrunner/test/resources/com/android/monkeyrunner/image1.rawbin307545 -> 0 bytes
-rw-r--r--monkeyrunner/test/resources/com/android/monkeyrunner/image2.pngbin82036 -> 0 bytes
-rw-r--r--monkeyrunner/test/resources/com/android/monkeyrunner/image2.rawbin1536345 -> 0 bytes
-rw-r--r--ninepatch/.classpath6
-rw-r--r--ninepatch/.gitignore1
-rw-r--r--ninepatch/.project17
-rw-r--r--ninepatch/Android.mk26
-rw-r--r--ninepatch/NOTICE190
-rw-r--r--ninepatch/src/com/android/ninepatch/GraphicsUtilities.java102
-rw-r--r--ninepatch/src/com/android/ninepatch/NinePatch.java224
-rw-r--r--ninepatch/src/com/android/ninepatch/NinePatchChunk.java494
-rw-r--r--ninepatch/tests/.classpath8
-rw-r--r--ninepatch/tests/.project17
-rw-r--r--ninepatch/tests/Android.mk33
-rw-r--r--ninepatch/tests/res/com/android/ninepatch/button.9.pngbin3750 -> 0 bytes
-rw-r--r--ninepatch/tests/src/com/android/ninepatch/NinePatchTest.java48
-rw-r--r--rule_api/.classpath9
-rw-r--r--rule_api/.gitignore1
-rw-r--r--rule_api/.project17
-rw-r--r--rule_api/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--rule_api/Android.mk30
-rw-r--r--rule_api/NOTICE190
-rw-r--r--rule_api/README.txt10
-rw-r--r--rule_api/src/com/android/ide/common/api/AbstractViewRule.java145
-rw-r--r--rule_api/src/com/android/ide/common/api/DrawingStyle.java177
-rw-r--r--rule_api/src/com/android/ide/common/api/DropFeedback.java185
-rw-r--r--rule_api/src/com/android/ide/common/api/IAttributeInfo.java157
-rw-r--r--rule_api/src/com/android/ide/common/api/IClientRulesEngine.java321
-rwxr-xr-xrule_api/src/com/android/ide/common/api/IColor.java31
-rw-r--r--rule_api/src/com/android/ide/common/api/IDragElement.java122
-rw-r--r--rule_api/src/com/android/ide/common/api/IFeedbackPainter.java39
-rw-r--r--rule_api/src/com/android/ide/common/api/IGraphics.java240
-rw-r--r--rule_api/src/com/android/ide/common/api/IMenuCallback.java65
-rw-r--r--rule_api/src/com/android/ide/common/api/INode.java282
-rw-r--r--rule_api/src/com/android/ide/common/api/INodeHandler.java39
-rw-r--r--rule_api/src/com/android/ide/common/api/IValidator.java44
-rw-r--r--rule_api/src/com/android/ide/common/api/IViewMetadata.java123
-rw-r--r--rule_api/src/com/android/ide/common/api/IViewRule.java401
-rw-r--r--rule_api/src/com/android/ide/common/api/InsertType.java62
-rw-r--r--rule_api/src/com/android/ide/common/api/MarginType.java57
-rw-r--r--rule_api/src/com/android/ide/common/api/Margins.java66
-rw-r--r--rule_api/src/com/android/ide/common/api/Point.java86
-rw-r--r--rule_api/src/com/android/ide/common/api/Rect.java253
-rw-r--r--rule_api/src/com/android/ide/common/api/ResizePolicy.java184
-rw-r--r--rule_api/src/com/android/ide/common/api/RuleAction.java739
-rw-r--r--rule_api/src/com/android/ide/common/api/Segment.java83
-rw-r--r--rule_api/src/com/android/ide/common/api/SegmentType.java117
-rw-r--r--screenshot/.classpath7
-rw-r--r--screenshot/.gitignore1
-rw-r--r--screenshot/.project17
-rw-r--r--screenshot/Android.mk18
-rw-r--r--screenshot/NOTICE190
-rw-r--r--screenshot/etc/Android.mk21
-rw-r--r--screenshot/etc/manifest.txt1
-rwxr-xr-xscreenshot/etc/screenshot274
-rw-r--r--screenshot/src/Android.mk27
-rw-r--r--screenshot/src/com/android/screenshot/Screenshot.java269
-rw-r--r--sdk_common/.classpath11
-rw-r--r--sdk_common/.gitignore2
-rw-r--r--sdk_common/.project17
-rw-r--r--sdk_common/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--sdk_common/.settings/org.moreunit.prefs4
-rw-r--r--sdk_common/Android.mk39
-rw-r--r--sdk_common/NOTICE190
-rw-r--r--sdkmanager/.gitignore7
-rw-r--r--sdkmanager/Android.mk19
-rw-r--r--sdkmanager/MODULE_LICENSE_APACHE20
-rw-r--r--sdkmanager/app/.classpath16
-rw-r--r--sdkmanager/app/.project19
-rw-r--r--sdkmanager/app/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--sdkmanager/app/Android.mk72
-rw-r--r--sdkmanager/app/NOTICE190
-rw-r--r--sdkmanager/app/etc/Android.mk9
-rwxr-xr-xsdkmanager/app/etc/android114
-rwxr-xr-xsdkmanager/app/etc/android.bat84
-rw-r--r--sdkmanager/app/etc/manifest.txt2
-rw-r--r--sdkmanager/app/src/main/java/com/android/sdkmanager/Main.java1617
-rw-r--r--sdkmanager/app/src/main/java/com/android/sdkmanager/SdkCommandLine.java599
-rwxr-xr-xsdkmanager/app/src/test/java/com/android/sdklib/SdkManagerTestCase.java272
-rw-r--r--sdkmanager/app/src/test/java/com/android/sdklib/mock/MockLog.java84
-rw-r--r--sdkmanager/app/src/test/java/com/android/sdkmanager/AvdManagerTest.java101
-rw-r--r--sdkmanager/app/src/test/java/com/android/sdkmanager/MainTest.java357
-rw-r--r--sdkmanager/app/src/test/java/com/android/sdkmanager/SdkCommandLineTest.java189
-rw-r--r--sdkmanager/libs/Android.mk18
-rw-r--r--sdkmanager/libs/sdklib/.classpath18
-rw-r--r--sdkmanager/libs/sdklib/.project17
-rwxr-xr-xsdkmanager/libs/sdklib/.settings/org.eclipse.core.resources.prefs4
-rw-r--r--sdkmanager/libs/sdklib/.settings/org.eclipse.jdt.core.prefs98
-rwxr-xr-xsdkmanager/libs/sdklib/.settings/org.eclipse.jdt.ui.prefs55
-rw-r--r--sdkmanager/libs/sdklib/Android.mk45
-rw-r--r--sdkmanager/libs/sdklib/NOTICE190
-rw-r--r--sdkmanager/libs/sdklib/manifest.txt1
-rw-r--r--sdkmanager/libs/sdkuilib/.classpath21
-rw-r--r--sdkmanager/libs/sdkuilib/.project17
-rw-r--r--sdkmanager/libs/sdkuilib/.settings/org.eclipse.jdt.core.prefs98
-rwxr-xr-xsdkmanager/libs/sdkuilib/.settings/org.eclipse.jdt.ui.prefs55
-rw-r--r--sdkmanager/libs/sdkuilib/Android.mk48
-rw-r--r--sdkmanager/libs/sdkuilib/NOTICE190
-rw-r--r--sdkmanager/libs/sdkuilib/README45
-rw-r--r--sdkmanager/libs/sdkuilib/etc/manifest.txt1
-rw-r--r--sdkstats/.classpath13
-rw-r--r--sdkstats/.gitignore2
-rw-r--r--sdkstats/.project17
-rw-r--r--sdkstats/.settings/README.txt2
-rw-r--r--sdkstats/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--sdkstats/Android.mk4
-rw-r--r--sdkstats/NOTICE190
-rw-r--r--sdkstats/README11
-rw-r--r--sdkstats/src/Android.mk15
-rwxr-xr-xsdkstats/src/com/android/sdkstats/DdmsPreferenceStore.java332
-rw-r--r--sdkstats/src/com/android/sdkstats/SdkStatsPermissionDialog.java196
-rw-r--r--sdkstats/src/com/android/sdkstats/SdkStatsService.java558
-rwxr-xr-xsdkstats/tests/com/android/sdkstats/SdkStatsServiceTest.java544
-rw-r--r--swtmenubar/.classpath10
-rw-r--r--swtmenubar/.gitignore1
-rw-r--r--swtmenubar/.project17
-rw-r--r--swtmenubar/Android.mk32
-rw-r--r--swtmenubar/MODULE_LICENSE_EPL0
-rw-r--r--swtmenubar/NOTICE224
-rwxr-xr-xswtmenubar/README80
-rw-r--r--testutils/.classpath9
-rw-r--r--testutils/.gitignore2
-rw-r--r--testutils/.project17
-rw-r--r--testutils/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--testutils/Android.mk49
-rw-r--r--testutils/NOTICE189
-rw-r--r--testutils/manifest.txt1
-rw-r--r--testutils/src/main/java/com/android/testutils/SdkTestCase.java436
-rw-r--r--testutils/src/test/.classpath9
-rw-r--r--testutils/src/test/.project17
-rw-r--r--testutils/src/test/java/com/android/testutils/SdkTestCaseTest.java161
-rw-r--r--traceview/.classpath13
-rw-r--r--traceview/.gitignore1
-rw-r--r--traceview/.project17
-rw-r--r--traceview/.settings/README.txt2
-rw-r--r--traceview/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--traceview/Android.mk5
-rw-r--r--traceview/NOTICE190
-rw-r--r--traceview/README11
-rw-r--r--traceview/etc/Android.mk9
-rw-r--r--traceview/etc/manifest.txt2
-rwxr-xr-xtraceview/etc/traceview108
-rwxr-xr-xtraceview/etc/traceview.bat65
-rw-r--r--traceview/src/Android.mk20
-rw-r--r--traceview/src/com/android/traceview/Call.java177
-rw-r--r--traceview/src/com/android/traceview/ColorController.java113
-rw-r--r--traceview/src/com/android/traceview/DmTraceReader.java754
-rw-r--r--traceview/src/com/android/traceview/MainWindow.java300
-rw-r--r--traceview/src/com/android/traceview/MethodData.java513
-rw-r--r--traceview/src/com/android/traceview/ProfileData.java88
-rw-r--r--traceview/src/com/android/traceview/ProfileNode.java51
-rw-r--r--traceview/src/com/android/traceview/ProfileProvider.java467
-rw-r--r--traceview/src/com/android/traceview/ProfileSelf.java39
-rw-r--r--traceview/src/com/android/traceview/ProfileView.java332
-rw-r--r--traceview/src/com/android/traceview/PropertiesDialog.java104
-rw-r--r--traceview/src/com/android/traceview/Selection.java70
-rw-r--r--traceview/src/com/android/traceview/SelectionController.java35
-rw-r--r--traceview/src/com/android/traceview/ThreadData.java170
-rw-r--r--traceview/src/com/android/traceview/TickScaler.java148
-rw-r--r--traceview/src/com/android/traceview/TimeBase.java71
-rw-r--r--traceview/src/com/android/traceview/TimeLineView.java2154
-rw-r--r--traceview/src/com/android/traceview/TraceAction.java31
-rw-r--r--traceview/src/com/android/traceview/TraceReader.java79
-rw-r--r--traceview/src/com/android/traceview/TraceUnits.java93
-rw-r--r--traceview/src/resources/icons/sort_down.pngbin102 -> 0 bytes
-rw-r--r--traceview/src/resources/icons/sort_up.pngbin105 -> 0 bytes
-rw-r--r--traceview/src/resources/icons/traceview-128.pngbin17131 -> 0 bytes
-rw-r--r--uiautomatorviewer/.classpath12
-rw-r--r--uiautomatorviewer/.gitignore1
-rw-r--r--uiautomatorviewer/.project17
-rw-r--r--uiautomatorviewer/.settings/org.eclipse.jdt.core.prefs98
-rw-r--r--uiautomatorviewer/Android.mk38
-rw-r--r--uiautomatorviewer/MODULE_LICENSE_APACHE20
-rw-r--r--uiautomatorviewer/etc/Android.mk21
-rw-r--r--uiautomatorviewer/etc/manifest.txt2
-rwxr-xr-xuiautomatorviewer/etc/uiautomatorviewer104
-rwxr-xr-xuiautomatorviewer/etc/uiautomatorviewer.bat66
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/DebugBridge.java76
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/OpenDialog.java225
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/UiAutomatorHelper.java196
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/UiAutomatorModel.java143
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/UiAutomatorView.java436
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/UiAutomatorViewer.java108
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/actions/ExpandAllAction.java42
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/actions/ImageHelper.java48
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/actions/OpenFilesAction.java83
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/actions/ScreenshotAction.java176
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/actions/ToggleNafAction.java46
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/tree/AttributePair.java26
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/tree/BasicTreeNode.java114
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/tree/BasicTreeNodeContentProvider.java63
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/tree/RootWindowNode.java52
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/tree/UiHierarchyXmlLoader.java149
-rw-r--r--uiautomatorviewer/src/com/android/uiautomator/tree/UiNode.java123
-rw-r--r--uiautomatorviewer/src/images/expandall.pngbin268 -> 0 bytes
-rw-r--r--uiautomatorviewer/src/images/open-folder.pngbin383 -> 0 bytes
-rw-r--r--uiautomatorviewer/src/images/screenshot.pngbin1226 -> 0 bytes
-rw-r--r--uiautomatorviewer/src/images/warning.pngbin147 -> 0 bytes
1362 files changed, 0 insertions, 120758 deletions
diff --git a/ant-glob-tests/.classpath b/ant-glob-tests/.classpath
deleted file mode 100644
index 0a4978e..0000000
--- a/ant-glob-tests/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ant-glob"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/ant-glob-tests/.gitignore b/ant-glob-tests/.gitignore
deleted file mode 100644
index 3826f65..0000000
--- a/ant-glob-tests/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-bin
-*~
-*.bak
-Thumbs.db
-*.class
-*.DS_Store
diff --git a/ant-glob-tests/.project b/ant-glob-tests/.project
deleted file mode 100644
index 4686cc9..0000000
--- a/ant-glob-tests/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>ant-glob-tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/ant-glob-tests/src/org/apache/tools/ant/types/selectors/SelectorUtilsTest.java b/ant-glob-tests/src/org/apache/tools/ant/types/selectors/SelectorUtilsTest.java
deleted file mode 100644
index 943ebd5..0000000
--- a/ant-glob-tests/src/org/apache/tools/ant/types/selectors/SelectorUtilsTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.tools.ant.types.selectors;
-
-import junit.framework.TestCase;
-
-
-public class SelectorUtilsTest extends TestCase {
-
- public void test1() {
- assertTrue(SelectorUtils.matchPath("**", "a"));
-
- assertTrue(SelectorUtils.matchPath("a/**/b", "a/c/d/b"));
- assertTrue(SelectorUtils.matchPath("a/**/b", "a/b"));
- assertFalse(SelectorUtils.matchPath("a/**/b", "a/b/c"));
-
- assertTrue(SelectorUtils.matchPath("a/**", "a"));
- assertTrue(SelectorUtils.matchPath("a/**", "a/b"));
-
- assertTrue(SelectorUtils.matchPath("bin/**/*.class", "bin/a/foo.class"));
- assertFalse(SelectorUtils.matchPath("bin/**/*.class", "bin/a/fooclass"));
- }
-}
diff --git a/anttargetprint/.classpath b/anttargetprint/.classpath
deleted file mode 100644
index fa310aa..0000000
--- a/anttargetprint/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/misc/common/kxml2/kxml2-2.3.0.jar" sourcepath="/ANDROID_SRC/dalvik/libcore/xml/src/main/java"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/anttargetprint/.project b/anttargetprint/.project
deleted file mode 100644
index 10b95ef..0000000
--- a/anttargetprint/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>anttargetprint</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/anttargetprint/.settings/org.eclipse.jdt.core.prefs b/anttargetprint/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/anttargetprint/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/anttargetprint/src/com/android/anttargetprint/BuildXmlHandler.java b/anttargetprint/src/com/android/anttargetprint/BuildXmlHandler.java
deleted file mode 100644
index e9bc4f3..0000000
--- a/anttargetprint/src/com/android/anttargetprint/BuildXmlHandler.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.anttargetprint;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-public class BuildXmlHandler extends DefaultHandler {
-
- private Map<String, String> mTargets = new HashMap<String, String>();
- private int mLevel = 0;
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes attributes)
- throws SAXException {
-
- mLevel++;
-
- if (mLevel == 2 && "target".equals(qName)) {
- String name = attributes.getValue("name");
- String depends = attributes.getValue("depends");
-
- if (name != null) {
- if (depends == null) {
- depends = "";
- }
-
- mTargets.put(name, depends);
- }
- }
-
- super.startElement(uri, localName, qName, attributes);
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- mLevel--;
- super.endElement(uri, localName, qName);
- }
-
- Map<String, List<String>> processTargets() {
- HashMap<String, List<String>> result = new HashMap<String, List<String>>();
-
- for (Entry<String, String> entry : mTargets.entrySet()) {
- process(entry.getKey(), entry.getValue(), result);
- }
-
- return result;
- }
-
- private List<String> process(String targetName, String targetDepends,
- Map<String, List<String>> resultMap) {
-
- // first check if this was already processed.
- List<String> resultList = resultMap.get(targetName);
- if (resultList != null) {
- return resultList;
- }
-
- resultList = new ArrayList<String>();
-
- if (targetDepends.length() > 0) {
- String[] dependencies = targetDepends.split(",");
-
- for (String dependency : dependencies) {
- String dependencyTrim = dependency.trim();
- // get all the dependencies for this targets.
- List<String> dependencyList = resultMap.get(dependencyTrim);
- if (dependencyList == null) {
- dependencyList = process(dependencyTrim, mTargets.get(dependencyTrim),
- resultMap);
- }
-
- // add those to the new result list
- resultList.addAll(dependencyList);
-
- // and add this dependency as well
- resultList.add(dependencyTrim);
- }
- }
-
- resultMap.put(targetName, resultList);
-
- return resultList;
- }
-
-}
diff --git a/anttargetprint/src/com/android/anttargetprint/Main.java b/anttargetprint/src/com/android/anttargetprint/Main.java
deleted file mode 100644
index e270d97..0000000
--- a/anttargetprint/src/com/android/anttargetprint/Main.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.anttargetprint;
-
-import java.io.File;
-import java.util.List;
-import java.util.Map.Entry;
-
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-
-public class Main {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
-
- if (args.length != 1) {
- System.err.println("USAGE: <prog> [FILE]");
- System.exit(1);
- }
-
- try {
- SAXParser parser = SAXParserFactory.newInstance().newSAXParser();
- BuildXmlHandler handler = new BuildXmlHandler();
- parser.parse(new File(args[0]), handler);
-
- for (Entry<String, List<String>> entry : handler.processTargets().entrySet()) {
- String name = entry.getKey();
- if (name.charAt(0) != '-') {
- System.out.print(entry.getKey());
- System.out.print(" : ");
- for (String v : entry.getValue()) {
- System.out.print(v);
- System.out.print(" > ");
- }
- System.out.println();
- }
- }
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-}
diff --git a/anttasks/.classpath b/anttasks/.classpath
deleted file mode 100644
index f214a3b..0000000
--- a/anttasks/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/sdklib"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/ant/ant.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="ANDROID_SRC/prebuilts/tools/common/guava-tools/src.zip"/>
- <classpathentry combineaccessrules="false" kind="src" path="/manifest-merger"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/anttasks/.gitignore b/anttasks/.gitignore
deleted file mode 100644
index fe99505..0000000
--- a/anttasks/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-bin
-
diff --git a/anttasks/.project b/anttasks/.project
deleted file mode 100644
index aed1b61..0000000
--- a/anttasks/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>ant-tasks</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/anttasks/.settings/README.txt b/anttasks/.settings/README.txt
deleted file mode 100644
index 9120b20..0000000
--- a/anttasks/.settings/README.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Copy this in eclipse project as a .settings folder at the root.
-This ensure proper compilation compliance and warning/error levels. \ No newline at end of file
diff --git a/anttasks/.settings/org.eclipse.jdt.core.prefs b/anttasks/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/anttasks/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/anttasks/Android.mk b/anttasks/Android.mk
deleted file mode 100644
index ae0c3a9..0000000
--- a/anttasks/Android.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_RESOURCE_DIRS := src
-
-LOCAL_JAR_MANIFEST := etc/manifest.txt
-
-LOCAL_JAVA_LIBRARIES := \
- common \
- sdklib \
- manifmerger \
- ant \
- guava-tools
-
-LOCAL_MODULE := anttasks
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
diff --git a/anttasks/NOTICE b/anttasks/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/anttasks/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/anttasks/etc/manifest.txt b/anttasks/etc/manifest.txt
deleted file mode 100644
index e5449c8..0000000
--- a/anttasks/etc/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Class-Path: common.jar guava-tools.jar sdklib.jar manifmerger.jar
diff --git a/anttasks/src/anttasks.properties b/anttasks/src/anttasks.properties
deleted file mode 100644
index 458f355..0000000
--- a/anttasks/src/anttasks.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-checkenv: com.android.ant.CheckEnvTask
-gettype: com.android.ant.GetTypeTask
-gettarget: com.android.ant.GetTargetTask
-getuitarget: com.android.ant.GetUiTargetTask
-getprojectpaths: com.android.ant.GetProjectPathsTask
-getlibpath: com.android.ant.GetLibraryPathTask
-dependency: com.android.ant.ComputeDependencyTask
-testedprojectclasspath: com.android.ant.ComputeProjectClasspathTask
-getemmafilter: com.android.ant.GetEmmaFilterTask
-mergemanifest: com.android.ant.ManifestMergerTask
-aapt: com.android.ant.AaptExecTask
-aidl: com.android.ant.AidlExecTask
-renderscript: com.android.ant.RenderScriptTask
-buildconfig: com.android.ant.BuildConfigTask
-dex: com.android.ant.DexExecTask
-apkbuilder: com.android.ant.ApkBuilderTask
-signapk: com.android.ant.SignApkTask
-zipalign: com.android.ant.ZipAlignTask
-xpath: com.android.ant.XPathTask
-if: com.android.ant.IfElseTask
-propertybyreplace: com.android.ant.PropertyByReplaceTask
-lint: com.android.ant.LintExecTask
diff --git a/anttasks/src/com/android/ant/AaptExecTask.java b/anttasks/src/com/android/ant/AaptExecTask.java
deleted file mode 100644
index a1d44c4..0000000
--- a/anttasks/src/com/android/ant/AaptExecTask.java
+++ /dev/null
@@ -1,793 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.SdkConstants;
-import com.android.sdklib.internal.build.SymbolLoader;
-import com.android.sdklib.internal.build.SymbolWriter;
-import com.android.xml.AndroidXPathFactory;
-import com.google.common.collect.ArrayListMultimap;
-import com.google.common.collect.Multimap;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.ExecTask;
-import org.apache.tools.ant.types.Path;
-import org.xml.sax.InputSource;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathExpressionException;
-
-/**
- * Task to execute aapt.
- *
- * <p>It does not follow the exec task format, instead it has its own parameters, which maps
- * directly to aapt.</p>
- * <p>It is able to run aapt several times if library setup requires generating several
- * R.java files.
- * <p>The following map shows how to use the task for each supported aapt command line
- * parameter.</p>
- *
- * <table border="1">
- * <tr><td><b>Aapt Option</b></td><td><b>Ant Name</b></td><td><b>Type</b></td></tr>
- * <tr><td>path to aapt</td><td>executable</td><td>attribute (Path)</td>
- * <tr><td>command</td><td>command</td><td>attribute (String)</td>
- * <tr><td>-v</td><td>verbose</td><td>attribute (boolean)</td></tr>
- * <tr><td>-f</td><td>force</td><td>attribute (boolean)</td></tr>
- * <tr><td>-M AndroidManifest.xml</td><td>manifest</td><td>attribute (Path)</td></tr>
- * <tr><td>-I base-package</td><td>androidjar</td><td>attribute (Path)</td></tr>
- * <tr><td>-A asset-source-dir</td><td>assets</td><td>attribute (Path</td></tr>
- * <tr><td>-S resource-sources</td><td>&lt;res path=""&gt;</td><td>nested element(s)<br>with attribute (Path)</td></tr>
- * <tr><td>-0 extension</td><td>&lt;nocompress extension=""&gt;<br>&lt;nocompress&gt;</td><td>nested element(s)<br>with attribute (String)</td></tr>
- * <tr><td>-F apk-file</td><td>apkfolder<br>outfolder<br>apkbasename<br>basename</td><td>attribute (Path)<br>attribute (Path) deprecated<br>attribute (String)<br>attribute (String) deprecated</td></tr>
- * <tr><td>-J R-file-dir</td><td>rfolder</td><td>attribute (Path)<br>-m always enabled</td></tr>
- * <tr><td>--rename-manifest-package package-name</td><td>manifestpackage</td><td>attribute (String)</td></tr>
- * <tr><td></td><td></td><td></td></tr>
- * </table>
- */
-public final class AaptExecTask extends SingleDependencyTask {
-
- /**
- * Class representing a &lt;nocompress&gt; node in the main task XML.
- * This let the developers prevent compression of some files in assets/ and res/raw/
- * by extension.
- * If the extension is null, this will disable compression for all files in assets/ and
- * res/raw/
- */
- public final static class NoCompress {
- String mExtension;
-
- /**
- * Sets the value of the "extension" attribute.
- * @param extention the extension.
- */
- public void setExtension(String extention) {
- mExtension = extention;
- }
- }
-
- private String mExecutable;
- private String mCommand;
- private boolean mForce = true; // true due to legacy reasons
- private boolean mDebug = false;
- private boolean mVerbose = false;
- private boolean mUseCrunchCache = false;
- private int mVersionCode = 0;
- private String mVersionName;
- private String mManifestFile;
- private String mManifestPackage;
- private String mOriginalManifestPackage;
- private ArrayList<Path> mResources;
- private String mAssets;
- private String mAndroidJar;
- private String mApkFolder;
- private String mApkName;
- private String mResourceFilter;
- private String mRFolder;
- private final ArrayList<NoCompress> mNoCompressList = new ArrayList<NoCompress>();
- private String mLibraryResFolderPathRefid;
- private String mLibraryPackagesRefid;
- private String mLibraryRFileRefid;
- private boolean mNonConstantId;
- private String mIgnoreAssets;
- private String mBinFolder;
- private String mProguardFile;
-
- /**
- * Input path that ignores the same folders/files that aapt does.
- */
- private static class ResFolderInputPath extends InputPath {
- public ResFolderInputPath(File file, Set<String> extensionsToCheck) {
- super(file, extensionsToCheck);
- }
-
- @Override
- public boolean ignores(File file) {
- String name = file.getName();
- char firstChar = name.charAt(0);
-
- if (firstChar == '.' || (firstChar == '_' && file.isDirectory()) ||
- name.charAt(name.length()-1) == '~') {
- return true;
- }
-
- if ("CVS".equals(name) ||
- "thumbs.db".equalsIgnoreCase(name) ||
- "picasa.ini".equalsIgnoreCase(name)) {
- return true;
- }
-
- String ext = getExtension(name);
- if ("scc".equalsIgnoreCase(ext)) {
- return true;
- }
-
- return false;
- }
- }
-
- private final static InputPathFactory sPathFactory = new InputPathFactory() {
-
- @Override
- public InputPath createPath(File file, Set<String> extensionsToCheck) {
- return new ResFolderInputPath(file, extensionsToCheck);
- }
- };
-
- /**
- * Sets the value of the "executable" attribute.
- * @param executable the value.
- */
- public void setExecutable(Path executable) {
- mExecutable = TaskHelper.checkSinglePath("executable", executable);
- }
-
- /**
- * Sets the value of the "command" attribute.
- * @param command the value.
- */
- public void setCommand(String command) {
- mCommand = command;
- }
-
- /**
- * Sets the value of the "force" attribute.
- * @param force the value.
- */
- public void setForce(boolean force) {
- mForce = force;
- }
-
- /**
- * Sets the value of the "verbose" attribute.
- * @param verbose the value.
- */
- public void setVerbose(boolean verbose) {
- mVerbose = verbose;
- }
-
- /**
- * Sets the value of the "usecrunchcache" attribute
- * @param usecrunch whether to use the crunch cache.
- */
- public void setNoCrunch(boolean nocrunch) {
- mUseCrunchCache = nocrunch;
- }
-
- public void setNonConstantId(boolean nonConstantId) {
- mNonConstantId = nonConstantId;
- }
-
- public void setIgnoreAssets(String ignoreAssets) {
- mIgnoreAssets = ignoreAssets;
- }
-
- public void setVersioncode(String versionCode) {
- if (versionCode.length() > 0) {
- try {
- mVersionCode = Integer.decode(versionCode);
- } catch (NumberFormatException e) {
- System.out.println(String.format(
- "WARNING: Ignoring invalid version code value '%s'.", versionCode));
- }
- }
- }
-
- /**
- * Sets the value of the "versionName" attribute
- * @param versionName the value
- */
- public void setVersionname(String versionName) {
- mVersionName = versionName;
- }
-
- public void setDebug(boolean value) {
- mDebug = value;
- }
-
- /**
- * Sets the value of the "manifest" attribute.
- * @param manifest the value.
- */
- public void setManifest(Path manifest) {
- mManifestFile = TaskHelper.checkSinglePath("manifest", manifest);
- }
-
- /**
- * Sets a custom manifest package ID to be used during packaging.<p>
- * The manifest will be rewritten so that its package ID becomes the value given here.
- * Relative class names in the manifest (e.g. ".Foo") will be rewritten to absolute names based
- * on the existing package name, meaning that no code changes need to be made.
- *
- * @param packageName The package ID the APK should have.
- */
- public void setManifestpackage(String packageName) {
- if (packageName != null && packageName.length() != 0) {
- mManifestPackage = packageName;
- }
- }
-
- /**
- * Sets the original package name found in the manifest. This is the package name where
- * the R class is created.
- *
- * This is merely a shortcut in case the package is known when calling the aapt task. If not
- * provided (and needed) this task will recompute it.
- * @param packageName the package name declared in the manifest.
- */
- public void setOriginalManifestPackage(String packageName) {
- mOriginalManifestPackage = packageName;
- }
-
- /**
- * Sets the value of the "resources" attribute.
- * @param resources the value.
- *
- * @deprecated Use nested element(s) <res path="value" />
- */
- @Deprecated
- public void setResources(Path resources) {
- System.out.println("WARNNG: Using deprecated 'resources' attribute in AaptExecLoopTask." +
- "Use nested element(s) <res path=\"value\" /> instead.");
- if (mResources == null) {
- mResources = new ArrayList<Path>();
- }
-
- mResources.add(new Path(getProject(), resources.toString()));
- }
-
- /**
- * Sets the value of the "assets" attribute.
- * @param assets the value.
- */
- public void setAssets(Path assets) {
- mAssets = TaskHelper.checkSinglePath("assets", assets);
- }
-
- /**
- * Sets the value of the "androidjar" attribute.
- * @param androidJar the value.
- */
- public void setAndroidjar(Path androidJar) {
- mAndroidJar = TaskHelper.checkSinglePath("androidjar", androidJar);
- }
-
- /**
- * Sets the value of the "outfolder" attribute.
- * @param outFolder the value.
- * @deprecated use {@link #setApkfolder(Path)}
- */
- @Deprecated
- public void setOutfolder(Path outFolder) {
- System.out.println("WARNNG: Using deprecated 'outfolder' attribute in AaptExecLoopTask." +
- "Use 'apkfolder' (path) instead.");
- mApkFolder = TaskHelper.checkSinglePath("outfolder", outFolder);
- }
-
- /**
- * Sets the value of the "apkfolder" attribute.
- * @param apkFolder the value.
- */
- public void setApkfolder(Path apkFolder) {
- mApkFolder = TaskHelper.checkSinglePath("apkfolder", apkFolder);
- }
-
- /**
- * Sets the value of the resourcefilename attribute
- * @param apkName the value
- */
- public void setResourcefilename(String apkName) {
- mApkName = apkName;
- }
-
- /**
- * Sets the value of the "rfolder" attribute.
- * @param rFolder the value.
- */
- public void setRfolder(Path rFolder) {
- mRFolder = TaskHelper.checkSinglePath("rfolder", rFolder);
- }
-
- public void setresourcefilter(String filter) {
- if (filter != null && filter.length() > 0) {
- mResourceFilter = filter;
- }
- }
-
- /**
- * Set the property name of the property that contains the list of res folder for
- * Library Projects. This sets the name and not the value itself to handle the case where
- * it doesn't exist.
- * @param projectLibrariesResName
- */
- public void setLibraryResFolderPathRefid(String libraryResFolderPathRefid) {
- mLibraryResFolderPathRefid = libraryResFolderPathRefid;
- }
-
- public void setLibraryPackagesRefid(String libraryPackagesRefid) {
- mLibraryPackagesRefid = libraryPackagesRefid;
- }
-
- public void setLibraryRFileRefid(String libraryRFileRefid) {
- mLibraryRFileRefid = libraryRFileRefid;
- }
-
- public void setBinFolder(Path binFolder) {
- mBinFolder = TaskHelper.checkSinglePath("binFolder", binFolder);
- }
-
- public void setProguardFile(Path proguardFile) {
- mProguardFile = TaskHelper.checkSinglePath("proguardFile", proguardFile);
- }
-
- /**
- * Returns an object representing a nested <var>nocompress</var> element.
- */
- public Object createNocompress() {
- NoCompress nc = new NoCompress();
- mNoCompressList.add(nc);
- return nc;
- }
-
- /**
- * Returns an object representing a nested <var>res</var> element.
- */
- public Object createRes() {
- if (mResources == null) {
- mResources = new ArrayList<Path>();
- }
-
- Path path = new Path(getProject());
- mResources.add(path);
-
- return path;
- }
-
- @Override
- protected String getExecTaskName() {
- return "aapt";
- }
-
- /*
- * (non-Javadoc)
- *
- * Executes the loop. Based on the values inside project.properties, this will
- * create alternate temporary ap_ files.
- *
- * @see org.apache.tools.ant.Task#execute()
- */
- @SuppressWarnings("deprecation")
- @Override
- public void execute() throws BuildException {
- if (mLibraryResFolderPathRefid == null) {
- throw new BuildException("Missing attribute libraryResFolderPathRefid");
- }
- if (mLibraryPackagesRefid == null) {
- throw new BuildException("Missing attribute libraryPackagesRefid");
- }
- if (mLibraryRFileRefid == null) {
- throw new BuildException("Missing attribute libraryRFileRefid");
- }
-
- Project taskProject = getProject();
-
- String libPkgProp = null;
- Path libRFileProp = null;
-
- // if the parameters indicate generation of the R class, check if
- // more R classes need to be created for libraries, only if this project itself
- // is not a library
- if (mNonConstantId == false && mRFolder != null && new File(mRFolder).isDirectory()) {
- libPkgProp = taskProject.getProperty(mLibraryPackagesRefid);
- Object rFilePath = taskProject.getReference(mLibraryRFileRefid);
-
- // if one is null, both should be
- if ((libPkgProp == null || rFilePath == null) &&
- rFilePath != libPkgProp) {
- throw new BuildException(String.format(
- "Both %1$s and %2$s should resolve to valid values.",
- mLibraryPackagesRefid, mLibraryRFileRefid));
- }
-
- if (rFilePath instanceof Path) {
- libRFileProp = (Path) rFilePath;
- } else if (rFilePath != null) {
- throw new BuildException("attribute libraryRFileRefid must reference a Path object.");
- }
- }
-
- final boolean generateRClass = mRFolder != null && new File(mRFolder).isDirectory();
-
- // Get whether we have libraries
- Object libResRef = taskProject.getReference(mLibraryResFolderPathRefid);
-
- // Set up our input paths that matter for dependency checks
- ArrayList<File> paths = new ArrayList<File>();
-
- // the project res folder is an input path of course
- for (Path pathList : mResources) {
- for (String path : pathList.list()) {
- paths.add(new File(path));
- }
- }
-
- // and if libraries exist, their res folders folders too.
- if (libResRef instanceof Path) {
- for (String path : ((Path)libResRef).list()) {
- paths.add(new File(path));
- }
- }
-
- // Now we figure out what we need to do
- if (generateRClass) {
- // in this case we only want to run aapt if an XML file was touched, or if any
- // file is added/removed
- List<InputPath> inputPaths = getInputPaths(paths, Collections.singleton("xml"),
- sPathFactory);
-
- // let's not forget the manifest as an input path (with no extension restrictions).
- if (mManifestFile != null) {
- inputPaths.add(new InputPath(new File(mManifestFile)));
- }
-
- // Check to see if our dependencies have changed. If not, then skip
- if (initDependencies(mRFolder + File.separator + "R.java.d", inputPaths)
- && dependenciesHaveChanged() == false) {
- System.out.println("No changed resources. R.java and Manifest.java untouched.");
- return;
- } else {
- System.out.println("Generating resource IDs...");
- }
- } else {
- // in this case we want to run aapt if any file was updated/removed/added in any of the
- // input paths
- List<InputPath> inputPaths = getInputPaths(paths, null /*extensionsToCheck*/,
- sPathFactory);
-
- // let's not forget the manifest as an input path.
- if (mManifestFile != null) {
- inputPaths.add(new InputPath(new File(mManifestFile)));
- }
-
- // If we're here to generate a .ap_ file we need to use assets as an input path as well.
- if (mAssets != null) {
- File assetsDir = new File(mAssets);
- if (assetsDir.isDirectory()) {
- inputPaths.add(new InputPath(assetsDir));
- }
- }
-
- // Find our dependency file. It should have the same name as our target .ap_ but
- // with a .d extension
- String dependencyFilePath = mApkFolder + File.separator + mApkName;
- dependencyFilePath += ".d";
-
- // Check to see if our dependencies have changed
- if (initDependencies(dependencyFilePath, inputPaths)
- && dependenciesHaveChanged() == false) {
- System.out.println("No changed resources or assets. " + mApkName
- + " remains untouched");
- return;
- }
- if (mResourceFilter == null) {
- System.out.println("Creating full resource package...");
- } else {
- System.out.println(String.format(
- "Creating resource package with filter: (%1$s)...",
- mResourceFilter));
- }
- }
-
- // create a task for the default apk.
- ExecTask task = new ExecTask();
- task.setExecutable(mExecutable);
- task.setFailonerror(true);
-
- task.setTaskName(getExecTaskName());
-
- // aapt command. Only "package" is supported at this time really.
- task.createArg().setValue(mCommand);
-
- // No crunch flag
- if (mUseCrunchCache) {
- task.createArg().setValue("--no-crunch");
- }
-
- if (mNonConstantId) {
- task.createArg().setValue("--non-constant-id");
- }
-
- // force flag
- if (mForce) {
- task.createArg().setValue("-f");
- }
-
- // verbose flag
- if (mVerbose) {
- task.createArg().setValue("-v");
- }
-
- if (mDebug) {
- task.createArg().setValue("--debug-mode");
- }
-
- if (generateRClass) {
- task.createArg().setValue("-m");
- }
-
- // filters if needed
- if (mResourceFilter != null && mResourceFilter.length() > 0) {
- task.createArg().setValue("-c");
- task.createArg().setValue(mResourceFilter);
- }
-
- // no compress flag
- // first look to see if there's a NoCompress object with no specified extension
- boolean compressNothing = false;
- for (NoCompress nc : mNoCompressList) {
- if (nc.mExtension == null) {
- task.createArg().setValue("-0");
- task.createArg().setValue("");
- compressNothing = true;
- break;
- }
- }
-
- if (compressNothing == false) {
- for (NoCompress nc : mNoCompressList) {
- task.createArg().setValue("-0");
- task.createArg().setValue(nc.mExtension);
- }
- }
-
- // if this is a library or there are library dependencies
- if (mNonConstantId || (libPkgProp != null && libPkgProp.length() > 0)) {
- if (mBinFolder == null) {
- throw new BuildException(
- "Missing attribute binFolder when compiling libraries or projects with libraries.");
- }
- task.createArg().setValue("--output-text-symbols");
- task.createArg().setValue(mBinFolder);
- }
-
- // if the project contains libraries, force auto-add-overlay
- if (libResRef != null) {
- task.createArg().setValue("--auto-add-overlay");
- }
-
- if (mVersionCode != 0) {
- task.createArg().setValue("--version-code");
- task.createArg().setValue(Integer.toString(mVersionCode));
- }
-
- if (mVersionName != null && mVersionName.length() > 0) {
- task.createArg().setValue("--version-name");
- task.createArg().setValue(mVersionName);
- }
-
- // manifest location
- if (mManifestFile != null && mManifestFile.length() > 0) {
- task.createArg().setValue("-M");
- task.createArg().setValue(mManifestFile);
- }
-
- // Rename manifest package
- if (mManifestPackage != null) {
- task.createArg().setValue("--rename-manifest-package");
- task.createArg().setValue(mManifestPackage);
- }
-
- // resources locations.
- if (mResources.size() > 0) {
- for (Path pathList : mResources) {
- for (String path : pathList.list()) {
- // This may not exists, and aapt doesn't like it, so we check first.
- File res = new File(path);
- if (res.isDirectory()) {
- task.createArg().setValue("-S");
- task.createArg().setValue(path);
- }
- }
- }
- }
-
- // add other resources coming from library project
- if (libResRef instanceof Path) {
- for (String path : ((Path)libResRef).list()) {
- // This may not exists, and aapt doesn't like it, so we check first.
- File res = new File(path);
- if (res.isDirectory()) {
- task.createArg().setValue("-S");
- task.createArg().setValue(path);
- }
- }
- }
-
- // assets location. This may not exists, and aapt doesn't like it, so we check first.
- if (mAssets != null && new File(mAssets).isDirectory()) {
- task.createArg().setValue("-A");
- task.createArg().setValue(mAssets);
- }
-
- // android.jar
- if (mAndroidJar != null) {
- task.createArg().setValue("-I");
- task.createArg().setValue(mAndroidJar);
- }
-
- // apk file. This is based on the apkFolder, apkBaseName, and the configName (if applicable)
- String filename = null;
- if (mApkName != null) {
- filename = mApkName;
- }
-
- if (filename != null) {
- File file = new File(mApkFolder, filename);
- task.createArg().setValue("-F");
- task.createArg().setValue(file.getAbsolutePath());
- }
-
- // R class generation
- if (generateRClass) {
- task.createArg().setValue("-J");
- task.createArg().setValue(mRFolder);
- }
-
- // ignore assets flag
- if (mIgnoreAssets != null && mIgnoreAssets.length() > 0) {
- task.createArg().setValue("--ignore-assets");
- task.createArg().setValue(mIgnoreAssets);
- }
-
- // Use dependency generation
- task.createArg().setValue("--generate-dependencies");
-
- // use the proguard file
- if (mProguardFile != null && mProguardFile.length() > 0) {
- task.createArg().setValue("-G");
- task.createArg().setValue(mProguardFile);
- }
-
- // final setup of the task
- task.setProject(taskProject);
- task.setOwningTarget(getOwningTarget());
-
- // execute it.
- task.execute();
-
- // now if the project has libraries, R needs to be created for each libraries
- // but only if the project is not a library.
- try {
- if (!mNonConstantId && libPkgProp != null && !libPkgProp.isEmpty()) {
- File rFile = new File(mBinFolder, SdkConstants.FN_RESOURCE_TEXT);
- if (rFile.isFile()) {
- // Load the full symbols from the full R.txt file.
- SymbolLoader fullSymbolValues = new SymbolLoader(rFile);
- fullSymbolValues.load();
-
- // we have two props which contains list of items. Both items represent
- // 2 data of a single property.
- // Don't want to use guava's splitter because it doesn't provide a list of the
- // result. but we know the list starts with a ; so strip it.
- if (libPkgProp.startsWith(";")) {
- libPkgProp = libPkgProp.substring(1).trim();
- }
- String[] packages = libPkgProp.split(";");
- String[] rFiles = libRFileProp.list();
-
- if (packages.length != rFiles.length) {
- throw new BuildException(String.format(
- "%1$s and %2$s must contain the same number of items.",
- mLibraryPackagesRefid, mLibraryRFileRefid));
- }
-
- if (mOriginalManifestPackage == null) {
- mOriginalManifestPackage = getPackageName(mManifestFile);
- }
-
- Multimap<String, SymbolLoader> libMap = ArrayListMultimap.create();
-
- // First pass processing the libraries, collecting them by packageName,
- // and ignoring the ones that have the same package name as the application
- // (since that R class was already created).
- for (int i = 0 ; i < packages.length ; i++) {
- String libPackage = packages[i];
-
- // skip libraries that have the same package name as the application.
- if (mOriginalManifestPackage.equals(libPackage)) {
- continue;
- }
-
- File rText = new File(rFiles[i]);
- if (rText.isFile()) {
- // load the lib symbols
- SymbolLoader libSymbols = new SymbolLoader(rText);
- libSymbols.load();
-
- // store these symbols by associating them with the package name.
- libMap.put(libPackage, libSymbols);
- }
- }
-
- // now loop on all the package names, merge all the symbols to write,
- // and write them
- for (String packageName : libMap.keySet()) {
- Collection<SymbolLoader> symbols = libMap.get(packageName);
-
- SymbolWriter writer = new SymbolWriter(mRFolder, packageName,
- fullSymbolValues);
- for (SymbolLoader symbolLoader : symbols) {
- writer.addSymbolsToWrite(symbolLoader);
- }
- writer.write();
- }
- }
- }
- } catch (Exception e) {
- // HACK alert.
- // in order for this step to happen again when this part fails, we delete
- // the dependency file.
- File f = new File(mRFolder, "R.java.d");
- f.delete();
-
- throw (e instanceof BuildException) ? (BuildException)e : new BuildException(e);
- }
- }
-
- private String getPackageName(String manifest) {
- XPath xpath = AndroidXPathFactory.newXPath();
-
- try {
- String s = xpath.evaluate("/manifest/@package",
- new InputSource(new FileInputStream(manifest)));
- return s;
- } catch (XPathExpressionException e) {
- throw new BuildException(e);
- } catch (FileNotFoundException e) {
- throw new BuildException(e);
- }
- }
-}
diff --git a/anttasks/src/com/android/ant/AidlExecTask.java b/anttasks/src/com/android/ant/AidlExecTask.java
deleted file mode 100644
index 87ca599..0000000
--- a/anttasks/src/com/android/ant/AidlExecTask.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.SdkConstants;
-import com.android.sdklib.io.FileOp;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.ExecTask;
-import org.apache.tools.ant.types.Path;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Task to execute aidl.
- * <p>
- * It expects 5 attributes:<br>
- * 'executable' ({@link Path} with a single path) for the location of the aidl executable<br>
- * 'framework' ({@link Path} with a single path) for the "preprocessed" file containing all the
- * parcelables exported by the framework<br>
- * 'genFolder' ({@link Path} with a single path) for the location of the gen folder.
- * 'aidlOutFolder' ({@link Path} with a single path) for the location of the bin/aidl folder to
- * copy the aidl files.
- * 'libraryBinAidlFolderPathRefid' the name of the reference to a path object that contains
- * libraries aidl output folder.
- *
- * It also expects one or more inner elements called "source" which are identical to {@link Path}
- * elements.
- */
-public class AidlExecTask extends MultiFilesTask {
-
- private String mExecutable;
- private String mFramework;
- private Path mLibraryBinAidlFolderPath;
- private String mGenFolder;
- private final ArrayList<Path> mPaths = new ArrayList<Path>();
- private String mAidlOutFolder;
-
- private class AidlProcessor implements SourceProcessor {
-
- @Override
- public Set<String> getSourceFileExtensions() {
- return Collections.singleton(SdkConstants.EXT_AIDL);
- }
-
- @Override
- public void process(String filePath, String sourceFolder,
- List<String> sourceFolders, Project taskProject) {
- ExecTask task = new ExecTask();
- task.setProject(taskProject);
- task.setOwningTarget(getOwningTarget());
- task.setExecutable(mExecutable);
- task.setTaskName("aidl");
- task.setFailonerror(true);
-
- task.createArg().setValue("-p" + mFramework);
- task.createArg().setValue("-o" + mGenFolder);
- // add all the source folders as import in case an aidl file in a source folder
- // imports a parcelable from another source folder.
- for (String importFolder : sourceFolders) {
- task.createArg().setValue("-I" + importFolder);
- }
-
- // add all the library aidl folders to access parcelables that are in libraries
- if (mLibraryBinAidlFolderPath != null) {
- for (String importFolder : mLibraryBinAidlFolderPath.list()) {
- task.createArg().setValue("-I" + importFolder);
- }
- }
-
- // set auto dependency file creation
- task.createArg().setValue("-a");
-
- task.createArg().setValue(filePath);
-
- // execute it.
- task.execute();
-
- // if we reach here, it was successful (execute throws an exception otherwise).
- // Copy the file into the bin/aidl directory.
- String relative = filePath.substring(sourceFolder.length());
- if (relative.charAt(0) == '/' || relative.charAt(0) == File.separatorChar) {
- relative = relative.substring(1);
- }
-
- try {
- File dest = new File(mAidlOutFolder, relative);
- File parent = dest.getParentFile();
- parent.mkdirs();
-
- FileOp op = new FileOp();
- op.copyFile(new File(filePath), dest);
- } catch (IOException e) {
- throw new BuildException(e);
- }
- }
-
- @Override
- public void displayMessage(DisplayType type, int count) {
- switch (type) {
- case FOUND:
- System.out.println(String.format("Found %1$d AIDL files.", count));
- break;
- case COMPILING:
- if (count > 0) {
- System.out.println(String.format("Compiling %1$d AIDL files.",
- count));
- } else {
- System.out.println("No AIDL files to compile.");
- }
- break;
- case REMOVE_OUTPUT:
- System.out.println(String.format("Found %1$d obsolete output files to remove.",
- count));
- break;
- case REMOVE_DEP:
- System.out.println(
- String.format("Found %1$d obsolete dependency files to remove.",
- count));
- break;
- }
- }
- }
-
- /**
- * Sets the value of the "executable" attribute.
- * @param executable the value.
- */
- public void setExecutable(Path executable) {
- mExecutable = TaskHelper.checkSinglePath("executable", executable);
- }
-
- public void setFramework(Path value) {
- mFramework = TaskHelper.checkSinglePath("framework", value);
- }
-
- public void setLibraryBinAidlFolderPathRefid(String libraryBinAidlFolderPathRefid) {
- Object libBinAidlRef = getProject().getReference(libraryBinAidlFolderPathRefid);
- if (libBinAidlRef instanceof Path) {
- mLibraryBinAidlFolderPath = (Path) libBinAidlRef;
- }
- }
-
- public void setGenFolder(Path value) {
- mGenFolder = TaskHelper.checkSinglePath("genFolder", value);
- }
-
- public void setAidlOutFolder(Path value) {
- mAidlOutFolder = TaskHelper.checkSinglePath("aidlOutFolder", value);
- }
-
- public Path createSource() {
- Path p = new Path(getProject());
- mPaths.add(p);
- return p;
- }
-
- @Override
- public void execute() throws BuildException {
- if (mExecutable == null) {
- throw new BuildException("AidlExecTask's 'executable' is required.");
- }
- if (mFramework == null) {
- throw new BuildException("AidlExecTask's 'framework' is required.");
- }
- if (mGenFolder == null) {
- throw new BuildException("AidlExecTask's 'genFolder' is required.");
- }
- if (mAidlOutFolder == null) {
- throw new BuildException("AidlExecTask's 'aidlOutFolder' is required.");
- }
-
- processFiles(new AidlProcessor(), mPaths, mGenFolder);
- }
-}
diff --git a/anttasks/src/com/android/ant/ApkBuilderTask.java b/anttasks/src/com/android/ant/ApkBuilderTask.java
deleted file mode 100644
index 8997ad1..0000000
--- a/anttasks/src/com/android/ant/ApkBuilderTask.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.sdklib.build.ApkBuilder;
-import com.android.sdklib.build.ApkBuilder.FileEntry;
-import com.android.sdklib.build.ApkCreationException;
-import com.android.sdklib.build.DuplicateFileException;
-import com.android.sdklib.build.SealedApkException;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.types.Path;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Pattern;
-
-public class ApkBuilderTask extends SingleDependencyTask {
-
- private final static Pattern PATTERN_JAR_EXT = Pattern.compile("^.+\\.jar$",
- Pattern.CASE_INSENSITIVE);
-
- private String mOutFolder;
- private String mApkFilepath;
- private String mResourceFile;
- private boolean mVerbose = false;
- private boolean mDebugPackaging = false;
- private boolean mDebugSigning = false;
- private boolean mHasCode = true;
-
- private Path mDexPath;
-
- private final ArrayList<Path> mZipList = new ArrayList<Path>();
- private final ArrayList<Path> mSourceList = new ArrayList<Path>();
- private final ArrayList<Path> mJarfolderList = new ArrayList<Path>();
- private final ArrayList<Path> mJarfileList = new ArrayList<Path>();
- private final ArrayList<Path> mNativeList = new ArrayList<Path>();
-
- private static class SourceFolderInputPath extends InputPath {
- public SourceFolderInputPath(File file) {
- super(file);
- }
-
- @Override
- public boolean ignores(File file) {
- if (file.isDirectory()) {
- return !ApkBuilder.checkFolderForPackaging(file.getName());
- } else {
- return !ApkBuilder.checkFileForPackaging(file.getName());
- }
- }
- }
-
- /**
- * Sets the value of the "outfolder" attribute.
- * @param outFolder the value.
- */
- public void setOutfolder(Path outFolder) {
- mOutFolder = TaskHelper.checkSinglePath("outfolder", outFolder);
- }
-
- /**
- * Sets the full filepath to the apk to generate.
- * @param filepath
- */
- public void setApkfilepath(String filepath) {
- mApkFilepath = filepath;
- }
-
- /**
- * Sets the resourcefile attribute
- * @param resourceFile
- */
- public void setResourcefile(String resourceFile) {
- mResourceFile = resourceFile;
- }
-
- /**
- * Sets the value of the "verbose" attribute.
- * @param verbose the value.
- */
- public void setVerbose(boolean verbose) {
- mVerbose = verbose;
- }
-
- /**
- * Sets the value of the "debug" attribute.
- * @param debug the debug mode value.
- */
- public void setDebug(boolean debug) {
- System.out.println("WARNNG: Using deprecated 'debug' attribute in ApkBuilderTask." +
- "Use 'debugpackaging' and 'debugsigning' instead.");
- mDebugPackaging = debug;
- mDebugSigning = debug;
- }
-
- /**
- * Sets the value of the "debugpackaging" attribute.
- * @param debug the debug mode value.
- */
- public void setDebugpackaging(boolean debug) {
- mDebugPackaging = debug;
- }
-
- /**
- * Sets the value of the "debugsigning" attribute.
- * @param debug the debug mode value.
- */
- public void setDebugsigning(boolean debug) {
- mDebugSigning = debug;
- }
-
- /**
- * Sets the hascode attribute. Default is true.
- * If set to false, then <dex> and <sourcefolder> nodes are ignored and not processed.
- * @param hasCode the value of the attribute.
- */
- public void setHascode(boolean hasCode) {
- mHasCode = hasCode;
- }
-
- /**
- * Returns an object representing a nested <var>zip</var> element.
- */
- public Object createZip() {
- Path path = new Path(getProject());
- mZipList.add(path);
- return path;
- }
-
- /**
- * Returns an object representing a nested <var>dex</var> element.
- * This is similar to a nested <var>file</var> element, except when {@link #mHasCode}
- * is <code>false</code> in which case it's ignored.
- */
- public Object createDex() {
- if (mDexPath == null) {
- return mDexPath = new Path(getProject());
- } else {
- throw new BuildException("Only one <dex> inner element can be provided");
- }
- }
-
- /**
- * Returns an object representing a nested <var>sourcefolder</var> element.
- */
- public Object createSourcefolder() {
- Path path = new Path(getProject());
- mSourceList.add(path);
- return path;
- }
-
- /**
- * Returns an object representing a nested <var>jarfolder</var> element.
- */
- public Object createJarfolder() {
- Path path = new Path(getProject());
- mJarfolderList.add(path);
- return path;
- }
-
- /**
- * Returns an object representing a nested <var>jarfile</var> element.
- */
- public Object createJarfile() {
- Path path = new Path(getProject());
- mJarfileList.add(path);
- return path;
- }
-
- /**
- * Returns an object representing a nested <var>nativefolder</var> element.
- */
- public Object createNativefolder() {
- Path path = new Path(getProject());
- mNativeList.add(path);
- return path;
- }
-
- @Override
- public void execute() throws BuildException {
-
- File outputFile;
- if (mApkFilepath != null) {
- outputFile = new File(mApkFilepath);
- } else {
- throw new BuildException("missing attribute 'apkFilepath'");
- }
-
- if (mResourceFile == null) {
- throw new BuildException("missing attribute 'resourcefile'");
- }
-
- if (mOutFolder == null) {
- throw new BuildException("missing attribute 'outfolder'");
- }
-
- // check dexPath is only one file.
- File dexFile = null;
- if (mHasCode) {
- String[] dexFiles = mDexPath.list();
- if (dexFiles.length != 1) {
- throw new BuildException(String.format(
- "Expected one dex file but path value resolve to %d files.",
- dexFiles.length));
- }
- dexFile = new File(dexFiles[0]);
- }
-
- try {
- // build list of input files/folders to compute dependencies
- // add the content of the zip files.
- List<InputPath> inputPaths = new ArrayList<InputPath>();
-
- // resource file
- InputPath resourceInputPath = new InputPath(new File(mOutFolder, mResourceFile));
- inputPaths.add(resourceInputPath);
-
- // dex file
- if (dexFile != null) {
- inputPaths.add(new InputPath(dexFile));
- }
-
- // zip input files
- List<File> zipFiles = new ArrayList<File>();
- for (Path pathList : mZipList) {
- for (String path : pathList.list()) {
- File f = new File(path);
- zipFiles.add(f);
- inputPaths.add(new InputPath(f));
- }
- }
-
- // now go through the list of source folders used to add non java files.
- List<File> sourceFolderList = new ArrayList<File>();
- if (mHasCode) {
- for (Path pathList : mSourceList) {
- for (String path : pathList.list()) {
- File f = new File(path);
- sourceFolderList.add(f);
- // because this is a source folder but we only care about non
- // java files.
- inputPaths.add(new SourceFolderInputPath(f));
- }
- }
- }
-
- // now go through the list of jar folders.
- List<File> jarFileList = new ArrayList<File>();
- for (Path pathList : mJarfolderList) {
- for (String path : pathList.list()) {
- // it's ok if top level folders are missing
- File folder = new File(path);
- if (folder.isDirectory()) {
- String[] filenames = folder.list(new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return PATTERN_JAR_EXT.matcher(name).matches();
- }
- });
-
- for (String filename : filenames) {
- File f = new File(folder, filename);
- jarFileList.add(f);
- inputPaths.add(new InputPath(f));
- }
- }
- }
- }
-
- // now go through the list of jar files.
- for (Path pathList : mJarfileList) {
- for (String path : pathList.list()) {
- File f = new File(path);
- jarFileList.add(f);
- inputPaths.add(new InputPath(f));
- }
- }
-
- // now the native lib folder.
- List<FileEntry> nativeFileList = new ArrayList<FileEntry>();
- for (Path pathList : mNativeList) {
- for (String path : pathList.list()) {
- // it's ok if top level folders are missing
- File folder = new File(path);
- if (folder.isDirectory()) {
- List<FileEntry> entries = ApkBuilder.getNativeFiles(folder,
- mDebugPackaging);
- // add the list to the list of native files and then create an input
- // path for each file
- nativeFileList.addAll(entries);
-
- for (FileEntry entry : entries) {
- inputPaths.add(new InputPath(entry.mFile));
- }
- }
- }
- }
-
- // Finally figure out the path to the dependency file.
- String depFile = outputFile.getAbsolutePath() + ".d";
-
- // check dependencies
- if (initDependencies(depFile, inputPaths) && dependenciesHaveChanged() == false) {
- System.out.println(
- "No changes. No need to create apk.");
- return;
- }
-
- if (mDebugSigning) {
- System.out.println(String.format(
- "Creating %s and signing it with a debug key...", outputFile.getName()));
- } else {
- System.out.println(String.format(
- "Creating %s for release...", outputFile.getName()));
- }
-
- ApkBuilder apkBuilder = new ApkBuilder(
- outputFile,
- resourceInputPath.getFile(),
- dexFile,
- mDebugSigning ? ApkBuilder.getDebugKeystore() : null,
- mVerbose ? System.out : null);
- apkBuilder.setDebugMode(mDebugPackaging);
-
-
- // add the content of the zip files.
- for (File f : zipFiles) {
- if (mVerbose) {
- System.out.println("Zip Input: " + f.getAbsolutePath());
- }
- apkBuilder.addZipFile(f);
- }
-
- // now go through the list of file to directly add the to the list.
- for (File f : sourceFolderList) {
- if (mVerbose) {
- System.out.println("Source Folder Input: " + f.getAbsolutePath());
- }
- apkBuilder.addSourceFolder(f);
- }
-
- // now go through the list of jar files.
- for (File f : jarFileList) {
- if (mVerbose) {
- System.out.println("Jar Input: " + f.getAbsolutePath());
- }
- apkBuilder.addResourcesFromJar(f);
- }
-
- // and finally the native files
- apkBuilder.addNativeLibraries(nativeFileList);
-
- // close the archive
- apkBuilder.sealApk();
-
- // and generate the dependency file
- generateDependencyFile(depFile, inputPaths, outputFile.getAbsolutePath());
- } catch (DuplicateFileException e) {
- System.err.println(String.format(
- "Found duplicate file for APK: %1$s\nOrigin 1: %2$s\nOrigin 2: %3$s",
- e.getArchivePath(), e.getFile1(), e.getFile2()));
- throw new BuildException(e);
- } catch (ApkCreationException e) {
- throw new BuildException(e);
- } catch (SealedApkException e) {
- throw new BuildException(e);
- } catch (IllegalArgumentException e) {
- throw new BuildException(e);
- }
- }
-
- @Override
- protected String getExecTaskName() {
- return "apkbuilder";
- }
-}
diff --git a/anttasks/src/com/android/ant/BuildConfigTask.java b/anttasks/src/com/android/ant/BuildConfigTask.java
deleted file mode 100644
index 4fee80c..0000000
--- a/anttasks/src/com/android/ant/BuildConfigTask.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.sdklib.internal.build.BuildConfigGenerator;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.types.Path;
-
-import java.io.File;
-import java.io.IOException;
-
-public class BuildConfigTask extends BuildTypedTask {
-
- private String mGenFolder;
- private String mAppPackage;
-
- public void setGenFolder(Path path) {
- mGenFolder = TaskHelper.checkSinglePath("genFolder", path);
- }
-
- public void setPackage(String appPackage) {
- mAppPackage = appPackage;
- }
-
-
- @Override
- public void execute() throws BuildException {
- if (mGenFolder == null) {
- throw new BuildException("Missing attribute genFolder");
- }
- if (mAppPackage == null) {
- throw new BuildException("Missing attribute package");
- }
-
- BuildConfigGenerator generator = new BuildConfigGenerator(
- mGenFolder, mAppPackage,
- Boolean.parseBoolean(getBuildType()));
-
- // first check if the file is missing.
- File buildConfigFile = generator.getBuildConfigFile();
- boolean missingFile = buildConfigFile.exists() == false;
-
- if (missingFile || hasBuildTypeChanged()) {
- if (isNewBuild()) {
- System.out.println("Generating BuildConfig class.");
- } else if (missingFile) {
- System.out.println("BuildConfig class missing: Generating new BuildConfig class.");
- } else {
- System.out.println("Build type changed: Generating new BuildConfig class.");
- }
-
- try {
- generator.generate();
- } catch (IOException e) {
- throw new BuildException("Failed to create BuildConfig class", e);
- }
- } else {
- System.out.println("No need to generate new BuildConfig.");
- }
- }
-}
diff --git a/anttasks/src/com/android/ant/BuildTypedTask.java b/anttasks/src/com/android/ant/BuildTypedTask.java
deleted file mode 100644
index 3f4b64a..0000000
--- a/anttasks/src/com/android/ant/BuildTypedTask.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import org.apache.tools.ant.Task;
-
-/**
- * Base class for tasks that should exec when the build type change.
- */
-public abstract class BuildTypedTask extends Task {
-
- private String mPreviousBuildType;
- private String mBuildType;
-
- /** Sets the current build type */
- public void setBuildType(String buildType) {
- mBuildType = buildType;
- }
-
- /** Sets the previous build type */
- public void setPreviousBuildType(String previousBuildType) {
- mPreviousBuildType = previousBuildType;
- }
-
- protected String getBuildType() {
- return mBuildType;
- }
-
- /**
- * Returns if it is a new build. If the build type is not input
- * from the XML, this always returns true.
- * A build type is defined by having an empty previousBuildType.
- */
- protected boolean isNewBuild() {
- return mBuildType == null || mPreviousBuildType.length() == 0;
- }
-
- /**
- * Returns true if the build type changed.
- */
- protected boolean hasBuildTypeChanged() {
- // no build type? return false as the feature is simply not used
- if (mBuildType == null && mPreviousBuildType == null) {
- return false;
- }
-
- return mBuildType.equals(mPreviousBuildType) == false;
- }
-}
diff --git a/anttasks/src/com/android/ant/CheckEnvTask.java b/anttasks/src/com/android/ant/CheckEnvTask.java
deleted file mode 100644
index 98312f9..0000000
--- a/anttasks/src/com/android/ant/CheckEnvTask.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.SdkConstants;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.util.DeweyDecimal;
-
-import java.io.File;
-
-/**
- * Checks the Ant environment to make sure Android builds
- * can run.
- *
- * No parameters are neeed.
- *
- */
-public class CheckEnvTask extends Task {
-
- private final static String ANT_MIN_VERSION = "1.8.0";
-
- @Override
- public void execute() {
-
- Project antProject = getProject();
-
- // check the Ant version
- DeweyDecimal version = getAntVersion(antProject);
- DeweyDecimal atLeast = new DeweyDecimal(ANT_MIN_VERSION);
- if (atLeast.isGreaterThan(version)) {
- throw new BuildException(
- "The Android Ant-based build system requires Ant " +
- ANT_MIN_VERSION +
- " or later. Current version is " +
- version);
- }
-
- // get the SDK location
- File sdkDir = TaskHelper.getSdkLocation(antProject);
-
- // detect that the platform tools is there.
- File platformTools = new File(sdkDir, SdkConstants.FD_PLATFORM_TOOLS);
- if (platformTools.isDirectory() == false) {
- throw new BuildException(String.format(
- "SDK Platform Tools component is missing. " +
- "Please install it with the SDK Manager (%1$s%2$c%3$s)",
- SdkConstants.FD_TOOLS,
- File.separatorChar,
- SdkConstants.androidCmdName()));
- }
-
- // display SDK Tools revision
- DeweyDecimal toolsRevison = TaskHelper.getToolsRevision(sdkDir);
- if (toolsRevison != null) {
- System.out.println("Android SDK Tools Revision " + toolsRevison);
- System.out.println("Installed at " + sdkDir.getAbsolutePath());
- }
- }
-
- /**
- * Returns the Ant version as a {@link DeweyDecimal} object.
- *
- * This is based on the implementation of
- * org.apache.tools.ant.taskdefs.condition.AntVersion.getVersion()
- *
- * @param antProject the current ant project.
- * @return the ant version.
- */
- private DeweyDecimal getAntVersion(Project antProject) {
- char[] versionString = antProject.getProperty("ant.version").toCharArray();
- StringBuilder sb = new StringBuilder();
- boolean foundFirstDigit = false;
- for (int i = 0; i < versionString.length; i++) {
- if (Character.isDigit(versionString[i])) {
- sb.append(versionString[i]);
- foundFirstDigit = true;
- }
- if (versionString[i] == '.' && foundFirstDigit) {
- sb.append(versionString[i]);
- }
- if (Character.isLetter(versionString[i]) && foundFirstDigit) {
- break;
- }
- }
- return new DeweyDecimal(sb.toString());
- }
-
-}
diff --git a/anttasks/src/com/android/ant/ComputeDependencyTask.java b/anttasks/src/com/android/ant/ComputeDependencyTask.java
deleted file mode 100644
index 7d96c70..0000000
--- a/anttasks/src/com/android/ant/ComputeDependencyTask.java
+++ /dev/null
@@ -1,283 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.SdkConstants;
-import com.android.ant.DependencyHelper.JarProcessor;
-import com.android.io.FileWrapper;
-import com.android.sdklib.internal.project.IPropertySource;
-import com.android.xml.AndroidManifest;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.Path.PathElement;
-
-import java.io.File;
-import java.util.List;
-
-/**
- * Computes the dependency of the current project.
- *
- * Out params:
- * <code>libraryResFolderPathOut</code>: the Path object containing the res folder for all the
- * library projects in the order needed by aapt.
- *
- * <code>libraryPackagesOut</code>: a simple property containing ;-separated package name from
- * the library projects.
- *
- * <code>jarLibraryPathOut</code>: the Path object containing all the 3rd party jar files.
- *
- * <code>libraryNativeFolderPathOut</code>: the Path with all the native folder for the library
- * projects.
- *
- *
- * In params:
- * <code>targetApi</code>: the compilation target api.
- * <code>verbose</code>: whether the build is verbose.
- *
- */
-public class ComputeDependencyTask extends GetLibraryPathTask {
-
- private String mLibraryManifestFilePathOut;
- private String mLibraryResFolderPathOut;
- private String mLibraryPackagesOut;
- private String mJarLibraryPathOut;
- private String mLibraryNativeFolderPathOut;
- private String mLibraryBinAidlFolderPathOut;
- private String mLibraryRFilePathOut;
- private int mTargetApi = -1;
- private boolean mVerbose = false;
-
- public void setLibraryManifestFilePathOut(String libraryManifestFilePathOut) {
- mLibraryManifestFilePathOut = libraryManifestFilePathOut;
- }
-
- public void setLibraryResFolderPathOut(String libraryResFolderPathOut) {
- mLibraryResFolderPathOut = libraryResFolderPathOut;
- }
-
- public void setLibraryPackagesOut(String libraryPackagesOut) {
- mLibraryPackagesOut = libraryPackagesOut;
- }
-
- public void setJarLibraryPathOut(String jarLibraryPathOut) {
- mJarLibraryPathOut = jarLibraryPathOut;
- }
-
- public void setLibraryBinAidlFolderPathOut(String libraryBinAidlFolderPathOut) {
- mLibraryBinAidlFolderPathOut = libraryBinAidlFolderPathOut;
- }
-
- public void setLibraryRFilePathOut(String libraryRFilePathOut) {
- mLibraryRFilePathOut = libraryRFilePathOut;
- }
-
- public void setLibraryNativeFolderPathOut(String libraryNativeFolderPathOut) {
- mLibraryNativeFolderPathOut = libraryNativeFolderPathOut;
- }
-
- public void setTargetApi(int targetApi) {
- mTargetApi = targetApi;
- }
-
- @Override
- public void execute() throws BuildException {
- if (mLibraryManifestFilePathOut == null) {
- throw new BuildException("Missing attribute libraryManifestFilePathOut");
- }
- if (mLibraryResFolderPathOut == null) {
- throw new BuildException("Missing attribute libraryResFolderPathOut");
- }
- if (mLibraryPackagesOut == null) {
- throw new BuildException("Missing attribute libraryPackagesOut");
- }
- if (mJarLibraryPathOut == null) {
- throw new BuildException("Missing attribute jarLibraryPathOut");
- }
- if (mLibraryNativeFolderPathOut == null) {
- throw new BuildException("Missing attribute libraryNativeFolderPathOut");
- }
- if (mLibraryBinAidlFolderPathOut == null) {
- throw new BuildException("Missing attribute libraryBinFolderPathOut");
- }
- if (mLibraryRFilePathOut == null) {
- throw new BuildException("Missing attribute libraryRFilePathOut");
- }
- if (mTargetApi == -1) {
- throw new BuildException("Missing attribute targetApi");
- }
-
- final Project antProject = getProject();
-
- // get the SDK location
- File sdkDir = TaskHelper.getSdkLocation(antProject);
-
- // prepare several paths for future tasks
- final Path manifestFilePath = new Path(antProject);
- final Path resFolderPath = new Path(antProject);
- final Path nativeFolderPath = new Path(antProject);
- final Path binAidlFolderPath = new Path(antProject);
- final Path rFilePath = new Path(antProject);
- final StringBuilder packageStrBuilder = new StringBuilder();
-
- // custom jar processor doing a bit more than just collecting the jar files
- JarProcessor processor = new JarProcessor() {
- @Override
- public void processLibrary(String libRootPath, IPropertySource properties) {
- // let the super class handle the jar files
- super.processLibrary(libRootPath, properties);
-
- // get the AndroidManifest.xml path.
- // FIXME: support renamed location.
- PathElement element = manifestFilePath.createPathElement();
- element.setPath(libRootPath + '/' + SdkConstants.FN_ANDROID_MANIFEST_XML);
-
- // get the res path. $PROJECT/res as well as the crunch cache.
- // FIXME: support renamed folders.
- element = resFolderPath.createPathElement();
- element.setPath(libRootPath + '/' + SdkConstants.FD_OUTPUT +
- '/' + SdkConstants.FD_RES);
- element = resFolderPath.createPathElement();
- element.setPath(libRootPath + '/' + SdkConstants.FD_RESOURCES);
-
- // get the folder for the native libraries. Always $PROJECT/libs
- // FIXME: support renamed folder and/or move libs to bin/libs/
- element = nativeFolderPath.createPathElement();
- element.setPath(libRootPath + '/' + SdkConstants.FD_NATIVE_LIBS);
-
- // get the bin/aidl folder. $PROJECT/bin/aidl for now
- // FIXME: support renamed folder.
- element = binAidlFolderPath.createPathElement();
- element.setPath(libRootPath + '/' + SdkConstants.FD_OUTPUT +
- '/' + SdkConstants.FD_AIDL);
-
- // get the package from the manifest.
- FileWrapper manifest = new FileWrapper(libRootPath,
- SdkConstants.FN_ANDROID_MANIFEST_XML);
-
- try {
- String value = AndroidManifest.getPackage(manifest);
- if (value != null) { // aapt will complain if it's missing.
- packageStrBuilder.append(';');
- packageStrBuilder.append(value);
-
- // get the text R file. $PROJECT/bin/R.txt for now
- // This must be in sync with the package list.
- // FIXME: support renamed folder.
- element = rFilePath.createPathElement();
- element.setPath(libRootPath + "/" + SdkConstants.FD_OUTPUT +
- "/" + "R.txt");
-
- }
- } catch (Exception e) {
- throw new BuildException(e);
- }
- }
- };
-
- // list of all the jars that are on the classpath. This will receive the
- // project's libs/*.jar files, the Library Projects output and their own libs/*.jar
- List<File> jars = processor.getJars();
-
-
- // in case clean has been called before a build type target, the list of
- // libraries has already been computed so we don't need to compute it again.
- Path libraryFolderPath = (Path) antProject.getReference(getLibraryFolderPathOut());
- if (libraryFolderPath == null) {
- execute(processor);
- } else {
- // this contains the list of library folder in reverse order (compilation order).
- // We need to process it in the normal order (res order).
- System.out.println("Ordered libraries:");
-
- String[] libraries = libraryFolderPath.list();
- for (int i = libraries.length - 1 ; i >= 0 ; i--) {
- String libRootPath = libraries[i];
- System.out.println(libRootPath);
-
- processor.processLibrary(libRootPath);
- }
- }
-
- boolean hasLibraries = jars.size() > 0;
-
- if (mTargetApi <= 15) {
- System.out.println("\n------------------");
- System.out.println("API<=15: Adding annotations.jar to the classpath.");
-
- jars.add(new File(sdkDir, SdkConstants.FD_TOOLS +
- '/' + SdkConstants.FD_SUPPORT +
- '/' + SdkConstants.FN_ANNOTATIONS_JAR));
-
- }
-
- // even with no libraries, always setup these so that various tasks in Ant don't complain
- // (the task themselves can handle a ref to an empty Path)
- antProject.addReference(mLibraryNativeFolderPathOut, nativeFolderPath);
- antProject.addReference(mLibraryManifestFilePathOut, manifestFilePath);
- antProject.addReference(mLibraryBinAidlFolderPathOut, binAidlFolderPath);
-
- // the rest is done only if there's a library.
- if (hasLibraries) {
- antProject.addReference(mLibraryResFolderPathOut, resFolderPath);
- antProject.setProperty(mLibraryPackagesOut, packageStrBuilder.toString());
- antProject.addReference(mLibraryRFilePathOut, rFilePath);
- }
-
- File projectFolder = antProject.getBaseDir();
-
- // add the project's own content of libs/*.jar
- File libsFolder = new File(projectFolder, SdkConstants.FD_NATIVE_LIBS);
- File[] jarFiles = libsFolder.listFiles(processor.getFilter());
- if (jarFiles != null) {
- for (File jarFile : jarFiles) {
- jars.add(jarFile);
- }
- }
-
- // now sanitize the path to remove dups
- jars = DependencyHelper.sanitizePaths(projectFolder, new IPropertySource() {
- @Override
- public String getProperty(String name) {
- return antProject.getProperty(name);
- }
-
- @Override
- public void debugPrint() {
- }
- }, jars);
-
- // and create a Path object for them
- Path jarsPath = new Path(antProject);
- if (mVerbose) {
- System.out.println("\n------------------\nSanitized jar list:");
- }
- for (File f : jars) {
- if (mVerbose) {
- System.out.println("- " + f.getAbsolutePath());
- }
- PathElement element = jarsPath.createPathElement();
- element.setPath(f.getAbsolutePath());
- }
- antProject.addReference(mJarLibraryPathOut, jarsPath);
-
- if (mVerbose) {
- System.out.println();
- }
- }
-}
diff --git a/anttasks/src/com/android/ant/ComputeProjectClasspathTask.java b/anttasks/src/com/android/ant/ComputeProjectClasspathTask.java
deleted file mode 100644
index ac793f3..0000000
--- a/anttasks/src/com/android/ant/ComputeProjectClasspathTask.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.SdkConstants;
-import com.android.ant.DependencyHelper.JarProcessor;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.Path.PathElement;
-
-import java.io.File;
-import java.util.List;
-
-public class ComputeProjectClasspathTask extends Task {
-
- private String mProjectLocation;
- private String mProjectClassPathOut;
-
- public void setProjectLocation(String projectLocation) {
- mProjectLocation = projectLocation;
- }
-
- public void setProjectClassPathOut(String projectClassPathOut) {
- mProjectClassPathOut = projectClassPathOut;
- }
-
- @Override
- public void execute() throws BuildException {
- if (mProjectLocation == null) {
- throw new BuildException("Missing attribute projectLocation");
- }
- if (mProjectClassPathOut == null) {
- throw new BuildException("Missing attribute projectClassPathOut");
- }
-
- DependencyHelper helper = new DependencyHelper(new File(mProjectLocation),
- false /*verbose*/);
-
- JarProcessor processor = new JarProcessor();
-
- helper.processLibraries(processor);
- List<File> jars = processor.getJars();
-
- // add the project's own content of libs/*.jar
- File libsFolder = new File(mProjectLocation, SdkConstants.FD_NATIVE_LIBS);
- File[] jarFiles = libsFolder.listFiles(processor.getFilter());
- if (jarFiles != null) {
- for (File jarFile : jarFiles) {
- jars.add(jarFile);
- }
- }
-
- jars = helper.sanitizePaths(jars);
-
- Project antProject = getProject();
-
- System.out.println("Resolved classpath:");
-
- // create a path with all the jars and the project's output as well.
- Path path = new Path(antProject);
- for (File jar : jars) {
- PathElement element = path.createPathElement();
- String p = jar.getAbsolutePath();
- element.setPath(p);
- System.out.println(p);
- }
-
- File bin = new File(mProjectLocation,
- helper.getOutDir() + File.separator + "classes");
- PathElement element = path.createPathElement();
- String p = bin.getAbsolutePath();
- element.setPath(p);
- System.out.println(p);
-
- antProject.addReference(mProjectClassPathOut, path);
- }
-}
diff --git a/anttasks/src/com/android/ant/DependencyGraph.java b/anttasks/src/com/android/ant/DependencyGraph.java
deleted file mode 100644
index 7cb13a0..0000000
--- a/anttasks/src/com/android/ant/DependencyGraph.java
+++ /dev/null
@@ -1,441 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
-
-import org.apache.tools.ant.BuildException;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * This class takes care of dependency tracking for all targets and prerequisites listed in
- * a single dependency file. A dependency graph always has a dependency file associated with it
- * for the duration of its lifetime
- */
-public class DependencyGraph {
-
- private final static boolean DEBUG = false;
-
- private static enum DependencyStatus {
- NONE, NEW_FILE, UPDATED_FILE, MISSING_FILE, ERROR;
- }
-
- // Files that we know about from the dependency file
- private Set<File> mTargets = Collections.emptySet();
- private Set<File> mPrereqs = mTargets;
- private File mFirstPrereq = null;
- private boolean mMissingDepFile = false;
- private long mDepFileLastModified;
- private final List<InputPath> mNewInputs;
-
- public DependencyGraph(String dependencyFilePath, List<InputPath> newInputPaths) {
- mNewInputs = newInputPaths;
- parseDependencyFile(dependencyFilePath);
- }
-
- /**
- * Check all the dependencies to see if anything has changed.
- *
- * @param printStatus will print to {@link System#out} the dependencies status.
- * @return true if new prerequisites have appeared, target files are missing or if
- * prerequisite files have been modified since the last target generation.
- */
- public boolean dependenciesHaveChanged(boolean printStatus) {
- // If no dependency file has been set up, then we'll just return true
- // if we have a dependency file, we'll check to see what's been changed
- if (mMissingDepFile) {
- System.out.println("No Dependency File Found");
- return true;
- }
-
- // check for missing output first
- if (missingTargetFile()) {
- if (printStatus) {
- System.out.println("Found Deleted Target File");
- }
- return true;
- }
-
- // get the time stamp of the oldest target.
- long oldestTarget = getOutputLastModified();
-
- // first look through the input folders and look for new files or modified files.
- DependencyStatus status = checkInputs(oldestTarget);
-
- // this can't find missing files. This is done later.
- switch (status) {
- case ERROR:
- throw new BuildException();
- case NEW_FILE:
- if (printStatus) {
- System.out.println("Found new input file");
- }
- return true;
- case UPDATED_FILE:
- if (printStatus) {
- System.out.println("Found modified input file");
- }
- return true;
- }
-
- // now do a full check on the remaining files.
- status = checkPrereqFiles(oldestTarget);
- // this can't find new input files. This is done above.
- switch (status) {
- case ERROR:
- throw new BuildException();
- case MISSING_FILE:
- if (printStatus) {
- System.out.println("Found deleted input file");
- }
- return true;
- case UPDATED_FILE:
- if (printStatus) {
- System.out.println("Found modified input file");
- }
- return true;
- }
-
- return false;
- }
-
- public Set<File> getTargets() {
- return Collections.unmodifiableSet(mTargets);
- }
-
- public File getFirstPrereq() {
- return mFirstPrereq;
- }
-
- /**
- * Parses the given dependency file and stores the file paths
- *
- * @param dependencyFilePath the dependency file
- */
- private void parseDependencyFile(String dependencyFilePath) {
- // first check if the dependency file is here.
- File depFile = new File(dependencyFilePath);
- if (depFile.isFile() == false) {
- mMissingDepFile = true;
- return;
- }
-
- // get the modification time of the dep file as we may need it later
- mDepFileLastModified = depFile.lastModified();
-
- // Read in our dependency file
- List<String> content = readFile(depFile);
- if (content == null) {
- System.err.println("ERROR: Couldn't read " + dependencyFilePath);
- return;
- }
-
- // The format is something like:
- // output1 output2 [...]: dep1 dep2 [...]
- // expect it's likely split on several lines. So let's move it back on a single line
- // first
- StringBuilder sb = new StringBuilder();
- for (String line : content) {
- line = line.trim();
- if (line.endsWith("\\")) {
- line = line.substring(0, line.length() - 1);
- }
- sb.append(line);
- }
-
- // split the left and right part
- String[] files = sb.toString().split(":");
-
- // get the target files:
- String[] targets = files[0].trim().split(" ");
-
- String[] prereqs = {};
- // Check to make sure our dependency file is okay
- if (files.length < 1) {
- System.err.println(
- "Warning! Dependency file does not list any prerequisites after ':' ");
- } else {
- // and the prerequisite files:
- prereqs = files[1].trim().split(" ");
- }
-
- mTargets = new HashSet<File>(targets.length);
- for (String path : targets) {
- if (path.length() > 0) {
- mTargets.add(new File(path));
- }
- }
-
- mPrereqs = new HashSet<File>(prereqs.length);
- for (String path : prereqs) {
- if (path.length() > 0) {
- if (DEBUG) {
- System.out.println("PREREQ: " + path);
- }
- File f = new File(path);
- if (mFirstPrereq == null) {
- mFirstPrereq = f;
- }
- mPrereqs.add(f);
- }
- }
- }
-
- /**
- * Check all the input files and folders to see if there have been new
- * files added to them or if any of the existing files have been modified.
- *
- * This looks at the input paths, not at the list of known prereq. Therefore this
- * will not find missing files. It will however remove processed files from the
- * prereq file list so that we can process those in a 2nd step.
- *
- * This should be followed by a call to {@link #checkPrereqFiles(long)} which
- * will process the remaining files in the prereq list.
- *
- * If a change is found, this will return immediately with either
- * {@link DependencyStatus#NEW_FILE} or {@link DependencyStatus#UPDATED_FILE}.
- *
- * @param oldestTarget the timestamp of the oldest output file to compare against.
- *
- * @return the status of the file in the watched folders.
- *
- */
- private DependencyStatus checkInputs(long oldestTarget) {
- if (mNewInputs != null) {
- for (InputPath input : mNewInputs) {
- File file = input.getFile();
- if (file.isDirectory()) {
- DependencyStatus status = checkInputFolder(file, input, oldestTarget);
- if (status != DependencyStatus.NONE) {
- return status;
- }
- } else if (file.isFile()) {
- DependencyStatus status = checkInputFile(file, input, oldestTarget);
- if (status != DependencyStatus.NONE) {
- return status;
- }
- }
- }
- }
-
- // If we make it all the way through our directories we're good.
- return DependencyStatus.NONE;
- }
-
- /**
- * Check all the files in the tree under root and check to see if the files are
- * listed under the dependencies, or if they have been modified. Recurses into subdirs.
- *
- * @param folder the folder to search through.
- * @param inputFolder the root level inputFolder
- * @param oldestTarget the time stamp of the oldest output file to compare against.
- *
- * @return the status of the file in the folder.
- */
- private DependencyStatus checkInputFolder(File folder, InputPath inputFolder,
- long oldestTarget) {
- if (inputFolder.ignores(folder)) {
- return DependencyStatus.NONE;
- }
-
- File[] files = folder.listFiles();
- if (files == null) {
- System.err.println("ERROR " + folder.toString() + " is not a dir or can't be read");
- return DependencyStatus.ERROR;
- }
- // Loop through files in this folder
- for (File file : files) {
- // If this is a directory, recurse into it
- if (file.isDirectory()) {
- DependencyStatus status = checkInputFolder(file, inputFolder, oldestTarget);
- if (status != DependencyStatus.NONE) {
- return status;
- }
- } else if (file.isFile()) {
- DependencyStatus status = checkInputFile(file, inputFolder, oldestTarget);
- if (status != DependencyStatus.NONE) {
- return status;
- }
- }
- }
- // If we got to here then we didn't find anything interesting
- return DependencyStatus.NONE;
- }
-
- private DependencyStatus checkInputFile(File file, InputPath inputFolder,
- long oldestTarget) {
- if (inputFolder.ignores(file)) {
- return DependencyStatus.NONE;
- }
-
- // if it's a file, remove it from the list of prereqs.
- // This way if files in this folder don't trigger a build we'll have less
- // files to go through manually
- if (mPrereqs.remove(file) == false) {
- // turns out this is a new file!
-
- if (DEBUG) {
- System.out.println("NEW FILE: " + file.getAbsolutePath());
- }
- return DependencyStatus.NEW_FILE;
- } else {
- // check the time stamp on this file if it's a file we care about based what the
- // input folder decides.
- if (inputFolder.checksForModification(file)) {
- if (file.lastModified() > oldestTarget) {
- if (DEBUG) {
- System.out.println("UPDATED FILE: " + file.getAbsolutePath());
- }
- return DependencyStatus.UPDATED_FILE;
- }
- }
- }
-
- return DependencyStatus.NONE;
- }
-
- /**
- * Check all the prereq files we know about to make sure they're still there, or that they
- * haven't been modified since the last build.
- *
- * @param oldestTarget the time stamp of the oldest output file to compare against.
- *
- * @return the status of the files
- */
- private DependencyStatus checkPrereqFiles(long oldestTarget) {
- // TODO: Optimize for the case of a specific file as inputPath.
- // We should have a map of filepath to inputpath to quickly search through them?
-
- // Loop through our prereq files and make sure they still exist
- for (File prereq : mPrereqs) {
- if (prereq.exists() == false) {
- if (DEBUG) {
- System.out.println("MISSING FILE: " + prereq.getAbsolutePath());
- }
- return DependencyStatus.MISSING_FILE;
- }
-
- // check the time stamp on this file if it's a file we care about.
- // To know if we care about the file we have to find the matching input.
- if (mNewInputs != null) {
- String filePath = prereq.getAbsolutePath();
- for (InputPath input : mNewInputs) {
- File inputFile = input.getFile();
- // if the input path is a directory, check if the prereq file is in it,
- // otherwise check if the prereq file match exactly the input path.
- if (inputFile.isDirectory()) {
- if (filePath.startsWith(inputFile.getAbsolutePath())) {
- // ok file is inside a directory type input folder.
- // check if we need to check this type of file, and if yes, check it.
- if (input.checksForModification(prereq)) {
- if (prereq.lastModified() > oldestTarget) {
- if (DEBUG) {
- System.out.println(
- "UPDATED FILE: " + prereq.getAbsolutePath());
- }
- return DependencyStatus.UPDATED_FILE;
- }
- }
- }
- } else {
- // this is a file input path, we must check if the match is exact.
- if (prereq.equals(inputFile)) {
- if (input.checksForModification(prereq)) {
- if (prereq.lastModified() > oldestTarget) {
- if (DEBUG) {
- System.out.println(
- "UPDATED FILE: " + prereq.getAbsolutePath());
- }
- return DependencyStatus.UPDATED_FILE;
- }
- }
- }
- }
- }
- } else {
- // no input? we consider all files.
- if (prereq.lastModified() > oldestTarget) {
- if (DEBUG) {
- System.out.println("UPDATED FILE: " + prereq.getAbsolutePath());
- }
- return DependencyStatus.UPDATED_FILE;
- }
- }
- }
-
- // If we get this far, then all our prereq are okay
- return DependencyStatus.NONE;
- }
-
- /**
- * Check all the target files we know about to make sure they're still there
- * @return true if any of the target files are missing.
- */
- private boolean missingTargetFile() {
- // Loop through our target files and make sure they still exist
- for (File target : mTargets) {
- if (target.exists() == false) {
- return true;
- }
- }
- // If we get this far, then all our targets are okay
- return false;
- }
-
- /**
- * Returns the earliest modification time stamp from all the output targets. If there
- * are no known target, the dependency file time stamp is returned.
- */
- private long getOutputLastModified() {
- // Find the oldest target
- long oldestTarget = Long.MAX_VALUE;
- // if there's no output, then compare to the time of the dependency file.
- if (mTargets.size() == 0) {
- oldestTarget = mDepFileLastModified;
- } else {
- for (File target : mTargets) {
- if (target.lastModified() < oldestTarget) {
- oldestTarget = target.lastModified();
- }
- }
- }
-
- return oldestTarget;
- }
-
- /**
- * Reads and returns the content of a text file.
- * @param file the file to read
- * @return null if the file could not be read
- */
- private static List<String> readFile(File file) {
- try {
- return Files.readLines(file, Charsets.UTF_8);
- } catch (IOException e) {
- // return null below
- }
-
- return null;
- }
-}
diff --git a/anttasks/src/com/android/ant/DependencyHelper.java b/anttasks/src/com/android/ant/DependencyHelper.java
deleted file mode 100644
index b1797ad..0000000
--- a/anttasks/src/com/android/ant/DependencyHelper.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.SdkConstants;
-import com.android.annotations.Nullable;
-import com.android.io.FolderWrapper;
-import com.android.sdklib.build.JarListSanitizer;
-import com.android.sdklib.build.JarListSanitizer.DifferentLibException;
-import com.android.sdklib.build.JarListSanitizer.Sha1Exception;
-import com.android.sdklib.internal.project.IPropertySource;
-import com.android.sdklib.internal.project.ProjectProperties;
-import com.android.sdklib.internal.project.ProjectProperties.PropertyType;
-
-import org.apache.tools.ant.BuildException;
-
-import java.io.File;
-import java.io.FilenameFilter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-/**
- * Helper class to manage dependency for projects.
- *
- */
-public class DependencyHelper {
-
- private final boolean mVerbose;
- private final File mProjectFolder;
- private final IPropertySource mProperties;
- private final List<File> mLibraries = new ArrayList<File>();
-
- /**
- * A Library Processor. Used in {@link DependencyHelper#processLibraries(LibraryProcessor)}
- *
- */
- protected interface LibraryProcessor {
- void processLibrary(String libRootPath);
- }
-
- /**
- * Advanced version of the {@link LibraryProcessor} that provides the library properties
- * to the processor.
- */
- public static abstract class AdvancedLibraryProcessor implements LibraryProcessor {
-
- public abstract void processLibrary(String libRootPath, IPropertySource properties);
-
- @Override
- public final void processLibrary(String libRootPath) {
- ProjectProperties properties = TaskHelper.getProperties(libRootPath);
-
- processLibrary(libRootPath, properties);
- }
- }
-
- /**
- * Implementation of {@link AdvancedLibraryProcessor} that builds a list of sanitized list
- * of 3rd party jar files from all the Library Projects.
- */
- public static class JarProcessor extends AdvancedLibraryProcessor {
-
- private final List<File> mJars = new ArrayList<File>();
-
- private final FilenameFilter mFilter = new FilenameFilter() {
- @Override
- public boolean accept(File dir, String name) {
- return name.toLowerCase(Locale.US).endsWith(".jar");
- }
- };
-
- public List<File> getJars() {
- return mJars;
- }
-
- public FilenameFilter getFilter() {
- return mFilter;
- }
-
- @Override
- public void processLibrary(String libRootPath, IPropertySource properties) {
- // get the library output
- // FIXME: support renamed folder.
- mJars.add(new File(libRootPath + "/" + SdkConstants.FD_OUTPUT +
- "/" + SdkConstants.FN_CLASSES_JAR));
-
- // Get the 3rd party jar files.
- // FIXME: support renamed folder.
- File libsFolder = new File(libRootPath, SdkConstants.FD_NATIVE_LIBS);
- File[] jarFiles = libsFolder.listFiles(mFilter);
- if (jarFiles != null) {
- for (File jarFile : jarFiles) {
- mJars.add(jarFile);
- }
- }
- }
- }
-
-
- public static List<File> sanitizePaths(File projectFolder, IPropertySource properties,
- List<File> paths) {
- // first get the non-files.
- List<File> results = new ArrayList<File>();
- for (int i = 0 ; i < paths.size() ;) {
- File f = paths.get(i);
- // TEMP WORKAROUND: ignore classes.jar as all the output of libraries are
- // called the same (in Ant) but are not actually the same jar file.
- // TODO: Be aware of library output vs. regular jar dependency.
- if (f.isFile() && f.getName().equals(SdkConstants.FN_CLASSES_JAR) == false) {
- i++;
- } else {
- results.add(f);
- paths.remove(i);
- }
- }
-
-
- File outputFile = new File(projectFolder, getOutDir(properties));
- JarListSanitizer sanitizer = new JarListSanitizer(outputFile);
-
- try {
- results.addAll(sanitizer.sanitize(paths));
- } catch (DifferentLibException e) {
- String[] details = e.getDetails();
- for (String s : details) {
- System.err.println(s);
- }
- throw new BuildException(e.getMessage(), e);
- } catch (Sha1Exception e) {
- throw new BuildException(
- "Failed to compute sha1 for " + e.getJarFile().getAbsolutePath(), e);
- }
-
- return results;
- }
-
- /**
- *
- * @param projectFolder the project root folder.
- */
- public DependencyHelper(File projectFolder, boolean verbose) {
- mProjectFolder = projectFolder;
- mVerbose = verbose;
-
- mProperties = TaskHelper.getProperties(projectFolder.getAbsolutePath());
-
- init(projectFolder);
- }
-
- /**
- *
- * @param projectFolder the project root folder.
- * @param source an {@link IPropertySource} that can provide the project properties values.
- */
- public DependencyHelper(File projectFolder, IPropertySource properties, boolean verbose) {
- mProjectFolder = projectFolder;
- mProperties = properties;
- mVerbose = verbose;
-
- init(projectFolder);
- }
-
- private void init(File projectFolder) {
- // get the top level list of library dependencies.
- List<File> topLevelLibraries = getDirectDependencies(projectFolder, mProperties);
-
- // process the libraries in case they depend on other libraries.
- resolveFullLibraryDependencies(topLevelLibraries, mLibraries);
- }
-
- public List<File> getLibraries() {
- return mLibraries;
- }
-
- public int getLibraryCount() {
- return mLibraries.size();
- }
-
- public String getProperty(String name) {
- return mProperties.getProperty(name);
- }
-
- public void processLibraries(@Nullable LibraryProcessor processor) {
- // use that same order to process the libraries.
- for (File library : mLibraries) {
- // get the root path.
- String libRootPath = library.getAbsolutePath();
- if (mVerbose) {
- System.out.println(libRootPath);
- }
-
- if (processor != null) {
- processor.processLibrary(libRootPath);
- }
- }
- }
-
- public List<File> sanitizePaths(List<File> paths) {
- return sanitizePaths(mProjectFolder, mProperties, paths);
- }
-
- public String getOutDir() {
- return getOutDir(mProperties);
- }
-
-
- /**
- * Returns the top level library dependencies of a given <var>source</var> representing a
- * project properties.
- * @param baseFolder the base folder of the project (to resolve relative paths)
- * @param properties a source of project properties.
- */
- private List<File> getDirectDependencies(File baseFolder, IPropertySource properties) {
- ArrayList<File> libraries = new ArrayList<File>();
-
- // first build the list. they are ordered highest priority first.
- int index = 1;
- while (true) {
- String propName = ProjectProperties.PROPERTY_LIB_REF + Integer.toString(index++);
- String rootPath = properties.getProperty(propName);
-
- if (rootPath == null) {
- break;
- }
-
- try {
- File library = new File(baseFolder, rootPath).getCanonicalFile();
-
- // check for validity
- File projectProp = new File(library, PropertyType.PROJECT.getFilename());
- if (projectProp.isFile() == false) {
- // error!
- throw new BuildException(String.format(
- "%1$s resolve to a path with no %2$s file for project %3$s", rootPath,
- PropertyType.PROJECT.getFilename(), baseFolder.getAbsolutePath()));
- }
-
- if (libraries.contains(library) == false) {
- if (mVerbose) {
- System.out.println(String.format("%1$s: %2$s => %3$s",
- baseFolder.getAbsolutePath(), rootPath, library.getAbsolutePath()));
- }
-
- libraries.add(library);
- }
- } catch (IOException e) {
- throw new BuildException("Failed to resolve library path: " + rootPath, e);
- }
- }
-
- return libraries;
- }
-
- /**
- * Resolves a given list of libraries, finds out if they depend on other libraries, and
- * returns a full list of all the direct and indirect dependencies in the proper order (first
- * is higher priority when calling aapt).
- * @param inLibraries the libraries to resolve
- * @param outLibraries where to store all the libraries.
- */
- private void resolveFullLibraryDependencies(List<File> inLibraries, List<File> outLibraries) {
- // loop in the inverse order to resolve dependencies on the libraries, so that if a library
- // is required by two higher level libraries it can be inserted in the correct place
- for (int i = inLibraries.size() - 1 ; i >= 0 ; i--) {
- File library = inLibraries.get(i);
-
- // get the default.property file for it
- final ProjectProperties projectProp = ProjectProperties.load(
- new FolderWrapper(library), PropertyType.PROJECT);
-
- // get its libraries
- List<File> dependencies = getDirectDependencies(library, projectProp);
-
- // resolve the dependencies for those libraries
- resolveFullLibraryDependencies(dependencies, outLibraries);
-
- // and add the current one (if needed) in front (higher priority)
- if (outLibraries.contains(library) == false) {
- outLibraries.add(0, library);
- }
- }
- }
-
- private static String getOutDir(IPropertySource properties) {
- String bin = properties.getProperty("out.dir");
- if (bin == null) {
- return SdkConstants.FD_OUTPUT;
- }
-
- return bin;
- }
-
-}
diff --git a/anttasks/src/com/android/ant/DexExecTask.java b/anttasks/src/com/android/ant/DexExecTask.java
deleted file mode 100644
index e33da32..0000000
--- a/anttasks/src/com/android/ant/DexExecTask.java
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.google.common.hash.HashCode;
-import com.google.common.hash.HashFunction;
-import com.google.common.hash.Hashing;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.taskdefs.ExecTask;
-import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.resources.FileResource;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Custom task to execute dx while handling dependencies.
- */
-public class DexExecTask extends SingleDependencyTask {
-
- private String mExecutable;
- private String mOutput;
- private String mDexedLibs;
- private boolean mVerbose = false;
- private boolean mNoLocals = false;
- private boolean mForceJumbo = false;
- private boolean mDisableDexMerger = false;
- private List<Path> mPathInputs;
- private List<FileSet> mFileSetInputs;
-
-
- /**
- * Sets the value of the "executable" attribute.
- * @param executable the value.
- */
- public void setExecutable(Path executable) {
- mExecutable = TaskHelper.checkSinglePath("executable", executable);
- }
-
- /**
- * Sets the value of the "verbose" attribute.
- * @param verbose the value.
- */
- public void setVerbose(boolean verbose) {
- mVerbose = verbose;
- }
-
- /**
- * Sets the value of the "output" attribute.
- * @param output the value.
- */
- public void setOutput(Path output) {
- mOutput = TaskHelper.checkSinglePath("output", output);
- }
-
- public void setDexedLibs(Path dexedLibs) {
- mDexedLibs = TaskHelper.checkSinglePath("dexedLibs", dexedLibs);
- }
-
- /**
- * Sets the value of the "nolocals" attribute.
- * @param verbose the value.
- */
- public void setNoLocals(boolean nolocals) {
- mNoLocals = nolocals;
- }
-
- public void setForceJumbo(boolean forceJumbo) {
- mForceJumbo = forceJumbo;
- }
-
- public void setDisableDexMerger(boolean disableMerger) {
- mDisableDexMerger = disableMerger;
- }
-
- /**
- * Returns an object representing a nested <var>path</var> element.
- */
- public Object createPath() {
- if (mPathInputs == null) {
- mPathInputs = new ArrayList<Path>();
- }
-
- Path path = new Path(getProject());
- mPathInputs.add(path);
-
- return path;
- }
-
- /**
- * Returns an object representing a nested <var>path</var> element.
- */
- public Object createFileSet() {
- if (mFileSetInputs == null) {
- mFileSetInputs = new ArrayList<FileSet>();
- }
-
- FileSet fs = new FileSet();
- fs.setProject(getProject());
- mFileSetInputs.add(fs);
-
- return fs;
- }
-
-
- private void preDexLibraries(List<File> inputs) {
- if (mDisableDexMerger || inputs.size() == 1) {
- // only one input, no need to put a pre-dexed version, even if this path is
- // just a jar file (case for proguard'ed builds)
- return;
- }
-
- final int count = inputs.size();
- for (int i = 0 ; i < count; i++) {
- File input = inputs.get(i);
- if (input.isFile()) {
- // check if this libs needs to be pre-dexed
- String fileName = getDexFileName(input);
- File dexedLib = new File(mDexedLibs, fileName);
- String dexedLibPath = dexedLib.getAbsolutePath();
-
- if (dexedLib.isFile() == false ||
- dexedLib.lastModified() < input.lastModified()) {
-
- System.out.println(
- String.format("Pre-Dexing %1$s -> %2$s",
- input.getAbsolutePath(), fileName));
-
- if (dexedLib.isFile()) {
- dexedLib.delete();
- }
-
- runDx(input, dexedLibPath, false /*showInput*/);
- } else {
- System.out.println(
- String.format("Using Pre-Dexed %1$s <- %2$s",
- fileName, input.getAbsolutePath()));
- }
-
- // replace the input with the pre-dex libs.
- inputs.set(i, dexedLib);
- }
- }
- }
-
- private String getDexFileName(File inputFile) {
- // get the filename
- String name = inputFile.getName();
- // remove the extension
- int pos = name.lastIndexOf('.');
- if (pos != -1) {
- name = name.substring(0, pos);
- }
-
- // add a hash of the original file path
- HashFunction hashFunction = Hashing.md5();
- HashCode hashCode = hashFunction.hashString(inputFile.getAbsolutePath());
-
- return name + "-" + hashCode.toString() + ".jar";
- }
-
-
- @Override
- public void execute() throws BuildException {
-
- // get all input paths
- List<File> paths = new ArrayList<File>();
- if (mPathInputs != null) {
- for (Path pathList : mPathInputs) {
- for (String path : pathList.list()) {
- System.out.println("input: " + path);
- paths.add(new File(path));
- }
- }
- }
-
- if (mFileSetInputs != null) {
- for (FileSet fs : mFileSetInputs) {
- Iterator<?> iter = fs.iterator();
- while (iter.hasNext()) {
- FileResource fr = (FileResource) iter.next();
- System.out.println("input: " + fr.getFile().toString());
- paths.add(fr.getFile());
- }
- }
- }
-
- // pre dex libraries if needed
- preDexLibraries(paths);
-
- // figure out the path to the dependency file.
- String depFile = mOutput + ".d";
-
- // get InputPath with no extension restrictions
- List<InputPath> inputPaths = getInputPaths(paths, null /*extensionsToCheck*/,
- null /*factory*/);
-
- if (initDependencies(depFile, inputPaths) && dependenciesHaveChanged() == false) {
- System.out.println(
- "No new compiled code. No need to convert bytecode to dalvik format.");
- return;
- }
-
- System.out.println(String.format(
- "Converting compiled files and external libraries into %1$s...", mOutput));
-
- runDx(paths, mOutput, mVerbose /*showInputs*/);
-
- // generate the dependency file.
- generateDependencyFile(depFile, inputPaths, mOutput);
- }
-
- private void runDx(File input, String output, boolean showInputs) {
- runDx(Collections.singleton(input), output, showInputs);
- }
-
- private void runDx(Collection<File> inputs, String output, boolean showInputs) {
- ExecTask task = new ExecTask();
- task.setProject(getProject());
- task.setOwningTarget(getOwningTarget());
- task.setExecutable(mExecutable);
- task.setTaskName(getExecTaskName());
- task.setFailonerror(true);
-
- task.createArg().setValue("--dex");
-
- if (mNoLocals) {
- task.createArg().setValue("--no-locals");
- }
-
- if (mVerbose) {
- task.createArg().setValue("--verbose");
- }
-
- if (mForceJumbo) {
- task.createArg().setValue("--force-jumbo");
- }
-
- task.createArg().setValue("--output");
- task.createArg().setValue(output);
-
- for (File input : inputs) {
- String absPath = input.getAbsolutePath();
- if (showInputs) {
- System.out.println("Input: " + absPath);
- }
- task.createArg().setValue(absPath);
- }
-
- // execute it.
- task.execute();
- }
-
- @Override
- protected String getExecTaskName() {
- return "dx";
- }
-}
diff --git a/anttasks/src/com/android/ant/GetEmmaFilterTask.java b/anttasks/src/com/android/ant/GetEmmaFilterTask.java
deleted file mode 100644
index f449f8d..0000000
--- a/anttasks/src/com/android/ant/GetEmmaFilterTask.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-
-/**
- * Task building an emma filter to remove all build-only classes.
- *
- * Currently ignore:
- * app.package.R
- * app.package.R$*
- * app.package.Manifest
- * app.package.BuildConfig
- *
- */
-public class GetEmmaFilterTask extends Task {
-
- private static final String[] FILTER_CLASSES = new String[] {
- "R", "R$*", "Manifest", "BuildConfig"
- };
-
- private String mAppPackage;
- private String mLibraryPackagesRefId;
- private String mFilterOut;
-
-
- public void setAppPackage(String appPackage) {
- mAppPackage = appPackage;
- }
-
- public void setLibraryPackagesRefId(String libraryPackagesRefId) {
- mLibraryPackagesRefId = libraryPackagesRefId;
- }
-
- public void setFilterOut(String filterOut) {
- mFilterOut = filterOut;
- }
-
- @Override
- public void execute() throws BuildException {
- if (mAppPackage == null) {
- throw new BuildException("Missing attribute appPackage");
- }
- if (mLibraryPackagesRefId == null) {
- throw new BuildException("Missing attribute libraryPackagesRefId");
- }
- if (mFilterOut == null) {
- throw new BuildException("Missing attribute filterOut");
- }
-
- StringBuilder sb = new StringBuilder();
-
- String libraryPackagesValue = getProject().getProperty(mLibraryPackagesRefId);
-
- if (libraryPackagesValue != null && libraryPackagesValue.length() > 0) {
- // split the app packages.
- String[] libPackages = libraryPackagesValue.split(";");
-
- for (String libPackage : libPackages) {
- if (libPackage.length() > 0) {
- for (String filterClass : FILTER_CLASSES) {
- sb.append(libPackage).append('.').append(filterClass).append(',');
- }
- }
- }
- }
-
- // add the app package:
- final int count = FILTER_CLASSES.length;
- for (int i = 0 ; i < count ; i++) {
- sb.append(mAppPackage).append('.').append(FILTER_CLASSES[i]);
- if (i < count - 1) {
- sb.append(',');
- }
- }
-
- getProject().setProperty(mFilterOut, sb.toString());
- }
-}
diff --git a/anttasks/src/com/android/ant/GetLibraryPathTask.java b/anttasks/src/com/android/ant/GetLibraryPathTask.java
deleted file mode 100644
index 813574e..0000000
--- a/anttasks/src/com/android/ant/GetLibraryPathTask.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.android.ant.DependencyHelper.AdvancedLibraryProcessor;
-import com.android.ant.DependencyHelper.LibraryProcessor;
-import com.android.sdklib.internal.project.IPropertySource;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.Path.PathElement;
-
-import java.io.File;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Task to get the list of Library Project paths for either the current project or any given
- * project.
- *
- */
-public class GetLibraryPathTask extends Task {
-
- private String mProjectPath;
- private String mLibraryFolderPathOut;
- private String mLeaf;
- private boolean mVerbose = false;
-
- private static class LeafProcessor extends AdvancedLibraryProcessor {
- private final static Pattern PH = Pattern.compile("^\\@\\{(.*)\\}$");
-
- private Path mPath;
- private final String[] mLeafSegments;
-
- LeafProcessor(Project antProject, String leaf) {
- mPath = new Path(antProject);
- mLeafSegments = leaf.split("/");
- }
-
- @Override
- public void processLibrary(String libRootPath, IPropertySource properties) {
- StringBuilder sb = new StringBuilder(libRootPath);
- for (String segment : mLeafSegments) {
- sb.append('/');
-
- Matcher m = PH.matcher(segment);
- if (m.matches()) {
- String value = properties.getProperty(m.group(1));
- if (value == null) {
- value = TaskHelper.getDefault(m.group(1));
- }
- if (value == null) {
- throw new BuildException(
- "Failed to resolve '" + m.group(1) + "' for project "
- + libRootPath);
- }
- sb.append(value);
- } else {
- sb.append(segment);
- }
- }
-
- PathElement element = mPath.createPathElement();
- element.setPath(sb.toString());
- }
-
- @NonNull public Path getPath() {
- return mPath;
- }
- }
-
- public void setProjectPath(String projectPath) {
- mProjectPath = projectPath;
- }
-
- public void setLibraryFolderPathOut(String libraryFolderPathOut) {
- mLibraryFolderPathOut = libraryFolderPathOut;
- }
-
- protected String getLibraryFolderPathOut() {
- return mLibraryFolderPathOut;
- }
-
- public void setLeaf(String leaf) {
- mLeaf = leaf;
- }
-
- /**
- * Sets the value of the "verbose" attribute.
- * @param verbose the value.
- */
- public void setVerbose(boolean verbose) {
- mVerbose = verbose;
- }
-
- protected boolean getVerbose() {
- return mVerbose;
- }
-
- @Override
- public void execute() throws BuildException {
- if (mLibraryFolderPathOut == null) {
- throw new BuildException("Missing attribute libraryFolderPathOut");
- }
-
- LibraryProcessor processor = null;
-
- if (mLeaf != null) {
- // we need a custom processor
- processor = new LeafProcessor(getProject(), mLeaf);
- }
-
- if (mProjectPath == null) {
- execute(processor);
- } else {
- DependencyHelper helper = new DependencyHelper(new File(mProjectPath), mVerbose);
-
- execute(helper, processor);
- }
- }
-
- /**
- * Executes the processor on the current project.
- * @param processor
- * @throws BuildException
- */
- protected void execute(@Nullable LibraryProcessor processor) throws BuildException {
- final Project antProject = getProject();
-
- DependencyHelper helper = new DependencyHelper(antProject.getBaseDir(),
- new IPropertySource() {
- @Override
- public String getProperty(String name) {
- return antProject.getProperty(name);
- }
-
- @Override
- public void debugPrint() {
- }
- },
- mVerbose);
-
- execute(helper, processor);
- }
-
- /**
- * Executes the processor using a given DependencyHelper.
- * @param helper
- * @param processor
- * @throws BuildException
- */
- private void execute(@NonNull DependencyHelper helper, @Nullable LibraryProcessor processor)
- throws BuildException {
-
- final Project antProject = getProject();
-
- System.out.println("Library dependencies:");
-
- Path path = new Path(antProject);
-
- if (helper.getLibraryCount() > 0) {
- System.out.println("\n------------------\nOrdered libraries:");
-
- helper.processLibraries(processor);
-
- if (mLibraryFolderPathOut != null) {
- if (mLeaf == null) {
- // Fill a Path object with all the libraries in reverse order.
- // This is important so that compilation of libraries happens
- // in the reverse order.
- List<File> libraries = helper.getLibraries();
-
- for (int i = libraries.size() - 1 ; i >= 0; i--) {
- File library = libraries.get(i);
- PathElement element = path.createPathElement();
- element.setPath(library.getAbsolutePath());
- }
-
- } else {
- path = ((LeafProcessor) processor).getPath();
- }
- }
- } else {
- System.out.println("No Libraries");
- }
-
- antProject.addReference(mLibraryFolderPathOut, path);
- }
-}
diff --git a/anttasks/src/com/android/ant/GetProjectPathsTask.java b/anttasks/src/com/android/ant/GetProjectPathsTask.java
deleted file mode 100644
index 42494ab..0000000
--- a/anttasks/src/com/android/ant/GetProjectPathsTask.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.sdklib.internal.project.ProjectProperties;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-
-import java.io.File;
-
-public class GetProjectPathsTask extends Task {
-
- private String mProjectPath;
- private String mBinName;
- private String mSrcName;
-
- public void setProjectPath(String projectPath) {
- mProjectPath = projectPath;
- }
-
- public void setBinOut(String binName) {
- mBinName = binName;
- }
-
- public void setSrcOut(String srcName) {
- mSrcName = srcName;
- }
-
- @Override
- public void execute() throws BuildException {
- if (mProjectPath == null) {
- throw new BuildException("Missing attribute projectPath");
- }
-
- ProjectProperties props = TaskHelper.getProperties(mProjectPath);
-
- if (mBinName != null) {
- handleProp(props, "out.dir", mBinName);
- }
-
- if (mSrcName != null) {
- handleProp(props, "source.dir", mSrcName);
- }
-
- }
-
- private void handleProp(ProjectProperties props, String inName, String outName) {
- String value = props.getProperty(inName);
- if (value == null) {
- value = TaskHelper.getDefault(inName);
- }
- getProject().setProperty(outName, new File(mProjectPath, value).getAbsolutePath());
-
- }
-}
diff --git a/anttasks/src/com/android/ant/GetTargetTask.java b/anttasks/src/com/android/ant/GetTargetTask.java
deleted file mode 100644
index d79ffee..0000000
--- a/anttasks/src/com/android/ant/GetTargetTask.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.SdkConstants;
-import com.android.annotations.NonNull;
-import com.android.sdklib.AndroidVersion;
-import com.android.sdklib.IAndroidTarget;
-import com.android.sdklib.IAndroidTarget.IOptionalLibrary;
-import com.android.sdklib.SdkManager;
-import com.android.sdklib.internal.project.ProjectProperties;
-import com.android.utils.ILogger;
-import com.android.xml.AndroidManifest;
-import com.android.xml.AndroidXPathFactory;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.Path.PathElement;
-import org.xml.sax.InputSource;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.util.ArrayList;
-import java.util.HashSet;
-
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathExpressionException;
-
-/**
- * Task to resolve the target of the current Android project.
- *
- * Out params:
- * <code>bootClassPathOut</code>: The boot class path of the project.
- *
- * <code>androidJarFileOut</code>: the android.jar used by the project.
- *
- * <code>androidAidlFileOut</code>: the framework.aidl used by the project.
- *
- * <code>targetApiOut</code>: the build API level.
- *
- * <code>minSdkVersionOut</code>: the app's minSdkVersion.
- *
- */
-public class GetTargetTask extends Task {
-
- private String mBootClassPathOut;
- private String mAndroidJarFileOut;
- private String mAndroidAidlFileOut;
- private String mTargetApiOut;
- private String mMinSdkVersionOut;
-
- public void setBootClassPathOut(String bootClassPathOut) {
- mBootClassPathOut = bootClassPathOut;
- }
-
- public void setAndroidJarFileOut(String androidJarFileOut) {
- mAndroidJarFileOut = androidJarFileOut;
- }
-
- public void setAndroidAidlFileOut(String androidAidlFileOut) {
- mAndroidAidlFileOut = androidAidlFileOut;
- }
-
- public void setTargetApiOut(String targetApiOut) {
- mTargetApiOut = targetApiOut;
- }
-
- public void setMinSdkVersionOut(String minSdkVersionOut) {
- mMinSdkVersionOut = minSdkVersionOut;
- }
-
- @Override
- public void execute() throws BuildException {
- if (mBootClassPathOut == null) {
- throw new BuildException("Missing attribute bootClassPathOut");
- }
- if (mAndroidJarFileOut == null) {
- throw new BuildException("Missing attribute androidJarFileOut");
- }
- if (mAndroidAidlFileOut == null) {
- throw new BuildException("Missing attribute androidAidlFileOut");
- }
- if (mTargetApiOut == null) {
- throw new BuildException("Missing attribute targetApiOut");
- }
- if (mMinSdkVersionOut == null) {
- throw new BuildException("Missing attribute mMinSdkVersionOut");
- }
-
- Project antProject = getProject();
-
- // get the SDK location
- File sdkDir = TaskHelper.getSdkLocation(antProject);
-
- // get the target property value
- String targetHashString = antProject.getProperty(ProjectProperties.PROPERTY_TARGET);
-
- if (targetHashString == null) {
- throw new BuildException("Android Target is not set.");
- }
-
- // load up the sdk targets.
- final ArrayList<String> messages = new ArrayList<String>();
- SdkManager manager = SdkManager.createManager(sdkDir.getPath(), new ILogger() {
- @Override
- public void error(Throwable t, String errorFormat, Object... args) {
- if (errorFormat != null) {
- messages.add(String.format("Error: " + errorFormat, args));
- }
- if (t != null) {
- messages.add("Error: " + t.getMessage());
- }
- }
-
- @Override
- public void info(@NonNull String msgFormat, Object... args) {
- messages.add(String.format(msgFormat, args));
- }
-
- @Override
- public void verbose(@NonNull String msgFormat, Object... args) {
- info(msgFormat, args);
- }
-
- @Override
- public void warning(@NonNull String warningFormat, Object... args) {
- messages.add(String.format("Warning: " + warningFormat, args));
- }
- });
-
- if (manager == null) {
- // since we failed to parse the SDK, lets display the parsing output.
- for (String msg : messages) {
- System.out.println(msg);
- }
- throw new BuildException("Failed to parse SDK content.");
- }
-
- // resolve it
- IAndroidTarget androidTarget = manager.getTargetFromHashString(targetHashString);
-
- if (androidTarget == null) {
- throw new BuildException(String.format(
- "Unable to resolve project target '%s'", targetHashString));
- }
-
- // display the project info
- System.out.println( "Project Target: " + androidTarget.getName());
- if (androidTarget.isPlatform() == false) {
- System.out.println("Vendor: " + androidTarget.getVendor());
- System.out.println("Platform Version: " + androidTarget.getVersionName());
- }
- System.out.println( "API level: " + androidTarget.getVersion().getApiString());
-
- antProject.setProperty(mTargetApiOut,
- Integer.toString(androidTarget.getVersion().getApiLevel()));
-
- // always check the manifest minSdkVersion.
- checkManifest(antProject, androidTarget.getVersion());
-
- // sets up the properties to find android.jar/framework.aidl/target tools
- String androidJar = androidTarget.getPath(IAndroidTarget.ANDROID_JAR);
- antProject.setProperty(mAndroidJarFileOut, androidJar);
-
- String androidAidl = androidTarget.getPath(IAndroidTarget.ANDROID_AIDL);
- antProject.setProperty(mAndroidAidlFileOut, androidAidl);
-
- // sets up the boot classpath
-
- // create the Path object
- Path bootclasspath = new Path(antProject);
-
- // create a PathElement for the framework jar
- PathElement element = bootclasspath.createPathElement();
- element.setPath(androidJar);
-
- // create PathElement for each optional library.
- IOptionalLibrary[] libraries = androidTarget.getOptionalLibraries();
- if (libraries != null) {
- HashSet<String> visitedJars = new HashSet<String>();
- for (IOptionalLibrary library : libraries) {
- String jarPath = library.getJarPath();
- if (visitedJars.contains(jarPath) == false) {
- visitedJars.add(jarPath);
-
- element = bootclasspath.createPathElement();
- element.setPath(jarPath);
- }
- }
- }
-
- // sets the path in the project with a reference
- antProject.addReference(mBootClassPathOut, bootclasspath);
- }
-
- /**
- * Checks the manifest <code>minSdkVersion</code> attribute.
- * @param antProject the ant project
- * @param androidVersion the version of the platform the project is compiling against.
- */
- private void checkManifest(Project antProject, AndroidVersion androidVersion) {
- try {
- File manifest = new File(antProject.getBaseDir(), SdkConstants.FN_ANDROID_MANIFEST_XML);
-
- XPath xPath = AndroidXPathFactory.newXPath();
-
- // check the package name.
- String value = xPath.evaluate(
- "/" + AndroidManifest.NODE_MANIFEST +
- "/@" + AndroidManifest.ATTRIBUTE_PACKAGE,
- new InputSource(new FileInputStream(manifest)));
- if (value != null) { // aapt will complain if it's missing.
- // only need to check that the package has 2 segments
- if (value.indexOf('.') == -1) {
- throw new BuildException(String.format(
- "Application package '%1$s' must have a minimum of 2 segments.",
- value));
- }
- }
-
- // check the minSdkVersion value
- value = xPath.evaluate(
- "/" + AndroidManifest.NODE_MANIFEST +
- "/" + AndroidManifest.NODE_USES_SDK +
- "/@" + AndroidXPathFactory.DEFAULT_NS_PREFIX + ":" +
- AndroidManifest.ATTRIBUTE_MIN_SDK_VERSION,
- new InputSource(new FileInputStream(manifest)));
-
- if (androidVersion.isPreview()) {
- // in preview mode, the content of the minSdkVersion must match exactly the
- // platform codename.
- String codeName = androidVersion.getCodename();
- if (codeName.equals(value) == false) {
- throw new BuildException(String.format(
- "For '%1$s' SDK Preview, attribute minSdkVersion in AndroidManifest.xml must be '%1$s' (current: %2$s)",
- codeName, value));
- }
-
- // set the minSdkVersion to the previous API level (which is actually the value in
- // androidVersion.)
- antProject.setProperty(mMinSdkVersionOut,
- Integer.toString(androidVersion.getApiLevel()));
-
- } else if (value.length() > 0) {
- // for normal platform, we'll only display warnings if the value is lower or higher
- // than the target api level.
- // First convert to an int.
- int minSdkValue = -1;
- try {
- minSdkValue = Integer.parseInt(value);
- } catch (NumberFormatException e) {
- // looks like it's not a number: error!
- throw new BuildException(String.format(
- "Attribute %1$s in AndroidManifest.xml must be an Integer!",
- AndroidManifest.ATTRIBUTE_MIN_SDK_VERSION));
- }
-
- // set the minSdkVersion to the value
- antProject.setProperty(mMinSdkVersionOut, value);
-
- int projectApiLevel = androidVersion.getApiLevel();
- if (minSdkValue > androidVersion.getApiLevel()) {
- System.out.println(String.format(
- "WARNING: Attribute %1$s in AndroidManifest.xml (%2$d) is higher than the project target API level (%3$d)",
- AndroidManifest.ATTRIBUTE_MIN_SDK_VERSION,
- minSdkValue, projectApiLevel));
- }
- } else {
- // no minSdkVersion? display a warning
- System.out.println(
- "WARNING: No minSdkVersion value set. Application will install on all Android versions.");
-
- // set the target api to 1
- antProject.setProperty(mMinSdkVersionOut, "1");
- }
-
- } catch (XPathExpressionException e) {
- throw new BuildException(e);
- } catch (FileNotFoundException e) {
- throw new BuildException(e);
- }
- }
-}
diff --git a/anttasks/src/com/android/ant/GetTypeTask.java b/anttasks/src/com/android/ant/GetTypeTask.java
deleted file mode 100644
index 143bc35..0000000
--- a/anttasks/src/com/android/ant/GetTypeTask.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.SdkConstants;
-import com.android.sdklib.internal.project.ProjectProperties;
-import com.android.xml.AndroidManifest;
-import com.android.xml.AndroidXPathFactory;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.xml.sax.InputSource;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathExpressionException;
-
-/**
- * Task to query the type of the current project.
- *
- * Out params:
- *
- * <code>projectTypeOut</code>: String value containing the type of the project. Possible values
- * are 'app', 'library', 'test', 'test-app'
- *
- */
-public class GetTypeTask extends Task {
-
- private String mProjectTypeOut;
-
- public void setProjectTypeOut(String projectTypeOut) {
- mProjectTypeOut = projectTypeOut;
- }
-
- @Override
- public void execute() throws BuildException {
- if (mProjectTypeOut == null) {
- throw new BuildException("Missing attribute projectTypeOut");
- }
-
- Project antProject = getProject();
-
- String libraryProp = antProject.getProperty(ProjectProperties.PROPERTY_LIBRARY);
- if (libraryProp != null) {
- if (Boolean.valueOf(libraryProp).booleanValue()) {
- System.out.println("Project Type: Android Library");
-
- antProject.setProperty(mProjectTypeOut, "library");
- return;
- }
- }
-
- if (antProject.getProperty(ProjectProperties.PROPERTY_TESTED_PROJECT) != null) {
- System.out.println("Project Type: Test Application");
-
- antProject.setProperty(mProjectTypeOut, "test");
- return;
- }
-
- // we also need to check if the Manifest doesn't have some instrumentation which
- // means the app is a self-contained test project.
- try {
- File manifest = new File(antProject.getBaseDir(), SdkConstants.FN_ANDROID_MANIFEST_XML);
- XPath xPath = AndroidXPathFactory.newXPath();
-
- // check the present of /manifest/instrumentation/
- String value = xPath.evaluate(
- "/" + AndroidManifest.NODE_MANIFEST +
- "/" + AndroidManifest.NODE_INSTRUMENTATION +
- "/@" + AndroidXPathFactory.DEFAULT_NS_PREFIX +
- ":" + AndroidManifest.ATTRIBUTE_TARGET_PACKAGE,
- new InputSource(new FileInputStream(manifest)));
-
- if (value != null && value.length() > 0) {
- System.out.println("Project Type: Self-Tested Application");
-
- antProject.setProperty(mProjectTypeOut, "test-app");
- return;
- }
- } catch (XPathExpressionException e) {
- throw new BuildException(e);
- } catch (FileNotFoundException e) {
- throw new BuildException(e);
- }
-
- // default case
- System.out.println("Project Type: Application");
-
- antProject.setProperty(mProjectTypeOut, "app");
- }
-}
diff --git a/anttasks/src/com/android/ant/GetUiTargetTask.java b/anttasks/src/com/android/ant/GetUiTargetTask.java
deleted file mode 100644
index e45d2bc..0000000
--- a/anttasks/src/com/android/ant/GetUiTargetTask.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.annotations.NonNull;
-import com.android.sdklib.IAndroidTarget;
-import com.android.sdklib.IAndroidTarget.IOptionalLibrary;
-import com.android.sdklib.SdkManager;
-import com.android.sdklib.internal.project.ProjectProperties;
-import com.android.utils.ILogger;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.Path.PathElement;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.HashSet;
-
-/**
- * Task to resolve the target of the current Android uiautomator project.
- *
- * Out params:
- * <code>compileClassPathOut</code>: The compile class path for the project.
- */
-public class GetUiTargetTask extends Task {
-
- private String mCompileClassPathOut;
-
- public void setCompileClassPathOut(String compileClassPathOut) {
- mCompileClassPathOut = compileClassPathOut;
- }
-
- @Override
- public void execute() throws BuildException {
- if (mCompileClassPathOut == null) {
- throw new BuildException("Missing attribute compileClassPathOut");
- }
-
- Project antProject = getProject();
-
- // get the SDK location
- File sdkDir = TaskHelper.getSdkLocation(antProject);
-
- // get the target property value
- String targetHashString = antProject.getProperty(ProjectProperties.PROPERTY_TARGET);
-
- if (targetHashString == null) {
- throw new BuildException("Android Target is not set.");
- }
-
- // load up the sdk targets.
- final ArrayList<String> messages = new ArrayList<String>();
- SdkManager manager = SdkManager.createManager(sdkDir.getPath(), new ILogger() {
- @Override
- public void error(Throwable t, String errorFormat, Object... args) {
- if (errorFormat != null) {
- messages.add(String.format("Error: " + errorFormat, args));
- }
- if (t != null) {
- messages.add("Error: " + t.getMessage());
- }
- }
-
- @Override
- public void info(@NonNull String msgFormat, Object... args) {
- messages.add(String.format(msgFormat, args));
- }
-
- @Override
- public void verbose(@NonNull String msgFormat, Object... args) {
- info(msgFormat, args);
- }
-
- @Override
- public void warning(@NonNull String warningFormat, Object... args) {
- messages.add(String.format("Warning: " + warningFormat, args));
- }
- });
-
- if (manager == null) {
- // since we failed to parse the SDK, lets display the parsing output.
- for (String msg : messages) {
- System.out.println(msg);
- }
- throw new BuildException("Failed to parse SDK content.");
- }
-
- // resolve it
- IAndroidTarget androidTarget = manager.getTargetFromHashString(targetHashString);
-
- if (androidTarget == null) {
- throw new BuildException(String.format(
- "Unable to resolve project target '%s'", targetHashString));
- }
-
- // display the project info
- System.out.println( "Project Target: " + androidTarget.getName());
- if (androidTarget.isPlatform() == false) {
- System.out.println("Vendor: " + androidTarget.getVendor());
- System.out.println("Platform Version: " + androidTarget.getVersionName());
- }
- System.out.println( "API level: " + androidTarget.getVersion().getApiString());
-
- if (androidTarget.getVersion().getApiLevel() < 16) {
- throw new BuildException("UI Automator requires API 16");
- }
-
- // sets up the properties to find android.jar/framework.aidl/target tools
- String androidJar = androidTarget.getPath(IAndroidTarget.ANDROID_JAR);
- String uiAutomatorJar = androidTarget.getPath(IAndroidTarget.UI_AUTOMATOR_JAR);
-
- // sets up the boot classpath
-
- // create the Path object
- Path compileclasspath = new Path(antProject);
-
- // create a PathElement for the framework jars
- PathElement element = compileclasspath.createPathElement();
- element.setPath(androidJar);
-
- element = compileclasspath.createPathElement();
- element.setPath(uiAutomatorJar);
-
- // create PathElement for each optional library.
- IOptionalLibrary[] libraries = androidTarget.getOptionalLibraries();
- if (libraries != null) {
- HashSet<String> visitedJars = new HashSet<String>();
- for (IOptionalLibrary library : libraries) {
- String jarPath = library.getJarPath();
- if (visitedJars.contains(jarPath) == false) {
- visitedJars.add(jarPath);
-
- element = compileclasspath.createPathElement();
- element.setPath(jarPath);
- }
- }
- }
-
- // sets the path in the project with a reference
- antProject.addReference(mCompileClassPathOut, compileclasspath);
- }
-}
diff --git a/anttasks/src/com/android/ant/IfElseTask.java b/anttasks/src/com/android/ant/IfElseTask.java
deleted file mode 100644
index f34e486..0000000
--- a/anttasks/src/com/android/ant/IfElseTask.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.taskdefs.Sequential;
-import org.apache.tools.ant.taskdefs.condition.And;
-
-/**
- * If (condition) then: {@link Sequential} else: {@link Sequential}.
- *
- * In XML:
- * <if condition="${prop with a boolean value}">
- * <then>
- * </then>
- * <else>
- * </else>
- * </if>
- *
- * or
- *
- * <if>
- * <condition>
- * ...
- * </condition>
- * <then>
- * </then>
- * <else>
- * </else>
- * </if>
- *
- * both <then> and <else> behave like <sequential>.
- * <condition> behaves like an <and> condition.
- *
- * The presence of both <then> and <else> is not required, but one of them must be present.
- * <if condition="${some.condition}">
- * <else>
- * </else>
- * </if>
- * is perfectly valid.
- *
- */
-public class IfElseTask extends Task {
-
- private boolean mCondition;
- private boolean mConditionIsSet = false;
- private And mAnd;
- private Sequential mThen;
- private Sequential mElse;
-
- /**
- * Sets the condition value
- */
- public void setCondition(boolean condition) {
- mCondition = condition;
- mConditionIsSet = true;
- }
-
- /**
- * Creates and returns the <condition> node which is basically a <and>.
- */
- public Object createCondition() {
- if (mConditionIsSet) {
- throw new BuildException("Cannot use both condition attribute and <condition> element");
- }
-
- mAnd = new And();
- mAnd.setProject(getProject());
- return mAnd;
- }
-
- /**
- * Creates and returns the <then> {@link Sequential}
- */
- public Object createThen() {
- mThen = new Sequential();
- return mThen;
- }
-
- /**
- * Creates and returns the <else> {@link Sequential}
- */
- public Object createElse() {
- mElse = new Sequential();
- return mElse;
- }
-
- @Override
- public void execute() throws BuildException {
- if (mConditionIsSet == false && mAnd == null) {
- throw new BuildException("condition attribute or element must be set.");
- }
-
- if (mAnd != null) {
- mCondition = mAnd.eval();
- }
-
- // need at least one.
- if (mThen == null && mElse == null) {
- throw new BuildException("Need at least <then> or <else>");
- }
-
- if (mCondition) {
- if (mThen != null) {
- mThen.execute();
- }
- } else {
- if (mElse != null) {
- mElse.execute();
- }
- }
- }
-}
diff --git a/anttasks/src/com/android/ant/InputPath.java b/anttasks/src/com/android/ant/InputPath.java
deleted file mode 100644
index 2299f07..0000000
--- a/anttasks/src/com/android/ant/InputPath.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import java.io.File;
-import java.util.Set;
-
-public class InputPath {
-
- private final File mFile;
- /**
- * A set of extensions. Only files with an extension in this set will
- * be considered for a modification check. All deleted/created files will still be
- * checked.
- */
- private final Set<String> mTouchedExtensions;
-
- public InputPath(File file) {
- this(file, null);
- }
-
- public InputPath(File file, Set<String> extensionsToCheck) {
- if (file == null) {
- throw new RuntimeException("File in InputPath(File) can't be null");
- }
- mFile = file;
- mTouchedExtensions = extensionsToCheck;
- }
-
- public File getFile() {
- return mFile;
- }
-
- /**
- * Returns whether this input path (likely actually a folder) must check this files for
- * modification (all files are checked for add/delete).
- *
- * This is configured by constructing the {@link InputPath} with additional restriction
- * parameters such as specific extensions.
- * @param file the file to check
- * @return true if the file must be checked for modification.
- */
- public boolean checksForModification(File file) {
- if (ignores(file)) {
- return false;
- }
-
- if (mTouchedExtensions != null &&
- mTouchedExtensions.contains(getExtension(file)) == false) {
- return false;
- }
-
- return true;
- }
-
- /**
- * Returns whether the InputPath ignores a given file or folder. If it is ignored then
- * the file (or folder) is not checked for any event (modification/add/delete).
- * If it's a folder, then it and its content are completely ignored.
- * @param file the file or folder to check
- * @return true if the file or folder are ignored.
- */
- public boolean ignores(File file) {
- // always ignore hidden files/folders.
- return file.getName().startsWith(".");
- }
-
- /**
- * Gets the extension (if present) on a file by looking at the filename
- * @param file the file to get the extension from
- * @return the extension if present, or the empty string if the filename doesn't have
- * and extension.
- */
- protected static String getExtension(File file) {
- return getExtension(file.getName());
- }
-
- /**
- * Gets the extension (if present) on a file by looking at the filename
- * @param fileName the filename to get the extension from
- * @return the extension if present, or the empty string if the filename doesn't have
- * and extension.
- */
- protected static String getExtension(String fileName) {
- int index = fileName.lastIndexOf('.');
- if (index == -1) {
- return "";
- }
- // Don't include the leading '.' in the extension
- return fileName.substring(index + 1);
- }
-
-}
diff --git a/anttasks/src/com/android/ant/LintExecTask.java b/anttasks/src/com/android/ant/LintExecTask.java
deleted file mode 100644
index 3d687cb..0000000
--- a/anttasks/src/com/android/ant/LintExecTask.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.taskdefs.ExecTask;
-import org.apache.tools.ant.types.Path;
-
-/**
- * Custom task to execute lint
- */
-public class LintExecTask extends ExecTask {
-
- private String mExecutable;
- private String mHtml;
- private String mXml;
- private Path mSourcePath;
- private Path mClassPath;
-
- /**
- * Sets the value of the "executable" attribute.
- * @param executable the value.
- */
- public void setExecutable(Path executable) {
- mExecutable = TaskHelper.checkSinglePath("executable", executable);
- }
-
- /** Sets the path where Java source code should be found */
- public void setSrc(Path path) {
- mSourcePath = path;
- }
-
- /** Sets the path where class files should be found */
- public void setClasspath(Path path) {
- mClassPath = path;
- }
-
- /**
- * Sets the value of the "html" attribute: a path to a file or directory name
- * where the HTML report should be written.
- *
- * @param html path to the html report
- */
- public void setHtml(Path html) {
- mHtml = TaskHelper.checkSinglePath("html", html);
- }
-
- /**
- * Sets the value of the "xml" attribute: a path to a file or directory name
- * where the XML report should be written.
- *
- * @param xml path to the xml report
- */
- public void setXml(Path xml) {
- mXml = TaskHelper.checkSinglePath("xml", xml);
- }
-
- @Override
- public void execute() throws BuildException {
-
- ExecTask task = new ExecTask();
- task.setProject(getProject());
- task.setOwningTarget(getOwningTarget());
- task.setExecutable(mExecutable);
- task.setTaskName("lint");
- task.setFailonerror(true);
-
- task.createArg().setValue("--text");
- task.createArg().setValue("stdout");
-
- if (mHtml != null) {
- task.createArg().setValue("--html");
- task.createArg().setValue(mHtml);
- }
-
- if (mXml != null) {
- task.createArg().setValue("--xml");
- task.createArg().setValue(mXml);
- }
-
- if (mSourcePath != null) {
- task.createArg().setValue("--sources");
- task.createArg().setValue(mSourcePath.toString());
- }
-
- if (mClassPath != null) {
- task.createArg().setValue("--classpath");
- task.createArg().setValue(mClassPath.toString());
- }
-
- task.createArg().setValue(getProject().getBaseDir().getAbsolutePath());
- task.execute();
- }
-}
diff --git a/anttasks/src/com/android/ant/ManifestMergerTask.java b/anttasks/src/com/android/ant/ManifestMergerTask.java
deleted file mode 100644
index 6c53069..0000000
--- a/anttasks/src/com/android/ant/ManifestMergerTask.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.annotations.NonNull;
-import com.android.manifmerger.ICallback;
-import com.android.manifmerger.ManifestMerger;
-import com.android.manifmerger.MergerLog;
-import com.android.sdklib.IAndroidTarget;
-import com.android.sdklib.SdkManager;
-import com.android.sdklib.io.FileOp;
-import com.android.utils.StdLogger;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.types.Path;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-public class ManifestMergerTask extends SingleDependencyTask {
-
- private String mAppManifest;
- private String mOutManifest;
-
- private ArrayList<Path> mLibraryPaths;
- private boolean mEnabled = false;
-
- public void setAppManifest(Path appManifest) {
- mAppManifest = TaskHelper.checkSinglePath("appManifest", appManifest);
- }
-
- public void setOutManifest(Path outManifest) {
- mOutManifest = TaskHelper.checkSinglePath("outManifest", outManifest);
- }
-
- public void setEnabled(boolean enabled) {
- mEnabled = enabled;
- }
-
- /**
- * Returns an object representing a nested <var>library</var> element.
- */
- public Object createLibrary() {
- if (mLibraryPaths == null) {
- mLibraryPaths = new ArrayList<Path>();
- }
-
- Path path = new Path(getProject());
- mLibraryPaths.add(path);
-
- return path;
- }
-
- @Override
- public void execute() throws BuildException {
- if (mAppManifest == null) {
- throw new BuildException("Missing attribute appManifest");
- }
- if (mOutManifest == null) {
- throw new BuildException("Missing attribute outManifest");
- }
-
- // if we merge, then get the rest of the input paths.
- List<File> libraries = new ArrayList<File>();
- if (mLibraryPaths != null) {
- for (Path pathList : mLibraryPaths) {
- for (String path : pathList.list()) {
- libraries.add(new File(path));
- }
- }
- }
-
- // prepare input files
- ArrayList<File> allInputs = new ArrayList<File>(libraries.size() + 1);
-
- // always: the input manifest.
- File appManifestFile = new File(mAppManifest);
- allInputs.add(appManifestFile);
-
- // if enabled: add the libraries
- if (mEnabled) {
- allInputs.addAll(libraries);
- }
-
- // figure out the path to the dependency file.
- String depFile = mOutManifest + ".d";
-
- // get InputPath with no extension restrictions
- List<InputPath> inputPaths = getInputPaths(allInputs, null /*extensionsToCheck*/,
- null /*factory*/);
-
- if (initDependencies(depFile, inputPaths) && dependenciesHaveChanged() == false) {
- System.out.println(
- "No changes in the AndroidManifest files.");
- return;
- }
-
- System.out.println("Merging AndroidManifest files into one.");
-
- if (mEnabled == false || libraries.size() == 0) {
- if (mEnabled == false) {
- System.out.println("Manifest merger disabled. Using project manifest only.");
- } else {
- System.out.println("No libraries. Using project manifest only.");
- }
- // no merge (disabled or nothing to merge)? do a simple copy.
- try {
- new FileOp().copyFile(appManifestFile, new File(mOutManifest));
- } catch (IOException e) {
- throw new BuildException(e);
- }
- } else {
- System.out.println(String.format("Merging manifests from project and %d libraries.",
- libraries.size()));
- ManifestMerger merger = new ManifestMerger(
- MergerLog.wrapSdkLog(new StdLogger(StdLogger.Level.VERBOSE)),
- new ICallback() {
- SdkManager mManager;
- @Override
- public int queryCodenameApiLevel(@NonNull String codename) {
- if (mManager == null) {
- File sdkDir = TaskHelper.getSdkLocation(getProject());
- mManager = SdkManager.createManager(sdkDir.getPath(),
- new StdLogger(StdLogger.Level.VERBOSE));
- }
- if (mManager != null) {
- IAndroidTarget t = mManager.getTargetFromHashString(
- IAndroidTarget.PLATFORM_HASH_PREFIX + codename);
- if (t != null) {
- return t.getVersion().getApiLevel();
- }
- }
- return ICallback.UNKNOWN_CODENAME;
- }
- });
- if (merger.process(
- new File(mOutManifest),
- appManifestFile,
- libraries.toArray(new File[libraries.size()]),
- null /*injectAttributes*/) == false) {
- throw new BuildException();
- }
- }
-
- // generate the dependency file.
- generateDependencyFile(depFile, inputPaths, mOutManifest);
- }
-
- @Override
- protected String getExecTaskName() {
- return "ManifestMerger";
- }
-}
diff --git a/anttasks/src/com/android/ant/MultiFilesTask.java b/anttasks/src/com/android/ant/MultiFilesTask.java
deleted file mode 100644
index 4f1ae40..0000000
--- a/anttasks/src/com/android/ant/MultiFilesTask.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.types.FileSet;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.types.PatternSet.NameEntry;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-class MultiFilesTask extends BuildTypedTask {
-
- static enum DisplayType {
- FOUND, COMPILING, REMOVE_OUTPUT, REMOVE_DEP;
- }
-
- interface SourceProcessor {
- Set<String> getSourceFileExtensions();
- void process(String filePath, String sourceFolder,
- List<String> sourceFolders, Project taskProject);
- void displayMessage(DisplayType type, int count);
- }
-
- protected void processFiles(SourceProcessor processor, List<Path> paths, String genFolder) {
-
- Project taskProject = getProject();
-
- Set<String> extensions = processor.getSourceFileExtensions();
-
- // build a list of all the source folders
- ArrayList<String> sourceFolders = new ArrayList<String>();
- for (Path p : paths) {
- String[] values = p.list();
- if (values != null) {
- sourceFolders.addAll(Arrays.asList(values));
- }
- }
-
- ArrayList<String> includePatterns = new ArrayList<String>(extensions.size());
- for (String extension : extensions) {
- includePatterns.add("**/*." + extension);
- }
-
- // gather all the source files from all the source folders.
- Map<String, String> sourceFiles = getFilesByNameEntryFilter(sourceFolders,
- includePatterns.toArray(new String[includePatterns.size()]));
- if (sourceFiles.size() > 0) {
- processor.displayMessage(DisplayType.FOUND, sourceFiles.size());
- }
-
- // go look for all dependency files in the gen folder. This will have all dependency
- // files but we can filter them based on the first pre-req file.
- Iterator<?> depFiles = getFilesByNameEntryFilter(genFolder, "**/*.d");
-
- // parse all the dep files and keep the ones that are of the proper type and check if
- // they require compilation again.
- Map<String, String> toCompile = new HashMap<String, String>();
- ArrayList<File> toRemove = new ArrayList<File>();
- ArrayList<String> depsToRemove = new ArrayList<String>();
- while (depFiles.hasNext()) {
- String depFile = depFiles.next().toString();
- DependencyGraph graph = new DependencyGraph(depFile, null /*watchPaths*/);
-
- // get the source file. it's the first item in the pre-reqs
- File sourceFile = graph.getFirstPrereq();
- String sourceFilePath = sourceFile.getAbsolutePath();
-
- // The gen folder may contain other dependency files not generated by this particular
- // processor.
- // We only care if the first pre-rep is of the right extension.
- String fileExtension = sourceFilePath.substring(sourceFilePath.lastIndexOf('.') + 1);
- if (extensions.contains(fileExtension.toLowerCase(Locale.US))) {
- // remove from the list of sourceFiles to mark as "processed" (but not compiled
- // yet, that'll be done by adding it to toCompile)
- String sourceFolder = sourceFiles.get(sourceFilePath);
- if (sourceFolder == null) {
- // looks like the source file does not exist anymore!
- // we'll have to remove the output!
- Set<File> outputFiles = graph.getTargets();
- toRemove.addAll(outputFiles);
-
- // also need to remove the dep file.
- depsToRemove.add(depFile);
- } else {
- // Source file is present. remove it from the list as being processed.
- sourceFiles.remove(sourceFilePath);
-
- // check if it needs to be recompiled.
- if (hasBuildTypeChanged() ||
- graph.dependenciesHaveChanged(false /*printStatus*/)) {
- toCompile.put(sourceFilePath, sourceFolder);
- }
- }
- }
- }
-
- // add to the list of files to compile, whatever is left in sourceFiles. Those are
- // new files that have never been compiled.
- toCompile.putAll(sourceFiles);
-
- processor.displayMessage(DisplayType.COMPILING, toCompile.size());
- if (toCompile.size() > 0) {
- for (Entry<String, String> toCompilePath : toCompile.entrySet()) {
- processor.process(toCompilePath.getKey(), toCompilePath.getValue(),
- sourceFolders, taskProject);
- }
- }
-
- if (toRemove.size() > 0) {
- processor.displayMessage(DisplayType.REMOVE_OUTPUT, toRemove.size());
-
- for (File toRemoveFile : toRemove) {
- if (toRemoveFile.delete() == false) {
- System.err.println("Failed to remove " + toRemoveFile.getAbsolutePath());
- }
- }
- }
-
- // remove the dependency files that are obsolete
- if (depsToRemove.size() > 0) {
- processor.displayMessage(DisplayType.REMOVE_DEP, toRemove.size());
-
- for (String path : depsToRemove) {
- if (new File(path).delete() == false) {
- System.err.println("Failed to remove " + path);
- }
- }
- }
- }
-
- /**
- * Returns a list of files found in given folders, all matching a given filter.
- * The result is a map of (file, folder).
- * @param folders the folders to search
- * @param filter the filter for the files. Typically a glob.
- * @return a map of (file, folder)
- */
- private Map<String, String> getFilesByNameEntryFilter(List<String> folders, String[] filters) {
- Map<String, String> sourceFiles = new HashMap<String, String>();
-
- for (String folder : folders) {
- Iterator<?> iterator = getFilesByNameEntryFilter(folder, filters);
-
- while (iterator.hasNext()) {
- sourceFiles.put(iterator.next().toString(), folder);
- }
- }
-
- return sourceFiles;
- }
-
- /**
- * Returns a list of files found in a given folder, matching a given filter.
- * @param folder the folder to search
- * @param filter the filter for the files. Typically a glob.
- * @return an iterator.
- */
- private Iterator<?> getFilesByNameEntryFilter(String folder, String... filters) {
- Project taskProject = getProject();
-
- // create a fileset to find all the files in the folder
- FileSet fs = new FileSet();
- fs.setProject(taskProject);
- fs.setDir(new File(folder));
- for (String filter : filters) {
- NameEntry include = fs.createInclude();
- include.setName(filter);
- }
-
- // loop through the results of the file set
- return fs.iterator();
- }
-}
diff --git a/anttasks/src/com/android/ant/PropertyByReplaceTask.java b/anttasks/src/com/android/ant/PropertyByReplaceTask.java
deleted file mode 100644
index a0707de..0000000
--- a/anttasks/src/com/android/ant/PropertyByReplaceTask.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.taskdefs.Property;
-
-/**
- * Task to do simple char to char replacement on strings.
- */
-public class PropertyByReplaceTask extends Property {
-
- private String mInput;
- private char mInputChar;
- private char mWithChar;
-
- public void setInput(String input) {
- mInput = input;
- }
-
- public void setReplace(char inputChar) {
- mInputChar = inputChar;
- }
-
- public void setWith(char withChar) {
- mWithChar = withChar;
- }
-
- @Override
- public void execute() throws BuildException {
- setValue(mInput.replace(mInputChar, mWithChar));
- super.execute();
- }
-}
diff --git a/anttasks/src/com/android/ant/RenderScriptTask.java b/anttasks/src/com/android/ant/RenderScriptTask.java
deleted file mode 100644
index 5f743bb8..0000000
--- a/anttasks/src/com/android/ant/RenderScriptTask.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright (C) 2010, 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.SdkConstants;
-import com.google.common.collect.Sets;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.taskdefs.ExecTask;
-import org.apache.tools.ant.types.Path;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Task to execute renderscript.
- * <p>
- * It expects 7 attributes:<br>
- * 'executable' ({@link Path} with a single path) for the location of the llvm executable<br>
- * 'framework' ({@link Path} with 1 or more paths) for the include paths.<br>
- * 'genFolder' ({@link Path} with a single path) for the location of the gen folder.<br>
- * 'resFolder' ({@link Path} with a single path) for the location of the res folder.<br>
- * 'targetApi' for the -target-api value.<br>
- * 'optLevel' for the -O optimization level.<br>
- * 'debug' for -g renderscript debugging.<br>
- * <p>
- * It also expects one or more inner elements called "source" which are identical to {@link Path}
- * elements for where to find .rs files.
- */
-public class RenderScriptTask extends MultiFilesTask {
-
- private final static Set<String> EXTENSIONS = Sets.newHashSetWithExpectedSize(2);
- static {
- EXTENSIONS.add(SdkConstants.EXT_RS);
- EXTENSIONS.add(SdkConstants.EXT_FS);
- }
-
- private String mExecutable;
- private Path mIncludePath;
- private String mGenFolder;
- private String mResFolder;
- private final List<Path> mPaths = new ArrayList<Path>();
- private int mTargetApi = 0;
- public enum OptLevel { O0, O1, O2, O3 };
- private OptLevel mOptLevel;
- private boolean mDebug = false;
-
- private class RenderScriptProcessor implements SourceProcessor {
-
- private final String mTargetApiStr;
-
- public RenderScriptProcessor(int targetApi) {
- // get the target api value. Must be 11+ or llvm-rs-cc complains.
- mTargetApiStr = Integer.toString(mTargetApi < 11 ? 11 : mTargetApi);
- }
-
- @Override
- public Set<String> getSourceFileExtensions() {
- return EXTENSIONS;
- }
-
- @Override
- public void process(String filePath, String sourceFolder, List<String> sourceFolders,
- Project taskProject) {
- File exe = new File(mExecutable);
- String execTaskName = exe.getName();
-
- ExecTask task = new ExecTask();
- task.setTaskName(execTaskName);
- task.setProject(taskProject);
- task.setOwningTarget(getOwningTarget());
- task.setExecutable(mExecutable);
- task.setFailonerror(true);
-
- for (String path : mIncludePath.list()) {
- File res = new File(path);
- if (res.isDirectory()) {
- task.createArg().setValue("-I");
- task.createArg().setValue(path);
- } else {
- System.out.println(String.format(
- "WARNING: RenderScript include directory '%s' does not exist!",
- res.getAbsolutePath()));
- }
-
- }
-
- if (mDebug) {
- task.createArg().setValue("-g");
- }
-
- task.createArg().setValue("-O");
- task.createArg().setValue(Integer.toString(mOptLevel.ordinal()));
-
- task.createArg().setValue("-target-api");
- task.createArg().setValue(mTargetApiStr);
-
- task.createArg().setValue("-d");
- task.createArg().setValue(getDependencyFolder(filePath, sourceFolder));
- task.createArg().setValue("-MD");
-
- task.createArg().setValue("-p");
- task.createArg().setValue(mGenFolder);
- task.createArg().setValue("-o");
- task.createArg().setValue(mResFolder);
- task.createArg().setValue(filePath);
-
- // execute it.
- task.execute();
- }
-
- @Override
- public void displayMessage(DisplayType type, int count) {
- switch (type) {
- case FOUND:
- System.out.println(String.format("Found %1$d RenderScript files.", count));
- break;
- case COMPILING:
- if (count > 0) {
- System.out.println(String.format(
- "Compiling %1$d RenderScript files with -target-api %2$d",
- count, mTargetApi));
- System.out.println(String.format("Optimization Level: %1$d", mOptLevel.ordinal()));
- } else {
- System.out.println("No RenderScript files to compile.");
- }
- break;
- case REMOVE_OUTPUT:
- System.out.println(String.format("Found %1$d obsolete output files to remove.",
- count));
- break;
- case REMOVE_DEP:
- System.out.println(
- String.format("Found %1$d obsolete dependency files to remove.",
- count));
- break;
- }
- }
-
- private String getDependencyFolder(String filePath, String sourceFolder) {
- String relative = filePath.substring(sourceFolder.length());
- if (relative.charAt(0) == '/') {
- relative = relative.substring(1);
- }
-
- return new File(mGenFolder, relative).getParent();
- }
- }
-
-
- /**
- * Sets the value of the "executable" attribute.
- * @param executable the value.
- */
- public void setExecutable(Path executable) {
- mExecutable = TaskHelper.checkSinglePath("executable", executable);
- }
-
- public void setIncludePathRefId(String refId) {
- Object path = getProject().getReference(refId);
- if (path instanceof Path) {
- mIncludePath = (Path) path;
- } else if (path != null) {
- throw new BuildException(refId + " is expected to reference a Path object.");
- }
- }
-
- public void setGenFolder(Path value) {
- mGenFolder = TaskHelper.checkSinglePath("genFolder", value);
- }
-
- public void setResFolder(Path value) {
- mResFolder = TaskHelper.checkSinglePath("resFolder", value);
- }
-
- public void setTargetApi(String targetApi) {
- try {
- mTargetApi = Integer.parseInt(targetApi);
- if (mTargetApi <= 0) {
- throw new BuildException("targetApi attribute value must be >= 1");
- }
- } catch (NumberFormatException e) {
- throw new BuildException("targetApi attribute value must be an integer", e);
- }
- }
-
- public void setOptLevel(OptLevel optLevel) {
- mOptLevel = optLevel;
- }
-
- /** Sets the current build type. value is a boolean, true for debug build, false for release */
- @Override
- public void setBuildType(String buildType) {
- super.setBuildType(buildType);
- mDebug = Boolean.valueOf(buildType);
- }
-
- public Path createSource() {
- Path p = new Path(getProject());
- mPaths.add(p);
- return p;
- }
-
- @Override
- public void execute() throws BuildException {
- if (mExecutable == null) {
- throw new BuildException("RenderScriptTask's 'executable' is required.");
- }
- if (mIncludePath == null) {
- throw new BuildException("RenderScriptTask's 'includePath' is required.");
- }
- if (mGenFolder == null) {
- throw new BuildException("RenderScriptTask's 'genFolder' is required.");
- }
- if (mResFolder == null) {
- throw new BuildException("RenderScriptTask's 'resFolder' is required.");
- }
- if (mTargetApi == 0) {
- throw new BuildException("RenderScriptTask's 'targetApi' is required.");
- }
-
- processFiles(new RenderScriptProcessor(mTargetApi), mPaths, mGenFolder);
- }
-}
diff --git a/anttasks/src/com/android/ant/SignApkTask.java b/anttasks/src/com/android/ant/SignApkTask.java
deleted file mode 100644
index 6c29d68..0000000
--- a/anttasks/src/com/android/ant/SignApkTask.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.sdklib.internal.build.SignedJarBuilder;
-import com.android.sdklib.internal.build.SignedJarBuilder.IZipEntryFilter;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.types.Path;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.security.KeyStore;
-import java.security.KeyStore.PrivateKeyEntry;
-import java.security.cert.X509Certificate;
-
-/**
- * Simple Task to sign an apk.
- *
- */
-public class SignApkTask extends SingleInputOutputTask {
-
- private String mKeystore;
- private String mStorepass;
- private String mAlias;
- private String mKeypass;
-
- public void setKeystore(Path keystore) {
- mKeystore = TaskHelper.checkSinglePath("keystore", keystore);
- }
-
- public void setStorepass(String storepass) {
- mStorepass = storepass;
- }
-
- public void setAlias(String alias) {
- mAlias = alias;
- }
-
- public void setKeypass(String keypass) {
- mKeypass = keypass;
- }
-
- @Override
- protected void createOutput() throws BuildException {
- PrivateKeyEntry key = loadKeyEntry(
- mKeystore, null, mStorepass.toCharArray(),
- mAlias, mKeypass.toCharArray());
-
- if (key == null) {
- throw new BuildException(String.format("Signing key %s not found", mAlias));
- }
-
- SignedJarBuilder mBuilder = null;
- try {
- mBuilder = new SignedJarBuilder(
- new FileOutputStream(getOutput(), false /* append */),
- key.getPrivateKey(), (X509Certificate) key.getCertificate());
-
- mBuilder.writeZip(new FileInputStream(getInput()), new NullZipFilter());
-
- mBuilder.close();
- } catch (FileNotFoundException e) {
- throw new BuildException(String.format("Keystore '%s' is not found!", mKeystore));
- } catch (Exception e) {
- throw new BuildException(e.getMessage());
- } finally {
- if (mBuilder != null) {
- mBuilder.cleanUp();
- }
- }
- }
-
- /**
- * Loads the debug key from the keystore.
- * @param osKeyStorePath the OS path to the keystore.
- * @param storeType an optional keystore type, or <code>null</code> if the default is to
- * be used.
- * @return <code>true</code> if success, <code>false</code> if the keystore does not exist.
- */
- private PrivateKeyEntry loadKeyEntry(String osKeyStorePath, String storeType,
- char[] storePassword, String alias, char[] aliasPassword) {
- FileInputStream fis = null;
- try {
- KeyStore keyStore = KeyStore.getInstance(
- storeType != null ? storeType : KeyStore.getDefaultType());
- fis = new FileInputStream(osKeyStorePath);
- keyStore.load(fis, storePassword);
- return (KeyStore.PrivateKeyEntry)keyStore.getEntry(
- alias, new KeyStore.PasswordProtection(aliasPassword));
- } catch (Exception e) {
- String msg = e.getMessage();
- String causeMsg = null;
-
- Throwable cause = e.getCause();
- if (cause != null) {
- causeMsg = cause.getMessage();
- }
-
- if (msg != null) {
- if (causeMsg == null) {
- throw new BuildException(msg);
- } else {
- throw new BuildException(msg + ": " + causeMsg);
- }
- } else {
- if (causeMsg == null) {
- throw new BuildException(e);
- } else {
- throw new BuildException(causeMsg);
- }
- }
- } finally {
- if (fis != null) {
- try {
- fis.close();
- } catch (IOException e) {
- // pass
- }
- }
- }
- }
-
- private final static class NullZipFilter implements IZipEntryFilter {
-
- @Override
- public boolean checkEntry(String archivePath) throws ZipAbortException {
- return true;
- }
- }
-}
diff --git a/anttasks/src/com/android/ant/SingleDependencyTask.java b/anttasks/src/com/android/ant/SingleDependencyTask.java
deleted file mode 100644
index 4cc8f3e..0000000
--- a/anttasks/src/com/android/ant/SingleDependencyTask.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import org.apache.tools.ant.BuildException;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-/**
- * A base class for ant tasks that use a single dependency file to control (re)execution.
- */
-public abstract class SingleDependencyTask extends BuildTypedTask {
-
- private DependencyGraph mDependencies;
-
- protected abstract String getExecTaskName();
-
- protected interface InputPathFactory {
- InputPath createPath(File file, Set<String> extensionsToCheck);
- }
-
- private final static InputPathFactory sDefaultFactory = new InputPathFactory() {
- @Override
- public InputPath createPath(File file, Set<String> extensionsToCheck) {
- return new InputPath(file, extensionsToCheck);
- }
- };
-
- /**
- * Creates a list of {@link InputPath} from a list of {@link File} and an optional list of
- * extensions. All the {@link InputPath} will share the same extension restrictions.
- * @param paths the list of path
- * @param extensionsToCheck A set of extensions. Only files with an extension in this set will
- * be considered for a modification check. All deleted/created files will still be
- * checked. If this is null, all files will be checked for modification date
- * @return a list of {@link InputPath}
- */
- protected static List<InputPath> getInputPaths(List<File> paths,
- Set<String> extensionsToCheck, InputPathFactory factory) {
- List<InputPath> result = new ArrayList<InputPath>(paths.size());
-
- if (factory == null ) {
- factory = sDefaultFactory;
- }
-
- for (File f : paths) {
- result.add(factory.createPath(f, extensionsToCheck));
- }
-
- return result;
- }
-
- /**
- * Set up the dependency graph by passing it the location of the ".d" file, and the new input
- * paths.
- * @param dependencyFile path to the dependency file to use
- * @param the new input paths for this new compilation.
- * @return true if the dependency graph was successfully initialized
- */
- protected boolean initDependencies(String dependencyFile, List<InputPath> inputPaths) {
- if (hasBuildTypeChanged()) {
- // we don't care about deps, we need to execute the task no matter what.
- return true;
- }
-
- File depFile = new File(dependencyFile);
- if (depFile.exists()) {
- mDependencies = new DependencyGraph(dependencyFile, inputPaths);
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * Wrapper check to see if we need to execute this task at all
- * @return true if the DependencyGraph reports that our prereqs or targets
- * have changed since the last run
- */
- protected boolean dependenciesHaveChanged() {
- if (hasBuildTypeChanged()) {
- // if this is not a new build, display that build type change is forcing running
- // the task.
- if (isNewBuild() == false) {
- String execName = getExecTaskName();
- if (execName == null) {
- System.out.println(
- "Current build type is different than previous build: forced task run.");
- } else {
- System.out.println(
- "Current build type is different than previous build: forced " +
- execName + " run.");
- }
- }
- return true;
- }
-
- assert mDependencies != null : "Dependencies have not been initialized";
- return mDependencies.dependenciesHaveChanged(true /*printStatus*/);
- }
-
- protected void generateDependencyFile(String depFilePath,
- List<InputPath> inputs, String outputFile) {
- File depFile = new File(depFilePath);
-
- try {
- PrintStream ps = new PrintStream(depFile);
-
- // write the output file.
- ps.print(outputFile);
- ps.println(" : \\");
-
- //write the input files
- int count = inputs.size();
- for (int i = 0 ; i < count ; i++) {
- InputPath input = inputs.get(i);
- File file = input.getFile();
- if (file.isDirectory()) {
- writeContent(ps, file, input);
- } else {
- ps.print(file.getAbsolutePath());
- ps.println(" \\");
- }
- }
-
- ps.close();
- } catch (FileNotFoundException e) {
- new BuildException(e);
- }
- }
-
- private void writeContent(PrintStream ps, File file, InputPath input) {
- if (input.ignores(file)) {
- return;
- }
-
- File[] files = file.listFiles();
- if (files != null) {
- for (File f : files) {
- if (f.isDirectory()) {
- writeContent(ps, f, input);
- } else if (input.ignores(f) == false) {
- ps.print(f.getAbsolutePath());
- ps.println(" \\");
- }
- }
- }
- }
-}
diff --git a/anttasks/src/com/android/ant/SingleInputOutputTask.java b/anttasks/src/com/android/ant/SingleInputOutputTask.java
deleted file mode 100644
index a559673..0000000
--- a/anttasks/src/com/android/ant/SingleInputOutputTask.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.Path;
-
-import java.io.File;
-
-/**
- * Single input single output class. Execution is controlled
- * by modification timestamp of the input and output files.
- *
- * Implementation classes must implement {@link #createOutput()}
- *
- */
-public abstract class SingleInputOutputTask extends Task {
-
- private String mInput;
- private String mOutput;
-
- public void setInput(Path inputPath) {
- mInput = TaskHelper.checkSinglePath("input", inputPath);
- }
-
- public void setOutput(Path outputPath) {
- mOutput = TaskHelper.checkSinglePath("output", outputPath);
- }
-
- @Override
- public final void execute() throws BuildException {
- if (mInput == null) {
- throw new BuildException("Missing attribute input");
- }
- if (mOutput == null) {
- throw new BuildException("Missing attribute output");
- }
-
- // check if there's a need for the task to run.
- File outputFile = new File(mOutput);
- if (outputFile.isFile()) {
- File inputFile = new File(mInput);
- if (outputFile.lastModified() >= inputFile.lastModified()) {
- System.out.println(String.format(
- "Run cancelled: no changes to input file %1$s",
- inputFile.getAbsolutePath()));
- return;
- }
- }
-
- createOutput();
- }
-
- protected abstract void createOutput() throws BuildException;
-
- protected String getInput() {
- return mInput;
- }
-
- protected String getOutput() {
- return mOutput;
- }
-}
diff --git a/anttasks/src/com/android/ant/TaskHelper.java b/anttasks/src/com/android/ant/TaskHelper.java
deleted file mode 100644
index c93b193..0000000
--- a/anttasks/src/com/android/ant/TaskHelper.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.SdkConstants;
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.android.sdklib.internal.project.ProjectProperties;
-import com.android.sdklib.internal.project.ProjectProperties.PropertyType;
-import com.android.sdklib.internal.project.ProjectPropertiesWorkingCopy;
-import com.android.sdklib.repository.FullRevision;
-import com.android.sdklib.repository.PkgProps;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Project;
-import org.apache.tools.ant.types.Path;
-import org.apache.tools.ant.util.DeweyDecimal;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Properties;
-
-final class TaskHelper {
-
- private static Map<String, String> DEFAULT_ATTR_VALUES = new HashMap<String, String>();
- static {
- DEFAULT_ATTR_VALUES.put("source.dir", SdkConstants.FD_SOURCES);
- DEFAULT_ATTR_VALUES.put("out.dir", SdkConstants.FD_OUTPUT);
- }
-
- static String getDefault(String name) {
- return DEFAULT_ATTR_VALUES.get(name);
- }
-
- static File getSdkLocation(Project antProject) {
- // get the SDK location
- String sdkOsPath = antProject.getProperty(ProjectProperties.PROPERTY_SDK);
-
- // check if it's valid and exists
- if (sdkOsPath == null || sdkOsPath.length() == 0) {
- throw new BuildException("SDK Location is not set.");
- }
-
- File sdk = new File(sdkOsPath);
- if (sdk.isDirectory() == false) {
- throw new BuildException(String.format("SDK Location '%s' is not valid.", sdkOsPath));
- }
-
- return sdk;
- }
-
- /**
- * Returns the revision of the tools for a given SDK.
- * @param sdkFile the {@link File} for the root folder of the SDK
- * @return the tools revision or -1 if not found.
- */
- @Nullable
- static DeweyDecimal getToolsRevision(File sdkFile) {
- Properties p = new Properties();
- try{
- // tools folder must exist, or this custom task wouldn't run!
- File toolsFolder= new File(sdkFile, SdkConstants.FD_TOOLS);
- File sourceProp = new File(toolsFolder, SdkConstants.FN_SOURCE_PROP);
-
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(sourceProp);
- p.load(fis);
- } finally {
- if (fis != null) {
- try {
- fis.close();
- } catch (IOException ignore) {
- }
- }
- }
-
- String value = p.getProperty(PkgProps.PKG_REVISION);
- if (value != null) {
- FullRevision rev = FullRevision.parseRevision(value);
- return new DeweyDecimal(rev.toIntArray(false /*includePreview*/));
- }
- } catch (NumberFormatException e) {
- // couldn't parse the version number.
- } catch (FileNotFoundException e) {
- // couldn't find the file.
- } catch (IOException e) {
- // couldn't find the file.
- }
-
- return null;
- }
-
- static String checkSinglePath(String attribute, Path path) {
- String[] paths = path.list();
- if (paths.length != 1) {
- throw new BuildException(String.format(
- "Value for '%1$s' is not valid. It must resolve to a single path", attribute));
- }
-
- return paths[0];
- }
-
- /**
- * Returns the ProjectProperties for a given project path.
- * This loads and merges all the .properties files in the same way that Ant does it.
- *
- * Note that this does not return all the Ant properties but only the one customized by the
- * project's own build.xml file.
- *
- * If the project has no .properties files, this returns an empty {@link ProjectProperties}
- * with type {@link PropertyType#PROJECT}.
- *
- * @param projectPath the path to the project root folder.
- * @return a ProjectProperties.
- */
- @NonNull
- static ProjectProperties getProperties(@NonNull String projectPath) {
- // the import order is local, ant, project so we need to respect this.
- PropertyType[] types = PropertyType.getOrderedTypes();
-
- // make a working copy of the first non null props and then merge the rest into it.
- ProjectProperties properties = null;
- for (int i = 0 ; i < types.length ; i++) {
- properties = ProjectProperties.load(projectPath, types[i]);
-
- if (properties != null) {
- ProjectPropertiesWorkingCopy workingCopy = properties.makeWorkingCopy();
- for (int k = i + 1 ; k < types.length ; k++) {
- workingCopy.merge(types[k]);
- }
-
- // revert back to a read-only version
- properties = workingCopy.makeReadOnlyCopy();
-
- return properties;
- }
- }
-
- // return an empty object with type PropertyType.PROJECT (doesn't actually matter).
- return ProjectProperties.createEmpty(projectPath, PropertyType.PROJECT);
- }
-}
diff --git a/anttasks/src/com/android/ant/XPathTask.java b/anttasks/src/com/android/ant/XPathTask.java
deleted file mode 100644
index b6de469..0000000
--- a/anttasks/src/com/android/ant/XPathTask.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import com.android.xml.AndroidXPathFactory;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.Path;
-import org.xml.sax.InputSource;
-
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathExpressionException;
-
-/**
- * Android specific XPath task.
- * The goal is to get the result of an XPath expression on Android XML files. The android namespace
- * (http://schemas.android.com/apk/res/android) must be associated to the "android" prefix.
- */
-public class XPathTask extends Task {
-
- private Path mManifestFile;
- private String mProperty;
- private String mExpression;
- private String mDefault;
-
- public void setInput(Path manifestFile) {
- mManifestFile = manifestFile;
- }
-
- public void setOutput(String property) {
- mProperty = property;
- }
-
- public void setExpression(String expression) {
- mExpression = expression;
- }
-
- public void setDefault(String defaultValue) {
- mDefault = defaultValue;
- }
-
- @Override
- public void execute() throws BuildException {
- try {
- if (mManifestFile == null || mManifestFile.list().length == 0) {
- throw new BuildException("input attribute is missing!");
- }
-
- if (mProperty == null) {
- throw new BuildException("output attribute is missing!");
- }
-
- if (mExpression == null) {
- throw new BuildException("expression attribute is missing!");
- }
-
- XPath xpath = AndroidXPathFactory.newXPath();
-
- String file = mManifestFile.list()[0];
- String result = xpath.evaluate(mExpression, new InputSource(new FileInputStream(file)));
- if (result.length() == 0 && mDefault != null) {
- result = mDefault;
- }
-
- getProject().setProperty(mProperty, result);
- } catch (XPathExpressionException e) {
- throw new BuildException(e);
- } catch (FileNotFoundException e) {
- throw new BuildException(e);
- }
- }
-}
diff --git a/anttasks/src/com/android/ant/ZipAlignTask.java b/anttasks/src/com/android/ant/ZipAlignTask.java
deleted file mode 100644
index 840bee1..0000000
--- a/anttasks/src/com/android/ant/ZipAlignTask.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ant;
-
-import org.apache.tools.ant.BuildException;
-import org.apache.tools.ant.taskdefs.ExecTask;
-import org.apache.tools.ant.types.Path;
-
-public class ZipAlignTask extends SingleInputOutputTask {
-
- private String mExecutable;
- private int mAlign = 4;
- private boolean mVerbose = false;
-
- /**
- * Sets the value of the "executable" attribute.
- * @param executable the value.
- */
- public void setExecutable(Path executable) {
- mExecutable = TaskHelper.checkSinglePath("executable", executable);
- }
-
- public void setAlign(int align) {
- mAlign = align;
- }
-
- public void setVerbose(boolean verbose) {
- mVerbose = verbose;
- }
-
- @Override
- public void createOutput() throws BuildException {
- if (mExecutable == null) {
- throw new BuildException("Missing attribute executable");
- }
-
- System.out.println("Running zip align on final apk...");
- doZipAlign();
- }
-
- private void doZipAlign() {
- ExecTask task = new ExecTask();
- task.setExecutable(mExecutable);
- task.setFailonerror(true);
- task.setProject(getProject());
- task.setOwningTarget(getOwningTarget());
-
- task.setTaskName("zip-align");
-
- // force overwrite of existing output file
- task.createArg().setValue("-f");
-
- // verbose flag
- if (mVerbose) {
- task.createArg().setValue("-v");
- }
-
- // align value
- task.createArg().setValue(Integer.toString(mAlign));
-
- // input
- task.createArg().setValue(getInput());
-
- // output
- task.createArg().setValue(getOutput());
-
- // execute
- task.execute();
- }
-}
diff --git a/apigenerator/.classpath b/apigenerator/.classpath
deleted file mode 100644
index 613f84d..0000000
--- a/apigenerator/.classpath
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/misc/common/kxml2/kxml2-2.3.0.jar" sourcepath="/ANDROID_SRC/dalvik/libcore/xml/src/main/java"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-tree-4.0.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/apigenerator/.gitignore b/apigenerator/.gitignore
deleted file mode 100644
index fe99505..0000000
--- a/apigenerator/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-bin
-
diff --git a/apigenerator/.project b/apigenerator/.project
deleted file mode 100644
index 1d45b20..0000000
--- a/apigenerator/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>apiGenerator</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/apigenerator/src/com/android/apigenerator/AndroidJarReader.java b/apigenerator/src/com/android/apigenerator/AndroidJarReader.java
deleted file mode 100644
index 07a3ce6..0000000
--- a/apigenerator/src/com/android/apigenerator/AndroidJarReader.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.apigenerator;
-
-import com.android.utils.Pair;
-
-import org.objectweb.asm.ClassReader;
-import org.objectweb.asm.Opcodes;
-import org.objectweb.asm.tree.ClassNode;
-import org.objectweb.asm.tree.FieldNode;
-import org.objectweb.asm.tree.MethodNode;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipInputStream;
-
-/**
- * Reads all the android.jar files found in an SDK and generate a map of {@link ApiClass}.
- *
- */
-public class AndroidJarReader {
-
- private static final byte[] BUFFER = new byte[65535];
-
- private final String mSdkFolder;
-
- public AndroidJarReader(String sdkFolder) {
- mSdkFolder = sdkFolder;
- }
-
- public Map<String, ApiClass> getClasses() {
- HashMap<String, ApiClass> map = new HashMap<String, ApiClass>();
-
- // Get all the android.jar. They are in platforms-#
- int apiLevel = 0;
- while (true) {
- apiLevel++;
- try {
- File jar = new File(mSdkFolder, "platforms/android-" + apiLevel + "/android.jar");
- if (jar.exists() == false) {
- System.out.println("Last API level found: " + (apiLevel-1));
- break;
- }
-
- FileInputStream fis = new FileInputStream(jar);
- ZipInputStream zis = new ZipInputStream(fis);
- ZipEntry entry = zis.getNextEntry();
- while (entry != null) {
- String name = entry.getName();
-
- if (name.endsWith(".class")) {
-
- int index = 0;
- do {
- int size = zis.read(BUFFER, index, BUFFER.length - index);
- if (size >= 0) {
- index += size;
- } else {
- break;
- }
- } while (true);
-
- byte[] b = new byte[index];
- System.arraycopy(BUFFER, 0, b, 0, index);
-
- ClassReader reader = new ClassReader(b);
- ClassNode classNode = new ClassNode();
- reader.accept(classNode, 0 /*flags*/);
-
- if (classNode != null) {
- ApiClass theClass = addClass(map, classNode.name, apiLevel);
-
- // super class
- if (classNode.superName != null) {
- theClass.addSuperClass(classNode.superName, apiLevel);
- }
-
- // interfaces
- for (Object interfaceName : classNode.interfaces) {
- theClass.addInterface((String) interfaceName, apiLevel);
- }
-
- // fields
- for (Object field : classNode.fields) {
- FieldNode fieldNode = (FieldNode) field;
- if ((fieldNode.access & Opcodes.ACC_PRIVATE) != 0) {
- continue;
- }
- if (fieldNode.name.startsWith("this$") == false &&
- fieldNode.name.equals("$VALUES") == false) {
- theClass.addField(fieldNode.name, apiLevel);
- }
- }
-
- // methods
- for (Object method : classNode.methods) {
- MethodNode methodNode = (MethodNode) method;
- if ((methodNode.access & Opcodes.ACC_PRIVATE) != 0) {
- continue;
- }
- if (methodNode.name.equals("<clinit>") == false) {
- theClass.addMethod(methodNode.name + methodNode.desc, apiLevel);
- }
- }
- }
- }
- entry = zis.getNextEntry();
- }
-
- } catch (MalformedURLException e) {
- e.printStackTrace();
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
-
- }
- }
-
- postProcessClasses(map);
-
- return map;
- }
-
- private void postProcessClasses(Map<String, ApiClass> classes) {
- for (ApiClass theClass : classes.values()) {
- Map<String, Integer> methods = theClass.getMethods();
- Map<String, Integer> fixedMethods = new HashMap<String, Integer>();
-
- List<Pair<String, Integer>> superClasses = theClass.getSuperClasses();
- List<Pair<String, Integer>> interfaces = theClass.getInterfaces();
-
- methodLoop: for (Entry<String, Integer> method : methods.entrySet()) {
- String methodName = method.getKey();
- int apiLevel = method.getValue();
-
- if (methodName.startsWith("<init>(") == false) {
-
- for (Pair<String, Integer> parent : superClasses) {
- // only check the parent if it was a parent class at the introduction
- // of the method.
- if (parent.getSecond() <= apiLevel) {
- ApiClass parentClass = classes.get(parent.getFirst());
- assert parentClass != null;
- if (parentClass != null &&
- checkClassContains(theClass.getName(),
- methodName, apiLevel,
- classes, parentClass)) {
- continue methodLoop;
- }
- }
- }
-
- for (Pair<String, Integer> parent : interfaces) {
- // only check the parent if it was a parent class at the introduction
- // of the method.
- if (parent.getSecond() <= apiLevel) {
- ApiClass parentClass = classes.get(parent.getFirst());
- assert parentClass != null;
- if (parentClass != null &&
- checkClassContains(theClass.getName(),
- methodName, apiLevel,
- classes, parentClass)) {
- continue methodLoop;
- }
- }
- }
- }
-
- // if we reach here. the method isn't an override
- fixedMethods.put(methodName, method.getValue());
- }
-
- theClass.replaceMethods(fixedMethods);
- }
- }
-
- private boolean checkClassContains(String className, String methodName, int apiLevel,
- Map<String, ApiClass> classMap, ApiClass parentClass) {
-
- Integer parentMethodApiLevel = parentClass.getMethods().get(methodName);
- if (parentMethodApiLevel != null && parentMethodApiLevel <= apiLevel) {
- // the parent class has the method and it was introduced in the parent at the
- // same api level as the method, or before.
- return true;
- }
-
- // check on this class parents.
- List<Pair<String, Integer>> superClasses = parentClass.getSuperClasses();
- List<Pair<String, Integer>> interfaces = parentClass.getInterfaces();
-
- for (Pair<String, Integer> parent : superClasses) {
- // only check the parent if it was a parent class at the introduction
- // of the method.
- if (parent.getSecond() <= apiLevel) {
- ApiClass superParentClass = classMap.get(parent.getFirst());
- assert superParentClass != null;
- if (superParentClass != null && checkClassContains(className, methodName, apiLevel,
- classMap, superParentClass)) {
- return true;
- }
- }
- }
-
- for (Pair<String, Integer> parent : interfaces) {
- // only check the parent if it was a parent class at the introduction
- // of the method.
- if (parent.getSecond() <= apiLevel) {
- ApiClass superParentClass = classMap.get(parent.getFirst());
- assert superParentClass != null;
- if (superParentClass != null && checkClassContains(className, methodName, apiLevel,
- classMap, superParentClass)) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- private ApiClass addClass(HashMap<String, ApiClass> classes, String name, int apiLevel) {
- ApiClass theClass = classes.get(name);
- if (theClass == null) {
- theClass = new ApiClass(name, apiLevel);
- classes.put(name, theClass);
- }
-
- return theClass;
- }
-}
diff --git a/apigenerator/src/com/android/apigenerator/ApiClass.java b/apigenerator/src/com/android/apigenerator/ApiClass.java
deleted file mode 100644
index 50ee8c8..0000000
--- a/apigenerator/src/com/android/apigenerator/ApiClass.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.apigenerator;
-
-import com.android.utils.Pair;
-
-import java.io.PrintStream;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.TreeMap;
-
-/**
- * Represents a class and its methods/fields.
- * This is used to write the simplified XML file containing all the public API.
- *
- */
-public class ApiClass {
-
- private final String mName;
- private final int mSince;
-
- private final List<Pair<String, Integer>> mSuperClasses =
- new ArrayList<Pair<String, Integer>>();
-
- private final List<Pair<String, Integer>> mInterfaces = new ArrayList<Pair<String, Integer>>();
-
- private final Map<String, Integer> mFields = new HashMap<String, Integer>();
- private final Map<String, Integer> mMethods = new HashMap<String, Integer>();
-
- public ApiClass(String name, int since) {
- mName = name;
- mSince = since;
- }
-
- public String getName() {
- return mName;
- }
-
- int getSince() {
- return mSince;
- }
-
- public void addField(String name, int since) {
- Integer i = mFields.get(name);
- if (i == null || i.intValue() > since) {
- mFields.put(name, Integer.valueOf(since));
- }
- }
-
- public void addMethod(String name, int since) {
- Integer i = mMethods.get(name);
- if (i == null || i.intValue() > since) {
- mMethods.put(name, Integer.valueOf(since));
- }
- }
-
- public Map<String, Integer> getMethods() {
- return mMethods;
- }
-
- public void replaceMethods(Map<String, Integer> fixedMethods) {
- mMethods.clear();
- mMethods.putAll(fixedMethods);
- }
-
- public void addSuperClass(String superClass, int since) {
- addToArray(mSuperClasses, superClass, since);
- }
-
- public List<Pair<String, Integer>> getSuperClasses() {
- return mSuperClasses;
- }
-
- public void addInterface(String interfaceClass, int since) {
- addToArray(mInterfaces, interfaceClass, since);
- }
-
- public List<Pair<String, Integer>> getInterfaces() {
- return mInterfaces;
- }
-
- void addToArray(List<Pair<String, Integer>> list, String name, int value) {
- // check if we already have that name (at a lower level)
- for (Pair<String, Integer> pair : list) {
- if (name.equals(pair.getFirst()) && pair.getSecond() < value) {
- return;
- }
- }
-
- list.add(Pair.of(name, Integer.valueOf(value)));
- }
-
- public void print(PrintStream stream) {
- stream.print("\t<class name=\"");
- stream.print(mName);
- stream.print("\" since=\"");
- stream.print(mSince);
- stream.println("\">");
-
- print(mSuperClasses, "extends", stream);
- print(mInterfaces, "implements", stream);
- print(mMethods, "method", stream);
- print(mFields, "field", stream);
-
- stream.println("\t</class>");
- }
-
- private void print(List<Pair<String, Integer> > list, String name, PrintStream stream) {
- Collections.sort(list, new Comparator<Pair<String, Integer> >() {
-
- @Override
- public int compare(Pair<String, Integer> o1, Pair<String, Integer> o2) {
- return o1.getFirst().compareTo(o2.getFirst());
- }
- });
-
- for (Pair<String, Integer> pair : list) {
- if (mSince == pair.getSecond()) {
- stream.print("\t\t<");
- stream.print(name);
- stream.print(" name=\"");
- stream.print(encodeAttribute(pair.getFirst()));
- stream.println("\" />");
- } else {
- stream.print("\t\t<");
- stream.print(name);
- stream.print(" name=\"");
- stream.print(encodeAttribute(pair.getFirst()));
- stream.print("\" since=\"");
- stream.print(pair.getSecond());
- stream.println("\" />");
- }
- }
- }
-
- private void print(Map<String, Integer> map, String name, PrintStream stream) {
- TreeMap<String, Integer> map2 = new TreeMap<String, Integer>(map);
-
- for (Entry<String, Integer> entry : map2.entrySet()) {
- if (mSince == entry.getValue()) {
- stream.print("\t\t<");
- stream.print(name);
- stream.print(" name=\"");
- stream.print(encodeAttribute(entry.getKey()));
- stream.println("\" />");
- } else {
- stream.print("\t\t<");
- stream.print(name);
- stream.print(" name=\"");
- stream.print(encodeAttribute(entry.getKey()));
- stream.print("\" since=\"");
- stream.print(entry.getValue());
- stream.println("\" />");
- }
- }
- }
-
- private String encodeAttribute(String attribute) {
- StringBuilder sb = new StringBuilder();
- int n = attribute.length();
- // &, ", ' and < are illegal in attributes; see http://www.w3.org/TR/REC-xml/#NT-AttValue
- // (' legal in a " string and " is legal in a ' string but here we'll stay on the safe
- // side)
- for (int i = 0; i < n; i++) {
- char c = attribute.charAt(i);
- if (c == '"') {
- sb.append("&quot;"); //$NON-NLS-1$
- } else if (c == '<') {
- sb.append("&lt;"); //$NON-NLS-1$
- } else if (c == '\'') {
- sb.append("&apos;"); //$NON-NLS-1$
- } else if (c == '&') {
- sb.append("&amp;"); //$NON-NLS-1$
- } else {
- sb.append(c);
- }
- }
-
- return sb.toString();
- }
-
- @Override
- public String toString() {
- return mName;
- }
-}
diff --git a/apigenerator/src/com/android/apigenerator/Main.java b/apigenerator/src/com/android/apigenerator/Main.java
deleted file mode 100644
index 4ce7ac9..0000000
--- a/apigenerator/src/com/android/apigenerator/Main.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.apigenerator;
-
-
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintStream;
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * Main class for command line command to convert the existing API XML/TXT files into diff-based
- * simple text files.
- *
- */
-public class Main {
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- if (args.length != 2) {
- printUsage();
- }
-
- AndroidJarReader reader = new AndroidJarReader(args[0]);
- Map<String, ApiClass> classes = reader.getClasses();
- createApiFile(new File(args[1]), classes);
- }
-
- private static void printUsage() {
- System.err.println("Generates a single API file from the content of an SDK.\n");
- System.err.println("Usage\n");
- System.err.println("\tApiCheck SDKFOLDER OUTFILE\n");
- System.exit(1);
- }
-
- /**
- * Creates the simplified diff-based API level.
- * @param outFolder the out folder.
- * @param classes
- */
- private static void createApiFile(File outFile, Map<String, ApiClass> classes) {
-
- PrintStream ps = null;
- try {
- ps = new PrintStream(outFile);
- ps.println("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
- ps.println("<api version=\"1\">");
- TreeMap<String, ApiClass> map = new TreeMap<String, ApiClass>(classes);
- for (ApiClass theClass : map.values()) {
- (theClass).print(ps);
- }
- ps.println("</api>");
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } finally {
- if (ps != null) {
- ps.close();
- }
- }
- }
-}
diff --git a/archquery/.classpath b/archquery/.classpath
deleted file mode 100644
index fb50116..0000000
--- a/archquery/.classpath
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/archquery/.gitignore b/archquery/.gitignore
deleted file mode 100644
index ba077a4..0000000
--- a/archquery/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/archquery/.project b/archquery/.project
deleted file mode 100644
index 9886091..0000000
--- a/archquery/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>archquery</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/archquery/Android.mk b/archquery/Android.mk
deleted file mode 100644
index 11718a1..0000000
--- a/archquery/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright (C) 2009 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_RESOURCE_DIRS := src
-
-LOCAL_JAR_MANIFEST := etc/manifest.txt
-
-LOCAL_JAVA_LIBRARIES := \
-
-LOCAL_MODULE := archquery
-
-LOCAL_MODULE_TAGS := debug
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/archquery/NOTICE b/archquery/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/archquery/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/archquery/etc/manifest.txt b/archquery/etc/manifest.txt
deleted file mode 100644
index a362e88..0000000
--- a/archquery/etc/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Main-Class: com.android.archquery.Main
diff --git a/archquery/src/com/android/archquery/Main.java b/archquery/src/com/android/archquery/Main.java
deleted file mode 100644
index 030cfe5..0000000
--- a/archquery/src/com/android/archquery/Main.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.archquery;
-
-/**
- * Java command line tool to return the CPU architecture of the host java VM.
- *
- * The goal is to be able to launch SWT based applications (DDMS, Traceview, Android) on any
- * type of OS.
- *
- * Because a 64 bit OS can run a 32 bit Virtual Machine, we need to query the VM itself to know
- * whether it's 32 or 64 bit to detect which swt.jar it should use (it contains native libraries).
- * Simply querying the OS is not enough.
- *
- * The other problem is that once a VM is launched it is impossible to change its classpath to
- * point the VM to the correct version of swt.jar.
- *
- * The solution is this small command line tool, running in the VM, and returning the value of
- * the 'os.arch' property. Based on the returned value, the script launching the SWT based
- * applications will configure the Java VM with the path to the correct swt.jar
- *
- * Because different VMs return different values for 32 and 64 bit version of x86 CPUs, the program
- * handles all the possible values and normalize the returned value.
- *
- * At this time, the normalized values are:
- * x86: 32 bit x86
- * x86_64: 64 bit x86
- * ppc: PowerPC (WARNING: the SDK doesn't actually support this architecture).
- *
- *
- */
-public final class Main {
- public static void main(String[] args) {
-
- for (String arg : args) {
- System.out.println(System.getProperty(arg));
- }
-
- if (args.length == 0) {
- // Values listed from http://lopica.sourceforge.net/os.html
- String arch = System.getProperty("os.arch");
-
- if (arch.equalsIgnoreCase("x86_64") || arch.equalsIgnoreCase("amd64")) {
- System.out.print("x86_64");
-
- } else if (arch.equalsIgnoreCase("x86")
- || arch.equalsIgnoreCase("i386")
- || arch.equalsIgnoreCase("i686")) {
- System.out.print("x86");
-
- } else if (arch.equalsIgnoreCase("ppc") || arch.equalsIgnoreCase("PowerPC")) {
- System.out.print("ppc");
- } else {
- System.out.print(arch);
- }
- }
- }
-}
diff --git a/assetstudio/.classpath b/assetstudio/.classpath
deleted file mode 100644
index bee5c09..0000000
--- a/assetstudio/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="tests/src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="ANDROID_SRC/prebuilts/tools/common/guava-tools/src.zip"/>
- <classpathentry combineaccessrules="false" kind="src" path="/layoutlib_api"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/assetstudio/.gitignore b/assetstudio/.gitignore
deleted file mode 100644
index fe99505..0000000
--- a/assetstudio/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-bin
-
diff --git a/assetstudio/.project b/assetstudio/.project
deleted file mode 100644
index f9aa2ce..0000000
--- a/assetstudio/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>assetstudio</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/assetstudio/.settings/org.eclipse.jdt.core.prefs b/assetstudio/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/assetstudio/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/assetstudio/Android.mk b/assetstudio/Android.mk
deleted file mode 100644
index 19e2d3c..0000000
--- a/assetstudio/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-#
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# The assetstudio code has moved to tools/base/assetstudio.
-# The rule below uses the prebuilt assetstudio.jar.
-#
-# If you want to run the tests, cd to tools/base/assetstudio
-# and run ./gradlew :assetstudio:test
-
-LOCAL_MODULE := assetstudio
-LOCAL_MODULE_TAGS := optional
-
-# TODO: Replace common with the batik stuff
-LOCAL_JAVA_LIBRARIES := \
- common \
- guava-tools \
- layoutlib_api
-
-LOCAL_JAR_MANIFEST := etc/manifest.txt
-
-LOCAL_PREBUILT_JAVA_LIBRARIES := \
- ../../prebuilts/devtools/tools/lib/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/assetstudio/etc/manifest.txt b/assetstudio/etc/manifest.txt
deleted file mode 100644
index 23e6524..0000000
--- a/assetstudio/etc/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Class-Path: layoutlib_api.jar
diff --git a/build/sdk_only_whitelist.mk b/build/sdk_only_whitelist.mk
deleted file mode 100644
index 53f2d94..0000000
--- a/build/sdk_only_whitelist.mk
+++ /dev/null
@@ -1,74 +0,0 @@
-# Whitelist of SDK projects that can be built for the SDK on Windows
-
-# The Windows SDK cannot build all the projects from the SDK tree, typically
-# due to obvious compiler/architectures differences. When building the Windows
-# SDK, we only care about a subset of projects (e.g. generally the SDK tools
-# and a few platform-specific binaries.)
-#
-# This file defines a whitelist of projects that can be built in the Windows
-# SDK case. Note that whitelisting a project directory will NOT actually build
-# it -- it will only allow one to reference it as a make dependency.
-#
-# This file is included by build/core/main.mk.
-
-# Note that there are 2 flavors of this file:
-#
-# - This file: sdk/build/sdk_only_whitelist.mk
-# must list all projects that are that are NOT specific to a given platform.
-# These binaries are the ones typically found in the SDK/tools directory.
-#
-# - The other file: development/build/sdk_only_whitelist.mk
-# must list all projects that are specific to a given platform. These
-# projects generate files that are generally locates in SDK/platform-tools,
-# or SDK/platforms/, etc.
-
-# -----
-# Whitelist of SDK specific projects that do NOT need Java (e.g. C libraries)
-
-subdirs += \
- external/openssl \
- external/qemu \
- prebuilts/tools \
- sdk/avdlauncher \
- sdk/emulator/mksdcard \
- sdk/emulator/opengl \
- sdk/find_java \
- sdk/find_lock \
- sdk/sdklauncher
-
-# -----
-# Whitelist of SDK specific projects that DO require Java
-
-ifneq (,$(shell which javac 2>/dev/null))
-subdirs += \
- external/ant-glob \
- external/eclipse-windowbuilder/propertysheet \
- external/hamcrest \
- external/junit \
- sdk/archquery \
- sdk/annotations \
- sdk/apkbuilder \
- sdk/assetstudio \
- sdk/common \
- sdk/ddms \
- sdk/device_validator \
- sdk/eclipse/scripts/rcp \
- sdk/hierarchyviewer2 \
- sdk/sdk_common \
- sdk/jarutils \
- sdk/layoutlib_api \
- sdk/manifmerger \
- sdk/monitor \
- sdk/ninepatch \
- sdk/rule_api \
- sdk/lint \
- sdk/sdkstats \
- sdk/sdkmanager \
- sdk/swtmenubar \
- sdk/testutils \
- sdk/traceview \
- sdk/uiautomatorviewer
-
-else
-$(warning SDK_ONLY: javac not available.)
-endif
diff --git a/chimpchat/Android.mk b/chimpchat/Android.mk
deleted file mode 100644
index 281b1ea..0000000
--- a/chimpchat/Android.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-CHIMPCHAT_LOCAL_DIR := $(call my-dir)
-include $(CHIMPCHAT_LOCAL_DIR)/src/Android.mk
-include $(CHIMPCHAT_LOCAL_DIR)/test/Android.mk
diff --git a/chimpchat/MODULE_LICENSE_APACHE2 b/chimpchat/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/chimpchat/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/chimpchat/NOTICE b/chimpchat/NOTICE
deleted file mode 100644
index 7317ae2..0000000
--- a/chimpchat/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2011, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/chimpchat/src/Android.mk b/chimpchat/src/Android.mk
deleted file mode 100644
index 5a35980..0000000
--- a/chimpchat/src/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_JAVA_LIBRARIES := \
- common \
- ddmlib \
- hierarchyviewerlib \
- guavalib \
- sdklib \
- swt
-
-LOCAL_MODULE := chimpchat
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/chimpchat/src/com/android/chimpchat/ChimpChat.java b/chimpchat/src/com/android/chimpchat/ChimpChat.java
deleted file mode 100644
index 5618ec6..0000000
--- a/chimpchat/src/com/android/chimpchat/ChimpChat.java
+++ /dev/null
@@ -1,109 +0,0 @@
-
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.chimpchat;
-
-import com.android.chimpchat.adb.AdbBackend;
-import com.android.chimpchat.core.IChimpBackend;
-import com.android.chimpchat.core.IChimpDevice;
-
-import java.util.Map;
-import java.util.TreeMap;
-
-/**
- * ChimpChat is a host-side library that provides an API for communication with
- * an instance of Monkey on a device. This class provides an entry point to
- * setting up communication with a device. Currently it only supports communciation
- * over ADB, however.
- */
-public class ChimpChat {
- private final IChimpBackend mBackend;
- private static String sAdbLocation;
- private static boolean sNoInitAdb;
-
- private ChimpChat(IChimpBackend backend) {
- this.mBackend = backend;
- }
-
- /**
- * Generates a new instance of ChimpChat based on the options passed.
- * @param options a map of settings for the new ChimpChat instance
- * @return a new instance of ChimpChat or null if errors occur during creation
- */
- public static ChimpChat getInstance(Map<String, String> options) {
- sAdbLocation = options.get("adbLocation");
- sNoInitAdb = Boolean.valueOf(options.get("noInitAdb"));
-
- IChimpBackend backend = createBackendByName(options.get("backend"));
- if (backend == null) {
- return null;
- }
- ChimpChat chimpchat = new ChimpChat(backend);
- return chimpchat;
- }
-
- /** Generates a new instance of ChimpChat using default settings
- * @return a new instance of ChimpChat or null if errors occur during creation
- */
- public static ChimpChat getInstance() {
- Map<String, String> options = new TreeMap<String, String>();
- options.put("backend", "adb");
- return ChimpChat.getInstance(options);
- }
-
-
- /**
- * Creates a specific backend by name.
- *
- * @param backendName the name of the backend to create
- * @return the new backend, or null if none were found.
- */
-
- private static IChimpBackend createBackendByName(String backendName) {
- if ("adb".equals(backendName)) {
- return new AdbBackend(sAdbLocation, sNoInitAdb);
- } else {
- return null;
- }
- }
-
- /**
- * Retrieves an instance of the device from the backend
- * @param timeoutMs length of time to wait before timing out
- * @param deviceId the id of the device you want to connect to
- * @return an instance of the device
- */
- public IChimpDevice waitForConnection(long timeoutMs, String deviceId){
- return mBackend.waitForConnection(timeoutMs, deviceId);
- }
-
- /**
- * Retrieves an instance of the device from the backend.
- * Defaults to the longest possible wait time and any available device.
- * @return an instance of the device
- */
- public IChimpDevice waitForConnection(){
- return mBackend.waitForConnection(Integer.MAX_VALUE, ".*");
- }
-
- /**
- * Shutdown and clean up chimpchat.
- */
- public void shutdown(){
- mBackend.shutdown();
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/ChimpManager.java b/chimpchat/src/com/android/chimpchat/ChimpManager.java
deleted file mode 100644
index 475c7c1..0000000
--- a/chimpchat/src/com/android/chimpchat/ChimpManager.java
+++ /dev/null
@@ -1,455 +0,0 @@
-
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat;
-
-import com.android.chimpchat.core.IChimpView;
-import com.android.chimpchat.core.PhysicalButton;
-import com.android.chimpchat.core.ChimpException;
-import com.android.chimpchat.core.ChimpRect;
-import com.android.chimpchat.core.ChimpView;
-
-import com.google.common.collect.Lists;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.net.Socket;
-import java.net.SocketException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.StringTokenizer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Provides a nicer interface to interacting with the low-level network access protocol for talking
- * to the monkey.
- *
- * This class is thread-safe and can handle being called from multiple threads.
- */
-public class ChimpManager {
- private static Logger LOG = Logger.getLogger(ChimpManager.class.getName());
-
- private Socket monkeySocket;
- private BufferedWriter monkeyWriter;
- private BufferedReader monkeyReader;
-
- /**
- * Create a new ChimpMananger to talk to the specified device.
- *
- * @param monkeySocket the already connected socket on which to send protocol messages.
- * @throws IOException if there is an issue setting up the sockets
- */
- public ChimpManager(Socket monkeySocket) throws IOException {
- this.monkeySocket = monkeySocket;
- monkeyWriter =
- new BufferedWriter(new OutputStreamWriter(monkeySocket.getOutputStream()));
- monkeyReader = new BufferedReader(new InputStreamReader(monkeySocket.getInputStream()));
- }
-
- /* Ensure that everything gets shutdown properly */
- protected void finalize() throws Throwable {
- try {
- quit();
- } finally {
- close();
- super.finalize();
- }
- }
-
- /**
- * Send a touch down event at the specified location.
- *
- * @param x the x coordinate of where to click
- * @param y the y coordinate of where to click
- * @return success or not
- * @throws IOException on error communicating with the device
- */
- public boolean touchDown(int x, int y) throws IOException {
- return sendMonkeyEvent("touch down " + x + " " + y);
- }
-
- /**
- * Send a touch down event at the specified location.
- *
- * @param x the x coordinate of where to click
- * @param y the y coordinate of where to click
- * @return success or not
- * @throws IOException on error communicating with the device
- */
- public boolean touchUp(int x, int y) throws IOException {
- return sendMonkeyEvent("touch up " + x + " " + y);
- }
-
- /**
- * Send a touch move event at the specified location.
- *
- * @param x the x coordinate of where to click
- * @param y the y coordinate of where to click
- * @return success or not
- * @throws IOException on error communicating with the device
- */
- public boolean touchMove(int x, int y) throws IOException {
- return sendMonkeyEvent("touch move " + x + " " + y);
- }
-
- /**
- * Send a touch (down and then up) event at the specified location.
- *
- * @param x the x coordinate of where to click
- * @param y the y coordinate of where to click
- * @return success or not
- * @throws IOException on error communicating with the device
- */
- public boolean touch(int x, int y) throws IOException {
- return sendMonkeyEvent("tap " + x + " " + y);
- }
-
- /**
- * Press a physical button on the device.
- *
- * @param name the name of the button (As specified in the protocol)
- * @return success or not
- * @throws IOException on error communicating with the device
- */
- public boolean press(String name) throws IOException {
- return sendMonkeyEvent("press " + name);
- }
-
- /**
- * Send a Key Down event for the specified button.
- *
- * @param name the name of the button (As specified in the protocol)
- * @return success or not
- * @throws IOException on error communicating with the device
- */
- public boolean keyDown(String name) throws IOException {
- return sendMonkeyEvent("key down " + name);
- }
-
- /**
- * Send a Key Up event for the specified button.
- *
- * @param name the name of the button (As specified in the protocol)
- * @return success or not
- * @throws IOException on error communicating with the device
- */
- public boolean keyUp(String name) throws IOException {
- return sendMonkeyEvent("key up " + name);
- }
-
- /**
- * Press a physical button on the device.
- *
- * @param button the button to press
- * @return success or not
- * @throws IOException on error communicating with the device
- */
- public boolean press(PhysicalButton button) throws IOException {
- return press(button.getKeyName());
- }
-
- /**
- * This function allows the communication bridge between the host and the device
- * to be invisible to the script for internal needs.
- * It splits a command into monkey events and waits for responses for each over an adb tcp socket.
- * Returns on an error, else continues and sets up last response.
- *
- * @param command the monkey command to send to the device
- * @return the (unparsed) response returned from the monkey.
- * @throws IOException on error communicating with the device
- */
- private String sendMonkeyEventAndGetResponse(String command) throws IOException {
- command = command.trim();
- LOG.info("Monkey Command: " + command + ".");
-
- // send a single command and get the response
- monkeyWriter.write(command + "\n");
- monkeyWriter.flush();
- return monkeyReader.readLine();
- }
-
- /**
- * Parse a monkey response string to see if the command succeeded or not.
- *
- * @param monkeyResponse the response
- * @return true if response code indicated success.
- */
- private boolean parseResponseForSuccess(String monkeyResponse) {
- if (monkeyResponse == null) {
- return false;
- }
- // return on ok
- if(monkeyResponse.startsWith("OK")) {
- return true;
- }
-
- return false;
- }
-
- /**
- * Parse a monkey response string to get the extra data returned.
- *
- * @param monkeyResponse the response
- * @return any extra data that was returned, or empty string if there was nothing.
- */
- private String parseResponseForExtra(String monkeyResponse) {
- int offset = monkeyResponse.indexOf(':');
- if (offset < 0) {
- return "";
- }
- return monkeyResponse.substring(offset + 1);
- }
-
- /**
- * This function allows the communication bridge between the host and the device
- * to be invisible to the script for internal needs.
- * It splits a command into monkey events and waits for responses for each over an
- * adb tcp socket.
- *
- * @param command the monkey command to send to the device
- * @return true on success.
- * @throws IOException on error communicating with the device
- */
- private boolean sendMonkeyEvent(String command) throws IOException {
- synchronized (this) {
- String monkeyResponse = sendMonkeyEventAndGetResponse(command);
- return parseResponseForSuccess(monkeyResponse);
- }
- }
-
- /**
- * Close all open resources related to this device.
- */
- public void close() {
- try {
- monkeySocket.close();
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Unable to close monkeySocket", e);
- }
- try {
- monkeyReader.close();
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Unable to close monkeyReader", e);
- }
- try {
- monkeyWriter.close();
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Unable to close monkeyWriter", e);
- }
- }
-
- /**
- * Function to get a static variable from the device.
- *
- * @param name name of static variable to get
- * @return the value of the variable, or null if there was an error
- * @throws IOException on error communicating with the device
- */
- public String getVariable(String name) throws IOException {
- synchronized (this) {
- String response = sendMonkeyEventAndGetResponse("getvar " + name);
- if (!parseResponseForSuccess(response)) {
- return null;
- }
- return parseResponseForExtra(response);
- }
- }
-
- /**
- * Function to get the list of variables from the device.
- * @return the list of variables as a collection of strings
- * @throws IOException on error communicating with the device
- */
- public Collection<String> listVariable() throws IOException {
- synchronized (this) {
- String response = sendMonkeyEventAndGetResponse("listvar");
- if (!parseResponseForSuccess(response)) {
- Collections.emptyList();
- }
- String extras = parseResponseForExtra(response);
- return Lists.newArrayList(extras.split(" "));
- }
- }
-
- /**
- * Tells the monkey that we are done for this session.
- * @throws IOException on error communicating with the device
- */
- public void done() throws IOException {
- // this command just drops the connection, so handle it here
- synchronized (this) {
- sendMonkeyEventAndGetResponse("done");
- }
- }
-
- /**
- * Tells the monkey that we are done forever.
- * @throws IOException on error communicating with the device
- */
- public void quit() throws IOException {
- // this command drops the connection, so handle it here
- synchronized (this) {
- try {
- sendMonkeyEventAndGetResponse("quit");
- } catch (SocketException e) {
- // flush was called after the call had been written, so it tried flushing to a
- // broken pipe.
- }
- }
- }
-
- /**
- * Send a tap event at the specified location.
- *
- * @param x the x coordinate of where to click
- * @param y the y coordinate of where to click
- * @return success or not
- * @throws IOException on error communicating with the device
- */
- public boolean tap(int x, int y) throws IOException {
- return sendMonkeyEvent("tap " + x + " " + y);
- }
-
- /**
- * Type the following string to the monkey.
- *
- * @param text the string to type
- * @return success
- * @throws IOException on error communicating with the device
- */
- public boolean type(String text) throws IOException {
- // The network protocol can't handle embedded line breaks, so we have to handle it
- // here instead
- StringTokenizer tok = new StringTokenizer(text, "\n", true);
- while (tok.hasMoreTokens()) {
- String line = tok.nextToken();
- if ("\n".equals(line)) {
- boolean success = press(PhysicalButton.ENTER);
- if (!success) {
- return false;
- }
- } else {
- boolean success = sendMonkeyEvent("type " + line);
- if (!success) {
- return false;
- }
- }
- }
- return true;
- }
-
- /**
- * Type the character to the monkey.
- *
- * @param keyChar the character to type.
- * @return success
- * @throws IOException on error communicating with the device
- */
- public boolean type(char keyChar) throws IOException {
- return type(Character.toString(keyChar));
- }
-
- /**
- * Wake the device up from sleep.
- * @throws IOException on error communicating with the device
- */
- public void wake() throws IOException {
- sendMonkeyEvent("wake");
- }
-
-
- /**
- * Retrieves the list of view ids from the current application.
- * @return the list of view ids as a collection of strings
- * @throws IOException on error communicating with the device
- */
- public Collection<String> listViewIds() throws IOException {
- synchronized (this) {
- String response = sendMonkeyEventAndGetResponse("listviews");
- if (!parseResponseForSuccess(response)) {
- Collections.emptyList();
- }
- String extras = parseResponseForExtra(response);
- return Lists.newArrayList(extras.split(" "));
- }
- }
-
- /**
- * Queries the on-screen view with the given id and returns the response.
- * It's up to the calling method to parse the returned String.
- * @param idType The type of ID to query the view by
- * @param id The view id of the view
- * @param query the query
- * @return the response from the query
- * @throws IOException on error communicating with the device
- */
- public String queryView(String idType, List<String> ids, String query) throws IOException {
- StringBuilder monkeyCommand = new StringBuilder("queryview " + idType + " ");
- for(String id : ids) {
- monkeyCommand.append(id).append(" ");
- }
- monkeyCommand.append(query);
- synchronized (this) {
- String response = sendMonkeyEventAndGetResponse(monkeyCommand.toString());
- if (!parseResponseForSuccess(response)) {
- throw new ChimpException(parseResponseForExtra(response));
- }
- return parseResponseForExtra(response);
- }
- }
-
- /**
- * Returns the current root view of the device.
- * @return the root view of the device
- */
- public IChimpView getRootView() throws IOException {
- synchronized(this) {
- String response = sendMonkeyEventAndGetResponse("getrootview");
- String extra = parseResponseForExtra(response);
- List<String> ids = Arrays.asList(extra.split(" "));
- if (!parseResponseForSuccess(response) || ids.size() != 2) {
- throw new ChimpException(extra);
- }
- ChimpView root = new ChimpView(ChimpView.ACCESSIBILITY_IDS, ids);
- root.setManager(this);
- return root;
- }
- }
-
- /**
- * Queries the device for a list of views with the given
- * @return A string containing the accessibility ids of the views with the given text
- */
- public String getViewsWithText(String text) throws IOException {
- synchronized(this) {
- // Monkey has trouble parsing a single word in quotes
- if (text.split(" ").length > 1) {
- text = "\"" + text + "\"";
- }
- String response = sendMonkeyEventAndGetResponse("getviewswithtext " + text);
- if (!parseResponseForSuccess(response)) {
- throw new ChimpException(parseResponseForExtra(response));
- }
- return parseResponseForExtra(response);
- }
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/adb/AdbBackend.java b/chimpchat/src/com/android/chimpchat/adb/AdbBackend.java
deleted file mode 100644
index 2cb5be7..0000000
--- a/chimpchat/src/com/android/chimpchat/adb/AdbBackend.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.adb;
-
-import com.google.common.collect.Lists;
-
-import com.android.SdkConstants;
-import com.android.chimpchat.core.IChimpBackend;
-import com.android.chimpchat.core.IChimpDevice;
-import com.android.ddmlib.AndroidDebugBridge;
-import com.android.ddmlib.IDevice;
-
-import java.io.File;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.regex.Pattern;
-
-/**
- * Backend implementation that works over ADB to talk to the device.
- */
-public class AdbBackend implements IChimpBackend {
- private static Logger LOG = Logger.getLogger(AdbBackend.class.getCanonicalName());
- // How long to wait each time we check for the device to be connected.
- private static final int CONNECTION_ITERATION_TIMEOUT_MS = 200;
- private final List<IChimpDevice> devices = Lists.newArrayList();
- private final AndroidDebugBridge bridge;
- private final boolean initAdb;
-
- /**
- * Constructs an AdbBackend with default options.
- */
- public AdbBackend() {
- this(null, false);
- }
-
- /**
- * Constructs an AdbBackend.
- *
- * @param adbLocation The location of the adb binary. If null, AdbBackend will
- * attempt to find the binary by itself.
- * @param noInitAdb If true, AdbBackend will not initialize AndroidDebugBridge.
- */
- public AdbBackend(String adbLocation, boolean noInitAdb) {
- this.initAdb = !noInitAdb;
-
- // [try to] ensure ADB is running
- if (adbLocation == null) {
- adbLocation = findAdb();
- }
-
- if (initAdb) {
- AndroidDebugBridge.init(false /* debugger support */);
- }
-
- bridge = AndroidDebugBridge.createBridge(
- adbLocation, true /* forceNewBridge */);
- }
-
- private String findAdb() {
- String mrParentLocation =
- System.getProperty("com.android.monkeyrunner.bindir"); //$NON-NLS-1$
-
-
- // in the new SDK, adb is in the platform-tools, but when run from the command line
- // in the Android source tree, then adb is next to monkeyrunner.
- if (mrParentLocation != null && mrParentLocation.length() != 0) {
- // check if there's a platform-tools folder
- File platformTools = new File(new File(mrParentLocation).getParent(),
- SdkConstants.FD_PLATFORM_TOOLS);
- if (platformTools.isDirectory()) {
- return platformTools.getAbsolutePath() + File.separator + SdkConstants.FN_ADB;
- }
-
- return mrParentLocation + File.separator + SdkConstants.FN_ADB;
- }
-
- return SdkConstants.FN_ADB;
- }
-
- /**
- * Checks the attached devices looking for one whose device id matches the specified regex.
- *
- * @param deviceIdRegex the regular expression to match against
- * @return the Device (if found), or null (if not found).
- */
- private IDevice findAttachedDevice(String deviceIdRegex) {
- Pattern pattern = Pattern.compile(deviceIdRegex);
- for (IDevice device : bridge.getDevices()) {
- String serialNumber = device.getSerialNumber();
- if (pattern.matcher(serialNumber).matches()) {
- return device;
- }
- }
- return null;
- }
-
- @Override
- public IChimpDevice waitForConnection() {
- return waitForConnection(Integer.MAX_VALUE, ".*");
- }
-
- @Override
- public IChimpDevice waitForConnection(long timeoutMs, String deviceIdRegex) {
- do {
- IDevice device = findAttachedDevice(deviceIdRegex);
- // Only return the device when it is online
- if (device != null && device.getState() == IDevice.DeviceState.ONLINE) {
- IChimpDevice chimpDevice = new AdbChimpDevice(device);
- devices.add(chimpDevice);
- return chimpDevice;
- }
-
- try {
- Thread.sleep(CONNECTION_ITERATION_TIMEOUT_MS);
- } catch (InterruptedException e) {
- LOG.log(Level.SEVERE, "Error sleeping", e);
- }
- timeoutMs -= CONNECTION_ITERATION_TIMEOUT_MS;
- } while (timeoutMs > 0);
-
- // Timeout. Give up.
- return null;
- }
-
- @Override
- public void shutdown() {
- for (IChimpDevice device : devices) {
- device.dispose();
- }
- if (initAdb) {
- AndroidDebugBridge.terminate();
- }
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java b/chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java
deleted file mode 100644
index af09efe..0000000
--- a/chimpchat/src/com/android/chimpchat/adb/AdbChimpDevice.java
+++ /dev/null
@@ -1,631 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.adb;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-
-import com.android.ddmlib.AdbCommandRejectedException;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.InstallException;
-import com.android.ddmlib.ShellCommandUnresponsiveException;
-import com.android.ddmlib.TimeoutException;
-import com.android.chimpchat.ChimpManager;
-import com.android.chimpchat.adb.LinearInterpolator.Point;
-import com.android.chimpchat.core.ChimpRect;
-import com.android.chimpchat.core.IChimpImage;
-import com.android.chimpchat.core.IChimpDevice;
-import com.android.chimpchat.core.IChimpView;
-import com.android.chimpchat.core.IMultiSelector;
-import com.android.chimpchat.core.ISelector;
-import com.android.chimpchat.core.PhysicalButton;
-import com.android.chimpchat.core.TouchPressType;
-import com.android.chimpchat.hierarchyviewer.HierarchyViewer;
-
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.UnknownHostException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.annotation.Nullable;
-
-public class AdbChimpDevice implements IChimpDevice {
- private static final Logger LOG = Logger.getLogger(AdbChimpDevice.class.getName());
-
- private static final String[] ZERO_LENGTH_STRING_ARRAY = new String[0];
- private static final long MANAGER_CREATE_TIMEOUT_MS = 30 * 1000; // 30 seconds
- private static final long MANAGER_CREATE_WAIT_TIME_MS = 1000; // wait 1 second
-
- private final ExecutorService executor = Executors.newSingleThreadExecutor();
-
- private final IDevice device;
- private ChimpManager manager;
-
- public AdbChimpDevice(IDevice device) {
- this.device = device;
- this.manager = createManager("127.0.0.1", 12345);
-
- Preconditions.checkNotNull(this.manager);
- }
-
- @Override
- public ChimpManager getManager() {
- return manager;
- }
-
- @Override
- public void dispose() {
- try {
- manager.quit();
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Error getting the manager to quit", e);
- }
- manager.close();
- executor.shutdown();
- manager = null;
- }
-
- @Override
- public HierarchyViewer getHierarchyViewer() {
- return new HierarchyViewer(device);
- }
-
- private void executeAsyncCommand(final String command,
- final LoggingOutputReceiver logger) {
- executor.submit(new Runnable() {
- @Override
- public void run() {
- try {
- device.executeShellCommand(command, logger);
- } catch (TimeoutException e) {
- LOG.log(Level.SEVERE, "Error starting command: " + command, e);
- throw new RuntimeException(e);
- } catch (AdbCommandRejectedException e) {
- LOG.log(Level.SEVERE, "Error starting command: " + command, e);
- throw new RuntimeException(e);
- } catch (ShellCommandUnresponsiveException e) {
- // This happens a lot
- LOG.log(Level.INFO, "Error starting command: " + command, e);
- throw new RuntimeException(e);
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Error starting command: " + command, e);
- throw new RuntimeException(e);
- }
- }
- });
- }
-
- private ChimpManager createManager(String address, int port) {
- try {
- device.createForward(port, port);
- } catch (TimeoutException e) {
- LOG.log(Level.SEVERE, "Timeout creating adb port forwarding", e);
- return null;
- } catch (AdbCommandRejectedException e) {
- LOG.log(Level.SEVERE, "Adb rejected adb port forwarding command: " + e.getMessage(), e);
- return null;
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Unable to create adb port forwarding: " + e.getMessage(), e);
- return null;
- }
-
- String command = "monkey --port " + port;
- executeAsyncCommand(command, new LoggingOutputReceiver(LOG, Level.FINE));
-
- // Sleep for a second to give the command time to execute.
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- LOG.log(Level.SEVERE, "Unable to sleep", e);
- }
-
- InetAddress addr;
- try {
- addr = InetAddress.getByName(address);
- } catch (UnknownHostException e) {
- LOG.log(Level.SEVERE, "Unable to convert address into InetAddress: " + address, e);
- return null;
- }
-
- // We have a tough problem to solve here. "monkey" on the device gives us no indication
- // when it has started up and is ready to serve traffic. If you try too soon, commands
- // will fail. To remedy this, we will keep trying until a single command (in this case,
- // wake) succeeds.
- boolean success = false;
- ChimpManager mm = null;
- long start = System.currentTimeMillis();
-
- while (!success) {
- long now = System.currentTimeMillis();
- long diff = now - start;
- if (diff > MANAGER_CREATE_TIMEOUT_MS) {
- LOG.severe("Timeout while trying to create chimp mananger");
- return null;
- }
-
- try {
- Thread.sleep(MANAGER_CREATE_WAIT_TIME_MS);
- } catch (InterruptedException e) {
- LOG.log(Level.SEVERE, "Unable to sleep", e);
- }
-
- Socket monkeySocket;
- try {
- monkeySocket = new Socket(addr, port);
- } catch (IOException e) {
- LOG.log(Level.FINE, "Unable to connect socket", e);
- success = false;
- continue;
- }
-
- try {
- mm = new ChimpManager(monkeySocket);
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Unable to open writer and reader to socket");
- continue;
- }
-
- try {
- mm.wake();
- } catch (IOException e) {
- LOG.log(Level.FINE, "Unable to wake up device", e);
- success = false;
- continue;
- }
- success = true;
- }
-
- return mm;
- }
-
- @Override
- public IChimpImage takeSnapshot() {
- try {
- return new AdbChimpImage(device.getScreenshot());
- } catch (TimeoutException e) {
- LOG.log(Level.SEVERE, "Unable to take snapshot", e);
- return null;
- } catch (AdbCommandRejectedException e) {
- LOG.log(Level.SEVERE, "Unable to take snapshot", e);
- return null;
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Unable to take snapshot", e);
- return null;
- }
- }
-
- @Override
- public String getSystemProperty(String key) {
- return device.getProperty(key);
- }
-
- @Override
- public String getProperty(String key) {
- try {
- return manager.getVariable(key);
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Unable to get variable: " + key, e);
- return null;
- }
- }
-
- @Override
- public Collection<String> getPropertyList() {
- try {
- return manager.listVariable();
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Unable to get variable list", e);
- return null;
- }
- }
-
- @Override
- public void wake() {
- try {
- manager.wake();
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Unable to wake device (too sleepy?)", e);
- }
- }
-
- private String shell(String... args) {
- StringBuilder cmd = new StringBuilder();
- for (String arg : args) {
- cmd.append(arg).append(" ");
- }
- return shell(cmd.toString());
- }
-
- @Override
- public String shell(String cmd) {
- // 5000 is the default timeout from the ddmlib.
- // This timeout arg is needed to the backwards compatibility.
- return shell(cmd, 5000);
- }
-
- @Override
- public String shell(String cmd, int timeout) {
- CommandOutputCapture capture = new CommandOutputCapture();
- try {
- device.executeShellCommand(cmd, capture, timeout);
- } catch (TimeoutException e) {
- LOG.log(Level.SEVERE, "Error executing command: " + cmd, e);
- return null;
- } catch (ShellCommandUnresponsiveException e) {
- LOG.log(Level.SEVERE, "Error executing command: " + cmd, e);
- return null;
- } catch (AdbCommandRejectedException e) {
- LOG.log(Level.SEVERE, "Error executing command: " + cmd, e);
- return null;
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Error executing command: " + cmd, e);
- return null;
- }
- return capture.toString();
- }
-
- @Override
- public boolean installPackage(String path) {
- try {
- String result = device.installPackage(path, true);
- if (result != null) {
- LOG.log(Level.SEVERE, "Got error installing package: "+ result);
- return false;
- }
- return true;
- } catch (InstallException e) {
- LOG.log(Level.SEVERE, "Error installing package: " + path, e);
- return false;
- }
- }
-
- @Override
- public boolean removePackage(String packageName) {
- try {
- String result = device.uninstallPackage(packageName);
- if (result != null) {
- LOG.log(Level.SEVERE, "Got error uninstalling package "+ packageName + ": " +
- result);
- return false;
- }
- return true;
- } catch (InstallException e) {
- LOG.log(Level.SEVERE, "Error installing package: " + packageName, e);
- return false;
- }
- }
-
- @Override
- public void press(String keyName, TouchPressType type) {
- try {
- switch (type) {
- case DOWN_AND_UP:
- manager.press(keyName);
- break;
- case DOWN:
- manager.keyDown(keyName);
- break;
- case UP:
- manager.keyUp(keyName);
- break;
- }
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Error sending press event: " + keyName + " " + type, e);
- }
- }
-
- @Override
- public void press(PhysicalButton key, TouchPressType type) {
- press(key.getKeyName(), type);
- }
-
- @Override
- public void type(String string) {
- try {
- manager.type(string);
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Error Typing: " + string, e);
- }
- }
-
- @Override
- public void touch(int x, int y, TouchPressType type) {
- try {
- switch (type) {
- case DOWN:
- manager.touchDown(x, y);
- break;
- case UP:
- manager.touchUp(x, y);
- break;
- case DOWN_AND_UP:
- manager.tap(x, y);
- break;
- case MOVE:
- manager.touchMove(x, y);
- break;
- }
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Error sending touch event: " + x + " " + y + " " + type, e);
- }
- }
-
- @Override
- public void reboot(String into) {
- try {
- device.reboot(into);
- } catch (TimeoutException e) {
- LOG.log(Level.SEVERE, "Unable to reboot device", e);
- } catch (AdbCommandRejectedException e) {
- LOG.log(Level.SEVERE, "Unable to reboot device", e);
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Unable to reboot device", e);
- }
- }
-
- @Override
- public void startActivity(String uri, String action, String data, String mimetype,
- Collection<String> categories, Map<String, Object> extras, String component,
- int flags) {
- List<String> intentArgs = buildIntentArgString(uri, action, data, mimetype, categories,
- extras, component, flags);
- shell(Lists.asList("am", "start",
- intentArgs.toArray(ZERO_LENGTH_STRING_ARRAY)).toArray(ZERO_LENGTH_STRING_ARRAY));
- }
-
- @Override
- public void broadcastIntent(String uri, String action, String data, String mimetype,
- Collection<String> categories, Map<String, Object> extras, String component,
- int flags) {
- List<String> intentArgs = buildIntentArgString(uri, action, data, mimetype, categories,
- extras, component, flags);
- shell(Lists.asList("am", "broadcast",
- intentArgs.toArray(ZERO_LENGTH_STRING_ARRAY)).toArray(ZERO_LENGTH_STRING_ARRAY));
- }
-
- private static boolean isNullOrEmpty(@Nullable String string) {
- return string == null || string.length() == 0;
- }
-
- private List<String> buildIntentArgString(String uri, String action, String data, String mimetype,
- Collection<String> categories, Map<String, Object> extras, String component,
- int flags) {
- List<String> parts = Lists.newArrayList();
-
- // from adb docs:
- //<INTENT> specifications include these flags:
- // [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
- // [-c <CATEGORY> [-c <CATEGORY>] ...]
- // [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
- // [--esn <EXTRA_KEY> ...]
- // [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]
- // [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
- // [-n <COMPONENT>] [-f <FLAGS>]
- // [<URI>]
-
- if (!isNullOrEmpty(action)) {
- parts.add("-a");
- parts.add(action);
- }
-
- if (!isNullOrEmpty(data)) {
- parts.add("-d");
- parts.add(data);
- }
-
- if (!isNullOrEmpty(mimetype)) {
- parts.add("-t");
- parts.add(mimetype);
- }
-
- // Handle categories
- for (String category : categories) {
- parts.add("-c");
- parts.add(category);
- }
-
- // Handle extras
- for (Entry<String, Object> entry : extras.entrySet()) {
- // Extras are either boolean, string, or int. See which we have
- Object value = entry.getValue();
- String valueString;
- String arg;
- if (value instanceof Integer) {
- valueString = Integer.toString((Integer) value);
- arg = "--ei";
- } else if (value instanceof Boolean) {
- valueString = Boolean.toString((Boolean) value);
- arg = "--ez";
- } else {
- // treat is as a string.
- valueString = value.toString();
- arg = "--es";
- }
- parts.add(arg);
- parts.add(entry.getKey());
- parts.add(valueString);
- }
-
- if (!isNullOrEmpty(component)) {
- parts.add("-n");
- parts.add(component);
- }
-
- if (flags != 0) {
- parts.add("-f");
- parts.add(Integer.toString(flags));
- }
-
- if (!isNullOrEmpty(uri)) {
- parts.add(uri);
- }
-
- return parts;
- }
-
- @Override
- public Map<String, Object> instrument(String packageName, Map<String, Object> args) {
- List<String> shellCmd = Lists.newArrayList("am", "instrument", "-w", "-r");
- for (Entry<String, Object> entry: args.entrySet()) {
- final String key = entry.getKey();
- final Object value = entry.getValue();
- if (key != null && value != null) {
- shellCmd.add("-e");
- shellCmd.add(key);
- shellCmd.add(value.toString());
- }
- }
- shellCmd.add(packageName);
- String result = shell(shellCmd.toArray(ZERO_LENGTH_STRING_ARRAY));
- return convertInstrumentResult(result);
- }
-
- /**
- * Convert the instrumentation result into it's Map representation.
- *
- * @param result the result string
- * @return the new map
- */
- @VisibleForTesting
- /* package */ static Map<String, Object> convertInstrumentResult(String result) {
- Map<String, Object> map = Maps.newHashMap();
- Pattern pattern = Pattern.compile("^INSTRUMENTATION_(\\w+): ", Pattern.MULTILINE);
- Matcher matcher = pattern.matcher(result);
-
- int previousEnd = 0;
- String previousWhich = null;
-
- while (matcher.find()) {
- if ("RESULT".equals(previousWhich)) {
- String resultLine = result.substring(previousEnd, matcher.start()).trim();
- // Look for the = in the value, and split there
- int splitIndex = resultLine.indexOf("=");
- String key = resultLine.substring(0, splitIndex);
- String value = resultLine.substring(splitIndex + 1);
-
- map.put(key, value);
- }
-
- previousEnd = matcher.end();
- previousWhich = matcher.group(1);
- }
- if ("RESULT".equals(previousWhich)) {
- String resultLine = result.substring(previousEnd, matcher.start()).trim();
- // Look for the = in the value, and split there
- int splitIndex = resultLine.indexOf("=");
- String key = resultLine.substring(0, splitIndex);
- String value = resultLine.substring(splitIndex + 1);
-
- map.put(key, value);
- }
- return map;
- }
-
- @Override
- public void drag(int startx, int starty, int endx, int endy, int steps, long ms) {
- final long iterationTime = ms / steps;
-
- LinearInterpolator lerp = new LinearInterpolator(steps);
- LinearInterpolator.Point start = new LinearInterpolator.Point(startx, starty);
- LinearInterpolator.Point end = new LinearInterpolator.Point(endx, endy);
- lerp.interpolate(start, end, new LinearInterpolator.Callback() {
- @Override
- public void step(Point point) {
- try {
- manager.touchMove(point.getX(), point.getY());
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Error sending drag start event", e);
- }
-
- try {
- Thread.sleep(iterationTime);
- } catch (InterruptedException e) {
- LOG.log(Level.SEVERE, "Error sleeping", e);
- }
- }
-
- @Override
- public void start(Point point) {
- try {
- manager.touchDown(point.getX(), point.getY());
- manager.touchMove(point.getX(), point.getY());
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Error sending drag start event", e);
- }
-
- try {
- Thread.sleep(iterationTime);
- } catch (InterruptedException e) {
- LOG.log(Level.SEVERE, "Error sleeping", e);
- }
- }
-
- @Override
- public void end(Point point) {
- try {
- manager.touchMove(point.getX(), point.getY());
- manager.touchUp(point.getX(), point.getY());
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Error sending drag end event", e);
- }
- }
- });
- }
-
-
- @Override
- public Collection<String> getViewIdList() {
- try {
- return manager.listViewIds();
- } catch(IOException e) {
- LOG.log(Level.SEVERE, "Error retrieving view IDs", e);
- return new ArrayList<String>();
- }
- }
-
- @Override
- public IChimpView getView(ISelector selector) {
- return selector.getView(manager);
- }
-
- @Override
- public Collection<IChimpView> getViews(IMultiSelector selector) {
- return selector.getViews(manager);
- }
-
- @Override
- public IChimpView getRootView() {
- try {
- return manager.getRootView();
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Error retrieving root view");
- return null;
- }
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/adb/AdbChimpImage.java b/chimpchat/src/com/android/chimpchat/adb/AdbChimpImage.java
deleted file mode 100644
index f37896f..0000000
--- a/chimpchat/src/com/android/chimpchat/adb/AdbChimpImage.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.adb;
-
-import com.android.ddmlib.RawImage;
-import com.android.chimpchat.adb.image.ImageUtils;
-import com.android.chimpchat.core.ChimpImageBase;
-
-import java.awt.image.BufferedImage;
-
-/**
- * ADB implementation of the ChimpImage class.
- */
-public class AdbChimpImage extends ChimpImageBase {
- private final RawImage image;
-
- /**
- * Create a new AdbMonkeyImage.
- *
- * @param image the image from adb.
- */
- AdbChimpImage(RawImage image) {
- this.image = image;
- }
-
- @Override
- public BufferedImage createBufferedImage() {
- return ImageUtils.convertImage(image);
- }
-
- public RawImage getRawImage() {
- return image;
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/adb/CommandOutputCapture.java b/chimpchat/src/com/android/chimpchat/adb/CommandOutputCapture.java
deleted file mode 100644
index 736e82f..0000000
--- a/chimpchat/src/com/android/chimpchat/adb/CommandOutputCapture.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.adb;
-
-import com.android.ddmlib.IShellOutputReceiver;
-
-/**
- * Shell Output Receiver that captures shell output into a String for
- * later retrieval.
- */
-public class CommandOutputCapture implements IShellOutputReceiver {
- private final StringBuilder builder = new StringBuilder();
-
- public void flush() { }
-
- public boolean isCancelled() {
- return false;
- }
-
- public void addOutput(byte[] data, int offset, int length) {
- String message = new String(data, offset, length);
- builder.append(message);
- }
-
- @Override
- public String toString() {
- return builder.toString();
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/adb/LinearInterpolator.java b/chimpchat/src/com/android/chimpchat/adb/LinearInterpolator.java
deleted file mode 100644
index 934749a..0000000
--- a/chimpchat/src/com/android/chimpchat/adb/LinearInterpolator.java
+++ /dev/null
@@ -1,128 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.adb;
-
-
-
-/**
- * Linear Interpolation class.
- */
-public class LinearInterpolator {
- private final int steps;
-
- /**
- * Use our own Point class so we don't pull in java.awt.* just for this simple class.
- */
- public static class Point {
- private final int x;
- private final int y;
-
- public Point(int x, int y) {
- this.x = x;
- this.y = y;
- }
-
- @Override
- public String toString() {
- return new StringBuilder().
- append("(").
- append(x).
- append(",").
- append(y).
- append(")").toString();
- }
-
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Point) {
- Point that = (Point) obj;
- return this.x == that.x && this.y == that.y;
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- return 0x43125315 + x + y;
- }
-
- public int getX() {
- return x;
- }
-
- public int getY() {
- return y;
- }
- }
-
- /**
- * Callback interface to recieve interpolated points.
- */
- public interface Callback {
- /**
- * Called once to inform of the start point.
- */
- void start(Point point);
- /**
- * Called once to inform of the end point.
- */
- void end(Point point);
- /**
- * Called at every step in-between start and end.
- */
- void step(Point point);
- }
-
- /**
- * Create a new linear Interpolator.
- *
- * @param steps How many steps should be in a single run. This counts the intervals
- * in-between points, so the actual number of points generated will be steps + 1.
- */
- public LinearInterpolator(int steps) {
- this.steps = steps;
- }
-
- // Copied from android.util.MathUtils since we couldn't link it in on the host.
- private static float lerp(float start, float stop, float amount) {
- return start + (stop - start) * amount;
- }
-
- /**
- * Calculate the interpolated points.
- *
- * @param start The starting point
- * @param end The ending point
- * @param callback the callback to call with each calculated points.
- */
- public void interpolate(Point start, Point end, Callback callback) {
- int xDistance = Math.abs(end.getX() - start.getX());
- int yDistance = Math.abs(end.getY() - start.getY());
- float amount = (float) (1.0 / steps);
-
-
- callback.start(start);
- for (int i = 1; i < steps; i++) {
- float newX = lerp(start.getX(), end.getX(), amount * i);
- float newY = lerp(start.getY(), end.getY(), amount * i);
-
- callback.step(new Point(Math.round(newX), Math.round(newY)));
- }
- // Generate final point
- callback.end(end);
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/adb/LoggingOutputReceiver.java b/chimpchat/src/com/android/chimpchat/adb/LoggingOutputReceiver.java
deleted file mode 100644
index e1002d1..0000000
--- a/chimpchat/src/com/android/chimpchat/adb/LoggingOutputReceiver.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.adb;
-
-import com.android.ddmlib.IShellOutputReceiver;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * Shell Output Receiver that sends shell output to a Logger.
- */
-public class LoggingOutputReceiver implements IShellOutputReceiver {
- private final Logger log;
- private final Level level;
-
- public LoggingOutputReceiver(Logger log, Level level) {
- this.log = log;
- this.level = level;
- }
-
- public void addOutput(byte[] data, int offset, int length) {
- String message = new String(data, offset, length);
- for (String line : message.split("\n")) {
- log.log(level, line);
- }
- }
-
- public void flush() { }
-
- public boolean isCancelled() {
- return false;
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/adb/image/CaptureRawAndConvertedImage.java b/chimpchat/src/com/android/chimpchat/adb/image/CaptureRawAndConvertedImage.java
deleted file mode 100644
index 6327a77..0000000
--- a/chimpchat/src/com/android/chimpchat/adb/image/CaptureRawAndConvertedImage.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.adb.image;
-
-import com.android.ddmlib.RawImage;
-import com.android.chimpchat.adb.AdbBackend;
-import com.android.chimpchat.adb.AdbChimpImage;
-import com.android.chimpchat.core.IChimpBackend;
-import com.android.chimpchat.core.IChimpImage;
-import com.android.chimpchat.core.IChimpDevice;
-
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.io.Serializable;
-
-/**
- * Utility program to capture raw and converted images from a device and write them to a file.
- * This is used to generate the test data for ImageUtilsTest.
- */
-public class CaptureRawAndConvertedImage {
- public static class ChimpRawImage implements Serializable {
- public int version;
- public int bpp;
- public int size;
- public int width;
- public int height;
- public int red_offset;
- public int red_length;
- public int blue_offset;
- public int blue_length;
- public int green_offset;
- public int green_length;
- public int alpha_offset;
- public int alpha_length;
-
- public byte[] data;
-
- public ChimpRawImage(RawImage rawImage) {
- version = rawImage.version;
- bpp = rawImage.bpp;
- size = rawImage.size;
- width = rawImage.width;
- height = rawImage.height;
- red_offset = rawImage.red_offset;
- red_length = rawImage.red_length;
- blue_offset = rawImage.blue_offset;
- blue_length = rawImage.blue_length;
- green_offset = rawImage.green_offset;
- green_length = rawImage.green_length;
- alpha_offset = rawImage.alpha_offset;
- alpha_length = rawImage.alpha_length;
-
- data = rawImage.data;
- }
-
- public RawImage toRawImage() {
- RawImage rawImage = new RawImage();
-
- rawImage.version = version;
- rawImage.bpp = bpp;
- rawImage.size = size;
- rawImage.width = width;
- rawImage.height = height;
- rawImage.red_offset = red_offset;
- rawImage.red_length = red_length;
- rawImage.blue_offset = blue_offset;
- rawImage.blue_length = blue_length;
- rawImage.green_offset = green_offset;
- rawImage.green_length = green_length;
- rawImage.alpha_offset = alpha_offset;
- rawImage.alpha_length = alpha_length;
-
- rawImage.data = data;
- return rawImage;
- }
- }
-
- private static void writeOutImage(RawImage screenshot, String name) throws IOException {
- ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(name));
- out.writeObject(new ChimpRawImage(screenshot));
- out.close();
- }
-
- public static void main(String[] args) throws IOException {
- IChimpBackend backend = new AdbBackend();
- IChimpDevice device = backend.waitForConnection();
- IChimpImage snapshot = (IChimpImage) device.takeSnapshot();
-
- // write out to a file
- snapshot.writeToFile("output.png", "png");
- writeOutImage(((AdbChimpImage)snapshot).getRawImage(), "output.raw");
- System.exit(0);
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/adb/image/ImageUtils.java b/chimpchat/src/com/android/chimpchat/adb/image/ImageUtils.java
deleted file mode 100644
index 131c9ef..0000000
--- a/chimpchat/src/com/android/chimpchat/adb/image/ImageUtils.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.adb.image;
-
-import com.android.ddmlib.RawImage;
-
-import java.awt.Point;
-import java.awt.image.BufferedImage;
-import java.awt.image.DataBuffer;
-import java.awt.image.DataBufferByte;
-import java.awt.image.PixelInterleavedSampleModel;
-import java.awt.image.Raster;
-import java.awt.image.WritableRaster;
-import java.util.Hashtable;
-/**
- * Useful image related functions.
- */
-public class ImageUtils {
- // Utility class
- private ImageUtils() { }
-
- private static Hashtable<?,?> EMPTY_HASH = new Hashtable();
- private static int[] BAND_OFFSETS_32 = { 0, 1, 2, 3 };
- private static int[] BAND_OFFSETS_16 = { 0, 1 };
-
- /**
- * Convert a raw image into a buffered image.
- *
- * @param rawImage the raw image to convert
- * @param image the old image to (possibly) recycle
- * @return the converted image
- */
- public static BufferedImage convertImage(RawImage rawImage, BufferedImage image) {
- switch (rawImage.bpp) {
- case 16:
- return rawImage16toARGB(image, rawImage);
- case 32:
- return rawImage32toARGB(rawImage);
- }
- return null;
- }
-
- /**
- * Convert a raw image into a buffered image.
- *
- * @param rawImage the image to convert.
- * @return the converted image.
- */
- public static BufferedImage convertImage(RawImage rawImage) {
- return convertImage(rawImage, null);
- }
-
- static int getMask(int length) {
- int res = 0;
- for (int i = 0 ; i < length ; i++) {
- res = (res << 1) + 1;
- }
-
- return res;
- }
-
- private static BufferedImage rawImage32toARGB(RawImage rawImage) {
- // Do as much as we can to not make an extra copy of the data. This is just a bunch of
- // classes that wrap's the raw byte array of the image data.
- DataBufferByte dataBuffer = new DataBufferByte(rawImage.data, rawImage.size);
-
- PixelInterleavedSampleModel sampleModel =
- new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, rawImage.width, rawImage.height,
- 4, rawImage.width * 4, BAND_OFFSETS_32);
- WritableRaster raster = Raster.createWritableRaster(sampleModel, dataBuffer,
- new Point(0, 0));
- return new BufferedImage(new ThirtyTwoBitColorModel(rawImage), raster, false, EMPTY_HASH);
- }
-
- private static BufferedImage rawImage16toARGB(BufferedImage image, RawImage rawImage) {
- // Do as much as we can to not make an extra copy of the data. This is just a bunch of
- // classes that wrap's the raw byte array of the image data.
- DataBufferByte dataBuffer = new DataBufferByte(rawImage.data, rawImage.size);
-
- PixelInterleavedSampleModel sampleModel =
- new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, rawImage.width, rawImage.height,
- 2, rawImage.width * 2, BAND_OFFSETS_16);
- WritableRaster raster = Raster.createWritableRaster(sampleModel, dataBuffer,
- new Point(0, 0));
- return new BufferedImage(new SixteenBitColorModel(rawImage), raster, false, EMPTY_HASH);
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/adb/image/SixteenBitColorModel.java b/chimpchat/src/com/android/chimpchat/adb/image/SixteenBitColorModel.java
deleted file mode 100644
index ad1392f..0000000
--- a/chimpchat/src/com/android/chimpchat/adb/image/SixteenBitColorModel.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.adb.image;
-
-import com.android.ddmlib.RawImage;
-
-import java.awt.Transparency;
-import java.awt.color.ColorSpace;
-import java.awt.image.ColorModel;
-import java.awt.image.DataBuffer;
-import java.awt.image.Raster;
-
-/**
- * Internal color model used to do conversion of 16bpp RawImages.
- */
-class SixteenBitColorModel extends ColorModel {
- private static final int[] BITS = {
- 8, 8, 8, 8
- };
- public SixteenBitColorModel(RawImage rawImage) {
- super(32
- , BITS, ColorSpace.getInstance(ColorSpace.CS_sRGB),
- true, false, Transparency.TRANSLUCENT,
- DataBuffer.TYPE_BYTE);
- }
-
- @Override
- public boolean isCompatibleRaster(Raster raster) {
- return true;
- }
-
- private int getPixel(Object inData) {
- byte[] data = (byte[]) inData;
- int value = data[0] & 0x00FF;
- value |= (data[1] << 8) & 0x0FF00;
-
- return value;
- }
-
- @Override
- public int getAlpha(Object inData) {
- return 0xff;
- }
-
- @Override
- public int getBlue(Object inData) {
- int pixel = getPixel(inData);
- return ((pixel >> 0) & 0x01F) << 3;
- }
-
- @Override
- public int getGreen(Object inData) {
- int pixel = getPixel(inData);
- return ((pixel >> 5) & 0x03F) << 2;
- }
-
- @Override
- public int getRed(Object inData) {
- int pixel = getPixel(inData);
- return ((pixel >> 11) & 0x01F) << 3;
- }
-
- @Override
- public int getAlpha(int pixel) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getBlue(int pixel) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getGreen(int pixel) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getRed(int pixel) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/adb/image/ThirtyTwoBitColorModel.java b/chimpchat/src/com/android/chimpchat/adb/image/ThirtyTwoBitColorModel.java
deleted file mode 100644
index d4e8c9e..0000000
--- a/chimpchat/src/com/android/chimpchat/adb/image/ThirtyTwoBitColorModel.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.adb.image;
-
-import com.android.ddmlib.RawImage;
-
-import java.awt.Transparency;
-import java.awt.color.ColorSpace;
-import java.awt.image.ColorModel;
-import java.awt.image.DataBuffer;
-import java.awt.image.Raster;
-
-/**
- * Internal color model used to do conversion of 32bpp RawImages.
- */
-class ThirtyTwoBitColorModel extends ColorModel {
- private static final int[] BITS = {
- 8, 8, 8, 8,
- };
- private final int alphaLength;
- private final int alphaMask;
- private final int alphaOffset;
- private final int blueMask;
- private final int blueLength;
- private final int blueOffset;
- private final int greenMask;
- private final int greenLength;
- private final int greenOffset;
- private final int redMask;
- private final int redLength;
- private final int redOffset;
-
- public ThirtyTwoBitColorModel(RawImage rawImage) {
- super(32, BITS, ColorSpace.getInstance(ColorSpace.CS_sRGB),
- true, false, Transparency.TRANSLUCENT,
- DataBuffer.TYPE_BYTE);
-
- redOffset = rawImage.red_offset;
- redLength = rawImage.red_length;
- redMask = ImageUtils.getMask(redLength);
- greenOffset = rawImage.green_offset;
- greenLength = rawImage.green_length;
- greenMask = ImageUtils.getMask(greenLength);
- blueOffset = rawImage.blue_offset;
- blueLength = rawImage.blue_length;
- blueMask = ImageUtils.getMask(blueLength);
- alphaLength = rawImage.alpha_length;
- alphaOffset = rawImage.alpha_offset;
- alphaMask = ImageUtils.getMask(alphaLength);
- }
-
- @Override
- public boolean isCompatibleRaster(Raster raster) {
- return true;
- }
-
- private int getPixel(Object inData) {
- byte[] data = (byte[]) inData;
- int value = data[0] & 0x00FF;
- value |= (data[1] & 0x00FF) << 8;
- value |= (data[2] & 0x00FF) << 16;
- value |= (data[3] & 0x00FF) << 24;
-
- return value;
- }
-
- @Override
- public int getAlpha(Object inData) {
- int pixel = getPixel(inData);
- if(alphaLength == 0) {
- return 0xff;
- }
- return ((pixel >>> alphaOffset) & alphaMask) << (8 - alphaLength);
- }
-
- @Override
- public int getBlue(Object inData) {
- int pixel = getPixel(inData);
- return ((pixel >>> blueOffset) & blueMask) << (8 - blueLength);
- }
-
- @Override
- public int getGreen(Object inData) {
- int pixel = getPixel(inData);
- return ((pixel >>> greenOffset) & greenMask) << (8 - greenLength);
- }
-
- @Override
- public int getRed(Object inData) {
- int pixel = getPixel(inData);
- return ((pixel >>> redOffset) & redMask) << (8 - redLength);
- }
-
- @Override
- public int getAlpha(int pixel) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getBlue(int pixel) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getGreen(int pixel) {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public int getRed(int pixel) {
- throw new UnsupportedOperationException();
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/By.java b/chimpchat/src/com/android/chimpchat/core/By.java
deleted file mode 100644
index 364eab4..0000000
--- a/chimpchat/src/com/android/chimpchat/core/By.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.chimpchat.core;
-
-/**
- * A class that lets you select objects based on different criteria.
- * It operates similar to WebDriver's By class.
- */
-public class By {
- /**
- * A method to let you select items by id.
- * @param id The string id of the object you want
- * @return a selector that will select the appropriate item by id
- */
- public static ISelector id(String id) {
- return new SelectorId(id);
- }
-
- /**
- * A method that lets you select items by accessibility ids.
- * @param windowId the windowId of the object you want to select.
- * @param accessibilityId the accessibility id of the object you want to select
- * @return a selector that will select the appropriate object by its accessibility ids.
- */
- public static ISelector accessibilityIds(int windowId, int accessibilityId){
- return new SelectorAccessibilityIds(windowId, accessibilityId);
- }
-
- public static IMultiSelector text(String searchText) {
- return new MultiSelectorText(searchText);
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/ChimpException.java b/chimpchat/src/com/android/chimpchat/core/ChimpException.java
deleted file mode 100644
index 9546595..0000000
--- a/chimpchat/src/com/android/chimpchat/core/ChimpException.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.core;
-
-public class ChimpException extends RuntimeException {
- public ChimpException(String s) {
- super(s);
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/ChimpImageBase.java b/chimpchat/src/com/android/chimpchat/core/ChimpImageBase.java
deleted file mode 100644
index e1ec29f..0000000
--- a/chimpchat/src/com/android/chimpchat/core/ChimpImageBase.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.core;
-
-import java.awt.Graphics;
-import java.awt.image.BufferedImage;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.IOException;
-import java.lang.ref.WeakReference;
-import java.util.Iterator;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.imageio.ImageIO;
-import javax.imageio.ImageWriter;
-import javax.imageio.stream.ImageOutputStream;
-
-/**
- * Base class with basic functionality for ChimpImage implementations.
- */
-public abstract class ChimpImageBase implements IChimpImage {
- private static Logger LOG = Logger.getLogger(ChimpImageBase.class.getCanonicalName());
-
- /**
- * Convert the ChimpImage to a BufferedImage.
- *
- * @return a BufferedImage for this ChimpImage.
- */
- @Override
- public abstract BufferedImage createBufferedImage();
-
- // Cache the BufferedImage so we don't have to generate it every time.
- private WeakReference<BufferedImage> cachedBufferedImage = null;
-
- /**
- * Utility method to handle getting the BufferedImage and managing the cache.
- *
- * @return the BufferedImage for this image.
- */
- @Override
- public BufferedImage getBufferedImage() {
- // Check the cache first
- if (cachedBufferedImage != null) {
- BufferedImage img = cachedBufferedImage.get();
- if (img != null) {
- return img;
- }
- }
-
- // Not in the cache, so create it and cache it.
- BufferedImage img = createBufferedImage();
- cachedBufferedImage = new WeakReference<BufferedImage>(img);
- return img;
- }
-
- @Override
- public byte[] convertToBytes(String format) {
- BufferedImage argb = convertSnapshot();
-
- ByteArrayOutputStream os = new ByteArrayOutputStream();
- try {
- ImageIO.write(argb, format, os);
- } catch (IOException e) {
- return new byte[0];
- }
- return os.toByteArray();
- }
-
- @Override
- public boolean writeToFile(String path, String format) {
- if (format != null) {
- return writeToFileHelper(path, format);
- }
- int offset = path.lastIndexOf('.');
- if (offset < 0) {
- return writeToFileHelper(path, "png");
- }
- String ext = path.substring(offset + 1);
- Iterator<ImageWriter> writers = ImageIO.getImageWritersBySuffix(ext);
- if (!writers.hasNext()) {
- return writeToFileHelper(path, "png");
- }
- ImageWriter writer = writers.next();
- BufferedImage image = convertSnapshot();
- try {
- File f = new File(path);
- f.delete();
-
- ImageOutputStream outputStream = ImageIO.createImageOutputStream(f);
- writer.setOutput(outputStream);
-
- try {
- writer.write(image);
- } finally {
- writer.dispose();
- outputStream.flush();
- }
- } catch (IOException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public int getPixel(int x, int y) {
- BufferedImage image = getBufferedImage();
- return image.getRGB(x, y);
- }
-
- private BufferedImage convertSnapshot() {
- BufferedImage image = getBufferedImage();
-
- // Convert the image to ARGB so ImageIO writes it out nicely
- BufferedImage argb = new BufferedImage(image.getWidth(), image.getHeight(),
- BufferedImage.TYPE_INT_ARGB);
- Graphics g = argb.createGraphics();
- g.drawImage(image, 0, 0, null);
- g.dispose();
- return argb;
- }
-
- private boolean writeToFileHelper(String path, String format) {
- BufferedImage argb = convertSnapshot();
-
- try {
- ImageIO.write(argb, format, new File(path));
- } catch (IOException e) {
- return false;
- }
- return true;
- }
-
- @Override
- public boolean sameAs(IChimpImage other, double percent) {
- BufferedImage otherImage = other.getBufferedImage();
- BufferedImage myImage = getBufferedImage();
-
- // Easy size check
- if (otherImage.getWidth() != myImage.getWidth()) {
- return false;
- }
- if (otherImage.getHeight() != myImage.getHeight()) {
- return false;
- }
-
- int[] otherPixel = new int[1];
- int[] myPixel = new int[1];
-
- int width = myImage.getWidth();
- int height = myImage.getHeight();
-
- int numDiffPixels = 0;
- // Now, go through pixel-by-pixel and check that the images are the same;
- for (int y = 0; y < height; y++) {
- for (int x = 0; x < width; x++) {
- if (myImage.getRGB(x, y) != otherImage.getRGB(x, y)) {
- numDiffPixels++;
- }
- }
- }
- double numberPixels = (height * width);
- double diffPercent = numDiffPixels / numberPixels;
- return percent <= 1.0 - diffPercent;
- }
-
- // TODO: figure out the location of this class and is superclasses
- private static class BufferedImageChimpImage extends ChimpImageBase {
- private final BufferedImage image;
-
- public BufferedImageChimpImage(BufferedImage image) {
- this.image = image;
- }
-
- @Override
- public BufferedImage createBufferedImage() {
- return image;
- }
- }
-
- public static IChimpImage loadImageFromFile(String path) {
- File f = new File(path);
- if (f.exists() && f.canRead()) {
- try {
- BufferedImage bufferedImage = ImageIO.read(new File(path));
- if (bufferedImage == null) {
- LOG.log(Level.WARNING, "Cannot decode file %s", path);
- return null;
- }
- return new BufferedImageChimpImage(bufferedImage);
- } catch (IOException e) {
- LOG.log(Level.WARNING, "Exception trying to decode image", e);
- return null;
- }
- } else {
- LOG.log(Level.WARNING, "Cannot read file %s", path);
- return null;
- }
- }
-
- @Override
- public IChimpImage getSubImage(int x, int y, int w, int h) {
- BufferedImage image = getBufferedImage();
- return new BufferedImageChimpImage(image.getSubimage(x, y, w, h));
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/ChimpRect.java b/chimpchat/src/com/android/chimpchat/core/ChimpRect.java
deleted file mode 100644
index 956ec0d..0000000
--- a/chimpchat/src/com/android/chimpchat/core/ChimpRect.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.chimpchat.core;
-
-/**
- * A class for holding information about view locations
- */
-public class ChimpRect {
- public int left;
- public int top;
- public int right;
- public int bottom;
-
- /**
- * Creates an empty ChimpRect object. All coordinates are initialized to 0.
- */
- public ChimpRect() {}
-
- /**
- * Create a new ChimpRect with the given coordinates.
- * @param left The X coordinate of the left side of the rectangle
- * @param top The Y coordinate of the top of the rectangle
- * @param right The X coordinate of the right side of the rectangle
- * @param bottom The Y coordinate of the bottom of the rectangle
- */
- public ChimpRect(int left, int top, int right, int bottom) {
- this.left = left;
- this.top = top;
- this.right = right;
- this.bottom = bottom;
- }
-
- /**
- * A comparison method to determine if the object is equivalent to other ChimpRects.
- * @param obj The object to compare it to
- * @return True if the object is an equivalent rectangle, false otherwise.
- */
- @Override
- public boolean equals(Object obj) {
- if(obj instanceof ChimpRect){
- ChimpRect r = (ChimpRect) obj;
- if (r != null) {
- return left == r.left && top == r.top && right == r.right
- && bottom == r.bottom;
- }
- }
- return false;
- }
-
- /**
- * The width of the ChimpRect
- * @return the width of the rectangle
- */
- public int getWidth() {
- return right-left;
- }
-
- /**
- * The height of the ChimpRect
- * @return the height of the rectangle
- */
- public int getHeight() {
- return bottom-top;
- }
-
- /**
- * Returns a 2 item int array with the x, y coordinates of the center of the ChimpRect.
- * @return a 2 item int array. The first item is the x value of the center of the ChimpRect and
- * the second item is the y value.
- */
- public int[] getCenter() {
- int[] center = new int[2];
- center[0] = left + getWidth() / 2;
- center[1] = top + getHeight() / 2;
- return center;
- }
-
- /**
- * Returns a representation of the rectangle in string form
- * @return a string representation of the rectangle
- */
- public String toString() {
- StringBuilder sb = new StringBuilder();
- sb.append("ChimpRect ");
- sb.append("top: ").append(top).append(" ");
- sb.append("right: ").append(right).append(" ");
- sb.append("bottom: ").append(bottom).append(" ");
- sb.append("left: ").append(left).append(" ");
- return sb.toString();
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/ChimpView.java b/chimpchat/src/com/android/chimpchat/core/ChimpView.java
deleted file mode 100644
index c1c5be3..0000000
--- a/chimpchat/src/com/android/chimpchat/core/ChimpView.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.chimpchat.core;
-
-import com.android.chimpchat.ChimpManager;
-
-import com.google.common.collect.Lists;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/* A class for querying a view object by its id */
-public class ChimpView implements IChimpView {
- private static final Logger LOG = Logger.getLogger(ChimpView.class.getName());
- public static final String ACCESSIBILITY_IDS = "accessibilityids";
- public static final String VIEW_ID = "viewid";
-
- private String viewType;
- private List<String> ids;
- private ChimpManager manager;
-
- public ChimpView(String viewType, List<String> ids) {
- this.viewType = viewType;
- this.ids = ids;
- }
-
- public void setManager(ChimpManager manager) {
- this.manager = manager;
- }
-
- private String queryView(String query) {
- try {
- return manager.queryView(viewType, ids, query);
- } catch(IOException e) {
- LOG.log(Level.SEVERE, "Error querying view: " + e.getMessage());
- return "";
- }
- }
-
- /**
- * Get the coordinates for the view with the given id.
- * @return a ChimpRect object with the coordinates for the corners of the view
- */
- public ChimpRect getLocation() {
- List<String> result = Lists.newArrayList(queryView("getlocation").split(" "));
- if (result.size() == 4) {
- try {
- int left = Integer.parseInt(result.get(0));
- int top = Integer.parseInt(result.get(1));
- int width = Integer.parseInt(result.get(2));
- int height = Integer.parseInt(result.get(3));
- return new ChimpRect(left, top, left+width, top+height);
- } catch (NumberFormatException e) {
- return new ChimpRect();
- }
- }
- return new ChimpRect();
- }
-
- /**
- * Retrieve the text contained by the view
- * @return the text contained by the view
- */
- public String getText() {
- return queryView("gettext");
- }
-
- /**
- * Get the class of the view
- * @return the class name of the view
- */
- public String getViewClass(){
- return queryView("getclass");
- }
-
- /**
- * Get the checked status of the view.
- * @return true if the view is checked, false otherwise
- */
- public boolean getChecked(){
- return Boolean.valueOf(queryView("getchecked").trim());
- }
-
- /**
- * Get whether the view is enabled or not.
- * @return true if the view is enabled, false otherwise
- */
- public boolean getEnabled(){
- return Boolean.valueOf(queryView("getenabled").trim());
- }
-
- /**
- * Get the selected status of the view.
- * @return true if the view is selected, false otherwise
- */
- public boolean getSelected(){
- return Boolean.valueOf(queryView("getselected").trim());
- }
-
- /**
- * Set the selected status of the view.
- * @param selected the select status to set for the view
- */
- public void setSelected(boolean selected) {
- queryView("setselected " + selected);
- }
-
- /**
- * Get the focused status of the view.
- * @return true if the view is focused, false otherwise
- */
- public boolean getFocused(){
- return Boolean.valueOf(queryView("getselected").trim());
- }
-
- /**
- * Set the focused status of the view.
- * @param focused the focus status to set for the view
- */
- public void setFocused(boolean focused) {
- queryView("setfocused " + focused);
- }
-
- /**
- * Get the parent of the view.
- * @return the parent of the view
- */
- public IChimpView getParent() {
- List<String> results = Lists.newArrayList(queryView("getparent").split(" "));
- if (results.size() == 2) {
- ChimpView parent = new ChimpView(ChimpView.ACCESSIBILITY_IDS, results);
- parent.setManager(manager);
- return parent;
- }
- return null;
- }
-
- /**
- * Gets the children of the view.
- * @return the children of the view as a List of IChimpViews
- */
- public List<IChimpView> getChildren() {
- List<String> results = Lists.newArrayList(queryView("getchildren").split(" "));
- /* We make sure this has an even number of results because we don't necessarily know how
- * many children there are, but we know all children will return a pair of accessibility ids
- */
- if (results.size() % 2 == 0) {
- List<IChimpView> children = new ArrayList<IChimpView>();
- for (int i = 0; i < results.size()/2; i++) {
- List<String> ids = Lists.newArrayList(results.get(2 * i), results.get(2 * i + 1));
- ChimpView child = new ChimpView(ChimpView.ACCESSIBILITY_IDS, ids);
- child.setManager(manager);
- children.add(child);
- }
- return children;
- }
- return new ArrayList<IChimpView>();
- }
-
-
- /**
- * Gets the accessibility ids of the current view
- * @return the accessibility ids of the current view. Its returned as a two-item array of ints
- * with first int being the window id, and the second int being the accessibility view id.
- */
- public int[] getAccessibilityIds() {
- List<String> results = Lists.newArrayList(queryView("getaccessibilityids").split(" "));
- if (results.size() == 2) {
- int[] accessibilityIds = new int[2];
- try {
- accessibilityIds[0] = Integer.parseInt(results.get(0));
- accessibilityIds[1] = Integer.parseInt(results.get(1));
- return accessibilityIds;
- } catch (NumberFormatException e) {
- LOG.log(Level.SEVERE, "Error retrieving accesibility ids: " + e.getMessage());
- }
- }
- int[] empty = {0,0};
- return empty;
- }
-
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/IChimpBackend.java b/chimpchat/src/com/android/chimpchat/core/IChimpBackend.java
deleted file mode 100644
index ac9353d..0000000
--- a/chimpchat/src/com/android/chimpchat/core/IChimpBackend.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.core;
-
-import com.android.chimpchat.core.IChimpDevice;
-
-/**
- * Interface between the ChimpChat API and the ChimpChat backend that communicates
- * with Monkey.
- */
-public interface IChimpBackend {
- /**
- * Wait for a default device to connect to the backend.
- *
- * @return the connected device (or null if timeout);
- */
- IChimpDevice waitForConnection();
-
- /**
- * Wait for a device to connect to the backend.
- *
- * @param timeoutMs how long (in ms) to wait
- * @param deviceIdRegex the regular expression to specify which device to wait for.
- * @return the connected device (or null if timeout);
- */
- IChimpDevice waitForConnection(long timeoutMs, String deviceIdRegex);
-
- /**
- * Shutdown the backend and cleanup any resources it was using.
- */
- void shutdown();
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/IChimpDevice.java b/chimpchat/src/com/android/chimpchat/core/IChimpDevice.java
deleted file mode 100644
index 60cfa76..0000000
--- a/chimpchat/src/com/android/chimpchat/core/IChimpDevice.java
+++ /dev/null
@@ -1,247 +0,0 @@
-
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.core;
-
-import com.android.chimpchat.ChimpManager;
-import com.android.chimpchat.hierarchyviewer.HierarchyViewer;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Map;
-
-import javax.annotation.Nullable;
-
-/**
- * ChimpDevice interface.
- */
-public interface IChimpDevice {
- /**
- * Create a ChimpManager for talking to this device.
- *
- * @return the ChimpManager
- */
- ChimpManager getManager();
-
- /**
- * Dispose of any native resources this device may have taken hold of.
- */
- void dispose();
-
- /**
- * @return hierarchy viewer implementation for querying state of the view
- * hierarchy.
- */
- HierarchyViewer getHierarchyViewer();
-
- /**
- * Take the current screen's snapshot.
- * @return the snapshot image
- */
- IChimpImage takeSnapshot();
-
- /**
- * Reboot the device.
- *
- * @param into which bootloader to boot into. Null means default reboot.
- */
- void reboot(@Nullable String into);
-
- /**
- * List properties of the device that we can inspect
- *
- * @return the list of property keys
- */
- Collection<String> getPropertyList();
-
- /**
- * Get device's property.
- *
- * @param key the property name
- * @return the property value
- */
- String getProperty(String key);
-
- /**
- * Get system property.
- *
- * @param key the name of the system property
- * @return the property value
- */
- String getSystemProperty(String key);
-
- /**
- * Perform a touch of the given type at (x,y).
- *
- * @param x the x coordinate
- * @param y the y coordinate
- * @param type the touch type
- */
- void touch(int x, int y, TouchPressType type);
-
- /**
- * Perform a press of a given type using a given key.
- *
- * @param keyName the name of the key to use
- * @param type the type of press to perform
- */
- void press(String keyName, TouchPressType type);
-
-
- /**
- * Perform a press of a given type using a given key.
- *
- * @param key the key to press
- * @param type the type of press to perform
- */
- void press(PhysicalButton key, TouchPressType type);
-
- /**
- * Perform a drag from one one location to another
- *
- * @param startx the x coordinate of the drag's starting point
- * @param starty the y coordinate of the drag's starting point
- * @param endx the x coordinate of the drag's end point
- * @param endy the y coordinate of the drag's end point
- * @param steps the number of steps to take when interpolating points
- * @param ms the duration of the drag
- */
- void drag(int startx, int starty, int endx, int endy, int steps, long ms);
-
- /**
- * Type a given string.
- *
- * @param string the string to type
- */
- void type(String string);
-
- /**
- * Execute a shell command.
- *
- * Will timeout if there is no ouput for 5 secounds.
- *
- * @param cmd the command to execute
- * @return the output of the command
- */
- String shell(String cmd);
-
- /**
- * Execute a shell command.
- *
- * @param cmd the command to execute
- * @param timeout maximum time to output response
- * @return the output of the command
- */
- String shell(String cmd, int timeout);
-
- /**
- * Install a given package.
- *
- * @param path the path to the installation package
- * @return true if success
- */
- boolean installPackage(String path);
-
- /**
- * Uninstall a given package.
- *
- * @param packageName the name of the package
- * @return true if success
- */
- boolean removePackage(String packageName);
-
- /**
- * Start an activity.
- *
- * @param uri the URI for the Intent
- * @param action the action for the Intent
- * @param data the data URI for the Intent
- * @param mimeType the mime type for the Intent
- * @param categories the category names for the Intent
- * @param extras the extras to add to the Intent
- * @param component the component of the Intent
- * @param flags the flags for the Intent
- */
- void startActivity(@Nullable String uri, @Nullable String action,
- @Nullable String data, @Nullable String mimeType,
- Collection<String> categories, Map<String, Object> extras, @Nullable String component,
- int flags);
-
- /**
- * Send a broadcast intent to the device.
- *
- * @param uri the URI for the Intent
- * @param action the action for the Intent
- * @param data the data URI for the Intent
- * @param mimeType the mime type for the Intent
- * @param categories the category names for the Intent
- * @param extras the extras to add to the Intent
- * @param component the component of the Intent
- * @param flags the flags for the Intent
- */
- void broadcastIntent(@Nullable String uri, @Nullable String action,
- @Nullable String data, @Nullable String mimeType,
- Collection<String> categories, Map<String, Object> extras, @Nullable String component,
- int flags);
-
- /**
- * Run the specified package with instrumentation and return the output it
- * generates.
- *
- * Use this to run a test package using InstrumentationTestRunner.
- *
- * @param packageName The class to run with instrumentation. The format is
- * packageName/className. Use packageName to specify the Android package to
- * run, and className to specify the class to run within that package. For
- * test packages, this is usually testPackageName/InstrumentationTestRunner
- * @param args a map of strings to objects containing the arguments to pass
- * to this instrumentation.
- * @return A map of strings to objects for the output from the package.
- * For a test package, contains a single key-value pair: the key is 'stream'
- * and the value is a string containing the test output.
- */
- Map<String, Object> instrument(String packageName,
- Map<String, Object> args);
-
- /**
- * Wake up the screen on the device.
- */
- void wake();
-
- /**
- * List the possible view ID strings from the current applications resource file
- * @return the list of view id strings
- */
- Collection<String> getViewIdList();
-
- /**
- * Retrieve the view object for the view with the given id.
- * @return a view object for the view with the given id
- */
- IChimpView getView(ISelector selector);
-
- /**
- * Retrive the root view object.
- * @return the root view object.
- */
- IChimpView getRootView();
-
- /**
- * Retrieves the view objects that match the given selector
- * @return A list of views that match the given selector
- */
- Collection<IChimpView> getViews(IMultiSelector selector);
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/IChimpImage.java b/chimpchat/src/com/android/chimpchat/core/IChimpImage.java
deleted file mode 100644
index 6cd8f53..0000000
--- a/chimpchat/src/com/android/chimpchat/core/IChimpImage.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.core;
-
-import java.awt.image.BufferedImage;
-
-/**
- * ChimpImage interface.
- *
- * This interface defines an image representing a screen snapshot.
- */
-public interface IChimpImage {
- // TODO: add java docs
- BufferedImage createBufferedImage();
- BufferedImage getBufferedImage();
-
- IChimpImage getSubImage(int x, int y, int w, int h);
-
- byte[] convertToBytes(String format);
- boolean writeToFile(String path, String format);
- int getPixel(int x, int y);
- boolean sameAs(IChimpImage other, double percent);
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/IChimpView.java b/chimpchat/src/com/android/chimpchat/core/IChimpView.java
deleted file mode 100644
index 177271a..0000000
--- a/chimpchat/src/com/android/chimpchat/core/IChimpView.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.chimpchat.core;
-
-import com.android.chimpchat.ChimpManager;
-
-import java.util.List;
-
-/**
- * An interface for view introspection.
- */
-public interface IChimpView {
-
- /**
- * Set the manager for this view to communicate through.
- */
- void setManager(ChimpManager manager);
-
- /**
- * Obtain the class of the view as a string
- */
- String getViewClass();
-
- /**
- * Obtain the text contained in the view
- */
- String getText();
-
- /**
- * Obtain the location of the view on the device screen
- */
- ChimpRect getLocation();
-
- /**
- * Obtain the checked status of this view.
- */
- boolean getChecked();
-
- /**
- * Obtain the enabled status of this view.
- */
- boolean getEnabled();
-
- /**
- * Obtain the selected status of this view.
- */
- boolean getSelected();
-
- /**
- * Set the selected status of the this view
- */
- void setSelected(boolean selected);
-
- /**
- * Obtain the focused status of this view.
- */
- boolean getFocused();
-
- /**
- * Set the focused status of this view.
- */
- void setFocused(boolean focused);
-
- /**
- * Retrieve the parent of this view if it has one.
- */
- IChimpView getParent();
-
- /**
- * Get the children of this view as a list of IChimpViews.
- */
- List<IChimpView> getChildren();
-
- /**
- * Get the accessibility ids of this view.
- */
- int[] getAccessibilityIds();
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/IMultiSelector.java b/chimpchat/src/com/android/chimpchat/core/IMultiSelector.java
deleted file mode 100644
index 43e67fb..0000000
--- a/chimpchat/src/com/android/chimpchat/core/IMultiSelector.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.chimpchat.core;
-
-import com.android.chimpchat.ChimpManager;
-
-import java.util.Collection;
-
-/** An interface for selectors that select more than one item */
-public interface IMultiSelector {
- /**
- * A method that allows you to get a list of views based on the given selector type
- */
- Collection<IChimpView> getViews(ChimpManager manager);
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/ISelector.java b/chimpchat/src/com/android/chimpchat/core/ISelector.java
deleted file mode 100644
index c3db2a5..0000000
--- a/chimpchat/src/com/android/chimpchat/core/ISelector.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.chimpchat.core;
-
-import com.android.chimpchat.ChimpManager;
-
-/**
- * An interface for selectors
- */
-public interface ISelector {
- /**
- * A method that allows you to get a view based on the give selector type
- */
- IChimpView getView(ChimpManager manager);
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/MultiSelectorText.java b/chimpchat/src/com/android/chimpchat/core/MultiSelectorText.java
deleted file mode 100644
index c7bf362..0000000
--- a/chimpchat/src/com/android/chimpchat/core/MultiSelectorText.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.chimpchat.core;
-
-import com.android.chimpchat.ChimpManager;
-
-import com.google.common.collect.Lists;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/** A class for selecting objects by their text */
-public class MultiSelectorText implements IMultiSelector {
- private static final Logger LOG = Logger.getLogger(ChimpView.class.getName());
- private String text;
-
- /**
- * @param text the text which to select objects by
- */
- public MultiSelectorText(String text) {
- this.text = text;
- }
-
- /**
- * A method for selecting views by the given text.
- * @return The collection of views that contain the given text
- */
- public Collection<IChimpView> getViews(ChimpManager manager) {
- String response;
- List<String> ids;
- try {
- response = manager.getViewsWithText(text);
- ids = Arrays.asList(response.split(" "));
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Error communicating with device: " + e.getMessage());
- return new ArrayList<IChimpView>();
- }
- /* We make sure this has an even number of results because we don't necessarily know how
- * many views with the given textthere are, but we know all of the views will return a pair
- * of accessibility ids */
- if (ids.size() % 2 == 0) {
- List<IChimpView> views = new ArrayList<IChimpView>();
- for (int i = 0; i < ids.size()/2; i++) {
- List<String> accessibilityIds =
- Lists.newArrayList(ids.get(2 * i ), ids.get(2 * i + 1));
- ChimpView view = new ChimpView(ChimpView.ACCESSIBILITY_IDS, accessibilityIds);
- view.setManager(manager);
- views.add(view);
- }
- return views;
- }
- LOG.log(Level.SEVERE, "Error retrieving views: " + response);
- return Collections.emptyList();
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/PhysicalButton.java b/chimpchat/src/com/android/chimpchat/core/PhysicalButton.java
deleted file mode 100644
index 8faabdd..0000000
--- a/chimpchat/src/com/android/chimpchat/core/PhysicalButton.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.core;
-
-public enum PhysicalButton {
- HOME("KEYCODE_HOME"),
- SEARCH("KEYCODE_SEARCH"),
- MENU("KEYCODE_MENU"),
- BACK("KEYCODE_BACK"),
- DPAD_UP("DPAD_UP"),
- DPAD_DOWN("DPAD_DOWN"),
- DPAD_LEFT("DPAD_LEFT"),
- DPAD_RIGHT("DPAD_RIGHT"),
- DPAD_CENTER("DPAD_CENTER"),
- ENTER("enter");
-
- private String keyName;
-
- private PhysicalButton(String keyName) {
- this.keyName = keyName;
- }
-
- public String getKeyName() {
- return keyName;
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/SelectorAccessibilityIds.java b/chimpchat/src/com/android/chimpchat/core/SelectorAccessibilityIds.java
deleted file mode 100644
index 7e534b3..0000000
--- a/chimpchat/src/com/android/chimpchat/core/SelectorAccessibilityIds.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.chimpchat.core;
-
-import com.android.chimpchat.ChimpManager;
-
-import com.google.common.collect.Lists;
-
-/* A class for selecting objects by their accessibility ids */
-public class SelectorAccessibilityIds implements ISelector {
- private int windowId;
- private int accessibilityId;
-
- /**
- * @param windowId the window id of the node you want to select
- * @param accessibilityId the accessibility id of the node you want to select
- */
- public SelectorAccessibilityIds(int windowId, int accessibilityId) {
- this.windowId = windowId;
- this.accessibilityId = accessibilityId;
- }
-
- /**
- * A method for selecting a view by the given accessibility ids.
- * @param manager The manager object used for interacting with the device.
- * @return The view with the given accessibility ids.
- */
- public IChimpView getView(ChimpManager manager) {
- ChimpView view = new ChimpView(ChimpView.ACCESSIBILITY_IDS,
- Lists.newArrayList(Integer.toString(windowId), Integer.toString(accessibilityId)));
- view.setManager(manager);
- return view;
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/SelectorId.java b/chimpchat/src/com/android/chimpchat/core/SelectorId.java
deleted file mode 100644
index aa3598d..0000000
--- a/chimpchat/src/com/android/chimpchat/core/SelectorId.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.chimpchat.core;
-
-import com.android.chimpchat.ChimpManager;
-
-import com.google.common.collect.Lists;
-
-/* A class for selecting objects by their id */
-public class SelectorId implements ISelector {
- private String id;
- /**
- * @param id the id to select objects by
- */
- public SelectorId(String id){
- this.id = id;
- }
-
- /**
- * A method for selecting a view by the given id.
- * @return The view with the given id
- */
- public IChimpView getView(ChimpManager manager) {
- ChimpView view = new ChimpView(ChimpView.VIEW_ID, Lists.newArrayList(id));
- view.setManager(manager);
- return view;
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/core/TouchPressType.java b/chimpchat/src/com/android/chimpchat/core/TouchPressType.java
deleted file mode 100644
index 7e1d4b6..0000000
--- a/chimpchat/src/com/android/chimpchat/core/TouchPressType.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.core;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * TouchPressType enum contains valid input for the "touch" Monkey command.
- * When passed as a string, the "identifier" value is used.
- */
-public enum TouchPressType {
- DOWN("down"), UP("up"), DOWN_AND_UP("downAndUp"), MOVE("move");
-
- private static final Map<String,TouchPressType> identifierToEnum =
- new HashMap<String,TouchPressType>();
- static {
- for (TouchPressType type : values()) {
- identifierToEnum.put(type.identifier, type);
- }
- }
-
- private String identifier;
-
- TouchPressType(String identifier) {
- this.identifier = identifier;
- }
-
- public String getIdentifier() {
- return identifier;
- }
-
- public static TouchPressType fromIdentifier(String name) {
- return identifierToEnum.get(name);
- }
-}
diff --git a/chimpchat/src/com/android/chimpchat/hierarchyviewer/HierarchyViewer.java b/chimpchat/src/com/android/chimpchat/hierarchyviewer/HierarchyViewer.java
deleted file mode 100644
index 5714701..0000000
--- a/chimpchat/src/com/android/chimpchat/hierarchyviewer/HierarchyViewer.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.chimpchat.hierarchyviewer;
-
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log;
-import com.android.hierarchyviewerlib.device.DeviceBridge;
-import com.android.hierarchyviewerlib.device.ViewServerDevice;
-import com.android.hierarchyviewerlib.models.ViewNode;
-import com.android.hierarchyviewerlib.models.Window;
-
-import org.eclipse.swt.graphics.Point;
-
-/**
- * Class for querying the view hierarchy of the device.
- */
-public class HierarchyViewer {
- public static final String TAG = "hierarchyviewer";
-
- private IDevice mDevice;
-
- /**
- * Constructs the hierarchy viewer for the specified device.
- *
- * @param device The Android device to connect to.
- */
- public HierarchyViewer(IDevice device) {
- this.mDevice = device;
- setupViewServer();
- }
-
- private void setupViewServer() {
- DeviceBridge.setupDeviceForward(mDevice);
- if (!DeviceBridge.isViewServerRunning(mDevice)) {
- if (!DeviceBridge.startViewServer(mDevice)) {
- // TODO: Get rid of this delay.
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- }
- if (!DeviceBridge.startViewServer(mDevice)) {
- Log.e(TAG, "Unable to debug device " + mDevice);
- throw new RuntimeException("Could not connect to the view server");
- }
- return;
- }
- }
- DeviceBridge.loadViewServerInfo(mDevice);
- }
-
- /**
- * Find a view by id.
- *
- * @param id id for the view.
- * @return view with the specified ID, or {@code null} if no view found.
- */
-
- public ViewNode findViewById(String id) {
- ViewNode rootNode = DeviceBridge.loadWindowData(
- new Window(new ViewServerDevice(mDevice), "", 0xffffffff));
- if (rootNode == null) {
- throw new RuntimeException("Could not dump view");
- }
- return findViewById(id, rootNode);
- }
-
- /**
- * Find a view by ID, starting from the given root node
- * @param id ID of the view you're looking for
- * @param rootNode the ViewNode at which to begin the traversal
- * @return view with the specified ID, or {@code null} if no view found.
- */
-
- public ViewNode findViewById(String id, ViewNode rootNode) {
- if (rootNode.id.equals(id)) {
- return rootNode;
- }
-
- for (ViewNode child : rootNode.children) {
- ViewNode found = findViewById(id,child);
- if (found != null) {
- return found;
- }
- }
- return null;
- }
-
- /**
- * Gets the window that currently receives the focus.
- *
- * @return name of the window that currently receives the focus.
- */
- public String getFocusedWindowName() {
- int id = DeviceBridge.getFocusedWindow(mDevice);
- Window[] windows = DeviceBridge.loadWindows(new ViewServerDevice(mDevice), mDevice);
- for (Window w : windows) {
- if (w.getHashCode() == id)
- return w.getTitle();
- }
- return null;
- }
-
- /**
- * Gets the absolute x/y position of the view node.
- *
- * @param node view node to find position of.
- * @return point specifying the x/y position of the node.
- */
- public static Point getAbsolutePositionOfView(ViewNode node) {
- int x = node.left;
- int y = node.top;
- ViewNode p = node.parent;
- while (p != null) {
- x += p.left - p.scrollX;
- y += p.top - p.scrollY;
- p = p.parent;
- }
- return new Point(x, y);
- }
-
- /**
- * Gets the absolute x/y center of the specified view node.
- *
- * @param node view node to find position of.
- * @return absolute x/y center of the specified view node.
- */
- public static Point getAbsoluteCenterOfView(ViewNode node) {
- Point point = getAbsolutePositionOfView(node);
- return new Point(
- point.x + (node.width / 2), point.y + (node.height / 2));
- }
-
- /**
- * Gets the visibility of a given element.
- *
- * @param selector selector for the view.
- * @return True if the element is visible.
- */
- public boolean visible(ViewNode node) {
- boolean ret = (node != null)
- && node.namedProperties.containsKey("getVisibility()")
- && "VISIBLE".equalsIgnoreCase(
- node.namedProperties.get("getVisibility()").value);
- return ret;
-
- }
-
- /**
- * Gets the text of a given element.
- *
- * @param selector selector for the view.
- * @return the text of the given element.
- */
- public String getText(ViewNode node) {
- if (node == null) {
- throw new RuntimeException("Node not found");
- }
- ViewNode.Property textProperty = node.namedProperties.get("text:mText");
- if (textProperty == null) {
- // give it another chance, ICS ViewServer returns mText
- textProperty = node.namedProperties.get("mText");
- if (textProperty == null) {
- throw new RuntimeException("No text property on node");
- }
- }
- return textProperty.value;
- }
-}
diff --git a/chimpchat/test/Android.mk b/chimpchat/test/Android.mk
deleted file mode 100644
index d7f686c..0000000
--- a/chimpchat/test/Android.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_MODULE := chimpchattest
-LOCAL_JAVA_LIBRARIES := junit chimpchat ddmlib guavalib
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/chimpchat/test/com/android/chimpchat/AllTests.java b/chimpchat/test/com/android/chimpchat/AllTests.java
deleted file mode 100644
index 9f647e3..0000000
--- a/chimpchat/test/com/android/chimpchat/AllTests.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat;
-
-import com.android.chimpchat.adb.AdbChimpDeviceTest;
-import com.android.chimpchat.adb.LinearInterpolatorTest;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-/**
- * Test suite to run all the tests for MonkeyRunner.
- */
-public class AllTests {
- public static Test suite(Class<? extends TestCase>... classes) {
- TestSuite suite = new TestSuite();
- for (Class<? extends TestCase> clz : classes) {
- suite.addTestSuite(clz);
- }
- return suite;
- }
-
- public static void main(String args[]) {
- TestRunner tr = new TestRunner();
- TestResult result = tr.doRun(AllTests.suite(ImageUtilsTest.class,
- LinearInterpolatorTest.class, AdbChimpDeviceTest.class));
- if (result.wasSuccessful()) {
- System.exit(0);
- } else {
- System.exit(1);
- }
- }
-}
diff --git a/chimpchat/test/com/android/chimpchat/ImageUtilsTest.java b/chimpchat/test/com/android/chimpchat/ImageUtilsTest.java
deleted file mode 100644
index 19dc4ed..0000000
--- a/chimpchat/test/com/android/chimpchat/ImageUtilsTest.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat;
-
-import com.android.ddmlib.RawImage;
-import com.android.chimpchat.adb.image.CaptureRawAndConvertedImage;
-import com.android.chimpchat.adb.image.ImageUtils;
-import com.android.chimpchat.adb.image.CaptureRawAndConvertedImage.ChimpRawImage;
-
-import junit.framework.TestCase;
-
-import java.awt.image.BufferedImage;
-import java.awt.image.WritableRaster;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-
-import javax.imageio.ImageIO;
-
-public class ImageUtilsTest extends TestCase {
- private static BufferedImage createBufferedImage(String name) throws IOException {
- InputStream is = ImageUtilsTest.class.getResourceAsStream(name);
- BufferedImage img = ImageIO.read(is);
- is.close();
- return img;
- }
-
- private static RawImage createRawImage(String name) throws IOException, ClassNotFoundException {
- ObjectInputStream is =
- new ObjectInputStream(ImageUtilsTest.class.getResourceAsStream(name));
- CaptureRawAndConvertedImage.ChimpRawImage wrapper = (ChimpRawImage) is.readObject();
- is.close();
- return wrapper.toRawImage();
- }
-
- /**
- * Check that the two images will draw the same (ie. have the same pixels). This is different
- * that BufferedImage.equals(), which also wants to check that they have the same ColorModel
- * and other parameters.
- *
- * @param i1 the first image
- * @param i2 the second image
- * @return true if both images will draw the same (ie. have same pixels).
- */
- private static boolean checkImagesHaveSamePixels(BufferedImage i1, BufferedImage i2) {
- if (i1.getWidth() != i2.getWidth()) {
- return false;
- }
- if (i1.getHeight() != i2.getHeight()) {
- return false;
- }
-
- for (int y = 0; y < i1.getHeight(); y++) {
- for (int x = 0; x < i1.getWidth(); x++) {
- int p1 = i1.getRGB(x, y);
- int p2 = i2.getRGB(x, y);
- if (p1 != p2) {
- WritableRaster r1 = i1.getRaster();
- WritableRaster r2 = i2.getRaster();
- return false;
- }
- }
- }
-
- return true;
- }
-
- public void testImageConversionOld() throws IOException, ClassNotFoundException {
- RawImage rawImage = createRawImage("image1.raw");
- BufferedImage convertedImage = ImageUtils.convertImage(rawImage);
- BufferedImage correctConvertedImage = createBufferedImage("image1.png");
-
- assertTrue(checkImagesHaveSamePixels(convertedImage, correctConvertedImage));
- }
-
- public void testImageConversionNew() throws IOException, ClassNotFoundException {
- RawImage rawImage = createRawImage("image2.raw");
- BufferedImage convertedImage = ImageUtils.convertImage(rawImage);
- BufferedImage correctConvertedImage = createBufferedImage("image2.png");
-
- assertTrue(checkImagesHaveSamePixels(convertedImage, correctConvertedImage));
- }
-}
diff --git a/chimpchat/test/com/android/chimpchat/adb/AdbChimpDeviceTest.java b/chimpchat/test/com/android/chimpchat/adb/AdbChimpDeviceTest.java
deleted file mode 100644
index 482941a..0000000
--- a/chimpchat/test/com/android/chimpchat/adb/AdbChimpDeviceTest.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.adb;
-
-import com.google.common.base.Joiner;
-import com.google.common.io.Resources;
-
-import junit.framework.TestCase;
-
-import java.io.IOException;
-import java.net.URL;
-import java.nio.charset.Charset;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Unit Tests for AdbChimpDevice.
- */
-public class AdbChimpDeviceTest extends TestCase {
- private static String MULTILINE_RESULT = "\r\n" +
- "Test results for InstrumentationTestRunner=.\r\n" +
- "Time: 2.242\r\n" +
- "\r\n" +
- "OK (1 test)";
-
- private static String getResource(String resName) throws IOException {
- URL resource = Resources.getResource(AdbChimpDeviceTest.class, resName);
- List<String> lines = Resources.readLines(resource, Charset.defaultCharset());
- return Joiner.on("\r\n").join(lines);
- }
-
- public void testSimpleResultParse() throws IOException {
- String result = getResource("instrument_result.txt");
- Map<String, Object> convertedResult = AdbChimpDevice.convertInstrumentResult(result);
-
- assertEquals("one", convertedResult.get("result1"));
- assertEquals("two", convertedResult.get("result2"));
- }
-
- public void testMultilineResultParse() throws IOException {
- String result = getResource("multiline_instrument_result.txt");
- Map<String, Object> convertedResult = AdbChimpDevice.convertInstrumentResult(result);
-
- assertEquals(MULTILINE_RESULT, convertedResult.get("stream"));
- }
-}
diff --git a/chimpchat/test/com/android/chimpchat/adb/LinearInterpolatorTest.java b/chimpchat/test/com/android/chimpchat/adb/LinearInterpolatorTest.java
deleted file mode 100644
index f9bc72f..0000000
--- a/chimpchat/test/com/android/chimpchat/adb/LinearInterpolatorTest.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.chimpchat.adb;
-
-import com.google.common.collect.Lists;
-
-import com.android.chimpchat.adb.LinearInterpolator.Point;
-
-import junit.framework.TestCase;
-
-import java.util.List;
-
-/**
- * Unit tests for the LinerInterpolator class.S
- */
-public class LinearInterpolatorTest extends TestCase {
- private static class Collector implements LinearInterpolator.Callback {
- private final List<LinearInterpolator.Point> points = Lists.newArrayList();
-
- public List<LinearInterpolator.Point> getPoints() {
- return points;
- }
-
- public void end(Point input) {
- points.add(input);
- }
-
- public void start(Point input) {
- points.add(input);
- }
-
- public void step(Point input) {
- points.add(input);
- }
- }
-
- List<Integer> STEP_POINTS = Lists.newArrayList(0, 100, 200, 300, 400, 500, 600, 700, 800, 900,
- 1000);
- List<Integer> REVERSE_STEP_POINTS = Lists.newArrayList(1000, 900, 800, 700, 600, 500, 400, 300,
- 200, 100, 0);
-
- public void testLerpRight() {
- LinearInterpolator lerp = new LinearInterpolator(10);
- Collector collector = new Collector();
- lerp.interpolate(new LinearInterpolator.Point(0, 100),
- new LinearInterpolator.Point(1000, 100),
- collector);
-
- List<LinearInterpolator.Point> points = collector.getPoints();
- assertEquals(11, points.size());
- for (int x = 0; x < points.size(); x++) {
- assertEquals(new Point(STEP_POINTS.get(x), 100), points.get(x));
- }
- }
-
- public void testLerpLeft() {
- LinearInterpolator lerp = new LinearInterpolator(10);
- Collector collector = new Collector();
- lerp.interpolate(new LinearInterpolator.Point(1000, 100),
- new LinearInterpolator.Point(0, 100),
- collector);
-
- List<LinearInterpolator.Point> points = collector.getPoints();
- assertEquals(11, points.size());
- for (int x = 0; x < points.size(); x++) {
- assertEquals(new Point(REVERSE_STEP_POINTS.get(x), 100), points.get(x));
- }
- }
-
- public void testLerpUp() {
- LinearInterpolator lerp = new LinearInterpolator(10);
- Collector collector = new Collector();
- lerp.interpolate(new LinearInterpolator.Point(100, 1000),
- new LinearInterpolator.Point(100, 0),
- collector);
-
- List<LinearInterpolator.Point> points = collector.getPoints();
- assertEquals(11, points.size());
- for (int x = 0; x < points.size(); x++) {
- assertEquals(new Point(100, REVERSE_STEP_POINTS.get(x)), points.get(x));
- }
- }
-
- public void testLerpDown() {
- LinearInterpolator lerp = new LinearInterpolator(10);
- Collector collector = new Collector();
- lerp.interpolate(new LinearInterpolator.Point(100, 0),
- new LinearInterpolator.Point(100, 1000),
- collector);
-
- List<LinearInterpolator.Point> points = collector.getPoints();
- assertEquals(11, points.size());
- for (int x = 0; x < points.size(); x++) {
- assertEquals(new Point(100, STEP_POINTS.get(x)), points.get(x));
- }
- }
-
- public void testLerpNW() {
- LinearInterpolator lerp = new LinearInterpolator(10);
- Collector collector = new Collector();
- lerp.interpolate(new LinearInterpolator.Point(0, 0),
- new LinearInterpolator.Point(1000, 1000),
- collector);
-
- List<LinearInterpolator.Point> points = collector.getPoints();
- assertEquals(11, points.size());
- for (int x = 0; x < points.size(); x++) {
- assertEquals(new Point(STEP_POINTS.get(x), STEP_POINTS.get(x)), points.get(x));
- }
- }
-
- public void testLerpNE() {
- LinearInterpolator lerp = new LinearInterpolator(10);
- Collector collector = new Collector();
- lerp.interpolate(new LinearInterpolator.Point(1000, 1000),
- new LinearInterpolator.Point(0, 0),
- collector);
-
- List<LinearInterpolator.Point> points = collector.getPoints();
- assertEquals(11, points.size());
- for (int x = 0; x < points.size(); x++) {
- assertEquals(new Point(REVERSE_STEP_POINTS.get(x), REVERSE_STEP_POINTS.get(x)), points.get(x));
- }
- }
-}
diff --git a/chimpchat/test/resources/com/android/monkeyrunner/adb/instrument_result.txt b/chimpchat/test/resources/com/android/monkeyrunner/adb/instrument_result.txt
deleted file mode 100644
index c127c0f..0000000
--- a/chimpchat/test/resources/com/android/monkeyrunner/adb/instrument_result.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-INSTRUMENTATION_STATUS: id=InstrumentationTestRunner
-INSTRUMENTATION_STATUS: current=1
-INSTRUMENTATION_STATUS: class=com.example.android.notepad.NotePadTest
-INSTRUMENTATION_STATUS: stream=.
-INSTRUMENTATION_STATUS: numtests=1
-INSTRUMENTATION_STATUS: test=testActivityTestCaseSetUpProperly
-INSTRUMENTATION_STATUS_CODE: 0
-INSTRUMENTATION_RESULT: result1=one
-INSTRUMENTATION_RESULT: result2=two
-INSTRUMENTATION_CODE: -1
diff --git a/chimpchat/test/resources/com/android/monkeyrunner/adb/multiline_instrument_result.txt b/chimpchat/test/resources/com/android/monkeyrunner/adb/multiline_instrument_result.txt
deleted file mode 100644
index 32fd901..0000000
--- a/chimpchat/test/resources/com/android/monkeyrunner/adb/multiline_instrument_result.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-INSTRUMENTATION_STATUS: id=InstrumentationTestRunner
-INSTRUMENTATION_STATUS: current=1
-INSTRUMENTATION_STATUS: class=com.example.android.notepad.NotePadTest
-INSTRUMENTATION_STATUS: stream=.
-INSTRUMENTATION_STATUS: numtests=1
-INSTRUMENTATION_STATUS: test=testActivityTestCaseSetUpProperly
-INSTRUMENTATION_STATUS_CODE: 0
-INSTRUMENTATION_RESULT: stream=
-Test results for InstrumentationTestRunner=.
-Time: 2.242
-
-OK (1 test)
-
-
-INSTRUMENTATION_CODE: -1
diff --git a/chimpchat/test/resources/com/android/monkeyrunner/image1.png b/chimpchat/test/resources/com/android/monkeyrunner/image1.png
deleted file mode 100644
index 9ef1800..0000000
--- a/chimpchat/test/resources/com/android/monkeyrunner/image1.png
+++ /dev/null
Binary files differ
diff --git a/chimpchat/test/resources/com/android/monkeyrunner/image1.raw b/chimpchat/test/resources/com/android/monkeyrunner/image1.raw
deleted file mode 100644
index 99ec013..0000000
--- a/chimpchat/test/resources/com/android/monkeyrunner/image1.raw
+++ /dev/null
Binary files differ
diff --git a/chimpchat/test/resources/com/android/monkeyrunner/image2.png b/chimpchat/test/resources/com/android/monkeyrunner/image2.png
deleted file mode 100644
index 03ff0c1..0000000
--- a/chimpchat/test/resources/com/android/monkeyrunner/image2.png
+++ /dev/null
Binary files differ
diff --git a/chimpchat/test/resources/com/android/monkeyrunner/image2.raw b/chimpchat/test/resources/com/android/monkeyrunner/image2.raw
deleted file mode 100644
index 06e5b47..0000000
--- a/chimpchat/test/resources/com/android/monkeyrunner/image2.raw
+++ /dev/null
Binary files differ
diff --git a/common/.classpath b/common/.classpath
deleted file mode 100644
index 5f63122..0000000
--- a/common/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src.zip"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/common/.gitignore b/common/.gitignore
deleted file mode 100644
index 4ff597c..0000000
--- a/common/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-bin
-build
-
diff --git a/common/.project b/common/.project
deleted file mode 100644
index 3a7717d..0000000
--- a/common/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>common</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/common/.settings/org.eclipse.jdt.core.prefs b/common/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/common/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/common/.settings/org.moreunit.prefs b/common/.settings/org.moreunit.prefs
deleted file mode 100644
index 3001cbf..0000000
--- a/common/.settings/org.moreunit.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-eclipse.preferences.version=1
-org.moreunit.prefixes=
-org.moreunit.unitsourcefolder=common\:src/main/java\:common-tests\:java
-org.moreunit.useprojectsettings=true
diff --git a/common/Android.mk b/common/Android.mk
deleted file mode 100644
index f7ba3c1..0000000
--- a/common/Android.mk
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# The common code has moved to tools/base/common.
-# The rule below uses the prebuilt common.jar.
-#
-# If you want to run the tests, cd to tools/base/common
-# and run ./gradlew :common:test
-
-LOCAL_JAVA_LIBRARIES := \
- guava-tools
-
-LOCAL_MODULE := common
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PREBUILT_JAVA_LIBRARIES := \
- ../../prebuilts/devtools/tools/lib/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/common/NOTICE b/common/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/common/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/common/README.txt b/common/README.txt
deleted file mode 100644
index d4c6232..0000000
--- a/common/README.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-common.jar contains resource configuration enums. It is used by various tools, but also
-by layoutlib.jar
-
-Layoutlib.jar is built from frameworks/base.git and therefore is versioned with the platform.
-
-IMPORTANT NOTE REGARDING CHANGES IN common.jar:
-
-- The API must stay compatible. This is because while layoutlib.jar compiles against it,
- the client provides the implementation and must be able to load earlier versions of layoutlib.jar.
-
-- Updated version of common should be copied to the current in-dev branch of
- prebuilt/common/common/common-prebuilt.jar
- The PREBUILT file in the same folder must be updated as well to reflect how to rebuild this
- prebuilt jar file. \ No newline at end of file
diff --git a/common/manifest.txt b/common/manifest.txt
deleted file mode 100644
index b0f908d..0000000
--- a/common/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Class-Path: guava-tools.jar
diff --git a/ddms/.gitignore b/ddms/.gitignore
deleted file mode 100644
index 1ef345b..0000000
--- a/ddms/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-app/bin
-libs/ddmlib/bin
-libs/ddmlib/build
-libs/ddmuilib/bin
-
diff --git a/ddms/Android.mk b/ddms/Android.mk
deleted file mode 100644
index 82c248e..0000000
--- a/ddms/Android.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2007 The Android Open Source Project
-#
-DDMS_LOCAL_DIR := $(call my-dir)
-include $(DDMS_LOCAL_DIR)/libs/Android.mk
-include $(DDMS_LOCAL_DIR)/app/Android.mk
diff --git a/ddms/MODULE_LICENSE_APACHE2 b/ddms/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/ddms/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/ddms/app/.classpath b/ddms/app/.classpath
deleted file mode 100644
index 54b9743..0000000
--- a/ddms/app/.classpath
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/sdkstats"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/swt.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.core.commands_3.6.0.I20100512-1500.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.equinox.common_3.6.0.v20100503.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.jface_3.6.2.M20110210-1200.jar"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/swtmenubar.jar" sourcepath="/ANDROID_SRC/sdk/swtmenubar/src"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/osgi/osgi.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/ddms/app/.project b/ddms/app/.project
deleted file mode 100644
index ffb19d7..0000000
--- a/ddms/app/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>ddms</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/ddms/app/.settings/org.eclipse.jdt.core.prefs b/ddms/app/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/ddms/app/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/ddms/app/Android.mk b/ddms/app/Android.mk
deleted file mode 100644
index d4ad1fa..0000000
--- a/ddms/app/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2007 The Android Open Source Project
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_RESOURCE_DIRS := src
-
-LOCAL_JAR_MANIFEST := etc/manifest.txt
-
-# If the dependency list is changed, etc/manifest.txt
-# MUST be updated as well (Except for swt.jar which is dynamically
-# added based on whether the VM is 32 or 64 bit)
-LOCAL_JAVA_LIBRARIES := \
- common \
- sdkstats \
- ddmlib \
- ddmuilib \
- swt \
- swtmenubar \
- org.eclipse.jface_3.6.2.M20110210-1200 \
- org.eclipse.equinox.common_3.6.0.v20100503 \
- org.eclipse.core.commands_3.6.0.I20100512-1500
-LOCAL_MODULE := ddms
-
-LOCAL_MODULE_TAGS := debug
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-
-# Build all sub-directories
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/ddms/app/NOTICE b/ddms/app/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/ddms/app/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/ddms/app/README b/ddms/app/README
deleted file mode 100644
index 0d9bbc4..0000000
--- a/ddms/app/README
+++ /dev/null
@@ -1,75 +0,0 @@
-Using the Eclipse project DDMS
-------------------------------
-
-DDMS requires some external libraries to compile.
-If you build DDMS using the makefile, you have nothing to configure.
-However if you want to develop on DDMS using Eclipse, you need to
-perform the following configuration.
-
-
--------
-1- Projects required in Eclipse
--------
-
-To run DDMS from Eclipse, you need to import the following 5 projects:
-
- - sdk/androidpprefs: project AndroidPrefs
- - sdk/sdkstats: project SdkStatsService
- - sdk/ddms/app: project Ddms
- - sdk/ddms/libs/ddmlib: project Ddmlib
- - sdk/ddms/libs/ddmuilib: project Ddmuilib
-
-
--------
-2- DDMS requires some SWT and OSGI JARs to compile.
--------
-
-SWT is available in the tree under prebuild/<platform>/swt
-
-Because the build path cannot contain relative path that are not inside
-the project directory, the .classpath file references a user library
-called ANDROID_SWT.
-SWT depends on OSGI, so we'll also create an ANDROID_OSGI library for that.
-
-In order to compile the project:
-- Open Preferences > Java > Build Path > User Libraries
-
-- Create a new user library named ANDROID_SWT
-- Add the following 4 JAR files:
-
- - prebuilt/<platform>/swt/swt.jar
- - prebuilt/common/eclipse/org.eclipse.core.commands_3.*.jar
- - prebuilt/common/eclipse/org.eclipse.equinox.common_3.*.jar
- - prebuilt/common/eclipse/org.eclipse.jface_3.*.jar
-
-- Create a new user library named ANDROID_OSGI
-- Add the following JAR file:
-
- - prebuilt/common/eclipse/org.eclipse.osgi_3.*.jar
-
-
--------
-3- DDMS also requires the compiled SwtMenuBar library.
--------
-
-Build the swtmenubar library:
-$ cd $TOP (top of Android tree)
-$ . build/envsetup.sh && lunch sdk-eng
-$ sdk/eclipse/scripts/create_sdkman_symlinks.sh
-
-Define a classpath variable in Eclipse:
-- Open Preferences > Java > Build Path > Classpath Variables
-- Create a new classpath variable named ANDROID_OUT_FRAMEWORK
-- Set its folder value to <Android tree>/out/host/<platform>/framework
-- Create a new classpath variable named ANDROID_SRC
-- Set its folder value to <Android tree>
-
-You might need to clean the ddms project (Project > Clean...) after
-you add the new classpath variable, otherwise previous errors might not
-go away automatically.
-
-The ANDROID_SRC part should be optional. It allows you to have access to
-the SwtMenuBar generic parts from the Java editor.
-
---
-EOF
diff --git a/ddms/app/etc/Android.mk b/ddms/app/etc/Android.mk
deleted file mode 100644
index d44d26e..0000000
--- a/ddms/app/etc/Android.mk
+++ /dev/null
@@ -1,8 +0,0 @@
-# Copyright 2007 The Android Open Source Project
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_PREBUILT_EXECUTABLES := ddms
-LOCAL_MODULE_TAGS := debug
-include $(BUILD_HOST_PREBUILT)
diff --git a/ddms/app/etc/ddms b/ddms/app/etc/ddms
deleted file mode 100755
index 79b93f9..0000000
--- a/ddms/app/etc/ddms
+++ /dev/null
@@ -1,111 +0,0 @@
-#!/bin/bash
-# Copyright 2005-2007, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
- newProg=`/bin/ls -ld "${prog}"`
- newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
- if expr "x${newProg}" : 'x/' >/dev/null; then
- prog="${newProg}"
- else
- progdir=`dirname "${prog}"`
- prog="${progdir}/${newProg}"
- fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/`basename "${prog}"`
-cd "${oldwd}"
-
-jarfile=ddms.jar
-frameworkdir="$progdir"
-libdir="$progdir"
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/tools/lib
- libdir=`dirname "$progdir"`/tools/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/framework
- libdir=`dirname "$progdir"`/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- echo `basename "$prog"`": can't find $jarfile"
- exit 1
-fi
-
-
-# Check args.
-if [ debug = "$1" ]; then
- # add this in for debugging
- java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
- shift 1
-else
- java_debug=
-fi
-
-javaCmd="java"
-
-# Mac OS X needs an additional arg, or you get an "illegal thread" complaint.
-if [ `uname` = "Darwin" ]; then
- os_opts="-XstartOnFirstThread"
-else
- os_opts=
-fi
-
-if [ `uname` = "Linux" ]; then
- export GDK_NATIVE_WINDOWS=true
-fi
-
-jarpath="$frameworkdir/$jarfile:$frameworkdir/swtmenubar.jar"
-
-# Figure out the path to the swt.jar for the current architecture.
-# if ANDROID_SWT is defined, then just use this.
-# else, if running in the Android source tree, then look for the correct swt folder in prebuilt
-# else, look for the correct swt folder in the SDK under tools/lib/
-swtpath=""
-if [ -n "$ANDROID_SWT" ]; then
- swtpath="$ANDROID_SWT"
-else
- vmarch=`${javaCmd} -jar "${frameworkdir}"/archquery.jar`
- if [ -n "$ANDROID_BUILD_TOP" ]; then
- osname=`uname -s | tr A-Z a-z`
- swtpath="${ANDROID_BUILD_TOP}/prebuilts/tools/${osname}-${vmarch}/swt"
- else
- swtpath="${frameworkdir}/${vmarch}"
- fi
-fi
-
-if [ ! -d "$swtpath" ]; then
- echo "SWT folder '${swtpath}' does not exist."
- echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform."
- exit 1
-fi
-
-if [ -x $progdir/monitor ]; then
- echo "The standalone version of DDMS is deprecated."
- echo "Please use Android Device Monitor (tools/monitor) instead."
-fi
-exec "$javaCmd" \
- -Xmx256M $os_opts $java_debug \
- -Dcom.android.ddms.bindir="$progdir" \
- -classpath "$jarpath:$swtpath/swt.jar" \
- com.android.ddms.Main "$@"
diff --git a/ddms/app/etc/ddms.bat b/ddms/app/etc/ddms.bat
deleted file mode 100755
index d710ea6..0000000
--- a/ddms/app/etc/ddms.bat
+++ /dev/null
@@ -1,74 +0,0 @@
-@echo off
-rem Copyright (C) 2007 The Android Open Source Project
-rem
-rem Licensed under the Apache License, Version 2.0 (the "License");
-rem you may not use this file except in compliance with the License.
-rem You may obtain a copy of the License at
-rem
-rem http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-
-rem don't modify the caller's environment
-setlocal
-
-rem Set up prog to be the path of this script, including following symlinks,
-rem and set up progdir to be the fully-qualified pathname of its directory.
-set prog=%~f0
-
-rem Change current directory and drive to where the script is, to avoid
-rem issues with directories containing whitespaces.
-cd /d %~dp0
-
-rem Get the CWD as a full path with short names only (without spaces)
-for %%i in ("%cd%") do set prog_dir=%%~fsi
-
-rem Check we have a valid Java.exe in the path.
-set java_exe=
-call lib\find_java.bat
-if not defined java_exe goto :EOF
-
-set jarfile=ddms.jar
-set frameworkdir=
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=lib\
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=..\framework\
-
-:JarFileOk
-
-if debug NEQ "%1" goto NoDebug
- set java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
- shift 1
-:NoDebug
-
-set jarpath=%frameworkdir%%jarfile%;%frameworkdir%swtmenubar.jar
-
-if not defined ANDROID_SWT goto QueryArch
- set swt_path=%ANDROID_SWT%
- goto SwtDone
-
-:QueryArch
-
- for /f %%a in ('%java_exe% -jar %frameworkdir%archquery.jar') do set swt_path=%frameworkdir%%%a
-
-:SwtDone
-
-if exist %swt_path% goto SetPath
- echo SWT folder '%swt_path%' does not exist.
- echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
- exit /B
-
-:SetPath
-set javaextdirs=%swt_path%;%frameworkdir%
-
-echo The standalone version of DDMS is deprecated.
-echo Please use Android Device Monitor (monitor.bat) instead.
-call %java_exe% %java_debug% -Dcom.android.ddms.bindir=%prog_dir% -classpath "%jarpath%;%swt_path%\swt.jar" com.android.ddms.Main %*
-
diff --git a/ddms/app/etc/manifest.txt b/ddms/app/etc/manifest.txt
deleted file mode 100644
index f3d4fdd..0000000
--- a/ddms/app/etc/manifest.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-Main-Class: com.android.ddms.Main
-Class-Path: common.jar sdkstats.jar ddmlib.jar ddmuilib.jar swtmenubar.jar org.eclipse.jface_3.6.2.M20110210-1200.jar org.eclipse.equinox.common_3.6.0.v20100503.jar org.eclipse.core.commands_3.6.0.I20100512-1500.jar jcommon-1.0.12.jar jfreechart-1.0.9.jar jfreechart-1.0.9-swt.jar osgi.jar guava-tools.jar
-
diff --git a/ddms/app/src/com/android/ddms/AboutDialog.java b/ddms/app/src/com/android/ddms/AboutDialog.java
deleted file mode 100644
index b3ddff7..0000000
--- a/ddms/app/src/com/android/ddms/AboutDialog.java
+++ /dev/null
@@ -1,158 +0,0 @@
-/* //device/tools/ddms/src/com/android/ddms/AboutDialog.java
-**
-** Copyright 2007, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
-
-package com.android.ddms;
-
-import com.android.ddmlib.Log;
-import com.android.ddmuilib.ImageLoader;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.InputStream;
-
-/**
- * Our "about" box.
- */
-public class AboutDialog extends Dialog {
-
- private Image logoImage;
-
- /**
- * Create with default style.
- */
- public AboutDialog(Shell parent) {
- this(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
- }
-
- /**
- * Create with app-defined style.
- */
- public AboutDialog(Shell parent, int style) {
- super(parent, style);
- }
-
- /**
- * Prepare and display the dialog.
- */
- public void open() {
- Shell parent = getParent();
- Shell shell = new Shell(parent, getStyle());
- shell.setText("About...");
-
- logoImage = loadImage(shell, "ddms-128.png"); //$NON-NLS-1$
- createContents(shell);
- shell.pack();
-
- shell.open();
- Display display = parent.getDisplay();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- logoImage.dispose();
- }
-
- /*
- * Load an image file from a resource.
- *
- * This depends on Display, so I'm not sure what the rules are for
- * loading once and caching in a static class field.
- */
- private Image loadImage(Shell shell, String fileName) {
- InputStream imageStream;
- String pathName = "/images/" + fileName; //$NON-NLS-1$
-
- imageStream = this.getClass().getResourceAsStream(pathName);
- if (imageStream == null) {
- //throw new NullPointerException("couldn't find " + pathName);
- Log.w("ddms", "Couldn't load " + pathName);
- Display display = shell.getDisplay();
- return ImageLoader.createPlaceHolderArt(display, 100, 50,
- display.getSystemColor(SWT.COLOR_BLUE));
- }
-
- Image img = new Image(shell.getDisplay(), imageStream);
- if (img == null)
- throw new NullPointerException("couldn't load " + pathName);
- return img;
- }
-
- /*
- * Create the about box contents.
- */
- private void createContents(final Shell shell) {
- GridLayout layout;
- GridData data;
- Label label;
-
- shell.setLayout(new GridLayout(2, false));
-
- // Fancy logo
- Label logo = new Label(shell, SWT.BORDER);
- logo.setImage(logoImage);
-
- // Text Area
- Composite textArea = new Composite(shell, SWT.NONE);
- layout = new GridLayout(1, true);
- textArea.setLayout(layout);
-
- // Text lines
- label = new Label(textArea, SWT.NONE);
- if (Main.sRevision != null && Main.sRevision.length() > 0) {
- label.setText("Dalvik Debug Monitor Revision " + Main.sRevision);
- } else {
- label.setText("Dalvik Debug Monitor");
- }
- label = new Label(textArea, SWT.NONE);
- // TODO: update with new year date (search this to find other occurrences to update)
- label.setText("Copyright 2007-2012, The Android Open Source Project");
- label = new Label(textArea, SWT.NONE);
- label.setText("All Rights Reserved.");
-
- // blank spot in grid
- label = new Label(shell, SWT.NONE);
-
- // "OK" button
- Button ok = new Button(shell, SWT.PUSH);
- ok.setText("OK");
- data = new GridData(GridData.HORIZONTAL_ALIGN_END);
- data.widthHint = 80;
- ok.setLayoutData(data);
- ok.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- shell.close();
- }
- });
-
- shell.pack();
-
- shell.setDefaultButton(ok);
- }
-}
diff --git a/ddms/app/src/com/android/ddms/DebugPortProvider.java b/ddms/app/src/com/android/ddms/DebugPortProvider.java
deleted file mode 100644
index 2dcd5d4..0000000
--- a/ddms/app/src/com/android/ddms/DebugPortProvider.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddms;
-
-import com.android.ddmlib.DebugPortManager.IDebugPortProvider;
-import com.android.ddmlib.IDevice;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * DDMS implementation of the IDebugPortProvider interface.
- * This class handles saving/loading the list of static debug port from
- * the preference store and provides the port number to the Device Monitor.
- */
-public class DebugPortProvider implements IDebugPortProvider {
-
- private static DebugPortProvider sThis = new DebugPortProvider();
-
- /** Preference name for the static port list. */
- public static final String PREFS_STATIC_PORT_LIST = "android.staticPortList"; //$NON-NLS-1$
-
- /**
- * Mapping device serial numbers to maps. The embedded maps are mapping application names to
- * debugger ports.
- */
- private Map<String, Map<String, Integer>> mMap;
-
- public static DebugPortProvider getInstance() {
- return sThis;
- }
-
- private DebugPortProvider() {
- computePortList();
- }
-
- /**
- * Returns a static debug port for the specified application running on the
- * specified {@link IDevice}.
- * @param device The device the application is running on.
- * @param appName The application name, as defined in the
- * AndroidManifest.xml package attribute.
- * @return The static debug port or {@link #NO_STATIC_PORT} if there is none setup.
- *
- * @see IDebugPortProvider#getPort(IDevice, String)
- */
- @Override
- public int getPort(IDevice device, String appName) {
- if (mMap != null) {
- Map<String, Integer> deviceMap = mMap.get(device.getSerialNumber());
- if (deviceMap != null) {
- Integer i = deviceMap.get(appName);
- if (i != null) {
- return i.intValue();
- }
- }
- }
- return IDebugPortProvider.NO_STATIC_PORT;
- }
-
- /**
- * Returns the map of Static debugger ports. The map links device serial numbers to
- * a map linking application name to debugger ports.
- */
- public Map<String, Map<String, Integer>> getPortList() {
- return mMap;
- }
-
- /**
- * Create the map member from the values contained in the Preference Store.
- */
- private void computePortList() {
- mMap = new HashMap<String, Map<String, Integer>>();
-
- // get the prefs store
- IPreferenceStore store = PrefsDialog.getStore();
- String value = store.getString(PREFS_STATIC_PORT_LIST);
-
- if (value != null && value.length() > 0) {
- // format is
- // port1|port2|port3|...
- // where port# is
- // appPackageName:appPortNumber:device-serial-number
- String[] portSegments = value.split("\\|"); //$NON-NLS-1$
- for (String seg : portSegments) {
- String[] entry = seg.split(":"); //$NON-NLS-1$
-
- // backward compatibility support. if we have only 2 entry, we default
- // to the first emulator.
- String deviceName = null;
- if (entry.length == 3) {
- deviceName = entry[2];
- } else {
- deviceName = IDevice.FIRST_EMULATOR_SN;
- }
-
- // get the device map
- Map<String, Integer> deviceMap = mMap.get(deviceName);
- if (deviceMap == null) {
- deviceMap = new HashMap<String, Integer>();
- mMap.put(deviceName, deviceMap);
- }
-
- deviceMap.put(entry[0], Integer.valueOf(entry[1]));
- }
- }
- }
-
- /**
- * Sets new [device, app, port] values.
- * The values are also sync'ed in the preference store.
- * @param map The map containing the new values.
- */
- public void setPortList(Map<String, Map<String,Integer>> map) {
- // update the member map.
- mMap.clear();
- mMap.putAll(map);
-
- // create the value to store in the preference store.
- // see format definition in getPortList
- StringBuilder sb = new StringBuilder();
-
- Set<String> deviceKeys = map.keySet();
- for (String deviceKey : deviceKeys) {
- Map<String, Integer> deviceMap = map.get(deviceKey);
- if (deviceMap != null) {
- Set<String> appKeys = deviceMap.keySet();
-
- for (String appKey : appKeys) {
- Integer port = deviceMap.get(appKey);
- if (port != null) {
- sb.append(appKey).append(':').append(port.intValue()).append(':').
- append(deviceKey).append('|');
- }
- }
- }
- }
-
- String value = sb.toString();
-
- // get the prefs store.
- IPreferenceStore store = PrefsDialog.getStore();
-
- // and give it the new value.
- store.setValue(PREFS_STATIC_PORT_LIST, value);
- }
-}
diff --git a/ddms/app/src/com/android/ddms/DeviceCommandDialog.java b/ddms/app/src/com/android/ddms/DeviceCommandDialog.java
deleted file mode 100644
index 6775cbb..0000000
--- a/ddms/app/src/com/android/ddms/DeviceCommandDialog.java
+++ /dev/null
@@ -1,441 +0,0 @@
-/* //device/tools/ddms/src/com/android/ddms/DeviceCommandDialog.java
-**
-** Copyright 2007, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
-
-package com.android.ddms;
-
-import com.android.ddmlib.AdbCommandRejectedException;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.IShellOutputReceiver;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.ShellCommandUnresponsiveException;
-import com.android.ddmlib.TimeoutException;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import java.io.BufferedOutputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-
-
-/**
- * Execute a command on an ADB-attached device and save the output.
- *
- * There are several ways to do this. One is to run a single command
- * and show the output. Another is to have several possible commands and
- * let the user click a button next to the one (or ones) they want. This
- * currently uses the simple 1:1 form.
- */
-public class DeviceCommandDialog extends Dialog {
-
- public static final int DEVICE_STATE = 0;
- public static final int APP_STATE = 1;
- public static final int RADIO_STATE = 2;
- public static final int LOGCAT = 3;
-
- private String mCommand;
- private String mFileName;
-
- private Label mStatusLabel;
- private Button mCancelDone;
- private Button mSave;
- private Text mText;
- private Font mFont = null;
- private boolean mCancel;
- private boolean mFinished;
-
-
- /**
- * Create with default style.
- */
- public DeviceCommandDialog(String command, String fileName, Shell parent) {
- // don't want a close button, but it seems hard to get rid of on GTK
- // keep it on all platforms for consistency
- this(command, fileName, parent,
- SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL | SWT.RESIZE);
- }
-
- /**
- * Create with app-defined style.
- */
- public DeviceCommandDialog(String command, String fileName, Shell parent,
- int style)
- {
- super(parent, style);
- mCommand = command;
- mFileName = fileName;
- }
-
- /**
- * Prepare and display the dialog.
- * @param currentDevice
- */
- public void open(IDevice currentDevice) {
- Shell parent = getParent();
- Shell shell = new Shell(parent, getStyle());
- shell.setText("Remote Command");
-
- mFinished = false;
- mFont = findFont(shell.getDisplay());
- createContents(shell);
-
- // Getting weird layout behavior under Linux when Text is added --
- // looks like text widget has min width of 400 when FILL_HORIZONTAL
- // is used, and layout gets tweaked to force this. (Might be even
- // more with the scroll bars in place -- it wigged out when the
- // file save dialog was invoked.)
- shell.setMinimumSize(500, 200);
- shell.setSize(800, 600);
- shell.open();
-
- executeCommand(shell, currentDevice);
-
- Display display = parent.getDisplay();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- if (mFont != null)
- mFont.dispose();
- }
-
- /*
- * Create a text widget to show the output and some buttons to
- * manage things.
- */
- private void createContents(final Shell shell) {
- GridData data;
-
- shell.setLayout(new GridLayout(2, true));
-
- shell.addListener(SWT.Close, new Listener() {
- @Override
- public void handleEvent(Event event) {
- if (!mFinished) {
- Log.d("ddms", "NOT closing - cancelling command");
- event.doit = false;
- mCancel = true;
- }
- }
- });
-
- mStatusLabel = new Label(shell, SWT.NONE);
- mStatusLabel.setText("Executing '" + shortCommandString() + "'");
- data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- data.horizontalSpan = 2;
- mStatusLabel.setLayoutData(data);
-
- mText = new Text(shell, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
- mText.setEditable(false);
- mText.setFont(mFont);
- data = new GridData(GridData.FILL_BOTH);
- data.horizontalSpan = 2;
- mText.setLayoutData(data);
-
- // "save" button
- mSave = new Button(shell, SWT.PUSH);
- mSave.setText("Save");
- data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
- data.widthHint = 80;
- mSave.setLayoutData(data);
- mSave.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- saveText(shell);
- }
- });
- mSave.setEnabled(false);
-
- // "cancel/done" button
- mCancelDone = new Button(shell, SWT.PUSH);
- mCancelDone.setText("Cancel");
- data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
- data.widthHint = 80;
- mCancelDone.setLayoutData(data);
- mCancelDone.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (!mFinished)
- mCancel = true;
- else
- shell.close();
- }
- });
- }
-
- /*
- * Figure out what font to use.
- *
- * Returns "null" if we can't figure it out, which SWT understands to
- * mean "use default system font".
- */
- private Font findFont(Display display) {
- String fontStr = PrefsDialog.getStore().getString("textOutputFont");
- if (fontStr != null) {
- FontData fdat = new FontData(fontStr);
- if (fdat != null)
- return new Font(display, fdat);
- }
- return null;
- }
-
-
- /*
- * Callback class for command execution.
- */
- class Gatherer extends Thread implements IShellOutputReceiver {
- public static final int RESULT_UNKNOWN = 0;
- public static final int RESULT_SUCCESS = 1;
- public static final int RESULT_FAILURE = 2;
- public static final int RESULT_CANCELLED = 3;
-
- private Shell mShell;
- private String mCommand;
- private Text mText;
- private int mResult;
- private IDevice mDevice;
-
- /**
- * Constructor; pass in the text widget that will receive the output.
- * @param device
- */
- public Gatherer(Shell shell, IDevice device, String command, Text text) {
- mShell = shell;
- mDevice = device;
- mCommand = command;
- mText = text;
- mResult = RESULT_UNKNOWN;
-
- // this is in outer class
- mCancel = false;
- }
-
- /**
- * Thread entry point.
- */
- @Override
- public void run() {
-
- if (mDevice == null) {
- Log.w("ddms", "Cannot execute command: no device selected.");
- mResult = RESULT_FAILURE;
- } else {
- try {
- mDevice.executeShellCommand(mCommand, this);
- if (mCancel)
- mResult = RESULT_CANCELLED;
- else
- mResult = RESULT_SUCCESS;
- }
- catch (IOException ioe) {
- Log.w("ddms", "Remote exec failed: " + ioe.getMessage());
- mResult = RESULT_FAILURE;
- } catch (TimeoutException e) {
- Log.w("ddms", "Remote exec failed: " + e.getMessage());
- mResult = RESULT_FAILURE;
- } catch (AdbCommandRejectedException e) {
- Log.w("ddms", "Remote exec failed: " + e.getMessage());
- mResult = RESULT_FAILURE;
- } catch (ShellCommandUnresponsiveException e) {
- Log.w("ddms", "Remote exec failed: " + e.getMessage());
- mResult = RESULT_FAILURE;
- }
- }
-
- mShell.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- updateForResult(mResult);
- }
- });
- }
-
- /**
- * Called by executeRemoteCommand().
- */
- @Override
- public void addOutput(byte[] data, int offset, int length) {
-
- Log.v("ddms", "received " + length + " bytes");
- try {
- final String text;
- text = new String(data, offset, length, "ISO-8859-1");
-
- // add to text widget; must do in UI thread
- mText.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- mText.append(text);
- }
- });
- }
- catch (UnsupportedEncodingException uee) {
- uee.printStackTrace(); // not expected
- }
- }
-
- @Override
- public void flush() {
- // nothing to flush.
- }
-
- /**
- * Called by executeRemoteCommand().
- */
- @Override
- public boolean isCancelled() {
- return mCancel;
- }
- };
-
- /*
- * Execute a remote command, add the output to the text widget, and
- * update controls.
- *
- * We have to run the command in a thread so that the UI continues
- * to work.
- */
- private void executeCommand(Shell shell, IDevice device) {
- Gatherer gath = new Gatherer(shell, device, commandString(), mText);
- gath.start();
- }
-
- /*
- * Update the controls after the remote operation completes. This
- * must be called from the UI thread.
- */
- private void updateForResult(int result) {
- if (result == Gatherer.RESULT_SUCCESS) {
- mStatusLabel.setText("Successfully executed '"
- + shortCommandString() + "'");
- mSave.setEnabled(true);
- } else if (result == Gatherer.RESULT_CANCELLED) {
- mStatusLabel.setText("Execution cancelled; partial results below");
- mSave.setEnabled(true); // save partial
- } else if (result == Gatherer.RESULT_FAILURE) {
- mStatusLabel.setText("Failed");
- }
- mStatusLabel.pack();
- mCancelDone.setText("Done");
- mFinished = true;
- }
-
- /*
- * Allow the user to save the contents of the text dialog.
- */
- private void saveText(Shell shell) {
- FileDialog dlg = new FileDialog(shell, SWT.SAVE);
- String fileName;
-
- dlg.setText("Save output...");
- dlg.setFileName(defaultFileName());
- dlg.setFilterPath(PrefsDialog.getStore().getString("lastTextSaveDir"));
- dlg.setFilterNames(new String[] {
- "Text Files (*.txt)"
- });
- dlg.setFilterExtensions(new String[] {
- "*.txt"
- });
-
- fileName = dlg.open();
- if (fileName != null) {
- PrefsDialog.getStore().setValue("lastTextSaveDir",
- dlg.getFilterPath());
-
- Log.d("ddms", "Saving output to " + fileName);
-
- /*
- * Convert to 8-bit characters.
- */
- String text = mText.getText();
- byte[] ascii;
- try {
- ascii = text.getBytes("ISO-8859-1");
- }
- catch (UnsupportedEncodingException uee) {
- uee.printStackTrace();
- ascii = new byte[0];
- }
-
- /*
- * Output data, converting CRLF to LF.
- */
- try {
- int length = ascii.length;
-
- FileOutputStream outFile = new FileOutputStream(fileName);
- BufferedOutputStream out = new BufferedOutputStream(outFile);
- for (int i = 0; i < length; i++) {
- if (i < length-1 &&
- ascii[i] == 0x0d && ascii[i+1] == 0x0a)
- {
- continue;
- }
- out.write(ascii[i]);
- }
- out.close(); // flush buffer, close file
- }
- catch (IOException ioe) {
- Log.w("ddms", "Unable to save " + fileName + ": " + ioe);
- }
- }
- }
-
-
- /*
- * Return the shell command we're going to use.
- */
- private String commandString() {
- return mCommand;
-
- }
-
- /*
- * Return a default filename for the "save" command.
- */
- private String defaultFileName() {
- return mFileName;
- }
-
- /*
- * Like commandString(), but length-limited.
- */
- private String shortCommandString() {
- String str = commandString();
- if (str.length() > 50)
- return str.substring(0, 50) + "...";
- else
- return str;
- }
-}
-
diff --git a/ddms/app/src/com/android/ddms/DropdownSelectionListener.java b/ddms/app/src/com/android/ddms/DropdownSelectionListener.java
deleted file mode 100644
index 04d921c..0000000
--- a/ddms/app/src/com/android/ddms/DropdownSelectionListener.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/* //device/tools/ddms/src/com/android/ddms/DropdownSelectionListener.java
-**
-** Copyright 2007, The Android Open Source Project
-**
-** Licensed under the Apache License, Version 2.0 (the "License");
-** you may not use this file except in compliance with the License.
-** You may obtain a copy of the License at
-**
-** http://www.apache.org/licenses/LICENSE-2.0
-**
-** Unless required by applicable law or agreed to in writing, software
-** distributed under the License is distributed on an "AS IS" BASIS,
-** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-** See the License for the specific language governing permissions and
-** limitations under the License.
-*/
-
-package com.android.ddms;
-
-import com.android.ddmlib.Log;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.ToolItem;
-
-/**
- * Helper class for drop-down menus in toolbars.
- */
-public class DropdownSelectionListener extends SelectionAdapter {
- private Menu mMenu;
- private ToolItem mDropdown;
-
- /**
- * Basic constructor. Creates an empty Menu to hold items.
- */
- public DropdownSelectionListener(ToolItem item) {
- mDropdown = item;
- mMenu = new Menu(item.getParent().getShell(), SWT.POP_UP);
- }
-
- /**
- * Add an item to the dropdown menu.
- */
- public void add(String label) {
- MenuItem item = new MenuItem(mMenu, SWT.NONE);
- item.setText(label);
- item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // update the dropdown's text to match the selection
- MenuItem sel = (MenuItem) e.widget;
- mDropdown.setText(sel.getText());
- }
- });
- }
-
- /**
- * Invoked when dropdown or neighboring arrow is clicked.
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (e.detail == SWT.ARROW) {
- // arrow clicked, show menu
- ToolItem item = (ToolItem) e.widget;
- Rectangle rect = item.getBounds();
- Point pt = item.getParent().toDisplay(new Point(rect.x, rect.y));
- mMenu.setLocation(pt.x, pt.y + rect.height);
- mMenu.setVisible(true);
- } else {
- // button clicked
- Log.d("ddms", mDropdown.getText() + " Pressed");
- }
- }
-}
-
diff --git a/ddms/app/src/com/android/ddms/Main.java b/ddms/app/src/com/android/ddms/Main.java
deleted file mode 100644
index bfdb78b..0000000
--- a/ddms/app/src/com/android/ddms/Main.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddms;
-
-import com.android.ddmlib.AndroidDebugBridge;
-import com.android.ddmlib.DebugPortManager;
-import com.android.ddmlib.Log;
-import com.android.sdkstats.SdkStatsService;
-
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.lang.management.ManagementFactory;
-import java.lang.management.RuntimeMXBean;
-import java.util.Properties;
-
-
-/**
- * Start the UI and network.
- */
-public class Main {
-
- public static String sRevision;
-
- public Main() {
- }
-
- /*
- * If a thread bails with an uncaught exception, bring the whole
- * thing down.
- */
- private static class UncaughtHandler implements Thread.UncaughtExceptionHandler {
- @Override
- public void uncaughtException(Thread t, Throwable e) {
- Log.e("ddms", "shutting down due to uncaught exception");
- Log.e("ddms", e);
- System.exit(1);
- }
- }
-
- /**
- * Parse args, start threads.
- */
- public static void main(String[] args) {
- // In order to have the AWT/SWT bridge work on Leopard, we do this little hack.
- if (isMac()) {
- RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean();
- System.setProperty(
- "JAVA_STARTED_ON_FIRST_THREAD_" + (rt.getName().split("@"))[0], //$NON-NLS-1$
- "1"); //$NON-NLS-1$
- }
-
- Thread.setDefaultUncaughtExceptionHandler(new UncaughtHandler());
-
- // load prefs and init the default values
- PrefsDialog.init();
-
- Log.d("ddms", "Initializing");
-
- // Create an initial shell display with the correct app name.
- Display.setAppName(UIThread.APP_NAME);
- Shell shell = new Shell(Display.getDefault());
-
- // if this is the first time using ddms or adt, open up the stats service
- // opt out dialog, and request user for permissions.
- SdkStatsService stats = new SdkStatsService();
- stats.checkUserPermissionForPing(shell);
-
- // the "ping" argument means to check in with the server and exit
- // the application name and version number must also be supplied
- if (args.length >= 3 && args[0].equals("ping")) {
- stats.ping(args);
- return;
- } else if (args.length > 0) {
- Log.e("ddms", "Unknown argument: " + args[0]);
- System.exit(1);
- }
-
- // get the ddms parent folder location
- String ddmsParentLocation = System.getProperty("com.android.ddms.bindir"); //$NON-NLS-1$
-
- if (ddmsParentLocation == null) {
- // Tip: for debugging DDMS in eclipse, set this env var to the SDK/tools
- // directory path.
- ddmsParentLocation = System.getenv("com.android.ddms.bindir"); //$NON-NLS-1$
- }
-
- // we're past the point where ddms can be called just to send a ping, so we can
- // ping for ddms itself.
- ping(stats, ddmsParentLocation);
- stats = null;
-
- DebugPortManager.setProvider(DebugPortProvider.getInstance());
-
- // create the three main threads
- UIThread ui = UIThread.getInstance();
-
- try {
- ui.runUI(ddmsParentLocation);
- } finally {
- PrefsDialog.save();
-
- AndroidDebugBridge.terminate();
- }
-
- Log.d("ddms", "Bye");
-
- // this is kinda bad, but on MacOS the shutdown doesn't seem to finish because of
- // a thread called AWT-Shutdown. This will help while I track this down.
- System.exit(0);
- }
-
- /** Return true iff we're running on a Mac */
- static boolean isMac() {
- // TODO: Replace usages of this method with
- // org.eclipse.jface.util.Util#isMac() when we switch to Eclipse 3.5
- // (ddms is currently built with SWT 3.4.2 from ANDROID_SWT)
- return System.getProperty("os.name").startsWith("Mac OS"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private static void ping(SdkStatsService stats, String ddmsParentLocation) {
- Properties p = new Properties();
- try{
- File sourceProp;
- if (ddmsParentLocation != null && ddmsParentLocation.length() > 0) {
- sourceProp = new File(ddmsParentLocation, "source.properties"); //$NON-NLS-1$
- } else {
- sourceProp = new File("source.properties"); //$NON-NLS-1$
- }
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(sourceProp);
- p.load(fis);
- } finally {
- if (fis != null) {
- try {
- fis.close();
- } catch (IOException ignore) {
- }
- }
- }
-
- sRevision = p.getProperty("Pkg.Revision"); //$NON-NLS-1$
- if (sRevision != null && sRevision.length() > 0) {
- stats.ping("ddms", sRevision); //$NON-NLS-1$
- }
- } catch (FileNotFoundException e) {
- // couldn't find the file? don't ping.
- } catch (IOException e) {
- // couldn't find the file? don't ping.
- }
- }
-}
diff --git a/ddms/app/src/com/android/ddms/PrefsDialog.java b/ddms/app/src/com/android/ddms/PrefsDialog.java
deleted file mode 100644
index acadeb8..0000000
--- a/ddms/app/src/com/android/ddms/PrefsDialog.java
+++ /dev/null
@@ -1,610 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddms;
-
-import com.android.ddmlib.DdmConstants;
-import com.android.ddmlib.DdmPreferences;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmuilib.DdmUiPreferences;
-import com.android.ddmuilib.PortFieldEditor;
-import com.android.ddmuilib.logcat.LogCatMessageList;
-import com.android.ddmuilib.logcat.LogCatPanel;
-import com.android.sdkstats.DdmsPreferenceStore;
-import com.android.sdkstats.SdkStatsPermissionDialog;
-
-import org.eclipse.jface.preference.BooleanFieldEditor;
-import org.eclipse.jface.preference.DirectoryFieldEditor;
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.FontFieldEditor;
-import org.eclipse.jface.preference.IntegerFieldEditor;
-import org.eclipse.jface.preference.PreferenceDialog;
-import org.eclipse.jface.preference.PreferenceManager;
-import org.eclipse.jface.preference.PreferenceNode;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.preference.PreferenceStore;
-import org.eclipse.jface.preference.RadioGroupFieldEditor;
-import org.eclipse.jface.preference.StringFieldEditor;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.File;
-import java.io.IOException;
-
-/**
- * Preferences dialog.
- */
-public final class PrefsDialog {
-
- // public const values for storage
- public final static String SHELL_X = "shellX"; //$NON-NLS-1$
- public final static String SHELL_Y = "shellY"; //$NON-NLS-1$
- public final static String SHELL_WIDTH = "shellWidth"; //$NON-NLS-1$
- public final static String SHELL_HEIGHT = "shellHeight"; //$NON-NLS-1$
- public final static String EXPLORER_SHELL_X = "explorerShellX"; //$NON-NLS-1$
- public final static String EXPLORER_SHELL_Y = "explorerShellY"; //$NON-NLS-1$
- public final static String EXPLORER_SHELL_WIDTH = "explorerShellWidth"; //$NON-NLS-1$
- public final static String EXPLORER_SHELL_HEIGHT = "explorerShellHeight"; //$NON-NLS-1$
- public final static String SHOW_NATIVE_HEAP = "native"; //$NON-NLS-1$
-
- public final static String LOGCAT_COLUMN_MODE = "ddmsLogColumnMode"; //$NON-NLS-1$
- public final static String LOGCAT_FONT = "ddmsLogFont"; //$NON-NLS-1$
-
- public final static String LOGCAT_COLUMN_MODE_AUTO = "auto"; //$NON-NLS-1$
- public final static String LOGCAT_COLUMN_MODE_MANUAL = "manual"; //$NON-NLS-1$
-
- private final static String PREFS_DEBUG_PORT_BASE = "adbDebugBasePort"; //$NON-NLS-1$
- private final static String PREFS_SELECTED_DEBUG_PORT = "debugSelectedPort"; //$NON-NLS-1$
- private final static String PREFS_DEFAULT_THREAD_UPDATE = "defaultThreadUpdateEnabled"; //$NON-NLS-1$
- private final static String PREFS_DEFAULT_HEAP_UPDATE = "defaultHeapUpdateEnabled"; //$NON-NLS-1$
- private final static String PREFS_THREAD_REFRESH_INTERVAL = "threadStatusInterval"; //$NON-NLS-1$
- private final static String PREFS_LOG_LEVEL = "ddmsLogLevel"; //$NON-NLS-1$
- private final static String PREFS_TIMEOUT = "timeOut"; //$NON-NLS-1$
- private final static String PREFS_PROFILER_BUFFER_SIZE_MB = "profilerBufferSizeMb"; //$NON-NLS-1$
- private final static String PREFS_USE_ADBHOST = "useAdbHost"; //$NON-NLS-1$
- private final static String PREFS_ADBHOST_VALUE = "adbHostValue"; //$NON-NLS-1$
-
- // Preference store.
- private static DdmsPreferenceStore mStore = new DdmsPreferenceStore();
-
- /**
- * Private constructor -- do not instantiate.
- */
- private PrefsDialog() {}
-
- /**
- * Return the PreferenceStore that holds our values.
- *
- * @deprecated Callers should use {@link DdmsPreferenceStore} directly.
- */
- @Deprecated
- public static PreferenceStore getStore() {
- return mStore.getPreferenceStore();
- }
-
- /**
- * Save the prefs to the config file.
- *
- * @deprecated Callers should use {@link DdmsPreferenceStore} directly.
- */
- @Deprecated
- public static void save() {
- try {
- mStore.getPreferenceStore().save();
- }
- catch (IOException ioe) {
- Log.w("ddms", "Failed saving prefs file: " + ioe.getMessage());
- }
- }
-
- /**
- * Do some one-time prep.
- *
- * The original plan was to let the individual classes define their
- * own defaults, which we would get and then override with the config
- * file. However, PreferencesStore.load() doesn't trigger the "changed"
- * events, which means we have to pull the loaded config values out by
- * hand.
- *
- * So, we set the defaults, load the values from the config file, and
- * then run through and manually export the values. Then we duplicate
- * the second part later on for the "changed" events.
- */
- public static void init() {
- PreferenceStore prefStore = mStore.getPreferenceStore();
-
- if (prefStore == null) {
- // we have a serious issue here...
- Log.e("ddms",
- "failed to access both the user HOME directory and the system wide temp folder. Quitting.");
- System.exit(1);
- }
-
- // configure default values
- setDefaults(System.getProperty("user.home")); //$NON-NLS-1$
-
- // listen for changes
- prefStore.addPropertyChangeListener(new ChangeListener());
-
- // Now we initialize the value of the preference, from the values in the store.
-
- // First the ddm lib.
- DdmPreferences.setDebugPortBase(prefStore.getInt(PREFS_DEBUG_PORT_BASE));
- DdmPreferences.setSelectedDebugPort(prefStore.getInt(PREFS_SELECTED_DEBUG_PORT));
- DdmPreferences.setLogLevel(prefStore.getString(PREFS_LOG_LEVEL));
- DdmPreferences.setInitialThreadUpdate(prefStore.getBoolean(PREFS_DEFAULT_THREAD_UPDATE));
- DdmPreferences.setInitialHeapUpdate(prefStore.getBoolean(PREFS_DEFAULT_HEAP_UPDATE));
- DdmPreferences.setTimeOut(prefStore.getInt(PREFS_TIMEOUT));
- DdmPreferences.setProfilerBufferSizeMb(prefStore.getInt(PREFS_PROFILER_BUFFER_SIZE_MB));
- DdmPreferences.setUseAdbHost(prefStore.getBoolean(PREFS_USE_ADBHOST));
- DdmPreferences.setAdbHostValue(prefStore.getString(PREFS_ADBHOST_VALUE));
-
- // some static values
- String out = System.getenv("ANDROID_PRODUCT_OUT"); //$NON-NLS-1$
- DdmUiPreferences.setSymbolsLocation(out + File.separator + "symbols"); //$NON-NLS-1$
- DdmUiPreferences.setAddr2LineLocation("arm-linux-androideabi-addr2line"); //$NON-NLS-1$
-
- String traceview = System.getProperty("com.android.ddms.bindir"); //$NON-NLS-1$
- if (traceview != null && traceview.length() != 0) {
- traceview += File.separator + DdmConstants.FN_TRACEVIEW;
- } else {
- traceview = DdmConstants.FN_TRACEVIEW;
- }
- DdmUiPreferences.setTraceviewLocation(traceview);
-
- // Now the ddmui lib
- DdmUiPreferences.setStore(prefStore);
- DdmUiPreferences.setThreadRefreshInterval(prefStore.getInt(PREFS_THREAD_REFRESH_INTERVAL));
- }
-
- /*
- * Set default values for all preferences. These are either defined
- * statically or are based on the values set by the class initializers
- * in other classes.
- *
- * The other threads (e.g. VMWatcherThread) haven't been created yet,
- * so we want to use static values rather than reading fields from
- * class.getInstance().
- */
- private static void setDefaults(String homeDir) {
- PreferenceStore prefStore = mStore.getPreferenceStore();
-
- prefStore.setDefault(PREFS_DEBUG_PORT_BASE, DdmPreferences.DEFAULT_DEBUG_PORT_BASE);
-
- prefStore.setDefault(PREFS_SELECTED_DEBUG_PORT,
- DdmPreferences.DEFAULT_SELECTED_DEBUG_PORT);
-
- prefStore.setDefault(PREFS_USE_ADBHOST, DdmPreferences.DEFAULT_USE_ADBHOST);
- prefStore.setDefault(PREFS_ADBHOST_VALUE, DdmPreferences.DEFAULT_ADBHOST_VALUE);
-
- prefStore.setDefault(PREFS_DEFAULT_THREAD_UPDATE, true);
- prefStore.setDefault(PREFS_DEFAULT_HEAP_UPDATE, false);
- prefStore.setDefault(PREFS_THREAD_REFRESH_INTERVAL,
- DdmUiPreferences.DEFAULT_THREAD_REFRESH_INTERVAL);
-
- prefStore.setDefault("textSaveDir", homeDir); //$NON-NLS-1$
- prefStore.setDefault("imageSaveDir", homeDir); //$NON-NLS-1$
-
- prefStore.setDefault(PREFS_LOG_LEVEL, "info"); //$NON-NLS-1$
-
- prefStore.setDefault(PREFS_TIMEOUT, DdmPreferences.DEFAULT_TIMEOUT);
- prefStore.setDefault(PREFS_PROFILER_BUFFER_SIZE_MB,
- DdmPreferences.DEFAULT_PROFILER_BUFFER_SIZE_MB);
-
- // choose a default font for the text output
- FontData fdat = new FontData("Courier", 10, SWT.NORMAL); //$NON-NLS-1$
- prefStore.setDefault("textOutputFont", fdat.toString()); //$NON-NLS-1$
-
- // layout information.
- prefStore.setDefault(SHELL_X, 100);
- prefStore.setDefault(SHELL_Y, 100);
- prefStore.setDefault(SHELL_WIDTH, 800);
- prefStore.setDefault(SHELL_HEIGHT, 600);
-
- prefStore.setDefault(EXPLORER_SHELL_X, 50);
- prefStore.setDefault(EXPLORER_SHELL_Y, 50);
-
- prefStore.setDefault(SHOW_NATIVE_HEAP, false);
- }
-
-
- /*
- * Create a "listener" to take action when preferences change. These are
- * required for ongoing activities that don't check prefs on each use.
- *
- * This is only invoked when something explicitly changes the value of
- * a preference (e.g. not when the prefs file is loaded).
- */
- private static class ChangeListener implements IPropertyChangeListener {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- String changed = event.getProperty();
- PreferenceStore prefStore = mStore.getPreferenceStore();
-
- if (changed.equals(PREFS_DEBUG_PORT_BASE)) {
- DdmPreferences.setDebugPortBase(prefStore.getInt(PREFS_DEBUG_PORT_BASE));
- } else if (changed.equals(PREFS_SELECTED_DEBUG_PORT)) {
- DdmPreferences.setSelectedDebugPort(prefStore.getInt(PREFS_SELECTED_DEBUG_PORT));
- } else if (changed.equals(PREFS_LOG_LEVEL)) {
- DdmPreferences.setLogLevel((String)event.getNewValue());
- } else if (changed.equals("textSaveDir")) {
- prefStore.setValue("lastTextSaveDir",
- (String) event.getNewValue());
- } else if (changed.equals("imageSaveDir")) {
- prefStore.setValue("lastImageSaveDir",
- (String) event.getNewValue());
- } else if (changed.equals(PREFS_TIMEOUT)) {
- DdmPreferences.setTimeOut(prefStore.getInt(PREFS_TIMEOUT));
- } else if (changed.equals(PREFS_PROFILER_BUFFER_SIZE_MB)) {
- DdmPreferences.setProfilerBufferSizeMb(
- prefStore.getInt(PREFS_PROFILER_BUFFER_SIZE_MB));
- } else if (changed.equals(PREFS_USE_ADBHOST)) {
- DdmPreferences.setUseAdbHost(prefStore.getBoolean(PREFS_USE_ADBHOST));
- } else if (changed.equals(PREFS_ADBHOST_VALUE)) {
- DdmPreferences.setAdbHostValue(prefStore.getString(PREFS_ADBHOST_VALUE));
- } else {
- Log.v("ddms", "Preference change: " + event.getProperty()
- + ": '" + event.getOldValue()
- + "' --> '" + event.getNewValue() + "'");
- }
- }
- }
-
-
- /**
- * Create and display the dialog.
- */
- public static void run(Shell shell) {
- PreferenceStore prefStore = mStore.getPreferenceStore();
- assert prefStore != null;
-
- PreferenceManager prefMgr = new PreferenceManager();
-
- PreferenceNode node, subNode;
-
- // this didn't work -- got NPE, possibly from class lookup:
- //PreferenceNode app = new PreferenceNode("app", "Application", null,
- // AppPrefs.class.getName());
-
- node = new PreferenceNode("debugger", new DebuggerPrefs());
- prefMgr.addToRoot(node);
-
- subNode = new PreferenceNode("panel", new PanelPrefs());
- //prefMgr.addTo(node.getId(), subNode);
- prefMgr.addToRoot(subNode);
-
- node = new PreferenceNode("LogCat", new LogCatPrefs());
- prefMgr.addToRoot(node);
-
- node = new PreferenceNode("misc", new MiscPrefs());
- prefMgr.addToRoot(node);
-
- node = new PreferenceNode("stats", new UsageStatsPrefs());
- prefMgr.addToRoot(node);
-
- PreferenceDialog dlg = new PreferenceDialog(shell, prefMgr);
- dlg.setPreferenceStore(prefStore);
-
- // run it
- try {
- dlg.open();
- } catch (Throwable t) {
- Log.e("ddms", t);
- }
-
- // save prefs
- try {
- prefStore.save();
- }
- catch (IOException ioe) {
- }
-
- // discard the stuff we created
- //prefMgr.dispose();
- //dlg.dispose();
- }
-
- /**
- * "Debugger" prefs page.
- */
- private static class DebuggerPrefs extends FieldEditorPreferencePage {
-
- private BooleanFieldEditor mUseAdbHost;
- private StringFieldEditor mAdbHostValue;
-
- /**
- * Basic constructor.
- */
- public DebuggerPrefs() {
- super(GRID); // use "grid" layout so edit boxes line up
- setTitle("Debugger");
- }
-
- /**
- * Create field editors.
- */
- @Override
- protected void createFieldEditors() {
- IntegerFieldEditor ife;
-
- ife = new PortFieldEditor(PREFS_DEBUG_PORT_BASE,
- "Starting value for local port:", getFieldEditorParent());
- addField(ife);
-
- ife = new PortFieldEditor(PREFS_SELECTED_DEBUG_PORT,
- "Port of Selected VM:", getFieldEditorParent());
- addField(ife);
-
- mUseAdbHost = new BooleanFieldEditor(PREFS_USE_ADBHOST,
- "Use ADBHOST", getFieldEditorParent());
- addField(mUseAdbHost);
-
- mAdbHostValue = new StringFieldEditor(PREFS_ADBHOST_VALUE,
- "ADBHOST value:", getFieldEditorParent());
- mAdbHostValue.setEnabled(getPreferenceStore()
- .getBoolean(PREFS_USE_ADBHOST), getFieldEditorParent());
- addField(mAdbHostValue);
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- // TODO Auto-generated method stub
- if (event.getSource().equals(mUseAdbHost)) {
- mAdbHostValue.setEnabled(mUseAdbHost.getBooleanValue(), getFieldEditorParent());
- }
- }
- }
-
- /**
- * "Panel" prefs page.
- */
- private static class PanelPrefs extends FieldEditorPreferencePage {
-
- /**
- * Basic constructor.
- */
- public PanelPrefs() {
- super(FLAT); // use "flat" layout
- setTitle("Info Panels");
- }
-
- /**
- * Create field editors.
- */
- @Override
- protected void createFieldEditors() {
- BooleanFieldEditor bfe;
- IntegerFieldEditor ife;
-
- bfe = new BooleanFieldEditor(PREFS_DEFAULT_THREAD_UPDATE,
- "Thread updates enabled by default", getFieldEditorParent());
- addField(bfe);
-
- bfe = new BooleanFieldEditor(PREFS_DEFAULT_HEAP_UPDATE,
- "Heap updates enabled by default", getFieldEditorParent());
- addField(bfe);
-
- ife = new IntegerFieldEditor(PREFS_THREAD_REFRESH_INTERVAL,
- "Thread status interval (seconds):", getFieldEditorParent());
- ife.setValidRange(1, 60);
- addField(ife);
- }
- }
-
- /**
- * "logcat" prefs page.
- */
- private static class LogCatPrefs extends FieldEditorPreferencePage {
-
- /**
- * Basic constructor.
- */
- public LogCatPrefs() {
- super(FLAT); // use "flat" layout
- setTitle("Logcat");
- }
-
- /**
- * Create field editors.
- */
- @Override
- protected void createFieldEditors() {
- if (UIThread.useOldLogCatView()) {
- RadioGroupFieldEditor rgfe;
-
- rgfe = new RadioGroupFieldEditor(PrefsDialog.LOGCAT_COLUMN_MODE,
- "Message Column Resizing Mode", 1, new String[][] {
- { "Manual", PrefsDialog.LOGCAT_COLUMN_MODE_MANUAL },
- { "Automatic", PrefsDialog.LOGCAT_COLUMN_MODE_AUTO },
- },
- getFieldEditorParent(), true);
- addField(rgfe);
-
- FontFieldEditor ffe = new FontFieldEditor(PrefsDialog.LOGCAT_FONT,
- "Text output font:",
- getFieldEditorParent());
- addField(ffe);
- } else {
- FontFieldEditor ffe = new FontFieldEditor(LogCatPanel.LOGCAT_VIEW_FONT_PREFKEY,
- "Text output font:",
- getFieldEditorParent());
- addField(ffe);
-
- IntegerFieldEditor maxMessages = new IntegerFieldEditor(
- LogCatMessageList.MAX_MESSAGES_PREFKEY,
- "Maximum number of logcat messages to buffer",
- getFieldEditorParent());
- addField(maxMessages);
-
- BooleanFieldEditor autoScrollLock = new BooleanFieldEditor(
- LogCatPanel.AUTO_SCROLL_LOCK_PREFKEY,
- "Automatically enable/disable scroll lock based on the scrollbar position",
- getFieldEditorParent());
- addField(autoScrollLock);
- }
- }
- }
-
- /**
- * "misc" prefs page.
- */
- private static class MiscPrefs extends FieldEditorPreferencePage {
-
- /**
- * Basic constructor.
- */
- public MiscPrefs() {
- super(FLAT); // use "flat" layout
- setTitle("Misc");
- }
-
- /**
- * Create field editors.
- */
- @Override
- protected void createFieldEditors() {
- DirectoryFieldEditor dfe;
- FontFieldEditor ffe;
-
- IntegerFieldEditor ife = new IntegerFieldEditor(PREFS_TIMEOUT,
- "ADB connection time out (ms):", getFieldEditorParent());
- addField(ife);
-
- ife = new IntegerFieldEditor(PREFS_PROFILER_BUFFER_SIZE_MB,
- "Profiler buffer size (MB):", getFieldEditorParent());
- addField(ife);
-
- dfe = new DirectoryFieldEditor("textSaveDir",
- "Default text save dir:", getFieldEditorParent());
- addField(dfe);
-
- dfe = new DirectoryFieldEditor("imageSaveDir",
- "Default image save dir:", getFieldEditorParent());
- addField(dfe);
-
- ffe = new FontFieldEditor("textOutputFont", "Text output font:",
- getFieldEditorParent());
- addField(ffe);
-
- RadioGroupFieldEditor rgfe;
-
- rgfe = new RadioGroupFieldEditor(PREFS_LOG_LEVEL,
- "Logging Level", 1, new String[][] {
- { "Verbose", LogLevel.VERBOSE.getStringValue() },
- { "Debug", LogLevel.DEBUG.getStringValue() },
- { "Info", LogLevel.INFO.getStringValue() },
- { "Warning", LogLevel.WARN.getStringValue() },
- { "Error", LogLevel.ERROR.getStringValue() },
- { "Assert", LogLevel.ASSERT.getStringValue() },
- },
- getFieldEditorParent(), true);
- addField(rgfe);
- }
- }
-
- /**
- * "Device" prefs page.
- */
- private static class UsageStatsPrefs extends PreferencePage {
-
- private BooleanFieldEditor mOptInCheckbox;
- private Composite mTop;
-
- /**
- * Basic constructor.
- */
- public UsageStatsPrefs() {
- setTitle("Usage Stats");
- }
-
- @Override
- protected Control createContents(Composite parent) {
- mTop = new Composite(parent, SWT.NONE);
- mTop.setLayout(new GridLayout(1, false));
- mTop.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Label text = new Label(mTop, SWT.WRAP);
- text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- text.setText(SdkStatsPermissionDialog.BODY_TEXT);
-
- Link privacyPolicyLink = new Link(mTop, SWT.WRAP);
- privacyPolicyLink.setText(SdkStatsPermissionDialog.PRIVACY_POLICY_LINK_TEXT);
- privacyPolicyLink.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- SdkStatsPermissionDialog.openUrl(event.text);
- }
- });
-
- mOptInCheckbox = new BooleanFieldEditor(DdmsPreferenceStore.PING_OPT_IN,
- SdkStatsPermissionDialog.CHECKBOX_TEXT, mTop);
- mOptInCheckbox.setPage(this);
- mOptInCheckbox.setPreferenceStore(getPreferenceStore());
- mOptInCheckbox.load();
-
- return null;
- }
-
- @Override
- protected Point doComputeSize() {
- if (mTop != null) {
- return mTop.computeSize(450, SWT.DEFAULT, true);
- }
-
- return super.doComputeSize();
- }
-
- @Override
- protected void performDefaults() {
- if (mOptInCheckbox != null) {
- mOptInCheckbox.loadDefault();
- }
- super.performDefaults();
- }
-
- @Override
- public void performApply() {
- if (mOptInCheckbox != null) {
- mOptInCheckbox.store();
- }
- super.performApply();
- }
-
- @Override
- public boolean performOk() {
- if (mOptInCheckbox != null) {
- mOptInCheckbox.store();
- }
- return super.performOk();
- }
- }
-
-}
-
-
diff --git a/ddms/app/src/com/android/ddms/StaticPortConfigDialog.java b/ddms/app/src/com/android/ddms/StaticPortConfigDialog.java
deleted file mode 100644
index 9a8ada3..0000000
--- a/ddms/app/src/com/android/ddms/StaticPortConfigDialog.java
+++ /dev/null
@@ -1,395 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddms;
-
-import com.android.ddmuilib.TableHelper;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Dialog to configure the static debug ports.
- *
- */
-public class StaticPortConfigDialog extends Dialog {
-
- /** Preference name for the 0th column width */
- private static final String PREFS_DEVICE_COL = "spcd.deviceColumn"; //$NON-NLS-1$
-
- /** Preference name for the 1st column width */
- private static final String PREFS_APP_COL = "spcd.AppColumn"; //$NON-NLS-1$
-
- /** Preference name for the 2nd column width */
- private static final String PREFS_PORT_COL = "spcd.PortColumn"; //$NON-NLS-1$
-
- private static final int COL_DEVICE = 0;
- private static final int COL_APPLICATION = 1;
- private static final int COL_PORT = 2;
-
-
- private static final int DLG_WIDTH = 500;
- private static final int DLG_HEIGHT = 300;
-
- private Shell mShell;
- private Shell mParent;
-
- private Table mPortTable;
-
- /**
- * Array containing the list of already used static port to avoid
- * duplication.
- */
- private ArrayList<Integer> mPorts = new ArrayList<Integer>();
-
- /**
- * Basic constructor.
- * @param parent
- */
- public StaticPortConfigDialog(Shell parent) {
- super(parent, SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
- }
-
- /**
- * Open and display the dialog. This method returns only when the
- * user closes the dialog somehow.
- *
- */
- public void open() {
- createUI();
-
- if (mParent == null || mShell == null) {
- return;
- }
-
- updateFromStore();
-
- // Set the dialog size.
- mShell.setMinimumSize(DLG_WIDTH, DLG_HEIGHT);
- Rectangle r = mParent.getBounds();
- // get the center new top left.
- int cx = r.x + r.width/2;
- int x = cx - DLG_WIDTH / 2;
- int cy = r.y + r.height/2;
- int y = cy - DLG_HEIGHT / 2;
- mShell.setBounds(x, y, DLG_WIDTH, DLG_HEIGHT);
-
- mShell.pack();
-
- // actually open the dialog
- mShell.open();
-
- // event loop until the dialog is closed.
- Display display = mParent.getDisplay();
- while (!mShell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
- }
-
- /**
- * Creates the dialog ui.
- */
- private void createUI() {
- mParent = getParent();
- mShell = new Shell(mParent, getStyle());
- mShell.setText("Static Port Configuration");
-
- mShell.setLayout(new GridLayout(1, true));
-
- mShell.addListener(SWT.Close, new Listener() {
- @Override
- public void handleEvent(Event event) {
- event.doit = true;
- }
- });
-
- // center part with the list on the left and the buttons
- // on the right.
- Composite main = new Composite(mShell, SWT.NONE);
- main.setLayoutData(new GridData(GridData.FILL_BOTH));
- main.setLayout(new GridLayout(2, false));
-
- // left part: list view
- mPortTable = new Table(main, SWT.SINGLE | SWT.FULL_SELECTION);
- mPortTable.setLayoutData(new GridData(GridData.FILL_BOTH));
- mPortTable.setHeaderVisible(true);
- mPortTable.setLinesVisible(true);
-
- TableHelper.createTableColumn(mPortTable, "Device Serial Number",
- SWT.LEFT, "emulator-5554", //$NON-NLS-1$
- PREFS_DEVICE_COL, PrefsDialog.getStore());
-
- TableHelper.createTableColumn(mPortTable, "Application Package",
- SWT.LEFT, "com.android.samples.phone", //$NON-NLS-1$
- PREFS_APP_COL, PrefsDialog.getStore());
-
- TableHelper.createTableColumn(mPortTable, "Debug Port",
- SWT.RIGHT, "Debug Port", //$NON-NLS-1$
- PREFS_PORT_COL, PrefsDialog.getStore());
-
- // right part: buttons
- Composite buttons = new Composite(main, SWT.NONE);
- buttons.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- buttons.setLayout(new GridLayout(1, true));
-
- Button newButton = new Button(buttons, SWT.NONE);
- newButton.setText("New...");
- newButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- StaticPortEditDialog dlg = new StaticPortEditDialog(mShell,
- mPorts);
- if (dlg.open()) {
- // get the text
- String device = dlg.getDeviceSN();
- String app = dlg.getAppName();
- int port = dlg.getPortNumber();
-
- // add it to the list
- addEntry(device, app, port);
- }
- }
- });
-
- final Button editButton = new Button(buttons, SWT.NONE);
- editButton.setText("Edit...");
- editButton.setEnabled(false);
- editButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- int index = mPortTable.getSelectionIndex();
- String oldDeviceName = getDeviceName(index);
- String oldAppName = getAppName(index);
- String oldPortNumber = getPortNumber(index);
- StaticPortEditDialog dlg = new StaticPortEditDialog(mShell,
- mPorts, oldDeviceName, oldAppName, oldPortNumber);
- if (dlg.open()) {
- // get the text
- String deviceName = dlg.getDeviceSN();
- String app = dlg.getAppName();
- int port = dlg.getPortNumber();
-
- // add it to the list
- replaceEntry(index, deviceName, app, port);
- }
- }
- });
-
- final Button deleteButton = new Button(buttons, SWT.NONE);
- deleteButton.setText("Delete");
- deleteButton.setEnabled(false);
- deleteButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- int index = mPortTable.getSelectionIndex();
- removeEntry(index);
- }
- });
-
- // bottom part with the ok/cancel
- Composite bottomComp = new Composite(mShell, SWT.NONE);
- bottomComp.setLayoutData(new GridData(
- GridData.HORIZONTAL_ALIGN_CENTER));
- bottomComp.setLayout(new GridLayout(2, true));
-
- Button okButton = new Button(bottomComp, SWT.NONE);
- okButton.setText("OK");
- okButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- updateStore();
- mShell.close();
- }
- });
-
- Button cancelButton = new Button(bottomComp, SWT.NONE);
- cancelButton.setText("Cancel");
- cancelButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mShell.close();
- }
- });
-
- mPortTable.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // get the selection index
- int index = mPortTable.getSelectionIndex();
-
- boolean enabled = index != -1;
- editButton.setEnabled(enabled);
- deleteButton.setEnabled(enabled);
- }
- });
-
- mShell.pack();
-
- }
-
- /**
- * Add a new entry in the list.
- * @param deviceName the serial number of the device
- * @param appName java package for the application
- * @param portNumber port number
- */
- private void addEntry(String deviceName, String appName, int portNumber) {
- // create a new item for the table
- TableItem item = new TableItem(mPortTable, SWT.NONE);
-
- item.setText(COL_DEVICE, deviceName);
- item.setText(COL_APPLICATION, appName);
- item.setText(COL_PORT, Integer.toString(portNumber));
-
- // add the port to the list of port number used.
- mPorts.add(portNumber);
- }
-
- /**
- * Remove an entry from the list.
- * @param index The index of the entry to be removed
- */
- private void removeEntry(int index) {
- // remove from the ui
- mPortTable.remove(index);
-
- // and from the port list.
- mPorts.remove(index);
- }
-
- /**
- * Replace an entry in the list with new values.
- * @param index The index of the item to be replaced
- * @param deviceName the serial number of the device
- * @param appName The new java package for the application
- * @param portNumber The new port number.
- */
- private void replaceEntry(int index, String deviceName, String appName, int portNumber) {
- // get the table item by index
- TableItem item = mPortTable.getItem(index);
-
- // set its new value
- item.setText(COL_DEVICE, deviceName);
- item.setText(COL_APPLICATION, appName);
- item.setText(COL_PORT, Integer.toString(portNumber));
-
- // and replace the port number in the port list.
- mPorts.set(index, portNumber);
- }
-
-
- /**
- * Returns the device name for a specific index
- * @param index The index
- * @return the java package name of the application
- */
- private String getDeviceName(int index) {
- TableItem item = mPortTable.getItem(index);
- return item.getText(COL_DEVICE);
- }
-
- /**
- * Returns the application name for a specific index
- * @param index The index
- * @return the java package name of the application
- */
- private String getAppName(int index) {
- TableItem item = mPortTable.getItem(index);
- return item.getText(COL_APPLICATION);
- }
-
- /**
- * Returns the port number for a specific index
- * @param index The index
- * @return the port number
- */
- private String getPortNumber(int index) {
- TableItem item = mPortTable.getItem(index);
- return item.getText(COL_PORT);
- }
-
- /**
- * Updates the ui from the value in the preference store.
- */
- private void updateFromStore() {
- // get the map from the debug port manager
- DebugPortProvider provider = DebugPortProvider.getInstance();
- Map<String, Map<String, Integer>> map = provider.getPortList();
-
- // we're going to loop on the keys and fill the table.
- Set<String> deviceKeys = map.keySet();
-
- for (String deviceKey : deviceKeys) {
- Map<String, Integer> deviceMap = map.get(deviceKey);
- if (deviceMap != null) {
- Set<String> appKeys = deviceMap.keySet();
-
- for (String appKey : appKeys) {
- Integer port = deviceMap.get(appKey);
- if (port != null) {
- addEntry(deviceKey, appKey, port);
- }
- }
- }
- }
- }
-
- /**
- * Update the store from the content of the ui.
- */
- private void updateStore() {
- // create a new Map object and fill it.
- HashMap<String, Map<String, Integer>> map = new HashMap<String, Map<String, Integer>>();
-
- int count = mPortTable.getItemCount();
-
- for (int i = 0 ; i < count ; i++) {
- TableItem item = mPortTable.getItem(i);
- String deviceName = item.getText(COL_DEVICE);
-
- Map<String, Integer> deviceMap = map.get(deviceName);
- if (deviceMap == null) {
- deviceMap = new HashMap<String, Integer>();
- map.put(deviceName, deviceMap);
- }
-
- deviceMap.put(item.getText(COL_APPLICATION), Integer.valueOf(item.getText(COL_PORT)));
- }
-
- // set it in the store through the debug port manager.
- DebugPortProvider provider = DebugPortProvider.getInstance();
- provider.setPortList(map);
- }
-}
diff --git a/ddms/app/src/com/android/ddms/StaticPortEditDialog.java b/ddms/app/src/com/android/ddms/StaticPortEditDialog.java
deleted file mode 100644
index c9cb044..0000000
--- a/ddms/app/src/com/android/ddms/StaticPortEditDialog.java
+++ /dev/null
@@ -1,334 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddms;
-
-import com.android.ddmlib.IDevice;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import java.util.ArrayList;
-
-/**
- * Small dialog box to edit a static port number.
- */
-public class StaticPortEditDialog extends Dialog {
-
- private static final int DLG_WIDTH = 400;
- private static final int DLG_HEIGHT = 200;
-
- private Shell mParent;
-
- private Shell mShell;
-
- private boolean mOk = false;
-
- private String mAppName;
-
- private String mPortNumber;
-
- private Button mOkButton;
-
- private Label mWarning;
-
- /** List of ports already in use */
- private ArrayList<Integer> mPorts;
-
- /** This is the port being edited. */
- private int mEditPort = -1;
- private String mDeviceSn;
-
- /**
- * Creates a dialog with empty fields.
- * @param parent The parent Shell
- * @param ports The list of already used port numbers.
- */
- public StaticPortEditDialog(Shell parent, ArrayList<Integer> ports) {
- super(parent, SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
- mPorts = ports;
- mDeviceSn = IDevice.FIRST_EMULATOR_SN;
- }
-
- /**
- * Creates a dialog with predefined values.
- * @param shell The parent shell
- * @param ports The list of already used port numbers.
- * @param oldDeviceSN the device serial number to display
- * @param oldAppName The application name to display
- * @param oldPortNumber The port number to display
- */
- public StaticPortEditDialog(Shell shell, ArrayList<Integer> ports,
- String oldDeviceSN, String oldAppName, String oldPortNumber) {
- this(shell, ports);
-
- mDeviceSn = oldDeviceSN;
- mAppName = oldAppName;
- mPortNumber = oldPortNumber;
- mEditPort = Integer.valueOf(mPortNumber);
- }
-
- /**
- * Opens the dialog. The method will return when the user closes the dialog
- * somehow.
- *
- * @return true if ok was pressed, false if cancelled.
- */
- public boolean open() {
- createUI();
-
- if (mParent == null || mShell == null) {
- return false;
- }
-
- mShell.setMinimumSize(DLG_WIDTH, DLG_HEIGHT);
- Rectangle r = mParent.getBounds();
- // get the center new top left.
- int cx = r.x + r.width/2;
- int x = cx - DLG_WIDTH / 2;
- int cy = r.y + r.height/2;
- int y = cy - DLG_HEIGHT / 2;
- mShell.setBounds(x, y, DLG_WIDTH, DLG_HEIGHT);
-
- mShell.open();
-
- Display display = mParent.getDisplay();
- while (!mShell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- return mOk;
- }
-
- public String getDeviceSN() {
- return mDeviceSn;
- }
-
- public String getAppName() {
- return mAppName;
- }
-
- public int getPortNumber() {
- return Integer.valueOf(mPortNumber);
- }
-
- private void createUI() {
- mParent = getParent();
- mShell = new Shell(mParent, getStyle());
- mShell.setText("Static Port");
-
- mShell.setLayout(new GridLayout(1, false));
-
- mShell.addListener(SWT.Close, new Listener() {
- @Override
- public void handleEvent(Event event) {
- }
- });
-
- // center part with the edit field
- Composite main = new Composite(mShell, SWT.NONE);
- main.setLayoutData(new GridData(GridData.FILL_BOTH));
- main.setLayout(new GridLayout(2, false));
-
- Label l0 = new Label(main, SWT.NONE);
- l0.setText("Device Name:");
-
- final Text deviceSNText = new Text(main, SWT.SINGLE | SWT.BORDER);
- deviceSNText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- if (mDeviceSn != null) {
- deviceSNText.setText(mDeviceSn);
- }
- deviceSNText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- mDeviceSn = deviceSNText.getText().trim();
- validate();
- }
- });
-
- Label l = new Label(main, SWT.NONE);
- l.setText("Application Name:");
-
- final Text appNameText = new Text(main, SWT.SINGLE | SWT.BORDER);
- if (mAppName != null) {
- appNameText.setText(mAppName);
- }
- appNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- appNameText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- mAppName = appNameText.getText().trim();
- validate();
- }
- });
-
- Label l2 = new Label(main, SWT.NONE);
- l2.setText("Debug Port:");
-
- final Text debugPortText = new Text(main, SWT.SINGLE | SWT.BORDER);
- if (mPortNumber != null) {
- debugPortText.setText(mPortNumber);
- }
- debugPortText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- debugPortText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- mPortNumber = debugPortText.getText().trim();
- validate();
- }
- });
-
- // warning label
- Composite warningComp = new Composite(mShell, SWT.NONE);
- warningComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- warningComp.setLayout(new GridLayout(1, true));
-
- mWarning = new Label(warningComp, SWT.NONE);
- mWarning.setText("");
- mWarning.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // bottom part with the ok/cancel
- Composite bottomComp = new Composite(mShell, SWT.NONE);
- bottomComp
- .setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
- bottomComp.setLayout(new GridLayout(2, true));
-
- mOkButton = new Button(bottomComp, SWT.NONE);
- mOkButton.setText("OK");
- mOkButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mOk = true;
- mShell.close();
- }
- });
- mOkButton.setEnabled(false);
- mShell.setDefaultButton(mOkButton);
-
- Button cancelButton = new Button(bottomComp, SWT.NONE);
- cancelButton.setText("Cancel");
- cancelButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mShell.close();
- }
- });
-
- validate();
- }
-
- /**
- * Validates the content of the 2 text fields and enable/disable "ok", while
- * setting up the warning/error message.
- */
- private void validate() {
- // first we reset the warning dialog. This allows us to latter
- // display warnings.
- mWarning.setText(""); //$NON-NLS-1$
-
- // check the device name field is not empty
- if (mDeviceSn == null || mDeviceSn.length() == 0) {
- mWarning.setText("Device name missing.");
- mOkButton.setEnabled(false);
- return;
- }
-
- // check the application name field is not empty
- if (mAppName == null || mAppName.length() == 0) {
- mWarning.setText("Application name missing.");
- mOkButton.setEnabled(false);
- return;
- }
-
- String packageError = "Application name must be a valid Java package name.";
-
- // validate the package name as well. It must be a fully qualified
- // java package.
- String[] packageSegments = mAppName.split("\\."); //$NON-NLS-1$
- for (String p : packageSegments) {
- if (p.matches("^[a-zA-Z][a-zA-Z0-9]*") == false) { //$NON-NLS-1$
- mWarning.setText(packageError);
- mOkButton.setEnabled(false);
- return;
- }
-
- // lets also display a warning if the package contains upper case
- // letters.
- if (p.matches("^[a-z][a-z0-9]*") == false) { //$NON-NLS-1$
- mWarning.setText("Lower case is recommended for Java packages.");
- }
- }
-
- // the split will not detect the last char being a '.'
- // so we test it manually
- if (mAppName.charAt(mAppName.length()-1) == '.') {
- mWarning.setText(packageError);
- mOkButton.setEnabled(false);
- return;
- }
-
- // now we test the package name field is not empty.
- if (mPortNumber == null || mPortNumber.length() == 0) {
- mWarning.setText("Port Number missing.");
- mOkButton.setEnabled(false);
- return;
- }
-
- // then we check it only contains digits.
- if (mPortNumber.matches("[0-9]*") == false) { //$NON-NLS-1$
- mWarning.setText("Port Number invalid.");
- mOkButton.setEnabled(false);
- return;
- }
-
- // get the int from the port number to validate
- long port = Long.valueOf(mPortNumber);
- if (port >= 32767) {
- mOkButton.setEnabled(false);
- return;
- }
-
- // check if its in the list of already used ports
- if (port != mEditPort) {
- for (Integer i : mPorts) {
- if (port == i.intValue()) {
- mWarning.setText("Port already in use.");
- mOkButton.setEnabled(false);
- return;
- }
- }
- }
-
- // at this point there's not error, so we enable the ok button.
- mOkButton.setEnabled(true);
- }
-}
diff --git a/ddms/app/src/com/android/ddms/UIThread.java b/ddms/app/src/com/android/ddms/UIThread.java
deleted file mode 100644
index 8aaa806..0000000
--- a/ddms/app/src/com/android/ddms/UIThread.java
+++ /dev/null
@@ -1,1803 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddms;
-
-import com.android.ddmlib.AndroidDebugBridge;
-import com.android.ddmlib.AndroidDebugBridge.IClientChangeListener;
-import com.android.ddmlib.Client;
-import com.android.ddmlib.ClientData;
-import com.android.ddmlib.ClientData.IHprofDumpHandler;
-import com.android.ddmlib.ClientData.MethodProfilingStatus;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.Log.ILogOutput;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.SyncException;
-import com.android.ddmlib.SyncService;
-import com.android.ddmuilib.AllocationPanel;
-import com.android.ddmuilib.DdmUiPreferences;
-import com.android.ddmuilib.DevicePanel;
-import com.android.ddmuilib.DevicePanel.IUiSelectionListener;
-import com.android.ddmuilib.EmulatorControlPanel;
-import com.android.ddmuilib.HeapPanel;
-import com.android.ddmuilib.ITableFocusListener;
-import com.android.ddmuilib.ImageLoader;
-import com.android.ddmuilib.InfoPanel;
-import com.android.ddmuilib.NativeHeapPanel;
-import com.android.ddmuilib.ScreenShotDialog;
-import com.android.ddmuilib.SysinfoPanel;
-import com.android.ddmuilib.TablePanel;
-import com.android.ddmuilib.ThreadPanel;
-import com.android.ddmuilib.actions.ToolItemAction;
-import com.android.ddmuilib.explorer.DeviceExplorer;
-import com.android.ddmuilib.handler.BaseFileHandler;
-import com.android.ddmuilib.handler.MethodProfilingHandler;
-import com.android.ddmuilib.log.event.EventLogPanel;
-import com.android.ddmuilib.logcat.LogCatPanel;
-import com.android.ddmuilib.logcat.LogColors;
-import com.android.ddmuilib.logcat.LogFilter;
-import com.android.ddmuilib.logcat.LogPanel;
-import com.android.ddmuilib.logcat.LogPanel.ILogFilterStorageManager;
-import com.android.ddmuilib.net.NetworkPanel;
-import com.android.menubar.IMenuBarCallback;
-import com.android.menubar.IMenuBarEnhancer;
-import com.android.menubar.IMenuBarEnhancer.MenuBarMode;
-import com.android.menubar.MenuBarEnhancer;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.MenuAdapter;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.events.ShellListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.MenuItem;
-import org.eclipse.swt.widgets.Sash;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-
-import java.io.File;
-import java.util.ArrayList;
-
-/**
- * This acts as the UI builder. This cannot be its own thread since this prevent using AWT in an
- * SWT application. So this class mainly builds the ui, and manages communication between the panels
- * when {@link IDevice} / {@link Client} selection changes.
- */
-public class UIThread implements IUiSelectionListener, IClientChangeListener {
- public static final String APP_NAME = "DDMS";
-
- /*
- * UI tab panel definitions. The constants here must match up with the array
- * indices in mPanels. PANEL_CLIENT_LIST is a "virtual" panel representing
- * the client list.
- */
- public static final int PANEL_CLIENT_LIST = -1;
-
- public static final int PANEL_INFO = 0;
-
- public static final int PANEL_THREAD = 1;
-
- public static final int PANEL_HEAP = 2;
-
- private static final int PANEL_NATIVE_HEAP = 3;
-
- private static final int PANEL_ALLOCATIONS = 4;
-
- private static final int PANEL_SYSINFO = 5;
-
- private static final int PANEL_NETWORK = 6;
-
- private static final int PANEL_COUNT = 7;
-
- /** Content is setup in the constructor */
- private static TablePanel[] mPanels = new TablePanel[PANEL_COUNT];
-
- private static final String[] mPanelNames = new String[] {
- "Info", "Threads", "VM Heap", "Native Heap",
- "Allocation Tracker", "Sysinfo", "Network"
- };
-
- private static final String[] mPanelTips = new String[] {
- "Client information", "Thread status", "VM heap status",
- "Native heap status", "Allocation Tracker", "Sysinfo graphs",
- "Network usage"
- };
-
- private static final String PREFERENCE_LOGSASH =
- "logSashLocation"; //$NON-NLS-1$
- private static final String PREFERENCE_SASH =
- "sashLocation"; //$NON-NLS-1$
-
- private static final String PREFS_COL_TIME =
- "logcat.time"; //$NON-NLS-1$
- private static final String PREFS_COL_LEVEL =
- "logcat.level"; //$NON-NLS-1$
- private static final String PREFS_COL_PID =
- "logcat.pid"; //$NON-NLS-1$
- private static final String PREFS_COL_TAG =
- "logcat.tag"; //$NON-NLS-1$
- private static final String PREFS_COL_MESSAGE =
- "logcat.message"; //$NON-NLS-1$
-
- private static final String PREFS_FILTERS = "logcat.filter"; //$NON-NLS-1$
-
- // singleton instance
- private static UIThread mInstance = new UIThread();
-
- // our display
- private Display mDisplay;
-
- // the table we show in the left-hand pane
- private DevicePanel mDevicePanel;
-
- private IDevice mCurrentDevice = null;
- private Client mCurrentClient = null;
-
- // status line at the bottom of the app window
- private Label mStatusLine;
-
- // some toolbar items we need to update
- private ToolItem mTBShowThreadUpdates;
- private ToolItem mTBShowHeapUpdates;
- private ToolItem mTBHalt;
- private ToolItem mTBCauseGc;
- private ToolItem mTBDumpHprof;
- private ToolItem mTBProfiling;
-
- private final class FilterStorage implements ILogFilterStorageManager {
-
- @Override
- public LogFilter[] getFilterFromStore() {
- String filterPrefs = PrefsDialog.getStore().getString(
- PREFS_FILTERS);
-
- // split in a string per filter
- String[] filters = filterPrefs.split("\\|"); //$NON-NLS-1$
-
- ArrayList<LogFilter> list =
- new ArrayList<LogFilter>(filters.length);
-
- for (String f : filters) {
- if (f.length() > 0) {
- LogFilter logFilter = new LogFilter();
- if (logFilter.loadFromString(f)) {
- list.add(logFilter);
- }
- }
- }
-
- return list.toArray(new LogFilter[list.size()]);
- }
-
- @Override
- public void saveFilters(LogFilter[] filters) {
- StringBuilder sb = new StringBuilder();
- for (LogFilter f : filters) {
- String filterString = f.toString();
- sb.append(filterString);
- sb.append('|');
- }
-
- PrefsDialog.getStore().setValue(PREFS_FILTERS, sb.toString());
- }
-
- @Override
- public boolean requiresDefaultFilter() {
- return true;
- }
- }
-
-
- /**
- * Flag to indicate whether to use the old or the new logcat view. This is a
- * temporary workaround that will be removed once the new view is complete.
- */
- private static final String USE_OLD_LOGCAT_VIEW =
- System.getenv("ANDROID_USE_OLD_LOGCAT_VIEW");
- public static boolean useOldLogCatView() {
- return USE_OLD_LOGCAT_VIEW != null;
- }
-
- private LogPanel mLogPanel; /* only valid when useOldLogCatView() == true */
- private LogCatPanel mLogCatPanel; /* only valid when useOldLogCatView() == false */
-
- private ToolItemAction mCreateFilterAction;
- private ToolItemAction mDeleteFilterAction;
- private ToolItemAction mEditFilterAction;
- private ToolItemAction mExportAction;
- private ToolItemAction mClearAction;
-
- private ToolItemAction[] mLogLevelActions;
- private String[] mLogLevelIcons = {
- "v.png", //$NON-NLS-1S
- "d.png", //$NON-NLS-1S
- "i.png", //$NON-NLS-1S
- "w.png", //$NON-NLS-1S
- "e.png", //$NON-NLS-1S
- };
-
- protected Clipboard mClipboard;
-
- private MenuItem mCopyMenuItem;
-
- private MenuItem mSelectAllMenuItem;
-
- private TableFocusListener mTableListener;
-
- private DeviceExplorer mExplorer = null;
- private Shell mExplorerShell = null;
-
- private EmulatorControlPanel mEmulatorPanel;
-
- private EventLogPanel mEventLogPanel;
-
- private Image mTracingStartImage;
-
- private Image mTracingStopImage;
-
- private ImageLoader mDdmUiLibLoader;
-
- private class TableFocusListener implements ITableFocusListener {
-
- private IFocusedTableActivator mCurrentActivator;
-
- @Override
- public void focusGained(IFocusedTableActivator activator) {
- mCurrentActivator = activator;
- if (mCopyMenuItem.isDisposed() == false) {
- mCopyMenuItem.setEnabled(true);
- mSelectAllMenuItem.setEnabled(true);
- }
- }
-
- @Override
- public void focusLost(IFocusedTableActivator activator) {
- // if we move from one table to another, it's unclear
- // if the old table lose its focus before the new
- // one gets the focus, so we need to check.
- if (activator == mCurrentActivator) {
- activator = null;
- if (mCopyMenuItem.isDisposed() == false) {
- mCopyMenuItem.setEnabled(false);
- mSelectAllMenuItem.setEnabled(false);
- }
- }
- }
-
- public void copy(Clipboard clipboard) {
- if (mCurrentActivator != null) {
- mCurrentActivator.copy(clipboard);
- }
- }
-
- public void selectAll() {
- if (mCurrentActivator != null) {
- mCurrentActivator.selectAll();
- }
- }
- }
-
- /**
- * Handler for HPROF dumps.
- * This will always prompt the user to save the HPROF file.
- */
- private class HProfHandler extends BaseFileHandler implements IHprofDumpHandler {
-
- public HProfHandler(Shell parentShell) {
- super(parentShell);
- }
-
- @Override
- public void onEndFailure(final Client client, final String message) {
- mDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- try {
- displayErrorFromUiThread(
- "Unable to create HPROF file for application '%1$s'\n\n%2$s" +
- "Check logcat for more information.",
- client.getClientData().getClientDescription(),
- message != null ? message + "\n\n" : "");
- } finally {
- // this will make sure the dump hprof button is re-enabled for the
- // current selection. as the client is finished dumping an hprof file
- enableButtons();
- }
- }
- });
- }
-
- @Override
- public void onSuccess(final String remoteFilePath, final Client client) {
- mDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- final IDevice device = client.getDevice();
- try {
- // get the sync service to pull the HPROF file
- final SyncService sync = client.getDevice().getSyncService();
- if (sync != null) {
- promptAndPull(sync,
- client.getClientData().getClientDescription() + ".hprof",
- remoteFilePath, "Save HPROF file");
- } else {
- displayErrorFromUiThread(
- "Unable to download HPROF file from device '%1$s'.",
- device.getSerialNumber());
- }
- } catch (SyncException e) {
- if (e.wasCanceled() == false) {
- displayErrorFromUiThread(
- "Unable to download HPROF file from device '%1$s'.\n\n%2$s",
- device.getSerialNumber(), e.getMessage());
- }
- } catch (Exception e) {
- displayErrorFromUiThread("Unable to download HPROF file from device '%1$s'.",
- device.getSerialNumber());
-
- } finally {
- // this will make sure the dump hprof button is re-enabled for the
- // current selection. as the client is finished dumping an hprof file
- enableButtons();
- }
- }
- });
- }
-
- @Override
- public void onSuccess(final byte[] data, final Client client) {
- mDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- promptAndSave(client.getClientData().getClientDescription() + ".hprof", data,
- "Save HPROF file");
- }
- });
- }
-
- @Override
- protected String getDialogTitle() {
- return "HPROF Error";
- }
- }
-
-
- /**
- * Generic constructor.
- */
- private UIThread() {
- mPanels[PANEL_INFO] = new InfoPanel();
- mPanels[PANEL_THREAD] = new ThreadPanel();
- mPanels[PANEL_HEAP] = new HeapPanel();
- if (PrefsDialog.getStore().getBoolean(PrefsDialog.SHOW_NATIVE_HEAP)) {
- if (System.getenv("ANDROID_DDMS_OLD_HEAP_PANEL") != null) {
- mPanels[PANEL_NATIVE_HEAP] = new NativeHeapPanel();
- } else {
- mPanels[PANEL_NATIVE_HEAP] =
- new com.android.ddmuilib.heap.NativeHeapPanel(getStore());
- }
- } else {
- mPanels[PANEL_NATIVE_HEAP] = null;
- }
- mPanels[PANEL_ALLOCATIONS] = new AllocationPanel();
- mPanels[PANEL_SYSINFO] = new SysinfoPanel();
- mPanels[PANEL_NETWORK] = new NetworkPanel();
- }
-
- /**
- * Get singleton instance of the UI thread.
- */
- public static UIThread getInstance() {
- return mInstance;
- }
-
- /**
- * Return the Display. Don't try this unless you're in the UI thread.
- */
- public Display getDisplay() {
- return mDisplay;
- }
-
- public void asyncExec(Runnable r) {
- if (mDisplay != null && mDisplay.isDisposed() == false) {
- mDisplay.asyncExec(r);
- }
- }
-
- /** returns the IPreferenceStore */
- public IPreferenceStore getStore() {
- return PrefsDialog.getStore();
- }
-
- /**
- * Create SWT objects and drive the user interface event loop.
- * @param ddmsParentLocation location of the folder that contains ddms.
- */
- public void runUI(String ddmsParentLocation) {
- Display.setAppName(APP_NAME);
- mDisplay = Display.getDefault();
- final Shell shell = new Shell(mDisplay, SWT.SHELL_TRIM);
-
- // create the image loaders for DDMS and DDMUILIB
- mDdmUiLibLoader = ImageLoader.getDdmUiLibLoader();
-
- shell.setImage(ImageLoader.getLoader(this.getClass()).loadImage(mDisplay,
- "ddms-128.png", //$NON-NLS-1$
- 100, 50, null));
-
- Log.setLogOutput(new ILogOutput() {
- @Override
- public void printAndPromptLog(final LogLevel logLevel, final String tag,
- final String message) {
- Log.printLog(logLevel, tag, message);
- // dialog box only run in UI thread..
- mDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- Shell activeShell = mDisplay.getActiveShell();
- if (logLevel == LogLevel.ERROR) {
- MessageDialog.openError(activeShell, tag, message);
- } else {
- MessageDialog.openWarning(activeShell, tag, message);
- }
- }
- });
- }
-
- @Override
- public void printLog(LogLevel logLevel, String tag, String message) {
- Log.printLog(logLevel, tag, message);
- }
- });
-
- // set the handler for hprof dump
- ClientData.setHprofDumpHandler(new HProfHandler(shell));
- ClientData.setMethodProfilingHandler(new MethodProfilingHandler(shell));
-
- // [try to] ensure ADB is running
- // in the new SDK, adb is in the platform-tools, but when run from the command line
- // in the Android source tree, then adb is next to ddms.
- String adbLocation;
- if (ddmsParentLocation != null && ddmsParentLocation.length() != 0) {
- // check if there's a platform-tools folder
- File platformTools = new File(new File(ddmsParentLocation).getParent(),
- "platform-tools"); //$NON-NLS-1$
- if (platformTools.isDirectory()) {
- adbLocation = platformTools.getAbsolutePath() + File.separator + "adb"; //$NON-NLS-1$
- } else {
- adbLocation = ddmsParentLocation + File.separator + "adb"; //$NON-NLS-1$
- }
- } else {
- adbLocation = "adb"; //$NON-NLS-1$
- }
-
- AndroidDebugBridge.init(true /* debugger support */);
- AndroidDebugBridge.createBridge(adbLocation, true /* forceNewBridge */);
-
- // we need to listen to client change to be notified of client status (profiling) change
- AndroidDebugBridge.addClientChangeListener(this);
-
- shell.setText("Dalvik Debug Monitor");
- setConfirmClose(shell);
- createMenus(shell);
- createWidgets(shell);
-
- shell.pack();
- setSizeAndPosition(shell);
- shell.open();
-
- Log.d("ddms", "UI is up");
-
- while (!shell.isDisposed()) {
- if (!mDisplay.readAndDispatch())
- mDisplay.sleep();
- }
- if (useOldLogCatView()) {
- mLogPanel.stopLogCat(true);
- }
-
- mDevicePanel.dispose();
- for (TablePanel panel : mPanels) {
- if (panel != null) {
- panel.dispose();
- }
- }
-
- ImageLoader.dispose();
-
- mDisplay.dispose();
- Log.d("ddms", "UI is down");
- }
-
- /**
- * Set the size and position of the main window from the preference, and
- * setup listeners for control events (resize/move of the window)
- */
- private void setSizeAndPosition(final Shell shell) {
- shell.setMinimumSize(400, 200);
-
- // get the x/y and w/h from the prefs
- PreferenceStore prefs = PrefsDialog.getStore();
- int x = prefs.getInt(PrefsDialog.SHELL_X);
- int y = prefs.getInt(PrefsDialog.SHELL_Y);
- int w = prefs.getInt(PrefsDialog.SHELL_WIDTH);
- int h = prefs.getInt(PrefsDialog.SHELL_HEIGHT);
-
- // check that we're not out of the display area
- Rectangle rect = mDisplay.getClientArea();
- // first check the width/height
- if (w > rect.width) {
- w = rect.width;
- prefs.setValue(PrefsDialog.SHELL_WIDTH, rect.width);
- }
- if (h > rect.height) {
- h = rect.height;
- prefs.setValue(PrefsDialog.SHELL_HEIGHT, rect.height);
- }
- // then check x. Make sure the left corner is in the screen
- if (x < rect.x) {
- x = rect.x;
- prefs.setValue(PrefsDialog.SHELL_X, rect.x);
- } else if (x >= rect.x + rect.width) {
- x = rect.x + rect.width - w;
- prefs.setValue(PrefsDialog.SHELL_X, rect.x);
- }
- // then check y. Make sure the left corner is in the screen
- if (y < rect.y) {
- y = rect.y;
- prefs.setValue(PrefsDialog.SHELL_Y, rect.y);
- } else if (y >= rect.y + rect.height) {
- y = rect.y + rect.height - h;
- prefs.setValue(PrefsDialog.SHELL_Y, rect.y);
- }
-
- // now we can set the location/size
- shell.setBounds(x, y, w, h);
-
- // add listener for resize/move
- shell.addControlListener(new ControlListener() {
- @Override
- public void controlMoved(ControlEvent e) {
- // get the new x/y
- Rectangle controlBounds = shell.getBounds();
- // store in pref file
- PreferenceStore currentPrefs = PrefsDialog.getStore();
- currentPrefs.setValue(PrefsDialog.SHELL_X, controlBounds.x);
- currentPrefs.setValue(PrefsDialog.SHELL_Y, controlBounds.y);
- }
-
- @Override
- public void controlResized(ControlEvent e) {
- // get the new w/h
- Rectangle controlBounds = shell.getBounds();
- // store in pref file
- PreferenceStore currentPrefs = PrefsDialog.getStore();
- currentPrefs.setValue(PrefsDialog.SHELL_WIDTH, controlBounds.width);
- currentPrefs.setValue(PrefsDialog.SHELL_HEIGHT, controlBounds.height);
- }
- });
- }
-
- /**
- * Set the size and position of the file explorer window from the
- * preference, and setup listeners for control events (resize/move of
- * the window)
- */
- private void setExplorerSizeAndPosition(final Shell shell) {
- shell.setMinimumSize(400, 200);
-
- // get the x/y and w/h from the prefs
- PreferenceStore prefs = PrefsDialog.getStore();
- int x = prefs.getInt(PrefsDialog.EXPLORER_SHELL_X);
- int y = prefs.getInt(PrefsDialog.EXPLORER_SHELL_Y);
- int w = prefs.getInt(PrefsDialog.EXPLORER_SHELL_WIDTH);
- int h = prefs.getInt(PrefsDialog.EXPLORER_SHELL_HEIGHT);
-
- // check that we're not out of the display area
- Rectangle rect = mDisplay.getClientArea();
- // first check the width/height
- if (w > rect.width) {
- w = rect.width;
- prefs.setValue(PrefsDialog.EXPLORER_SHELL_WIDTH, rect.width);
- }
- if (h > rect.height) {
- h = rect.height;
- prefs.setValue(PrefsDialog.EXPLORER_SHELL_HEIGHT, rect.height);
- }
- // then check x. Make sure the left corner is in the screen
- if (x < rect.x) {
- x = rect.x;
- prefs.setValue(PrefsDialog.EXPLORER_SHELL_X, rect.x);
- } else if (x >= rect.x + rect.width) {
- x = rect.x + rect.width - w;
- prefs.setValue(PrefsDialog.EXPLORER_SHELL_X, rect.x);
- }
- // then check y. Make sure the left corner is in the screen
- if (y < rect.y) {
- y = rect.y;
- prefs.setValue(PrefsDialog.EXPLORER_SHELL_Y, rect.y);
- } else if (y >= rect.y + rect.height) {
- y = rect.y + rect.height - h;
- prefs.setValue(PrefsDialog.EXPLORER_SHELL_Y, rect.y);
- }
-
- // now we can set the location/size
- shell.setBounds(x, y, w, h);
-
- // add listener for resize/move
- shell.addControlListener(new ControlListener() {
- @Override
- public void controlMoved(ControlEvent e) {
- // get the new x/y
- Rectangle controlBounds = shell.getBounds();
- // store in pref file
- PreferenceStore currentPrefs = PrefsDialog.getStore();
- currentPrefs.setValue(PrefsDialog.EXPLORER_SHELL_X, controlBounds.x);
- currentPrefs.setValue(PrefsDialog.EXPLORER_SHELL_Y, controlBounds.y);
- }
-
- @Override
- public void controlResized(ControlEvent e) {
- // get the new w/h
- Rectangle controlBounds = shell.getBounds();
- // store in pref file
- PreferenceStore currentPrefs = PrefsDialog.getStore();
- currentPrefs.setValue(PrefsDialog.EXPLORER_SHELL_WIDTH, controlBounds.width);
- currentPrefs.setValue(PrefsDialog.EXPLORER_SHELL_HEIGHT, controlBounds.height);
- }
- });
- }
-
- /*
- * Set the confirm-before-close dialog.
- */
- private void setConfirmClose(final Shell shell) {
- // Note: there was some commented out code to display a confirmation box
- // when closing. The feature seems unnecessary and the code was not being
- // used, so it has been removed.
- }
-
- /*
- * Create the menu bar and items.
- */
- private void createMenus(final Shell shell) {
- // create menu bar
- Menu menuBar = new Menu(shell, SWT.BAR);
-
- // create top-level items
- MenuItem fileItem = new MenuItem(menuBar, SWT.CASCADE);
- fileItem.setText("&File");
- MenuItem editItem = new MenuItem(menuBar, SWT.CASCADE);
- editItem.setText("&Edit");
- MenuItem actionItem = new MenuItem(menuBar, SWT.CASCADE);
- actionItem.setText("&Actions");
- MenuItem deviceItem = new MenuItem(menuBar, SWT.CASCADE);
- deviceItem.setText("&Device");
-
- // create top-level menus
- Menu fileMenu = new Menu(menuBar);
- fileItem.setMenu(fileMenu);
- Menu editMenu = new Menu(menuBar);
- editItem.setMenu(editMenu);
- Menu actionMenu = new Menu(menuBar);
- actionItem.setMenu(actionMenu);
- Menu deviceMenu = new Menu(menuBar);
- deviceItem.setMenu(deviceMenu);
-
- MenuItem item;
-
- // create File menu items
- item = new MenuItem(fileMenu, SWT.NONE);
- item.setText("&Static Port Configuration...");
- item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- StaticPortConfigDialog dlg = new StaticPortConfigDialog(shell);
- dlg.open();
- }
- });
-
- IMenuBarEnhancer enhancer = MenuBarEnhancer.setupMenu(APP_NAME, fileMenu,
- new IMenuBarCallback() {
- @Override
- public void printError(String format, Object... args) {
- Log.e("DDMS Menu Bar", String.format(format, args));
- }
-
- @Override
- public void onPreferencesMenuSelected() {
- PrefsDialog.run(shell);
- }
-
- @Override
- public void onAboutMenuSelected() {
- AboutDialog dlg = new AboutDialog(shell);
- dlg.open();
- }
- });
-
- if (enhancer.getMenuBarMode() == MenuBarMode.GENERIC) {
- new MenuItem(fileMenu, SWT.SEPARATOR);
-
- item = new MenuItem(fileMenu, SWT.NONE);
- item.setText("E&xit\tCtrl-Q");
- item.setAccelerator('Q' | SWT.MOD1);
- item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- shell.close();
- }
- });
- }
-
- // create edit menu items
- mCopyMenuItem = new MenuItem(editMenu, SWT.NONE);
- mCopyMenuItem.setText("&Copy\tCtrl-C");
- mCopyMenuItem.setAccelerator('C' | SWT.MOD1);
- mCopyMenuItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mTableListener.copy(mClipboard);
- }
- });
-
- new MenuItem(editMenu, SWT.SEPARATOR);
-
- mSelectAllMenuItem = new MenuItem(editMenu, SWT.NONE);
- mSelectAllMenuItem.setText("Select &All\tCtrl-A");
- mSelectAllMenuItem.setAccelerator('A' | SWT.MOD1);
- mSelectAllMenuItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mTableListener.selectAll();
- }
- });
-
- // create Action menu items
- // TODO: this should come with a confirmation dialog
- final MenuItem actionHaltItem = new MenuItem(actionMenu, SWT.NONE);
- actionHaltItem.setText("&Halt VM");
- actionHaltItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mDevicePanel.killSelectedClient();
- }
- });
-
- final MenuItem actionCauseGcItem = new MenuItem(actionMenu, SWT.NONE);
- actionCauseGcItem.setText("Cause &GC");
- actionCauseGcItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mDevicePanel.forceGcOnSelectedClient();
- }
- });
-
- final MenuItem actionResetAdb = new MenuItem(actionMenu, SWT.NONE);
- actionResetAdb.setText("&Reset adb");
- actionResetAdb.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- AndroidDebugBridge bridge = AndroidDebugBridge.getBridge();
- if (bridge != null) {
- bridge.restart();
- }
- }
- });
-
- // configure Action items based on current state
- actionMenu.addMenuListener(new MenuAdapter() {
- @Override
- public void menuShown(MenuEvent e) {
- actionHaltItem.setEnabled(mTBHalt.getEnabled() && mCurrentClient != null);
- actionCauseGcItem.setEnabled(mTBCauseGc.getEnabled() && mCurrentClient != null);
- actionResetAdb.setEnabled(true);
- }
- });
-
- // create Device menu items
- final MenuItem screenShotItem = new MenuItem(deviceMenu, SWT.NONE);
-
- // The \tCtrl-S "keybinding text" here isn't right for the Mac - but
- // it's stripped out and replaced by the proper keyboard accelerator
- // text (e.g. the unicode symbol for the command key + S) anyway
- // so it's fine to leave it there for the other platforms.
- screenShotItem.setText("&Screen capture...\tCtrl-S");
- screenShotItem.setAccelerator('S' | SWT.MOD1);
- screenShotItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mCurrentDevice != null) {
- ScreenShotDialog dlg = new ScreenShotDialog(shell);
- dlg.open(mCurrentDevice);
- }
- }
- });
-
- new MenuItem(deviceMenu, SWT.SEPARATOR);
-
- final MenuItem explorerItem = new MenuItem(deviceMenu, SWT.NONE);
- explorerItem.setText("File Explorer...");
- explorerItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- createFileExplorer();
- }
- });
-
- new MenuItem(deviceMenu, SWT.SEPARATOR);
-
- final MenuItem processItem = new MenuItem(deviceMenu, SWT.NONE);
- processItem.setText("Show &process status...");
- processItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- DeviceCommandDialog dlg;
- dlg = new DeviceCommandDialog("ps -x", "ps-x.txt", shell);
- dlg.open(mCurrentDevice);
- }
- });
-
- final MenuItem deviceStateItem = new MenuItem(deviceMenu, SWT.NONE);
- deviceStateItem.setText("Dump &device state...");
- deviceStateItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- DeviceCommandDialog dlg;
- dlg = new DeviceCommandDialog("/system/bin/dumpstate /proc/self/fd/0",
- "device-state.txt", shell);
- dlg.open(mCurrentDevice);
- }
- });
-
- final MenuItem appStateItem = new MenuItem(deviceMenu, SWT.NONE);
- appStateItem.setText("Dump &app state...");
- appStateItem.setEnabled(false);
- appStateItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- DeviceCommandDialog dlg;
- dlg = new DeviceCommandDialog("dumpsys", "app-state.txt", shell);
- dlg.open(mCurrentDevice);
- }
- });
-
- final MenuItem radioStateItem = new MenuItem(deviceMenu, SWT.NONE);
- radioStateItem.setText("Dump &radio state...");
- radioStateItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- DeviceCommandDialog dlg;
- dlg = new DeviceCommandDialog(
- "cat /data/logs/radio.4 /data/logs/radio.3"
- + " /data/logs/radio.2 /data/logs/radio.1"
- + " /data/logs/radio",
- "radio-state.txt", shell);
- dlg.open(mCurrentDevice);
- }
- });
-
- final MenuItem logCatItem = new MenuItem(deviceMenu, SWT.NONE);
- logCatItem.setText("Run &logcat...");
- logCatItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- DeviceCommandDialog dlg;
- dlg = new DeviceCommandDialog("logcat '*:d jdwp:w'", "log.txt",
- shell);
- dlg.open(mCurrentDevice);
- }
- });
-
- // configure Action items based on current state
- deviceMenu.addMenuListener(new MenuAdapter() {
- @Override
- public void menuShown(MenuEvent e) {
- boolean deviceEnabled = mCurrentDevice != null;
- screenShotItem.setEnabled(deviceEnabled);
- explorerItem.setEnabled(deviceEnabled);
- processItem.setEnabled(deviceEnabled);
- deviceStateItem.setEnabled(deviceEnabled);
- appStateItem.setEnabled(deviceEnabled);
- radioStateItem.setEnabled(deviceEnabled);
- logCatItem.setEnabled(deviceEnabled);
- }
- });
-
- // tell the shell to use this menu
- shell.setMenuBar(menuBar);
- }
-
- /*
- * Create the widgets in the main application window. The basic layout is a
- * two-panel sash, with a scrolling list of VMs on the left and detailed
- * output for a single VM on the right.
- */
- private void createWidgets(final Shell shell) {
- Color darkGray = shell.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
-
- /*
- * Create three areas: tool bar, split panels, status line
- */
- shell.setLayout(new GridLayout(1, false));
-
- // 1. panel area
- final Composite panelArea = new Composite(shell, SWT.BORDER);
-
- // make the panel area absorb all space
- panelArea.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // 2. status line.
- mStatusLine = new Label(shell, SWT.NONE);
-
- // make status line extend all the way across
- mStatusLine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- mStatusLine.setText("Initializing...");
-
- /*
- * Configure the split-panel area.
- */
- final PreferenceStore prefs = PrefsDialog.getStore();
-
- Composite topPanel = new Composite(panelArea, SWT.NONE);
- final Sash sash = new Sash(panelArea, SWT.HORIZONTAL);
- sash.setBackground(darkGray);
- Composite bottomPanel = new Composite(panelArea, SWT.NONE);
-
- panelArea.setLayout(new FormLayout());
-
- createTopPanel(topPanel, darkGray);
-
- mClipboard = new Clipboard(panelArea.getDisplay());
- if (useOldLogCatView()) {
- createBottomPanel(bottomPanel);
- } else {
- createLogCatView(bottomPanel);
- }
-
- // form layout data
- FormData data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(sash, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- topPanel.setLayoutData(data);
-
- final FormData sashData = new FormData();
- if (prefs != null && prefs.contains(PREFERENCE_LOGSASH)) {
- sashData.top = new FormAttachment(0, prefs.getInt(
- PREFERENCE_LOGSASH));
- } else {
- sashData.top = new FormAttachment(50,0); // 50% across
- }
- sashData.left = new FormAttachment(0, 0);
- sashData.right = new FormAttachment(100, 0);
- sash.setLayoutData(sashData);
-
- data = new FormData();
- data.top = new FormAttachment(sash, 0);
- data.bottom = new FormAttachment(100, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- bottomPanel.setLayoutData(data);
-
- // allow resizes, but cap at minPanelWidth
- sash.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event e) {
- Rectangle sashRect = sash.getBounds();
- Rectangle panelRect = panelArea.getClientArea();
- int bottom = panelRect.height - sashRect.height - 100;
- e.y = Math.max(Math.min(e.y, bottom), 100);
- if (e.y != sashRect.y) {
- sashData.top = new FormAttachment(0, e.y);
- if (prefs != null) {
- prefs.setValue(PREFERENCE_LOGSASH, e.y);
- }
- panelArea.layout();
- }
- }
- });
-
- // add a global focus listener for all the tables
- mTableListener = new TableFocusListener();
-
- // now set up the listener in the various panels
- if (useOldLogCatView()) {
- mLogPanel.setTableFocusListener(mTableListener);
- } else {
- mLogCatPanel.setTableFocusListener(mTableListener);
- }
- mEventLogPanel.setTableFocusListener(mTableListener);
- for (TablePanel p : mPanels) {
- if (p != null) {
- p.setTableFocusListener(mTableListener);
- }
- }
-
- mStatusLine.setText("");
- }
-
- /*
- * Populate the tool bar.
- */
- private void createDevicePanelToolBar(ToolBar toolBar) {
- Display display = toolBar.getDisplay();
-
- // add "show heap updates" button
- mTBShowHeapUpdates = new ToolItem(toolBar, SWT.CHECK);
- mTBShowHeapUpdates.setImage(mDdmUiLibLoader.loadImage(display,
- DevicePanel.ICON_HEAP, DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mTBShowHeapUpdates.setToolTipText("Show heap updates");
- mTBShowHeapUpdates.setEnabled(false);
- mTBShowHeapUpdates.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mCurrentClient != null) {
- // boolean status = ((ToolItem)e.item).getSelection();
- // invert previous state
- boolean enable = !mCurrentClient.isHeapUpdateEnabled();
- mCurrentClient.setHeapUpdateEnabled(enable);
- } else {
- e.doit = false; // this has no effect?
- }
- }
- });
-
- // add "dump HPROF" button
- mTBDumpHprof = new ToolItem(toolBar, SWT.PUSH);
- mTBDumpHprof.setToolTipText("Dump HPROF file");
- mTBDumpHprof.setEnabled(false);
- mTBDumpHprof.setImage(mDdmUiLibLoader.loadImage(display,
- DevicePanel.ICON_HPROF, DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mTBDumpHprof.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mDevicePanel.dumpHprof();
-
- // this will make sure the dump hprof button is disabled for the current selection
- // as the client is already dumping an hprof file
- enableButtons();
- }
- });
-
- // add "cause GC" button
- mTBCauseGc = new ToolItem(toolBar, SWT.PUSH);
- mTBCauseGc.setToolTipText("Cause an immediate GC");
- mTBCauseGc.setEnabled(false);
- mTBCauseGc.setImage(mDdmUiLibLoader.loadImage(display,
- DevicePanel.ICON_GC, DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mTBCauseGc.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mDevicePanel.forceGcOnSelectedClient();
- }
- });
-
- new ToolItem(toolBar, SWT.SEPARATOR);
-
- // add "show thread updates" button
- mTBShowThreadUpdates = new ToolItem(toolBar, SWT.CHECK);
- mTBShowThreadUpdates.setImage(mDdmUiLibLoader.loadImage(display,
- DevicePanel.ICON_THREAD, DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mTBShowThreadUpdates.setToolTipText("Show thread updates");
- mTBShowThreadUpdates.setEnabled(false);
- mTBShowThreadUpdates.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mCurrentClient != null) {
- // boolean status = ((ToolItem)e.item).getSelection();
- // invert previous state
- boolean enable = !mCurrentClient.isThreadUpdateEnabled();
-
- mCurrentClient.setThreadUpdateEnabled(enable);
- } else {
- e.doit = false; // this has no effect?
- }
- }
- });
-
- // add a start/stop method tracing
- mTracingStartImage = mDdmUiLibLoader.loadImage(display,
- DevicePanel.ICON_TRACING_START,
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null);
- mTracingStopImage = mDdmUiLibLoader.loadImage(display,
- DevicePanel.ICON_TRACING_STOP,
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null);
- mTBProfiling = new ToolItem(toolBar, SWT.PUSH);
- mTBProfiling.setToolTipText("Start Method Profiling");
- mTBProfiling.setEnabled(false);
- mTBProfiling.setImage(mTracingStartImage);
- mTBProfiling.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mDevicePanel.toggleMethodProfiling();
- }
- });
-
- new ToolItem(toolBar, SWT.SEPARATOR);
-
- // add "kill VM" button; need to make this visually distinct from
- // the status update buttons
- mTBHalt = new ToolItem(toolBar, SWT.PUSH);
- mTBHalt.setToolTipText("Halt the target VM");
- mTBHalt.setEnabled(false);
- mTBHalt.setImage(mDdmUiLibLoader.loadImage(display,
- DevicePanel.ICON_HALT, DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mTBHalt.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mDevicePanel.killSelectedClient();
- }
- });
-
- toolBar.pack();
- }
-
- private void createTopPanel(final Composite comp, Color darkGray) {
- final PreferenceStore prefs = PrefsDialog.getStore();
-
- comp.setLayout(new FormLayout());
-
- Composite leftPanel = new Composite(comp, SWT.NONE);
- final Sash sash = new Sash(comp, SWT.VERTICAL);
- sash.setBackground(darkGray);
- Composite rightPanel = new Composite(comp, SWT.NONE);
-
- createLeftPanel(leftPanel);
- createRightPanel(rightPanel);
-
- FormData data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(sash, 0);
- leftPanel.setLayoutData(data);
-
- final FormData sashData = new FormData();
- sashData.top = new FormAttachment(0, 0);
- sashData.bottom = new FormAttachment(100, 0);
- if (prefs != null && prefs.contains(PREFERENCE_SASH)) {
- sashData.left = new FormAttachment(0, prefs.getInt(
- PREFERENCE_SASH));
- } else {
- // position the sash 380 from the right instead of x% (done by using
- // FormAttachment(x, 0)) in order to keep the sash at the same
- // position
- // from the left when the window is resized.
- // 380px is just enough to display the left table with no horizontal
- // scrollbar with the default font.
- sashData.left = new FormAttachment(0, 380);
- }
- sash.setLayoutData(sashData);
-
- data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
- data.left = new FormAttachment(sash, 0);
- data.right = new FormAttachment(100, 0);
- rightPanel.setLayoutData(data);
-
- final int minPanelWidth = 60;
-
- // allow resizes, but cap at minPanelWidth
- sash.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event e) {
- Rectangle sashRect = sash.getBounds();
- Rectangle panelRect = comp.getClientArea();
- int right = panelRect.width - sashRect.width - minPanelWidth;
- e.x = Math.max(Math.min(e.x, right), minPanelWidth);
- if (e.x != sashRect.x) {
- sashData.left = new FormAttachment(0, e.x);
- if (prefs != null) {
- prefs.setValue(PREFERENCE_SASH, e.x);
- }
- comp.layout();
- }
- }
- });
- }
-
- private void createBottomPanel(final Composite comp) {
- final PreferenceStore prefs = PrefsDialog.getStore();
-
- // create clipboard
- Display display = comp.getDisplay();
-
- LogColors colors = new LogColors();
-
- colors.infoColor = new Color(display, 0, 127, 0);
- colors.debugColor = new Color(display, 0, 0, 127);
- colors.errorColor = new Color(display, 255, 0, 0);
- colors.warningColor = new Color(display, 255, 127, 0);
- colors.verboseColor = new Color(display, 0, 0, 0);
-
- // set the preferences names
- LogPanel.PREFS_TIME = PREFS_COL_TIME;
- LogPanel.PREFS_LEVEL = PREFS_COL_LEVEL;
- LogPanel.PREFS_PID = PREFS_COL_PID;
- LogPanel.PREFS_TAG = PREFS_COL_TAG;
- LogPanel.PREFS_MESSAGE = PREFS_COL_MESSAGE;
-
- comp.setLayout(new GridLayout(1, false));
-
- ToolBar toolBar = new ToolBar(comp, SWT.HORIZONTAL);
-
- mCreateFilterAction = new ToolItemAction(toolBar, SWT.PUSH);
- mCreateFilterAction.item.setToolTipText("Create Filter");
- mCreateFilterAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay,
- "add.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mCreateFilterAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mLogPanel.addFilter();
- }
- });
-
- mEditFilterAction = new ToolItemAction(toolBar, SWT.PUSH);
- mEditFilterAction.item.setToolTipText("Edit Filter");
- mEditFilterAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay,
- "edit.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mEditFilterAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mLogPanel.editFilter();
- }
- });
-
- mDeleteFilterAction = new ToolItemAction(toolBar, SWT.PUSH);
- mDeleteFilterAction.item.setToolTipText("Delete Filter");
- mDeleteFilterAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay,
- "delete.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mDeleteFilterAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mLogPanel.deleteFilter();
- }
- });
-
-
- new ToolItem(toolBar, SWT.SEPARATOR);
-
- LogLevel[] levels = LogLevel.values();
- mLogLevelActions = new ToolItemAction[mLogLevelIcons.length];
- for (int i = 0 ; i < mLogLevelActions.length; i++) {
- String name = levels[i].getStringValue();
- final ToolItemAction newAction = new ToolItemAction(toolBar, SWT.CHECK);
- mLogLevelActions[i] = newAction;
- //newAction.item.setText(name);
- newAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // disable the other actions and record current index
- for (int k = 0 ; k < mLogLevelActions.length; k++) {
- ToolItemAction a = mLogLevelActions[k];
- if (a == newAction) {
- a.setChecked(true);
-
- // set the log level
- mLogPanel.setCurrentFilterLogLevel(k+2);
- } else {
- a.setChecked(false);
- }
- }
- }
- });
-
- newAction.item.setToolTipText(name);
- newAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay,
- mLogLevelIcons[i],
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- }
-
- new ToolItem(toolBar, SWT.SEPARATOR);
-
- mClearAction = new ToolItemAction(toolBar, SWT.PUSH);
- mClearAction.item.setToolTipText("Clear Log");
-
- mClearAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay,
- "clear.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mClearAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mLogPanel.clear();
- }
- });
-
- new ToolItem(toolBar, SWT.SEPARATOR);
-
- mExportAction = new ToolItemAction(toolBar, SWT.PUSH);
- mExportAction.item.setToolTipText("Export Selection As Text...");
- mExportAction.item.setImage(mDdmUiLibLoader.loadImage(mDisplay,
- "save.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
- mExportAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mLogPanel.save();
- }
- });
-
-
- toolBar.pack();
-
- // now create the log view
- mLogPanel = new LogPanel(colors, new FilterStorage(), LogPanel.FILTER_MANUAL);
-
- mLogPanel.setActions(mDeleteFilterAction, mEditFilterAction, mLogLevelActions);
-
- String colMode = prefs.getString(PrefsDialog.LOGCAT_COLUMN_MODE);
- if (PrefsDialog.LOGCAT_COLUMN_MODE_AUTO.equals(colMode)) {
- mLogPanel.setColumnMode(LogPanel.COLUMN_MODE_AUTO);
- }
-
- String fontStr = PrefsDialog.getStore().getString(PrefsDialog.LOGCAT_FONT);
- if (fontStr != null) {
- try {
- FontData fdat = new FontData(fontStr);
- mLogPanel.setFont(new Font(display, fdat));
- } catch (IllegalArgumentException e) {
- // Looks like fontStr isn't a valid font representation.
- // We do nothing in this case, the logcat view will use the default font.
- } catch (SWTError e2) {
- // Looks like the Font() constructor failed.
- // We do nothing in this case, the logcat view will use the default font.
- }
- }
-
- mLogPanel.createPanel(comp);
-
- // and start the logcat
- mLogPanel.startLogCat(mCurrentDevice);
- }
-
- private void createLogCatView(Composite parent) {
- IPreferenceStore prefStore = DdmUiPreferences.getStore();
- mLogCatPanel = new LogCatPanel(prefStore);
- mLogCatPanel.createPanel(parent);
-
- if (mCurrentDevice != null) {
- mLogCatPanel.deviceSelected(mCurrentDevice);
- }
- }
-
- /*
- * Create the contents of the left panel: a table of VMs.
- */
- private void createLeftPanel(final Composite comp) {
- comp.setLayout(new GridLayout(1, false));
- ToolBar toolBar = new ToolBar(comp, SWT.HORIZONTAL | SWT.RIGHT | SWT.WRAP);
- toolBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- createDevicePanelToolBar(toolBar);
-
- Composite c = new Composite(comp, SWT.NONE);
- c.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- mDevicePanel = new DevicePanel(true /* showPorts */);
- mDevicePanel.createPanel(c);
-
- // add ourselves to the device panel selection listener
- mDevicePanel.addSelectionListener(this);
- }
-
- /*
- * Create the contents of the right panel: tabs with VM information.
- */
- private void createRightPanel(final Composite comp) {
- TabItem item;
- TabFolder tabFolder;
-
- comp.setLayout(new FillLayout());
-
- tabFolder = new TabFolder(comp, SWT.NONE);
-
- for (int i = 0; i < mPanels.length; i++) {
- if (mPanels[i] != null) {
- item = new TabItem(tabFolder, SWT.NONE);
- item.setText(mPanelNames[i]);
- item.setToolTipText(mPanelTips[i]);
- item.setControl(mPanels[i].createPanel(tabFolder));
- }
- }
-
- // add the emulator control panel to the folders.
- item = new TabItem(tabFolder, SWT.NONE);
- item.setText("Emulator Control");
- item.setToolTipText("Emulator Control Panel");
- mEmulatorPanel = new EmulatorControlPanel();
- item.setControl(mEmulatorPanel.createPanel(tabFolder));
-
- // add the event log panel to the folders.
- item = new TabItem(tabFolder, SWT.NONE);
- item.setText("Event Log");
- item.setToolTipText("Event Log");
-
- // create the composite that will hold the toolbar and the event log panel.
- Composite eventLogTopComposite = new Composite(tabFolder, SWT.NONE);
- item.setControl(eventLogTopComposite);
- eventLogTopComposite.setLayout(new GridLayout(1, false));
-
- // create the toolbar and the actions
- ToolBar toolbar = new ToolBar(eventLogTopComposite, SWT.HORIZONTAL);
- toolbar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- ToolItemAction optionsAction = new ToolItemAction(toolbar, SWT.PUSH);
- optionsAction.item.setToolTipText("Opens the options panel");
- optionsAction.item.setImage(mDdmUiLibLoader.loadImage(comp.getDisplay(),
- "edit.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
-
- ToolItemAction clearAction = new ToolItemAction(toolbar, SWT.PUSH);
- clearAction.item.setToolTipText("Clears the event log");
- clearAction.item.setImage(mDdmUiLibLoader.loadImage(comp.getDisplay(),
- "clear.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
-
- new ToolItem(toolbar, SWT.SEPARATOR);
-
- ToolItemAction saveAction = new ToolItemAction(toolbar, SWT.PUSH);
- saveAction.item.setToolTipText("Saves the event log");
- saveAction.item.setImage(mDdmUiLibLoader.loadImage(comp.getDisplay(),
- "save.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
-
- ToolItemAction loadAction = new ToolItemAction(toolbar, SWT.PUSH);
- loadAction.item.setToolTipText("Loads an event log");
- loadAction.item.setImage(mDdmUiLibLoader.loadImage(comp.getDisplay(),
- "load.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
-
- ToolItemAction importBugAction = new ToolItemAction(toolbar, SWT.PUSH);
- importBugAction.item.setToolTipText("Imports a bug report");
- importBugAction.item.setImage(mDdmUiLibLoader.loadImage(comp.getDisplay(),
- "importBug.png", //$NON-NLS-1$
- DevicePanel.ICON_WIDTH, DevicePanel.ICON_WIDTH, null));
-
- // create the event log panel
- mEventLogPanel = new EventLogPanel();
-
- // set the external actions
- mEventLogPanel.setActions(optionsAction, clearAction, saveAction, loadAction,
- importBugAction);
-
- // create the panel
- mEventLogPanel.createPanel(eventLogTopComposite);
- }
-
- private void createFileExplorer() {
- if (mExplorer == null) {
- mExplorerShell = new Shell(mDisplay);
-
- // create the ui
- mExplorerShell.setLayout(new GridLayout(1, false));
-
- // toolbar + action
- ToolBar toolBar = new ToolBar(mExplorerShell, SWT.HORIZONTAL);
- toolBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- ToolItemAction pullAction = new ToolItemAction(toolBar, SWT.PUSH);
- pullAction.item.setToolTipText("Pull File from Device");
- Image image = mDdmUiLibLoader.loadImage("pull.png", mDisplay); //$NON-NLS-1$
- if (image != null) {
- pullAction.item.setImage(image);
- } else {
- // this is for debugging purpose when the icon is missing
- pullAction.item.setText("Pull"); //$NON-NLS-1$
- }
-
- ToolItemAction pushAction = new ToolItemAction(toolBar, SWT.PUSH);
- pushAction.item.setToolTipText("Push file onto Device");
- image = mDdmUiLibLoader.loadImage("push.png", mDisplay); //$NON-NLS-1$
- if (image != null) {
- pushAction.item.setImage(image);
- } else {
- // this is for debugging purpose when the icon is missing
- pushAction.item.setText("Push"); //$NON-NLS-1$
- }
-
- ToolItemAction deleteAction = new ToolItemAction(toolBar, SWT.PUSH);
- deleteAction.item.setToolTipText("Delete");
- image = mDdmUiLibLoader.loadImage("delete.png", mDisplay); //$NON-NLS-1$
- if (image != null) {
- deleteAction.item.setImage(image);
- } else {
- // this is for debugging purpose when the icon is missing
- deleteAction.item.setText("Delete"); //$NON-NLS-1$
- }
-
- ToolItemAction createNewFolderAction = new ToolItemAction(toolBar, SWT.PUSH);
- createNewFolderAction.item.setToolTipText("New Folder");
- image = mDdmUiLibLoader.loadImage("add.png", mDisplay); //$NON-NLS-1$
- if (image != null) {
- createNewFolderAction.item.setImage(image);
- } else {
- // this is for debugging purpose when the icon is missing
- createNewFolderAction.item.setText("New Folder"); //$NON-NLS-1$
- }
-
- // device explorer
- mExplorer = new DeviceExplorer();
- mExplorer.setActions(pushAction, pullAction, deleteAction, createNewFolderAction);
-
- pullAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mExplorer.pullSelection();
- }
- });
- pullAction.setEnabled(false);
-
- pushAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mExplorer.pushIntoSelection();
- }
- });
- pushAction.setEnabled(false);
-
- deleteAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mExplorer.deleteSelection();
- }
- });
- deleteAction.setEnabled(false);
-
- createNewFolderAction.item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mExplorer.createNewFolderInSelection();
- }
- });
- createNewFolderAction.setEnabled(false);
-
- Composite parent = new Composite(mExplorerShell, SWT.NONE);
- parent.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- mExplorer.createPanel(parent);
- mExplorer.switchDevice(mCurrentDevice);
-
- mExplorerShell.addShellListener(new ShellListener() {
- @Override
- public void shellActivated(ShellEvent e) {
- // pass
- }
-
- @Override
- public void shellClosed(ShellEvent e) {
- mExplorer = null;
- mExplorerShell = null;
- }
-
- @Override
- public void shellDeactivated(ShellEvent e) {
- // pass
- }
-
- @Override
- public void shellDeiconified(ShellEvent e) {
- // pass
- }
-
- @Override
- public void shellIconified(ShellEvent e) {
- // pass
- }
- });
-
- mExplorerShell.pack();
- setExplorerSizeAndPosition(mExplorerShell);
- mExplorerShell.open();
- } else {
- if (mExplorerShell != null) {
- mExplorerShell.forceActive();
- }
- }
- }
-
- /**
- * Set the status line. TODO: make this a stack, so we can safely have
- * multiple things trying to set it all at once. Also specify an expiration?
- */
- public void setStatusLine(final String str) {
- try {
- mDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- doSetStatusLine(str);
- }
- });
- } catch (SWTException swte) {
- if (!mDisplay.isDisposed())
- throw swte;
- }
- }
-
- private void doSetStatusLine(String str) {
- if (mStatusLine.isDisposed())
- return;
-
- if (!mStatusLine.getText().equals(str)) {
- mStatusLine.setText(str);
-
- // try { Thread.sleep(100); }
- // catch (InterruptedException ie) {}
- }
- }
-
- public void displayError(final String msg) {
- try {
- mDisplay.syncExec(new Runnable() {
- @Override
- public void run() {
- MessageDialog.openError(mDisplay.getActiveShell(), "Error",
- msg);
- }
- });
- } catch (SWTException swte) {
- if (!mDisplay.isDisposed())
- throw swte;
- }
- }
-
- private void enableButtons() {
- if (mCurrentClient != null) {
- mTBShowThreadUpdates.setSelection(mCurrentClient.isThreadUpdateEnabled());
- mTBShowThreadUpdates.setEnabled(true);
- mTBShowHeapUpdates.setSelection(mCurrentClient.isHeapUpdateEnabled());
- mTBShowHeapUpdates.setEnabled(true);
- mTBHalt.setEnabled(true);
- mTBCauseGc.setEnabled(true);
-
- ClientData data = mCurrentClient.getClientData();
-
- if (data.hasFeature(ClientData.FEATURE_HPROF)) {
- mTBDumpHprof.setEnabled(data.hasPendingHprofDump() == false);
- mTBDumpHprof.setToolTipText("Dump HPROF file");
- } else {
- mTBDumpHprof.setEnabled(false);
- mTBDumpHprof.setToolTipText("Dump HPROF file (not supported by this VM)");
- }
-
- if (data.hasFeature(ClientData.FEATURE_PROFILING)) {
- mTBProfiling.setEnabled(true);
- if (data.getMethodProfilingStatus() == MethodProfilingStatus.ON) {
- mTBProfiling.setToolTipText("Stop Method Profiling");
- mTBProfiling.setImage(mTracingStopImage);
- } else {
- mTBProfiling.setToolTipText("Start Method Profiling");
- mTBProfiling.setImage(mTracingStartImage);
- }
- } else {
- mTBProfiling.setEnabled(false);
- mTBProfiling.setImage(mTracingStartImage);
- mTBProfiling.setToolTipText("Start Method Profiling (not supported by this VM)");
- }
- } else {
- // list is empty, disable these
- mTBShowThreadUpdates.setSelection(false);
- mTBShowThreadUpdates.setEnabled(false);
- mTBShowHeapUpdates.setSelection(false);
- mTBShowHeapUpdates.setEnabled(false);
- mTBHalt.setEnabled(false);
- mTBCauseGc.setEnabled(false);
-
- mTBDumpHprof.setEnabled(false);
- mTBDumpHprof.setToolTipText("Dump HPROF file");
-
- mTBProfiling.setEnabled(false);
- mTBProfiling.setImage(mTracingStartImage);
- mTBProfiling.setToolTipText("Start Method Profiling");
- }
- }
-
- /**
- * Sent when a new {@link IDevice} and {@link Client} are selected.
- * @param selectedDevice the selected device. If null, no devices are selected.
- * @param selectedClient The selected client. If null, no clients are selected.
- *
- * @see IUiSelectionListener
- */
- @Override
- public void selectionChanged(IDevice selectedDevice, Client selectedClient) {
- if (mCurrentDevice != selectedDevice) {
- mCurrentDevice = selectedDevice;
- for (TablePanel panel : mPanels) {
- if (panel != null) {
- panel.deviceSelected(mCurrentDevice);
- }
- }
-
- mEmulatorPanel.deviceSelected(mCurrentDevice);
- if (useOldLogCatView()) {
- mLogPanel.deviceSelected(mCurrentDevice);
- } else {
- mLogCatPanel.deviceSelected(mCurrentDevice);
- }
- if (mEventLogPanel != null) {
- mEventLogPanel.deviceSelected(mCurrentDevice);
- }
-
- if (mExplorer != null) {
- mExplorer.switchDevice(mCurrentDevice);
- }
- }
-
- if (mCurrentClient != selectedClient) {
- AndroidDebugBridge.getBridge().setSelectedClient(selectedClient);
- mCurrentClient = selectedClient;
- for (TablePanel panel : mPanels) {
- if (panel != null) {
- panel.clientSelected(mCurrentClient);
- }
- }
-
- enableButtons();
- }
- }
-
- @Override
- public void clientChanged(Client client, int changeMask) {
- if ((changeMask & Client.CHANGE_METHOD_PROFILING_STATUS) ==
- Client.CHANGE_METHOD_PROFILING_STATUS) {
- if (mCurrentClient == client) {
- mDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- // force refresh of the button enabled state.
- enableButtons();
- }
- });
- }
- }
- }
-}
diff --git a/ddms/app/src/images/ddms-128.png b/ddms/app/src/images/ddms-128.png
deleted file mode 100644
index 392a8f3..0000000
--- a/ddms/app/src/images/ddms-128.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/Android.mk b/ddms/libs/Android.mk
deleted file mode 100644
index c62c6d0..0000000
--- a/ddms/libs/Android.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2007 The Android Open Source Project
-#
-DDMSLIBS_LOCAL_DIR := $(call my-dir)
-include $(DDMSLIBS_LOCAL_DIR)/ddmlib/Android.mk
-include $(DDMSLIBS_LOCAL_DIR)/ddmuilib/Android.mk
diff --git a/ddms/libs/ddmlib/.classpath b/ddms/libs/ddmlib/.classpath
deleted file mode 100644
index ebdb5af..0000000
--- a/ddms/libs/ddmlib/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry excluding="Android.mk" kind="src" path="src/main/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry exported="true" kind="var" path="ANDROID_SRC/prebuilts/misc/common/kxml2/kxml2-2.3.0.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/ddms/libs/ddmlib/.project b/ddms/libs/ddmlib/.project
deleted file mode 100644
index fea25c7..0000000
--- a/ddms/libs/ddmlib/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>ddmlib</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/ddms/libs/ddmlib/.settings/org.eclipse.jdt.core.prefs b/ddms/libs/ddmlib/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/ddms/libs/ddmlib/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/ddms/libs/ddmlib/Android.mk b/ddms/libs/ddmlib/Android.mk
deleted file mode 100644
index 74ee46a..0000000
--- a/ddms/libs/ddmlib/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# The ddmlib source has moved to tools/base/ddmlib.
-# The rule below uses the prebuilt ddmlib.jar if found.
-#
-# If you want to run the tests, cd to tools/base/ddmlib
-# and run ./gradlew :ddmlib:test
-
-LOCAL_MODULE := ddmlib
-LOCAL_MODULE_TAGS := optional
-LOCAL_JAVA_LIBRARIES := kxml2-2.3.0
-
-LOCAL_PREBUILT_JAVA_LIBRARIES := \
- ../../../../prebuilts/devtools/tools/lib/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/ddms/libs/ddmlib/NOTICE b/ddms/libs/ddmlib/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/ddms/libs/ddmlib/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/ddms/libs/ddmuilib/.classpath b/ddms/libs/ddmuilib/.classpath
deleted file mode 100644
index e2e92e6..0000000
--- a/ddms/libs/ddmuilib/.classpath
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/swt.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.core.commands_3.6.0.I20100512-1500.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.equinox.common_3.6.0.v20100503.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.jface_3.6.2.M20110210-1200.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/jfreechart/jcommon-1.0.12.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/jfreechart/jfreechart-1.0.9-swt.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/jfreechart/jfreechart-1.0.9.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src.zip"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/ddms/libs/ddmuilib/.project b/ddms/libs/ddmuilib/.project
deleted file mode 100644
index 29cb2f2..0000000
--- a/ddms/libs/ddmuilib/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>ddmuilib</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/ddms/libs/ddmuilib/.settings/org.eclipse.jdt.core.prefs b/ddms/libs/ddmuilib/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/ddms/libs/ddmuilib/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/ddms/libs/ddmuilib/Android.mk b/ddms/libs/ddmuilib/Android.mk
deleted file mode 100644
index 22eb2e6..0000000
--- a/ddms/libs/ddmuilib/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2007 The Android Open Source Project
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# Only compile source java files in this lib.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_RESOURCE_DIRS := src
-
-LOCAL_JAR_MANIFEST := etc/manifest.txt
-
-# If the dependency list is changed, etc/manifest.txt
-# MUST be updated as well (Except for swt.jar which is dynamically
-# added based on whether the VM is 32 or 64 bit)
-LOCAL_JAVA_LIBRARIES := \
- ddmlib \
- swt \
- org.eclipse.jface_3.6.2.M20110210-1200 \
- org.eclipse.equinox.common_3.6.0.v20100503 \
- org.eclipse.core.commands_3.6.0.I20100512-1500 \
- jcommon-1.0.12 \
- jfreechart-1.0.9 \
- jfreechart-1.0.9-swt \
- guava-tools
-
-LOCAL_MODULE := ddmuilib
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-# Build all sub-directories
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/ddms/libs/ddmuilib/NOTICE b/ddms/libs/ddmuilib/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/ddms/libs/ddmuilib/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/ddms/libs/ddmuilib/README b/ddms/libs/ddmuilib/README
deleted file mode 100644
index 971e211..0000000
--- a/ddms/libs/ddmuilib/README
+++ /dev/null
@@ -1,14 +0,0 @@
-Using the Eclipse projects for ddmuilib.
-
-ddmuilib requires SWT to compile.
-
-SWT is available in the depot under prebuild/<platform>/swt
-
-Because the build path cannot contain relative path that are not inside the project directory,
-the .classpath file references a user library called ANDROID_SWT.
-
-In order to compile the project, make a user library called ANDROID_SWT containing the jar files
-available at prebuild/<platform>/swt.
-
-You also need a user library called ANDROID_JFREECHART containing the jar files
-available at prebuild/common/jfreechart.
diff --git a/ddms/libs/ddmuilib/etc/manifest.txt b/ddms/libs/ddmuilib/etc/manifest.txt
deleted file mode 100644
index f222c61..0000000
--- a/ddms/libs/ddmuilib/etc/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Class-Path: ddmlib.jar org.eclipse.jface_3.6.2.M20110210-1200.jar org.eclipse.equinox.common_3.6.0.v20100503.jar org.eclipse.core.commands_3.6.0.I20100512-1500.jar jcommon-1.0.12.jar jfreechart-1.0.9.jar jfreechart-1.0.9-swt.jar guava-13.0.1.jar
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/AbstractBufferFindTarget.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/AbstractBufferFindTarget.java
deleted file mode 100644
index 13a787a..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/AbstractBufferFindTarget.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import java.util.regex.Pattern;
-
-/**
- * {@link AbstractBufferFindTarget} implements methods to find items inside a buffer. It takes
- * care of the logic to search backwards/forwards in the buffer, wrapping around when necessary.
- * The actual contents of the buffer should be provided by the classes that extend this.
- */
-public abstract class AbstractBufferFindTarget implements IFindTarget {
- private int mCurrentSearchIndex;
-
- // Single element cache of the last search regex
- private Pattern mLastSearchPattern;
- private String mLastSearchText;
-
- @Override
- public boolean findAndSelect(String text, boolean isNewSearch, boolean searchForward) {
- boolean found = false;
- int maxIndex = getItemCount();
-
- synchronized (this) {
- // Find starting index for this search
- if (isNewSearch) {
- // for new searches, start from an appropriate place as provided by the delegate
- mCurrentSearchIndex = getStartingIndex();
- } else {
- // for ongoing searches (finding next match for the same term), continue from
- // the current result index
- mCurrentSearchIndex = getNext(mCurrentSearchIndex, searchForward, maxIndex);
- }
-
- // Create a regex pattern based on the search term.
- Pattern pattern;
- if (text.equals(mLastSearchText)) {
- pattern = mLastSearchPattern;
- } else {
- pattern = Pattern.compile(text, Pattern.CASE_INSENSITIVE);
- mLastSearchPattern = pattern;
- mLastSearchText = text;
- }
-
- // Iterate through the list of items. The search ends if we have gone through
- // all items once.
- int index = mCurrentSearchIndex;
- do {
- String msgText = getItem(mCurrentSearchIndex);
- if (msgText != null && pattern.matcher(msgText).find()) {
- found = true;
- break;
- }
-
- mCurrentSearchIndex = getNext(mCurrentSearchIndex, searchForward, maxIndex);
- } while (index != mCurrentSearchIndex); // loop through entire contents once
- }
-
- if (found) {
- selectAndReveal(mCurrentSearchIndex);
- }
-
- return found;
- }
-
- /** Indicate that the log buffer has scrolled by certain number of elements */
- public void scrollBy(int delta) {
- synchronized (this) {
- if (mCurrentSearchIndex > 0) {
- mCurrentSearchIndex = Math.max(0, mCurrentSearchIndex - delta);
- }
- }
- }
-
- private int getNext(int index, boolean searchForward, int max) {
- // increment or decrement index
- index = searchForward ? index + 1 : index - 1;
-
- // take care of underflow
- if (index == -1) {
- index = max - 1;
- }
-
- // ..and overflow
- if (index == max) {
- index = 0;
- }
-
- return index;
- }
-
- /** Obtain the number of items in the buffer */
- public abstract int getItemCount();
-
- /** Obtain the item at given index */
- public abstract String getItem(int index);
-
- /** Select and reveal the item at given index */
- public abstract void selectAndReveal(int index);
-
- /** Obtain the index from which search should begin */
- public abstract int getStartingIndex();
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/Addr2Line.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/Addr2Line.java
deleted file mode 100644
index 10799ec..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/Addr2Line.java
+++ /dev/null
@@ -1,355 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.Log;
-import com.android.ddmlib.NativeLibraryMapInfo;
-import com.android.ddmlib.NativeStackCallInfo;
-
-import java.io.BufferedOutputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-
-/**
- * Represents an addr2line process to get filename/method information from a
- * memory address.<br>
- * Each process can only handle one library, which should be provided when
- * creating a new process.<br>
- * <br>
- * The processes take some time to load as they need to parse the library files.
- * For this reason, processes cannot be manually started. Instead the class
- * keeps an internal list of processes and one asks for a process for a specific
- * library, using <code>getProcess(String library)<code>.<br></br>
- * Internally, the processes are started in pipe mode to be able to query them
- * with multiple addresses.
- */
-public class Addr2Line {
- private static final String ANDROID_SYMBOLS_ENVVAR = "ANDROID_SYMBOLS";
-
- private static final String LIBRARY_NOT_FOUND_MESSAGE_FORMAT =
- "Unable to locate library %s on disk. Addresses mapping to this library "
- + "will not be resolved. In order to fix this, set the the library search path "
- + "in the UI, or set the environment variable " + ANDROID_SYMBOLS_ENVVAR + ".";
-
- /**
- * Loaded processes list. This is also used as a locking object for any
- * methods dealing with starting/stopping/creating processes/querying for
- * method.
- */
- private static final HashMap<String, Addr2Line> sProcessCache =
- new HashMap<String, Addr2Line>();
-
- /**
- * byte array representing a carriage return. Used to push addresses in the
- * process pipes.
- */
- private static final byte[] sCrLf = {
- '\n'
- };
-
- /** Path to the library */
- private NativeLibraryMapInfo mLibrary;
-
- /** the command line process */
- private Process mProcess;
-
- /** buffer to read the result of the command line process from */
- private BufferedReader mResultReader;
-
- /**
- * output stream to provide new addresses to decode to the command line
- * process
- */
- private BufferedOutputStream mAddressWriter;
-
- private static final String DEFAULT_LIBRARY_SYMBOLS_FOLDER;
- static {
- String symbols = System.getenv(ANDROID_SYMBOLS_ENVVAR);
- if (symbols == null) {
- DEFAULT_LIBRARY_SYMBOLS_FOLDER = DdmUiPreferences.getSymbolDirectory();
- } else {
- DEFAULT_LIBRARY_SYMBOLS_FOLDER = symbols;
- }
- }
-
- private static List<String> mLibrarySearchPaths = new ArrayList<String>();
-
- /**
- * Set the search path where libraries should be found.
- * @param path search path to use, can be a colon separated list of paths if multiple folders
- * should be searched
- */
- public static void setSearchPath(String path) {
- mLibrarySearchPaths.clear();
- mLibrarySearchPaths.addAll(Arrays.asList(path.split(":")));
- }
-
- /**
- * Returns the instance of a Addr2Line process for the specified library.
- * <br>The library should be in a format that makes<br>
- * <code>$ANDROID_PRODUCT_OUT + "/symbols" + library</code> a valid file.
- *
- * @param library the library in which to look for addresses.
- * @return a new Addr2Line object representing a started process, ready to
- * be queried for addresses. If any error happened when launching a
- * new process, <code>null</code> will be returned.
- */
- public static Addr2Line getProcess(final NativeLibraryMapInfo library) {
- String libName = library.getLibraryName();
-
- // synchronize around the hashmap object
- if (libName != null) {
- synchronized (sProcessCache) {
- // look for an existing process
- Addr2Line process = sProcessCache.get(libName);
-
- // if we don't find one, we create it
- if (process == null) {
- process = new Addr2Line(library);
-
- // then we start it
- boolean status = process.start();
-
- if (status) {
- // if starting the process worked, then we add it to the
- // list.
- sProcessCache.put(libName, process);
- } else {
- // otherwise we just drop the object, to return null
- process = null;
- }
- }
- // return the process
- return process;
- }
- }
- return null;
- }
-
- /**
- * Construct the object with a library name. The library should be present
- * in the search path as provided by ANDROID_SYMBOLS, ANDROID_OUT/symbols, or in the user
- * provided search path.
- *
- * @param library the library in which to look for address.
- */
- private Addr2Line(final NativeLibraryMapInfo library) {
- mLibrary = library;
- }
-
- /**
- * Search for the library in the library search path and obtain the full path to where it
- * is found.
- * @return fully resolved path to the library if found in search path, null otherwise
- */
- private String getLibraryPath(String library) {
- // first check the symbols folder
- String path = DEFAULT_LIBRARY_SYMBOLS_FOLDER + library;
- if (new File(path).exists()) {
- return path;
- }
-
- for (String p : mLibrarySearchPaths) {
- // try appending the full path on device
- String fullPath = p + "/" + library;
- if (new File(fullPath).exists()) {
- return fullPath;
- }
-
- // try appending basename(library)
- fullPath = p + "/" + new File(library).getName();
- if (new File(fullPath).exists()) {
- return fullPath;
- }
- }
-
- return null;
- }
-
- /**
- * Starts the command line process.
- *
- * @return true if the process was started, false if it failed to start, or
- * if there was any other errors.
- */
- private boolean start() {
- // because this is only called from getProcess() we know we don't need
- // to synchronize this code.
-
- String addr2Line = System.getenv("ANDROID_ADDR2LINE");
- if (addr2Line == null) {
- addr2Line = DdmUiPreferences.getAddr2Line();
- }
-
- // build the command line
- String[] command = new String[5];
- command[0] = addr2Line;
- command[1] = "-C";
- command[2] = "-f";
- command[3] = "-e";
-
- String fullPath = getLibraryPath(mLibrary.getLibraryName());
- if (fullPath == null) {
- String msg = String.format(LIBRARY_NOT_FOUND_MESSAGE_FORMAT, mLibrary.getLibraryName());
- Log.e("ddm-Addr2Line", msg);
- return false;
- }
-
- command[4] = fullPath;
-
- try {
- // attempt to start the process
- mProcess = Runtime.getRuntime().exec(command);
-
- if (mProcess != null) {
- // get the result reader
- InputStreamReader is = new InputStreamReader(mProcess
- .getInputStream());
- mResultReader = new BufferedReader(is);
-
- // get the outstream to write the addresses
- mAddressWriter = new BufferedOutputStream(mProcess
- .getOutputStream());
-
- // check our streams are here
- if (mResultReader == null || mAddressWriter == null) {
- // not here? stop the process and return false;
- mProcess.destroy();
- mProcess = null;
- return false;
- }
-
- // return a success
- return true;
- }
-
- } catch (IOException e) {
- // log the error
- String msg = String.format(
- "Error while trying to start %1$s process for library %2$s",
- DdmUiPreferences.getAddr2Line(), mLibrary);
- Log.e("ddm-Addr2Line", msg);
-
- // drop the process just in case
- if (mProcess != null) {
- mProcess.destroy();
- mProcess = null;
- }
- }
-
- // we can be here either cause the allocation of mProcess failed, or we
- // caught an exception
- return false;
- }
-
- /**
- * Stops the command line process.
- */
- public void stop() {
- synchronized (sProcessCache) {
- if (mProcess != null) {
- // remove the process from the list
- sProcessCache.remove(mLibrary);
-
- // then stops the process
- mProcess.destroy();
-
- // set the reference to null.
- // this allows to make sure another thread calling getAddress()
- // will not query a stopped thread
- mProcess = null;
- }
- }
- }
-
- /**
- * Stops all current running processes.
- */
- public static void stopAll() {
- // because of concurrent access (and our use of HashMap.values()), we
- // can't rely on the synchronized inside stop(). We need to put one
- // around the whole loop.
- synchronized (sProcessCache) {
- // just a basic loop on all the values in the hashmap and call to
- // stop();
- Collection<Addr2Line> col = sProcessCache.values();
- for (Addr2Line a2l : col) {
- a2l.stop();
- }
- }
- }
-
- /**
- * Looks up an address and returns method name, source file name, and line
- * number.
- *
- * @param addr the address to look up
- * @return a BacktraceInfo object containing the method/filename/linenumber
- * or null if the process we stopped before the query could be
- * processed, or if an IO exception happened.
- */
- public NativeStackCallInfo getAddress(long addr) {
- long offset = addr - mLibrary.getStartAddress();
-
- // even though we don't access the hashmap object, we need to
- // synchronized on it to prevent
- // another thread from stopping the process we're going to query.
- synchronized (sProcessCache) {
- // check the process is still alive/allocated
- if (mProcess != null) {
- // prepare to the write the address to the output buffer.
-
- // first, conversion to a string containing the hex value.
- String tmp = Long.toString(offset, 16);
-
- try {
- // write the address to the buffer
- mAddressWriter.write(tmp.getBytes());
-
- // add CR-LF
- mAddressWriter.write(sCrLf);
-
- // flush it all.
- mAddressWriter.flush();
-
- // read the result. We need to read 2 lines
- String method = mResultReader.readLine();
- String source = mResultReader.readLine();
-
- // make the backtrace object and return it
- if (method != null && source != null) {
- return new NativeStackCallInfo(addr, mLibrary.getLibraryName(), method, source);
- }
- } catch (IOException e) {
- // log the error
- Log.e("ddms",
- "Error while trying to get information for addr: "
- + tmp + " in library: " + mLibrary);
- // we'll return null later
- }
- }
- }
- return null;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/AllocationPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/AllocationPanel.java
deleted file mode 100644
index a48f73d..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/AllocationPanel.java
+++ /dev/null
@@ -1,651 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.AllocationInfo;
-import com.android.ddmlib.AllocationInfo.AllocationSorter;
-import com.android.ddmlib.AllocationInfo.SortMode;
-import com.android.ddmlib.AndroidDebugBridge.IClientChangeListener;
-import com.android.ddmlib.Client;
-import com.android.ddmlib.ClientData.AllocationTrackingStatus;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Sash;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Text;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Locale;
-
-/**
- * Base class for our information panels.
- */
-public class AllocationPanel extends TablePanel {
-
- private final static String PREFS_ALLOC_COL_NUMBER = "allocPanel.Col00"; //$NON-NLS-1$
- private final static String PREFS_ALLOC_COL_SIZE = "allocPanel.Col0"; //$NON-NLS-1$
- private final static String PREFS_ALLOC_COL_CLASS = "allocPanel.Col1"; //$NON-NLS-1$
- private final static String PREFS_ALLOC_COL_THREAD = "allocPanel.Col2"; //$NON-NLS-1$
- private final static String PREFS_ALLOC_COL_TRACE_CLASS = "allocPanel.Col3"; //$NON-NLS-1$
- private final static String PREFS_ALLOC_COL_TRACE_METHOD = "allocPanel.Col4"; //$NON-NLS-1$
-
- private final static String PREFS_ALLOC_SASH = "allocPanel.sash"; //$NON-NLS-1$
-
- private static final String PREFS_STACK_COLUMN = "allocPanel.stack.col0"; //$NON-NLS-1$
-
- private Composite mAllocationBase;
- private Table mAllocationTable;
- private TableViewer mAllocationViewer;
-
- private StackTracePanel mStackTracePanel;
- private Table mStackTraceTable;
- private Button mEnableButton;
- private Button mRequestButton;
- private Button mTraceFilterCheck;
-
- private final AllocationSorter mSorter = new AllocationSorter();
- private TableColumn mSortColumn;
- private Image mSortUpImg;
- private Image mSortDownImg;
- private String mFilterText = null;
-
- /**
- * Content Provider to display the allocations of a client.
- * Expected input is a {@link Client} object, elements used in the table are of type
- * {@link AllocationInfo}.
- */
- private class AllocationContentProvider implements IStructuredContentProvider {
- @Override
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof Client) {
- AllocationInfo[] allocs = ((Client)inputElement).getClientData().getAllocations();
- if (allocs != null) {
- if (mFilterText != null && mFilterText.length() > 0) {
- allocs = getFilteredAllocations(allocs, mFilterText);
- }
- Arrays.sort(allocs, mSorter);
- return allocs;
- }
- }
-
- return new Object[0];
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // pass
- }
- }
-
- /**
- * A Label Provider to use with {@link AllocationContentProvider}. It expects the elements to be
- * of type {@link AllocationInfo}.
- */
- private static class AllocationLabelProvider implements ITableLabelProvider {
-
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- @Override
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof AllocationInfo) {
- AllocationInfo alloc = (AllocationInfo)element;
- switch (columnIndex) {
- case 0:
- return Integer.toString(alloc.getAllocNumber());
- case 1:
- return Integer.toString(alloc.getSize());
- case 2:
- return alloc.getAllocatedClass();
- case 3:
- return Short.toString(alloc.getThreadId());
- case 4:
- return alloc.getFirstTraceClassName();
- case 5:
- return alloc.getFirstTraceMethodName();
- }
- }
-
- return null;
- }
-
- @Override
- public void addListener(ILabelProviderListener listener) {
- // pass
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- // pass
- return false;
- }
-
- @Override
- public void removeListener(ILabelProviderListener listener) {
- // pass
- }
- }
-
- /**
- * Create our control(s).
- */
- @Override
- protected Control createControl(Composite parent) {
- final IPreferenceStore store = DdmUiPreferences.getStore();
-
- Display display = parent.getDisplay();
-
- // get some images
- mSortUpImg = ImageLoader.getDdmUiLibLoader().loadImage("sort_up.png", display);
- mSortDownImg = ImageLoader.getDdmUiLibLoader().loadImage("sort_down.png", display);
-
- // base composite for selected client with enabled thread update.
- mAllocationBase = new Composite(parent, SWT.NONE);
- mAllocationBase.setLayout(new FormLayout());
-
- // table above the sash
- Composite topParent = new Composite(mAllocationBase, SWT.NONE);
- topParent.setLayout(new GridLayout(6, false));
-
- mEnableButton = new Button(topParent, SWT.PUSH);
- mEnableButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- Client current = getCurrentClient();
- AllocationTrackingStatus status = current.getClientData().getAllocationStatus();
- if (status == AllocationTrackingStatus.ON) {
- current.enableAllocationTracker(false);
- } else {
- current.enableAllocationTracker(true);
- }
- current.requestAllocationStatus();
- }
- });
-
- mRequestButton = new Button(topParent, SWT.PUSH);
- mRequestButton.setText("Get Allocations");
- mRequestButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- getCurrentClient().requestAllocationDetails();
- }
- });
-
- setUpButtons(false /* enabled */, AllocationTrackingStatus.OFF);
-
- GridData gridData;
-
- Composite spacer = new Composite(topParent, SWT.NONE);
- spacer.setLayoutData(gridData = new GridData(GridData.FILL_HORIZONTAL));
-
- new Label(topParent, SWT.NONE).setText("Filter:");
-
- final Text filterText = new Text(topParent, SWT.BORDER);
- filterText.setLayoutData(gridData = new GridData(GridData.FILL_HORIZONTAL));
- gridData.widthHint = 200;
-
- filterText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent arg0) {
- mFilterText = filterText.getText().trim();
- mAllocationViewer.refresh();
- }
- });
-
- mTraceFilterCheck = new Button(topParent, SWT.CHECK);
- mTraceFilterCheck.setText("Inc. trace");
- mTraceFilterCheck.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- mAllocationViewer.refresh();
- }
- });
-
- mAllocationTable = new Table(topParent, SWT.MULTI | SWT.FULL_SELECTION);
- mAllocationTable.setLayoutData(gridData = new GridData(GridData.FILL_BOTH));
- gridData.horizontalSpan = 6;
- mAllocationTable.setHeaderVisible(true);
- mAllocationTable.setLinesVisible(true);
-
- final TableColumn numberCol = TableHelper.createTableColumn(
- mAllocationTable,
- "Alloc Order",
- SWT.RIGHT,
- "Alloc Order", //$NON-NLS-1$
- PREFS_ALLOC_COL_NUMBER, store);
- numberCol.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- setSortColumn(numberCol, SortMode.NUMBER);
- }
- });
-
- final TableColumn sizeCol = TableHelper.createTableColumn(
- mAllocationTable,
- "Allocation Size",
- SWT.RIGHT,
- "888", //$NON-NLS-1$
- PREFS_ALLOC_COL_SIZE, store);
- sizeCol.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- setSortColumn(sizeCol, SortMode.SIZE);
- }
- });
-
- final TableColumn classCol = TableHelper.createTableColumn(
- mAllocationTable,
- "Allocated Class",
- SWT.LEFT,
- "Allocated Class", //$NON-NLS-1$
- PREFS_ALLOC_COL_CLASS, store);
- classCol.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- setSortColumn(classCol, SortMode.CLASS);
- }
- });
-
- final TableColumn threadCol = TableHelper.createTableColumn(
- mAllocationTable,
- "Thread Id",
- SWT.LEFT,
- "999", //$NON-NLS-1$
- PREFS_ALLOC_COL_THREAD, store);
- threadCol.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- setSortColumn(threadCol, SortMode.THREAD);
- }
- });
-
- final TableColumn inClassCol = TableHelper.createTableColumn(
- mAllocationTable,
- "Allocated in",
- SWT.LEFT,
- "utime", //$NON-NLS-1$
- PREFS_ALLOC_COL_TRACE_CLASS, store);
- inClassCol.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- setSortColumn(inClassCol, SortMode.IN_CLASS);
- }
- });
-
- final TableColumn inMethodCol = TableHelper.createTableColumn(
- mAllocationTable,
- "Allocated in",
- SWT.LEFT,
- "utime", //$NON-NLS-1$
- PREFS_ALLOC_COL_TRACE_METHOD, store);
- inMethodCol.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- setSortColumn(inMethodCol, SortMode.IN_METHOD);
- }
- });
-
- // init the default sort colum
- switch (mSorter.getSortMode()) {
- case SIZE:
- mSortColumn = sizeCol;
- break;
- case CLASS:
- mSortColumn = classCol;
- break;
- case THREAD:
- mSortColumn = threadCol;
- break;
- case IN_CLASS:
- mSortColumn = inClassCol;
- break;
- case IN_METHOD:
- mSortColumn = inMethodCol;
- break;
- }
-
- mSortColumn.setImage(mSorter.isDescending() ? mSortDownImg : mSortUpImg);
-
- mAllocationViewer = new TableViewer(mAllocationTable);
- mAllocationViewer.setContentProvider(new AllocationContentProvider());
- mAllocationViewer.setLabelProvider(new AllocationLabelProvider());
-
- mAllocationViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- AllocationInfo selectedAlloc = getAllocationSelection(event.getSelection());
- updateAllocationStackTrace(selectedAlloc);
- }
- });
-
- // the separating sash
- final Sash sash = new Sash(mAllocationBase, SWT.HORIZONTAL);
- Color darkGray = parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
- sash.setBackground(darkGray);
-
- // the UI below the sash
- mStackTracePanel = new StackTracePanel();
- mStackTraceTable = mStackTracePanel.createPanel(mAllocationBase, PREFS_STACK_COLUMN, store);
-
- // now setup the sash.
- // form layout data
- FormData data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(sash, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- topParent.setLayoutData(data);
-
- final FormData sashData = new FormData();
- if (store != null && store.contains(PREFS_ALLOC_SASH)) {
- sashData.top = new FormAttachment(0, store.getInt(PREFS_ALLOC_SASH));
- } else {
- sashData.top = new FormAttachment(50,0); // 50% across
- }
- sashData.left = new FormAttachment(0, 0);
- sashData.right = new FormAttachment(100, 0);
- sash.setLayoutData(sashData);
-
- data = new FormData();
- data.top = new FormAttachment(sash, 0);
- data.bottom = new FormAttachment(100, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- mStackTraceTable.setLayoutData(data);
-
- // allow resizes, but cap at minPanelWidth
- sash.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event e) {
- Rectangle sashRect = sash.getBounds();
- Rectangle panelRect = mAllocationBase.getClientArea();
- int bottom = panelRect.height - sashRect.height - 100;
- e.y = Math.max(Math.min(e.y, bottom), 100);
- if (e.y != sashRect.y) {
- sashData.top = new FormAttachment(0, e.y);
- store.setValue(PREFS_ALLOC_SASH, e.y);
- mAllocationBase.layout();
- }
- }
- });
-
- return mAllocationBase;
- }
-
- @Override
- public void dispose() {
- mSortUpImg.dispose();
- mSortDownImg.dispose();
- super.dispose();
- }
-
- /**
- * Sets the focus to the proper control inside the panel.
- */
- @Override
- public void setFocus() {
- mAllocationTable.setFocus();
- }
-
- /**
- * Sent when an existing client information changed.
- * <p/>
- * This is sent from a non UI thread.
- * @param client the updated client.
- * @param changeMask the bit mask describing the changed properties. It can contain
- * any of the following values: {@link Client#CHANGE_INFO}, {@link Client#CHANGE_NAME}
- * {@link Client#CHANGE_DEBUGGER_STATUS}, {@link Client#CHANGE_THREAD_MODE},
- * {@link Client#CHANGE_THREAD_DATA}, {@link Client#CHANGE_HEAP_MODE},
- * {@link Client#CHANGE_HEAP_DATA}, {@link Client#CHANGE_NATIVE_HEAP_DATA}
- *
- * @see IClientChangeListener#clientChanged(Client, int)
- */
- @Override
- public void clientChanged(final Client client, int changeMask) {
- if (client == getCurrentClient()) {
- if ((changeMask & Client.CHANGE_HEAP_ALLOCATIONS) != 0) {
- try {
- mAllocationTable.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- mAllocationViewer.refresh();
- updateAllocationStackCall();
- }
- });
- } catch (SWTException e) {
- // widget is disposed, we do nothing
- }
- } else if ((changeMask & Client.CHANGE_HEAP_ALLOCATION_STATUS) != 0) {
- try {
- mAllocationTable.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- setUpButtons(true, client.getClientData().getAllocationStatus());
- }
- });
- } catch (SWTException e) {
- // widget is disposed, we do nothing
- }
- }
- }
- }
-
- /**
- * Sent when a new device is selected. The new device can be accessed
- * with {@link #getCurrentDevice()}.
- */
- @Override
- public void deviceSelected() {
- // pass
- }
-
- /**
- * Sent when a new client is selected. The new client can be accessed
- * with {@link #getCurrentClient()}.
- */
- @Override
- public void clientSelected() {
- if (mAllocationTable.isDisposed()) {
- return;
- }
-
- Client client = getCurrentClient();
-
- mStackTracePanel.setCurrentClient(client);
- mStackTracePanel.setViewerInput(null); // always empty on client selection change.
-
- if (client != null) {
- setUpButtons(true /* enabled */, client.getClientData().getAllocationStatus());
- } else {
- setUpButtons(false /* enabled */, AllocationTrackingStatus.OFF);
- }
-
- mAllocationViewer.setInput(client);
- }
-
- /**
- * Updates the stack call of the currently selected thread.
- * <p/>
- * This <b>must</b> be called from the UI thread.
- */
- private void updateAllocationStackCall() {
- Client client = getCurrentClient();
- if (client != null) {
- // get the current selection in the ThreadTable
- AllocationInfo selectedAlloc = getAllocationSelection(null);
-
- if (selectedAlloc != null) {
- updateAllocationStackTrace(selectedAlloc);
- } else {
- updateAllocationStackTrace(null);
- }
- }
- }
-
- /**
- * updates the stackcall of the specified allocation. If <code>null</code> the UI is emptied
- * of current data.
- * @param thread
- */
- private void updateAllocationStackTrace(AllocationInfo alloc) {
- mStackTracePanel.setViewerInput(alloc);
- }
-
- @Override
- protected void setTableFocusListener() {
- addTableToFocusListener(mAllocationTable);
- addTableToFocusListener(mStackTraceTable);
- }
-
- /**
- * Returns the current allocation selection or <code>null</code> if none is found.
- * If a {@link ISelection} object is specified, the first {@link AllocationInfo} from this
- * selection is returned, otherwise, the <code>ISelection</code> returned by
- * {@link TableViewer#getSelection()} is used.
- * @param selection the {@link ISelection} to use, or <code>null</code>
- */
- private AllocationInfo getAllocationSelection(ISelection selection) {
- if (selection == null) {
- selection = mAllocationViewer.getSelection();
- }
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection)selection;
- Object object = structuredSelection.getFirstElement();
- if (object instanceof AllocationInfo) {
- return (AllocationInfo)object;
- }
- }
-
- return null;
- }
-
- /**
- *
- * @param enabled
- * @param trackingStatus
- */
- private void setUpButtons(boolean enabled, AllocationTrackingStatus trackingStatus) {
- if (enabled) {
- switch (trackingStatus) {
- case UNKNOWN:
- mEnableButton.setText("?");
- mEnableButton.setEnabled(false);
- mRequestButton.setEnabled(false);
- break;
- case OFF:
- mEnableButton.setText("Start Tracking");
- mEnableButton.setEnabled(true);
- mRequestButton.setEnabled(false);
- break;
- case ON:
- mEnableButton.setText("Stop Tracking");
- mEnableButton.setEnabled(true);
- mRequestButton.setEnabled(true);
- break;
- }
- } else {
- mEnableButton.setEnabled(false);
- mRequestButton.setEnabled(false);
- mEnableButton.setText("Start Tracking");
- }
- }
-
- private void setSortColumn(final TableColumn column, SortMode sortMode) {
- // set the new sort mode
- mSorter.setSortMode(sortMode);
-
- mAllocationTable.setRedraw(false);
-
- // remove image from previous sort colum
- if (mSortColumn != column) {
- mSortColumn.setImage(null);
- }
-
- mSortColumn = column;
- if (mSorter.isDescending()) {
- mSortColumn.setImage(mSortDownImg);
- } else {
- mSortColumn.setImage(mSortUpImg);
- }
-
- mAllocationTable.setRedraw(true);
- mAllocationViewer.refresh();
- }
-
- private AllocationInfo[] getFilteredAllocations(AllocationInfo[] allocations,
- String filterText) {
- ArrayList<AllocationInfo> results = new ArrayList<AllocationInfo>();
- // Using default locale here such that the locale-specific c
- Locale locale = Locale.getDefault();
- filterText = filterText.toLowerCase(locale);
- boolean fullTrace = mTraceFilterCheck.getSelection();
-
- for (AllocationInfo info : allocations) {
- if (info.filter(filterText, fullTrace, locale)) {
- results.add(info);
- }
- }
-
- return results.toArray(new AllocationInfo[results.size()]);
- }
-
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/BackgroundThread.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/BackgroundThread.java
deleted file mode 100644
index 0ed4c95..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/BackgroundThread.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.Log;
-
-/**
- * base background thread class. The class provides a synchronous quit method
- * which sets a quitting flag to true. Inheriting classes should regularly test
- * this flag with <code>isQuitting()</code> and should finish if the flag is
- * true.
- */
-public abstract class BackgroundThread extends Thread {
- private boolean mQuit = false;
-
- /**
- * Tell the thread to exit. This is usually called from the UI thread. The
- * call is synchronous and will only return once the thread has terminated
- * itself.
- */
- public final void quit() {
- mQuit = true;
- Log.d("ddms", "Waiting for BackgroundThread to quit");
- try {
- this.join();
- } catch (InterruptedException ie) {
- ie.printStackTrace();
- }
- }
-
- /** returns if the thread was asked to quit. */
- protected final boolean isQuitting() {
- return mQuit;
- }
-
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/BaseHeapPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/BaseHeapPanel.java
deleted file mode 100644
index 3e66ea5..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/BaseHeapPanel.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.HeapSegment;
-import com.android.ddmlib.ClientData.HeapData;
-import com.android.ddmlib.HeapSegment.HeapSegmentElement;
-
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.PaletteData;
-
-import java.io.ByteArrayOutputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-
-
-/**
- * Base Panel for heap panels.
- */
-public abstract class BaseHeapPanel extends TablePanel {
-
- /** store the processed heap segment, so that we don't recompute Image for nothing */
- protected byte[] mProcessedHeapData;
- private Map<Integer, ArrayList<HeapSegmentElement>> mHeapMap;
-
- /**
- * Serialize the heap data into an array. The resulting array is available through
- * <code>getSerializedData()</code>.
- * @param heapData The heap data to serialize
- * @return true if the data changed.
- */
- protected boolean serializeHeapData(HeapData heapData) {
- Collection<HeapSegment> heapSegments;
-
- // Atomically get and clear the heap data.
- synchronized (heapData) {
- // get the segments
- heapSegments = heapData.getHeapSegments();
-
-
- if (heapSegments != null) {
- // if they are not null, we never processed them.
- // Before we process then, we drop them from the HeapData
- heapData.clearHeapData();
-
- // process them into a linear byte[]
- doSerializeHeapData(heapSegments);
- heapData.setProcessedHeapData(mProcessedHeapData);
- heapData.setProcessedHeapMap(mHeapMap);
-
- } else {
- // the heap segments are null. Let see if the heapData contains a
- // list that is already processed.
-
- byte[] pixData = heapData.getProcessedHeapData();
-
- // and compare it to the one we currently have in the panel.
- if (pixData == mProcessedHeapData) {
- // looks like its the same
- return false;
- } else {
- mProcessedHeapData = pixData;
- }
-
- Map<Integer, ArrayList<HeapSegmentElement>> heapMap =
- heapData.getProcessedHeapMap();
- mHeapMap = heapMap;
- }
- }
-
- return true;
- }
-
- /**
- * Returns the serialized heap data
- */
- protected byte[] getSerializedData() {
- return mProcessedHeapData;
- }
-
- /**
- * Processes and serialize the heapData.
- * <p/>
- * The resulting serialized array is {@link #mProcessedHeapData}.
- * <p/>
- * the resulting map is {@link #mHeapMap}.
- * @param heapData the collection of {@link HeapSegment} that forms the heap data.
- */
- private void doSerializeHeapData(Collection<HeapSegment> heapData) {
- mHeapMap = new TreeMap<Integer, ArrayList<HeapSegmentElement>>();
-
- Iterator<HeapSegment> iterator;
- ByteArrayOutputStream out;
-
- out = new ByteArrayOutputStream(4 * 1024);
-
- iterator = heapData.iterator();
- while (iterator.hasNext()) {
- HeapSegment hs = iterator.next();
-
- HeapSegmentElement e = null;
- while (true) {
- int v;
-
- e = hs.getNextElement(null);
- if (e == null) {
- break;
- }
-
- if (e.getSolidity() == HeapSegmentElement.SOLIDITY_FREE) {
- v = 1;
- } else {
- v = e.getKind() + 2;
- }
-
- // put the element in the map
- ArrayList<HeapSegmentElement> elementList = mHeapMap.get(v);
- if (elementList == null) {
- elementList = new ArrayList<HeapSegmentElement>();
- mHeapMap.put(v, elementList);
- }
- elementList.add(e);
-
-
- int len = e.getLength() / 8;
- while (len > 0) {
- out.write(v);
- --len;
- }
- }
- }
- mProcessedHeapData = out.toByteArray();
-
- // sort the segment element in the heap info.
- Collection<ArrayList<HeapSegmentElement>> elementLists = mHeapMap.values();
- for (ArrayList<HeapSegmentElement> elementList : elementLists) {
- Collections.sort(elementList);
- }
- }
-
- /**
- * Creates a linear image of the heap data.
- * @param pixData
- * @param h
- * @param palette
- * @return
- */
- protected ImageData createLinearHeapImage(byte[] pixData, int h, PaletteData palette) {
- int w = pixData.length / h;
- if (pixData.length % h != 0) {
- w++;
- }
-
- // Create the heap image.
- ImageData id = new ImageData(w, h, 8, palette);
-
- int x = 0;
- int y = 0;
- for (byte b : pixData) {
- if (b >= 0) {
- id.setPixel(x, y, b);
- }
-
- y++;
- if (y >= h) {
- y = 0;
- x++;
- }
- }
-
- return id;
- }
-
-
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/ClientDisplayPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/ClientDisplayPanel.java
deleted file mode 100644
index a711933..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/ClientDisplayPanel.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.AndroidDebugBridge;
-import com.android.ddmlib.AndroidDebugBridge.IClientChangeListener;
-
-public abstract class ClientDisplayPanel extends SelectionDependentPanel
- implements IClientChangeListener {
-
- @Override
- protected void postCreation() {
- AndroidDebugBridge.addClientChangeListener(this);
- }
-
- public void dispose() {
- AndroidDebugBridge.removeClientChangeListener(this);
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/DdmUiPreferences.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/DdmUiPreferences.java
deleted file mode 100644
index db3642b..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/DdmUiPreferences.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-/**
- * Preference entry point for ddmuilib. Allows the lib to access a preference
- * store (org.eclipse.jface.preference.IPreferenceStore) defined by the
- * application that includes the lib.
- */
-public final class DdmUiPreferences {
-
- public static final int DEFAULT_THREAD_REFRESH_INTERVAL = 4; // seconds
-
- private static int sThreadRefreshInterval = DEFAULT_THREAD_REFRESH_INTERVAL;
-
- private static IPreferenceStore mStore;
-
- private static String sSymbolLocation =""; //$NON-NLS-1$
- private static String sAddr2LineLocation =""; //$NON-NLS-1$
- private static String sTraceviewLocation =""; //$NON-NLS-1$
-
- public static void setStore(IPreferenceStore store) {
- mStore = store;
- }
-
- public static IPreferenceStore getStore() {
- return mStore;
- }
-
- public static int getThreadRefreshInterval() {
- return sThreadRefreshInterval;
- }
-
- public static void setThreadRefreshInterval(int port) {
- sThreadRefreshInterval = port;
- }
-
- public static String getSymbolDirectory() {
- return sSymbolLocation;
- }
-
- public static void setSymbolsLocation(String location) {
- sSymbolLocation = location;
- }
-
- public static String getAddr2Line() {
- return sAddr2LineLocation;
- }
-
- public static void setAddr2LineLocation(String location) {
- sAddr2LineLocation = location;
- }
-
- public static String getTraceview() {
- return sTraceviewLocation;
- }
-
- public static void setTraceviewLocation(String location) {
- sTraceviewLocation = location;
- }
-
-
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/DevicePanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/DevicePanel.java
deleted file mode 100644
index a24b8a0..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/DevicePanel.java
+++ /dev/null
@@ -1,784 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.AndroidDebugBridge;
-import com.android.ddmlib.AndroidDebugBridge.IClientChangeListener;
-import com.android.ddmlib.AndroidDebugBridge.IDebugBridgeChangeListener;
-import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
-import com.android.ddmlib.Client;
-import com.android.ddmlib.ClientData;
-import com.android.ddmlib.ClientData.DebuggerStatus;
-import com.android.ddmlib.DdmPreferences;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.IDevice.DeviceState;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreePath;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.swt.widgets.TreeItem;
-
-import java.util.ArrayList;
-import java.util.Locale;
-
-/**
- * A display of both the devices and their clients.
- */
-public final class DevicePanel extends Panel implements IDebugBridgeChangeListener,
- IDeviceChangeListener, IClientChangeListener {
-
- private final static String PREFS_COL_NAME_SERIAL = "devicePanel.Col0"; //$NON-NLS-1$
- private final static String PREFS_COL_PID_STATE = "devicePanel.Col1"; //$NON-NLS-1$
- private final static String PREFS_COL_PORT_BUILD = "devicePanel.Col4"; //$NON-NLS-1$
-
- private final static int DEVICE_COL_SERIAL = 0;
- private final static int DEVICE_COL_STATE = 1;
- // col 2, 3 not used.
- private final static int DEVICE_COL_BUILD = 4;
-
- private final static int CLIENT_COL_NAME = 0;
- private final static int CLIENT_COL_PID = 1;
- private final static int CLIENT_COL_THREAD = 2;
- private final static int CLIENT_COL_HEAP = 3;
- private final static int CLIENT_COL_PORT = 4;
-
- public final static int ICON_WIDTH = 16;
- public final static String ICON_THREAD = "thread.png"; //$NON-NLS-1$
- public final static String ICON_HEAP = "heap.png"; //$NON-NLS-1$
- public final static String ICON_HALT = "halt.png"; //$NON-NLS-1$
- public final static String ICON_GC = "gc.png"; //$NON-NLS-1$
- public final static String ICON_HPROF = "hprof.png"; //$NON-NLS-1$
- public final static String ICON_TRACING_START = "tracing_start.png"; //$NON-NLS-1$
- public final static String ICON_TRACING_STOP = "tracing_stop.png"; //$NON-NLS-1$
-
- private IDevice mCurrentDevice;
- private Client mCurrentClient;
-
- private Tree mTree;
- private TreeViewer mTreeViewer;
-
- private Image mDeviceImage;
- private Image mEmulatorImage;
-
- private Image mThreadImage;
- private Image mHeapImage;
- private Image mWaitingImage;
- private Image mDebuggerImage;
- private Image mDebugErrorImage;
-
- private final ArrayList<IUiSelectionListener> mListeners = new ArrayList<IUiSelectionListener>();
-
- private final ArrayList<IDevice> mDevicesToExpand = new ArrayList<IDevice>();
-
- private boolean mAdvancedPortSupport;
-
- /**
- * A Content provider for the {@link TreeViewer}.
- * <p/>
- * The input is a {@link AndroidDebugBridge}. First level elements are {@link IDevice} objects,
- * and second level elements are {@link Client} object.
- */
- private class ContentProvider implements ITreeContentProvider {
- @Override
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof IDevice) {
- return ((IDevice)parentElement).getClients();
- }
- return new Object[0];
- }
-
- @Override
- public Object getParent(Object element) {
- if (element instanceof Client) {
- return ((Client)element).getDevice();
- }
- return null;
- }
-
- @Override
- public boolean hasChildren(Object element) {
- if (element instanceof IDevice) {
- return ((IDevice)element).hasClients();
- }
-
- // Clients never have children.
- return false;
- }
-
- @Override
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof AndroidDebugBridge) {
- return ((AndroidDebugBridge)inputElement).getDevices();
- }
- return new Object[0];
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // pass
- }
- }
-
- /**
- * A Label Provider for the {@link TreeViewer} in {@link DevicePanel}. It provides
- * labels and images for {@link IDevice} and {@link Client} objects.
- */
- private class LabelProvider implements ITableLabelProvider {
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- if (columnIndex == DEVICE_COL_SERIAL && element instanceof IDevice) {
- IDevice device = (IDevice)element;
- if (device.isEmulator()) {
- return mEmulatorImage;
- }
-
- return mDeviceImage;
- } else if (element instanceof Client) {
- Client client = (Client)element;
- ClientData cd = client.getClientData();
-
- switch (columnIndex) {
- case CLIENT_COL_NAME:
- switch (cd.getDebuggerConnectionStatus()) {
- case DEFAULT:
- return null;
- case WAITING:
- return mWaitingImage;
- case ATTACHED:
- return mDebuggerImage;
- case ERROR:
- return mDebugErrorImage;
- }
- return null;
- case CLIENT_COL_THREAD:
- if (client.isThreadUpdateEnabled()) {
- return mThreadImage;
- }
- return null;
- case CLIENT_COL_HEAP:
- if (client.isHeapUpdateEnabled()) {
- return mHeapImage;
- }
- return null;
- }
- }
- return null;
- }
-
- @Override
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof IDevice) {
- IDevice device = (IDevice)element;
- switch (columnIndex) {
- case DEVICE_COL_SERIAL:
- return device.getName();
- case DEVICE_COL_STATE:
- return getStateString(device);
- case DEVICE_COL_BUILD: {
- String version = device.getProperty(IDevice.PROP_BUILD_VERSION);
- if (version != null) {
- String debuggable = device.getProperty(IDevice.PROP_DEBUGGABLE);
- if (device.isEmulator()) {
- String avdName = device.getAvdName();
- if (avdName == null) {
- avdName = "?"; // the device is probably not online yet, so
- // we don't know its AVD name just yet.
- }
- if (debuggable != null && debuggable.equals("1")) { //$NON-NLS-1$
- return String.format("%1$s [%2$s, debug]", avdName,
- version);
- } else {
- return String.format("%1$s [%2$s]", avdName, version); //$NON-NLS-1$
- }
- } else {
- if (debuggable != null && debuggable.equals("1")) { //$NON-NLS-1$
- return String.format("%1$s, debug", version);
- } else {
- return String.format("%1$s", version); //$NON-NLS-1$
- }
- }
- } else {
- return "unknown";
- }
- }
- }
- } else if (element instanceof Client) {
- Client client = (Client)element;
- ClientData cd = client.getClientData();
-
- switch (columnIndex) {
- case CLIENT_COL_NAME:
- String name = cd.getClientDescription();
- if (name != null) {
- if (cd.isValidUserId() && cd.getUserId() != 0) {
- return String.format(Locale.US, "%s (%d)", name, cd.getUserId());
- } else {
- return name;
- }
- }
- return "?";
- case CLIENT_COL_PID:
- return Integer.toString(cd.getPid());
- case CLIENT_COL_PORT:
- if (mAdvancedPortSupport) {
- int port = client.getDebuggerListenPort();
- String portString = "?";
- if (port != 0) {
- portString = Integer.toString(port);
- }
- if (client.isSelectedClient()) {
- return String.format("%1$s / %2$d", portString, //$NON-NLS-1$
- DdmPreferences.getSelectedDebugPort());
- }
-
- return portString;
- }
- }
- }
- return null;
- }
-
- @Override
- public void addListener(ILabelProviderListener listener) {
- // pass
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- // pass
- return false;
- }
-
- @Override
- public void removeListener(ILabelProviderListener listener) {
- // pass
- }
- }
-
- /**
- * Classes which implement this interface provide methods that deals
- * with {@link IDevice} and {@link Client} selection changes coming from the ui.
- */
- public interface IUiSelectionListener {
- /**
- * Sent when a new {@link IDevice} and {@link Client} are selected.
- * @param selectedDevice the selected device. If null, no devices are selected.
- * @param selectedClient The selected client. If null, no clients are selected.
- */
- public void selectionChanged(IDevice selectedDevice, Client selectedClient);
- }
-
- /**
- * Creates the {@link DevicePanel} object.
- * @param loader
- * @param advancedPortSupport if true the device panel will add support for selected client port
- * and display the ports in the ui.
- */
- public DevicePanel(boolean advancedPortSupport) {
- mAdvancedPortSupport = advancedPortSupport;
- }
-
- public void addSelectionListener(IUiSelectionListener listener) {
- mListeners.add(listener);
- }
-
- public void removeSelectionListener(IUiSelectionListener listener) {
- mListeners.remove(listener);
- }
-
- @Override
- protected Control createControl(Composite parent) {
- loadImages(parent.getDisplay());
-
- parent.setLayout(new FillLayout());
-
- // create the tree and its column
- mTree = new Tree(parent, SWT.SINGLE | SWT.FULL_SELECTION);
- mTree.setHeaderVisible(true);
- mTree.setLinesVisible(true);
-
- IPreferenceStore store = DdmUiPreferences.getStore();
-
- TableHelper.createTreeColumn(mTree, "Name", SWT.LEFT,
- "com.android.home", //$NON-NLS-1$
- PREFS_COL_NAME_SERIAL, store);
- TableHelper.createTreeColumn(mTree, "", SWT.LEFT, //$NON-NLS-1$
- "Offline", //$NON-NLS-1$
- PREFS_COL_PID_STATE, store);
-
- TreeColumn col = new TreeColumn(mTree, SWT.NONE);
- col.setWidth(ICON_WIDTH + 8);
- col.setResizable(false);
- col = new TreeColumn(mTree, SWT.NONE);
- col.setWidth(ICON_WIDTH + 8);
- col.setResizable(false);
-
- TableHelper.createTreeColumn(mTree, "", SWT.LEFT, //$NON-NLS-1$
- "9999-9999", //$NON-NLS-1$
- PREFS_COL_PORT_BUILD, store);
-
- // create the tree viewer
- mTreeViewer = new TreeViewer(mTree);
-
- // make the device auto expanded.
- mTreeViewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS);
-
- // set up the content and label providers.
- mTreeViewer.setContentProvider(new ContentProvider());
- mTreeViewer.setLabelProvider(new LabelProvider());
-
- mTree.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- notifyListeners();
- }
- });
-
- return mTree;
- }
-
- /**
- * Sets the focus to the proper control inside the panel.
- */
- @Override
- public void setFocus() {
- mTree.setFocus();
- }
-
- @Override
- protected void postCreation() {
- // ask for notification of changes in AndroidDebugBridge (a new one is created when
- // adb is restarted from a different location), IDevice and Client objects.
- AndroidDebugBridge.addDebugBridgeChangeListener(this);
- AndroidDebugBridge.addDeviceChangeListener(this);
- AndroidDebugBridge.addClientChangeListener(this);
- }
-
- public void dispose() {
- AndroidDebugBridge.removeDebugBridgeChangeListener(this);
- AndroidDebugBridge.removeDeviceChangeListener(this);
- AndroidDebugBridge.removeClientChangeListener(this);
- }
-
- /**
- * Returns the selected {@link Client}. May be null.
- */
- public Client getSelectedClient() {
- return mCurrentClient;
- }
-
- /**
- * Returns the selected {@link IDevice}. If a {@link Client} is selected, it returns the
- * IDevice object containing the client.
- */
- public IDevice getSelectedDevice() {
- return mCurrentDevice;
- }
-
- /**
- * Kills the selected {@link Client} by sending its VM a halt command.
- */
- public void killSelectedClient() {
- if (mCurrentClient != null) {
- Client client = mCurrentClient;
-
- // reset the selection to the device.
- TreePath treePath = new TreePath(new Object[] { mCurrentDevice });
- TreeSelection treeSelection = new TreeSelection(treePath);
- mTreeViewer.setSelection(treeSelection);
-
- client.kill();
- }
- }
-
- /**
- * Forces a GC on the selected {@link Client}.
- */
- public void forceGcOnSelectedClient() {
- if (mCurrentClient != null) {
- mCurrentClient.executeGarbageCollector();
- }
- }
-
- public void dumpHprof() {
- if (mCurrentClient != null) {
- mCurrentClient.dumpHprof();
- }
- }
-
- public void toggleMethodProfiling() {
- if (mCurrentClient != null) {
- mCurrentClient.toggleMethodProfiling();
- }
- }
-
- public void setEnabledHeapOnSelectedClient(boolean enable) {
- if (mCurrentClient != null) {
- mCurrentClient.setHeapUpdateEnabled(enable);
- }
- }
-
- public void setEnabledThreadOnSelectedClient(boolean enable) {
- if (mCurrentClient != null) {
- mCurrentClient.setThreadUpdateEnabled(enable);
- }
- }
-
- /**
- * Sent when a new {@link AndroidDebugBridge} is started.
- * <p/>
- * This is sent from a non UI thread.
- * @param bridge the new {@link AndroidDebugBridge} object.
- *
- * @see IDebugBridgeChangeListener#serverChanged(AndroidDebugBridge)
- */
- @Override
- public void bridgeChanged(final AndroidDebugBridge bridge) {
- if (mTree.isDisposed() == false) {
- exec(new Runnable() {
- @Override
- public void run() {
- if (mTree.isDisposed() == false) {
- // set up the data source.
- mTreeViewer.setInput(bridge);
-
- // notify the listener of a possible selection change.
- notifyListeners();
- } else {
- // tree is disposed, we need to do something.
- // lets remove ourselves from the listener.
- AndroidDebugBridge.removeDebugBridgeChangeListener(DevicePanel.this);
- AndroidDebugBridge.removeDeviceChangeListener(DevicePanel.this);
- AndroidDebugBridge.removeClientChangeListener(DevicePanel.this);
- }
- }
- });
- }
-
- // all current devices are obsolete
- synchronized (mDevicesToExpand) {
- mDevicesToExpand.clear();
- }
- }
-
- /**
- * Sent when the a device is connected to the {@link AndroidDebugBridge}.
- * <p/>
- * This is sent from a non UI thread.
- * @param device the new device.
- *
- * @see IDeviceChangeListener#deviceConnected(IDevice)
- */
- @Override
- public void deviceConnected(IDevice device) {
- exec(new Runnable() {
- @Override
- public void run() {
- if (mTree.isDisposed() == false) {
- // refresh all
- mTreeViewer.refresh();
-
- // notify the listener of a possible selection change.
- notifyListeners();
- } else {
- // tree is disposed, we need to do something.
- // lets remove ourselves from the listener.
- AndroidDebugBridge.removeDebugBridgeChangeListener(DevicePanel.this);
- AndroidDebugBridge.removeDeviceChangeListener(DevicePanel.this);
- AndroidDebugBridge.removeClientChangeListener(DevicePanel.this);
- }
- }
- });
-
- // if it doesn't have clients yet, it'll need to be manually expanded when it gets them.
- if (device.hasClients() == false) {
- synchronized (mDevicesToExpand) {
- mDevicesToExpand.add(device);
- }
- }
- }
-
- /**
- * Sent when the a device is connected to the {@link AndroidDebugBridge}.
- * <p/>
- * This is sent from a non UI thread.
- * @param device the new device.
- *
- * @see IDeviceChangeListener#deviceDisconnected(IDevice)
- */
- @Override
- public void deviceDisconnected(IDevice device) {
- deviceConnected(device);
-
- // just in case, we remove it from the list of devices to expand.
- synchronized (mDevicesToExpand) {
- mDevicesToExpand.remove(device);
- }
- }
-
- /**
- * Sent when a device data changed, or when clients are started/terminated on the device.
- * <p/>
- * This is sent from a non UI thread.
- * @param device the device that was updated.
- * @param changeMask the mask indicating what changed.
- *
- * @see IDeviceChangeListener#deviceChanged(IDevice)
- */
- @Override
- public void deviceChanged(final IDevice device, int changeMask) {
- boolean expand = false;
- synchronized (mDevicesToExpand) {
- int index = mDevicesToExpand.indexOf(device);
- if (device.hasClients() && index != -1) {
- mDevicesToExpand.remove(index);
- expand = true;
- }
- }
-
- final boolean finalExpand = expand;
-
- exec(new Runnable() {
- @Override
- public void run() {
- if (mTree.isDisposed() == false) {
- // look if the current device is selected. This is done in case the current
- // client of this particular device was killed. In this case, we'll need to
- // manually reselect the device.
-
- IDevice selectedDevice = getSelectedDevice();
-
- // refresh the device
- mTreeViewer.refresh(device);
-
- // if the selected device was the changed device and the new selection is
- // empty, we reselect the device.
- if (selectedDevice == device && mTreeViewer.getSelection().isEmpty()) {
- mTreeViewer.setSelection(new TreeSelection(new TreePath(
- new Object[] { device })));
- }
-
- // notify the listener of a possible selection change.
- notifyListeners();
-
- if (finalExpand) {
- mTreeViewer.setExpandedState(device, true);
- }
- } else {
- // tree is disposed, we need to do something.
- // lets remove ourselves from the listener.
- AndroidDebugBridge.removeDebugBridgeChangeListener(DevicePanel.this);
- AndroidDebugBridge.removeDeviceChangeListener(DevicePanel.this);
- AndroidDebugBridge.removeClientChangeListener(DevicePanel.this);
- }
- }
- });
- }
-
- /**
- * Sent when an existing client information changed.
- * <p/>
- * This is sent from a non UI thread.
- * @param client the updated client.
- * @param changeMask the bit mask describing the changed properties. It can contain
- * any of the following values: {@link Client#CHANGE_INFO},
- * {@link Client#CHANGE_DEBUGGER_STATUS}, {@link Client#CHANGE_THREAD_MODE},
- * {@link Client#CHANGE_THREAD_DATA}, {@link Client#CHANGE_HEAP_MODE},
- * {@link Client#CHANGE_HEAP_DATA}, {@link Client#CHANGE_NATIVE_HEAP_DATA}
- *
- * @see IClientChangeListener#clientChanged(Client, int)
- */
- @Override
- public void clientChanged(final Client client, final int changeMask) {
- exec(new Runnable() {
- @Override
- public void run() {
- if (mTree.isDisposed() == false) {
- // refresh the client
- mTreeViewer.refresh(client);
-
- if ((changeMask & Client.CHANGE_DEBUGGER_STATUS) ==
- Client.CHANGE_DEBUGGER_STATUS &&
- client.getClientData().getDebuggerConnectionStatus() ==
- DebuggerStatus.WAITING) {
- // make sure the device is expanded. Normally the setSelection below
- // will auto expand, but the children of device may not already exist
- // at this time. Forcing an expand will make the TreeViewer create them.
- IDevice device = client.getDevice();
- if (mTreeViewer.getExpandedState(device) == false) {
- mTreeViewer.setExpandedState(device, true);
- }
-
- // create and set the selection
- TreePath treePath = new TreePath(new Object[] { device, client});
- TreeSelection treeSelection = new TreeSelection(treePath);
- mTreeViewer.setSelection(treeSelection);
-
- if (mAdvancedPortSupport) {
- client.setAsSelectedClient();
- }
-
- // notify the listener of a possible selection change.
- notifyListeners(device, client);
- }
- } else {
- // tree is disposed, we need to do something.
- // lets remove ourselves from the listener.
- AndroidDebugBridge.removeDebugBridgeChangeListener(DevicePanel.this);
- AndroidDebugBridge.removeDeviceChangeListener(DevicePanel.this);
- AndroidDebugBridge.removeClientChangeListener(DevicePanel.this);
- }
- }
- });
- }
-
- private void loadImages(Display display) {
- ImageLoader loader = ImageLoader.getDdmUiLibLoader();
-
- if (mDeviceImage == null) {
- mDeviceImage = loader.loadImage(display, "device.png", //$NON-NLS-1$
- ICON_WIDTH, ICON_WIDTH,
- display.getSystemColor(SWT.COLOR_RED));
- }
- if (mEmulatorImage == null) {
- mEmulatorImage = loader.loadImage(display,
- "emulator.png", ICON_WIDTH, ICON_WIDTH, //$NON-NLS-1$
- display.getSystemColor(SWT.COLOR_BLUE));
- }
- if (mThreadImage == null) {
- mThreadImage = loader.loadImage(display, ICON_THREAD,
- ICON_WIDTH, ICON_WIDTH,
- display.getSystemColor(SWT.COLOR_YELLOW));
- }
- if (mHeapImage == null) {
- mHeapImage = loader.loadImage(display, ICON_HEAP,
- ICON_WIDTH, ICON_WIDTH,
- display.getSystemColor(SWT.COLOR_BLUE));
- }
- if (mWaitingImage == null) {
- mWaitingImage = loader.loadImage(display,
- "debug-wait.png", ICON_WIDTH, ICON_WIDTH, //$NON-NLS-1$
- display.getSystemColor(SWT.COLOR_RED));
- }
- if (mDebuggerImage == null) {
- mDebuggerImage = loader.loadImage(display,
- "debug-attach.png", ICON_WIDTH, ICON_WIDTH, //$NON-NLS-1$
- display.getSystemColor(SWT.COLOR_GREEN));
- }
- if (mDebugErrorImage == null) {
- mDebugErrorImage = loader.loadImage(display,
- "debug-error.png", ICON_WIDTH, ICON_WIDTH, //$NON-NLS-1$
- display.getSystemColor(SWT.COLOR_RED));
- }
- }
-
- /**
- * Returns a display string representing the state of the device.
- * @param d the device
- */
- private static String getStateString(IDevice d) {
- DeviceState deviceState = d.getState();
- if (deviceState == DeviceState.ONLINE) {
- return "Online";
- } else if (deviceState == DeviceState.OFFLINE) {
- return "Offline";
- } else if (deviceState == DeviceState.BOOTLOADER) {
- return "Bootloader";
- }
-
- return "??";
- }
-
- /**
- * Executes the {@link Runnable} in the UI thread.
- * @param runnable the runnable to execute.
- */
- private void exec(Runnable runnable) {
- try {
- Display display = mTree.getDisplay();
- display.asyncExec(runnable);
- } catch (SWTException e) {
- // tree is disposed, we need to do something. lets remove ourselves from the listener.
- AndroidDebugBridge.removeDebugBridgeChangeListener(this);
- AndroidDebugBridge.removeDeviceChangeListener(this);
- AndroidDebugBridge.removeClientChangeListener(this);
- }
- }
-
- private void notifyListeners() {
- // get the selection
- TreeItem[] items = mTree.getSelection();
-
- Client client = null;
- IDevice device = null;
-
- if (items.length == 1) {
- Object object = items[0].getData();
- if (object instanceof Client) {
- client = (Client)object;
- device = client.getDevice();
- } else if (object instanceof IDevice) {
- device = (IDevice)object;
- }
- }
-
- notifyListeners(device, client);
- }
-
- private void notifyListeners(IDevice selectedDevice, Client selectedClient) {
- if (selectedDevice != mCurrentDevice || selectedClient != mCurrentClient) {
- mCurrentDevice = selectedDevice;
- mCurrentClient = selectedClient;
-
- for (IUiSelectionListener listener : mListeners) {
- // notify the listener with a try/catch-all to make sure this thread won't die
- // because of an uncaught exception before all the listeners were notified.
- try {
- listener.selectionChanged(selectedDevice, selectedClient);
- } catch (Exception e) {
- }
- }
- }
- }
-
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/EmulatorControlPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/EmulatorControlPanel.java
deleted file mode 100644
index 82aed98..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/EmulatorControlPanel.java
+++ /dev/null
@@ -1,1463 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.EmulatorConsole;
-import com.android.ddmlib.EmulatorConsole.GsmMode;
-import com.android.ddmlib.EmulatorConsole.GsmStatus;
-import com.android.ddmlib.EmulatorConsole.NetworkStatus;
-import com.android.ddmlib.IDevice;
-import com.android.ddmuilib.location.CoordinateControls;
-import com.android.ddmuilib.location.GpxParser;
-import com.android.ddmuilib.location.GpxParser.Track;
-import com.android.ddmuilib.location.KmlParser;
-import com.android.ddmuilib.location.TrackContentProvider;
-import com.android.ddmuilib.location.TrackLabelProvider;
-import com.android.ddmuilib.location.TrackPoint;
-import com.android.ddmuilib.location.WayPoint;
-import com.android.ddmuilib.location.WayPointContentProvider;
-import com.android.ddmuilib.location.WayPointLabelProvider;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Panel to control the emulator using EmulatorConsole objects.
- */
-public class EmulatorControlPanel extends SelectionDependentPanel {
-
- // default location: Patio outside Charlie's
- private final static double DEFAULT_LONGITUDE = -122.084095;
- private final static double DEFAULT_LATITUDE = 37.422006;
-
- private final static String SPEED_FORMAT = "Speed: %1$dX";
-
-
- /**
- * Map between the display gsm mode and the internal tag used by the display.
- */
- private final static String[][] GSM_MODES = new String[][] {
- { "unregistered", GsmMode.UNREGISTERED.getTag() },
- { "home", GsmMode.HOME.getTag() },
- { "roaming", GsmMode.ROAMING.getTag() },
- { "searching", GsmMode.SEARCHING.getTag() },
- { "denied", GsmMode.DENIED.getTag() },
- };
-
- private final static String[] NETWORK_SPEEDS = new String[] {
- "Full",
- "GSM",
- "HSCSD",
- "GPRS",
- "EDGE",
- "UMTS",
- "HSDPA",
- };
-
- private final static String[] NETWORK_LATENCIES = new String[] {
- "None",
- "GPRS",
- "EDGE",
- "UMTS",
- };
-
- private final static int[] PLAY_SPEEDS = new int[] { 1, 2, 5, 10, 20, 50 };
-
- private final static String RE_PHONE_NUMBER = "^[+#0-9]+$"; //$NON-NLS-1$
- private final static String PREFS_WAYPOINT_COL_NAME = "emulatorControl.waypoint.name"; //$NON-NLS-1$
- private final static String PREFS_WAYPOINT_COL_LONGITUDE = "emulatorControl.waypoint.longitude"; //$NON-NLS-1$
- private final static String PREFS_WAYPOINT_COL_LATITUDE = "emulatorControl.waypoint.latitude"; //$NON-NLS-1$
- private final static String PREFS_WAYPOINT_COL_ELEVATION = "emulatorControl.waypoint.elevation"; //$NON-NLS-1$
- private final static String PREFS_WAYPOINT_COL_DESCRIPTION = "emulatorControl.waypoint.desc"; //$NON-NLS-1$
- private final static String PREFS_TRACK_COL_NAME = "emulatorControl.track.name"; //$NON-NLS-1$
- private final static String PREFS_TRACK_COL_COUNT = "emulatorControl.track.count"; //$NON-NLS-1$
- private final static String PREFS_TRACK_COL_FIRST = "emulatorControl.track.first"; //$NON-NLS-1$
- private final static String PREFS_TRACK_COL_LAST = "emulatorControl.track.last"; //$NON-NLS-1$
- private final static String PREFS_TRACK_COL_COMMENT = "emulatorControl.track.comment"; //$NON-NLS-1$
-
- private EmulatorConsole mEmulatorConsole;
-
- private Composite mParent;
-
- private Label mVoiceLabel;
- private Combo mVoiceMode;
- private Label mDataLabel;
- private Combo mDataMode;
- private Label mSpeedLabel;
- private Combo mNetworkSpeed;
- private Label mLatencyLabel;
- private Combo mNetworkLatency;
-
- private Label mNumberLabel;
- private Text mPhoneNumber;
-
- private Button mVoiceButton;
- private Button mSmsButton;
-
- private Label mMessageLabel;
- private Text mSmsMessage;
-
- private Button mCallButton;
- private Button mCancelButton;
-
- private TabFolder mLocationFolders;
-
- private Button mDecimalButton;
- private Button mSexagesimalButton;
- private CoordinateControls mLongitudeControls;
- private CoordinateControls mLatitudeControls;
- private Button mGpxUploadButton;
- private Table mGpxWayPointTable;
- private Table mGpxTrackTable;
- private Button mKmlUploadButton;
- private Table mKmlWayPointTable;
-
- private Button mPlayGpxButton;
- private Button mGpxBackwardButton;
- private Button mGpxForwardButton;
- private Button mGpxSpeedButton;
- private Button mPlayKmlButton;
- private Button mKmlBackwardButton;
- private Button mKmlForwardButton;
- private Button mKmlSpeedButton;
-
- private Image mPlayImage;
- private Image mPauseImage;
-
- private Thread mPlayingThread;
- private boolean mPlayingTrack;
- private int mPlayDirection = 1;
- private int mSpeed;
- private int mSpeedIndex;
-
- private final SelectionAdapter mDirectionButtonAdapter = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- Button b = (Button)e.getSource();
- if (b.getSelection() == false) {
- // basically the button was unselected, which we don't allow.
- // so we reselect it.
- b.setSelection(true);
- return;
- }
-
- // now handle selection change.
- if (b == mGpxForwardButton || b == mKmlForwardButton) {
- mGpxBackwardButton.setSelection(false);
- mGpxForwardButton.setSelection(true);
- mKmlBackwardButton.setSelection(false);
- mKmlForwardButton.setSelection(true);
- mPlayDirection = 1;
-
- } else {
- mGpxBackwardButton.setSelection(true);
- mGpxForwardButton.setSelection(false);
- mKmlBackwardButton.setSelection(true);
- mKmlForwardButton.setSelection(false);
- mPlayDirection = -1;
- }
- }
- };
-
- private final SelectionAdapter mSpeedButtonAdapter = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mSpeedIndex = (mSpeedIndex+1) % PLAY_SPEEDS.length;
- mSpeed = PLAY_SPEEDS[mSpeedIndex];
-
- mGpxSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
- mGpxPlayControls.pack();
- mKmlSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
- mKmlPlayControls.pack();
-
- if (mPlayingThread != null) {
- mPlayingThread.interrupt();
- }
- }
- };
- private Composite mKmlPlayControls;
- private Composite mGpxPlayControls;
-
-
- public EmulatorControlPanel() {
- }
-
- /**
- * Sent when a new device is selected. The new device can be accessed
- * with {@link #getCurrentDevice()}
- */
- @Override
- public void deviceSelected() {
- handleNewDevice(getCurrentDevice());
- }
-
- /**
- * Sent when a new client is selected. The new client can be accessed
- * with {@link #getCurrentClient()}
- */
- @Override
- public void clientSelected() {
- // pass
- }
-
- /**
- * Creates a control capable of displaying some information. This is
- * called once, when the application is initializing, from the UI thread.
- */
- @Override
- protected Control createControl(Composite parent) {
- mParent = parent;
-
- final ScrolledComposite scollingParent = new ScrolledComposite(parent, SWT.V_SCROLL);
- scollingParent.setExpandVertical(true);
- scollingParent.setExpandHorizontal(true);
- scollingParent.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- final Composite top = new Composite(scollingParent, SWT.NONE);
- scollingParent.setContent(top);
- top.setLayout(new GridLayout(1, false));
-
- // set the resize for the scrolling to work (why isn't that done automatically?!?)
- scollingParent.addControlListener(new ControlAdapter() {
- @Override
- public void controlResized(ControlEvent e) {
- Rectangle r = scollingParent.getClientArea();
- scollingParent.setMinSize(top.computeSize(r.width, SWT.DEFAULT));
- }
- });
-
- createRadioControls(top);
-
- createCallControls(top);
-
- createLocationControls(top);
-
- doEnable(false);
-
- top.layout();
- Rectangle r = scollingParent.getClientArea();
- scollingParent.setMinSize(top.computeSize(r.width, SWT.DEFAULT));
-
- return scollingParent;
- }
-
- /**
- * Create Radio (on/off/roaming, for voice/data) controls.
- * @param top
- */
- private void createRadioControls(final Composite top) {
- Group g1 = new Group(top, SWT.NONE);
- g1.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- g1.setLayout(new GridLayout(2, false));
- g1.setText("Telephony Status");
-
- // the inside of the group is 2 composite so that all the column of the controls (mainly
- // combos) have the same width, while not taking the whole screen width
- Composite insideGroup = new Composite(g1, SWT.NONE);
- GridLayout gl = new GridLayout(4, false);
- gl.marginBottom = gl.marginHeight = gl.marginLeft = gl.marginRight = 0;
- insideGroup.setLayout(gl);
-
- mVoiceLabel = new Label(insideGroup, SWT.NONE);
- mVoiceLabel.setText("Voice:");
- mVoiceLabel.setAlignment(SWT.RIGHT);
-
- mVoiceMode = new Combo(insideGroup, SWT.READ_ONLY);
- mVoiceMode.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- for (String[] mode : GSM_MODES) {
- mVoiceMode.add(mode[0]);
- }
- mVoiceMode.addSelectionListener(new SelectionAdapter() {
- // called when selection changes
- @Override
- public void widgetSelected(SelectionEvent e) {
- setVoiceMode(mVoiceMode.getSelectionIndex());
- }
- });
-
- mSpeedLabel = new Label(insideGroup, SWT.NONE);
- mSpeedLabel.setText("Speed:");
- mSpeedLabel.setAlignment(SWT.RIGHT);
-
- mNetworkSpeed = new Combo(insideGroup, SWT.READ_ONLY);
- mNetworkSpeed.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- for (String mode : NETWORK_SPEEDS) {
- mNetworkSpeed.add(mode);
- }
- mNetworkSpeed.addSelectionListener(new SelectionAdapter() {
- // called when selection changes
- @Override
- public void widgetSelected(SelectionEvent e) {
- setNetworkSpeed(mNetworkSpeed.getSelectionIndex());
- }
- });
-
- mDataLabel = new Label(insideGroup, SWT.NONE);
- mDataLabel.setText("Data:");
- mDataLabel.setAlignment(SWT.RIGHT);
-
- mDataMode = new Combo(insideGroup, SWT.READ_ONLY);
- mDataMode.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- for (String[] mode : GSM_MODES) {
- mDataMode.add(mode[0]);
- }
- mDataMode.addSelectionListener(new SelectionAdapter() {
- // called when selection changes
- @Override
- public void widgetSelected(SelectionEvent e) {
- setDataMode(mDataMode.getSelectionIndex());
- }
- });
-
- mLatencyLabel = new Label(insideGroup, SWT.NONE);
- mLatencyLabel.setText("Latency:");
- mLatencyLabel.setAlignment(SWT.RIGHT);
-
- mNetworkLatency = new Combo(insideGroup, SWT.READ_ONLY);
- mNetworkLatency.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- for (String mode : NETWORK_LATENCIES) {
- mNetworkLatency.add(mode);
- }
- mNetworkLatency.addSelectionListener(new SelectionAdapter() {
- // called when selection changes
- @Override
- public void widgetSelected(SelectionEvent e) {
- setNetworkLatency(mNetworkLatency.getSelectionIndex());
- }
- });
-
- // now an empty label to take the rest of the width of the group
- Label l = new Label(g1, SWT.NONE);
- l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
-
- /**
- * Create Voice/SMS call/hang up controls
- * @param top
- */
- private void createCallControls(final Composite top) {
- GridLayout gl;
- Group g2 = new Group(top, SWT.NONE);
- g2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- g2.setLayout(new GridLayout(1, false));
- g2.setText("Telephony Actions");
-
- // horizontal composite for label + text field
- Composite phoneComp = new Composite(g2, SWT.NONE);
- phoneComp.setLayoutData(new GridData(GridData.FILL_BOTH));
- gl = new GridLayout(2, false);
- gl.marginBottom = gl.marginHeight = gl.marginLeft = gl.marginRight = 0;
- phoneComp.setLayout(gl);
-
- mNumberLabel = new Label(phoneComp, SWT.NONE);
- mNumberLabel.setText("Incoming number:");
-
- mPhoneNumber = new Text(phoneComp, SWT.BORDER | SWT.LEFT | SWT.SINGLE);
- mPhoneNumber.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mPhoneNumber.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- // Reenable the widgets based on the content of the text.
- // doEnable checks the validity of the phone number to enable/disable some
- // widgets.
- // Looks like we're getting a callback at creation time, so we can't
- // suppose that we are enabled when the text is modified...
- doEnable(mEmulatorConsole != null);
- }
- });
-
- mVoiceButton = new Button(phoneComp, SWT.RADIO);
- GridData gd = new GridData();
- gd.horizontalSpan = 2;
- mVoiceButton.setText("Voice");
- mVoiceButton.setLayoutData(gd);
- mVoiceButton.setEnabled(false);
- mVoiceButton.setSelection(true);
- mVoiceButton.addSelectionListener(new SelectionAdapter() {
- // called when selection changes
- @Override
- public void widgetSelected(SelectionEvent e) {
- doEnable(true);
-
- if (mVoiceButton.getSelection()) {
- mCallButton.setText("Call");
- } else {
- mCallButton.setText("Send");
- }
- }
- });
-
- mSmsButton = new Button(phoneComp, SWT.RADIO);
- mSmsButton.setText("SMS");
- gd = new GridData();
- gd.horizontalSpan = 2;
- mSmsButton.setLayoutData(gd);
- mSmsButton.setEnabled(false);
- // Since there are only 2 radio buttons, we can put a listener on only one (they
- // are both called on select and unselect event.
-
- mMessageLabel = new Label(phoneComp, SWT.NONE);
- gd = new GridData();
- gd.verticalAlignment = SWT.TOP;
- mMessageLabel.setLayoutData(gd);
- mMessageLabel.setText("Message:");
- mMessageLabel.setEnabled(false);
-
- mSmsMessage = new Text(phoneComp, SWT.BORDER | SWT.LEFT | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
- mSmsMessage.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
- gd.heightHint = 70;
- mSmsMessage.setEnabled(false);
-
- // composite to put the 2 buttons horizontally
- Composite g2ButtonComp = new Composite(g2, SWT.NONE);
- g2ButtonComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- gl = new GridLayout(2, false);
- gl.marginWidth = gl.marginHeight = 0;
- g2ButtonComp.setLayout(gl);
-
- // now a button below the phone number
- mCallButton = new Button(g2ButtonComp, SWT.PUSH);
- mCallButton.setText("Call");
- mCallButton.setEnabled(false);
- mCallButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mEmulatorConsole != null) {
- if (mVoiceButton.getSelection()) {
- processCommandResult(mEmulatorConsole.call(mPhoneNumber.getText().trim()));
- } else {
- // we need to encode the message. We need to replace the carriage return
- // character by the 2 character string \n.
- // Because of this the \ character needs to be escaped as well.
- // ReplaceAll() expects regexp so \ char are escaped twice.
- String message = mSmsMessage.getText();
- message = message.replaceAll("\\\\", //$NON-NLS-1$
- "\\\\\\\\"); //$NON-NLS-1$
-
- // While the normal line delimiter is returned by Text.getLineDelimiter()
- // it seems copy pasting text coming from somewhere else could have another
- // delimited. For this reason, we'll replace is several steps
-
- // replace the dual CR-LF
- message = message.replaceAll("\r\n", "\\\\n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- // replace remaining stand alone \n
- message = message.replaceAll("\n", "\\\\n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- // replace remaining stand alone \r
- message = message.replaceAll("\r", "\\\\n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- processCommandResult(mEmulatorConsole.sendSms(mPhoneNumber.getText().trim(),
- message));
- }
- }
- }
- });
-
- mCancelButton = new Button(g2ButtonComp, SWT.PUSH);
- mCancelButton.setText("Hang Up");
- mCancelButton.setEnabled(false);
- mCancelButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mEmulatorConsole != null) {
- if (mVoiceButton.getSelection()) {
- processCommandResult(mEmulatorConsole.cancelCall(
- mPhoneNumber.getText().trim()));
- }
- }
- }
- });
- }
-
- /**
- * Create Location controls.
- * @param top
- */
- private void createLocationControls(final Composite top) {
- Label l = new Label(top, SWT.NONE);
- l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- l.setText("Location Controls");
-
- mLocationFolders = new TabFolder(top, SWT.NONE);
- mLocationFolders.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite manualLocationComp = new Composite(mLocationFolders, SWT.NONE);
- TabItem item = new TabItem(mLocationFolders, SWT.NONE);
- item.setText("Manual");
- item.setControl(manualLocationComp);
-
- createManualLocationControl(manualLocationComp);
-
- ImageLoader loader = ImageLoader.getDdmUiLibLoader();
- mPlayImage = loader.loadImage("play.png", mParent.getDisplay()); //$NON-NLS-1$
- mPauseImage = loader.loadImage("pause.png", mParent.getDisplay()); //$NON-NLS-1$
-
- Composite gpxLocationComp = new Composite(mLocationFolders, SWT.NONE);
- item = new TabItem(mLocationFolders, SWT.NONE);
- item.setText("GPX");
- item.setControl(gpxLocationComp);
-
- createGpxLocationControl(gpxLocationComp);
-
- Composite kmlLocationComp = new Composite(mLocationFolders, SWT.NONE);
- kmlLocationComp.setLayout(new FillLayout());
- item = new TabItem(mLocationFolders, SWT.NONE);
- item.setText("KML");
- item.setControl(kmlLocationComp);
-
- createKmlLocationControl(kmlLocationComp);
- }
-
- private void createManualLocationControl(Composite manualLocationComp) {
- final StackLayout sl;
- GridLayout gl;
- Label label;
-
- manualLocationComp.setLayout(new GridLayout(1, false));
- mDecimalButton = new Button(manualLocationComp, SWT.RADIO);
- mDecimalButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mDecimalButton.setText("Decimal");
- mSexagesimalButton = new Button(manualLocationComp, SWT.RADIO);
- mSexagesimalButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mSexagesimalButton.setText("Sexagesimal");
-
- // composite to hold and switching between the 2 modes.
- final Composite content = new Composite(manualLocationComp, SWT.NONE);
- content.setLayout(sl = new StackLayout());
-
- // decimal display
- final Composite decimalContent = new Composite(content, SWT.NONE);
- decimalContent.setLayout(gl = new GridLayout(2, false));
- gl.marginHeight = gl.marginWidth = 0;
-
- mLongitudeControls = new CoordinateControls();
- mLatitudeControls = new CoordinateControls();
-
- label = new Label(decimalContent, SWT.NONE);
- label.setText("Longitude");
-
- mLongitudeControls.createDecimalText(decimalContent);
-
- label = new Label(decimalContent, SWT.NONE);
- label.setText("Latitude");
-
- mLatitudeControls.createDecimalText(decimalContent);
-
- // sexagesimal content
- final Composite sexagesimalContent = new Composite(content, SWT.NONE);
- sexagesimalContent.setLayout(gl = new GridLayout(7, false));
- gl.marginHeight = gl.marginWidth = 0;
-
- label = new Label(sexagesimalContent, SWT.NONE);
- label.setText("Longitude");
-
- mLongitudeControls.createSexagesimalDegreeText(sexagesimalContent);
-
- label = new Label(sexagesimalContent, SWT.NONE);
- label.setText("\u00B0"); // degree character
-
- mLongitudeControls.createSexagesimalMinuteText(sexagesimalContent);
-
- label = new Label(sexagesimalContent, SWT.NONE);
- label.setText("'");
-
- mLongitudeControls.createSexagesimalSecondText(sexagesimalContent);
-
- label = new Label(sexagesimalContent, SWT.NONE);
- label.setText("\"");
-
- label = new Label(sexagesimalContent, SWT.NONE);
- label.setText("Latitude");
-
- mLatitudeControls.createSexagesimalDegreeText(sexagesimalContent);
-
- label = new Label(sexagesimalContent, SWT.NONE);
- label.setText("\u00B0");
-
- mLatitudeControls.createSexagesimalMinuteText(sexagesimalContent);
-
- label = new Label(sexagesimalContent, SWT.NONE);
- label.setText("'");
-
- mLatitudeControls.createSexagesimalSecondText(sexagesimalContent);
-
- label = new Label(sexagesimalContent, SWT.NONE);
- label.setText("\"");
-
- // set the default display to decimal
- sl.topControl = decimalContent;
- mDecimalButton.setSelection(true);
-
- mDecimalButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mDecimalButton.getSelection()) {
- sl.topControl = decimalContent;
- } else {
- sl.topControl = sexagesimalContent;
- }
- content.layout();
- }
- });
-
- Button sendButton = new Button(manualLocationComp, SWT.PUSH);
- sendButton.setText("Send");
- sendButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mEmulatorConsole != null) {
- processCommandResult(mEmulatorConsole.sendLocation(
- mLongitudeControls.getValue(), mLatitudeControls.getValue(), 0));
- }
- }
- });
-
- mLongitudeControls.setValue(DEFAULT_LONGITUDE);
- mLatitudeControls.setValue(DEFAULT_LATITUDE);
- }
-
- private void createGpxLocationControl(Composite gpxLocationComp) {
- GridData gd;
-
- IPreferenceStore store = DdmUiPreferences.getStore();
-
- gpxLocationComp.setLayout(new GridLayout(1, false));
-
- mGpxUploadButton = new Button(gpxLocationComp, SWT.PUSH);
- mGpxUploadButton.setText("Load GPX...");
-
- // Table for way point
- mGpxWayPointTable = new Table(gpxLocationComp,
- SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
- mGpxWayPointTable.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
- gd.heightHint = 100;
- mGpxWayPointTable.setHeaderVisible(true);
- mGpxWayPointTable.setLinesVisible(true);
-
- TableHelper.createTableColumn(mGpxWayPointTable, "Name", SWT.LEFT,
- "Some Name",
- PREFS_WAYPOINT_COL_NAME, store);
- TableHelper.createTableColumn(mGpxWayPointTable, "Longitude", SWT.LEFT,
- "-199.999999",
- PREFS_WAYPOINT_COL_LONGITUDE, store);
- TableHelper.createTableColumn(mGpxWayPointTable, "Latitude", SWT.LEFT,
- "-199.999999",
- PREFS_WAYPOINT_COL_LATITUDE, store);
- TableHelper.createTableColumn(mGpxWayPointTable, "Elevation", SWT.LEFT,
- "99999.9",
- PREFS_WAYPOINT_COL_ELEVATION, store);
- TableHelper.createTableColumn(mGpxWayPointTable, "Description", SWT.LEFT,
- "Some Description",
- PREFS_WAYPOINT_COL_DESCRIPTION, store);
-
- final TableViewer gpxWayPointViewer = new TableViewer(mGpxWayPointTable);
- gpxWayPointViewer.setContentProvider(new WayPointContentProvider());
- gpxWayPointViewer.setLabelProvider(new WayPointLabelProvider());
-
- gpxWayPointViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection selection = event.getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection)selection;
- Object selectedObject = structuredSelection.getFirstElement();
- if (selectedObject instanceof WayPoint) {
- WayPoint wayPoint = (WayPoint)selectedObject;
-
- if (mEmulatorConsole != null && mPlayingTrack == false) {
- processCommandResult(mEmulatorConsole.sendLocation(
- wayPoint.getLongitude(), wayPoint.getLatitude(),
- wayPoint.getElevation()));
- }
- }
- }
- }
- });
-
- // table for tracks.
- mGpxTrackTable = new Table(gpxLocationComp,
- SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
- mGpxTrackTable.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
- gd.heightHint = 100;
- mGpxTrackTable.setHeaderVisible(true);
- mGpxTrackTable.setLinesVisible(true);
-
- TableHelper.createTableColumn(mGpxTrackTable, "Name", SWT.LEFT,
- "Some very long name",
- PREFS_TRACK_COL_NAME, store);
- TableHelper.createTableColumn(mGpxTrackTable, "Point Count", SWT.RIGHT,
- "9999",
- PREFS_TRACK_COL_COUNT, store);
- TableHelper.createTableColumn(mGpxTrackTable, "First Point Time", SWT.LEFT,
- "999-99-99T99:99:99Z",
- PREFS_TRACK_COL_FIRST, store);
- TableHelper.createTableColumn(mGpxTrackTable, "Last Point Time", SWT.LEFT,
- "999-99-99T99:99:99Z",
- PREFS_TRACK_COL_LAST, store);
- TableHelper.createTableColumn(mGpxTrackTable, "Comment", SWT.LEFT,
- "-199.999999",
- PREFS_TRACK_COL_COMMENT, store);
-
- final TableViewer gpxTrackViewer = new TableViewer(mGpxTrackTable);
- gpxTrackViewer.setContentProvider(new TrackContentProvider());
- gpxTrackViewer.setLabelProvider(new TrackLabelProvider());
-
- gpxTrackViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection selection = event.getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection)selection;
- Object selectedObject = structuredSelection.getFirstElement();
- if (selectedObject instanceof Track) {
- Track track = (Track)selectedObject;
-
- if (mEmulatorConsole != null && mPlayingTrack == false) {
- TrackPoint[] points = track.getPoints();
- processCommandResult(mEmulatorConsole.sendLocation(
- points[0].getLongitude(), points[0].getLatitude(),
- points[0].getElevation()));
- }
-
- mPlayGpxButton.setEnabled(true);
- mGpxBackwardButton.setEnabled(true);
- mGpxForwardButton.setEnabled(true);
- mGpxSpeedButton.setEnabled(true);
-
- return;
- }
- }
-
- mPlayGpxButton.setEnabled(false);
- mGpxBackwardButton.setEnabled(false);
- mGpxForwardButton.setEnabled(false);
- mGpxSpeedButton.setEnabled(false);
- }
- });
-
- mGpxUploadButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- FileDialog fileDialog = new FileDialog(mParent.getShell(), SWT.OPEN);
-
- fileDialog.setText("Load GPX File");
- fileDialog.setFilterExtensions(new String[] { "*.gpx" } );
-
- String fileName = fileDialog.open();
- if (fileName != null) {
- GpxParser parser = new GpxParser(fileName);
- if (parser.parse()) {
- gpxWayPointViewer.setInput(parser.getWayPoints());
- gpxTrackViewer.setInput(parser.getTracks());
- }
- }
- }
- });
-
- mGpxPlayControls = new Composite(gpxLocationComp, SWT.NONE);
- GridLayout gl;
- mGpxPlayControls.setLayout(gl = new GridLayout(5, false));
- gl.marginHeight = gl.marginWidth = 0;
- mGpxPlayControls.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- mPlayGpxButton = new Button(mGpxPlayControls, SWT.PUSH | SWT.FLAT);
- mPlayGpxButton.setImage(mPlayImage);
- mPlayGpxButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mPlayingTrack == false) {
- ISelection selection = gpxTrackViewer.getSelection();
- if (selection.isEmpty() == false && selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection)selection;
- Object selectedObject = structuredSelection.getFirstElement();
- if (selectedObject instanceof Track) {
- Track track = (Track)selectedObject;
- playTrack(track);
- }
- }
- } else {
- // if we're playing, then we pause
- mPlayingTrack = false;
- if (mPlayingThread != null) {
- mPlayingThread.interrupt();
- }
- }
- }
- });
-
- Label separator = new Label(mGpxPlayControls, SWT.SEPARATOR | SWT.VERTICAL);
- separator.setLayoutData(gd = new GridData(
- GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
- gd.heightHint = 0;
-
- ImageLoader loader = ImageLoader.getDdmUiLibLoader();
- mGpxBackwardButton = new Button(mGpxPlayControls, SWT.TOGGLE | SWT.FLAT);
- mGpxBackwardButton.setImage(loader.loadImage("backward.png", mParent.getDisplay())); //$NON-NLS-1$
- mGpxBackwardButton.setSelection(false);
- mGpxBackwardButton.addSelectionListener(mDirectionButtonAdapter);
- mGpxForwardButton = new Button(mGpxPlayControls, SWT.TOGGLE | SWT.FLAT);
- mGpxForwardButton.setImage(loader.loadImage("forward.png", mParent.getDisplay())); //$NON-NLS-1$
- mGpxForwardButton.setSelection(true);
- mGpxForwardButton.addSelectionListener(mDirectionButtonAdapter);
-
- mGpxSpeedButton = new Button(mGpxPlayControls, SWT.PUSH | SWT.FLAT);
-
- mSpeedIndex = 0;
- mSpeed = PLAY_SPEEDS[mSpeedIndex];
-
- mGpxSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
- mGpxSpeedButton.addSelectionListener(mSpeedButtonAdapter);
-
- mPlayGpxButton.setEnabled(false);
- mGpxBackwardButton.setEnabled(false);
- mGpxForwardButton.setEnabled(false);
- mGpxSpeedButton.setEnabled(false);
-
- }
-
- private void createKmlLocationControl(Composite kmlLocationComp) {
- GridData gd;
-
- IPreferenceStore store = DdmUiPreferences.getStore();
-
- kmlLocationComp.setLayout(new GridLayout(1, false));
-
- mKmlUploadButton = new Button(kmlLocationComp, SWT.PUSH);
- mKmlUploadButton.setText("Load KML...");
-
- // Table for way point
- mKmlWayPointTable = new Table(kmlLocationComp,
- SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
- mKmlWayPointTable.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
- gd.heightHint = 200;
- mKmlWayPointTable.setHeaderVisible(true);
- mKmlWayPointTable.setLinesVisible(true);
-
- TableHelper.createTableColumn(mKmlWayPointTable, "Name", SWT.LEFT,
- "Some Name",
- PREFS_WAYPOINT_COL_NAME, store);
- TableHelper.createTableColumn(mKmlWayPointTable, "Longitude", SWT.LEFT,
- "-199.999999",
- PREFS_WAYPOINT_COL_LONGITUDE, store);
- TableHelper.createTableColumn(mKmlWayPointTable, "Latitude", SWT.LEFT,
- "-199.999999",
- PREFS_WAYPOINT_COL_LATITUDE, store);
- TableHelper.createTableColumn(mKmlWayPointTable, "Elevation", SWT.LEFT,
- "99999.9",
- PREFS_WAYPOINT_COL_ELEVATION, store);
- TableHelper.createTableColumn(mKmlWayPointTable, "Description", SWT.LEFT,
- "Some Description",
- PREFS_WAYPOINT_COL_DESCRIPTION, store);
-
- final TableViewer kmlWayPointViewer = new TableViewer(mKmlWayPointTable);
- kmlWayPointViewer.setContentProvider(new WayPointContentProvider());
- kmlWayPointViewer.setLabelProvider(new WayPointLabelProvider());
-
- mKmlUploadButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- FileDialog fileDialog = new FileDialog(mParent.getShell(), SWT.OPEN);
-
- fileDialog.setText("Load KML File");
- fileDialog.setFilterExtensions(new String[] { "*.kml" } );
-
- String fileName = fileDialog.open();
- if (fileName != null) {
- KmlParser parser = new KmlParser(fileName);
- if (parser.parse()) {
- kmlWayPointViewer.setInput(parser.getWayPoints());
-
- mPlayKmlButton.setEnabled(true);
- mKmlBackwardButton.setEnabled(true);
- mKmlForwardButton.setEnabled(true);
- mKmlSpeedButton.setEnabled(true);
- }
- }
- }
- });
-
- kmlWayPointViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection selection = event.getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection)selection;
- Object selectedObject = structuredSelection.getFirstElement();
- if (selectedObject instanceof WayPoint) {
- WayPoint wayPoint = (WayPoint)selectedObject;
-
- if (mEmulatorConsole != null && mPlayingTrack == false) {
- processCommandResult(mEmulatorConsole.sendLocation(
- wayPoint.getLongitude(), wayPoint.getLatitude(),
- wayPoint.getElevation()));
- }
- }
- }
- }
- });
-
-
-
- mKmlPlayControls = new Composite(kmlLocationComp, SWT.NONE);
- GridLayout gl;
- mKmlPlayControls.setLayout(gl = new GridLayout(5, false));
- gl.marginHeight = gl.marginWidth = 0;
- mKmlPlayControls.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- mPlayKmlButton = new Button(mKmlPlayControls, SWT.PUSH | SWT.FLAT);
- mPlayKmlButton.setImage(mPlayImage);
- mPlayKmlButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mPlayingTrack == false) {
- Object input = kmlWayPointViewer.getInput();
- if (input instanceof WayPoint[]) {
- playKml((WayPoint[])input);
- }
- } else {
- // if we're playing, then we pause
- mPlayingTrack = false;
- if (mPlayingThread != null) {
- mPlayingThread.interrupt();
- }
- }
- }
- });
-
- Label separator = new Label(mKmlPlayControls, SWT.SEPARATOR | SWT.VERTICAL);
- separator.setLayoutData(gd = new GridData(
- GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
- gd.heightHint = 0;
-
- ImageLoader loader = ImageLoader.getDdmUiLibLoader();
- mKmlBackwardButton = new Button(mKmlPlayControls, SWT.TOGGLE | SWT.FLAT);
- mKmlBackwardButton.setImage(loader.loadImage("backward.png", mParent.getDisplay())); //$NON-NLS-1$
- mKmlBackwardButton.setSelection(false);
- mKmlBackwardButton.addSelectionListener(mDirectionButtonAdapter);
- mKmlForwardButton = new Button(mKmlPlayControls, SWT.TOGGLE | SWT.FLAT);
- mKmlForwardButton.setImage(loader.loadImage("forward.png", mParent.getDisplay())); //$NON-NLS-1$
- mKmlForwardButton.setSelection(true);
- mKmlForwardButton.addSelectionListener(mDirectionButtonAdapter);
-
- mKmlSpeedButton = new Button(mKmlPlayControls, SWT.PUSH | SWT.FLAT);
-
- mSpeedIndex = 0;
- mSpeed = PLAY_SPEEDS[mSpeedIndex];
-
- mKmlSpeedButton.setText(String.format(SPEED_FORMAT, mSpeed));
- mKmlSpeedButton.addSelectionListener(mSpeedButtonAdapter);
-
- mPlayKmlButton.setEnabled(false);
- mKmlBackwardButton.setEnabled(false);
- mKmlForwardButton.setEnabled(false);
- mKmlSpeedButton.setEnabled(false);
- }
-
- /**
- * Sets the focus to the proper control inside the panel.
- */
- @Override
- public void setFocus() {
- }
-
- @Override
- protected void postCreation() {
- // pass
- }
-
- private synchronized void setDataMode(int selectionIndex) {
- if (mEmulatorConsole != null) {
- processCommandResult(mEmulatorConsole.setGsmDataMode(
- GsmMode.getEnum(GSM_MODES[selectionIndex][1])));
- }
- }
-
- private synchronized void setVoiceMode(int selectionIndex) {
- if (mEmulatorConsole != null) {
- processCommandResult(mEmulatorConsole.setGsmVoiceMode(
- GsmMode.getEnum(GSM_MODES[selectionIndex][1])));
- }
- }
-
- private synchronized void setNetworkLatency(int selectionIndex) {
- if (mEmulatorConsole != null) {
- processCommandResult(mEmulatorConsole.setNetworkLatency(selectionIndex));
- }
- }
-
- private synchronized void setNetworkSpeed(int selectionIndex) {
- if (mEmulatorConsole != null) {
- processCommandResult(mEmulatorConsole.setNetworkSpeed(selectionIndex));
- }
- }
-
-
- /**
- * Callback on device selection change.
- * @param device the new selected device
- */
- public void handleNewDevice(IDevice device) {
- if (mParent.isDisposed()) {
- return;
- }
- // unlink to previous console.
- synchronized (this) {
- mEmulatorConsole = null;
- }
-
- try {
- // get the emulator console for this device
- // First we need the device itself
- if (device != null) {
- GsmStatus gsm = null;
- NetworkStatus netstatus = null;
-
- synchronized (this) {
- mEmulatorConsole = EmulatorConsole.getConsole(device);
- if (mEmulatorConsole != null) {
- // get the gsm status
- gsm = mEmulatorConsole.getGsmStatus();
- netstatus = mEmulatorConsole.getNetworkStatus();
-
- if (gsm == null || netstatus == null) {
- mEmulatorConsole = null;
- }
- }
- }
-
- if (gsm != null && netstatus != null) {
- Display d = mParent.getDisplay();
- if (d.isDisposed() == false) {
- final GsmStatus f_gsm = gsm;
- final NetworkStatus f_netstatus = netstatus;
-
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (f_gsm.voice != GsmMode.UNKNOWN) {
- mVoiceMode.select(getGsmComboIndex(f_gsm.voice));
- } else {
- mVoiceMode.clearSelection();
- }
- if (f_gsm.data != GsmMode.UNKNOWN) {
- mDataMode.select(getGsmComboIndex(f_gsm.data));
- } else {
- mDataMode.clearSelection();
- }
-
- if (f_netstatus.speed != -1) {
- mNetworkSpeed.select(f_netstatus.speed);
- } else {
- mNetworkSpeed.clearSelection();
- }
-
- if (f_netstatus.latency != -1) {
- mNetworkLatency.select(f_netstatus.latency);
- } else {
- mNetworkLatency.clearSelection();
- }
- }
- });
- }
- }
- }
- } finally {
- // enable/disable the ui
- boolean enable = false;
- synchronized (this) {
- enable = mEmulatorConsole != null;
- }
-
- enable(enable);
- }
- }
-
- /**
- * Enable or disable the ui. Can be called from non ui threads.
- * @param enabled
- */
- private void enable(final boolean enabled) {
- try {
- Display d = mParent.getDisplay();
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (mParent.isDisposed() == false) {
- doEnable(enabled);
- }
- }
- });
- } catch (SWTException e) {
- // disposed. do nothing
- }
- }
-
- private boolean isValidPhoneNumber() {
- String number = mPhoneNumber.getText().trim();
-
- return number.matches(RE_PHONE_NUMBER);
- }
-
- /**
- * Enable or disable the ui. Cannot be called from non ui threads.
- * @param enabled
- */
- protected void doEnable(boolean enabled) {
- mVoiceLabel.setEnabled(enabled);
- mVoiceMode.setEnabled(enabled);
-
- mDataLabel.setEnabled(enabled);
- mDataMode.setEnabled(enabled);
-
- mSpeedLabel.setEnabled(enabled);
- mNetworkSpeed.setEnabled(enabled);
-
- mLatencyLabel.setEnabled(enabled);
- mNetworkLatency.setEnabled(enabled);
-
- // Calling setEnabled on a text field will trigger a modifyText event, so we don't do it
- // if we don't need to.
- if (mPhoneNumber.isEnabled() != enabled) {
- mNumberLabel.setEnabled(enabled);
- mPhoneNumber.setEnabled(enabled);
- }
-
- boolean valid = isValidPhoneNumber();
-
- mVoiceButton.setEnabled(enabled && valid);
- mSmsButton.setEnabled(enabled && valid);
-
- boolean smsValid = enabled && valid && mSmsButton.getSelection();
-
- // Calling setEnabled on a text field will trigger a modifyText event, so we don't do it
- // if we don't need to.
- if (mSmsMessage.isEnabled() != smsValid) {
- mMessageLabel.setEnabled(smsValid);
- mSmsMessage.setEnabled(smsValid);
- }
- if (enabled == false) {
- mSmsMessage.setText(""); //$NON-NLs-1$
- }
-
- mCallButton.setEnabled(enabled && valid);
- mCancelButton.setEnabled(enabled && valid && mVoiceButton.getSelection());
-
- if (enabled == false) {
- mVoiceMode.clearSelection();
- mDataMode.clearSelection();
- mNetworkSpeed.clearSelection();
- mNetworkLatency.clearSelection();
- if (mPhoneNumber.getText().length() > 0) {
- mPhoneNumber.setText(""); //$NON-NLS-1$
- }
- }
-
- // location controls
- mLocationFolders.setEnabled(enabled);
-
- mDecimalButton.setEnabled(enabled);
- mSexagesimalButton.setEnabled(enabled);
- mLongitudeControls.setEnabled(enabled);
- mLatitudeControls.setEnabled(enabled);
-
- mGpxUploadButton.setEnabled(enabled);
- mGpxWayPointTable.setEnabled(enabled);
- mGpxTrackTable.setEnabled(enabled);
- mKmlUploadButton.setEnabled(enabled);
- mKmlWayPointTable.setEnabled(enabled);
- }
-
- /**
- * Returns the index of the combo item matching a specific GsmMode.
- * @param mode
- */
- private int getGsmComboIndex(GsmMode mode) {
- for (int i = 0 ; i < GSM_MODES.length; i++) {
- String[] modes = GSM_MODES[i];
- if (mode.getTag().equals(modes[1])) {
- return i;
- }
- }
- return -1;
- }
-
- /**
- * Processes the result of a command sent to the console.
- * @param result the result of the command.
- */
- private boolean processCommandResult(final String result) {
- if (result != EmulatorConsole.RESULT_OK) {
- try {
- mParent.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (mParent.isDisposed() == false) {
- MessageDialog.openError(mParent.getShell(), "Emulator Console",
- result);
- }
- }
- });
- } catch (SWTException e) {
- // we're quitting, just ignore
- }
-
- return false;
- }
-
- return true;
- }
-
- /**
- * @param track
- */
- private void playTrack(final Track track) {
- // no need to synchronize this check, the worst that can happen, is we start the thread
- // for nothing.
- if (mEmulatorConsole != null) {
- mPlayGpxButton.setImage(mPauseImage);
- mPlayKmlButton.setImage(mPauseImage);
- mPlayingTrack = true;
-
- mPlayingThread = new Thread() {
- @Override
- public void run() {
- try {
- TrackPoint[] trackPoints = track.getPoints();
- int count = trackPoints.length;
-
- // get the start index.
- int start = 0;
- if (mPlayDirection == -1) {
- start = count - 1;
- }
-
- for (int p = start; p >= 0 && p < count; p += mPlayDirection) {
- if (mPlayingTrack == false) {
- return;
- }
-
- // get the current point and send its location to
- // the emulator.
- final TrackPoint trackPoint = trackPoints[p];
-
- synchronized (EmulatorControlPanel.this) {
- if (mEmulatorConsole == null ||
- processCommandResult(mEmulatorConsole.sendLocation(
- trackPoint.getLongitude(), trackPoint.getLatitude(),
- trackPoint.getElevation())) == false) {
- return;
- }
- }
-
- // if this is not the final point, then get the next one and
- // compute the delta time
- int nextIndex = p + mPlayDirection;
- if (nextIndex >=0 && nextIndex < count) {
- TrackPoint nextPoint = trackPoints[nextIndex];
-
- long delta = nextPoint.getTime() - trackPoint.getTime();
- if (delta < 0) {
- delta = -delta;
- }
-
- long startTime = System.currentTimeMillis();
-
- try {
- sleep(delta / mSpeed);
- } catch (InterruptedException e) {
- if (mPlayingTrack == false) {
- return;
- }
-
- // we got interrupted, lets make sure we can play
- do {
- long waited = System.currentTimeMillis() - startTime;
- long needToWait = delta / mSpeed;
- if (waited < needToWait) {
- try {
- sleep(needToWait - waited);
- } catch (InterruptedException e1) {
- // we'll just loop and wait again if needed.
- // unless we're supposed to stop
- if (mPlayingTrack == false) {
- return;
- }
- }
- } else {
- break;
- }
- } while (true);
- }
- }
- }
- } finally {
- mPlayingTrack = false;
- try {
- mParent.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (mPlayGpxButton.isDisposed() == false) {
- mPlayGpxButton.setImage(mPlayImage);
- mPlayKmlButton.setImage(mPlayImage);
- }
- }
- });
- } catch (SWTException e) {
- // we're quitting, just ignore
- }
- }
- }
- };
-
- mPlayingThread.start();
- }
- }
-
- private void playKml(final WayPoint[] trackPoints) {
- // no need to synchronize this check, the worst that can happen, is we start the thread
- // for nothing.
- if (mEmulatorConsole != null) {
- mPlayGpxButton.setImage(mPauseImage);
- mPlayKmlButton.setImage(mPauseImage);
- mPlayingTrack = true;
-
- mPlayingThread = new Thread() {
- @Override
- public void run() {
- try {
- int count = trackPoints.length;
-
- // get the start index.
- int start = 0;
- if (mPlayDirection == -1) {
- start = count - 1;
- }
-
- for (int p = start; p >= 0 && p < count; p += mPlayDirection) {
- if (mPlayingTrack == false) {
- return;
- }
-
- // get the current point and send its location to
- // the emulator.
- WayPoint trackPoint = trackPoints[p];
-
- synchronized (EmulatorControlPanel.this) {
- if (mEmulatorConsole == null ||
- processCommandResult(mEmulatorConsole.sendLocation(
- trackPoint.getLongitude(), trackPoint.getLatitude(),
- trackPoint.getElevation())) == false) {
- return;
- }
- }
-
- // if this is not the final point, then get the next one and
- // compute the delta time
- int nextIndex = p + mPlayDirection;
- if (nextIndex >=0 && nextIndex < count) {
-
- long delta = 1000; // 1 second
- if (delta < 0) {
- delta = -delta;
- }
-
- long startTime = System.currentTimeMillis();
-
- try {
- sleep(delta / mSpeed);
- } catch (InterruptedException e) {
- if (mPlayingTrack == false) {
- return;
- }
-
- // we got interrupted, lets make sure we can play
- do {
- long waited = System.currentTimeMillis() - startTime;
- long needToWait = delta / mSpeed;
- if (waited < needToWait) {
- try {
- sleep(needToWait - waited);
- } catch (InterruptedException e1) {
- // we'll just loop and wait again if needed.
- // unless we're supposed to stop
- if (mPlayingTrack == false) {
- return;
- }
- }
- } else {
- break;
- }
- } while (true);
- }
- }
- }
- } finally {
- mPlayingTrack = false;
- try {
- mParent.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (mPlayGpxButton.isDisposed() == false) {
- mPlayGpxButton.setImage(mPlayImage);
- mPlayKmlButton.setImage(mPlayImage);
- }
- }
- });
- } catch (SWTException e) {
- // we're quitting, just ignore
- }
- }
- }
- };
-
- mPlayingThread.start();
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/FindDialog.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/FindDialog.java
deleted file mode 100644
index fe3f438..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/FindDialog.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * {@link FindDialog} provides a text box where users can enter text that should be
- * searched for in the target editor/view. The buttons "Find Previous" and "Find Next"
- * allow users to search forwards/backwards. This dialog simply provides a front end for the user
- * and the actual task of searching is delegated to the {@link IFindTarget}.
- */
-public class FindDialog extends Dialog {
- private Label mStatusLabel;
- private Button mFindNext;
- private Button mFindPrevious;
- private final IFindTarget mTarget;
- private Text mSearchText;
- private String mPreviousSearchText;
- private final int mDefaultButtonId;
-
- /** Id of the "Find Next" button */
- public static final int FIND_NEXT_ID = IDialogConstants.CLIENT_ID;
-
- /** Id of the "Find Previous button */
- public static final int FIND_PREVIOUS_ID = IDialogConstants.CLIENT_ID + 1;
-
- public FindDialog(Shell shell, IFindTarget target) {
- this(shell, target, FIND_PREVIOUS_ID);
- }
-
- /**
- * Construct a find dialog.
- * @param shell shell to use
- * @param target delegate to be invoked on user action
- * @param defaultButtonId one of {@code #FIND_NEXT_ID} or {@code #FIND_PREVIOUS_ID}.
- */
- public FindDialog(Shell shell, IFindTarget target, int defaultButtonId) {
- super(shell);
-
- mTarget = target;
- mDefaultButtonId = defaultButtonId;
-
- setShellStyle((getShellStyle() & ~SWT.APPLICATION_MODAL) | SWT.MODELESS);
- setBlockOnOpen(true);
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite panel = new Composite(parent, SWT.NONE);
- panel.setLayout(new GridLayout(2, false));
- panel.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Label lblMessage = new Label(panel, SWT.NONE);
- lblMessage.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
- lblMessage.setText("Find:");
-
- mSearchText = new Text(panel, SWT.BORDER);
- mSearchText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- mSearchText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- boolean hasText = !mSearchText.getText().trim().isEmpty();
- mFindNext.setEnabled(hasText);
- mFindPrevious.setEnabled(hasText);
- }
- });
-
- mStatusLabel = new Label(panel, SWT.NONE);
- mStatusLabel.setForeground(getShell().getDisplay().getSystemColor(SWT.COLOR_DARK_RED));
- GridData gd = new GridData();
- gd.horizontalSpan = 2;
- gd.grabExcessHorizontalSpace = true;
- mStatusLabel.setLayoutData(gd);
-
- return panel;
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, false);
-
- mFindNext = createButton(parent, FIND_NEXT_ID, "Find Next",
- mDefaultButtonId == FIND_NEXT_ID);
- mFindPrevious = createButton(parent, FIND_PREVIOUS_ID, "Find Previous",
- mDefaultButtonId != FIND_NEXT_ID);
- mFindNext.setEnabled(false);
- mFindPrevious.setEnabled(false);
- }
-
- @Override
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.CLOSE_ID) {
- close();
- return;
- }
-
- if (buttonId == FIND_PREVIOUS_ID || buttonId == FIND_NEXT_ID) {
- if (mTarget != null) {
- String searchText = mSearchText.getText();
- boolean newSearch = !searchText.equals(mPreviousSearchText);
- mPreviousSearchText = searchText;
- boolean searchForward = buttonId == FIND_NEXT_ID;
-
- boolean hasMatches = mTarget.findAndSelect(searchText, newSearch, searchForward);
- if (!hasMatches) {
- mStatusLabel.setText("String not found");
- mStatusLabel.pack();
- } else {
- mStatusLabel.setText("");
- }
- }
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/HeapPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/HeapPanel.java
deleted file mode 100644
index d0af8b0..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/HeapPanel.java
+++ /dev/null
@@ -1,1310 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.AndroidDebugBridge.IClientChangeListener;
-import com.android.ddmlib.Client;
-import com.android.ddmlib.ClientData;
-import com.android.ddmlib.HeapSegment.HeapSegmentElement;
-import com.android.ddmlib.Log;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.PaletteData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.jfree.chart.ChartFactory;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.axis.CategoryAxis;
-import org.jfree.chart.axis.CategoryLabelPositions;
-import org.jfree.chart.labels.CategoryToolTipGenerator;
-import org.jfree.chart.plot.CategoryPlot;
-import org.jfree.chart.plot.Plot;
-import org.jfree.chart.plot.PlotOrientation;
-import org.jfree.chart.renderer.category.CategoryItemRenderer;
-import org.jfree.chart.title.TextTitle;
-import org.jfree.data.category.CategoryDataset;
-import org.jfree.data.category.DefaultCategoryDataset;
-import org.jfree.experimental.chart.swt.ChartComposite;
-import org.jfree.experimental.swt.SWTUtils;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.NumberFormat;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-
-/**
- * Base class for our information panels.
- */
-public final class HeapPanel extends BaseHeapPanel {
- private static final String PREFS_STATS_COL_TYPE = "heapPanel.col0"; //$NON-NLS-1$
- private static final String PREFS_STATS_COL_COUNT = "heapPanel.col1"; //$NON-NLS-1$
- private static final String PREFS_STATS_COL_SIZE = "heapPanel.col2"; //$NON-NLS-1$
- private static final String PREFS_STATS_COL_SMALLEST = "heapPanel.col3"; //$NON-NLS-1$
- private static final String PREFS_STATS_COL_LARGEST = "heapPanel.col4"; //$NON-NLS-1$
- private static final String PREFS_STATS_COL_MEDIAN = "heapPanel.col5"; //$NON-NLS-1$
- private static final String PREFS_STATS_COL_AVERAGE = "heapPanel.col6"; //$NON-NLS-1$
-
- /* args to setUpdateStatus() */
- private static final int NOT_SELECTED = 0;
- private static final int NOT_ENABLED = 1;
- private static final int ENABLED = 2;
-
- /** color palette and map legend. NATIVE is the last enum is a 0 based enum list, so we need
- * Native+1 at least. We also need 2 more entries for free area and expansion area. */
- private static final int NUM_PALETTE_ENTRIES = HeapSegmentElement.KIND_NATIVE+2 +1;
- private static final String[] mMapLegend = new String[NUM_PALETTE_ENTRIES];
- private static final PaletteData mMapPalette = createPalette();
-
- private static final boolean DISPLAY_HEAP_BITMAP = false;
- private static final boolean DISPLAY_HILBERT_BITMAP = false;
-
- private static final int PLACEHOLDER_HILBERT_SIZE = 200;
- private static final int PLACEHOLDER_LINEAR_V_SIZE = 100;
- private static final int PLACEHOLDER_LINEAR_H_SIZE = 300;
-
- private static final int[] ZOOMS = {100, 50, 25};
-
- private static final NumberFormat sByteFormatter = NumberFormat.getInstance();
- private static final NumberFormat sLargeByteFormatter = NumberFormat.getInstance();
- private static final NumberFormat sCountFormatter = NumberFormat.getInstance();
-
- static {
- sByteFormatter.setMinimumFractionDigits(0);
- sByteFormatter.setMaximumFractionDigits(1);
- sLargeByteFormatter.setMinimumFractionDigits(3);
- sLargeByteFormatter.setMaximumFractionDigits(3);
-
- sCountFormatter.setGroupingUsed(true);
- }
-
- private Display mDisplay;
-
- private Composite mTop; // real top
- private Label mUpdateStatus;
- private Table mHeapSummary;
- private Combo mDisplayMode;
-
- //private ScrolledComposite mScrolledComposite;
-
- private Composite mDisplayBase; // base of the displays.
- private StackLayout mDisplayStack;
-
- private Composite mStatisticsBase;
- private Table mStatisticsTable;
- private JFreeChart mChart;
- private ChartComposite mChartComposite;
- private Button mGcButton;
- private DefaultCategoryDataset mAllocCountDataSet;
-
- private Composite mLinearBase;
- private Label mLinearHeapImage;
-
- private Composite mHilbertBase;
- private Label mHilbertHeapImage;
- private Group mLegend;
- private Combo mZoom;
-
- /** Image used for the hilbert display. Since we recreate a new image every time, we
- * keep this one around to dispose it. */
- private Image mHilbertImage;
- private Image mLinearImage;
- private Composite[] mLayout;
-
- /*
- * Create color palette for map. Set up titles for legend.
- */
- private static PaletteData createPalette() {
- RGB colors[] = new RGB[NUM_PALETTE_ENTRIES];
- colors[0]
- = new RGB(192, 192, 192); // non-heap pixels are gray
- mMapLegend[0]
- = "(heap expansion area)";
-
- colors[1]
- = new RGB(0, 0, 0); // free chunks are black
- mMapLegend[1]
- = "free";
-
- colors[HeapSegmentElement.KIND_OBJECT + 2]
- = new RGB(0, 0, 255); // objects are blue
- mMapLegend[HeapSegmentElement.KIND_OBJECT + 2]
- = "data object";
-
- colors[HeapSegmentElement.KIND_CLASS_OBJECT + 2]
- = new RGB(0, 255, 0); // class objects are green
- mMapLegend[HeapSegmentElement.KIND_CLASS_OBJECT + 2]
- = "class object";
-
- colors[HeapSegmentElement.KIND_ARRAY_1 + 2]
- = new RGB(255, 0, 0); // byte/bool arrays are red
- mMapLegend[HeapSegmentElement.KIND_ARRAY_1 + 2]
- = "1-byte array (byte[], boolean[])";
-
- colors[HeapSegmentElement.KIND_ARRAY_2 + 2]
- = new RGB(255, 128, 0); // short/char arrays are orange
- mMapLegend[HeapSegmentElement.KIND_ARRAY_2 + 2]
- = "2-byte array (short[], char[])";
-
- colors[HeapSegmentElement.KIND_ARRAY_4 + 2]
- = new RGB(255, 255, 0); // obj/int/float arrays are yellow
- mMapLegend[HeapSegmentElement.KIND_ARRAY_4 + 2]
- = "4-byte array (object[], int[], float[])";
-
- colors[HeapSegmentElement.KIND_ARRAY_8 + 2]
- = new RGB(255, 128, 128); // long/double arrays are pink
- mMapLegend[HeapSegmentElement.KIND_ARRAY_8 + 2]
- = "8-byte array (long[], double[])";
-
- colors[HeapSegmentElement.KIND_UNKNOWN + 2]
- = new RGB(255, 0, 255); // unknown objects are cyan
- mMapLegend[HeapSegmentElement.KIND_UNKNOWN + 2]
- = "unknown object";
-
- colors[HeapSegmentElement.KIND_NATIVE + 2]
- = new RGB(64, 64, 64); // native objects are dark gray
- mMapLegend[HeapSegmentElement.KIND_NATIVE + 2]
- = "non-Java object";
-
- return new PaletteData(colors);
- }
-
- /**
- * Sent when an existing client information changed.
- * <p/>
- * This is sent from a non UI thread.
- * @param client the updated client.
- * @param changeMask the bit mask describing the changed properties. It can contain
- * any of the following values: {@link Client#CHANGE_INFO}, {@link Client#CHANGE_NAME}
- * {@link Client#CHANGE_DEBUGGER_STATUS}, {@link Client#CHANGE_THREAD_MODE},
- * {@link Client#CHANGE_THREAD_DATA}, {@link Client#CHANGE_HEAP_MODE},
- * {@link Client#CHANGE_HEAP_DATA}, {@link Client#CHANGE_NATIVE_HEAP_DATA}
- *
- * @see IClientChangeListener#clientChanged(Client, int)
- */
- @Override
- public void clientChanged(final Client client, int changeMask) {
- if (client == getCurrentClient()) {
- if ((changeMask & Client.CHANGE_HEAP_MODE) == Client.CHANGE_HEAP_MODE ||
- (changeMask & Client.CHANGE_HEAP_DATA) == Client.CHANGE_HEAP_DATA) {
- try {
- mTop.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- clientSelected();
- }
- });
- } catch (SWTException e) {
- // display is disposed (app is quitting most likely), we do nothing.
- }
- }
- }
- }
-
- /**
- * Sent when a new device is selected. The new device can be accessed
- * with {@link #getCurrentDevice()}
- */
- @Override
- public void deviceSelected() {
- // pass
- }
-
- /**
- * Sent when a new client is selected. The new client can be accessed
- * with {@link #getCurrentClient()}.
- */
- @Override
- public void clientSelected() {
- if (mTop.isDisposed())
- return;
-
- Client client = getCurrentClient();
-
- Log.d("ddms", "HeapPanel: changed " + client);
-
- if (client != null) {
- ClientData cd = client.getClientData();
-
- if (client.isHeapUpdateEnabled()) {
- mGcButton.setEnabled(true);
- mDisplayMode.setEnabled(true);
- setUpdateStatus(ENABLED);
- } else {
- setUpdateStatus(NOT_ENABLED);
- mGcButton.setEnabled(false);
- mDisplayMode.setEnabled(false);
- }
-
- fillSummaryTable(cd);
-
- int mode = mDisplayMode.getSelectionIndex();
- if (mode == 0) {
- fillDetailedTable(client, false /* forceRedraw */);
- } else {
- if (DISPLAY_HEAP_BITMAP) {
- renderHeapData(cd, mode - 1, false /* forceRedraw */);
- }
- }
- } else {
- mGcButton.setEnabled(false);
- mDisplayMode.setEnabled(false);
- fillSummaryTable(null);
- fillDetailedTable(null, true);
- setUpdateStatus(NOT_SELECTED);
- }
-
- // sizes of things change frequently, so redo layout
- //mScrolledComposite.setMinSize(mDisplayStack.topControl.computeSize(SWT.DEFAULT,
- // SWT.DEFAULT));
- mDisplayBase.layout();
- //mScrolledComposite.redraw();
- }
-
- /**
- * Create our control(s).
- */
- @Override
- protected Control createControl(Composite parent) {
- mDisplay = parent.getDisplay();
-
- GridLayout gl;
-
- mTop = new Composite(parent, SWT.NONE);
- mTop.setLayout(new GridLayout(1, false));
- mTop.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- mUpdateStatus = new Label(mTop, SWT.NONE);
- setUpdateStatus(NOT_SELECTED);
-
- Composite summarySection = new Composite(mTop, SWT.NONE);
- summarySection.setLayout(gl = new GridLayout(2, false));
- gl.marginHeight = gl.marginWidth = 0;
-
- mHeapSummary = createSummaryTable(summarySection);
- mGcButton = new Button(summarySection, SWT.PUSH);
- mGcButton.setText("Cause GC");
- mGcButton.setEnabled(false);
- mGcButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- Client client = getCurrentClient();
- if (client != null) {
- client.executeGarbageCollector();
- }
- }
- });
-
- Composite comboSection = new Composite(mTop, SWT.NONE);
- gl = new GridLayout(2, false);
- gl.marginHeight = gl.marginWidth = 0;
- comboSection.setLayout(gl);
-
- Label displayLabel = new Label(comboSection, SWT.NONE);
- displayLabel.setText("Display: ");
-
- mDisplayMode = new Combo(comboSection, SWT.READ_ONLY);
- mDisplayMode.setEnabled(false);
- mDisplayMode.add("Stats");
- if (DISPLAY_HEAP_BITMAP) {
- mDisplayMode.add("Linear");
- if (DISPLAY_HILBERT_BITMAP) {
- mDisplayMode.add("Hilbert");
- }
- }
-
- // the base of the displays.
- mDisplayBase = new Composite(mTop, SWT.NONE);
- mDisplayBase.setLayoutData(new GridData(GridData.FILL_BOTH));
- mDisplayStack = new StackLayout();
- mDisplayBase.setLayout(mDisplayStack);
-
- // create the statistics display
- mStatisticsBase = new Composite(mDisplayBase, SWT.NONE);
- //mStatisticsBase.setLayoutData(new GridData(GridData.FILL_BOTH));
- mStatisticsBase.setLayout(gl = new GridLayout(1, false));
- gl.marginHeight = gl.marginWidth = 0;
- mDisplayStack.topControl = mStatisticsBase;
-
- mStatisticsTable = createDetailedTable(mStatisticsBase);
- mStatisticsTable.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createChart();
-
- //create the linear composite
- mLinearBase = new Composite(mDisplayBase, SWT.NONE);
- //mLinearBase.setLayoutData(new GridData());
- gl = new GridLayout(1, false);
- gl.marginHeight = gl.marginWidth = 0;
- mLinearBase.setLayout(gl);
-
- {
- mLinearHeapImage = new Label(mLinearBase, SWT.NONE);
- mLinearHeapImage.setLayoutData(new GridData());
- mLinearHeapImage.setImage(ImageLoader.createPlaceHolderArt(mDisplay,
- PLACEHOLDER_LINEAR_H_SIZE, PLACEHOLDER_LINEAR_V_SIZE,
- mDisplay.getSystemColor(SWT.COLOR_BLUE)));
-
- // create a composite to contain the bottom part (legend)
- Composite bottomSection = new Composite(mLinearBase, SWT.NONE);
- gl = new GridLayout(1, false);
- gl.marginHeight = gl.marginWidth = 0;
- bottomSection.setLayout(gl);
-
- createLegend(bottomSection);
- }
-
-/*
- mScrolledComposite = new ScrolledComposite(mTop, SWT.H_SCROLL | SWT.V_SCROLL);
- mScrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
- mScrolledComposite.setExpandHorizontal(true);
- mScrolledComposite.setExpandVertical(true);
- mScrolledComposite.setContent(mDisplayBase);
-*/
-
-
- // create the hilbert display.
- mHilbertBase = new Composite(mDisplayBase, SWT.NONE);
- //mHilbertBase.setLayoutData(new GridData());
- gl = new GridLayout(2, false);
- gl.marginHeight = gl.marginWidth = 0;
- mHilbertBase.setLayout(gl);
-
- if (DISPLAY_HILBERT_BITMAP) {
- mHilbertHeapImage = new Label(mHilbertBase, SWT.NONE);
- mHilbertHeapImage.setLayoutData(new GridData());
- mHilbertHeapImage.setImage(ImageLoader.createPlaceHolderArt(mDisplay,
- PLACEHOLDER_HILBERT_SIZE, PLACEHOLDER_HILBERT_SIZE,
- mDisplay.getSystemColor(SWT.COLOR_BLUE)));
-
- // create a composite to contain the right part (legend + zoom)
- Composite rightSection = new Composite(mHilbertBase, SWT.NONE);
- gl = new GridLayout(1, false);
- gl.marginHeight = gl.marginWidth = 0;
- rightSection.setLayout(gl);
-
- Composite zoomComposite = new Composite(rightSection, SWT.NONE);
- gl = new GridLayout(2, false);
- zoomComposite.setLayout(gl);
-
- Label l = new Label(zoomComposite, SWT.NONE);
- l.setText("Zoom:");
- mZoom = new Combo(zoomComposite, SWT.READ_ONLY);
- for (int z : ZOOMS) {
- mZoom.add(String.format("%1$d%%", z)); //$NON-NLS-1$
- }
-
- mZoom.select(0);
- mZoom.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- setLegendText(mZoom.getSelectionIndex());
- Client client = getCurrentClient();
- if (client != null) {
- renderHeapData(client.getClientData(), 1, true);
- mTop.pack();
- }
- }
- });
-
- createLegend(rightSection);
- }
- mHilbertBase.pack();
-
- mLayout = new Composite[] { mStatisticsBase, mLinearBase, mHilbertBase };
- mDisplayMode.select(0);
- mDisplayMode.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- int index = mDisplayMode.getSelectionIndex();
- Client client = getCurrentClient();
-
- if (client != null) {
- if (index == 0) {
- fillDetailedTable(client, true /* forceRedraw */);
- } else {
- renderHeapData(client.getClientData(), index-1, true /* forceRedraw */);
- }
- }
-
- mDisplayStack.topControl = mLayout[index];
- //mScrolledComposite.setMinSize(mDisplayStack.topControl.computeSize(SWT.DEFAULT,
- // SWT.DEFAULT));
- mDisplayBase.layout();
- //mScrolledComposite.redraw();
- }
- });
-
- //mScrolledComposite.setMinSize(mDisplayStack.topControl.computeSize(SWT.DEFAULT,
- // SWT.DEFAULT));
- mDisplayBase.layout();
- //mScrolledComposite.redraw();
-
- return mTop;
- }
-
- /**
- * Sets the focus to the proper control inside the panel.
- */
- @Override
- public void setFocus() {
- mHeapSummary.setFocus();
- }
-
-
- private Table createSummaryTable(Composite base) {
- Table tab = new Table(base, SWT.SINGLE | SWT.FULL_SELECTION);
- tab.setHeaderVisible(true);
- tab.setLinesVisible(true);
-
- TableColumn col;
-
- col = new TableColumn(tab, SWT.RIGHT);
- col.setText("ID");
- col.pack();
-
- col = new TableColumn(tab, SWT.RIGHT);
- col.setText("000.000WW"); //$NON-NLS-1$
- col.pack();
- col.setText("Heap Size");
-
- col = new TableColumn(tab, SWT.RIGHT);
- col.setText("000.000WW"); //$NON-NLS-1$
- col.pack();
- col.setText("Allocated");
-
- col = new TableColumn(tab, SWT.RIGHT);
- col.setText("000.000WW"); //$NON-NLS-1$
- col.pack();
- col.setText("Free");
-
- col = new TableColumn(tab, SWT.RIGHT);
- col.setText("000.00%"); //$NON-NLS-1$
- col.pack();
- col.setText("% Used");
-
- col = new TableColumn(tab, SWT.RIGHT);
- col.setText("000,000,000"); //$NON-NLS-1$
- col.pack();
- col.setText("# Objects");
-
- // make sure there is always one empty item so that one table row is always displayed.
- TableItem item = new TableItem(tab, SWT.NONE);
- item.setText("");
-
- return tab;
- }
-
- private Table createDetailedTable(Composite base) {
- IPreferenceStore store = DdmUiPreferences.getStore();
-
- Table tab = new Table(base, SWT.SINGLE | SWT.FULL_SELECTION);
- tab.setHeaderVisible(true);
- tab.setLinesVisible(true);
-
- TableHelper.createTableColumn(tab, "Type", SWT.LEFT,
- "4-byte array (object[], int[], float[])", //$NON-NLS-1$
- PREFS_STATS_COL_TYPE, store);
-
- TableHelper.createTableColumn(tab, "Count", SWT.RIGHT,
- "00,000", //$NON-NLS-1$
- PREFS_STATS_COL_COUNT, store);
-
- TableHelper.createTableColumn(tab, "Total Size", SWT.RIGHT,
- "000.000 WW", //$NON-NLS-1$
- PREFS_STATS_COL_SIZE, store);
-
- TableHelper.createTableColumn(tab, "Smallest", SWT.RIGHT,
- "000.000 WW", //$NON-NLS-1$
- PREFS_STATS_COL_SMALLEST, store);
-
- TableHelper.createTableColumn(tab, "Largest", SWT.RIGHT,
- "000.000 WW", //$NON-NLS-1$
- PREFS_STATS_COL_LARGEST, store);
-
- TableHelper.createTableColumn(tab, "Median", SWT.RIGHT,
- "000.000 WW", //$NON-NLS-1$
- PREFS_STATS_COL_MEDIAN, store);
-
- TableHelper.createTableColumn(tab, "Average", SWT.RIGHT,
- "000.000 WW", //$NON-NLS-1$
- PREFS_STATS_COL_AVERAGE, store);
-
- tab.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
-
- Client client = getCurrentClient();
- if (client != null) {
- int index = mStatisticsTable.getSelectionIndex();
- TableItem item = mStatisticsTable.getItem(index);
-
- if (item != null) {
- Map<Integer, ArrayList<HeapSegmentElement>> heapMap =
- client.getClientData().getVmHeapData().getProcessedHeapMap();
-
- ArrayList<HeapSegmentElement> list = heapMap.get(item.getData());
- if (list != null) {
- showChart(list);
- }
- }
- }
-
- }
- });
-
- return tab;
- }
-
- /**
- * Creates the chart below the statistics table
- */
- private void createChart() {
- mAllocCountDataSet = new DefaultCategoryDataset();
- mChart = ChartFactory.createBarChart(null, "Size", "Count", mAllocCountDataSet,
- PlotOrientation.VERTICAL, false, true, false);
-
- // get the font to make a proper title. We need to convert the swt font,
- // into an awt font.
- Font f = mStatisticsBase.getFont();
- FontData[] fData = f.getFontData();
-
- // event though on Mac OS there could be more than one fontData, we'll only use
- // the first one.
- FontData firstFontData = fData[0];
-
- java.awt.Font awtFont = SWTUtils.toAwtFont(mStatisticsBase.getDisplay(),
- firstFontData, true /* ensureSameSize */);
-
- mChart.setTitle(new TextTitle("Allocation count per size", awtFont));
-
- Plot plot = mChart.getPlot();
- if (plot instanceof CategoryPlot) {
- // get the plot
- CategoryPlot categoryPlot = (CategoryPlot)plot;
-
- // set the domain axis to draw labels that are displayed even with many values.
- CategoryAxis domainAxis = categoryPlot.getDomainAxis();
- domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
-
- CategoryItemRenderer renderer = categoryPlot.getRenderer();
- renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() {
- @Override
- public String generateToolTip(CategoryDataset dataset, int row, int column) {
- // get the key for the size of the allocation
- ByteLong columnKey = (ByteLong)dataset.getColumnKey(column);
- String rowKey = (String)dataset.getRowKey(row);
- Number value = dataset.getValue(rowKey, columnKey);
-
- return String.format("%1$d %2$s of %3$d bytes", value.intValue(), rowKey,
- columnKey.getValue());
- }
- });
- }
- mChartComposite = new ChartComposite(mStatisticsBase, SWT.BORDER, mChart,
- ChartComposite.DEFAULT_WIDTH,
- ChartComposite.DEFAULT_HEIGHT,
- ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH,
- ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT,
- 3000, // max draw width. We don't want it to zoom, so we put a big number
- 3000, // max draw height. We don't want it to zoom, so we put a big number
- true, // off-screen buffer
- true, // properties
- true, // save
- true, // print
- false, // zoom
- true); // tooltips
-
- mChartComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
- }
-
- private static String prettyByteCount(long bytes) {
- double fracBytes = bytes;
- String units = " B";
- if (fracBytes < 1024) {
- return sByteFormatter.format(fracBytes) + units;
- } else {
- fracBytes /= 1024;
- units = " KB";
- }
- if (fracBytes >= 1024) {
- fracBytes /= 1024;
- units = " MB";
- }
- if (fracBytes >= 1024) {
- fracBytes /= 1024;
- units = " GB";
- }
-
- return sLargeByteFormatter.format(fracBytes) + units;
- }
-
- private static String approximateByteCount(long bytes) {
- double fracBytes = bytes;
- String units = "";
- if (fracBytes >= 1024) {
- fracBytes /= 1024;
- units = "K";
- }
- if (fracBytes >= 1024) {
- fracBytes /= 1024;
- units = "M";
- }
- if (fracBytes >= 1024) {
- fracBytes /= 1024;
- units = "G";
- }
-
- return sByteFormatter.format(fracBytes) + units;
- }
-
- private static String addCommasToNumber(long num) {
- return sCountFormatter.format(num);
- }
-
- private static String fractionalPercent(long num, long denom) {
- double val = (double)num / (double)denom;
- val *= 100;
-
- NumberFormat nf = NumberFormat.getInstance();
- nf.setMinimumFractionDigits(2);
- nf.setMaximumFractionDigits(2);
- return nf.format(val) + "%";
- }
-
- private void fillSummaryTable(ClientData cd) {
- if (mHeapSummary.isDisposed()) {
- return;
- }
-
- mHeapSummary.setRedraw(false);
- mHeapSummary.removeAll();
-
- int numRows = 0;
- if (cd != null) {
- synchronized (cd) {
- Iterator<Integer> iter = cd.getVmHeapIds();
-
- while (iter.hasNext()) {
- numRows++;
- Integer id = iter.next();
- Map<String, Long> heapInfo = cd.getVmHeapInfo(id);
- if (heapInfo == null) {
- continue;
- }
- long sizeInBytes = heapInfo.get(ClientData.HEAP_SIZE_BYTES);
- long bytesAllocated = heapInfo.get(ClientData.HEAP_BYTES_ALLOCATED);
- long objectsAllocated = heapInfo.get(ClientData.HEAP_OBJECTS_ALLOCATED);
-
- TableItem item = new TableItem(mHeapSummary, SWT.NONE);
- item.setText(0, id.toString());
-
- item.setText(1, prettyByteCount(sizeInBytes));
- item.setText(2, prettyByteCount(bytesAllocated));
- item.setText(3, prettyByteCount(sizeInBytes - bytesAllocated));
- item.setText(4, fractionalPercent(bytesAllocated, sizeInBytes));
- item.setText(5, addCommasToNumber(objectsAllocated));
- }
- }
- }
-
- if (numRows == 0) {
- // make sure there is always one empty item so that one table row is always displayed.
- TableItem item = new TableItem(mHeapSummary, SWT.NONE);
- item.setText("");
- }
-
- mHeapSummary.pack();
- mHeapSummary.setRedraw(true);
- }
-
- private void fillDetailedTable(Client client, boolean forceRedraw) {
- // first check if the client is invalid or heap updates are not enabled.
- if (client == null || client.isHeapUpdateEnabled() == false) {
- mStatisticsTable.removeAll();
- showChart(null);
- return;
- }
-
- ClientData cd = client.getClientData();
-
- Map<Integer, ArrayList<HeapSegmentElement>> heapMap;
-
- // Atomically get and clear the heap data.
- synchronized (cd) {
- if (serializeHeapData(cd.getVmHeapData()) == false && forceRedraw == false) {
- // no change, we return.
- return;
- }
-
- heapMap = cd.getVmHeapData().getProcessedHeapMap();
- }
-
- // we have new data, lets display it.
-
- // First, get the current selection, and its key.
- int index = mStatisticsTable.getSelectionIndex();
- Integer selectedKey = null;
- if (index != -1) {
- selectedKey = (Integer)mStatisticsTable.getItem(index).getData();
- }
-
- // disable redraws and remove all from the table.
- mStatisticsTable.setRedraw(false);
- mStatisticsTable.removeAll();
-
- if (heapMap != null) {
- int selectedIndex = -1;
- ArrayList<HeapSegmentElement> selectedList = null;
-
- // get the keys
- Set<Integer> keys = heapMap.keySet();
- int iter = 0; // use a manual iter int because Set<?> doesn't have an index
- // based accessor.
- for (Integer key : keys) {
- ArrayList<HeapSegmentElement> list = heapMap.get(key);
-
- // check if this is the key that is supposed to be selected
- if (key.equals(selectedKey)) {
- selectedIndex = iter;
- selectedList = list;
- }
- iter++;
-
- TableItem item = new TableItem(mStatisticsTable, SWT.NONE);
- item.setData(key);
-
- // get the type
- item.setText(0, mMapLegend[key]);
-
- // set the count, smallest, largest
- int count = list.size();
- item.setText(1, addCommasToNumber(count));
-
- if (count > 0) {
- item.setText(3, prettyByteCount(list.get(0).getLength()));
- item.setText(4, prettyByteCount(list.get(count-1).getLength()));
-
- int median = count / 2;
- HeapSegmentElement element = list.get(median);
- long size = element.getLength();
- item.setText(5, prettyByteCount(size));
-
- long totalSize = 0;
- for (int i = 0 ; i < count; i++) {
- element = list.get(i);
-
- size = element.getLength();
- totalSize += size;
- }
-
- // set the average and total
- item.setText(2, prettyByteCount(totalSize));
- item.setText(6, prettyByteCount(totalSize / count));
- }
- }
-
- mStatisticsTable.setRedraw(true);
-
- if (selectedIndex != -1) {
- mStatisticsTable.setSelection(selectedIndex);
- showChart(selectedList);
- } else {
- showChart(null);
- }
- } else {
- mStatisticsTable.setRedraw(true);
- }
- }
-
- private static class ByteLong implements Comparable<ByteLong> {
- private long mValue;
-
- private ByteLong(long value) {
- mValue = value;
- }
-
- public long getValue() {
- return mValue;
- }
-
- @Override
- public String toString() {
- return approximateByteCount(mValue);
- }
-
- @Override
- public int compareTo(ByteLong other) {
- if (mValue != other.mValue) {
- return mValue < other.mValue ? -1 : 1;
- }
- return 0;
- }
-
- }
-
- /**
- * Fills the chart with the content of the list of {@link HeapSegmentElement}.
- */
- private void showChart(ArrayList<HeapSegmentElement> list) {
- mAllocCountDataSet.clear();
-
- if (list != null) {
- String rowKey = "Alloc Count";
-
- long currentSize = -1;
- int currentCount = 0;
- for (HeapSegmentElement element : list) {
- if (element.getLength() != currentSize) {
- if (currentSize != -1) {
- ByteLong columnKey = new ByteLong(currentSize);
- mAllocCountDataSet.addValue(currentCount, rowKey, columnKey);
- }
-
- currentSize = element.getLength();
- currentCount = 1;
- } else {
- currentCount++;
- }
- }
-
- // add the last item
- if (currentSize != -1) {
- ByteLong columnKey = new ByteLong(currentSize);
- mAllocCountDataSet.addValue(currentCount, rowKey, columnKey);
- }
- }
- }
-
- /*
- * Add a color legend to the specified table.
- */
- private void createLegend(Composite parent) {
- mLegend = new Group(parent, SWT.NONE);
- mLegend.setText(getLegendText(0));
-
- mLegend.setLayout(new GridLayout(2, false));
-
- RGB[] colors = mMapPalette.colors;
-
- for (int i = 0; i < NUM_PALETTE_ENTRIES; i++) {
- Image tmpImage = createColorRect(parent.getDisplay(), colors[i]);
-
- Label l = new Label(mLegend, SWT.NONE);
- l.setImage(tmpImage);
-
- l = new Label(mLegend, SWT.NONE);
- l.setText(mMapLegend[i]);
- }
- }
-
- private String getLegendText(int level) {
- int bytes = 8 * (100 / ZOOMS[level]);
-
- return String.format("Key (1 pixel = %1$d bytes)", bytes);
- }
-
- private void setLegendText(int level) {
- mLegend.setText(getLegendText(level));
-
- }
-
- /*
- * Create a nice rectangle in the specified color.
- */
- private Image createColorRect(Display display, RGB color) {
- int width = 32;
- int height = 16;
-
- Image img = new Image(display, width, height);
- GC gc = new GC(img);
- gc.setBackground(new Color(display, color));
- gc.fillRectangle(0, 0, width, height);
- gc.dispose();
- return img;
- }
-
-
- /*
- * Are updates enabled?
- */
- private void setUpdateStatus(int status) {
- switch (status) {
- case NOT_SELECTED:
- mUpdateStatus.setText("Select a client to see heap updates");
- break;
- case NOT_ENABLED:
- mUpdateStatus.setText("Heap updates are " +
- "NOT ENABLED for this client");
- break;
- case ENABLED:
- mUpdateStatus.setText("Heap updates will happen after " +
- "every GC for this client");
- break;
- default:
- throw new RuntimeException();
- }
-
- mUpdateStatus.pack();
- }
-
-
- /**
- * Return the closest power of two greater than or equal to value.
- *
- * @param value the return value will be >= value
- * @return a power of two >= value. If value > 2^31, 2^31 is returned.
- */
-//xxx use Integer.highestOneBit() or numberOfLeadingZeros().
- private int nextPow2(int value) {
- for (int i = 31; i >= 0; --i) {
- if ((value & (1<<i)) != 0) {
- if (i < 31) {
- return 1<<(i + 1);
- } else {
- return 1<<31;
- }
- }
- }
- return 0;
- }
-
- private int zOrderData(ImageData id, byte pixData[]) {
- int maxX = 0;
- for (int i = 0; i < pixData.length; i++) {
- /* Tread the pixData index as a z-order curve index and
- * decompose into Cartesian coordinates.
- */
- int x = (i & 1) |
- ((i >>> 2) & 1) << 1 |
- ((i >>> 4) & 1) << 2 |
- ((i >>> 6) & 1) << 3 |
- ((i >>> 8) & 1) << 4 |
- ((i >>> 10) & 1) << 5 |
- ((i >>> 12) & 1) << 6 |
- ((i >>> 14) & 1) << 7 |
- ((i >>> 16) & 1) << 8 |
- ((i >>> 18) & 1) << 9 |
- ((i >>> 20) & 1) << 10 |
- ((i >>> 22) & 1) << 11 |
- ((i >>> 24) & 1) << 12 |
- ((i >>> 26) & 1) << 13 |
- ((i >>> 28) & 1) << 14 |
- ((i >>> 30) & 1) << 15;
- int y = ((i >>> 1) & 1) << 0 |
- ((i >>> 3) & 1) << 1 |
- ((i >>> 5) & 1) << 2 |
- ((i >>> 7) & 1) << 3 |
- ((i >>> 9) & 1) << 4 |
- ((i >>> 11) & 1) << 5 |
- ((i >>> 13) & 1) << 6 |
- ((i >>> 15) & 1) << 7 |
- ((i >>> 17) & 1) << 8 |
- ((i >>> 19) & 1) << 9 |
- ((i >>> 21) & 1) << 10 |
- ((i >>> 23) & 1) << 11 |
- ((i >>> 25) & 1) << 12 |
- ((i >>> 27) & 1) << 13 |
- ((i >>> 29) & 1) << 14 |
- ((i >>> 31) & 1) << 15;
- try {
- id.setPixel(x, y, pixData[i]);
- if (x > maxX) {
- maxX = x;
- }
- } catch (IllegalArgumentException ex) {
- System.out.println("bad pixels: i " + i +
- ", w " + id.width +
- ", h " + id.height +
- ", x " + x +
- ", y " + y);
- throw ex;
- }
- }
- return maxX;
- }
-
- private final static int HILBERT_DIR_N = 0;
- private final static int HILBERT_DIR_S = 1;
- private final static int HILBERT_DIR_E = 2;
- private final static int HILBERT_DIR_W = 3;
-
- private void hilbertWalk(ImageData id, InputStream pixData,
- int order, int x, int y, int dir)
- throws IOException {
- if (x >= id.width || y >= id.height) {
- return;
- } else if (order == 0) {
- try {
- int p = pixData.read();
- if (p >= 0) {
- // flip along x=y axis; assume width == height
- id.setPixel(y, x, p);
-
- /* Skanky; use an otherwise-unused ImageData field
- * to keep track of the max x,y used. Note that x and y are inverted.
- */
- if (y > id.x) {
- id.x = y;
- }
- if (x > id.y) {
- id.y = x;
- }
- }
-//xxx just give up; don't bother walking the rest of the image
- } catch (IllegalArgumentException ex) {
- System.out.println("bad pixels: order " + order +
- ", dir " + dir +
- ", w " + id.width +
- ", h " + id.height +
- ", x " + x +
- ", y " + y);
- throw ex;
- }
- } else {
- order--;
- int delta = 1 << order;
- int nextX = x + delta;
- int nextY = y + delta;
-
- switch (dir) {
- case HILBERT_DIR_E:
- hilbertWalk(id, pixData, order, x, y, HILBERT_DIR_N);
- hilbertWalk(id, pixData, order, x, nextY, HILBERT_DIR_E);
- hilbertWalk(id, pixData, order, nextX, nextY, HILBERT_DIR_E);
- hilbertWalk(id, pixData, order, nextX, y, HILBERT_DIR_S);
- break;
- case HILBERT_DIR_N:
- hilbertWalk(id, pixData, order, x, y, HILBERT_DIR_E);
- hilbertWalk(id, pixData, order, nextX, y, HILBERT_DIR_N);
- hilbertWalk(id, pixData, order, nextX, nextY, HILBERT_DIR_N);
- hilbertWalk(id, pixData, order, x, nextY, HILBERT_DIR_W);
- break;
- case HILBERT_DIR_S:
- hilbertWalk(id, pixData, order, nextX, nextY, HILBERT_DIR_W);
- hilbertWalk(id, pixData, order, x, nextY, HILBERT_DIR_S);
- hilbertWalk(id, pixData, order, x, y, HILBERT_DIR_S);
- hilbertWalk(id, pixData, order, nextX, y, HILBERT_DIR_E);
- break;
- case HILBERT_DIR_W:
- hilbertWalk(id, pixData, order, nextX, nextY, HILBERT_DIR_S);
- hilbertWalk(id, pixData, order, nextX, y, HILBERT_DIR_W);
- hilbertWalk(id, pixData, order, x, y, HILBERT_DIR_W);
- hilbertWalk(id, pixData, order, x, nextY, HILBERT_DIR_N);
- break;
- default:
- throw new RuntimeException("Unexpected Hilbert direction " +
- dir);
- }
- }
- }
-
- private Point hilbertOrderData(ImageData id, byte pixData[]) {
-
- int order = 0;
- for (int n = 1; n < id.width; n *= 2) {
- order++;
- }
- /* Skanky; use an otherwise-unused ImageData field
- * to keep track of maxX.
- */
- Point p = new Point(0,0);
- int oldIdX = id.x;
- int oldIdY = id.y;
- id.x = id.y = 0;
- try {
- hilbertWalk(id, new ByteArrayInputStream(pixData),
- order, 0, 0, HILBERT_DIR_E);
- p.x = id.x;
- p.y = id.y;
- } catch (IOException ex) {
- System.err.println("Exception during hilbertWalk()");
- p.x = id.height;
- p.y = id.width;
- }
- id.x = oldIdX;
- id.y = oldIdY;
- return p;
- }
-
- private ImageData createHilbertHeapImage(byte pixData[]) {
- int w, h;
-
- // Pick an image size that the largest of heaps will fit into.
- w = (int)Math.sqrt(((16 * 1024 * 1024)/8));
-
- // Space-filling curves require a power-of-2 width.
- w = nextPow2(w);
- h = w;
-
- // Create the heap image.
- ImageData id = new ImageData(w, h, 8, mMapPalette);
-
- // Copy the data into the image
- //int maxX = zOrderData(id, pixData);
- Point maxP = hilbertOrderData(id, pixData);
-
- // update the max size to make it a round number once the zoom is applied
- int factor = 100 / ZOOMS[mZoom.getSelectionIndex()];
- if (factor != 1) {
- int tmp = maxP.x % factor;
- if (tmp != 0) {
- maxP.x += factor - tmp;
- }
-
- tmp = maxP.y % factor;
- if (tmp != 0) {
- maxP.y += factor - tmp;
- }
- }
-
- if (maxP.y < id.height) {
- // Crop the image down to the interesting part.
- id = new ImageData(id.width, maxP.y, id.depth, id.palette,
- id.scanlinePad, id.data);
- }
-
- if (maxP.x < id.width) {
- // crop the image again. A bit trickier this time.
- ImageData croppedId = new ImageData(maxP.x, id.height, id.depth, id.palette);
-
- int[] buffer = new int[maxP.x];
- for (int l = 0 ; l < id.height; l++) {
- id.getPixels(0, l, maxP.x, buffer, 0);
- croppedId.setPixels(0, l, maxP.x, buffer, 0);
- }
-
- id = croppedId;
- }
-
- // apply the zoom
- if (factor != 1) {
- id = id.scaledTo(id.width / factor, id.height / factor);
- }
-
- return id;
- }
-
- /**
- * Convert the raw heap data to an image. We know we're running in
- * the UI thread, so we can issue graphics commands directly.
- *
- * http://help.eclipse.org/help31/nftopic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/swt/graphics/GC.html
- *
- * @param cd The client data
- * @param mode The display mode. 0 = linear, 1 = hilbert.
- * @param forceRedraw
- */
- private void renderHeapData(ClientData cd, int mode, boolean forceRedraw) {
- Image image;
-
- byte[] pixData;
-
- // Atomically get and clear the heap data.
- synchronized (cd) {
- if (serializeHeapData(cd.getVmHeapData()) == false && forceRedraw == false) {
- // no change, we return.
- return;
- }
-
- pixData = getSerializedData();
- }
-
- if (pixData != null) {
- ImageData id;
- if (mode == 1) {
- id = createHilbertHeapImage(pixData);
- } else {
- id = createLinearHeapImage(pixData, 200, mMapPalette);
- }
-
- image = new Image(mDisplay, id);
- } else {
- // Render a placeholder image.
- int width, height;
- if (mode == 1) {
- width = height = PLACEHOLDER_HILBERT_SIZE;
- } else {
- width = PLACEHOLDER_LINEAR_H_SIZE;
- height = PLACEHOLDER_LINEAR_V_SIZE;
- }
- image = new Image(mDisplay, width, height);
- GC gc = new GC(image);
- gc.setForeground(mDisplay.getSystemColor(SWT.COLOR_RED));
- gc.drawLine(0, 0, width-1, height-1);
- gc.dispose();
- gc = null;
- }
-
- // set the new image
-
- if (mode == 1) {
- if (mHilbertImage != null) {
- mHilbertImage.dispose();
- }
-
- mHilbertImage = image;
- mHilbertHeapImage.setImage(mHilbertImage);
- mHilbertHeapImage.pack(true);
- mHilbertBase.layout();
- mHilbertBase.pack(true);
- } else {
- if (mLinearImage != null) {
- mLinearImage.dispose();
- }
-
- mLinearImage = image;
- mLinearHeapImage.setImage(mLinearImage);
- mLinearHeapImage.pack(true);
- mLinearBase.layout();
- mLinearBase.pack(true);
- }
- }
-
- @Override
- protected void setTableFocusListener() {
- addTableToFocusListener(mHeapSummary);
- }
-}
-
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/IFindTarget.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/IFindTarget.java
deleted file mode 100644
index 9aa6943..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/IFindTarget.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-public interface IFindTarget {
- boolean findAndSelect(String text, boolean isNewSearch, boolean searchForward);
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/ITableFocusListener.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/ITableFocusListener.java
deleted file mode 100644
index 37dd9a0..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/ITableFocusListener.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import org.eclipse.swt.dnd.Clipboard;
-
-/**
- * An object listening to focus change in Table objects.<br>
- * For application not relying on a RCP to provide menu changes based on focus,
- * this class allows to get monitor the focus change of several Table widget
- * and update the menu action accordingly.
- */
-public interface ITableFocusListener {
-
- public interface IFocusedTableActivator {
- public void copy(Clipboard clipboard);
-
- public void selectAll();
- }
-
- public void focusGained(IFocusedTableActivator activator);
-
- public void focusLost(IFocusedTableActivator activator);
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/ImageLoader.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/ImageLoader.java
deleted file mode 100644
index fd480f6..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/ImageLoader.java
+++ /dev/null
@@ -1,206 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.Log;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.HashMap;
-
-/**
- * Class to load images stored in a jar file.
- * All images are loaded from /images/<var>filename</var>
- *
- * Because Java requires to know the jar file in which to load the image from, a class is required
- * when getting the instance. Instances are cached and associated to the class passed to
- * {@link #getLoader(Class)}.
- *
- * {@link #getDdmUiLibLoader()} use {@link ImageLoader#getClass()} as the class. This is to be used
- * to load images from ddmuilib.
- *
- * Loaded images are stored so that 2 calls with the same filename will return the same object.
- * This also means that {@link Image} object returned by the loader should never be disposed.
- *
- */
-public class ImageLoader {
-
- private static final String PATH = "/images/"; //$NON-NLS-1$
-
- private final HashMap<String, Image> mLoadedImages = new HashMap<String, Image>();
- private static final HashMap<Class<?>, ImageLoader> mInstances =
- new HashMap<Class<?>, ImageLoader>();
- private final Class<?> mClass;
-
- /**
- * Private constructor, creating an instance associated with a class.
- * The class is used to identify which jar file the images are loaded from.
- */
- private ImageLoader(Class<?> theClass) {
- if (theClass == null) {
- theClass = ImageLoader.class;
- }
- mClass = theClass;
- }
-
- /**
- * Returns the {@link ImageLoader} instance to load images from ddmuilib.jar
- */
- public static ImageLoader getDdmUiLibLoader() {
- return getLoader(null);
- }
-
- /**
- * Returns an {@link ImageLoader} to load images based on a given class.
- *
- * The loader will load images from the jar from which the class was loaded. using
- * {@link Class#getResource(String)} and {@link Class#getResourceAsStream(String)}.
- *
- * Since all images are loaded using the path /images/<var>filename</var>, any class from the
- * jar will work. However since the loader is cached and reused when the query provides the same
- * class instance, and since the loader will also cache the loaded images, it is recommended
- * to always use the same class for a given Jar file.
- *
- */
- public static ImageLoader getLoader(Class<?> theClass) {
- ImageLoader instance = mInstances.get(theClass);
- if (instance == null) {
- instance = new ImageLoader(theClass);
- mInstances.put(theClass, instance);
- }
-
- return instance;
- }
-
- /**
- * Disposes all images for all instances.
- * This should only be called when the program exits.
- */
- public static void dispose() {
- for (ImageLoader loader : mInstances.values()) {
- loader.doDispose();
- }
- }
-
- private synchronized void doDispose() {
- for (Image image : mLoadedImages.values()) {
- image.dispose();
- }
-
- mLoadedImages.clear();
- }
-
- /**
- * Returns an {@link ImageDescriptor} for a given filename.
- *
- * This searches for an image located at /images/<var>filename</var>.
- *
- * @param filename the filename of the image to load.
- */
- public ImageDescriptor loadDescriptor(String filename) {
- URL url = mClass.getResource(PATH + filename);
- // TODO cache in a map
- return ImageDescriptor.createFromURL(url);
- }
-
- /**
- * Returns an {@link Image} for a given filename.
- *
- * This searches for an image located at /images/<var>filename</var>.
- *
- * @param filename the filename of the image to load.
- * @param display the Display object
- */
- public synchronized Image loadImage(String filename, Display display) {
- Image img = mLoadedImages.get(filename);
- if (img == null) {
- String tmp = PATH + filename;
- InputStream imageStream = mClass.getResourceAsStream(tmp);
-
- if (imageStream != null) {
- img = new Image(display, imageStream);
- mLoadedImages.put(filename, img);
- }
-
- if (img == null) {
- throw new RuntimeException("Failed to load " + tmp);
- }
- }
-
- return img;
- }
-
- /**
- * Loads an image from a resource. This method used a class to locate the
- * resources, and then load the filename from /images inside the resources.<br>
- * Extra parameters allows for creation of a replacement image of the
- * loading failed.
- *
- * @param display the Display object
- * @param fileName the file name
- * @param width optional width to create replacement Image. If -1, null be
- * be returned if the loading fails.
- * @param height optional height to create replacement Image. If -1, null be
- * be returned if the loading fails.
- * @param phColor optional color to create replacement Image. If null, Blue
- * color will be used.
- * @return a new Image or null if the loading failed and the optional
- * replacement size was -1
- */
- public Image loadImage(Display display, String fileName, int width, int height,
- Color phColor) {
-
- Image img = loadImage(fileName, display);
-
- if (img == null) {
- Log.w("ddms", "Couldn't load " + fileName);
- // if we had the extra parameter to create replacement image then we
- // create and return it.
- if (width != -1 && height != -1) {
- return createPlaceHolderArt(display, width, height,
- phColor != null ? phColor : display
- .getSystemColor(SWT.COLOR_BLUE));
- }
-
- // otherwise, just return null
- return null;
- }
-
- return img;
- }
-
- /**
- * Create place-holder art with the specified color.
- */
- public static Image createPlaceHolderArt(Display display, int width,
- int height, Color color) {
- Image img = new Image(display, width, height);
- GC gc = new GC(img);
- gc.setForeground(color);
- gc.drawLine(0, 0, width, height);
- gc.drawLine(0, height - 1, width, -1);
- gc.dispose();
- return img;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/InfoPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/InfoPanel.java
deleted file mode 100644
index 60dc2c0..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/InfoPanel.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.AndroidDebugBridge.IClientChangeListener;
-import com.android.ddmlib.Client;
-import com.android.ddmlib.ClientData;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-
-/**
- * Display client info in a two-column format.
- */
-public class InfoPanel extends TablePanel {
- private Table mTable;
- private TableColumn mCol2;
-
- private static final String mLabels[] = {
- "DDM-aware?",
- "App description:",
- "VM version:",
- "Process ID:",
- "Supports Profiling Control:",
- "Supports HPROF Control:",
- };
- private static final int ENT_DDM_AWARE = 0;
- private static final int ENT_APP_DESCR = 1;
- private static final int ENT_VM_VERSION = 2;
- private static final int ENT_PROCESS_ID = 3;
- private static final int ENT_SUPPORTS_PROFILING = 4;
- private static final int ENT_SUPPORTS_HPROF = 5;
-
- /**
- * Create our control(s).
- */
- @Override
- protected Control createControl(Composite parent) {
- mTable = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION);
- mTable.setHeaderVisible(false);
- mTable.setLinesVisible(false);
-
- TableColumn col1 = new TableColumn(mTable, SWT.RIGHT);
- col1.setText("name");
- mCol2 = new TableColumn(mTable, SWT.LEFT);
- mCol2.setText("PlaceHolderContentForWidth");
-
- TableItem item;
- for (int i = 0; i < mLabels.length; i++) {
- item = new TableItem(mTable, SWT.NONE);
- item.setText(0, mLabels[i]);
- item.setText(1, "-");
- }
-
- col1.pack();
- mCol2.pack();
-
- return mTable;
- }
-
- /**
- * Sets the focus to the proper control inside the panel.
- */
- @Override
- public void setFocus() {
- mTable.setFocus();
- }
-
-
- /**
- * Sent when an existing client information changed.
- * <p/>
- * This is sent from a non UI thread.
- * @param client the updated client.
- * @param changeMask the bit mask describing the changed properties. It can contain
- * any of the following values: {@link Client#CHANGE_PORT}, {@link Client#CHANGE_NAME}
- * {@link Client#CHANGE_DEBUGGER_STATUS}, {@link Client#CHANGE_THREAD_MODE},
- * {@link Client#CHANGE_THREAD_DATA}, {@link Client#CHANGE_HEAP_MODE},
- * {@link Client#CHANGE_HEAP_DATA}, {@link Client#CHANGE_NATIVE_HEAP_DATA}
- *
- * @see IClientChangeListener#clientChanged(Client, int)
- */
- @Override
- public void clientChanged(final Client client, int changeMask) {
- if (client == getCurrentClient()) {
- if ((changeMask & Client.CHANGE_INFO) == Client.CHANGE_INFO) {
- if (mTable.isDisposed())
- return;
-
- mTable.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- clientSelected();
- }
- });
- }
- }
- }
-
-
- /**
- * Sent when a new device is selected. The new device can be accessed
- * with {@link #getCurrentDevice()}
- */
- @Override
- public void deviceSelected() {
- // pass
- }
-
- /**
- * Sent when a new client is selected. The new client can be accessed
- * with {@link #getCurrentClient()}
- */
- @Override
- public void clientSelected() {
- if (mTable.isDisposed())
- return;
-
- Client client = getCurrentClient();
-
- if (client == null) {
- for (int i = 0; i < mLabels.length; i++) {
- TableItem item = mTable.getItem(i);
- item.setText(1, "-");
- }
- } else {
- TableItem item;
- String clientDescription, vmIdentifier, isDdmAware,
- pid;
-
- ClientData cd = client.getClientData();
- synchronized (cd) {
- clientDescription = (cd.getClientDescription() != null) ?
- cd.getClientDescription() : "?";
- vmIdentifier = (cd.getVmIdentifier() != null) ?
- cd.getVmIdentifier() : "?";
- isDdmAware = cd.isDdmAware() ?
- "yes" : "no";
- pid = (cd.getPid() != 0) ?
- String.valueOf(cd.getPid()) : "?";
- }
-
- item = mTable.getItem(ENT_APP_DESCR);
- item.setText(1, clientDescription);
- item = mTable.getItem(ENT_VM_VERSION);
- item.setText(1, vmIdentifier);
- item = mTable.getItem(ENT_DDM_AWARE);
- item.setText(1, isDdmAware);
- item = mTable.getItem(ENT_PROCESS_ID);
- item.setText(1, pid);
-
- item = mTable.getItem(ENT_SUPPORTS_PROFILING);
- if (cd.hasFeature(ClientData.FEATURE_PROFILING_STREAMING)) {
- item.setText(1, "Yes");
- } else if (cd.hasFeature(ClientData.FEATURE_PROFILING)) {
- item.setText(1, "Yes (Application must be able to write on the SD Card)");
- } else {
- item.setText(1, "No");
- }
-
- item = mTable.getItem(ENT_SUPPORTS_HPROF);
- if (cd.hasFeature(ClientData.FEATURE_HPROF_STREAMING)) {
- item.setText(1, "Yes");
- } else if (cd.hasFeature(ClientData.FEATURE_HPROF)) {
- item.setText(1, "Yes (Application must be able to write on the SD Card)");
- } else {
- item.setText(1, "No");
- }
- }
-
- mCol2.pack();
-
- //Log.i("ddms", "InfoPanel: changed " + client);
- }
-
- @Override
- protected void setTableFocusListener() {
- addTableToFocusListener(mTable);
- }
-}
-
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/NativeHeapPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/NativeHeapPanel.java
deleted file mode 100644
index 337bff2..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/NativeHeapPanel.java
+++ /dev/null
@@ -1,1648 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.AndroidDebugBridge.IClientChangeListener;
-import com.android.ddmlib.Client;
-import com.android.ddmlib.ClientData;
-import com.android.ddmlib.HeapSegment.HeapSegmentElement;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.NativeAllocationInfo;
-import com.android.ddmlib.NativeLibraryMapInfo;
-import com.android.ddmlib.NativeStackCallInfo;
-import com.android.ddmuilib.annotation.WorkerThread;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.PaletteData;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Sash;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.text.DecimalFormat;
-import java.text.NumberFormat;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Panel with native heap information.
- */
-public final class NativeHeapPanel extends BaseHeapPanel {
-
- /** color palette and map legend. NATIVE is the last enum is a 0 based enum list, so we need
- * Native+1 at least. We also need 2 more entries for free area and expansion area. */
- private static final int NUM_PALETTE_ENTRIES = HeapSegmentElement.KIND_NATIVE+2 +1;
- private static final String[] mMapLegend = new String[NUM_PALETTE_ENTRIES];
- private static final PaletteData mMapPalette = createPalette();
-
- private static final int ALLOC_DISPLAY_ALL = 0;
- private static final int ALLOC_DISPLAY_PRE_ZYGOTE = 1;
- private static final int ALLOC_DISPLAY_POST_ZYGOTE = 2;
-
- private Display mDisplay;
-
- private Composite mBase;
-
- private Label mUpdateStatus;
-
- /** combo giving choice of what to display: all, pre-zygote, post-zygote */
- private Combo mAllocDisplayCombo;
-
- private Button mFullUpdateButton;
-
- // see CreateControl()
- //private Button mDiffUpdateButton;
-
- private Combo mDisplayModeCombo;
-
- /** stack composite for mode (1-2) & 3 */
- private Composite mTopStackComposite;
-
- private StackLayout mTopStackLayout;
-
- /** stack composite for mode 1 & 2 */
- private Composite mAllocationStackComposite;
-
- private StackLayout mAllocationStackLayout;
-
- /** top level container for mode 1 & 2 */
- private Composite mTableModeControl;
-
- /** top level object for the allocation mode */
- private Control mAllocationModeTop;
-
- /** top level for the library mode */
- private Control mLibraryModeTopControl;
-
- /** composite for page UI and total memory display */
- private Composite mPageUIComposite;
-
- private Label mTotalMemoryLabel;
-
- private Label mPageLabel;
-
- private Button mPageNextButton;
-
- private Button mPagePreviousButton;
-
- private Table mAllocationTable;
-
- private Table mLibraryTable;
-
- private Table mLibraryAllocationTable;
-
- private Table mDetailTable;
-
- private Label mImage;
-
- private int mAllocDisplayMode = ALLOC_DISPLAY_ALL;
-
- /**
- * pointer to current stackcall thread computation in order to quit it if
- * required (new update requested)
- */
- private StackCallThread mStackCallThread;
-
- /** Current Library Allocation table fill thread. killed if selection changes */
- private FillTableThread mFillTableThread;
-
- /**
- * current client data. Used to access the malloc info when switching pages
- * or selecting allocation to show stack call
- */
- private ClientData mClientData;
-
- /**
- * client data from a previous display. used when asking for an "update & diff"
- */
- private ClientData mBackUpClientData;
-
- /** list of NativeAllocationInfo objects filled with the list from ClientData */
- private final ArrayList<NativeAllocationInfo> mAllocations =
- new ArrayList<NativeAllocationInfo>();
-
- /** list of the {@link NativeAllocationInfo} being displayed based on the selection
- * of {@link #mAllocDisplayCombo}.
- */
- private final ArrayList<NativeAllocationInfo> mDisplayedAllocations =
- new ArrayList<NativeAllocationInfo>();
-
- /** list of NativeAllocationInfo object kept as backup when doing an "update & diff" */
- private final ArrayList<NativeAllocationInfo> mBackUpAllocations =
- new ArrayList<NativeAllocationInfo>();
-
- /** back up of the total memory, used when doing an "update & diff" */
- private int mBackUpTotalMemory;
-
- private int mCurrentPage = 0;
-
- private int mPageCount = 0;
-
- /**
- * list of allocation per Library. This is created from the list of
- * NativeAllocationInfo objects that is stored in the ClientData object. Since we
- * don't keep this list around, it is recomputed everytime the client
- * changes.
- */
- private final ArrayList<LibraryAllocations> mLibraryAllocations =
- new ArrayList<LibraryAllocations>();
-
- /* args to setUpdateStatus() */
- private static final int NOT_SELECTED = 0;
-
- private static final int NOT_ENABLED = 1;
-
- private static final int ENABLED = 2;
-
- private static final int DISPLAY_PER_PAGE = 20;
-
- private static final String PREFS_ALLOCATION_SASH = "NHallocSash"; //$NON-NLS-1$
- private static final String PREFS_LIBRARY_SASH = "NHlibrarySash"; //$NON-NLS-1$
- private static final String PREFS_DETAIL_ADDRESS = "NHdetailAddress"; //$NON-NLS-1$
- private static final String PREFS_DETAIL_LIBRARY = "NHdetailLibrary"; //$NON-NLS-1$
- private static final String PREFS_DETAIL_METHOD = "NHdetailMethod"; //$NON-NLS-1$
- private static final String PREFS_DETAIL_FILE = "NHdetailFile"; //$NON-NLS-1$
- private static final String PREFS_DETAIL_LINE = "NHdetailLine"; //$NON-NLS-1$
- private static final String PREFS_ALLOC_TOTAL = "NHallocTotal"; //$NON-NLS-1$
- private static final String PREFS_ALLOC_COUNT = "NHallocCount"; //$NON-NLS-1$
- private static final String PREFS_ALLOC_SIZE = "NHallocSize"; //$NON-NLS-1$
- private static final String PREFS_ALLOC_LIBRARY = "NHallocLib"; //$NON-NLS-1$
- private static final String PREFS_ALLOC_METHOD = "NHallocMethod"; //$NON-NLS-1$
- private static final String PREFS_ALLOC_FILE = "NHallocFile"; //$NON-NLS-1$
- private static final String PREFS_LIB_LIBRARY = "NHlibLibrary"; //$NON-NLS-1$
- private static final String PREFS_LIB_SIZE = "NHlibSize"; //$NON-NLS-1$
- private static final String PREFS_LIB_COUNT = "NHlibCount"; //$NON-NLS-1$
- private static final String PREFS_LIBALLOC_TOTAL = "NHlibAllocTotal"; //$NON-NLS-1$
- private static final String PREFS_LIBALLOC_COUNT = "NHlibAllocCount"; //$NON-NLS-1$
- private static final String PREFS_LIBALLOC_SIZE = "NHlibAllocSize"; //$NON-NLS-1$
- private static final String PREFS_LIBALLOC_METHOD = "NHlibAllocMethod"; //$NON-NLS-1$
-
- /** static formatter object to format all numbers as #,### */
- private static DecimalFormat sFormatter;
- static {
- sFormatter = (DecimalFormat)NumberFormat.getInstance();
- if (sFormatter == null) {
- sFormatter = new DecimalFormat("#,###");
- } else {
- sFormatter.applyPattern("#,###");
- }
- }
-
-
- /**
- * caching mechanism to avoid recomputing the backtrace for a particular
- * address several times.
- */
- private HashMap<Long, NativeStackCallInfo> mSourceCache =
- new HashMap<Long, NativeStackCallInfo>();
- private long mTotalSize;
- private Button mSaveButton;
- private Button mSymbolsButton;
-
- /**
- * thread class to convert the address call into method, file and line
- * number in the background.
- */
- private class StackCallThread extends BackgroundThread {
- private ClientData mClientData;
-
- public StackCallThread(ClientData cd) {
- mClientData = cd;
- }
-
- public ClientData getClientData() {
- return mClientData;
- }
-
- @Override
- public void run() {
- // loop through all the NativeAllocationInfo and init them
- Iterator<NativeAllocationInfo> iter = mAllocations.iterator();
- int total = mAllocations.size();
- int count = 0;
- while (iter.hasNext()) {
-
- if (isQuitting())
- return;
-
- NativeAllocationInfo info = iter.next();
- if (info.isStackCallResolved() == false) {
- final List<Long> list = info.getStackCallAddresses();
- final int size = list.size();
-
- ArrayList<NativeStackCallInfo> resolvedStackCall =
- new ArrayList<NativeStackCallInfo>();
-
- for (int i = 0; i < size; i++) {
- long addr = list.get(i);
-
- // first check if the addr has already been converted.
- NativeStackCallInfo source = mSourceCache.get(addr);
-
- // if not we convert it
- if (source == null) {
- source = sourceForAddr(addr);
- mSourceCache.put(addr, source);
- }
-
- resolvedStackCall.add(source);
- }
-
- info.setResolvedStackCall(resolvedStackCall);
- }
- // after every DISPLAY_PER_PAGE we ask for a ui refresh, unless
- // we reach total, since we also do it after the loop
- // (only an issue in case we have a perfect number of page)
- count++;
- if ((count % DISPLAY_PER_PAGE) == 0 && count != total) {
- if (updateNHAllocationStackCalls(mClientData, count) == false) {
- // looks like the app is quitting, so we just
- // stopped the thread
- return;
- }
- }
- }
-
- updateNHAllocationStackCalls(mClientData, count);
- }
-
- private NativeStackCallInfo sourceForAddr(long addr) {
- NativeLibraryMapInfo library = getLibraryFor(addr);
-
- if (library != null) {
-
- Addr2Line process = Addr2Line.getProcess(library);
- if (process != null) {
- // remove the base of the library address
- NativeStackCallInfo info = process.getAddress(addr);
- if (info != null) {
- return info;
- }
- }
- }
-
- return new NativeStackCallInfo(addr,
- library != null ? library.getLibraryName() : null,
- Long.toHexString(addr),
- "");
- }
-
- private NativeLibraryMapInfo getLibraryFor(long addr) {
- for (NativeLibraryMapInfo info : mClientData.getMappedNativeLibraries()) {
- if (info.isWithinLibrary(addr)) {
- return info;
- }
- }
-
- Log.d("ddm-nativeheap", "Failed finding Library for " + Long.toHexString(addr));
- return null;
- }
-
- /**
- * update the Native Heap panel with the amount of allocation for which the
- * stack call has been computed. This is called from a non UI thread, but
- * will be executed in the UI thread.
- *
- * @param count the amount of allocation
- * @return false if the display was disposed and the update couldn't happen
- */
- private boolean updateNHAllocationStackCalls(final ClientData clientData, final int count) {
- if (mDisplay.isDisposed() == false) {
- mDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- updateAllocationStackCalls(clientData, count);
- }
- });
- return true;
- }
- return false;
- }
- }
-
- private class FillTableThread extends BackgroundThread {
- private LibraryAllocations mLibAlloc;
-
- private int mMax;
-
- public FillTableThread(LibraryAllocations liballoc, int m) {
- mLibAlloc = liballoc;
- mMax = m;
- }
-
- @Override
- public void run() {
- for (int i = mMax; i > 0 && isQuitting() == false; i -= 10) {
- updateNHLibraryAllocationTable(mLibAlloc, mMax - i, mMax - i + 10);
- }
- }
-
- /**
- * updates the library allocation table in the Native Heap panel. This is
- * called from a non UI thread, but will be executed in the UI thread.
- *
- * @param liballoc the current library allocation object being displayed
- * @param start start index of items that need to be displayed
- * @param end end index of the items that need to be displayed
- */
- private void updateNHLibraryAllocationTable(final LibraryAllocations libAlloc,
- final int start, final int end) {
- if (mDisplay.isDisposed() == false) {
- mDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- updateLibraryAllocationTable(libAlloc, start, end);
- }
- });
- }
-
- }
- }
-
- /** class to aggregate allocations per library */
- public static class LibraryAllocations {
- private String mLibrary;
-
- private final ArrayList<NativeAllocationInfo> mLibAllocations =
- new ArrayList<NativeAllocationInfo>();
-
- private int mSize;
-
- private int mCount;
-
- /** construct the aggregate object for a library */
- public LibraryAllocations(final String lib) {
- mLibrary = lib;
- }
-
- /** get the library name */
- public String getLibrary() {
- return mLibrary;
- }
-
- /** add a NativeAllocationInfo object to this aggregate object */
- public void addAllocation(NativeAllocationInfo info) {
- mLibAllocations.add(info);
- }
-
- /** get an iterator on the NativeAllocationInfo objects */
- public Iterator<NativeAllocationInfo> getAllocations() {
- return mLibAllocations.iterator();
- }
-
- /** get a NativeAllocationInfo object by index */
- public NativeAllocationInfo getAllocation(int index) {
- return mLibAllocations.get(index);
- }
-
- /** returns the NativeAllocationInfo object count */
- public int getAllocationSize() {
- return mLibAllocations.size();
- }
-
- /** returns the total allocation size */
- public int getSize() {
- return mSize;
- }
-
- /** returns the number of allocations */
- public int getCount() {
- return mCount;
- }
-
- /**
- * compute the allocation count and size for allocation objects added
- * through <code>addAllocation()</code>, and sort the objects by
- * total allocation size.
- */
- public void computeAllocationSizeAndCount() {
- mSize = 0;
- mCount = 0;
- for (NativeAllocationInfo info : mLibAllocations) {
- mCount += info.getAllocationCount();
- mSize += info.getAllocationCount() * info.getSize();
- }
- Collections.sort(mLibAllocations, new Comparator<NativeAllocationInfo>() {
- @Override
- public int compare(NativeAllocationInfo o1, NativeAllocationInfo o2) {
- return o2.getAllocationCount() * o2.getSize() -
- o1.getAllocationCount() * o1.getSize();
- }
- });
- }
- }
-
- /**
- * Create our control(s).
- */
- @Override
- protected Control createControl(Composite parent) {
-
- mDisplay = parent.getDisplay();
-
- mBase = new Composite(parent, SWT.NONE);
- GridLayout gl = new GridLayout(1, false);
- gl.horizontalSpacing = 0;
- gl.verticalSpacing = 0;
- mBase.setLayout(gl);
- mBase.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // composite for <update btn> <status>
- Composite tmp = new Composite(mBase, SWT.NONE);
- tmp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- tmp.setLayout(gl = new GridLayout(2, false));
- gl.marginWidth = gl.marginHeight = 0;
-
- mFullUpdateButton = new Button(tmp, SWT.NONE);
- mFullUpdateButton.setText("Full Update");
- mFullUpdateButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mBackUpClientData = null;
- mDisplayModeCombo.setEnabled(false);
- mSaveButton.setEnabled(false);
- emptyTables();
- // if we already have a stack call computation for this
- // client
- // we stop it
- if (mStackCallThread != null &&
- mStackCallThread.getClientData() == mClientData) {
- mStackCallThread.quit();
- mStackCallThread = null;
- }
- mLibraryAllocations.clear();
- Client client = getCurrentClient();
- if (client != null) {
- client.requestNativeHeapInformation();
- }
- }
- });
-
- mUpdateStatus = new Label(tmp, SWT.NONE);
- mUpdateStatus.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // top layout for the combos and oter controls on the right.
- Composite top_layout = new Composite(mBase, SWT.NONE);
- top_layout.setLayout(gl = new GridLayout(4, false));
- gl.marginWidth = gl.marginHeight = 0;
-
- new Label(top_layout, SWT.NONE).setText("Show:");
-
- mAllocDisplayCombo = new Combo(top_layout, SWT.DROP_DOWN | SWT.READ_ONLY);
- mAllocDisplayCombo.setLayoutData(new GridData(
- GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
- mAllocDisplayCombo.add("All Allocations");
- mAllocDisplayCombo.add("Pre-Zygote Allocations");
- mAllocDisplayCombo.add("Zygote Child Allocations (Z)");
- mAllocDisplayCombo.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- onAllocDisplayChange();
- }
- });
- mAllocDisplayCombo.select(0);
-
- // separator
- Label separator = new Label(top_layout, SWT.SEPARATOR | SWT.VERTICAL);
- GridData gd;
- separator.setLayoutData(gd = new GridData(
- GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_VERTICAL));
- gd.heightHint = 0;
- gd.verticalSpan = 2;
-
- mSaveButton = new Button(top_layout, SWT.PUSH);
- mSaveButton.setText("Save...");
- mSaveButton.setEnabled(false);
- mSaveButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- FileDialog fileDialog = new FileDialog(mBase.getShell(), SWT.SAVE);
-
- fileDialog.setText("Save Allocations");
- fileDialog.setFileName("allocations.txt");
-
- String fileName = fileDialog.open();
- if (fileName != null) {
- saveAllocations(fileName);
- }
- }
- });
-
- /*
- * TODO: either fix the diff mechanism or remove it altogether.
- mDiffUpdateButton = new Button(top_layout, SWT.NONE);
- mDiffUpdateButton.setText("Update && Diff");
- mDiffUpdateButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // since this is an update and diff, we need to store the
- // current list
- // of mallocs
- mBackUpAllocations.clear();
- mBackUpAllocations.addAll(mAllocations);
- mBackUpClientData = mClientData;
- mBackUpTotalMemory = mClientData.getTotalNativeMemory();
-
- mDisplayModeCombo.setEnabled(false);
- emptyTables();
- // if we already have a stack call computation for this
- // client
- // we stop it
- if (mStackCallThread != null &&
- mStackCallThread.getClientData() == mClientData) {
- mStackCallThread.quit();
- mStackCallThread = null;
- }
- mLibraryAllocations.clear();
- Client client = getCurrentClient();
- if (client != null) {
- client.requestNativeHeapInformation();
- }
- }
- });
- */
-
- Label l = new Label(top_layout, SWT.NONE);
- l.setText("Display:");
-
- mDisplayModeCombo = new Combo(top_layout, SWT.DROP_DOWN | SWT.READ_ONLY);
- mDisplayModeCombo.setLayoutData(new GridData(
- GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
- mDisplayModeCombo.setItems(new String[] { "Allocation List", "By Libraries" });
- mDisplayModeCombo.select(0);
- mDisplayModeCombo.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- switchDisplayMode();
- }
- });
- mDisplayModeCombo.setEnabled(false);
-
- mSymbolsButton = new Button(top_layout, SWT.PUSH);
- mSymbolsButton.setText("Load Symbols");
- mSymbolsButton.setEnabled(false);
-
-
- // create a composite that will contains the actual content composites,
- // in stack mode layout.
- // This top level composite contains 2 other composites.
- // * one for both Allocations and Libraries mode
- // * one for flat mode (which is gone for now)
-
- mTopStackComposite = new Composite(mBase, SWT.NONE);
- mTopStackComposite.setLayout(mTopStackLayout = new StackLayout());
- mTopStackComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // create 1st and 2nd modes
- createTableDisplay(mTopStackComposite);
-
- mTopStackLayout.topControl = mTableModeControl;
- mTopStackComposite.layout();
-
- setUpdateStatus(NOT_SELECTED);
-
- // Work in progress
- // TODO add image display of native heap.
- //mImage = new Label(mBase, SWT.NONE);
-
- mBase.pack();
-
- return mBase;
- }
-
- /**
- * Sets the focus to the proper control inside the panel.
- */
- @Override
- public void setFocus() {
- // TODO
- }
-
-
- /**
- * Sent when an existing client information changed.
- * <p/>
- * This is sent from a non UI thread.
- * @param client the updated client.
- * @param changeMask the bit mask describing the changed properties. It can contain
- * any of the following values: {@link Client#CHANGE_INFO}, {@link Client#CHANGE_NAME}
- * {@link Client#CHANGE_DEBUGGER_STATUS}, {@link Client#CHANGE_THREAD_MODE},
- * {@link Client#CHANGE_THREAD_DATA}, {@link Client#CHANGE_HEAP_MODE},
- * {@link Client#CHANGE_HEAP_DATA}, {@link Client#CHANGE_NATIVE_HEAP_DATA}
- *
- * @see IClientChangeListener#clientChanged(Client, int)
- */
- @Override
- public void clientChanged(final Client client, int changeMask) {
- if (client == getCurrentClient()) {
- if ((changeMask & Client.CHANGE_NATIVE_HEAP_DATA) == Client.CHANGE_NATIVE_HEAP_DATA) {
- if (mBase.isDisposed())
- return;
-
- mBase.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- clientSelected();
- }
- });
- }
- }
- }
-
- /**
- * Sent when a new device is selected. The new device can be accessed
- * with {@link #getCurrentDevice()}.
- */
- @Override
- public void deviceSelected() {
- // pass
- }
-
- /**
- * Sent when a new client is selected. The new client can be accessed
- * with {@link #getCurrentClient()}.
- */
- @Override
- public void clientSelected() {
- if (mBase.isDisposed())
- return;
-
- Client client = getCurrentClient();
-
- mDisplayModeCombo.setEnabled(false);
- emptyTables();
-
- Log.d("ddms", "NativeHeapPanel: changed " + client);
-
- if (client != null) {
- ClientData cd = client.getClientData();
- mClientData = cd;
-
- // if (cd.getShowHeapUpdates())
- setUpdateStatus(ENABLED);
- // else
- // setUpdateStatus(NOT_ENABLED);
-
- initAllocationDisplay();
-
- //renderBitmap(cd);
- } else {
- mClientData = null;
- setUpdateStatus(NOT_SELECTED);
- }
-
- mBase.pack();
- }
-
- /**
- * Update the UI with the newly compute stack calls, unless the UI switched
- * to a different client.
- *
- * @param cd the ClientData for which the stack call are being computed.
- * @param count the current count of allocations for which the stack calls
- * have been computed.
- */
- @WorkerThread
- public void updateAllocationStackCalls(ClientData cd, int count) {
- // we have to check that the panel still shows the same clientdata than
- // the thread is computing for.
- if (cd == mClientData) {
-
- int total = mAllocations.size();
-
- if (count == total) {
- // we're done: do something
- mDisplayModeCombo.setEnabled(true);
- mSaveButton.setEnabled(true);
-
- mStackCallThread = null;
- } else {
- // work in progress, update the progress bar.
-// mUiThread.setStatusLine("Computing stack call: " + count
-// + "/" + total);
- }
-
- // FIXME: attempt to only update when needed.
- // Because the number of pages is not related to mAllocations.size() anymore
- // due to pre-zygote/post-zygote display, update all the time.
- // At some point we should remove the pages anyway, since it's getting computed
- // really fast now.
-// if ((mCurrentPage + 1) * DISPLAY_PER_PAGE == count
-// || (count == total && mCurrentPage == mPageCount - 1)) {
- try {
- // get the current selection of the allocation
- int index = mAllocationTable.getSelectionIndex();
- NativeAllocationInfo info = null;
-
- if (index != -1) {
- info = (NativeAllocationInfo)mAllocationTable.getItem(index).getData();
- }
-
- // empty the table
- emptyTables();
-
- // fill it again
- fillAllocationTable();
-
- // reselect
- mAllocationTable.setSelection(index);
-
- // display detail table if needed
- if (info != null) {
- fillDetailTable(info);
- }
- } catch (SWTException e) {
- if (mAllocationTable.isDisposed()) {
- // looks like the table is disposed. Let's ignore it.
- } else {
- throw e;
- }
- }
-
- } else {
- // old client still running. doesn't really matter.
- }
- }
-
- @Override
- protected void setTableFocusListener() {
- addTableToFocusListener(mAllocationTable);
- addTableToFocusListener(mLibraryTable);
- addTableToFocusListener(mLibraryAllocationTable);
- addTableToFocusListener(mDetailTable);
- }
-
- protected void onAllocDisplayChange() {
- mAllocDisplayMode = mAllocDisplayCombo.getSelectionIndex();
-
- // create the new list
- updateAllocDisplayList();
-
- updateTotalMemoryDisplay();
-
- // reset the ui.
- mCurrentPage = 0;
- updatePageUI();
- switchDisplayMode();
- }
-
- private void updateAllocDisplayList() {
- mTotalSize = 0;
- mDisplayedAllocations.clear();
- for (NativeAllocationInfo info : mAllocations) {
- if (mAllocDisplayMode == ALLOC_DISPLAY_ALL ||
- (mAllocDisplayMode == ALLOC_DISPLAY_PRE_ZYGOTE ^ info.isZygoteChild())) {
- mDisplayedAllocations.add(info);
- mTotalSize += info.getSize() * info.getAllocationCount();
- } else {
- // skip this item
- continue;
- }
- }
-
- int count = mDisplayedAllocations.size();
-
- mPageCount = count / DISPLAY_PER_PAGE;
-
- // need to add a page for the rest of the div
- if ((count % DISPLAY_PER_PAGE) > 0) {
- mPageCount++;
- }
- }
-
- private void updateTotalMemoryDisplay() {
- switch (mAllocDisplayMode) {
- case ALLOC_DISPLAY_ALL:
- mTotalMemoryLabel.setText(String.format("Total Memory: %1$s Bytes",
- sFormatter.format(mTotalSize)));
- break;
- case ALLOC_DISPLAY_PRE_ZYGOTE:
- mTotalMemoryLabel.setText(String.format("Zygote Memory: %1$s Bytes",
- sFormatter.format(mTotalSize)));
- break;
- case ALLOC_DISPLAY_POST_ZYGOTE:
- mTotalMemoryLabel.setText(String.format("Post-zygote Memory: %1$s Bytes",
- sFormatter.format(mTotalSize)));
- break;
- }
- }
-
-
- private void switchDisplayMode() {
- switch (mDisplayModeCombo.getSelectionIndex()) {
- case 0: {// allocations
- mTopStackLayout.topControl = mTableModeControl;
- mAllocationStackLayout.topControl = mAllocationModeTop;
- mAllocationStackComposite.layout();
- mTopStackComposite.layout();
- emptyTables();
- fillAllocationTable();
- }
- break;
- case 1: {// libraries
- mTopStackLayout.topControl = mTableModeControl;
- mAllocationStackLayout.topControl = mLibraryModeTopControl;
- mAllocationStackComposite.layout();
- mTopStackComposite.layout();
- emptyTables();
- fillLibraryTable();
- }
- break;
- }
- }
-
- private void initAllocationDisplay() {
- if (mStackCallThread != null) {
- mStackCallThread.quit();
- }
-
- mAllocations.clear();
- mAllocations.addAll(mClientData.getNativeAllocationList());
-
- updateAllocDisplayList();
-
- // if we have a previous clientdata and it matches the current one. we
- // do a diff between the new list and the old one.
- if (mBackUpClientData != null && mBackUpClientData == mClientData) {
-
- ArrayList<NativeAllocationInfo> add = new ArrayList<NativeAllocationInfo>();
-
- // we go through the list of NativeAllocationInfo in the new list and check if
- // there's one with the same exact data (size, allocation, count and
- // stackcall addresses) in the old list.
- // if we don't find any, we add it to the "add" list
- for (NativeAllocationInfo mi : mAllocations) {
- boolean found = false;
- for (NativeAllocationInfo old_mi : mBackUpAllocations) {
- if (mi.equals(old_mi)) {
- found = true;
- break;
- }
- }
- if (found == false) {
- add.add(mi);
- }
- }
-
- // put the result in mAllocations
- mAllocations.clear();
- mAllocations.addAll(add);
-
- // display the difference in memory usage. This is computed
- // calculating the memory usage of the objects in mAllocations.
- int count = 0;
- for (NativeAllocationInfo allocInfo : mAllocations) {
- count += allocInfo.getSize() * allocInfo.getAllocationCount();
- }
-
- mTotalMemoryLabel.setText(String.format("Memory Difference: %1$s Bytes",
- sFormatter.format(count)));
- }
- else {
- // display the full memory usage
- updateTotalMemoryDisplay();
- //mDiffUpdateButton.setEnabled(mClientData.getTotalNativeMemory() > 0);
- }
- mTotalMemoryLabel.pack();
-
- // update the page ui
- mDisplayModeCombo.select(0);
-
- mLibraryAllocations.clear();
-
- // reset to first page
- mCurrentPage = 0;
-
- // update the label
- updatePageUI();
-
- // now fill the allocation Table with the current page
- switchDisplayMode();
-
- // start the thread to compute the stack calls
- if (mAllocations.size() > 0) {
- mStackCallThread = new StackCallThread(mClientData);
- mStackCallThread.start();
- }
- }
-
- private void updatePageUI() {
-
- // set the label and pack to update the layout, otherwise
- // the label will be cut off if the new size is bigger
- if (mPageCount == 0) {
- mPageLabel.setText("0 of 0 allocations.");
- } else {
- StringBuffer buffer = new StringBuffer();
- // get our starting index
- int start = (mCurrentPage * DISPLAY_PER_PAGE) + 1;
- // end index, taking into account the last page can be half full
- int count = mDisplayedAllocations.size();
- int end = Math.min(start + DISPLAY_PER_PAGE - 1, count);
- buffer.append(sFormatter.format(start));
- buffer.append(" - ");
- buffer.append(sFormatter.format(end));
- buffer.append(" of ");
- buffer.append(sFormatter.format(count));
- buffer.append(" allocations.");
- mPageLabel.setText(buffer.toString());
- }
-
- // handle the button enabled state.
- mPagePreviousButton.setEnabled(mCurrentPage > 0);
- // reminder: mCurrentPage starts at 0.
- mPageNextButton.setEnabled(mCurrentPage < mPageCount - 1);
-
- mPageLabel.pack();
- mPageUIComposite.pack();
-
- }
-
- private void fillAllocationTable() {
- // get the count
- int count = mDisplayedAllocations.size();
-
- // get our starting index
- int start = mCurrentPage * DISPLAY_PER_PAGE;
-
- // loop for DISPLAY_PER_PAGE or till we reach count
- int end = start + DISPLAY_PER_PAGE;
-
- for (int i = start; i < end && i < count; i++) {
- NativeAllocationInfo info = mDisplayedAllocations.get(i);
-
- TableItem item = null;
-
- if (mAllocDisplayMode == ALLOC_DISPLAY_ALL) {
- item = new TableItem(mAllocationTable, SWT.NONE);
- item.setText(0, (info.isZygoteChild() ? "Z " : "") +
- sFormatter.format(info.getSize() * info.getAllocationCount()));
- item.setText(1, sFormatter.format(info.getAllocationCount()));
- item.setText(2, sFormatter.format(info.getSize()));
- } else if (mAllocDisplayMode == ALLOC_DISPLAY_PRE_ZYGOTE ^ info.isZygoteChild()) {
- item = new TableItem(mAllocationTable, SWT.NONE);
- item.setText(0, sFormatter.format(info.getSize() * info.getAllocationCount()));
- item.setText(1, sFormatter.format(info.getAllocationCount()));
- item.setText(2, sFormatter.format(info.getSize()));
- } else {
- // skip this item
- continue;
- }
-
- item.setData(info);
-
- NativeStackCallInfo bti = info.getRelevantStackCallInfo();
- if (bti != null) {
- String lib = bti.getLibraryName();
- String method = bti.getMethodName();
- String source = bti.getSourceFile();
- if (lib != null)
- item.setText(3, lib);
- if (method != null)
- item.setText(4, method);
- if (source != null)
- item.setText(5, source);
- }
- }
- }
-
- private void fillLibraryTable() {
- // fill the library table
- sortAllocationsPerLibrary();
-
- for (LibraryAllocations liballoc : mLibraryAllocations) {
- if (liballoc != null) {
- TableItem item = new TableItem(mLibraryTable, SWT.NONE);
- String lib = liballoc.getLibrary();
- item.setText(0, lib != null ? lib : "");
- item.setText(1, sFormatter.format(liballoc.getSize()));
- item.setText(2, sFormatter.format(liballoc.getCount()));
- }
- }
- }
-
- private void fillLibraryAllocationTable() {
- mLibraryAllocationTable.removeAll();
- mDetailTable.removeAll();
- int index = mLibraryTable.getSelectionIndex();
- if (index != -1) {
- LibraryAllocations liballoc = mLibraryAllocations.get(index);
- // start a thread that will fill table 10 at a time to keep the ui
- // responsive, but first we kill the previous one if there was one
- if (mFillTableThread != null) {
- mFillTableThread.quit();
- }
- mFillTableThread = new FillTableThread(liballoc,
- liballoc.getAllocationSize());
- mFillTableThread.start();
- }
- }
-
- public void updateLibraryAllocationTable(LibraryAllocations liballoc,
- int start, int end) {
- try {
- if (mLibraryTable.isDisposed() == false) {
- int index = mLibraryTable.getSelectionIndex();
- if (index != -1) {
- LibraryAllocations newliballoc = mLibraryAllocations.get(
- index);
- if (newliballoc == liballoc) {
- int count = liballoc.getAllocationSize();
- for (int i = start; i < end && i < count; i++) {
- NativeAllocationInfo info = liballoc.getAllocation(i);
-
- TableItem item = new TableItem(
- mLibraryAllocationTable, SWT.NONE);
- item.setText(0, sFormatter.format(
- info.getSize() * info.getAllocationCount()));
- item.setText(1, sFormatter.format(info.getAllocationCount()));
- item.setText(2, sFormatter.format(info.getSize()));
-
- NativeStackCallInfo stackCallInfo = info.getRelevantStackCallInfo();
- if (stackCallInfo != null) {
- item.setText(3, stackCallInfo.getMethodName());
- }
- }
- } else {
- // we should quit the thread
- if (mFillTableThread != null) {
- mFillTableThread.quit();
- mFillTableThread = null;
- }
- }
- }
- }
- } catch (SWTException e) {
- Log.e("ddms", "error when updating the library allocation table");
- }
- }
-
- private void fillDetailTable(final NativeAllocationInfo mi) {
- mDetailTable.removeAll();
- mDetailTable.setRedraw(false);
-
- try {
- // populate the detail Table with the back trace
- List<Long> addresses = mi.getStackCallAddresses();
- List<NativeStackCallInfo> resolvedStackCall = mi.getResolvedStackCall();
-
- if (resolvedStackCall == null) {
- return;
- }
-
- for (int i = 0 ; i < resolvedStackCall.size(); i++) {
- if (addresses.get(i) == null || addresses.get(i).longValue() == 0) {
- continue;
- }
-
- long addr = addresses.get(i).longValue();
- NativeStackCallInfo source = resolvedStackCall.get(i);
-
- TableItem item = new TableItem(mDetailTable, SWT.NONE);
- item.setText(0, String.format("%08x", addr)); //$NON-NLS-1$
-
- String libraryName = source.getLibraryName();
- String methodName = source.getMethodName();
- String sourceFile = source.getSourceFile();
- int lineNumber = source.getLineNumber();
-
- if (libraryName != null)
- item.setText(1, libraryName);
- if (methodName != null)
- item.setText(2, methodName);
- if (sourceFile != null)
- item.setText(3, sourceFile);
- if (lineNumber != -1)
- item.setText(4, Integer.toString(lineNumber));
- }
- } finally {
- mDetailTable.setRedraw(true);
- }
- }
-
- /*
- * Are updates enabled?
- */
- private void setUpdateStatus(int status) {
- switch (status) {
- case NOT_SELECTED:
- mUpdateStatus.setText("Select a client to see heap info");
- mAllocDisplayCombo.setEnabled(false);
- mFullUpdateButton.setEnabled(false);
- //mDiffUpdateButton.setEnabled(false);
- break;
- case NOT_ENABLED:
- mUpdateStatus.setText("Heap updates are " + "NOT ENABLED for this client");
- mAllocDisplayCombo.setEnabled(false);
- mFullUpdateButton.setEnabled(false);
- //mDiffUpdateButton.setEnabled(false);
- break;
- case ENABLED:
- mUpdateStatus.setText("Press 'Full Update' to retrieve " + "latest data");
- mAllocDisplayCombo.setEnabled(true);
- mFullUpdateButton.setEnabled(true);
- //mDiffUpdateButton.setEnabled(true);
- break;
- default:
- throw new RuntimeException();
- }
-
- mUpdateStatus.pack();
- }
-
- /**
- * Create the Table display. This includes a "detail" Table in the bottom
- * half and 2 modes in the top half: allocation Table and
- * library+allocations Tables.
- *
- * @param base the top parent to create the display into
- */
- private void createTableDisplay(Composite base) {
- final int minPanelWidth = 60;
-
- final IPreferenceStore prefs = DdmUiPreferences.getStore();
-
- // top level composite for mode 1 & 2
- mTableModeControl = new Composite(base, SWT.NONE);
- GridLayout gl = new GridLayout(1, false);
- gl.marginLeft = gl.marginRight = gl.marginTop = gl.marginBottom = 0;
- mTableModeControl.setLayout(gl);
- mTableModeControl.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- mTotalMemoryLabel = new Label(mTableModeControl, SWT.NONE);
- mTotalMemoryLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mTotalMemoryLabel.setText("Total Memory: 0 Bytes");
-
- // the top half of these modes is dynamic
-
- final Composite sash_composite = new Composite(mTableModeControl,
- SWT.NONE);
- sash_composite.setLayout(new FormLayout());
- sash_composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // create the stacked composite
- mAllocationStackComposite = new Composite(sash_composite, SWT.NONE);
- mAllocationStackLayout = new StackLayout();
- mAllocationStackComposite.setLayout(mAllocationStackLayout);
- mAllocationStackComposite.setLayoutData(new GridData(
- GridData.FILL_BOTH));
-
- // create the top half for mode 1
- createAllocationTopHalf(mAllocationStackComposite);
-
- // create the top half for mode 2
- createLibraryTopHalf(mAllocationStackComposite);
-
- final Sash sash = new Sash(sash_composite, SWT.HORIZONTAL);
-
- // bottom half of these modes is the same: detail table
- createDetailTable(sash_composite);
-
- // init value for stack
- mAllocationStackLayout.topControl = mAllocationModeTop;
-
- // form layout data
- FormData data = new FormData();
- data.top = new FormAttachment(mTotalMemoryLabel, 0);
- data.bottom = new FormAttachment(sash, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- mAllocationStackComposite.setLayoutData(data);
-
- final FormData sashData = new FormData();
- if (prefs != null && prefs.contains(PREFS_ALLOCATION_SASH)) {
- sashData.top = new FormAttachment(0,
- prefs.getInt(PREFS_ALLOCATION_SASH));
- } else {
- sashData.top = new FormAttachment(50, 0); // 50% across
- }
- sashData.left = new FormAttachment(0, 0);
- sashData.right = new FormAttachment(100, 0);
- sash.setLayoutData(sashData);
-
- data = new FormData();
- data.top = new FormAttachment(sash, 0);
- data.bottom = new FormAttachment(100, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- mDetailTable.setLayoutData(data);
-
- // allow resizes, but cap at minPanelWidth
- sash.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event e) {
- Rectangle sashRect = sash.getBounds();
- Rectangle panelRect = sash_composite.getClientArea();
- int bottom = panelRect.height - sashRect.height - minPanelWidth;
- e.y = Math.max(Math.min(e.y, bottom), minPanelWidth);
- if (e.y != sashRect.y) {
- sashData.top = new FormAttachment(0, e.y);
- prefs.setValue(PREFS_ALLOCATION_SASH, e.y);
- sash_composite.layout();
- }
- }
- });
- }
-
- private void createDetailTable(Composite base) {
-
- final IPreferenceStore prefs = DdmUiPreferences.getStore();
-
- mDetailTable = new Table(base, SWT.MULTI | SWT.FULL_SELECTION);
- mDetailTable.setLayoutData(new GridData(GridData.FILL_BOTH));
- mDetailTable.setHeaderVisible(true);
- mDetailTable.setLinesVisible(true);
-
- TableHelper.createTableColumn(mDetailTable, "Address", SWT.RIGHT,
- "00000000", PREFS_DETAIL_ADDRESS, prefs); //$NON-NLS-1$
- TableHelper.createTableColumn(mDetailTable, "Library", SWT.LEFT,
- "abcdefghijklmnopqrst", PREFS_DETAIL_LIBRARY, prefs); //$NON-NLS-1$
- TableHelper.createTableColumn(mDetailTable, "Method", SWT.LEFT,
- "abcdefghijklmnopqrst", PREFS_DETAIL_METHOD, prefs); //$NON-NLS-1$
- TableHelper.createTableColumn(mDetailTable, "File", SWT.LEFT,
- "abcdefghijklmnopqrstuvwxyz", PREFS_DETAIL_FILE, prefs); //$NON-NLS-1$
- TableHelper.createTableColumn(mDetailTable, "Line", SWT.RIGHT,
- "9,999", PREFS_DETAIL_LINE, prefs); //$NON-NLS-1$
- }
-
- private void createAllocationTopHalf(Composite b) {
- final IPreferenceStore prefs = DdmUiPreferences.getStore();
-
- Composite base = new Composite(b, SWT.NONE);
- mAllocationModeTop = base;
- GridLayout gl = new GridLayout(1, false);
- gl.marginLeft = gl.marginRight = gl.marginTop = gl.marginBottom = 0;
- gl.verticalSpacing = 0;
- base.setLayout(gl);
- base.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // horizontal layout for memory total and pages UI
- mPageUIComposite = new Composite(base, SWT.NONE);
- mPageUIComposite.setLayoutData(new GridData(
- GridData.HORIZONTAL_ALIGN_BEGINNING));
- gl = new GridLayout(3, false);
- gl.marginLeft = gl.marginRight = gl.marginTop = gl.marginBottom = 0;
- gl.horizontalSpacing = 0;
- mPageUIComposite.setLayout(gl);
-
- // Page UI
- mPagePreviousButton = new Button(mPageUIComposite, SWT.NONE);
- mPagePreviousButton.setText("<");
- mPagePreviousButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mCurrentPage--;
- updatePageUI();
- emptyTables();
- fillAllocationTable();
- }
- });
-
- mPageNextButton = new Button(mPageUIComposite, SWT.NONE);
- mPageNextButton.setText(">");
- mPageNextButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mCurrentPage++;
- updatePageUI();
- emptyTables();
- fillAllocationTable();
- }
- });
-
- mPageLabel = new Label(mPageUIComposite, SWT.NONE);
- mPageLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- updatePageUI();
-
- mAllocationTable = new Table(base, SWT.MULTI | SWT.FULL_SELECTION);
- mAllocationTable.setLayoutData(new GridData(GridData.FILL_BOTH));
- mAllocationTable.setHeaderVisible(true);
- mAllocationTable.setLinesVisible(true);
-
- TableHelper.createTableColumn(mAllocationTable, "Total", SWT.RIGHT,
- "9,999,999", PREFS_ALLOC_TOTAL, prefs); //$NON-NLS-1$
- TableHelper.createTableColumn(mAllocationTable, "Count", SWT.RIGHT,
- "9,999", PREFS_ALLOC_COUNT, prefs); //$NON-NLS-1$
- TableHelper.createTableColumn(mAllocationTable, "Size", SWT.RIGHT,
- "999,999", PREFS_ALLOC_SIZE, prefs); //$NON-NLS-1$
- TableHelper.createTableColumn(mAllocationTable, "Library", SWT.LEFT,
- "abcdefghijklmnopqrst", PREFS_ALLOC_LIBRARY, prefs); //$NON-NLS-1$
- TableHelper.createTableColumn(mAllocationTable, "Method", SWT.LEFT,
- "abcdefghijklmnopqrst", PREFS_ALLOC_METHOD, prefs); //$NON-NLS-1$
- TableHelper.createTableColumn(mAllocationTable, "File", SWT.LEFT,
- "abcdefghijklmnopqrstuvwxyz", PREFS_ALLOC_FILE, prefs); //$NON-NLS-1$
-
- mAllocationTable.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // get the selection index
- int index = mAllocationTable.getSelectionIndex();
- if (index >= 0 && index < mAllocationTable.getItemCount()) {
- TableItem item = mAllocationTable.getItem(index);
- if (item != null && item.getData() instanceof NativeAllocationInfo) {
- fillDetailTable((NativeAllocationInfo)item.getData());
- }
- }
- }
- });
- }
-
- private void createLibraryTopHalf(Composite base) {
- final int minPanelWidth = 60;
-
- final IPreferenceStore prefs = DdmUiPreferences.getStore();
-
- // create a composite that'll contain 2 tables horizontally
- final Composite top = new Composite(base, SWT.NONE);
- mLibraryModeTopControl = top;
- top.setLayout(new FormLayout());
- top.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // first table: library
- mLibraryTable = new Table(top, SWT.MULTI | SWT.FULL_SELECTION);
- mLibraryTable.setLayoutData(new GridData(GridData.FILL_BOTH));
- mLibraryTable.setHeaderVisible(true);
- mLibraryTable.setLinesVisible(true);
-
- TableHelper.createTableColumn(mLibraryTable, "Library", SWT.LEFT,
- "abcdefghijklmnopqrstuvwxyz", PREFS_LIB_LIBRARY, prefs); //$NON-NLS-1$
- TableHelper.createTableColumn(mLibraryTable, "Size", SWT.RIGHT,
- "9,999,999", PREFS_LIB_SIZE, prefs); //$NON-NLS-1$
- TableHelper.createTableColumn(mLibraryTable, "Count", SWT.RIGHT,
- "9,999", PREFS_LIB_COUNT, prefs); //$NON-NLS-1$
-
- mLibraryTable.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- fillLibraryAllocationTable();
- }
- });
-
- final Sash sash = new Sash(top, SWT.VERTICAL);
-
- // 2nd table: allocation per library
- mLibraryAllocationTable = new Table(top, SWT.MULTI | SWT.FULL_SELECTION);
- mLibraryAllocationTable.setLayoutData(new GridData(GridData.FILL_BOTH));
- mLibraryAllocationTable.setHeaderVisible(true);
- mLibraryAllocationTable.setLinesVisible(true);
-
- TableHelper.createTableColumn(mLibraryAllocationTable, "Total",
- SWT.RIGHT, "9,999,999", PREFS_LIBALLOC_TOTAL, prefs); //$NON-NLS-1$
- TableHelper.createTableColumn(mLibraryAllocationTable, "Count",
- SWT.RIGHT, "9,999", PREFS_LIBALLOC_COUNT, prefs); //$NON-NLS-1$
- TableHelper.createTableColumn(mLibraryAllocationTable, "Size",
- SWT.RIGHT, "999,999", PREFS_LIBALLOC_SIZE, prefs); //$NON-NLS-1$
- TableHelper.createTableColumn(mLibraryAllocationTable, "Method",
- SWT.LEFT, "abcdefghijklmnopqrst", PREFS_LIBALLOC_METHOD, prefs); //$NON-NLS-1$
-
- mLibraryAllocationTable.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // get the index of the selection in the library table
- int index1 = mLibraryTable.getSelectionIndex();
- // get the index in the library allocation table
- int index2 = mLibraryAllocationTable.getSelectionIndex();
- // get the MallocInfo object
- if (index1 != -1 && index2 != -1) {
- LibraryAllocations liballoc = mLibraryAllocations.get(index1);
- NativeAllocationInfo info = liballoc.getAllocation(index2);
- fillDetailTable(info);
- }
- }
- });
-
- // form layout data
- FormData data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(sash, 0);
- mLibraryTable.setLayoutData(data);
-
- final FormData sashData = new FormData();
- if (prefs != null && prefs.contains(PREFS_LIBRARY_SASH)) {
- sashData.left = new FormAttachment(0,
- prefs.getInt(PREFS_LIBRARY_SASH));
- } else {
- sashData.left = new FormAttachment(50, 0);
- }
- sashData.bottom = new FormAttachment(100, 0);
- sashData.top = new FormAttachment(0, 0); // 50% across
- sash.setLayoutData(sashData);
-
- data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
- data.left = new FormAttachment(sash, 0);
- data.right = new FormAttachment(100, 0);
- mLibraryAllocationTable.setLayoutData(data);
-
- // allow resizes, but cap at minPanelWidth
- sash.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event e) {
- Rectangle sashRect = sash.getBounds();
- Rectangle panelRect = top.getClientArea();
- int right = panelRect.width - sashRect.width - minPanelWidth;
- e.x = Math.max(Math.min(e.x, right), minPanelWidth);
- if (e.x != sashRect.x) {
- sashData.left = new FormAttachment(0, e.x);
- prefs.setValue(PREFS_LIBRARY_SASH, e.y);
- top.layout();
- }
- }
- });
- }
-
- private void emptyTables() {
- mAllocationTable.removeAll();
- mLibraryTable.removeAll();
- mLibraryAllocationTable.removeAll();
- mDetailTable.removeAll();
- }
-
- private void sortAllocationsPerLibrary() {
- if (mClientData != null) {
- mLibraryAllocations.clear();
-
- // create a hash map of LibraryAllocations to access aggregate
- // objects already created
- HashMap<String, LibraryAllocations> libcache =
- new HashMap<String, LibraryAllocations>();
-
- // get the allocation count
- int count = mDisplayedAllocations.size();
- for (int i = 0; i < count; i++) {
- NativeAllocationInfo allocInfo = mDisplayedAllocations.get(i);
-
- NativeStackCallInfo stackCallInfo = allocInfo.getRelevantStackCallInfo();
- if (stackCallInfo != null) {
- String libraryName = stackCallInfo.getLibraryName();
- LibraryAllocations liballoc = libcache.get(libraryName);
- if (liballoc == null) {
- // didn't find a library allocation object already
- // created so we create one
- liballoc = new LibraryAllocations(libraryName);
- // add it to the cache
- libcache.put(libraryName, liballoc);
- // add it to the list
- mLibraryAllocations.add(liballoc);
- }
- // add the MallocInfo object to it.
- liballoc.addAllocation(allocInfo);
- }
- }
- // now that the list is created, we need to compute the size and
- // sort it by size. This will also sort the MallocInfo objects
- // inside each LibraryAllocation objects.
- for (LibraryAllocations liballoc : mLibraryAllocations) {
- liballoc.computeAllocationSizeAndCount();
- }
-
- // now we sort it
- Collections.sort(mLibraryAllocations,
- new Comparator<LibraryAllocations>() {
- @Override
- public int compare(LibraryAllocations o1,
- LibraryAllocations o2) {
- return o2.getSize() - o1.getSize();
- }
- });
- }
- }
-
- private void renderBitmap(ClientData cd) {
- byte[] pixData;
-
- // Atomically get and clear the heap data.
- synchronized (cd) {
- if (serializeHeapData(cd.getVmHeapData()) == false) {
- // no change, we return.
- return;
- }
-
- pixData = getSerializedData();
-
- ImageData id = createLinearHeapImage(pixData, 200, mMapPalette);
- Image image = new Image(mBase.getDisplay(), id);
- mImage.setImage(image);
- mImage.pack(true);
- }
- }
-
- /*
- * Create color palette for map. Set up titles for legend.
- */
- private static PaletteData createPalette() {
- RGB colors[] = new RGB[NUM_PALETTE_ENTRIES];
- colors[0]
- = new RGB(192, 192, 192); // non-heap pixels are gray
- mMapLegend[0]
- = "(heap expansion area)";
-
- colors[1]
- = new RGB(0, 0, 0); // free chunks are black
- mMapLegend[1]
- = "free";
-
- colors[HeapSegmentElement.KIND_OBJECT + 2]
- = new RGB(0, 0, 255); // objects are blue
- mMapLegend[HeapSegmentElement.KIND_OBJECT + 2]
- = "data object";
-
- colors[HeapSegmentElement.KIND_CLASS_OBJECT + 2]
- = new RGB(0, 255, 0); // class objects are green
- mMapLegend[HeapSegmentElement.KIND_CLASS_OBJECT + 2]
- = "class object";
-
- colors[HeapSegmentElement.KIND_ARRAY_1 + 2]
- = new RGB(255, 0, 0); // byte/bool arrays are red
- mMapLegend[HeapSegmentElement.KIND_ARRAY_1 + 2]
- = "1-byte array (byte[], boolean[])";
-
- colors[HeapSegmentElement.KIND_ARRAY_2 + 2]
- = new RGB(255, 128, 0); // short/char arrays are orange
- mMapLegend[HeapSegmentElement.KIND_ARRAY_2 + 2]
- = "2-byte array (short[], char[])";
-
- colors[HeapSegmentElement.KIND_ARRAY_4 + 2]
- = new RGB(255, 255, 0); // obj/int/float arrays are yellow
- mMapLegend[HeapSegmentElement.KIND_ARRAY_4 + 2]
- = "4-byte array (object[], int[], float[])";
-
- colors[HeapSegmentElement.KIND_ARRAY_8 + 2]
- = new RGB(255, 128, 128); // long/double arrays are pink
- mMapLegend[HeapSegmentElement.KIND_ARRAY_8 + 2]
- = "8-byte array (long[], double[])";
-
- colors[HeapSegmentElement.KIND_UNKNOWN + 2]
- = new RGB(255, 0, 255); // unknown objects are cyan
- mMapLegend[HeapSegmentElement.KIND_UNKNOWN + 2]
- = "unknown object";
-
- colors[HeapSegmentElement.KIND_NATIVE + 2]
- = new RGB(64, 64, 64); // native objects are dark gray
- mMapLegend[HeapSegmentElement.KIND_NATIVE + 2]
- = "non-Java object";
-
- return new PaletteData(colors);
- }
-
- private void saveAllocations(String fileName) {
- try {
- PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(fileName)));
-
- for (NativeAllocationInfo alloc : mAllocations) {
- out.println(alloc.toString());
- }
- out.close();
- } catch (IOException e) {
- Log.e("Native", e);
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/Panel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/Panel.java
deleted file mode 100644
index d910cc7..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/Panel.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-
-/**
- * Base class for our information panels.
- */
-public abstract class Panel {
-
- public final Control createPanel(Composite parent) {
- Control panelControl = createControl(parent);
-
- postCreation();
-
- return panelControl;
- }
-
- protected abstract void postCreation();
-
- /**
- * Creates a control capable of displaying some information. This is
- * called once, when the application is initializing, from the UI thread.
- */
- protected abstract Control createControl(Composite parent);
-
- /**
- * Sets the focus to the proper control inside the panel.
- */
- public abstract void setFocus();
-}
-
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/PortFieldEditor.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/PortFieldEditor.java
deleted file mode 100644
index 533372e..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/PortFieldEditor.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import org.eclipse.jface.preference.IntegerFieldEditor;
-import org.eclipse.swt.widgets.Composite;
-
-/**
- * Edit an integer field, validating it as a port number.
- */
-public class PortFieldEditor extends IntegerFieldEditor {
-
- public boolean mRecursiveCheck = false;
-
- public PortFieldEditor(String name, String label, Composite parent) {
- super(name, label, parent);
- setValidateStrategy(VALIDATE_ON_KEY_STROKE);
- }
-
- /*
- * Get the current value of the field, as an integer.
- */
- public int getCurrentValue() {
- int val;
- try {
- val = Integer.parseInt(getStringValue());
- }
- catch (NumberFormatException nfe) {
- val = -1;
- }
- return val;
- }
-
- /*
- * Check the validity of the field.
- */
- @Override
- protected boolean checkState() {
- if (super.checkState() == false) {
- return false;
- }
- //Log.i("ddms", "check state " + getStringValue());
- boolean err = false;
- int val = getCurrentValue();
- if (val < 1024 || val > 32767) {
- setErrorMessage("Port must be between 1024 and 32767");
- err = true;
- } else {
- setErrorMessage(null);
- err = false;
- }
- showErrorMessage();
- return !err;
- }
-
- protected void updateCheckState(PortFieldEditor pfe) {
- pfe.refreshValidState();
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/ScreenShotDialog.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/ScreenShotDialog.java
deleted file mode 100644
index b0f885a..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/ScreenShotDialog.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.AdbCommandRejectedException;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.RawImage;
-import com.android.ddmlib.TimeoutException;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.ImageTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.PaletteData;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.Calendar;
-
-
-/**
- * Gather a screen shot from the device and save it to a file.
- */
-public class ScreenShotDialog extends Dialog {
-
- private Label mBusyLabel;
- private Label mImageLabel;
- private Button mSave;
- private IDevice mDevice;
- private RawImage mRawImage;
- private Clipboard mClipboard;
-
- /** Number of 90 degree rotations applied to the current image */
- private int mRotateCount = 0;
-
- /**
- * Create with default style.
- */
- public ScreenShotDialog(Shell parent) {
- this(parent, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
- mClipboard = new Clipboard(parent.getDisplay());
- }
-
- /**
- * Create with app-defined style.
- */
- public ScreenShotDialog(Shell parent, int style) {
- super(parent, style);
- }
-
- /**
- * Prepare and display the dialog.
- * @param device The {@link IDevice} from which to get the screenshot.
- */
- public void open(IDevice device) {
- mDevice = device;
-
- Shell parent = getParent();
- Shell shell = new Shell(parent, getStyle());
- shell.setText("Device Screen Capture");
-
- createContents(shell);
- shell.pack();
- shell.open();
-
- updateDeviceImage(shell);
-
- Display display = parent.getDisplay();
- while (!shell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- }
-
- /*
- * Create the screen capture dialog contents.
- */
- private void createContents(final Shell shell) {
- GridData data;
-
- final int colCount = 5;
-
- shell.setLayout(new GridLayout(colCount, true));
-
- // "refresh" button
- Button refresh = new Button(shell, SWT.PUSH);
- refresh.setText("Refresh");
- data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
- data.widthHint = 80;
- refresh.setLayoutData(data);
- refresh.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- updateDeviceImage(shell);
- // RawImage only allows us to rotate the image 90 degrees at the time,
- // so to preserve the current rotation we must call getRotated()
- // the same number of times the user has done it manually.
- // TODO: improve the RawImage class.
- for (int i=0; i < mRotateCount; i++) {
- mRawImage = mRawImage.getRotated();
- }
- updateImageDisplay(shell);
- }
- });
-
- // "rotate" button
- Button rotate = new Button(shell, SWT.PUSH);
- rotate.setText("Rotate");
- data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
- data.widthHint = 80;
- rotate.setLayoutData(data);
- rotate.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mRawImage != null) {
- mRotateCount = (mRotateCount + 1) % 4;
- mRawImage = mRawImage.getRotated();
- updateImageDisplay(shell);
- }
- }
- });
-
- // "save" button
- mSave = new Button(shell, SWT.PUSH);
- mSave.setText("Save");
- data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
- data.widthHint = 80;
- mSave.setLayoutData(data);
- mSave.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- saveImage(shell);
- }
- });
-
- Button copy = new Button(shell, SWT.PUSH);
- copy.setText("Copy");
- copy.setToolTipText("Copy the screenshot to the clipboard");
- data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
- data.widthHint = 80;
- copy.setLayoutData(data);
- copy.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- copy();
- }
- });
-
-
- // "done" button
- Button done = new Button(shell, SWT.PUSH);
- done.setText("Done");
- data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
- data.widthHint = 80;
- done.setLayoutData(data);
- done.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- shell.close();
- }
- });
-
- // title/"capturing" label
- mBusyLabel = new Label(shell, SWT.NONE);
- mBusyLabel.setText("Preparing...");
- data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- data.horizontalSpan = colCount;
- mBusyLabel.setLayoutData(data);
-
- // space for the image
- mImageLabel = new Label(shell, SWT.BORDER);
- data = new GridData(GridData.HORIZONTAL_ALIGN_CENTER);
- data.horizontalSpan = colCount;
- mImageLabel.setLayoutData(data);
- Display display = shell.getDisplay();
- mImageLabel.setImage(ImageLoader.createPlaceHolderArt(
- display, 50, 50, display.getSystemColor(SWT.COLOR_BLUE)));
-
-
- shell.setDefaultButton(done);
- }
-
- /**
- * Copies the content of {@link #mImageLabel} to the clipboard.
- */
- private void copy() {
- mClipboard.setContents(
- new Object[] {
- mImageLabel.getImage().getImageData()
- }, new Transfer[] {
- ImageTransfer.getInstance()
- });
- }
-
- /**
- * Captures a new image from the device, and display it.
- */
- private void updateDeviceImage(Shell shell) {
- mBusyLabel.setText("Capturing..."); // no effect
-
- shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT));
-
- mRawImage = getDeviceImage();
-
- updateImageDisplay(shell);
- }
-
- /**
- * Updates the display with {@link #mRawImage}.
- * @param shell
- */
- private void updateImageDisplay(Shell shell) {
- Image image;
- if (mRawImage == null) {
- Display display = shell.getDisplay();
- image = ImageLoader.createPlaceHolderArt(
- display, 320, 240, display.getSystemColor(SWT.COLOR_BLUE));
-
- mSave.setEnabled(false);
- mBusyLabel.setText("Screen not available");
- } else {
- // convert raw data to an Image.
- PaletteData palette = new PaletteData(
- mRawImage.getRedMask(),
- mRawImage.getGreenMask(),
- mRawImage.getBlueMask());
-
- ImageData imageData = new ImageData(mRawImage.width, mRawImage.height,
- mRawImage.bpp, palette, 1, mRawImage.data);
- image = new Image(getParent().getDisplay(), imageData);
-
- mSave.setEnabled(true);
- mBusyLabel.setText("Captured image:");
- }
-
- mImageLabel.setImage(image);
- mImageLabel.pack();
- shell.pack();
-
- // there's no way to restore old cursor; assume it's ARROW
- shell.setCursor(shell.getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
- }
-
- /**
- * Grabs an image from an ADB-connected device and returns it as a {@link RawImage}.
- */
- private RawImage getDeviceImage() {
- try {
- return mDevice.getScreenshot();
- }
- catch (IOException ioe) {
- Log.w("ddms", "Unable to get frame buffer: " + ioe.getMessage());
- return null;
- } catch (TimeoutException e) {
- Log.w("ddms", "Unable to get frame buffer: timeout ");
- return null;
- } catch (AdbCommandRejectedException e) {
- Log.w("ddms", "Unable to get frame buffer: " + e.getMessage());
- return null;
- }
- }
-
- /*
- * Prompt the user to save the image to disk.
- */
- private void saveImage(Shell shell) {
- FileDialog dlg = new FileDialog(shell, SWT.SAVE);
-
- Calendar now = Calendar.getInstance();
- String fileName = String.format("device-%tF-%tH%tM%tS.png",
- now, now, now, now);
-
- dlg.setText("Save image...");
- dlg.setFileName(fileName);
-
- String lastDir = DdmUiPreferences.getStore().getString("lastImageSaveDir");
- if (lastDir.length() == 0) {
- lastDir = DdmUiPreferences.getStore().getString("imageSaveDir");
- }
- dlg.setFilterPath(lastDir);
- dlg.setFilterNames(new String[] {
- "PNG Files (*.png)"
- });
- dlg.setFilterExtensions(new String[] {
- "*.png" //$NON-NLS-1$
- });
-
- fileName = dlg.open();
- if (fileName != null) {
- // FileDialog.getFilterPath() does NOT always return the current
- // directory of the FileDialog; on the Mac it sometimes just returns
- // the value the dialog was initialized with. It does however return
- // the full path as its return value, so just pick the path from
- // there.
- if (!fileName.endsWith(".png")) {
- fileName = fileName + ".png";
- }
-
- String saveDir = new File(fileName).getParent();
- if (saveDir != null) {
- DdmUiPreferences.getStore().setValue("lastImageSaveDir", saveDir);
- }
-
- Log.d("ddms", "Saving image to " + fileName);
- ImageData imageData = mImageLabel.getImage().getImageData();
-
- try {
- org.eclipse.swt.graphics.ImageLoader loader =
- new org.eclipse.swt.graphics.ImageLoader();
-
- loader.data = new ImageData[] { imageData };
- loader.save(fileName, SWT.IMAGE_PNG);
- }
- catch (SWTException e) {
- Log.w("ddms", "Unable to save " + fileName + ": " + e.getMessage());
- }
- }
- }
-
-}
-
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/SelectionDependentPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/SelectionDependentPanel.java
deleted file mode 100644
index e6d2211..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/SelectionDependentPanel.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.Client;
-import com.android.ddmlib.IDevice;
-
-/**
- * A Panel that requires {@link Device}/{@link Client} selection notifications.
- */
-public abstract class SelectionDependentPanel extends Panel {
- private IDevice mCurrentDevice = null;
- private Client mCurrentClient = null;
-
- /**
- * Returns the current {@link Device}.
- * @return the current device or null if none are selected.
- */
- protected final IDevice getCurrentDevice() {
- return mCurrentDevice;
- }
-
- /**
- * Returns the current {@link Client}.
- * @return the current client or null if none are selected.
- */
- protected final Client getCurrentClient() {
- return mCurrentClient;
- }
-
- /**
- * Sent when a new device is selected.
- * @param selectedDevice the selected device.
- */
- public final void deviceSelected(IDevice selectedDevice) {
- if (selectedDevice != mCurrentDevice) {
- mCurrentDevice = selectedDevice;
- deviceSelected();
- }
- }
-
- /**
- * Sent when a new client is selected.
- * @param selectedClient the selected client.
- */
- public final void clientSelected(Client selectedClient) {
- if (selectedClient != mCurrentClient) {
- mCurrentClient = selectedClient;
- clientSelected();
- }
- }
-
- /**
- * Sent when a new device is selected. The new device can be accessed
- * with {@link #getCurrentDevice()}.
- */
- public abstract void deviceSelected();
-
- /**
- * Sent when a new client is selected. The new client can be accessed
- * with {@link #getCurrentClient()}.
- */
- public abstract void clientSelected();
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/StackTracePanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/StackTracePanel.java
deleted file mode 100644
index b00120b..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/StackTracePanel.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.Client;
-import com.android.ddmlib.IStackTraceInfo;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-
-/**
- * Stack Trace Panel.
- * <p/>This is not a panel in the regular sense. Instead this is just an object around the creation
- * and management of a Stack Trace display.
- * <p/>UI creation is done through
- * {@link #createPanel(Composite, String, IPreferenceStore)}.
- *
- */
-public final class StackTracePanel {
-
- private static ISourceRevealer sSourceRevealer;
-
- private Table mStackTraceTable;
- private TableViewer mStackTraceViewer;
-
- private Client mCurrentClient;
-
-
- /**
- * Content Provider to display the stack trace of a thread.
- * Expected input is a {@link IStackTraceInfo} object.
- */
- private static class StackTraceContentProvider implements IStructuredContentProvider {
- @Override
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof IStackTraceInfo) {
- // getElement cannot return null, so we return an empty array
- // if there's no stack trace
- StackTraceElement trace[] = ((IStackTraceInfo)inputElement).getStackTrace();
- if (trace != null) {
- return trace;
- }
- }
-
- return new Object[0];
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // pass
- }
- }
-
-
- /**
- * A Label Provider to use with {@link StackTraceContentProvider}. It expects the elements to be
- * of type {@link StackTraceElement}.
- */
- private static class StackTraceLabelProvider implements ITableLabelProvider {
-
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- @Override
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof StackTraceElement && columnIndex == 0) {
- StackTraceElement traceElement = (StackTraceElement) element;
- return " at " + traceElement.toString();
- }
- return null;
- }
-
- @Override
- public void addListener(ILabelProviderListener listener) {
- // pass
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- // pass
- return false;
- }
-
- @Override
- public void removeListener(ILabelProviderListener listener) {
- // pass
- }
- }
-
- /**
- * Classes which implement this interface provide a method that is able to reveal a method
- * in a source editor
- */
- public interface ISourceRevealer {
- /**
- * Sent to reveal a particular line in a source editor
- * @param applicationName the name of the application running the source.
- * @param className the fully qualified class name
- * @param line the line to reveal
- */
- public void reveal(String applicationName, String className, int line);
- }
-
-
- /**
- * Sets the {@link ISourceRevealer} object able to reveal source code in a source editor.
- * @param revealer
- */
- public static void setSourceRevealer(ISourceRevealer revealer) {
- sSourceRevealer = revealer;
- }
-
- /**
- * Creates the controls for the StrackTrace display.
- * <p/>This method will set the parent {@link Composite} to use a {@link GridLayout} with
- * 2 columns.
- * @param parent the parent composite.
- * @param prefs_stack_column
- * @param store
- */
- public Table createPanel(Composite parent, String prefs_stack_column,
- IPreferenceStore store) {
-
- mStackTraceTable = new Table(parent, SWT.MULTI | SWT.FULL_SELECTION);
- mStackTraceTable.setHeaderVisible(false);
- mStackTraceTable.setLinesVisible(false);
-
- TableHelper.createTableColumn(
- mStackTraceTable,
- "Info",
- SWT.LEFT,
- "SomeLongClassName.method(android/somepackage/someotherpackage/somefile.java:99999)", //$NON-NLS-1$
- prefs_stack_column, store);
-
- mStackTraceViewer = new TableViewer(mStackTraceTable);
- mStackTraceViewer.setContentProvider(new StackTraceContentProvider());
- mStackTraceViewer.setLabelProvider(new StackTraceLabelProvider());
-
- mStackTraceViewer.addDoubleClickListener(new IDoubleClickListener() {
- @Override
- public void doubleClick(DoubleClickEvent event) {
- if (sSourceRevealer != null && mCurrentClient != null) {
- // get the selected stack trace element
- ISelection selection = mStackTraceViewer.getSelection();
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection)selection;
- Object object = structuredSelection.getFirstElement();
- if (object instanceof StackTraceElement) {
- StackTraceElement traceElement = (StackTraceElement)object;
-
- if (traceElement.isNativeMethod() == false) {
- sSourceRevealer.reveal(
- mCurrentClient.getClientData().getClientDescription(),
- traceElement.getClassName(),
- traceElement.getLineNumber());
- }
- }
- }
- }
- }
- });
-
- return mStackTraceTable;
- }
-
- /**
- * Sets the input for the {@link TableViewer}.
- * @param input the {@link IStackTraceInfo} that will provide the viewer with the list of
- * {@link StackTraceElement}
- */
- public void setViewerInput(IStackTraceInfo input) {
- mStackTraceViewer.setInput(input);
- mStackTraceViewer.refresh();
- }
-
- /**
- * Sets the current client running the stack trace.
- * @param currentClient the {@link Client}.
- */
- public void setCurrentClient(Client currentClient) {
- mCurrentClient = currentClient;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/SyncProgressHelper.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/SyncProgressHelper.java
deleted file mode 100644
index 732de59..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/SyncProgressHelper.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.SyncException;
-import com.android.ddmlib.SyncService;
-import com.android.ddmlib.SyncService.ISyncProgressMonitor;
-import com.android.ddmlib.TimeoutException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * Helper class to run a Sync in a {@link ProgressMonitorDialog}.
- */
-public class SyncProgressHelper {
-
- /**
- * a runnable class run with an {@link ISyncProgressMonitor}.
- */
- public interface SyncRunnable {
- /** Runs the sync action */
- void run(ISyncProgressMonitor monitor) throws SyncException, IOException, TimeoutException;
- /** close the {@link SyncService} */
- void close();
- }
-
- /**
- * Runs a {@link SyncRunnable} in a {@link ProgressMonitorDialog}.
- * @param runnable The {@link SyncRunnable} to run.
- * @param progressMessage the message to display in the progress dialog
- * @param parentShell the parent shell for the progress dialog.
- *
- * @throws InvocationTargetException
- * @throws InterruptedException
- * @throws SyncException if an error happens during the push of the package on the device.
- * @throws IOException
- * @throws TimeoutException
- */
- public static void run(final SyncRunnable runnable, final String progressMessage,
- final Shell parentShell)
- throws InvocationTargetException, InterruptedException, SyncException, IOException,
- TimeoutException {
-
- final Exception[] result = new Exception[1];
- new ProgressMonitorDialog(parentShell).run(true, true, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) {
- try {
- runnable.run(new SyncProgressMonitor(monitor, progressMessage));
- } catch (Exception e) {
- result[0] = e;
- } finally {
- runnable.close();
- }
- }
- });
-
- if (result[0] instanceof SyncException) {
- SyncException se = (SyncException)result[0];
- if (se.wasCanceled()) {
- // no need to throw this
- return;
- }
- throw se;
- }
-
- // just do some casting so that the method declaration matches what's thrown.
- if (result[0] instanceof TimeoutException) {
- throw (TimeoutException)result[0];
- }
-
- if (result[0] instanceof IOException) {
- throw (IOException)result[0];
- }
-
- if (result[0] instanceof RuntimeException) {
- throw (RuntimeException)result[0];
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/SyncProgressMonitor.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/SyncProgressMonitor.java
deleted file mode 100644
index 4254f67..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/SyncProgressMonitor.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.SyncService.ISyncProgressMonitor;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * Implementation of the {@link ISyncProgressMonitor} wrapping an Eclipse {@link IProgressMonitor}.
- */
-public class SyncProgressMonitor implements ISyncProgressMonitor {
-
- private IProgressMonitor mMonitor;
- private String mName;
-
- public SyncProgressMonitor(IProgressMonitor monitor, String name) {
- mMonitor = monitor;
- mName = name;
- }
-
- @Override
- public void start(int totalWork) {
- mMonitor.beginTask(mName, totalWork);
- }
-
- @Override
- public void stop() {
- mMonitor.done();
- }
-
- @Override
- public void advance(int work) {
- mMonitor.worked(work);
- }
-
- @Override
- public boolean isCanceled() {
- return mMonitor.isCanceled();
- }
-
- @Override
- public void startSubTask(String name) {
- mMonitor.subTask(name);
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/SysinfoPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/SysinfoPanel.java
deleted file mode 100644
index 8ba2171..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/SysinfoPanel.java
+++ /dev/null
@@ -1,907 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.AdbCommandRejectedException;
-import com.android.ddmlib.Client;
-import com.android.ddmlib.ClientData;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.IShellOutputReceiver;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.NullOutputReceiver;
-import com.android.ddmlib.ShellCommandUnresponsiveException;
-import com.android.ddmlib.TimeoutException;
-import com.android.ddmuilib.SysinfoPanel.BugReportParser.GfxProfileData;
-import com.google.common.base.Splitter;
-import com.google.common.collect.Lists;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.jfree.chart.ChartFactory;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.plot.PlotOrientation;
-import org.jfree.data.category.DefaultCategoryDataset;
-import org.jfree.data.general.DefaultPieDataset;
-import org.jfree.experimental.chart.swt.ChartComposite;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Displays system information graphs obtained from a bugreport file or device.
- */
-public class SysinfoPanel extends TablePanel implements IShellOutputReceiver {
-
- // UI components
- private Label mLabel;
- private Button mFetchButton;
- private Combo mDisplayMode;
-
- private DefaultPieDataset mDataset;
- private DefaultCategoryDataset mBarDataSet;
-
- private StackLayout mStackLayout;
- private Composite mChartComposite;
- private Composite mPieChartComposite;
- private Composite mStackedBarComposite;
-
- // The bugreport file to process
- private File mDataFile;
-
- // To get output from adb commands
- private FileOutputStream mTempStream;
-
- // Selects the current display: MODE_CPU, etc.
- private int mMode = 0;
- private String mGfxPackageName;
-
- private static final int MODE_CPU = 0;
- private static final int MODE_MEMINFO = 1;
- private static final int MODE_GFXINFO = 2;
-
- // argument to dumpsys; section in the bugreport holding the data
- private static final String DUMP_COMMAND[] = {
- "dumpsys cpuinfo",
- "cat /proc/meminfo ; procrank",
- "dumpsys gfxinfo",
- };
-
- private static final String CAPTIONS[] = {
- "CPU load",
- "Memory usage",
- "Frame Render Time",
- };
-
- /** Shell property that controls whether graphics profiling is enabled or not. */
- private static final String PROP_GFX_PROFILING = "debug.hwui.profile"; //$NON-NLS-1$
-
- /**
- * Generates the dataset to display.
- *
- * @param file The bugreport file to process.
- */
- private void generateDataset(File file) {
- if (file == null) {
- return;
- }
- try {
- BufferedReader br = getBugreportReader(file);
- if (mMode == MODE_CPU) {
- readCpuDataset(br);
- } else if (mMode == MODE_MEMINFO) {
- readMeminfoDataset(br);
- } else if (mMode == MODE_GFXINFO) {
- readGfxInfoDataset(br);
- }
- br.close();
- } catch (IOException e) {
- Log.e("DDMS", e);
- }
- }
-
- /**
- * Sent when a new device is selected. The new device can be accessed with
- * {@link #getCurrentDevice()}
- */
- @Override
- public void deviceSelected() {
- if (getCurrentDevice() != null) {
- mFetchButton.setEnabled(true);
- loadFromDevice();
- } else {
- mFetchButton.setEnabled(false);
- }
- }
-
- /**
- * Sent when a new client is selected. The new client can be accessed with
- * {@link #getCurrentClient()}.
- */
- @Override
- public void clientSelected() {
- }
-
- /**
- * Sets the focus to the proper control inside the panel.
- */
- @Override
- public void setFocus() {
- mDisplayMode.setFocus();
- }
-
- /**
- * Fetches a new bugreport from the device and updates the display.
- * Fetching is asynchronous. See also addOutput, flush, and isCancelled.
- */
- private void loadFromDevice() {
- clearDataSet();
-
- if (mMode == MODE_GFXINFO) {
- boolean en = isGfxProfilingEnabled();
- if (!en) {
- if (enableGfxProfiling()) {
- MessageDialog.openInformation(Display.getCurrent().getActiveShell(),
- "DDMS",
- "Graphics profiling was enabled on the device.\n" +
- "It may be necessary to relaunch your application to see profile information.");
- } else {
- MessageDialog.openError(Display.getCurrent().getActiveShell(),
- "DDMS",
- "Unexpected error enabling graphics profiling on device.\n");
- return;
- }
- }
- }
-
- final String command = getDumpsysCommand(mMode);
- if (command == null) {
- return;
- }
-
- Thread t = new Thread(new Runnable() {
- @Override
- public void run() {
- try {
- initShellOutputBuffer();
- if (mMode == MODE_MEMINFO) {
- // Hack to add bugreport-style section header for meminfo
- mTempStream.write("------ MEMORY INFO ------\n".getBytes());
- }
- getCurrentDevice().executeShellCommand(command, SysinfoPanel.this);
- } catch (IOException e) {
- Log.e("DDMS", e);
- } catch (TimeoutException e) {
- Log.e("DDMS", e);
- } catch (AdbCommandRejectedException e) {
- Log.e("DDMS", e);
- } catch (ShellCommandUnresponsiveException e) {
- Log.e("DDMS", e);
- }
- }
- }, "Sysinfo Output Collector");
- t.start();
- }
-
- private boolean isGfxProfilingEnabled() {
- IDevice device = getCurrentDevice();
- if (device == null) {
- return false;
- }
-
- String prop;
- try {
- prop = device.getPropertySync(PROP_GFX_PROFILING);
- return Boolean.valueOf(prop);
- } catch (Exception e) {
- return false;
- }
- }
-
- private boolean enableGfxProfiling() {
- IDevice device = getCurrentDevice();
- if (device == null) {
- return false;
- }
-
- try {
- device.executeShellCommand("setprop " + PROP_GFX_PROFILING + " true",
- new NullOutputReceiver());
- } catch (Exception e) {
- return false;
- }
-
- return true;
- }
-
- private String getDumpsysCommand(int mode) {
- if (mode == MODE_GFXINFO) {
- Client c = getCurrentClient();
- if (c == null) {
- return null;
- }
-
- ClientData cd = c.getClientData();
- if (cd == null) {
- return null;
- }
-
- mGfxPackageName = cd.getClientDescription();
- if (mGfxPackageName == null) {
- return null;
- }
-
- return "dumpsys gfxinfo " + mGfxPackageName;
- } else if (mode < DUMP_COMMAND.length) {
- return DUMP_COMMAND[mode];
- }
-
- return null;
- }
-
- /**
- * Initializes temporary output file for executeShellCommand().
- *
- * @throws IOException on file error
- */
- void initShellOutputBuffer() throws IOException {
- mDataFile = File.createTempFile("ddmsfile", ".txt");
- mDataFile.deleteOnExit();
- mTempStream = new FileOutputStream(mDataFile);
- }
-
- /**
- * Adds output to the temp file. IShellOutputReceiver method. Called by
- * executeShellCommand().
- */
- @Override
- public void addOutput(byte[] data, int offset, int length) {
- try {
- mTempStream.write(data, offset, length);
- } catch (IOException e) {
- Log.e("DDMS", e);
- }
- }
-
- /**
- * Processes output from shell command. IShellOutputReceiver method. The
- * output is passed to generateDataset(). Called by executeShellCommand() on
- * completion.
- */
- @Override
- public void flush() {
- if (mTempStream != null) {
- try {
- mTempStream.close();
- generateDataset(mDataFile);
- mTempStream = null;
- mDataFile = null;
- } catch (IOException e) {
- Log.e("DDMS", e);
- }
- }
- }
-
- /**
- * IShellOutputReceiver method.
- *
- * @return false - don't cancel
- */
- @Override
- public boolean isCancelled() {
- return false;
- }
-
- /**
- * Create our controls for the UI panel.
- */
- @Override
- protected Control createControl(Composite parent) {
- Composite top = new Composite(parent, SWT.NONE);
- top.setLayout(new GridLayout(1, false));
- top.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Composite buttons = new Composite(top, SWT.NONE);
- buttons.setLayout(new RowLayout());
-
- mDisplayMode = new Combo(buttons, SWT.PUSH);
- for (String mode : CAPTIONS) {
- mDisplayMode.add(mode);
- }
- mDisplayMode.select(mMode);
- mDisplayMode.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mMode = mDisplayMode.getSelectionIndex();
- if (mDataFile != null) {
- generateDataset(mDataFile);
- } else if (getCurrentDevice() != null) {
- loadFromDevice();
- }
- }
- });
-
- mFetchButton = new Button(buttons, SWT.PUSH);
- mFetchButton.setText("Update from Device");
- mFetchButton.setEnabled(false);
- mFetchButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- loadFromDevice();
- }
- });
-
- mLabel = new Label(top, SWT.NONE);
- mLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- mChartComposite = new Composite(top, SWT.NONE);
- mChartComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
- mStackLayout = new StackLayout();
- mChartComposite.setLayout(mStackLayout);
-
- mPieChartComposite = createPieChartComposite(mChartComposite);
- mStackedBarComposite = createStackedBarComposite(mChartComposite);
-
- mStackLayout.topControl = mPieChartComposite;
-
- return top;
- }
-
- private Composite createStackedBarComposite(Composite chartComposite) {
- mBarDataSet = new DefaultCategoryDataset();
- JFreeChart chart = ChartFactory.createStackedBarChart("Per Frame Rendering Time",
- "Frame #", "Time (ms)", mBarDataSet, PlotOrientation.VERTICAL,
- true /* legend */, true /* tooltips */, false /* urls */);
-
- ChartComposite c = newChartComposite(chart, chartComposite);
- c.setLayoutData(new GridData(GridData.FILL_BOTH));
- return c;
- }
-
- private Composite createPieChartComposite(Composite chartComposite) {
- mDataset = new DefaultPieDataset();
- JFreeChart chart = ChartFactory.createPieChart("", mDataset, false
- /* legend */, true/* tooltips */, false /* urls */);
-
- ChartComposite c = newChartComposite(chart, chartComposite);
- c.setLayoutData(new GridData(GridData.FILL_BOTH));
- return c;
- }
-
- private ChartComposite newChartComposite(JFreeChart chart, Composite parent) {
- return new ChartComposite(parent,
- SWT.BORDER, chart,
- ChartComposite.DEFAULT_HEIGHT,
- ChartComposite.DEFAULT_HEIGHT,
- ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH,
- ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT,
- 3000,
- // max draw width. We don't want it to zoom, so we put a big number
- 3000,
- // max draw height. We don't want it to zoom, so we put a big number
- true, // off-screen buffer
- true, // properties
- true, // save
- true, // print
- false, // zoom
- true);
- }
-
- @Override
- public void clientChanged(final Client client, int changeMask) {
- // Don't care
- }
-
- /**
- * Helper to open a bugreport and skip to the specified section.
- *
- * @param file File to open
- * @return Reader to bugreport file
- * @throws java.io.IOException on file error
- */
- private BufferedReader getBugreportReader(File file) throws
- IOException {
- return new BufferedReader(new FileReader(file));
- }
-
- /**
- * Parse the time string generated by BatteryStats.
- * A typical new-format string is "11d 13h 45m 39s 999ms".
- * A typical old-format string is "12.3 sec".
- * @return time in ms
- */
- private static long parseTimeMs(String s) {
- long total = 0;
- // Matches a single component e.g. "12.3 sec" or "45ms"
- Pattern p = Pattern.compile("([\\d\\.]+)\\s*([a-z]+)");
- Matcher m = p.matcher(s);
- while (m.find()) {
- String label = m.group(2);
- if ("sec".equals(label)) {
- // Backwards compatibility with old time format
- total += (long) (Double.parseDouble(m.group(1)) * 1000);
- continue;
- }
- long value = Integer.parseInt(m.group(1));
- if ("d".equals(label)) {
- total += value * 24 * 60 * 60 * 1000;
- } else if ("h".equals(label)) {
- total += value * 60 * 60 * 1000;
- } else if ("m".equals(label)) {
- total += value * 60 * 1000;
- } else if ("s".equals(label)) {
- total += value * 1000;
- } else if ("ms".equals(label)) {
- total += value;
- }
- }
- return total;
- }
-
- public static final class BugReportParser {
- public static final class DataValue {
- final String name;
- final double value;
-
- public DataValue(String n, double v) {
- name = n;
- value = v;
- }
- };
-
- /** Components of the time it takes to draw a single frame. */
- public static final class GfxProfileData {
- /** draw time (time spent building display lists) in ms */
- final double draw;
-
- /** process time (time spent by Android's 2D renderer to execute display lists) (ms) */
- final double process;
-
- /** execute time (time spent to send frame to the compositor) in ms */
- final double execute;
-
- public GfxProfileData(double draw, double process, double execute) {
- this.draw = draw;
- this.process = process;
- this.execute = execute;
- }
- }
-
- public static List<GfxProfileData> parseGfxInfo(BufferedReader br) throws IOException {
- Pattern headerPattern = Pattern.compile("\\s+Draw\\s+Process\\s+Execute");
-
- String line = null;
- while ((line = br.readLine()) != null) {
- Matcher m = headerPattern.matcher(line);
- if (m.find()) {
- break;
- }
- }
-
- if (line == null) {
- return Collections.emptyList();
- }
-
- // parse something like: " 0.85 1.10 0.61\n", 3 doubles basically
- Pattern dataPattern =
- Pattern.compile("(\\d*\\.\\d+)\\s+(\\d*\\.\\d+)\\s+(\\d*\\.\\d+)");
-
- List<GfxProfileData> data = new ArrayList<BugReportParser.GfxProfileData>(128);
- while ((line = br.readLine()) != null) {
- Matcher m = dataPattern.matcher(line);
- if (!m.find()) {
- break;
- }
-
- double draw = safeParseDouble(m.group(1));
- double process = safeParseDouble(m.group(2));
- double execute = safeParseDouble(m.group(3));
-
- data.add(new GfxProfileData(draw, process, execute));
- }
-
- return data;
- }
-
- /**
- * Processes wakelock information from bugreport. Updates mDataset with the
- * new data.
- *
- * @param br Reader providing the content
- * @throws IOException if error reading file
- */
- public static List<DataValue> readWakelockDataset(BufferedReader br) throws IOException {
- List<DataValue> results = new ArrayList<DataValue>();
-
- Pattern lockPattern = Pattern.compile("Wake lock (\\S+): (.+) partial");
- Pattern totalPattern = Pattern.compile("Total: (.+) uptime");
- double total = 0;
- boolean inCurrent = false;
-
- while (true) {
- String line = br.readLine();
- if (line == null || line.startsWith("DUMP OF SERVICE")) {
- // Done, or moved on to the next service
- break;
- }
- if (line.startsWith("Current Battery Usage Statistics")) {
- inCurrent = true;
- } else if (inCurrent) {
- Matcher m = lockPattern.matcher(line);
- if (m.find()) {
- double value = parseTimeMs(m.group(2)) / 1000.;
- results.add(new DataValue(m.group(1), value));
- total -= value;
- } else {
- m = totalPattern.matcher(line);
- if (m.find()) {
- total += parseTimeMs(m.group(1)) / 1000.;
- }
- }
- }
- }
- if (total > 0) {
- results.add(new DataValue("Unlocked", total));
- }
-
- return results;
- }
-
- /**
- * Processes alarm information from bugreport. Updates mDataset with the new
- * data.
- *
- * @param br Reader providing the content
- * @throws IOException if error reading file
- */
- public static List<DataValue> readAlarmDataset(BufferedReader br) throws IOException {
- List<DataValue> results = new ArrayList<DataValue>();
- Pattern pattern = Pattern.compile("(\\d+) alarms: Intent .*\\.([^. ]+) flags");
-
- while (true) {
- String line = br.readLine();
- if (line == null || line.startsWith("DUMP OF SERVICE")) {
- // Done, or moved on to the next service
- break;
- }
- Matcher m = pattern.matcher(line);
- if (m.find()) {
- long count = Long.parseLong(m.group(1));
- String name = m.group(2);
- results.add(new DataValue(name, count));
- }
- }
-
- return results;
- }
-
- /**
- * Processes cpu load information from bugreport. Updates mDataset with the
- * new data.
- *
- * @param br Reader providing the content
- * @throws IOException if error reading file
- */
- public static List<DataValue> readCpuDataset(BufferedReader br) throws IOException {
- List<DataValue> results = new ArrayList<DataValue>();
- Pattern pattern1 = Pattern.compile("(\\S+): (\\S+)% = (.+)% user . (.+)% kernel");
- Pattern pattern2 = Pattern.compile("(\\S+)% (\\S+): (.+)% user . (.+)% kernel");
-
- while (true) {
- String line = br.readLine();
- if (line == null) {
- break;
- }
- line = line.trim();
-
- if (line.startsWith("Load:")) {
- continue;
- }
-
- String name = "";
- double user = 0, kernel = 0, both = 0;
- boolean found = false;
-
- // try pattern1
- Matcher m = pattern1.matcher(line);
- if (m.find()) {
- found = true;
- name = m.group(1);
- both = safeParseLong(m.group(2));
- user = safeParseLong(m.group(3));
- kernel = safeParseLong(m.group(4));
- }
-
- // try pattern2
- m = pattern2.matcher(line);
- if (m.find()) {
- found = true;
- name = m.group(2);
- both = safeParseDouble(m.group(1));
- user = safeParseDouble(m.group(3));
- kernel = safeParseDouble(m.group(4));
- }
-
- if (!found) {
- continue;
- }
-
- if ("TOTAL".equals(name)) {
- if (both < 100) {
- results.add(new DataValue("Idle", (100 - both)));
- }
- } else {
- // Try to make graphs more useful even with rounding;
- // log often has 0% user + 0% kernel = 1% total
- // We arbitrarily give extra to kernel
- if (user > 0) {
- results.add(new DataValue(name + " (user)", user));
- }
- if (kernel > 0) {
- results.add(new DataValue(name + " (kernel)" , both - user));
- }
- if (user == 0 && kernel == 0 && both > 0) {
- results.add(new DataValue(name, both));
- }
- }
-
- }
-
- return results;
- }
-
- private static long safeParseLong(String s) {
- try {
- return Long.parseLong(s);
- } catch (NumberFormatException e) {
- return 0;
- }
- }
-
- private static double safeParseDouble(String s) {
- try {
- return Double.parseDouble(s);
- } catch (NumberFormatException e) {
- return 0;
- }
- }
-
- /**
- * Processes meminfo information from bugreport. Updates mDataset with the
- * new data.
- *
- * @param br Reader providing the content
- * @throws IOException if error reading file
- */
- public static List<DataValue> readMeminfoDataset(BufferedReader br) throws IOException {
- List<DataValue> results = new ArrayList<DataValue>();
- Pattern valuePattern = Pattern.compile("(\\d+) kB");
- long total = 0;
- long other = 0;
-
- // Scan meminfo
- String line = null;
- while ((line = br.readLine()) != null) {
- if (line.contains("----")) {
- continue;
- }
-
- Matcher m = valuePattern.matcher(line);
- if (m.find()) {
- long kb = Long.parseLong(m.group(1));
- if (line.startsWith("MemTotal")) {
- total = kb;
- } else if (line.startsWith("MemFree")) {
- results.add(new DataValue("Free", kb));
- total -= kb;
- } else if (line.startsWith("Slab")) {
- results.add(new DataValue("Slab", kb));
- total -= kb;
- } else if (line.startsWith("PageTables")) {
- results.add(new DataValue("PageTables", kb));
- total -= kb;
- } else if (line.startsWith("Buffers") && kb > 0) {
- results.add(new DataValue("Buffers", kb));
- total -= kb;
- } else if (line.startsWith("Inactive")) {
- results.add(new DataValue("Inactive", kb));
- total -= kb;
- } else if (line.startsWith("MemFree")) {
- results.add(new DataValue("Free", kb));
- total -= kb;
- }
- } else {
- break;
- }
- }
-
- List<DataValue> procRankResults = readProcRankDataset(br, line);
- for (DataValue procRank : procRankResults) {
- if (procRank.value > 2000) { // only show processes using > 2000K in memory
- results.add(procRank);
- } else {
- other += procRank.value;
- }
-
- total -= procRank.value;
- }
-
- if (other > 0) {
- results.add(new DataValue("Other", other));
- }
-
- // The Pss calculation is not necessarily accurate as accounting memory to
- // a process is not accurate. So only if there really is unaccounted for memory do we
- // add it to the pie.
- if (total > 0) {
- results.add(new DataValue("Unknown", total));
- }
-
- return results;
- }
-
- static List<DataValue> readProcRankDataset(BufferedReader br, String header)
- throws IOException {
- List<DataValue> results = new ArrayList<DataValue>();
-
- if (header == null || !header.contains("PID")) {
- return results;
- }
-
- Splitter PROCRANK_SPLITTER = Splitter.on(' ').omitEmptyStrings().trimResults();
- List<String> fields = Lists.newArrayList(PROCRANK_SPLITTER.split(header));
- int pssIndex = fields.indexOf("Pss");
- int cmdIndex = fields.indexOf("cmdline");
-
- if (pssIndex == -1 || cmdIndex == -1) {
- return results;
- }
-
- String line;
- while ((line = br.readLine()) != null) {
- // Extract pss field from procrank output
- fields = Lists.newArrayList(PROCRANK_SPLITTER.split(line));
-
- if (fields.size() < cmdIndex) {
- break;
- }
-
- String cmdline = fields.get(cmdIndex).replace("/system/bin/", "");
- String pssInK = fields.get(pssIndex);
- if (pssInK.endsWith("K")) {
- pssInK = pssInK.substring(0, pssInK.length() - 1);
- }
- long pss = safeParseLong(pssInK);
- results.add(new DataValue(cmdline, pss));
- }
-
- return results;
- }
-
- /**
- * Processes sync information from bugreport. Updates mDataset with the new
- * data.
- *
- * @param br Reader providing the content
- * @throws IOException if error reading file
- */
- public static List<DataValue> readSyncDataset(BufferedReader br) throws IOException {
- List<DataValue> results = new ArrayList<DataValue>();
-
- while (true) {
- String line = br.readLine();
- if (line == null || line.startsWith("DUMP OF SERVICE")) {
- // Done, or moved on to the next service
- break;
- }
- if (line.startsWith(" |") && line.length() > 70) {
- String authority = line.substring(3, 18).trim();
- String duration = line.substring(61, 70).trim();
- // Duration is MM:SS or HH:MM:SS (DateUtils.formatElapsedTime)
- String durParts[] = duration.split(":");
- if (durParts.length == 2) {
- long dur = Long.parseLong(durParts[0]) * 60 + Long
- .parseLong(durParts[1]);
- results.add(new DataValue(authority, dur));
- } else if (duration.length() == 3) {
- long dur = Long.parseLong(durParts[0]) * 3600
- + Long.parseLong(durParts[1]) * 60 + Long
- .parseLong(durParts[2]);
- results.add(new DataValue(authority, dur));
- }
- }
- }
-
- return results;
- }
- }
-
- private void readCpuDataset(BufferedReader br) throws IOException {
- updatePieDataSet(BugReportParser.readCpuDataset(br), "");
- }
-
- private void readMeminfoDataset(BufferedReader br) throws IOException {
- updatePieDataSet(BugReportParser.readMeminfoDataset(br), "PSS in kB");
- }
-
- private void readGfxInfoDataset(BufferedReader br) throws IOException {
- updateBarChartDataSet(BugReportParser.parseGfxInfo(br),
- mGfxPackageName == null ? "" : mGfxPackageName);
- }
-
- private void clearDataSet() {
- mLabel.setText("");
- mDataset.clear();
- mBarDataSet.clear();
- }
-
- private void updatePieDataSet(final List<BugReportParser.DataValue> data, final String label) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- mLabel.setText(label);
- mStackLayout.topControl = mPieChartComposite;
- mChartComposite.layout();
-
- for (BugReportParser.DataValue d : data) {
- mDataset.setValue(d.name, d.value);
- }
- }
- });
- }
-
- private void updateBarChartDataSet(final List<GfxProfileData> gfxProfileData,
- final String label) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- mLabel.setText(label);
- mStackLayout.topControl = mStackedBarComposite;
- mChartComposite.layout();
-
- for (int i = 0; i < gfxProfileData.size(); i++) {
- GfxProfileData d = gfxProfileData.get(i);
- String frameNumber = Integer.toString(i);
-
- mBarDataSet.addValue(d.draw, "Draw", frameNumber);
- mBarDataSet.addValue(d.process, "Process", frameNumber);
- mBarDataSet.addValue(d.execute, "Execute", frameNumber);
- }
- }
- });
- }
-
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/TableHelper.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/TableHelper.java
deleted file mode 100644
index 66dcc0a..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/TableHelper.java
+++ /dev/null
@@ -1,209 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-
-/**
- * Utility class to help using Table objects.
- *
- */
-public final class TableHelper {
- /**
- * Create a TableColumn with the specified parameters. If a
- * <code>PreferenceStore</code> object and a preference entry name String
- * object are provided then the column will listen to change in its width
- * and update the preference store accordingly.
- *
- * @param parent The Table parent object
- * @param header The header string
- * @param style The column style
- * @param sample_text A sample text to figure out column width if preference
- * value is missing
- * @param pref_name The preference entry name for column width
- * @param prefs The preference store
- * @return The TableColumn object that was created
- */
- public static TableColumn createTableColumn(Table parent, String header,
- int style, String sample_text, final String pref_name,
- final IPreferenceStore prefs) {
-
- // create the column
- TableColumn col = new TableColumn(parent, style);
-
- // if there is no pref store or the entry is missing, we use the sample
- // text and pack the column.
- // Otherwise we just read the width from the prefs and apply it.
- if (prefs == null || prefs.contains(pref_name) == false) {
- col.setText(sample_text);
- col.pack();
-
- // init the prefs store with the current value
- if (prefs != null) {
- prefs.setValue(pref_name, col.getWidth());
- }
- } else {
- col.setWidth(prefs.getInt(pref_name));
- }
-
- // set the header
- col.setText(header);
-
- // if there is a pref store and a pref entry name, then we setup a
- // listener to catch column resize to put store the new width value.
- if (prefs != null && pref_name != null) {
- col.addControlListener(new ControlListener() {
- @Override
- public void controlMoved(ControlEvent e) {
- }
-
- @Override
- public void controlResized(ControlEvent e) {
- // get the new width
- int w = ((TableColumn)e.widget).getWidth();
-
- // store in pref store
- prefs.setValue(pref_name, w);
- }
- });
- }
-
- return col;
- }
-
- /**
- * Create a TreeColumn with the specified parameters. If a
- * <code>PreferenceStore</code> object and a preference entry name String
- * object are provided then the column will listen to change in its width
- * and update the preference store accordingly.
- *
- * @param parent The Table parent object
- * @param header The header string
- * @param style The column style
- * @param sample_text A sample text to figure out column width if preference
- * value is missing
- * @param pref_name The preference entry name for column width
- * @param prefs The preference store
- */
- public static void createTreeColumn(Tree parent, String header, int style,
- String sample_text, final String pref_name,
- final IPreferenceStore prefs) {
-
- // create the column
- TreeColumn col = new TreeColumn(parent, style);
-
- // if there is no pref store or the entry is missing, we use the sample
- // text and pack the column.
- // Otherwise we just read the width from the prefs and apply it.
- if (prefs == null || prefs.contains(pref_name) == false) {
- col.setText(sample_text);
- col.pack();
-
- // init the prefs store with the current value
- if (prefs != null) {
- prefs.setValue(pref_name, col.getWidth());
- }
- } else {
- col.setWidth(prefs.getInt(pref_name));
- }
-
- // set the header
- col.setText(header);
-
- // if there is a pref store and a pref entry name, then we setup a
- // listener to catch column resize to put store the new width value.
- if (prefs != null && pref_name != null) {
- col.addControlListener(new ControlListener() {
- @Override
- public void controlMoved(ControlEvent e) {
- }
-
- @Override
- public void controlResized(ControlEvent e) {
- // get the new width
- int w = ((TreeColumn)e.widget).getWidth();
-
- // store in pref store
- prefs.setValue(pref_name, w);
- }
- });
- }
- }
-
- /**
- * Create a TreeColumn with the specified parameters. If a
- * <code>PreferenceStore</code> object and a preference entry name String
- * object are provided then the column will listen to change in its width
- * and update the preference store accordingly.
- *
- * @param parent The Table parent object
- * @param header The header string
- * @param style The column style
- * @param width the width of the column if the preference value is missing
- * @param pref_name The preference entry name for column width
- * @param prefs The preference store
- */
- public static void createTreeColumn(Tree parent, String header, int style,
- int width, final String pref_name,
- final IPreferenceStore prefs) {
-
- // create the column
- TreeColumn col = new TreeColumn(parent, style);
-
- // if there is no pref store or the entry is missing, we use the sample
- // text and pack the column.
- // Otherwise we just read the width from the prefs and apply it.
- if (prefs == null || prefs.contains(pref_name) == false) {
- col.setWidth(width);
-
- // init the prefs store with the current value
- if (prefs != null) {
- prefs.setValue(pref_name, width);
- }
- } else {
- col.setWidth(prefs.getInt(pref_name));
- }
-
- // set the header
- col.setText(header);
-
- // if there is a pref store and a pref entry name, then we setup a
- // listener to catch column resize to put store the new width value.
- if (prefs != null && pref_name != null) {
- col.addControlListener(new ControlListener() {
- @Override
- public void controlMoved(ControlEvent e) {
- }
-
- @Override
- public void controlResized(ControlEvent e) {
- // get the new width
- int w = ((TreeColumn)e.widget).getWidth();
-
- // store in pref store
- prefs.setValue(pref_name, w);
- }
- });
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/TablePanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/TablePanel.java
deleted file mode 100644
index c1eb7f6..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/TablePanel.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmuilib.ITableFocusListener.IFocusedTableActivator;
-
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-import java.util.Arrays;
-
-/**
- * Base class for panel containing Table that need to support copy-paste-selectAll
- */
-public abstract class TablePanel extends ClientDisplayPanel {
- private ITableFocusListener mGlobalListener;
-
- /**
- * Sets a TableFocusListener which will be notified when one of the tables
- * gets or loses focus.
- *
- * @param listener
- */
- public void setTableFocusListener(ITableFocusListener listener) {
- // record the global listener, to make sure table created after
- // this call will still be setup.
- mGlobalListener = listener;
-
- setTableFocusListener();
- }
-
- /**
- * Sets up the Table of object of the panel to work with the global listener.<br>
- * Default implementation does nothing.
- */
- protected void setTableFocusListener() {
-
- }
-
- /**
- * Sets up a Table object to notify the global Table Focus listener when it
- * gets or loses the focus.
- *
- * @param table the Table object.
- * @param colStart
- * @param colEnd
- */
- protected final void addTableToFocusListener(final Table table,
- final int colStart, final int colEnd) {
- // create the activator for this table
- final IFocusedTableActivator activator = new IFocusedTableActivator() {
- @Override
- public void copy(Clipboard clipboard) {
- int[] selection = table.getSelectionIndices();
-
- // we need to sort the items to be sure.
- Arrays.sort(selection);
-
- // all lines must be concatenated.
- StringBuilder sb = new StringBuilder();
-
- // loop on the selection and output the file.
- for (int i : selection) {
- TableItem item = table.getItem(i);
- for (int c = colStart ; c <= colEnd ; c++) {
- sb.append(item.getText(c));
- sb.append('\t');
- }
- sb.append('\n');
- }
-
- // now add that to the clipboard if the string has content
- String data = sb.toString();
- if (data != null && data.length() > 0) {
- clipboard.setContents(
- new Object[] { data },
- new Transfer[] { TextTransfer.getInstance() });
- }
- }
-
- @Override
- public void selectAll() {
- table.selectAll();
- }
- };
-
- // add the focus listener on the table to notify the global listener
- table.addFocusListener(new FocusListener() {
- @Override
- public void focusGained(FocusEvent e) {
- mGlobalListener.focusGained(activator);
- }
-
- @Override
- public void focusLost(FocusEvent e) {
- mGlobalListener.focusLost(activator);
- }
- });
- }
-
- /**
- * Sets up a Table object to notify the global Table Focus listener when it
- * gets or loses the focus.<br>
- * When the copy method is invoked, all columns are put in the clipboard, separated
- * by tabs
- *
- * @param table the Table object.
- */
- protected final void addTableToFocusListener(final Table table) {
- addTableToFocusListener(table, 0, table.getColumnCount()-1);
- }
-
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/ThreadPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/ThreadPanel.java
deleted file mode 100644
index 81e245d..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/ThreadPanel.java
+++ /dev/null
@@ -1,573 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmlib.AndroidDebugBridge.IClientChangeListener;
-import com.android.ddmlib.Client;
-import com.android.ddmlib.ThreadInfo;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Sash;
-import org.eclipse.swt.widgets.Table;
-
-import java.util.Date;
-
-/**
- * Base class for our information panels.
- */
-public class ThreadPanel extends TablePanel {
-
- private final static String PREFS_THREAD_COL_ID = "threadPanel.Col0"; //$NON-NLS-1$
- private final static String PREFS_THREAD_COL_TID = "threadPanel.Col1"; //$NON-NLS-1$
- private final static String PREFS_THREAD_COL_STATUS = "threadPanel.Col2"; //$NON-NLS-1$
- private final static String PREFS_THREAD_COL_UTIME = "threadPanel.Col3"; //$NON-NLS-1$
- private final static String PREFS_THREAD_COL_STIME = "threadPanel.Col4"; //$NON-NLS-1$
- private final static String PREFS_THREAD_COL_NAME = "threadPanel.Col5"; //$NON-NLS-1$
-
- private final static String PREFS_THREAD_SASH = "threadPanel.sash"; //$NON-NLS-1$
-
- private static final String PREFS_STACK_COLUMN = "threadPanel.stack.col0"; //$NON-NLS-1$
-
- private Display mDisplay;
- private Composite mBase;
- private Label mNotEnabled;
- private Label mNotSelected;
-
- private Composite mThreadBase;
- private Table mThreadTable;
- private TableViewer mThreadViewer;
-
- private Composite mStackTraceBase;
- private Button mRefreshStackTraceButton;
- private Label mStackTraceTimeLabel;
- private StackTracePanel mStackTracePanel;
- private Table mStackTraceTable;
-
- /** Indicates if a timer-based Runnable is current requesting thread updates regularly. */
- private boolean mMustStopRecurringThreadUpdate = false;
- /** Flag to tell the recurring thread update to stop running */
- private boolean mRecurringThreadUpdateRunning = false;
-
- private Object mLock = new Object();
-
- private static final String[] THREAD_STATUS = {
- "Zombie", "Runnable", "TimedWait", "Monitor",
- "Wait", "Initializing", "Starting", "Native", "VmWait",
- "Suspended"
- };
-
- /**
- * Content Provider to display the threads of a client.
- * Expected input is a {@link Client} object.
- */
- private static class ThreadContentProvider implements IStructuredContentProvider {
- @Override
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof Client) {
- return ((Client)inputElement).getClientData().getThreads();
- }
-
- return new Object[0];
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // pass
- }
- }
-
-
- /**
- * A Label Provider to use with {@link ThreadContentProvider}. It expects the elements to be
- * of type {@link ThreadInfo}.
- */
- private static class ThreadLabelProvider implements ITableLabelProvider {
-
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- @Override
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof ThreadInfo) {
- ThreadInfo thread = (ThreadInfo)element;
- switch (columnIndex) {
- case 0:
- return (thread.isDaemon() ? "*" : "") + //$NON-NLS-1$ //$NON-NLS-2$
- String.valueOf(thread.getThreadId());
- case 1:
- return String.valueOf(thread.getTid());
- case 2:
- if (thread.getStatus() >= 0 && thread.getStatus() < THREAD_STATUS.length)
- return THREAD_STATUS[thread.getStatus()];
- return "unknown";
- case 3:
- return String.valueOf(thread.getUtime());
- case 4:
- return String.valueOf(thread.getStime());
- case 5:
- return thread.getThreadName();
- }
- }
-
- return null;
- }
-
- @Override
- public void addListener(ILabelProviderListener listener) {
- // pass
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- // pass
- return false;
- }
-
- @Override
- public void removeListener(ILabelProviderListener listener) {
- // pass
- }
- }
-
- /**
- * Create our control(s).
- */
- @Override
- protected Control createControl(Composite parent) {
- mDisplay = parent.getDisplay();
-
- final IPreferenceStore store = DdmUiPreferences.getStore();
-
- mBase = new Composite(parent, SWT.NONE);
- mBase.setLayout(new StackLayout());
-
- // UI for thread not enabled
- mNotEnabled = new Label(mBase, SWT.CENTER | SWT.WRAP);
- mNotEnabled.setText("Thread updates not enabled for selected client\n"
- + "(use toolbar button to enable)");
-
- // UI for not client selected
- mNotSelected = new Label(mBase, SWT.CENTER | SWT.WRAP);
- mNotSelected.setText("no client is selected");
-
- // base composite for selected client with enabled thread update.
- mThreadBase = new Composite(mBase, SWT.NONE);
- mThreadBase.setLayout(new FormLayout());
-
- // table above the sash
- mThreadTable = new Table(mThreadBase, SWT.MULTI | SWT.FULL_SELECTION);
- mThreadTable.setHeaderVisible(true);
- mThreadTable.setLinesVisible(true);
-
- TableHelper.createTableColumn(
- mThreadTable,
- "ID",
- SWT.RIGHT,
- "888", //$NON-NLS-1$
- PREFS_THREAD_COL_ID, store);
-
- TableHelper.createTableColumn(
- mThreadTable,
- "Tid",
- SWT.RIGHT,
- "88888", //$NON-NLS-1$
- PREFS_THREAD_COL_TID, store);
-
- TableHelper.createTableColumn(
- mThreadTable,
- "Status",
- SWT.LEFT,
- "timed-wait", //$NON-NLS-1$
- PREFS_THREAD_COL_STATUS, store);
-
- TableHelper.createTableColumn(
- mThreadTable,
- "utime",
- SWT.RIGHT,
- "utime", //$NON-NLS-1$
- PREFS_THREAD_COL_UTIME, store);
-
- TableHelper.createTableColumn(
- mThreadTable,
- "stime",
- SWT.RIGHT,
- "utime", //$NON-NLS-1$
- PREFS_THREAD_COL_STIME, store);
-
- TableHelper.createTableColumn(
- mThreadTable,
- "Name",
- SWT.LEFT,
- "android.class.ReallyLongClassName.MethodName", //$NON-NLS-1$
- PREFS_THREAD_COL_NAME, store);
-
- mThreadViewer = new TableViewer(mThreadTable);
- mThreadViewer.setContentProvider(new ThreadContentProvider());
- mThreadViewer.setLabelProvider(new ThreadLabelProvider());
-
- mThreadViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- requestThreadStackTrace(getThreadSelection(event.getSelection()));
- }
- });
- mThreadViewer.addDoubleClickListener(new IDoubleClickListener() {
- @Override
- public void doubleClick(DoubleClickEvent event) {
- requestThreadStackTrace(getThreadSelection(event.getSelection()));
- }
- });
-
- // the separating sash
- final Sash sash = new Sash(mThreadBase, SWT.HORIZONTAL);
- Color darkGray = parent.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);
- sash.setBackground(darkGray);
-
- // the UI below the sash
- mStackTraceBase = new Composite(mThreadBase, SWT.NONE);
- mStackTraceBase.setLayout(new GridLayout(2, false));
-
- mRefreshStackTraceButton = new Button(mStackTraceBase, SWT.PUSH);
- mRefreshStackTraceButton.setText("Refresh");
- mRefreshStackTraceButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- requestThreadStackTrace(getThreadSelection(null));
- }
- });
-
- mStackTraceTimeLabel = new Label(mStackTraceBase, SWT.NONE);
- mStackTraceTimeLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- mStackTracePanel = new StackTracePanel();
- mStackTraceTable = mStackTracePanel.createPanel(mStackTraceBase, PREFS_STACK_COLUMN, store);
-
- GridData gd;
- mStackTraceTable.setLayoutData(gd = new GridData(GridData.FILL_BOTH));
- gd.horizontalSpan = 2;
-
- // now setup the sash.
- // form layout data
- FormData data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(sash, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- mThreadTable.setLayoutData(data);
-
- final FormData sashData = new FormData();
- if (store != null && store.contains(PREFS_THREAD_SASH)) {
- sashData.top = new FormAttachment(0, store.getInt(PREFS_THREAD_SASH));
- } else {
- sashData.top = new FormAttachment(50,0); // 50% across
- }
- sashData.left = new FormAttachment(0, 0);
- sashData.right = new FormAttachment(100, 0);
- sash.setLayoutData(sashData);
-
- data = new FormData();
- data.top = new FormAttachment(sash, 0);
- data.bottom = new FormAttachment(100, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- mStackTraceBase.setLayoutData(data);
-
- // allow resizes, but cap at minPanelWidth
- sash.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event e) {
- Rectangle sashRect = sash.getBounds();
- Rectangle panelRect = mThreadBase.getClientArea();
- int bottom = panelRect.height - sashRect.height - 100;
- e.y = Math.max(Math.min(e.y, bottom), 100);
- if (e.y != sashRect.y) {
- sashData.top = new FormAttachment(0, e.y);
- store.setValue(PREFS_THREAD_SASH, e.y);
- mThreadBase.layout();
- }
- }
- });
-
- ((StackLayout)mBase.getLayout()).topControl = mNotSelected;
-
- return mBase;
- }
-
- /**
- * Sets the focus to the proper control inside the panel.
- */
- @Override
- public void setFocus() {
- mThreadTable.setFocus();
- }
-
- /**
- * Sent when an existing client information changed.
- * <p/>
- * This is sent from a non UI thread.
- * @param client the updated client.
- * @param changeMask the bit mask describing the changed properties. It can contain
- * any of the following values: {@link Client#CHANGE_INFO}, {@link Client#CHANGE_NAME}
- * {@link Client#CHANGE_DEBUGGER_STATUS}, {@link Client#CHANGE_THREAD_MODE},
- * {@link Client#CHANGE_THREAD_DATA}, {@link Client#CHANGE_HEAP_MODE},
- * {@link Client#CHANGE_HEAP_DATA}, {@link Client#CHANGE_NATIVE_HEAP_DATA}
- *
- * @see IClientChangeListener#clientChanged(Client, int)
- */
- @Override
- public void clientChanged(final Client client, int changeMask) {
- if (client == getCurrentClient()) {
- if ((changeMask & Client.CHANGE_THREAD_MODE) != 0 ||
- (changeMask & Client.CHANGE_THREAD_DATA) != 0) {
- try {
- mThreadTable.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- clientSelected();
- }
- });
- } catch (SWTException e) {
- // widget is disposed, we do nothing
- }
- } else if ((changeMask & Client.CHANGE_THREAD_STACKTRACE) != 0) {
- try {
- mThreadTable.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- updateThreadStackCall();
- }
- });
- } catch (SWTException e) {
- // widget is disposed, we do nothing
- }
- }
- }
- }
-
- /**
- * Sent when a new device is selected. The new device can be accessed
- * with {@link #getCurrentDevice()}.
- */
- @Override
- public void deviceSelected() {
- // pass
- }
-
- /**
- * Sent when a new client is selected. The new client can be accessed
- * with {@link #getCurrentClient()}.
- */
- @Override
- public void clientSelected() {
- if (mThreadTable.isDisposed()) {
- return;
- }
-
- Client client = getCurrentClient();
-
- mStackTracePanel.setCurrentClient(client);
-
- if (client != null) {
- if (!client.isThreadUpdateEnabled()) {
- ((StackLayout)mBase.getLayout()).topControl = mNotEnabled;
- mThreadViewer.setInput(null);
-
- // if we are currently updating the thread, stop doing it.
- mMustStopRecurringThreadUpdate = true;
- } else {
- ((StackLayout)mBase.getLayout()).topControl = mThreadBase;
- mThreadViewer.setInput(client);
-
- synchronized (mLock) {
- // if we're not updating we start the process
- if (mRecurringThreadUpdateRunning == false) {
- startRecurringThreadUpdate();
- } else if (mMustStopRecurringThreadUpdate) {
- // else if there's a runnable that's still going to get called, lets
- // simply cancel the stop, and keep going
- mMustStopRecurringThreadUpdate = false;
- }
- }
- }
- } else {
- ((StackLayout)mBase.getLayout()).topControl = mNotSelected;
- mThreadViewer.setInput(null);
- }
-
- mBase.layout();
- }
-
- private void requestThreadStackTrace(ThreadInfo selectedThread) {
- if (selectedThread != null) {
- Client client = (Client) mThreadViewer.getInput();
- if (client != null) {
- client.requestThreadStackTrace(selectedThread.getThreadId());
- }
- }
- }
-
- /**
- * Updates the stack call of the currently selected thread.
- * <p/>
- * This <b>must</b> be called from the UI thread.
- */
- private void updateThreadStackCall() {
- Client client = getCurrentClient();
- if (client != null) {
- // get the current selection in the ThreadTable
- ThreadInfo selectedThread = getThreadSelection(null);
-
- if (selectedThread != null) {
- updateThreadStackTrace(selectedThread);
- } else {
- updateThreadStackTrace(null);
- }
- }
- }
-
- /**
- * updates the stackcall of the specified thread. If <code>null</code> the UI is emptied
- * of current data.
- * @param thread
- */
- private void updateThreadStackTrace(ThreadInfo thread) {
- mStackTracePanel.setViewerInput(thread);
-
- if (thread != null) {
- mRefreshStackTraceButton.setEnabled(true);
- long stackcallTime = thread.getStackCallTime();
- if (stackcallTime != 0) {
- String label = new Date(stackcallTime).toString();
- mStackTraceTimeLabel.setText(label);
- } else {
- mStackTraceTimeLabel.setText(""); //$NON-NLS-1$
- }
- } else {
- mRefreshStackTraceButton.setEnabled(true);
- mStackTraceTimeLabel.setText(""); //$NON-NLS-1$
- }
- }
-
- @Override
- protected void setTableFocusListener() {
- addTableToFocusListener(mThreadTable);
- addTableToFocusListener(mStackTraceTable);
- }
-
- /**
- * Initiate recurring events. We use a shorter "initialWait" so we do the
- * first execution sooner. We don't do it immediately because we want to
- * give the clients a chance to get set up.
- */
- private void startRecurringThreadUpdate() {
- mRecurringThreadUpdateRunning = true;
- int initialWait = 1000;
-
- mDisplay.timerExec(initialWait, new Runnable() {
- @Override
- public void run() {
- synchronized (mLock) {
- // lets check we still want updates.
- if (mMustStopRecurringThreadUpdate == false) {
- Client client = getCurrentClient();
- if (client != null) {
- client.requestThreadUpdate();
-
- mDisplay.timerExec(
- DdmUiPreferences.getThreadRefreshInterval() * 1000, this);
- } else {
- // we don't have a Client, which means the runnable is not
- // going to be called through the timer. We reset the running flag.
- mRecurringThreadUpdateRunning = false;
- }
- } else {
- // else actually stops (don't call the timerExec) and reset the flags.
- mRecurringThreadUpdateRunning = false;
- mMustStopRecurringThreadUpdate = false;
- }
- }
- }
- });
- }
-
- /**
- * Returns the current thread selection or <code>null</code> if none is found.
- * If a {@link ISelection} object is specified, the first {@link ThreadInfo} from this selection
- * is returned, otherwise, the <code>ISelection</code> returned by
- * {@link TableViewer#getSelection()} is used.
- * @param selection the {@link ISelection} to use, or <code>null</code>
- */
- private ThreadInfo getThreadSelection(ISelection selection) {
- if (selection == null) {
- selection = mThreadViewer.getSelection();
- }
-
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection)selection;
- Object object = structuredSelection.getFirstElement();
- if (object instanceof ThreadInfo) {
- return (ThreadInfo)object;
- }
- }
-
- return null;
- }
-
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/actions/ICommonAction.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/actions/ICommonAction.java
deleted file mode 100644
index 856b874..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/actions/ICommonAction.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.actions;
-
-/**
- * Common interface for basic action handling. This allows the common ui
- * components to access ToolItem or Action the same way.
- */
-public interface ICommonAction {
- /**
- * Sets the enabled state of this action.
- * @param enabled <code>true</code> to enable, and
- * <code>false</code> to disable
- */
- public void setEnabled(boolean enabled);
-
- /**
- * Sets the checked status of this action.
- * @param checked the new checked status
- */
- public void setChecked(boolean checked);
-
- /**
- * Sets the {@link Runnable} that will be executed when the action is triggered.
- */
- public void setRunnable(Runnable runnable);
-}
-
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/actions/ToolItemAction.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/actions/ToolItemAction.java
deleted file mode 100644
index c7fef32..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/actions/ToolItemAction.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.actions;
-
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-
-/**
- * Wrapper around {@link ToolItem} to implement {@link ICommonAction}
- */
-public class ToolItemAction implements ICommonAction {
- public ToolItem item;
-
- public ToolItemAction(ToolBar parent, int style) {
- item = new ToolItem(parent, style);
- }
-
- /**
- * Sets the enabled state of this action.
- * @param enabled <code>true</code> to enable, and
- * <code>false</code> to disable
- * @see ICommonAction#setChecked(boolean)
- */
- @Override
- public void setChecked(boolean checked) {
- item.setSelection(checked);
- }
-
- /**
- * Sets the enabled state of this action.
- * @param enabled <code>true</code> to enable, and
- * <code>false</code> to disable
- * @see ICommonAction#setEnabled(boolean)
- */
- @Override
- public void setEnabled(boolean enabled) {
- item.setEnabled(enabled);
- }
-
- /**
- * Sets the {@link Runnable} that will be executed when the action is triggered (through
- * {@link SelectionListener#widgetSelected(SelectionEvent)} on the wrapped {@link ToolItem}).
- * @see ICommonAction#setRunnable(Runnable)
- */
- @Override
- public void setRunnable(final Runnable runnable) {
- item.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- runnable.run();
- }
- });
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/annotation/UiThread.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/annotation/UiThread.java
deleted file mode 100644
index 8e9e11b..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/annotation/UiThread.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.annotation;
-
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Simple utility annotation used only to mark methods that are executed on the UI thread.
- * This annotation's sole purpose is to help reading the source code. It has no additional effect.
- */
-@Target({ ElementType.METHOD })
-@Retention(RetentionPolicy.SOURCE)
-public @interface UiThread {
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/annotation/WorkerThread.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/annotation/WorkerThread.java
deleted file mode 100644
index e767eda..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/annotation/WorkerThread.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.annotation;
-
-import java.lang.annotation.Target;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-
-/**
- * Simple utility annotation used only to mark methods that are not executed on the UI thread.
- * This annotation's sole purpose is to help reading the source code. It has no additional effect.
- */
-@Target({ ElementType.METHOD })
-@Retention(RetentionPolicy.SOURCE)
-public @interface WorkerThread {
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/console/DdmConsole.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/console/DdmConsole.java
deleted file mode 100644
index 4df4376..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/console/DdmConsole.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.console;
-
-
-/**
- * Static Console used to ouput messages. By default outputs the message to System.out and
- * System.err, but can receive a IDdmConsole object which will actually do something.
- */
-public class DdmConsole {
-
- private static IDdmConsole mConsole;
-
- /**
- * Prints a message to the android console.
- * @param message the message to print
- * @param forceDisplay if true, this force the console to be displayed.
- */
- public static void printErrorToConsole(String message) {
- if (mConsole != null) {
- mConsole.printErrorToConsole(message);
- } else {
- System.err.println(message);
- }
- }
-
- /**
- * Prints several messages to the android console.
- * @param messages the messages to print
- * @param forceDisplay if true, this force the console to be displayed.
- */
- public static void printErrorToConsole(String[] messages) {
- if (mConsole != null) {
- mConsole.printErrorToConsole(messages);
- } else {
- for (String message : messages) {
- System.err.println(message);
- }
- }
- }
-
- /**
- * Prints a message to the android console.
- * @param message the message to print
- * @param forceDisplay if true, this force the console to be displayed.
- */
- public static void printToConsole(String message) {
- if (mConsole != null) {
- mConsole.printToConsole(message);
- } else {
- System.out.println(message);
- }
- }
-
- /**
- * Prints several messages to the android console.
- * @param messages the messages to print
- * @param forceDisplay if true, this force the console to be displayed.
- */
- public static void printToConsole(String[] messages) {
- if (mConsole != null) {
- mConsole.printToConsole(messages);
- } else {
- for (String message : messages) {
- System.out.println(message);
- }
- }
- }
-
- /**
- * Sets a IDdmConsole to override the default behavior of the console
- * @param console The new IDdmConsole
- * **/
- public static void setConsole(IDdmConsole console) {
- mConsole = console;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/console/IDdmConsole.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/console/IDdmConsole.java
deleted file mode 100644
index 3679d41..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/console/IDdmConsole.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.console;
-
-
-/**
- * DDMS console interface.
- */
-public interface IDdmConsole {
- /**
- * Prints a message to the android console.
- * @param message the message to print
- */
- public void printErrorToConsole(String message);
-
- /**
- * Prints several messages to the android console.
- * @param messages the messages to print
- */
- public void printErrorToConsole(String[] messages);
-
- /**
- * Prints a message to the android console.
- * @param message the message to print
- */
- public void printToConsole(String message);
-
- /**
- * Prints several messages to the android console.
- * @param messages the messages to print
- */
- public void printToConsole(String[] messages);
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/explorer/DeviceContentProvider.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/explorer/DeviceContentProvider.java
deleted file mode 100644
index 062d4f0..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/explorer/DeviceContentProvider.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.explorer;
-
-import com.android.ddmlib.FileListingService;
-import com.android.ddmlib.FileListingService.FileEntry;
-import com.android.ddmlib.FileListingService.IListingReceiver;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Tree;
-
-/**
- * Content provider class for device Explorer.
- */
-class DeviceContentProvider implements ITreeContentProvider {
-
- private TreeViewer mViewer;
- private FileListingService mFileListingService;
- private FileEntry mRootEntry;
-
- private IListingReceiver sListingReceiver = new IListingReceiver() {
- @Override
- public void setChildren(final FileEntry entry, FileEntry[] children) {
- final Tree t = mViewer.getTree();
- if (t != null && t.isDisposed() == false) {
- Display display = t.getDisplay();
- if (display.isDisposed() == false) {
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (t.isDisposed() == false) {
- // refresh the entry.
- mViewer.refresh(entry);
-
- // force it open, since on linux and windows
- // when getChildren() returns null, the node is
- // not considered expanded.
- mViewer.setExpandedState(entry, true);
- }
- }
- });
- }
- }
- }
-
- @Override
- public void refreshEntry(final FileEntry entry) {
- final Tree t = mViewer.getTree();
- if (t != null && t.isDisposed() == false) {
- Display display = t.getDisplay();
- if (display.isDisposed() == false) {
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (t.isDisposed() == false) {
- // refresh the entry.
- mViewer.refresh(entry);
- }
- }
- });
- }
- }
- }
- };
-
- /**
- *
- */
- public DeviceContentProvider() {
- }
-
- public void setListingService(FileListingService fls) {
- mFileListingService = fls;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java.lang.Object)
- */
- @Override
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof FileEntry) {
- FileEntry parentEntry = (FileEntry)parentElement;
-
- Object[] oldEntries = parentEntry.getCachedChildren();
- Object[] newEntries = mFileListingService.getChildren(parentEntry,
- true, sListingReceiver);
-
- if (newEntries != null) {
- return newEntries;
- } else {
- // if null was returned, this means the cache was not valid,
- // and a thread was launched for ls. sListingReceiver will be
- // notified with the new entries.
- return oldEntries;
- }
- }
- return new Object[0];
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(java.lang.Object)
- */
- @Override
- public Object getParent(Object element) {
- if (element instanceof FileEntry) {
- FileEntry entry = (FileEntry)element;
-
- return entry.getParent();
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java.lang.Object)
- */
- @Override
- public boolean hasChildren(Object element) {
- if (element instanceof FileEntry) {
- FileEntry entry = (FileEntry)element;
-
- return entry.getType() == FileListingService.TYPE_DIRECTORY;
- }
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- @Override
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof FileEntry) {
- FileEntry entry = (FileEntry)inputElement;
- if (entry.isRoot()) {
- return getChildren(mRootEntry);
- }
- }
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- @Override
- public void dispose() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if (viewer instanceof TreeViewer) {
- mViewer = (TreeViewer)viewer;
- }
- if (newInput instanceof FileEntry) {
- mRootEntry = (FileEntry)newInput;
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/explorer/DeviceExplorer.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/explorer/DeviceExplorer.java
deleted file mode 100644
index b69d3b5..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/explorer/DeviceExplorer.java
+++ /dev/null
@@ -1,922 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.explorer;
-
-import com.android.ddmlib.AdbCommandRejectedException;
-import com.android.ddmlib.DdmConstants;
-import com.android.ddmlib.FileListingService;
-import com.android.ddmlib.FileListingService.FileEntry;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.IShellOutputReceiver;
-import com.android.ddmlib.ShellCommandUnresponsiveException;
-import com.android.ddmlib.SyncException;
-import com.android.ddmlib.SyncService;
-import com.android.ddmlib.SyncService.ISyncProgressMonitor;
-import com.android.ddmlib.TimeoutException;
-import com.android.ddmuilib.DdmUiPreferences;
-import com.android.ddmuilib.ImageLoader;
-import com.android.ddmuilib.Panel;
-import com.android.ddmuilib.SyncProgressHelper;
-import com.android.ddmuilib.SyncProgressHelper.SyncRunnable;
-import com.android.ddmuilib.TableHelper;
-import com.android.ddmuilib.actions.ICommonAction;
-import com.android.ddmuilib.console.DdmConsole;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.ViewerDropAdapter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.DirectoryDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Device filesystem explorer class.
- */
-public class DeviceExplorer extends Panel {
-
- private final static String TRACE_KEY_EXT = ".key"; // $NON-NLS-1S
- private final static String TRACE_DATA_EXT = ".data"; // $NON-NLS-1S
-
- private static Pattern mKeyFilePattern = Pattern.compile(
- "(.+)\\" + TRACE_KEY_EXT); // $NON-NLS-1S
- private static Pattern mDataFilePattern = Pattern.compile(
- "(.+)\\" + TRACE_DATA_EXT); // $NON-NLS-1S
-
- public static String COLUMN_NAME = "android.explorer.name"; //$NON-NLS-1S
- public static String COLUMN_SIZE = "android.explorer.size"; //$NON-NLS-1S
- public static String COLUMN_DATE = "android.explorer.data"; //$NON-NLS-1S
- public static String COLUMN_TIME = "android.explorer.time"; //$NON-NLS-1S
- public static String COLUMN_PERMISSIONS = "android.explorer.permissions"; // $NON-NLS-1S
- public static String COLUMN_INFO = "android.explorer.info"; // $NON-NLS-1S
-
- private Composite mParent;
- private TreeViewer mTreeViewer;
- private Tree mTree;
- private DeviceContentProvider mContentProvider;
-
- private ICommonAction mPushAction;
- private ICommonAction mPullAction;
- private ICommonAction mDeleteAction;
- private ICommonAction mCreateNewFolderAction;
-
- private Image mFileImage;
- private Image mFolderImage;
- private Image mPackageImage;
- private Image mOtherImage;
-
- private IDevice mCurrentDevice;
-
- private String mDefaultSave;
-
- public DeviceExplorer() {
- }
-
- /**
- * Sets custom images for the device explorer. If none are set then defaults are used.
- * This can be useful to set platform-specific explorer icons.
- *
- * This should be called before {@link #createControl(Composite)}.
- *
- * @param fileImage the icon to represent a file.
- * @param folderImage the icon to represent a folder.
- * @param packageImage the icon to represent an apk.
- * @param otherImage the icon to represent other types of files.
- */
- public void setCustomImages(Image fileImage, Image folderImage, Image packageImage,
- Image otherImage) {
- mFileImage = fileImage;
- mFolderImage = folderImage;
- mPackageImage = packageImage;
- mOtherImage = otherImage;
- }
-
- /**
- * Sets the actions so that the device explorer can enable/disable them based on the current
- * selection
- * @param pushAction
- * @param pullAction
- * @param deleteAction
- * @param createNewFolderAction
- */
- public void setActions(ICommonAction pushAction, ICommonAction pullAction,
- ICommonAction deleteAction, ICommonAction createNewFolderAction) {
- mPushAction = pushAction;
- mPullAction = pullAction;
- mDeleteAction = deleteAction;
- mCreateNewFolderAction = createNewFolderAction;
- }
-
- /**
- * Creates a control capable of displaying some information. This is
- * called once, when the application is initializing, from the UI thread.
- */
- @Override
- protected Control createControl(Composite parent) {
- mParent = parent;
- parent.setLayout(new FillLayout());
-
- ImageLoader loader = ImageLoader.getDdmUiLibLoader();
- if (mFileImage == null) {
- mFileImage = loader.loadImage("file.png", mParent.getDisplay());
- }
- if (mFolderImage == null) {
- mFolderImage = loader.loadImage("folder.png", mParent.getDisplay());
- }
- if (mPackageImage == null) {
- mPackageImage = loader.loadImage("android.png", mParent.getDisplay());
- }
- if (mOtherImage == null) {
- // TODO: find a default image for other.
- }
-
- mTree = new Tree(parent, SWT.MULTI | SWT.FULL_SELECTION | SWT.VIRTUAL);
- mTree.setHeaderVisible(true);
-
- IPreferenceStore store = DdmUiPreferences.getStore();
-
- // create columns
- TableHelper.createTreeColumn(mTree, "Name", SWT.LEFT,
- "0000drwxrwxrwx", COLUMN_NAME, store); //$NON-NLS-1$
- TableHelper.createTreeColumn(mTree, "Size", SWT.RIGHT,
- "000000", COLUMN_SIZE, store); //$NON-NLS-1$
- TableHelper.createTreeColumn(mTree, "Date", SWT.LEFT,
- "2007-08-14", COLUMN_DATE, store); //$NON-NLS-1$
- TableHelper.createTreeColumn(mTree, "Time", SWT.LEFT,
- "20:54", COLUMN_TIME, store); //$NON-NLS-1$
- TableHelper.createTreeColumn(mTree, "Permissions", SWT.LEFT,
- "drwxrwxrwx", COLUMN_PERMISSIONS, store); //$NON-NLS-1$
- TableHelper.createTreeColumn(mTree, "Info", SWT.LEFT,
- "drwxrwxrwx", COLUMN_INFO, store); //$NON-NLS-1$
-
- // create the jface wrapper
- mTreeViewer = new TreeViewer(mTree);
-
- // setup data provider
- mContentProvider = new DeviceContentProvider();
- mTreeViewer.setContentProvider(mContentProvider);
- mTreeViewer.setLabelProvider(new FileLabelProvider(mFileImage,
- mFolderImage, mPackageImage, mOtherImage));
-
- // setup a listener for selection
- mTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection sel = event.getSelection();
- if (sel.isEmpty()) {
- mPullAction.setEnabled(false);
- mPushAction.setEnabled(false);
- mDeleteAction.setEnabled(false);
- mCreateNewFolderAction.setEnabled(false);
- return;
- }
- if (sel instanceof IStructuredSelection) {
- IStructuredSelection selection = (IStructuredSelection) sel;
- Object element = selection.getFirstElement();
- if (element == null)
- return;
- if (element instanceof FileEntry) {
- mPullAction.setEnabled(true);
- mPushAction.setEnabled(selection.size() == 1);
- if (selection.size() == 1) {
- FileEntry entry = (FileEntry) element;
- setDeleteEnabledState(entry);
- mCreateNewFolderAction.setEnabled(entry.isDirectory());
- } else {
- mDeleteAction.setEnabled(false);
- }
- }
- }
- }
- });
-
- // add support for double click
- mTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
- @Override
- public void doubleClick(DoubleClickEvent event) {
- ISelection sel = event.getSelection();
-
- if (sel instanceof IStructuredSelection) {
- IStructuredSelection selection = (IStructuredSelection) sel;
-
- if (selection.size() == 1) {
- FileEntry entry = (FileEntry)selection.getFirstElement();
- String name = entry.getName();
-
- FileEntry parentEntry = entry.getParent();
-
- // can't really do anything with no parent
- if (parentEntry == null) {
- return;
- }
-
- // check this is a file like we want.
- Matcher m = mKeyFilePattern.matcher(name);
- if (m.matches()) {
- // get the name w/o the extension
- String baseName = m.group(1);
-
- // add the data extension
- String dataName = baseName + TRACE_DATA_EXT;
-
- FileEntry dataEntry = parentEntry.findChild(dataName);
-
- handleTraceDoubleClick(baseName, entry, dataEntry);
-
- } else {
- m = mDataFilePattern.matcher(name);
- if (m.matches()) {
- // get the name w/o the extension
- String baseName = m.group(1);
-
- // add the key extension
- String keyName = baseName + TRACE_KEY_EXT;
-
- FileEntry keyEntry = parentEntry.findChild(keyName);
-
- handleTraceDoubleClick(baseName, keyEntry, entry);
- }
- }
- }
- }
- }
- });
-
- // setup drop listener
- mTreeViewer.addDropSupport(DND.DROP_COPY | DND.DROP_MOVE,
- new Transfer[] { FileTransfer.getInstance() },
- new ViewerDropAdapter(mTreeViewer) {
- @Override
- public boolean performDrop(Object data) {
- // get the item on which we dropped the item(s)
- FileEntry target = (FileEntry)getCurrentTarget();
-
- // in case we drop at the same level as root
- if (target == null) {
- return false;
- }
-
- // if the target is not a directory, we get the parent directory
- if (target.isDirectory() == false) {
- target = target.getParent();
- }
-
- if (target == null) {
- return false;
- }
-
- // get the list of files to drop
- String[] files = (String[])data;
-
- // do the drop
- pushFiles(files, target);
-
- // we need to finish with a refresh
- refresh(target);
-
- return true;
- }
-
- @Override
- public boolean validateDrop(Object target, int operation, TransferData transferType) {
- if (target == null) {
- return false;
- }
-
- // convert to the real item
- FileEntry targetEntry = (FileEntry)target;
-
- // if the target is not a directory, we get the parent directory
- if (targetEntry.isDirectory() == false) {
- target = targetEntry.getParent();
- }
-
- if (target == null) {
- return false;
- }
-
- return true;
- }
- });
-
- // create and start the refresh thread
- new Thread("Device Ls refresher") {
- @Override
- public void run() {
- while (true) {
- try {
- sleep(FileListingService.REFRESH_RATE);
- } catch (InterruptedException e) {
- return;
- }
-
- if (mTree != null && mTree.isDisposed() == false) {
- Display display = mTree.getDisplay();
- if (display.isDisposed() == false) {
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (mTree.isDisposed() == false) {
- mTreeViewer.refresh(true);
- }
- }
- });
- } else {
- return;
- }
- } else {
- return;
- }
- }
-
- }
- }.start();
-
- return mTree;
- }
-
- @Override
- protected void postCreation() {
-
- }
-
- /**
- * Sets the focus to the proper control inside the panel.
- */
- @Override
- public void setFocus() {
- mTree.setFocus();
- }
-
- /**
- * Processes a double click on a trace file
- * @param baseName the base name of the 2 files.
- * @param keyEntry The FileEntry for the .key file.
- * @param dataEntry The FileEntry for the .data file.
- */
- private void handleTraceDoubleClick(String baseName, FileEntry keyEntry,
- FileEntry dataEntry) {
- // first we need to download the files.
- File keyFile;
- File dataFile;
- String path;
- try {
- // create a temp file for keyFile
- File f = File.createTempFile(baseName, DdmConstants.DOT_TRACE);
- f.delete();
- f.mkdir();
-
- path = f.getAbsolutePath();
-
- keyFile = new File(path + File.separator + keyEntry.getName());
- dataFile = new File(path + File.separator + dataEntry.getName());
- } catch (IOException e) {
- return;
- }
-
- // download the files
- try {
- SyncService sync = mCurrentDevice.getSyncService();
- if (sync != null) {
- ISyncProgressMonitor monitor = SyncService.getNullProgressMonitor();
- sync.pullFile(keyEntry, keyFile.getAbsolutePath(), monitor);
- sync.pullFile(dataEntry, dataFile.getAbsolutePath(), monitor);
-
- // now that we have the file, we need to launch traceview
- String[] command = new String[2];
- command[0] = DdmUiPreferences.getTraceview();
- command[1] = path + File.separator + baseName;
-
- try {
- final Process p = Runtime.getRuntime().exec(command);
-
- // create a thread for the output
- new Thread("Traceview output") {
- @Override
- public void run() {
- // create a buffer to read the stderr output
- InputStreamReader is = new InputStreamReader(p.getErrorStream());
- BufferedReader resultReader = new BufferedReader(is);
-
- // read the lines as they come. if null is returned, it's
- // because the process finished
- try {
- while (true) {
- String line = resultReader.readLine();
- if (line != null) {
- DdmConsole.printErrorToConsole("Traceview: " + line);
- } else {
- break;
- }
- }
- // get the return code from the process
- p.waitFor();
- } catch (IOException e) {
- } catch (InterruptedException e) {
-
- }
- }
- }.start();
-
- } catch (IOException e) {
- }
- }
- } catch (IOException e) {
- DdmConsole.printErrorToConsole(String.format(
- "Failed to pull %1$s: %2$s", keyEntry.getName(), e.getMessage()));
- return;
- } catch (SyncException e) {
- if (e.wasCanceled() == false) {
- DdmConsole.printErrorToConsole(String.format(
- "Failed to pull %1$s: %2$s", keyEntry.getName(), e.getMessage()));
- return;
- }
- } catch (TimeoutException e) {
- DdmConsole.printErrorToConsole(String.format(
- "Failed to pull %1$s: timeout", keyEntry.getName()));
- } catch (AdbCommandRejectedException e) {
- DdmConsole.printErrorToConsole(String.format(
- "Failed to pull %1$s: %2$s", keyEntry.getName(), e.getMessage()));
- }
- }
-
- /**
- * Pull the current selection on the local drive. This method displays
- * a dialog box to let the user select where to store the file(s) and
- * folder(s).
- */
- public void pullSelection() {
- // get the selection
- TreeItem[] items = mTree.getSelection();
-
- // name of the single file pull, or null if we're pulling a directory
- // or more than one object.
- String filePullName = null;
- FileEntry singleEntry = null;
-
- // are we pulling a single file?
- if (items.length == 1) {
- singleEntry = (FileEntry)items[0].getData();
- if (singleEntry.getType() == FileListingService.TYPE_FILE) {
- filePullName = singleEntry.getName();
- }
- }
-
- // where do we save by default?
- String defaultPath = mDefaultSave;
- if (defaultPath == null) {
- defaultPath = System.getProperty("user.home"); //$NON-NLS-1$
- }
-
- if (filePullName != null) {
- FileDialog fileDialog = new FileDialog(mParent.getShell(), SWT.SAVE);
-
- fileDialog.setText("Get Device File");
- fileDialog.setFileName(filePullName);
- fileDialog.setFilterPath(defaultPath);
-
- String fileName = fileDialog.open();
- if (fileName != null) {
- mDefaultSave = fileDialog.getFilterPath();
-
- pullFile(singleEntry, fileName);
- }
- } else {
- DirectoryDialog directoryDialog = new DirectoryDialog(mParent.getShell(), SWT.SAVE);
-
- directoryDialog.setText("Get Device Files/Folders");
- directoryDialog.setFilterPath(defaultPath);
-
- String directoryName = directoryDialog.open();
- if (directoryName != null) {
- pullSelection(items, directoryName);
- }
- }
- }
-
- /**
- * Push new file(s) and folder(s) into the current selection. Current
- * selection must be single item. If the current selection is not a
- * directory, the parent directory is used.
- * This method displays a dialog to let the user choose file to push to
- * the device.
- */
- public void pushIntoSelection() {
- // get the name of the object we're going to pull
- TreeItem[] items = mTree.getSelection();
-
- if (items.length == 0) {
- return;
- }
-
- FileDialog dlg = new FileDialog(mParent.getShell(), SWT.OPEN);
- String fileName;
-
- dlg.setText("Put File on Device");
-
- // There should be only one.
- FileEntry entry = (FileEntry)items[0].getData();
- dlg.setFileName(entry.getName());
-
- String defaultPath = mDefaultSave;
- if (defaultPath == null) {
- defaultPath = System.getProperty("user.home"); //$NON-NLS-1$
- }
- dlg.setFilterPath(defaultPath);
-
- fileName = dlg.open();
- if (fileName != null) {
- mDefaultSave = dlg.getFilterPath();
-
- // we need to figure out the remote path based on the current selection type.
- String remotePath;
- FileEntry toRefresh = entry;
- if (entry.isDirectory()) {
- remotePath = entry.getFullPath();
- } else {
- toRefresh = entry.getParent();
- remotePath = toRefresh.getFullPath();
- }
-
- pushFile(fileName, remotePath);
- mTreeViewer.refresh(toRefresh);
- }
- }
-
- public void deleteSelection() {
- // get the name of the object we're going to pull
- TreeItem[] items = mTree.getSelection();
-
- if (items.length != 1) {
- return;
- }
-
- FileEntry entry = (FileEntry)items[0].getData();
- final FileEntry parentEntry = entry.getParent();
-
- // create the delete command
- String command = "rm " + entry.getFullEscapedPath(); //$NON-NLS-1$
-
- try {
- mCurrentDevice.executeShellCommand(command, new IShellOutputReceiver() {
- @Override
- public void addOutput(byte[] data, int offset, int length) {
- // pass
- // TODO get output to display errors if any.
- }
-
- @Override
- public void flush() {
- mTreeViewer.refresh(parentEntry);
- }
-
- @Override
- public boolean isCancelled() {
- return false;
- }
- });
- } catch (IOException e) {
- // adb failed somehow, we do nothing. We should be displaying the error from the output
- // of the shell command.
- } catch (TimeoutException e) {
- // adb failed somehow, we do nothing. We should be displaying the error from the output
- // of the shell command.
- } catch (AdbCommandRejectedException e) {
- // adb failed somehow, we do nothing. We should be displaying the error from the output
- // of the shell command.
- } catch (ShellCommandUnresponsiveException e) {
- // adb failed somehow, we do nothing. We should be displaying the error from the output
- // of the shell command.
- }
-
- }
-
- public void createNewFolderInSelection() {
- TreeItem[] items = mTree.getSelection();
-
- if (items.length != 1) {
- return;
- }
-
- final FileEntry entry = (FileEntry) items[0].getData();
-
- if (entry.isDirectory()) {
- InputDialog inputDialog = new InputDialog(mTree.getShell(), "New Folder",
- "Please enter the new folder name", "New Folder", new IInputValidator() {
- @Override
- public String isValid(String newText) {
- if ((newText != null) && (newText.length() > 0)
- && (newText.trim().length() > 0)
- && (newText.indexOf('/') == -1)
- && (newText.indexOf('\\') == -1)) {
- return null;
- } else {
- return "Invalid name";
- }
- }
- });
- inputDialog.open();
- String value = inputDialog.getValue();
-
- if (value != null) {
- // create the mkdir command
- String command = "mkdir " + entry.getFullEscapedPath() //$NON-NLS-1$
- + FileListingService.FILE_SEPARATOR + FileEntry.escape(value);
-
- try {
- mCurrentDevice.executeShellCommand(command, new IShellOutputReceiver() {
-
- @Override
- public boolean isCancelled() {
- return false;
- }
-
- @Override
- public void flush() {
- mTreeViewer.refresh(entry);
- }
-
- @Override
- public void addOutput(byte[] data, int offset, int length) {
- String errorMessage;
- if (data != null) {
- errorMessage = new String(data);
- } else {
- errorMessage = "";
- }
- Status status = new Status(IStatus.ERROR,
- "DeviceExplorer", 0, errorMessage, null); //$NON-NLS-1$
- ErrorDialog.openError(mTree.getShell(), "New Folder Error",
- "New Folder Error", status);
- }
- });
- } catch (TimeoutException e) {
- // adb failed somehow, we do nothing. We should be
- // displaying the error from the output of the shell
- // command.
- } catch (AdbCommandRejectedException e) {
- // adb failed somehow, we do nothing. We should be
- // displaying the error from the output of the shell
- // command.
- } catch (ShellCommandUnresponsiveException e) {
- // adb failed somehow, we do nothing. We should be
- // displaying the error from the output of the shell
- // command.
- } catch (IOException e) {
- // adb failed somehow, we do nothing. We should be
- // displaying the error from the output of the shell
- // command.
- }
- }
- }
- }
-
- /**
- * Force a full refresh of the explorer.
- */
- public void refresh() {
- mTreeViewer.refresh(true);
- }
-
- /**
- * Sets the new device to explorer
- */
- public void switchDevice(final IDevice device) {
- if (device != mCurrentDevice) {
- mCurrentDevice = device;
- // now we change the input. but we need to do that in the
- // ui thread.
- if (mTree.isDisposed() == false) {
- Display d = mTree.getDisplay();
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (mTree.isDisposed() == false) {
- // new service
- if (mCurrentDevice != null) {
- FileListingService fls = mCurrentDevice.getFileListingService();
- mContentProvider.setListingService(fls);
- mTreeViewer.setInput(fls.getRoot());
- }
- }
- }
- });
- }
- }
- }
-
- /**
- * Refresh an entry from a non ui thread.
- * @param entry the entry to refresh.
- */
- private void refresh(final FileEntry entry) {
- Display d = mTreeViewer.getTree().getDisplay();
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- mTreeViewer.refresh(entry);
- }
- });
- }
-
- /**
- * Pulls the selection from a device.
- * @param items the tree selection the remote file on the device
- * @param localDirector the local directory in which to save the files.
- */
- private void pullSelection(TreeItem[] items, final String localDirectory) {
- try {
- final SyncService sync = mCurrentDevice.getSyncService();
- if (sync != null) {
- // make a list of the FileEntry.
- ArrayList<FileEntry> entries = new ArrayList<FileEntry>();
- for (TreeItem item : items) {
- Object data = item.getData();
- if (data instanceof FileEntry) {
- entries.add((FileEntry)data);
- }
- }
- final FileEntry[] entryArray = entries.toArray(
- new FileEntry[entries.size()]);
-
- SyncProgressHelper.run(new SyncRunnable() {
- @Override
- public void run(ISyncProgressMonitor monitor)
- throws SyncException, IOException, TimeoutException {
- sync.pull(entryArray, localDirectory, monitor);
- }
-
- @Override
- public void close() {
- sync.close();
- }
- }, "Pulling file(s) from the device", mParent.getShell());
- }
- } catch (SyncException e) {
- if (e.wasCanceled() == false) {
- DdmConsole.printErrorToConsole(String.format(
- "Failed to pull selection: %1$s", e.getMessage()));
- }
- } catch (Exception e) {
- DdmConsole.printErrorToConsole( "Failed to pull selection");
- DdmConsole.printErrorToConsole(e.getMessage());
- }
- }
-
- /**
- * Pulls a file from a device.
- * @param remote the remote file on the device
- * @param local the destination filepath
- */
- private void pullFile(final FileEntry remote, final String local) {
- try {
- final SyncService sync = mCurrentDevice.getSyncService();
- if (sync != null) {
- SyncProgressHelper.run(new SyncRunnable() {
- @Override
- public void run(ISyncProgressMonitor monitor)
- throws SyncException, IOException, TimeoutException {
- sync.pullFile(remote, local, monitor);
- }
-
- @Override
- public void close() {
- sync.close();
- }
- }, String.format("Pulling %1$s from the device", remote.getName()),
- mParent.getShell());
- }
- } catch (SyncException e) {
- if (e.wasCanceled() == false) {
- DdmConsole.printErrorToConsole(String.format(
- "Failed to pull selection: %1$s", e.getMessage()));
- }
- } catch (Exception e) {
- DdmConsole.printErrorToConsole( "Failed to pull selection");
- DdmConsole.printErrorToConsole(e.getMessage());
- }
- }
-
- /**
- * Pushes several files and directory into a remote directory.
- * @param localFiles
- * @param remoteDirectory
- */
- private void pushFiles(final String[] localFiles, final FileEntry remoteDirectory) {
- try {
- final SyncService sync = mCurrentDevice.getSyncService();
- if (sync != null) {
- SyncProgressHelper.run(new SyncRunnable() {
- @Override
- public void run(ISyncProgressMonitor monitor)
- throws SyncException, IOException, TimeoutException {
- sync.push(localFiles, remoteDirectory, monitor);
- }
-
- @Override
- public void close() {
- sync.close();
- }
- }, "Pushing file(s) to the device", mParent.getShell());
- }
- } catch (SyncException e) {
- if (e.wasCanceled() == false) {
- DdmConsole.printErrorToConsole(String.format(
- "Failed to push selection: %1$s", e.getMessage()));
- }
- } catch (Exception e) {
- DdmConsole.printErrorToConsole("Failed to push the items");
- DdmConsole.printErrorToConsole(e.getMessage());
- }
- }
-
- /**
- * Pushes a file on a device.
- * @param local the local filepath of the file to push
- * @param remoteDirectory the remote destination directory on the device
- */
- private void pushFile(final String local, final String remoteDirectory) {
- try {
- final SyncService sync = mCurrentDevice.getSyncService();
- if (sync != null) {
- // get the file name
- String[] segs = local.split(Pattern.quote(File.separator));
- String name = segs[segs.length-1];
- final String remoteFile = remoteDirectory + FileListingService.FILE_SEPARATOR
- + name;
-
- SyncProgressHelper.run(new SyncRunnable() {
- @Override
- public void run(ISyncProgressMonitor monitor)
- throws SyncException, IOException, TimeoutException {
- sync.pushFile(local, remoteFile, monitor);
- }
-
- @Override
- public void close() {
- sync.close();
- }
- }, String.format("Pushing %1$s to the device.", name), mParent.getShell());
- }
- } catch (SyncException e) {
- if (e.wasCanceled() == false) {
- DdmConsole.printErrorToConsole(String.format(
- "Failed to push selection: %1$s", e.getMessage()));
- }
- } catch (Exception e) {
- DdmConsole.printErrorToConsole("Failed to push the item(s).");
- DdmConsole.printErrorToConsole(e.getMessage());
- }
- }
-
- /**
- * Sets the enabled state based on a FileEntry properties
- * @param element The selected FileEntry
- */
- protected void setDeleteEnabledState(FileEntry element) {
- mDeleteAction.setEnabled(element.getType() == FileListingService.TYPE_FILE);
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/explorer/FileLabelProvider.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/explorer/FileLabelProvider.java
deleted file mode 100644
index 1240e59..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/explorer/FileLabelProvider.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.explorer;
-
-import com.android.ddmlib.FileListingService;
-import com.android.ddmlib.FileListingService.FileEntry;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * Label provider for the FileEntry.
- */
-class FileLabelProvider implements ILabelProvider, ITableLabelProvider {
-
- private Image mFileImage;
- private Image mFolderImage;
- private Image mPackageImage;
- private Image mOtherImage;
-
- /**
- * Creates Label provider with custom images.
- * @param fileImage the Image to represent a file
- * @param folderImage the Image to represent a folder
- * @param packageImage the Image to represent a .apk file. If null,
- * fileImage is used instead.
- * @param otherImage the Image to represent all other entry type.
- */
- public FileLabelProvider(Image fileImage, Image folderImage,
- Image packageImage, Image otherImage) {
- mFileImage = fileImage;
- mFolderImage = folderImage;
- mOtherImage = otherImage;
- if (packageImage != null) {
- mPackageImage = packageImage;
- } else {
- mPackageImage = fileImage;
- }
- }
-
- /**
- * Creates a label provider with default images.
- *
- */
- public FileLabelProvider() {
-
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- @Override
- public Image getImage(Object element) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- @Override
- public String getText(Object element) {
- return null;
- }
-
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- if (columnIndex == 0) {
- if (element instanceof FileEntry) {
- FileEntry entry = (FileEntry)element;
- switch (entry.getType()) {
- case FileListingService.TYPE_FILE:
- case FileListingService.TYPE_LINK:
- // get the name and extension
- if (entry.isApplicationPackage()) {
- return mPackageImage;
- }
- return mFileImage;
- case FileListingService.TYPE_DIRECTORY:
- case FileListingService.TYPE_DIRECTORY_LINK:
- return mFolderImage;
- }
- }
-
- // default case return a different image.
- return mOtherImage;
- }
- return null;
- }
-
- @Override
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof FileEntry) {
- FileEntry entry = (FileEntry)element;
-
- switch (columnIndex) {
- case 0:
- return entry.getName();
- case 1:
- return entry.getSize();
- case 2:
- return entry.getDate();
- case 3:
- return entry.getTime();
- case 4:
- return entry.getPermissions();
- case 5:
- return entry.getInfo();
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
- */
- @Override
- public void addListener(ILabelProviderListener listener) {
- // we don't need listeners.
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
- */
- @Override
- public void dispose() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object, java.lang.String)
- */
- @Override
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(org.eclipse.jface.viewers.ILabelProviderListener)
- */
- @Override
- public void removeListener(ILabelProviderListener listener) {
- // we don't need listeners
- }
-
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/handler/BaseFileHandler.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/handler/BaseFileHandler.java
deleted file mode 100644
index f50a94c..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/handler/BaseFileHandler.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.handler;
-
-import com.android.ddmlib.ClientData.IHprofDumpHandler;
-import com.android.ddmlib.ClientData.IMethodProfilingHandler;
-import com.android.ddmlib.SyncException;
-import com.android.ddmlib.SyncService;
-import com.android.ddmlib.SyncService.ISyncProgressMonitor;
-import com.android.ddmlib.TimeoutException;
-import com.android.ddmuilib.SyncProgressHelper;
-import com.android.ddmuilib.SyncProgressHelper.SyncRunnable;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * Base handler class for handler dealing with files located on a device.
- *
- * @see IHprofDumpHandler
- * @see IMethodProfilingHandler
- */
-public abstract class BaseFileHandler {
-
- protected final Shell mParentShell;
-
- public BaseFileHandler(Shell parentShell) {
- mParentShell = parentShell;
- }
-
- protected abstract String getDialogTitle();
-
- /**
- * Prompts the user for a save location and pulls the remote files into this location.
- * <p/>This <strong>must</strong> be called from the UI Thread.
- * @param sync the {@link SyncService} to use to pull the file from the device
- * @param localFileName The default local name
- * @param remoteFilePath The name of the file to pull off of the device
- * @param title The title of the File Save dialog.
- * @return The result of the pull as a {@link SyncResult} object, or null if the sync
- * didn't happen (canceled by the user).
- * @throws InvocationTargetException
- * @throws InterruptedException
- * @throws SyncException if an error happens during the push of the package on the device.
- * @throws IOException
- */
- protected void promptAndPull(final SyncService sync,
- String localFileName, final String remoteFilePath, String title)
- throws InvocationTargetException, InterruptedException, SyncException, TimeoutException,
- IOException {
- FileDialog fileDialog = new FileDialog(mParentShell, SWT.SAVE);
-
- fileDialog.setText(title);
- fileDialog.setFileName(localFileName);
-
- final String localFilePath = fileDialog.open();
- if (localFilePath != null) {
- SyncProgressHelper.run(new SyncRunnable() {
- @Override
- public void run(ISyncProgressMonitor monitor) throws SyncException, IOException,
- TimeoutException {
- sync.pullFile(remoteFilePath, localFilePath, monitor);
- }
-
- @Override
- public void close() {
- sync.close();
- }
- },
- String.format("Pulling %1$s from the device", remoteFilePath), mParentShell);
- }
- }
-
- /**
- * Prompts the user for a save location and copies a temp file into it.
- * <p/>This <strong>must</strong> be called from the UI Thread.
- * @param localFileName The default local name
- * @param tempFilePath The name of the temp file to copy.
- * @param title The title of the File Save dialog.
- * @return true if success, false on error or cancel.
- */
- protected boolean promptAndSave(String localFileName, byte[] data, String title) {
- FileDialog fileDialog = new FileDialog(mParentShell, SWT.SAVE);
-
- fileDialog.setText(title);
- fileDialog.setFileName(localFileName);
-
- String localFilePath = fileDialog.open();
- if (localFilePath != null) {
- try {
- saveFile(data, new File(localFilePath));
- return true;
- } catch (IOException e) {
- String errorMsg = e.getMessage();
- displayErrorInUiThread(
- "Failed to save file '%1$s'%2$s",
- localFilePath,
- errorMsg != null ? ":\n" + errorMsg : ".");
- }
- }
-
- return false;
- }
-
- /**
- * Display an error message.
- * <p/>This will call about to {@link Display} to run this in an async {@link Runnable} in the
- * UI Thread. This is safe to be called from a non-UI Thread.
- * @param format the string to display
- * @param args the string arguments
- */
- protected void displayErrorInUiThread(final String format, final Object... args) {
- mParentShell.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- MessageDialog.openError(mParentShell, getDialogTitle(),
- String.format(format, args));
- }
- });
- }
-
- /**
- * Display an error message.
- * This must be called from the UI Thread.
- * @param format the string to display
- * @param args the string arguments
- */
- protected void displayErrorFromUiThread(final String format, final Object... args) {
- MessageDialog.openError(mParentShell, getDialogTitle(),
- String.format(format, args));
- }
-
- /**
- * Saves a given data into a temp file and returns its corresponding {@link File} object.
- * @param data the data to save
- * @return the File into which the data was written or null if it failed.
- * @throws IOException
- */
- protected File saveTempFile(byte[] data, String extension) throws IOException {
- File f = File.createTempFile("ddms", extension);
- saveFile(data, f);
- return f;
- }
-
- /**
- * Saves some data into a given File.
- * @param data the data to save
- * @param output the file into the data is saved.
- * @throws IOException
- */
- protected void saveFile(byte[] data, File output) throws IOException {
- FileOutputStream fos = null;
- try {
- fos = new FileOutputStream(output);
- fos.write(data);
- } finally {
- if (fos != null) {
- fos.close();
- }
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/handler/MethodProfilingHandler.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/handler/MethodProfilingHandler.java
deleted file mode 100644
index ab1b5f7..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/handler/MethodProfilingHandler.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.handler;
-
-import com.android.ddmlib.Client;
-import com.android.ddmlib.ClientData.IMethodProfilingHandler;
-import com.android.ddmlib.DdmConstants;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.SyncException;
-import com.android.ddmlib.SyncService;
-import com.android.ddmlib.SyncService.ISyncProgressMonitor;
-import com.android.ddmlib.TimeoutException;
-import com.android.ddmuilib.DdmUiPreferences;
-import com.android.ddmuilib.SyncProgressHelper;
-import com.android.ddmuilib.SyncProgressHelper.SyncRunnable;
-import com.android.ddmuilib.console.DdmConsole;
-
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.lang.reflect.InvocationTargetException;
-
-/**
- * Handler for Method tracing.
- * This will pull the trace file into a temp file and launch traceview.
- */
-public class MethodProfilingHandler extends BaseFileHandler
- implements IMethodProfilingHandler {
-
- public MethodProfilingHandler(Shell parentShell) {
- super(parentShell);
- }
-
- @Override
- protected String getDialogTitle() {
- return "Method Profiling Error";
- }
-
- @Override
- public void onStartFailure(final Client client, final String message) {
- displayErrorInUiThread(
- "Unable to create Method Profiling file for application '%1$s'\n\n%2$s" +
- "Check logcat for more information.",
- client.getClientData().getClientDescription(),
- message != null ? message + "\n\n" : "");
- }
-
- @Override
- public void onEndFailure(final Client client, final String message) {
- displayErrorInUiThread(
- "Unable to finish Method Profiling for application '%1$s'\n\n%2$s" +
- "Check logcat for more information.",
- client.getClientData().getClientDescription(),
- message != null ? message + "\n\n" : "");
- }
-
- @Override
- public void onSuccess(final String remoteFilePath, final Client client) {
- mParentShell.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (remoteFilePath == null) {
- displayErrorFromUiThread(
- "Unable to download trace file: unknown file name.\n" +
- "This can happen if you disconnected the device while recording the trace.");
- return;
- }
-
- final IDevice device = client.getDevice();
- try {
- // get the sync service to pull the HPROF file
- final SyncService sync = client.getDevice().getSyncService();
- if (sync != null) {
- pullAndOpen(sync, remoteFilePath);
- } else {
- displayErrorFromUiThread(
- "Unable to download trace file from device '%1$s'.",
- device.getSerialNumber());
- }
- } catch (Exception e) {
- displayErrorFromUiThread("Unable to download trace file from device '%1$s'.",
- device.getSerialNumber());
- }
- }
-
- });
- }
-
- @Override
- public void onSuccess(byte[] data, final Client client) {
- try {
- File tempFile = saveTempFile(data, DdmConstants.DOT_TRACE);
- open(tempFile.getAbsolutePath());
- } catch (IOException e) {
- String errorMsg = e.getMessage();
- displayErrorInUiThread(
- "Failed to save trace data into temp file%1$s",
- errorMsg != null ? ":\n" + errorMsg : ".");
- }
- }
-
- /**
- * pulls and open a file. This is run from the UI thread.
- */
- private void pullAndOpen(final SyncService sync, final String remoteFilePath)
- throws InvocationTargetException, InterruptedException, IOException {
- // get a temp file
- File temp = File.createTempFile("android", DdmConstants.DOT_TRACE); //$NON-NLS-1$
- final String tempPath = temp.getAbsolutePath();
-
- // pull the file
- try {
- SyncProgressHelper.run(new SyncRunnable() {
- @Override
- public void run(ISyncProgressMonitor monitor)
- throws SyncException, IOException, TimeoutException {
- sync.pullFile(remoteFilePath, tempPath, monitor);
- }
-
- @Override
- public void close() {
- sync.close();
- }
- },
- String.format("Pulling %1$s from the device", remoteFilePath), mParentShell);
-
- // open the temp file in traceview
- open(tempPath);
- } catch (SyncException e) {
- if (e.wasCanceled() == false) {
- displayErrorFromUiThread("Unable to download trace file:\n\n%1$s", e.getMessage());
- }
- } catch (TimeoutException e) {
- displayErrorFromUiThread("Unable to download trace file:\n\ntimeout");
- }
- }
-
- protected void open(String tempPath) {
- // now that we have the file, we need to launch traceview
- String[] command = new String[2];
- command[0] = DdmUiPreferences.getTraceview();
- command[1] = tempPath;
-
- try {
- final Process p = Runtime.getRuntime().exec(command);
-
- // create a thread for the output
- new Thread("Traceview output") {
- @Override
- public void run() {
- // create a buffer to read the stderr output
- InputStreamReader is = new InputStreamReader(p.getErrorStream());
- BufferedReader resultReader = new BufferedReader(is);
-
- // read the lines as they come. if null is returned, it's
- // because the process finished
- try {
- while (true) {
- String line = resultReader.readLine();
- if (line != null) {
- DdmConsole.printErrorToConsole("Traceview: " + line);
- } else {
- break;
- }
- }
- // get the return code from the process
- p.waitFor();
- } catch (Exception e) {
- Log.e("traceview", e);
- }
- }
- }.start();
- } catch (IOException e) {
- Log.e("traceview", e);
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapDataImporter.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapDataImporter.java
deleted file mode 100644
index 88db5cc..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapDataImporter.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.heap;
-
-import com.android.ddmlib.NativeAllocationInfo;
-import com.android.ddmlib.NativeStackCallInfo;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
-import java.io.IOException;
-import java.io.LineNumberReader;
-import java.io.Reader;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.InputMismatchException;
-import java.util.List;
-import java.util.Scanner;
-import java.util.regex.Pattern;
-
-public class NativeHeapDataImporter implements IRunnableWithProgress {
- private LineNumberReader mReader;
- private int mStartLineNumber;
- private int mEndLineNumber;
-
- private NativeHeapSnapshot mSnapshot;
-
- public NativeHeapDataImporter(Reader stream) {
- mReader = new LineNumberReader(stream);
- mReader.setLineNumber(1); // start numbering at 1
- }
-
- @Override
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- monitor.beginTask("Importing Heap Data", IProgressMonitor.UNKNOWN);
-
- List<NativeAllocationInfo> allocations = new ArrayList<NativeAllocationInfo>();
- try {
- while (true) {
- String line;
- StringBuilder sb = new StringBuilder();
-
- // read in a sequence of lines corresponding to a single NativeAllocationInfo
- mStartLineNumber = mReader.getLineNumber();
- while ((line = mReader.readLine()) != null) {
- if (line.trim().length() == 0) {
- // each block of allocations end with an empty line
- break;
- }
-
- sb.append(line);
- sb.append('\n');
- }
- mEndLineNumber = mReader.getLineNumber();
-
- // parse those lines into a NativeAllocationInfo object
- String allocationBlock = sb.toString();
- if (allocationBlock.trim().length() > 0) {
- allocations.add(getNativeAllocation(allocationBlock));
- }
-
- if (line == null) { // EOF
- break;
- }
- }
- } catch (Exception e) {
- if (e.getMessage() == null) {
- e = new RuntimeException(genericErrorMessage("Unexpected Parse error"));
- }
- throw new InvocationTargetException(e);
- } finally {
- try {
- mReader.close();
- } catch (IOException e) {
- // we can ignore this exception
- }
- monitor.done();
- }
-
- mSnapshot = new NativeHeapSnapshot(allocations);
- }
-
- /** Parse a single native allocation dump. This is the complement of
- * {@link NativeAllocationInfo#toString()}.
- *
- * An allocation is of the following form:
- * Allocations: 1
- * Size: 344748
- * Total Size: 344748
- * BeginStackTrace:
- * 40069bd8 /lib/libc_malloc_leak.so --- get_backtrace --- /libc/bionic/malloc_leak.c:258
- * 40069dd8 /lib/libc_malloc_leak.so --- leak_calloc --- /libc/bionic/malloc_leak.c:576
- * 40069bd8 /lib/libc_malloc_leak.so --- 40069bd8 ---
- * 40069dd8 /lib/libc_malloc_leak.so --- 40069dd8 ---
- * EndStackTrace
- * Note that in the above stack trace, the last two lines are examples where the address
- * was not resolved.
- *
- * @param block a string of lines corresponding to a single {@code NativeAllocationInfo}
- * @return parse the input and return the corresponding {@link NativeAllocationInfo}
- * @throws InputMismatchException if there are any parse errors
- */
- private NativeAllocationInfo getNativeAllocation(String block) {
- Scanner sc = new Scanner(block);
-
- String kw = sc.next();
- if (!NativeAllocationInfo.ALLOCATIONS_KW.equals(kw)) {
- throw new InputMismatchException(
- expectedKeywordErrorMessage(NativeAllocationInfo.ALLOCATIONS_KW, kw));
- }
-
- int allocations = sc.nextInt();
-
- kw = sc.next();
- if (!NativeAllocationInfo.SIZE_KW.equals(kw)) {
- throw new InputMismatchException(
- expectedKeywordErrorMessage(NativeAllocationInfo.SIZE_KW, kw));
- }
-
- int size = sc.nextInt();
-
- kw = sc.next();
- if (!NativeAllocationInfo.TOTAL_SIZE_KW.equals(kw)) {
- throw new InputMismatchException(
- expectedKeywordErrorMessage(NativeAllocationInfo.TOTAL_SIZE_KW, kw));
- }
-
- int totalSize = sc.nextInt();
- if (totalSize != size * allocations) {
- throw new InputMismatchException(
- genericErrorMessage("Total Size does not match size * # of allocations"));
- }
-
- NativeAllocationInfo info = new NativeAllocationInfo(size, allocations);
-
- kw = sc.next();
- if (!NativeAllocationInfo.BEGIN_STACKTRACE_KW.equals(kw)) {
- throw new InputMismatchException(
- expectedKeywordErrorMessage(NativeAllocationInfo.BEGIN_STACKTRACE_KW, kw));
- }
-
- List<NativeStackCallInfo> stackInfo = new ArrayList<NativeStackCallInfo>();
- Pattern endTracePattern = Pattern.compile(NativeAllocationInfo.END_STACKTRACE_KW);
-
- while (true) {
- long address = sc.nextLong(16);
- info.addStackCallAddress(address);
-
- String library = sc.next();
- sc.next(); // ignore "---"
- String method = scanTillSeparator(sc, "---");
-
- String filename = "";
- if (!isUnresolved(method, address)) {
- filename = sc.next();
- }
-
- stackInfo.add(new NativeStackCallInfo(address, library, method, filename));
-
- if (sc.hasNext(endTracePattern)) {
- break;
- }
- }
-
- info.setResolvedStackCall(stackInfo);
- return info;
- }
-
- private String scanTillSeparator(Scanner sc, String separator) {
- StringBuilder sb = new StringBuilder();
-
- while (true) {
- String token = sc.next();
- if (token.equals(separator)) {
- break;
- }
-
- sb.append(token);
-
- // We do not know the exact delimiter that was skipped over, but we know
- // that there was atleast 1 whitespace. Add a single whitespace character
- // to account for this.
- sb.append(' ');
- }
-
- return sb.toString().trim();
- }
-
- private boolean isUnresolved(String method, long address) {
- // a method is unresolved if it is just the hex representation of the address
- return Long.toString(address, 16).equals(method);
- }
-
- private String genericErrorMessage(String message) {
- return String.format("%1$s between lines %2$d and %3$d",
- message, mStartLineNumber, mEndLineNumber);
- }
-
- private String expectedKeywordErrorMessage(String expected, String actual) {
- return String.format("Expected keyword '%1$s', saw '%2$s' between lines %3$d to %4$d.",
- expected, actual, mStartLineNumber, mEndLineNumber);
- }
-
- public NativeHeapSnapshot getImportedSnapshot() {
- return mSnapshot;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapDiffSnapshot.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapDiffSnapshot.java
deleted file mode 100644
index 9eb6ddf..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapDiffSnapshot.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.heap;
-
-import com.android.ddmlib.NativeAllocationInfo;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Models a heap snapshot that is the difference between two snapshots.
- */
-public class NativeHeapDiffSnapshot extends NativeHeapSnapshot {
- private long mCommonAllocationsTotalMemory;
-
- public NativeHeapDiffSnapshot(NativeHeapSnapshot newSnapshot, NativeHeapSnapshot oldSnapshot) {
- // The diff snapshots behaves like a snapshot that only contains the new allocations
- // not present in the old snapshot
- super(getNewAllocations(newSnapshot, oldSnapshot));
-
- Set<NativeAllocationInfo> commonAllocations =
- new HashSet<NativeAllocationInfo>(oldSnapshot.getAllocations());
- commonAllocations.retainAll(newSnapshot.getAllocations());
-
- // Memory common between the old and new snapshots
- mCommonAllocationsTotalMemory = getTotalMemory(commonAllocations);
- }
-
- private static List<NativeAllocationInfo> getNewAllocations(NativeHeapSnapshot newSnapshot,
- NativeHeapSnapshot oldSnapshot) {
- Set<NativeAllocationInfo> allocations =
- new HashSet<NativeAllocationInfo>(newSnapshot.getAllocations());
- allocations.removeAll(oldSnapshot.getAllocations());
- return new ArrayList<NativeAllocationInfo>(allocations);
- }
-
- @Override
- public String getFormattedMemorySize() {
- // for a diff snapshot, we report the following string for display:
- // xxx bytes new allocation + yyy bytes retained from previous allocation
- // = zzz bytes total
-
- long newAllocations = getTotalSize();
- return String.format("%s bytes new + %s bytes retained = %s bytes total",
- formatMemorySize(newAllocations),
- formatMemorySize(mCommonAllocationsTotalMemory),
- formatMemorySize(newAllocations + mCommonAllocationsTotalMemory));
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapLabelProvider.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapLabelProvider.java
deleted file mode 100644
index b96fa02..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapLabelProvider.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.heap;
-
-import com.android.ddmlib.NativeAllocationInfo;
-import com.android.ddmlib.NativeStackCallInfo;
-
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-/**
- * A Label Provider for the Native Heap TreeViewer in {@link NativeHeapPanel}.
- */
-public class NativeHeapLabelProvider extends LabelProvider implements ITableLabelProvider {
- private long mTotalSize;
-
- @Override
- public Image getColumnImage(Object arg0, int arg1) {
- return null;
- }
-
- @Override
- public String getColumnText(Object element, int index) {
- if (element instanceof NativeAllocationInfo) {
- return getColumnTextForNativeAllocation((NativeAllocationInfo) element, index);
- }
-
- if (element instanceof NativeLibraryAllocationInfo) {
- return getColumnTextForNativeLibrary((NativeLibraryAllocationInfo) element, index);
- }
-
- return null;
- }
-
- private String getColumnTextForNativeAllocation(NativeAllocationInfo info, int index) {
- NativeStackCallInfo stackInfo = info.getRelevantStackCallInfo();
-
- switch (index) {
- case 0:
- return stackInfo == null ? stackResolutionStatus(info) : stackInfo.getLibraryName();
- case 1:
- return Integer.toString(info.getSize() * info.getAllocationCount());
- case 2:
- return getPercentageString(info.getSize() * info.getAllocationCount(), mTotalSize);
- case 3:
- String prefix = "";
- if (!info.isZygoteChild()) {
- prefix = "Z ";
- }
- return prefix + Integer.toString(info.getAllocationCount());
- case 4:
- return Integer.toString(info.getSize());
- case 5:
- return stackInfo == null ? stackResolutionStatus(info) : stackInfo.getMethodName();
- default:
- return null;
- }
- }
-
- private String getColumnTextForNativeLibrary(NativeLibraryAllocationInfo info, int index) {
- switch (index) {
- case 0:
- return info.getLibraryName();
- case 1:
- return Long.toString(info.getTotalSize());
- case 2:
- return getPercentageString(info.getTotalSize(), mTotalSize);
- default:
- return null;
- }
- }
-
- private String getPercentageString(long size, long total) {
- if (total == 0) {
- return "";
- }
-
- return String.format("%.1f%%", (float)(size * 100)/(float)total);
- }
-
- private String stackResolutionStatus(NativeAllocationInfo info) {
- if (info.isStackCallResolved()) {
- return "?"; // resolved and unknown
- } else {
- return "Resolving..."; // still resolving...
- }
- }
-
- /**
- * Set the total size of the heap dump for use in percentage calculations.
- * This value should be set whenever the input to the tree changes so that the percentages
- * are computed correctly.
- */
- public void setTotalSize(long totalSize) {
- mTotalSize = totalSize;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapPanel.java
deleted file mode 100644
index f6631b7..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapPanel.java
+++ /dev/null
@@ -1,1150 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.heap;
-
-import com.android.ddmlib.Client;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.NativeAllocationInfo;
-import com.android.ddmlib.NativeLibraryMapInfo;
-import com.android.ddmlib.NativeStackCallInfo;
-import com.android.ddmuilib.Addr2Line;
-import com.android.ddmuilib.BaseHeapPanel;
-import com.android.ddmuilib.ITableFocusListener;
-import com.android.ddmuilib.ITableFocusListener.IFocusedTableActivator;
-import com.android.ddmuilib.ImageLoader;
-import com.android.ddmuilib.TableHelper;
-
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Sash;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.Reader;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/** Panel to display native heap information. */
-public class NativeHeapPanel extends BaseHeapPanel {
- private static final boolean USE_OLD_RESOLVER;
- static {
- String useOldResolver = System.getenv("ANDROID_DDMS_OLD_SYMRESOLVER");
- if (useOldResolver != null && useOldResolver.equalsIgnoreCase("true")) {
- USE_OLD_RESOLVER = true;
- } else {
- USE_OLD_RESOLVER = false;
- }
- }
- private final int MAX_DISPLAYED_ERROR_ITEMS = 5;
-
- private static final String TOOLTIP_EXPORT_DATA = "Export Heap Data";
- private static final String TOOLTIP_ZYGOTE_ALLOCATIONS = "Show Zygote Allocations";
- private static final String TOOLTIP_DIFFS_ONLY = "Only show new allocations not present in previous snapshot";
- private static final String TOOLTIP_GROUPBY = "Group allocations by library.";
-
- private static final String EXPORT_DATA_IMAGE = "save.png";
- private static final String ZYGOTE_IMAGE = "zygote.png";
- private static final String DIFFS_ONLY_IMAGE = "diff.png";
- private static final String GROUPBY_IMAGE = "groupby.png";
-
- private static final String SNAPSHOT_HEAP_BUTTON_TEXT = "Snapshot Current Native Heap Usage";
- private static final String LOAD_HEAP_DATA_BUTTON_TEXT = "Import Heap Data";
- private static final String SYMBOL_SEARCH_PATH_LABEL_TEXT = "Symbol Search Path:";
- private static final String SYMBOL_SEARCH_PATH_TEXT_MESSAGE =
- "List of colon separated paths to search for symbol debug information. See tooltip for examples.";
- private static final String SYMBOL_SEARCH_PATH_TOOLTIP_TEXT =
- "Colon separated paths that contain unstripped libraries with debug symbols.\n"
- + "e.g.: <android-src>/out/target/product/generic/symbols/system/lib:/path/to/my/app/obj/local/armeabi";
-
- private static final String PREFS_SHOW_DIFFS_ONLY = "nativeheap.show.diffs.only";
- private static final String PREFS_SHOW_ZYGOTE_ALLOCATIONS = "nativeheap.show.zygote";
- private static final String PREFS_GROUP_BY_LIBRARY = "nativeheap.grouby.library";
- private static final String PREFS_SYMBOL_SEARCH_PATH = "nativeheap.search.path";
- private static final String PREFS_SASH_HEIGHT_PERCENT = "nativeheap.sash.percent";
- private static final String PREFS_LAST_IMPORTED_HEAPPATH = "nativeheap.last.import.path";
- private IPreferenceStore mPrefStore;
-
- private List<NativeHeapSnapshot> mNativeHeapSnapshots;
-
- // Maintain the differences between a snapshot and its predecessor.
- // mDiffSnapshots[i] = mNativeHeapSnapshots[i] - mNativeHeapSnapshots[i-1]
- // The zeroth entry is null since there is no predecessor.
- // The list is filled lazily on demand.
- private List<NativeHeapSnapshot> mDiffSnapshots;
-
- private Map<Integer, List<NativeHeapSnapshot>> mImportedSnapshotsPerPid;
-
- private Button mSnapshotHeapButton;
- private Button mLoadHeapDataButton;
- private Text mSymbolSearchPathText;
- private Combo mSnapshotIndexCombo;
- private Label mMemoryAllocatedText;
-
- private TreeViewer mDetailsTreeViewer;
- private TreeViewer mStackTraceTreeViewer;
- private NativeHeapProviderByAllocations mContentProviderByAllocations;
- private NativeHeapProviderByLibrary mContentProviderByLibrary;
- private NativeHeapLabelProvider mDetailsTreeLabelProvider;
-
- private ToolBar mDetailsToolBar;
- private ToolItem mGroupByButton;
- private ToolItem mDiffsOnlyButton;
- private ToolItem mShowZygoteAllocationsButton;
- private ToolItem mExportHeapDataButton;
-
- public NativeHeapPanel(IPreferenceStore prefStore) {
- mPrefStore = prefStore;
- mPrefStore.setDefault(PREFS_SASH_HEIGHT_PERCENT, 75);
- mPrefStore.setDefault(PREFS_SYMBOL_SEARCH_PATH, "");
- mPrefStore.setDefault(PREFS_GROUP_BY_LIBRARY, false);
- mPrefStore.setDefault(PREFS_SHOW_ZYGOTE_ALLOCATIONS, true);
- mPrefStore.setDefault(PREFS_SHOW_DIFFS_ONLY, false);
-
- mNativeHeapSnapshots = new ArrayList<NativeHeapSnapshot>();
- mDiffSnapshots = new ArrayList<NativeHeapSnapshot>();
- mImportedSnapshotsPerPid = new HashMap<Integer, List<NativeHeapSnapshot>>();
- }
-
- /** {@inheritDoc} */
- @Override
- public void clientChanged(final Client client, int changeMask) {
- if (client != getCurrentClient()) {
- return;
- }
-
- if ((changeMask & Client.CHANGE_NATIVE_HEAP_DATA) != Client.CHANGE_NATIVE_HEAP_DATA) {
- return;
- }
-
- List<NativeAllocationInfo> allocations = client.getClientData().getNativeAllocationList();
- if (allocations.size() == 0) {
- return;
- }
-
- // We need to clone this list since getClientData().getNativeAllocationList() clobbers
- // the list on future updates
- final List<NativeAllocationInfo> nativeAllocations = shallowCloneList(allocations);
-
- addNativeHeapSnapshot(new NativeHeapSnapshot(nativeAllocations));
- updateDisplay();
-
- // Attempt to resolve symbols in a separate thread.
- // The UI should be refreshed once the symbols have been resolved.
- if (USE_OLD_RESOLVER) {
- Thread t = new Thread(new SymbolResolverTask(nativeAllocations,
- client.getClientData().getMappedNativeLibraries()));
- t.setName("Address to Symbol Resolver");
- t.start();
- } else {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- resolveSymbols();
- mDetailsTreeViewer.refresh();
- mStackTraceTreeViewer.refresh();
- }
-
- public void resolveSymbols() {
- Shell shell = Display.getDefault().getActiveShell();
- ProgressMonitorDialog d = new ProgressMonitorDialog(shell);
-
- NativeSymbolResolverTask resolver = new NativeSymbolResolverTask(
- nativeAllocations,
- client.getClientData().getMappedNativeLibraries(),
- mSymbolSearchPathText.getText());
-
- try {
- d.run(true, true, resolver);
- } catch (InvocationTargetException e) {
- MessageDialog.openError(shell,
- "Error Resolving Symbols",
- e.getCause().getMessage());
- return;
- } catch (InterruptedException e) {
- return;
- }
-
- MessageDialog.openInformation(shell, "Symbol Resolution Status",
- getResolutionStatusMessage(resolver));
- }
- });
- }
- }
-
- private String getResolutionStatusMessage(NativeSymbolResolverTask resolver) {
- StringBuilder sb = new StringBuilder();
- sb.append("Symbol Resolution Complete.\n\n");
-
- // show addresses that were not mapped
- Set<Long> unmappedAddresses = resolver.getUnmappedAddresses();
- if (unmappedAddresses.size() > 0) {
- sb.append(String.format("Unmapped addresses (%d): ",
- unmappedAddresses.size()));
- sb.append(getSampleForDisplay(unmappedAddresses));
- sb.append('\n');
- }
-
- // show libraries that were not present on disk
- Set<String> notFoundLibraries = resolver.getNotFoundLibraries();
- if (notFoundLibraries.size() > 0) {
- sb.append(String.format("Libraries not found on disk (%d): ",
- notFoundLibraries.size()));
- sb.append(getSampleForDisplay(notFoundLibraries));
- sb.append('\n');
- }
-
- // show addresses that were mapped but not resolved
- Set<Long> unresolvableAddresses = resolver.getUnresolvableAddresses();
- if (unresolvableAddresses.size() > 0) {
- sb.append(String.format("Unresolved addresses (%d): ",
- unresolvableAddresses.size()));
- sb.append(getSampleForDisplay(unresolvableAddresses));
- sb.append('\n');
- }
-
- if (resolver.getAddr2LineErrorMessage() != null) {
- sb.append("Error launching addr2line: ");
- sb.append(resolver.getAddr2LineErrorMessage());
- }
-
- return sb.toString();
- }
-
- /**
- * Get the string representation for a collection of items.
- * If there are more items than {@link #MAX_DISPLAYED_ERROR_ITEMS}, then only the first
- * {@link #MAX_DISPLAYED_ERROR_ITEMS} items are taken into account,
- * and an ellipsis is added at the end.
- */
- private String getSampleForDisplay(Collection<?> items) {
- StringBuilder sb = new StringBuilder();
-
- int c = 1;
- Iterator<?> it = items.iterator();
- while (it.hasNext()) {
- Object item = it.next();
- if (item instanceof Long) {
- sb.append(String.format("0x%x", item));
- } else {
- sb.append(item);
- }
-
- if (c == MAX_DISPLAYED_ERROR_ITEMS && it.hasNext()) {
- sb.append(", ...");
- break;
- } else if (it.hasNext()) {
- sb.append(", ");
- }
-
- c++;
- }
- return sb.toString();
- }
-
- private void addNativeHeapSnapshot(NativeHeapSnapshot snapshot) {
- mNativeHeapSnapshots.add(snapshot);
-
- // The diff snapshots are filled in lazily on demand.
- // But the list needs to be the same size as mNativeHeapSnapshots, so we add a null.
- mDiffSnapshots.add(null);
- }
-
- private List<NativeAllocationInfo> shallowCloneList(List<NativeAllocationInfo> allocations) {
- List<NativeAllocationInfo> clonedList =
- new ArrayList<NativeAllocationInfo>(allocations.size());
-
- for (NativeAllocationInfo i : allocations) {
- clonedList.add(i);
- }
-
- return clonedList;
- }
-
- @Override
- public void deviceSelected() {
- // pass
- }
-
- @Override
- public void clientSelected() {
- Client c = getCurrentClient();
-
- if (c == null) {
- // if there is no client selected, then we disable the buttons but leave the
- // display as is so that whatever snapshots are displayed continue to stay
- // visible to the user.
- mSnapshotHeapButton.setEnabled(false);
- mLoadHeapDataButton.setEnabled(false);
- return;
- }
-
- mNativeHeapSnapshots = new ArrayList<NativeHeapSnapshot>();
- mDiffSnapshots = new ArrayList<NativeHeapSnapshot>();
-
- mSnapshotHeapButton.setEnabled(true);
- mLoadHeapDataButton.setEnabled(true);
-
- List<NativeHeapSnapshot> importedSnapshots = mImportedSnapshotsPerPid.get(
- c.getClientData().getPid());
- if (importedSnapshots != null) {
- for (NativeHeapSnapshot n : importedSnapshots) {
- addNativeHeapSnapshot(n);
- }
- }
-
- List<NativeAllocationInfo> allocations = c.getClientData().getNativeAllocationList();
- allocations = shallowCloneList(allocations);
-
- if (allocations.size() > 0) {
- addNativeHeapSnapshot(new NativeHeapSnapshot(allocations));
- }
-
- updateDisplay();
- }
-
- private void updateDisplay() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- updateSnapshotIndexCombo();
- updateToolbars();
-
- int lastSnapshotIndex = mNativeHeapSnapshots.size() - 1;
- displaySnapshot(lastSnapshotIndex);
- displayStackTraceForSelection();
- }
- });
- }
-
- private void displaySelectedSnapshot() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- int idx = mSnapshotIndexCombo.getSelectionIndex();
- displaySnapshot(idx);
- }
- });
- }
-
- private void displaySnapshot(int index) {
- if (index < 0 || mNativeHeapSnapshots.size() == 0) {
- mDetailsTreeViewer.setInput(null);
- mMemoryAllocatedText.setText("");
- return;
- }
-
- assert index < mNativeHeapSnapshots.size() : "Invalid snapshot index";
-
- NativeHeapSnapshot snapshot = mNativeHeapSnapshots.get(index);
- if (mDiffsOnlyButton.getSelection() && index > 0) {
- snapshot = getDiffSnapshot(index);
- }
-
- mMemoryAllocatedText.setText(snapshot.getFormattedMemorySize());
- mMemoryAllocatedText.pack();
-
- mDetailsTreeLabelProvider.setTotalSize(snapshot.getTotalSize());
- mDetailsTreeViewer.setInput(snapshot);
- mDetailsTreeViewer.refresh();
- }
-
- /** Obtain the diff of snapshot[index] & snapshot[index-1] */
- private NativeHeapSnapshot getDiffSnapshot(int index) {
- // if it was already computed, simply return that
- NativeHeapSnapshot diffSnapshot = mDiffSnapshots.get(index);
- if (diffSnapshot != null) {
- return diffSnapshot;
- }
-
- // compute the diff
- NativeHeapSnapshot cur = mNativeHeapSnapshots.get(index);
- NativeHeapSnapshot prev = mNativeHeapSnapshots.get(index - 1);
- diffSnapshot = new NativeHeapDiffSnapshot(cur, prev);
-
- // cache for future use
- mDiffSnapshots.set(index, diffSnapshot);
-
- return diffSnapshot;
- }
-
- private void updateDisplayGrouping() {
- boolean groupByLibrary = mGroupByButton.getSelection();
- mPrefStore.setValue(PREFS_GROUP_BY_LIBRARY, groupByLibrary);
-
- if (groupByLibrary) {
- mDetailsTreeViewer.setContentProvider(mContentProviderByLibrary);
- } else {
- mDetailsTreeViewer.setContentProvider(mContentProviderByAllocations);
- }
- }
-
- private void updateDisplayForZygotes() {
- boolean displayZygoteMemory = mShowZygoteAllocationsButton.getSelection();
- mPrefStore.setValue(PREFS_SHOW_ZYGOTE_ALLOCATIONS, displayZygoteMemory);
-
- // inform the content providers of the zygote display setting
- mContentProviderByLibrary.displayZygoteMemory(displayZygoteMemory);
- mContentProviderByAllocations.displayZygoteMemory(displayZygoteMemory);
-
- // refresh the UI
- mDetailsTreeViewer.refresh();
- }
-
- private void updateSnapshotIndexCombo() {
- List<String> items = new ArrayList<String>();
-
- int numSnapshots = mNativeHeapSnapshots.size();
- for (int i = 0; i < numSnapshots; i++) {
- // offset indices by 1 so that users see index starting at 1 rather than 0
- items.add("Snapshot " + (i + 1));
- }
-
- mSnapshotIndexCombo.setItems(items.toArray(new String[0]));
-
- if (numSnapshots > 0) {
- mSnapshotIndexCombo.setEnabled(true);
- mSnapshotIndexCombo.select(numSnapshots - 1);
- } else {
- mSnapshotIndexCombo.setEnabled(false);
- }
- }
-
- private void updateToolbars() {
- int numSnapshots = mNativeHeapSnapshots.size();
- mExportHeapDataButton.setEnabled(numSnapshots > 0);
- }
-
- @Override
- protected Control createControl(Composite parent) {
- Composite c = new Composite(parent, SWT.NONE);
- c.setLayout(new GridLayout(1, false));
- c.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createControlsSection(c);
- createDetailsSection(c);
-
- // Initialize widget state based on whether a client
- // is selected or not.
- clientSelected();
-
- return c;
- }
-
- private void createControlsSection(Composite parent) {
- Composite c = new Composite(parent, SWT.NONE);
- c.setLayout(new GridLayout(3, false));
- c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- createGetHeapDataSection(c);
-
- Label l = new Label(c, SWT.SEPARATOR | SWT.VERTICAL);
- l.setLayoutData(new GridData(GridData.FILL_VERTICAL));
-
- createDisplaySection(c);
- }
-
- private void createGetHeapDataSection(Composite parent) {
- Composite c = new Composite(parent, SWT.NONE);
- c.setLayout(new GridLayout(1, false));
-
- createTakeHeapSnapshotButton(c);
-
- Label l = new Label(c, SWT.SEPARATOR | SWT.HORIZONTAL);
- l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- createLoadHeapDataButton(c);
- }
-
- private void createTakeHeapSnapshotButton(Composite parent) {
- mSnapshotHeapButton = new Button(parent, SWT.BORDER | SWT.PUSH);
- mSnapshotHeapButton.setText(SNAPSHOT_HEAP_BUTTON_TEXT);
- mSnapshotHeapButton.setLayoutData(new GridData());
-
- // disable by default, enabled only when a client is selected
- mSnapshotHeapButton.setEnabled(false);
-
- mSnapshotHeapButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent evt) {
- snapshotHeap();
- }
- });
- }
-
- private void snapshotHeap() {
- Client c = getCurrentClient();
- assert c != null : "Snapshot Heap could not have been enabled w/o a selected client.";
-
- // send an async request
- c.requestNativeHeapInformation();
- }
-
- private void createLoadHeapDataButton(Composite parent) {
- mLoadHeapDataButton = new Button(parent, SWT.BORDER | SWT.PUSH);
- mLoadHeapDataButton.setText(LOAD_HEAP_DATA_BUTTON_TEXT);
- mLoadHeapDataButton.setLayoutData(new GridData());
-
- // disable by default, enabled only when a client is selected
- mLoadHeapDataButton.setEnabled(false);
-
- mLoadHeapDataButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent evt) {
- loadHeapDataFromFile();
- }
- });
- }
-
- private void loadHeapDataFromFile() {
- // pop up a file dialog and get the file to load
- final String path = getHeapDumpToImport();
- if (path == null) {
- return;
- }
-
- Reader reader = null;
- try {
- reader = new FileReader(path);
- } catch (FileNotFoundException e) {
- // cannot occur since user input was via a FileDialog
- }
-
- Shell shell = Display.getDefault().getActiveShell();
- ProgressMonitorDialog d = new ProgressMonitorDialog(shell);
-
- NativeHeapDataImporter importer = new NativeHeapDataImporter(reader);
- try {
- d.run(true, true, importer);
- } catch (InvocationTargetException e) {
- // exception while parsing, display error to user and then return
- MessageDialog.openError(shell,
- "Error Importing Heap Data",
- e.getCause().getMessage());
- return;
- } catch (InterruptedException e) {
- // operation cancelled by user, simply return
- return;
- }
-
- NativeHeapSnapshot snapshot = importer.getImportedSnapshot();
-
- addToImportedSnapshots(snapshot); // save imported snapshot for future use
- addNativeHeapSnapshot(snapshot); // add to currently displayed snapshots as well
-
- updateDisplay();
- }
-
- private void addToImportedSnapshots(NativeHeapSnapshot snapshot) {
- Client c = getCurrentClient();
-
- if (c == null) {
- return;
- }
-
- Integer pid = c.getClientData().getPid();
- List<NativeHeapSnapshot> importedSnapshots = mImportedSnapshotsPerPid.get(pid);
- if (importedSnapshots == null) {
- importedSnapshots = new ArrayList<NativeHeapSnapshot>();
- }
-
- importedSnapshots.add(snapshot);
- mImportedSnapshotsPerPid.put(pid, importedSnapshots);
- }
-
- private String getHeapDumpToImport() {
- FileDialog fileDialog = new FileDialog(Display.getDefault().getActiveShell(),
- SWT.OPEN);
-
- fileDialog.setText("Import Heap Dump");
- fileDialog.setFilterExtensions(new String[] {"*.txt"});
- fileDialog.setFilterPath(mPrefStore.getString(PREFS_LAST_IMPORTED_HEAPPATH));
-
- String selectedFile = fileDialog.open();
- if (selectedFile != null) {
- // save the path to restore in future dialog open
- mPrefStore.setValue(PREFS_LAST_IMPORTED_HEAPPATH, new File(selectedFile).getParent());
- }
- return selectedFile;
- }
-
- private void createDisplaySection(Composite parent) {
- Composite c = new Composite(parent, SWT.NONE);
- c.setLayout(new GridLayout(2, false));
- c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Create: Display: __________________
- createLabel(c, "Display:");
- mSnapshotIndexCombo = new Combo(c, SWT.NONE | SWT.READ_ONLY);
- mSnapshotIndexCombo.setItems(new String[] {"No heap snapshots available."});
- mSnapshotIndexCombo.setEnabled(false);
- mSnapshotIndexCombo.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- displaySelectedSnapshot();
- }
- });
-
- // Create: Memory Allocated (bytes): _________________
- createLabel(c, "Memory Allocated:");
- mMemoryAllocatedText = new Label(c, SWT.NONE);
- GridData gd = new GridData();
- gd.widthHint = 100;
- mMemoryAllocatedText.setLayoutData(gd);
-
- // Create: Search Path: __________________
- createLabel(c, SYMBOL_SEARCH_PATH_LABEL_TEXT);
- mSymbolSearchPathText = new Text(c, SWT.BORDER);
- mSymbolSearchPathText.setMessage(SYMBOL_SEARCH_PATH_TEXT_MESSAGE);
- mSymbolSearchPathText.setToolTipText(SYMBOL_SEARCH_PATH_TOOLTIP_TEXT);
- mSymbolSearchPathText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent arg0) {
- String path = mSymbolSearchPathText.getText();
- updateSearchPath(path);
- mPrefStore.setValue(PREFS_SYMBOL_SEARCH_PATH, path);
- }
- });
- mSymbolSearchPathText.setText(mPrefStore.getString(PREFS_SYMBOL_SEARCH_PATH));
- mSymbolSearchPathText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- }
-
- private void updateSearchPath(String path) {
- Addr2Line.setSearchPath(path);
- }
-
- private void createLabel(Composite parent, String text) {
- Label l = new Label(parent, SWT.NONE);
- l.setText(text);
- GridData gd = new GridData();
- gd.horizontalAlignment = SWT.RIGHT;
- l.setLayoutData(gd);
- }
-
- /**
- * Create the details section displaying the details table and the stack trace
- * corresponding to the selection.
- *
- * The details is laid out like so:
- * Details Toolbar
- * Details Table
- * ------------sash---
- * Stack Trace Label
- * Stack Trace Text
- * There is a sash in between the two sections, and we need to save/restore the sash
- * preferences. Using FormLayout seems like the easiest solution here, but the layout
- * code looks ugly as a result.
- */
- private void createDetailsSection(Composite parent) {
- final Composite c = new Composite(parent, SWT.NONE);
- c.setLayout(new FormLayout());
- c.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- mDetailsToolBar = new ToolBar(c, SWT.FLAT | SWT.BORDER);
- initializeDetailsToolBar(mDetailsToolBar);
-
- Tree detailsTree = new Tree(c, SWT.VIRTUAL | SWT.BORDER | SWT.MULTI);
- initializeDetailsTree(detailsTree);
-
- final Sash sash = new Sash(c, SWT.HORIZONTAL | SWT.BORDER);
-
- Label stackTraceLabel = new Label(c, SWT.NONE);
- stackTraceLabel.setText("Stack Trace:");
-
- Tree stackTraceTree = new Tree(c, SWT.BORDER | SWT.MULTI);
- initializeStackTraceTree(stackTraceTree);
-
- // layout the widgets created above
- FormData data = new FormData();
- data.top = new FormAttachment(0, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- mDetailsToolBar.setLayoutData(data);
-
- data = new FormData();
- data.top = new FormAttachment(mDetailsToolBar, 0);
- data.bottom = new FormAttachment(sash, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- detailsTree.setLayoutData(data);
-
- final FormData sashData = new FormData();
- sashData.top = new FormAttachment(mPrefStore.getInt(PREFS_SASH_HEIGHT_PERCENT), 0);
- sashData.left = new FormAttachment(0, 0);
- sashData.right = new FormAttachment(100, 0);
- sash.setLayoutData(sashData);
-
- data = new FormData();
- data.top = new FormAttachment(sash, 0);
- data.left = new FormAttachment(0, 0);
- data.right = new FormAttachment(100, 0);
- stackTraceLabel.setLayoutData(data);
-
- data = new FormData();
- data.top = new FormAttachment(stackTraceLabel, 0);
- data.left = new FormAttachment(0, 0);
- data.bottom = new FormAttachment(100, 0);
- data.right = new FormAttachment(100, 0);
- stackTraceTree.setLayoutData(data);
-
- sash.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event e) {
- Rectangle sashRect = sash.getBounds();
- Rectangle panelRect = c.getClientArea();
- int sashPercent = sashRect.y * 100 / panelRect.height;
- mPrefStore.setValue(PREFS_SASH_HEIGHT_PERCENT, sashPercent);
-
- sashData.top = new FormAttachment(0, e.y);
- c.layout();
- }
- });
- }
-
- private void initializeDetailsToolBar(ToolBar toolbar) {
- mGroupByButton = new ToolItem(toolbar, SWT.CHECK);
- mGroupByButton.setImage(ImageLoader.getDdmUiLibLoader().loadImage(GROUPBY_IMAGE,
- toolbar.getDisplay()));
- mGroupByButton.setToolTipText(TOOLTIP_GROUPBY);
- mGroupByButton.setSelection(mPrefStore.getBoolean(PREFS_GROUP_BY_LIBRARY));
- mGroupByButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- updateDisplayGrouping();
- }
- });
-
- mDiffsOnlyButton = new ToolItem(toolbar, SWT.CHECK);
- mDiffsOnlyButton.setImage(ImageLoader.getDdmUiLibLoader().loadImage(DIFFS_ONLY_IMAGE,
- toolbar.getDisplay()));
- mDiffsOnlyButton.setToolTipText(TOOLTIP_DIFFS_ONLY);
- mDiffsOnlyButton.setSelection(mPrefStore.getBoolean(PREFS_SHOW_DIFFS_ONLY));
- mDiffsOnlyButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- // simply refresh the display, as the display logic takes care of
- // the current state of the diffs only checkbox.
- int idx = mSnapshotIndexCombo.getSelectionIndex();
- displaySnapshot(idx);
- }
- });
-
- mShowZygoteAllocationsButton = new ToolItem(toolbar, SWT.CHECK);
- mShowZygoteAllocationsButton.setImage(ImageLoader.getDdmUiLibLoader().loadImage(
- ZYGOTE_IMAGE, toolbar.getDisplay()));
- mShowZygoteAllocationsButton.setToolTipText(TOOLTIP_ZYGOTE_ALLOCATIONS);
- mShowZygoteAllocationsButton.setSelection(
- mPrefStore.getBoolean(PREFS_SHOW_ZYGOTE_ALLOCATIONS));
- mShowZygoteAllocationsButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- updateDisplayForZygotes();
- }
- });
-
- mExportHeapDataButton = new ToolItem(toolbar, SWT.PUSH);
- mExportHeapDataButton.setImage(ImageLoader.getDdmUiLibLoader().loadImage(
- EXPORT_DATA_IMAGE, toolbar.getDisplay()));
- mExportHeapDataButton.setToolTipText(TOOLTIP_EXPORT_DATA);
- mExportHeapDataButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- exportSnapshot();
- }
- });
- }
-
- /** Export currently displayed snapshot to a file */
- private void exportSnapshot() {
- int idx = mSnapshotIndexCombo.getSelectionIndex();
- String snapshotName = mSnapshotIndexCombo.getItem(idx);
-
- FileDialog fileDialog = new FileDialog(Display.getDefault().getActiveShell(),
- SWT.SAVE);
-
- fileDialog.setText("Save " + snapshotName);
- fileDialog.setFileName("allocations.txt");
-
- final String fileName = fileDialog.open();
- if (fileName == null) {
- return;
- }
-
- final NativeHeapSnapshot snapshot = mNativeHeapSnapshots.get(idx);
- Thread t = new Thread(new Runnable() {
- @Override
- public void run() {
- PrintWriter out;
- try {
- out = new PrintWriter(new BufferedWriter(new FileWriter(fileName)));
- } catch (IOException e) {
- displayErrorMessage(e.getMessage());
- return;
- }
-
- for (NativeAllocationInfo alloc : snapshot.getAllocations()) {
- out.println(alloc.toString());
- }
- out.close();
- }
-
- private void displayErrorMessage(final String message) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- MessageDialog.openError(Display.getDefault().getActiveShell(),
- "Failed to export heap data", message);
- }
- });
- }
- });
- t.setName("Saving Heap Data to File...");
- t.start();
- }
-
- private void initializeDetailsTree(Tree tree) {
- tree.setHeaderVisible(true);
- tree.setLinesVisible(true);
-
- List<String> properties = Arrays.asList(new String[] {
- "Library",
- "Total",
- "Percentage",
- "Count",
- "Size",
- "Method",
- });
-
- List<String> sampleValues = Arrays.asList(new String[] {
- "/path/in/device/to/system/library.so",
- "123456789",
- " 100%",
- "123456789",
- "123456789",
- "PossiblyLongDemangledMethodName",
- });
-
- // right align numeric values
- List<Integer> swtFlags = Arrays.asList(new Integer[] {
- SWT.LEFT,
- SWT.RIGHT,
- SWT.RIGHT,
- SWT.RIGHT,
- SWT.RIGHT,
- SWT.LEFT,
- });
-
- for (int i = 0; i < properties.size(); i++) {
- String p = properties.get(i);
- String v = sampleValues.get(i);
- int flags = swtFlags.get(i);
- TableHelper.createTreeColumn(tree, p, flags, v, getPref("details", p), mPrefStore);
- }
-
- mDetailsTreeViewer = new TreeViewer(tree);
-
- mDetailsTreeViewer.setUseHashlookup(true);
-
- boolean displayZygotes = mPrefStore.getBoolean(PREFS_SHOW_ZYGOTE_ALLOCATIONS);
- mContentProviderByAllocations = new NativeHeapProviderByAllocations(mDetailsTreeViewer,
- displayZygotes);
- mContentProviderByLibrary = new NativeHeapProviderByLibrary(mDetailsTreeViewer,
- displayZygotes);
- if (mPrefStore.getBoolean(PREFS_GROUP_BY_LIBRARY)) {
- mDetailsTreeViewer.setContentProvider(mContentProviderByLibrary);
- } else {
- mDetailsTreeViewer.setContentProvider(mContentProviderByAllocations);
- }
-
- mDetailsTreeLabelProvider = new NativeHeapLabelProvider();
- mDetailsTreeViewer.setLabelProvider(mDetailsTreeLabelProvider);
-
- mDetailsTreeViewer.setInput(null);
-
- tree.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- displayStackTraceForSelection();
- }
- });
- }
-
- private void initializeStackTraceTree(Tree tree) {
- tree.setHeaderVisible(true);
- tree.setLinesVisible(true);
-
- List<String> properties = Arrays.asList(new String[] {
- "Address",
- "Library",
- "Method",
- "File",
- "Line",
- });
-
- List<String> sampleValues = Arrays.asList(new String[] {
- "0x1234_5678",
- "/path/in/device/to/system/library.so",
- "PossiblyLongDemangledMethodName",
- "/android/out/prefix/in/home/directory/to/path/in/device/to/system/library.so",
- "2000",
- });
-
- for (int i = 0; i < properties.size(); i++) {
- String p = properties.get(i);
- String v = sampleValues.get(i);
- TableHelper.createTreeColumn(tree, p, SWT.LEFT, v, getPref("stack", p), mPrefStore);
- }
-
- mStackTraceTreeViewer = new TreeViewer(tree);
-
- mStackTraceTreeViewer.setContentProvider(new NativeStackContentProvider());
- mStackTraceTreeViewer.setLabelProvider(new NativeStackLabelProvider());
-
- mStackTraceTreeViewer.setInput(null);
- }
-
- private void displayStackTraceForSelection() {
- TreeItem []items = mDetailsTreeViewer.getTree().getSelection();
- if (items.length == 0) {
- mStackTraceTreeViewer.setInput(null);
- return;
- }
-
- Object data = items[0].getData();
- if (!(data instanceof NativeAllocationInfo)) {
- mStackTraceTreeViewer.setInput(null);
- return;
- }
-
- NativeAllocationInfo info = (NativeAllocationInfo) data;
- if (info.isStackCallResolved()) {
- mStackTraceTreeViewer.setInput(info.getResolvedStackCall());
- } else {
- mStackTraceTreeViewer.setInput(info.getStackCallAddresses());
- }
- }
-
- private String getPref(String prefix, String s) {
- return "nativeheap.tree." + prefix + "." + s;
- }
-
- @Override
- public void setFocus() {
- }
-
- private ITableFocusListener mTableFocusListener;
-
- @Override
- public void setTableFocusListener(ITableFocusListener listener) {
- mTableFocusListener = listener;
-
- final Tree heapSitesTree = mDetailsTreeViewer.getTree();
- final IFocusedTableActivator heapSitesActivator = new IFocusedTableActivator() {
- @Override
- public void copy(Clipboard clipboard) {
- TreeItem[] items = heapSitesTree.getSelection();
- copyToClipboard(items, clipboard);
- }
-
- @Override
- public void selectAll() {
- heapSitesTree.selectAll();
- }
- };
-
- heapSitesTree.addFocusListener(new FocusListener() {
- @Override
- public void focusLost(FocusEvent arg0) {
- mTableFocusListener.focusLost(heapSitesActivator);
- }
-
- @Override
- public void focusGained(FocusEvent arg0) {
- mTableFocusListener.focusGained(heapSitesActivator);
- }
- });
-
- final Tree stackTraceTree = mStackTraceTreeViewer.getTree();
- final IFocusedTableActivator stackTraceActivator = new IFocusedTableActivator() {
- @Override
- public void copy(Clipboard clipboard) {
- TreeItem[] items = stackTraceTree.getSelection();
- copyToClipboard(items, clipboard);
- }
-
- @Override
- public void selectAll() {
- stackTraceTree.selectAll();
- }
- };
-
- stackTraceTree.addFocusListener(new FocusListener() {
- @Override
- public void focusLost(FocusEvent arg0) {
- mTableFocusListener.focusLost(stackTraceActivator);
- }
-
- @Override
- public void focusGained(FocusEvent arg0) {
- mTableFocusListener.focusGained(stackTraceActivator);
- }
- });
- }
-
- private void copyToClipboard(TreeItem[] items, Clipboard clipboard) {
- StringBuilder sb = new StringBuilder();
-
- for (TreeItem item : items) {
- Object data = item.getData();
- if (data != null) {
- sb.append(data.toString());
- sb.append('\n');
- }
- }
-
- String content = sb.toString();
- if (content.length() > 0) {
- clipboard.setContents(
- new Object[] {sb.toString()},
- new Transfer[] {TextTransfer.getInstance()}
- );
- }
- }
-
- private class SymbolResolverTask implements Runnable {
- private List<NativeAllocationInfo> mCallSites;
- private List<NativeLibraryMapInfo> mMappedLibraries;
- private Map<Long, NativeStackCallInfo> mResolvedSymbolCache;
-
- public SymbolResolverTask(List<NativeAllocationInfo> callSites,
- List<NativeLibraryMapInfo> mappedLibraries) {
- mCallSites = callSites;
- mMappedLibraries = mappedLibraries;
-
- mResolvedSymbolCache = new HashMap<Long, NativeStackCallInfo>();
- }
-
- @Override
- public void run() {
- for (NativeAllocationInfo callSite : mCallSites) {
- if (callSite.isStackCallResolved()) {
- continue;
- }
-
- List<Long> addresses = callSite.getStackCallAddresses();
- List<NativeStackCallInfo> resolvedStackInfo =
- new ArrayList<NativeStackCallInfo>(addresses.size());
-
- for (Long address : addresses) {
- NativeStackCallInfo info = mResolvedSymbolCache.get(address);
-
- if (info != null) {
- resolvedStackInfo.add(info);
- } else {
- info = resolveAddress(address);
- resolvedStackInfo.add(info);
- mResolvedSymbolCache.put(address, info);
- }
- }
-
- callSite.setResolvedStackCall(resolvedStackInfo);
- }
-
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- mDetailsTreeViewer.refresh();
- mStackTraceTreeViewer.refresh();
- }
- });
- }
-
- private NativeStackCallInfo resolveAddress(long addr) {
- NativeLibraryMapInfo library = getLibraryFor(addr);
-
- if (library != null) {
- Addr2Line process = Addr2Line.getProcess(library);
- if (process != null) {
- NativeStackCallInfo info = process.getAddress(addr);
- if (info != null) {
- return info;
- }
- }
- }
-
- return new NativeStackCallInfo(addr,
- library != null ? library.getLibraryName() : null,
- Long.toHexString(addr),
- "");
- }
-
- private NativeLibraryMapInfo getLibraryFor(long addr) {
- for (NativeLibraryMapInfo info : mMappedLibraries) {
- if (info.isWithinLibrary(addr)) {
- return info;
- }
- }
-
- Log.d("ddm-nativeheap", "Failed finding Library for " + Long.toHexString(addr));
- return null;
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapProviderByAllocations.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapProviderByAllocations.java
deleted file mode 100644
index c31716b..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapProviderByAllocations.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.heap;
-
-import com.android.ddmlib.NativeAllocationInfo;
-
-import org.eclipse.jface.viewers.ILazyTreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-
-import java.util.List;
-
-/**
- * Content Provider for the native heap tree viewer in {@link NativeHeapPanel}.
- * It expects a {@link NativeHeapSnapshot} as input, and provides the list of allocations
- * in the heap dump as content to the UI.
- */
-public final class NativeHeapProviderByAllocations implements ILazyTreeContentProvider {
- private TreeViewer mViewer;
- private boolean mDisplayZygoteMemory;
- private NativeHeapSnapshot mNativeHeapDump;
-
- public NativeHeapProviderByAllocations(TreeViewer viewer, boolean displayZygotes) {
- mViewer = viewer;
- mDisplayZygoteMemory = displayZygotes;
- }
-
- @Override
- public void dispose() {
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- mNativeHeapDump = (NativeHeapSnapshot) newInput;
- }
-
- @Override
- public Object getParent(Object arg0) {
- return null;
- }
-
- @Override
- public void updateChildCount(Object element, int currentChildCount) {
- int childCount = 0;
-
- if (element == mNativeHeapDump) { // root element
- childCount = getAllocations().size();
- }
-
- mViewer.setChildCount(element, childCount);
- }
-
- @Override
- public void updateElement(Object parent, int index) {
- Object item = null;
-
- if (parent == mNativeHeapDump) { // root element
- item = getAllocations().get(index);
- }
-
- mViewer.replace(parent, index, item);
- mViewer.setChildCount(item, 0);
- }
-
- public void displayZygoteMemory(boolean en) {
- mDisplayZygoteMemory = en;
- }
-
- private List<NativeAllocationInfo> getAllocations() {
- if (mDisplayZygoteMemory) {
- return mNativeHeapDump.getAllocations();
- } else {
- return mNativeHeapDump.getNonZygoteAllocations();
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapProviderByLibrary.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapProviderByLibrary.java
deleted file mode 100644
index b786bfa..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapProviderByLibrary.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.heap;
-
-import org.eclipse.jface.viewers.ILazyTreeContentProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-
-import java.util.List;
-
-/**
- * Content Provider for the native heap tree viewer in {@link NativeHeapPanel}.
- * It expects input of type {@link NativeHeapSnapshot}, and provides heap allocations
- * grouped by library to the UI.
- */
-public class NativeHeapProviderByLibrary implements ILazyTreeContentProvider {
- private TreeViewer mViewer;
- private boolean mDisplayZygoteMemory;
-
- public NativeHeapProviderByLibrary(TreeViewer viewer, boolean displayZygotes) {
- mViewer = viewer;
- mDisplayZygoteMemory = displayZygotes;
- }
-
- @Override
- public void dispose() {
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- @Override
- public Object getParent(Object element) {
- return null;
- }
-
- @Override
- public void updateChildCount(Object element, int currentChildCount) {
- int childCount = 0;
-
- if (element instanceof NativeHeapSnapshot) {
- NativeHeapSnapshot snapshot = (NativeHeapSnapshot) element;
- childCount = getLibraryAllocations(snapshot).size();
- }
-
- mViewer.setChildCount(element, childCount);
- }
-
- @Override
- public void updateElement(Object parent, int index) {
- Object item = null;
- int childCount = 0;
-
- if (parent instanceof NativeHeapSnapshot) { // root element
- NativeHeapSnapshot snapshot = (NativeHeapSnapshot) parent;
- item = getLibraryAllocations(snapshot).get(index);
- childCount = ((NativeLibraryAllocationInfo) item).getAllocations().size();
- } else if (parent instanceof NativeLibraryAllocationInfo) {
- item = ((NativeLibraryAllocationInfo) parent).getAllocations().get(index);
- }
-
- mViewer.replace(parent, index, item);
- mViewer.setChildCount(item, childCount);
- }
-
- public void displayZygoteMemory(boolean en) {
- mDisplayZygoteMemory = en;
- }
-
- private List<NativeLibraryAllocationInfo> getLibraryAllocations(NativeHeapSnapshot snapshot) {
- if (mDisplayZygoteMemory) {
- return snapshot.getAllocationsByLibrary();
- } else {
- return snapshot.getNonZygoteAllocationsByLibrary();
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapSnapshot.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapSnapshot.java
deleted file mode 100644
index e2023d2..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeHeapSnapshot.java
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.heap;
-
-import com.android.ddmlib.NativeAllocationInfo;
-
-import java.text.NumberFormat;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-/**
- * A Native Heap Snapshot models a single heap dump.
- *
- * It primarily consists of a list of {@link NativeAllocationInfo} objects. From this list,
- * other objects of interest to the UI are computed and cached for future use.
- */
-public class NativeHeapSnapshot {
- private static final NumberFormat NUMBER_FORMATTER = NumberFormat.getInstance();
-
- private List<NativeAllocationInfo> mHeapAllocations;
- private List<NativeLibraryAllocationInfo> mHeapAllocationsByLibrary;
-
- private List<NativeAllocationInfo> mNonZygoteHeapAllocations;
- private List<NativeLibraryAllocationInfo> mNonZygoteHeapAllocationsByLibrary;
-
- private long mTotalSize;
-
- public NativeHeapSnapshot(List<NativeAllocationInfo> heapAllocations) {
- mHeapAllocations = heapAllocations;
-
- // precompute the total size as this is always needed.
- mTotalSize = getTotalMemory(heapAllocations);
- }
-
- protected long getTotalMemory(Collection<NativeAllocationInfo> heapSnapshot) {
- long total = 0;
-
- for (NativeAllocationInfo info : heapSnapshot) {
- total += info.getAllocationCount() * info.getSize();
- }
-
- return total;
- }
-
- public List<NativeAllocationInfo> getAllocations() {
- return mHeapAllocations;
- }
-
- public List<NativeLibraryAllocationInfo> getAllocationsByLibrary() {
- if (mHeapAllocationsByLibrary != null) {
- return mHeapAllocationsByLibrary;
- }
-
- List<NativeLibraryAllocationInfo> heapAllocations =
- NativeLibraryAllocationInfo.constructFrom(mHeapAllocations);
-
- // cache for future uses only if it is fully resolved.
- if (isFullyResolved(heapAllocations)) {
- mHeapAllocationsByLibrary = heapAllocations;
- }
-
- return heapAllocations;
- }
-
- private boolean isFullyResolved(List<NativeLibraryAllocationInfo> heapAllocations) {
- for (NativeLibraryAllocationInfo info : heapAllocations) {
- if (info.getLibraryName().equals(NativeLibraryAllocationInfo.UNRESOLVED_LIBRARY_NAME)) {
- return false;
- }
- }
-
- return true;
- }
-
- public long getTotalSize() {
- return mTotalSize;
- }
-
- public String getFormattedMemorySize() {
- return String.format("%s bytes", formatMemorySize(getTotalSize()));
- }
-
- protected String formatMemorySize(long memSize) {
- return NUMBER_FORMATTER.format(memSize);
- }
-
- public List<NativeAllocationInfo> getNonZygoteAllocations() {
- if (mNonZygoteHeapAllocations != null) {
- return mNonZygoteHeapAllocations;
- }
-
- // filter out all zygote allocations
- mNonZygoteHeapAllocations = new ArrayList<NativeAllocationInfo>();
- for (NativeAllocationInfo info : mHeapAllocations) {
- if (info.isZygoteChild()) {
- mNonZygoteHeapAllocations.add(info);
- }
- }
-
- return mNonZygoteHeapAllocations;
- }
-
- public List<NativeLibraryAllocationInfo> getNonZygoteAllocationsByLibrary() {
- if (mNonZygoteHeapAllocationsByLibrary != null) {
- return mNonZygoteHeapAllocationsByLibrary;
- }
-
- List<NativeLibraryAllocationInfo> heapAllocations =
- NativeLibraryAllocationInfo.constructFrom(getNonZygoteAllocations());
-
- // cache for future uses only if it is fully resolved.
- if (isFullyResolved(heapAllocations)) {
- mNonZygoteHeapAllocationsByLibrary = heapAllocations;
- }
-
- return heapAllocations;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeLibraryAllocationInfo.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeLibraryAllocationInfo.java
deleted file mode 100644
index 1722cdb..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeLibraryAllocationInfo.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.heap;
-
-import com.android.ddmlib.NativeAllocationInfo;
-import com.android.ddmlib.NativeStackCallInfo;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/**
- * A heap dump representation where each call site is associated with its source library.
- */
-public final class NativeLibraryAllocationInfo {
- /** Library name to use when grouping before symbol resolution is complete. */
- public static final String UNRESOLVED_LIBRARY_NAME = "Resolving..";
-
- /** Any call site that cannot be resolved to a specific library goes under this name. */
- private static final String UNKNOWN_LIBRARY_NAME = "unknown";
-
- private final String mLibraryName;
- private final List<NativeAllocationInfo> mHeapAllocations;
- private int mTotalSize;
-
- private NativeLibraryAllocationInfo(String libraryName) {
- mLibraryName = libraryName;
- mHeapAllocations = new ArrayList<NativeAllocationInfo>();
- }
-
- private void addAllocation(NativeAllocationInfo info) {
- mHeapAllocations.add(info);
- }
-
- private void updateTotalSize() {
- mTotalSize = 0;
- for (NativeAllocationInfo i : mHeapAllocations) {
- mTotalSize += i.getAllocationCount() * i.getSize();
- }
- }
-
- public String getLibraryName() {
- return mLibraryName;
- }
-
- public long getTotalSize() {
- return mTotalSize;
- }
-
- public List<NativeAllocationInfo> getAllocations() {
- return mHeapAllocations;
- }
-
- /**
- * Factory method to create a list of {@link NativeLibraryAllocationInfo} objects,
- * given the list of {@link NativeAllocationInfo} objects.
- *
- * If the {@link NativeAllocationInfo} objects do not have their symbols resolved,
- * then they are grouped under the library {@link #UNRESOLVED_LIBRARY_NAME}. If they do
- * have their symbols resolved, but map to an unknown library, then they are grouped under
- * the library {@link #UNKNOWN_LIBRARY_NAME}.
- */
- public static List<NativeLibraryAllocationInfo> constructFrom(
- List<NativeAllocationInfo> allocations) {
- if (allocations == null) {
- return null;
- }
-
- Map<String, NativeLibraryAllocationInfo> allocationsByLibrary =
- new HashMap<String, NativeLibraryAllocationInfo>();
-
- // go through each native allocation and assign it to the appropriate library
- for (NativeAllocationInfo info : allocations) {
- String libName = UNRESOLVED_LIBRARY_NAME;
-
- if (info.isStackCallResolved()) {
- NativeStackCallInfo relevantStackCall = info.getRelevantStackCallInfo();
- if (relevantStackCall != null) {
- libName = relevantStackCall.getLibraryName();
- } else {
- libName = UNKNOWN_LIBRARY_NAME;
- }
- }
-
- addtoLibrary(allocationsByLibrary, libName, info);
- }
-
- List<NativeLibraryAllocationInfo> libraryAllocations =
- new ArrayList<NativeLibraryAllocationInfo>(allocationsByLibrary.values());
-
- // now update some summary statistics for each library
- for (NativeLibraryAllocationInfo l : libraryAllocations) {
- l.updateTotalSize();
- }
-
- // finally, sort by total size
- Collections.sort(libraryAllocations, new Comparator<NativeLibraryAllocationInfo>() {
- @Override
- public int compare(NativeLibraryAllocationInfo o1,
- NativeLibraryAllocationInfo o2) {
- return (int) (o2.getTotalSize() - o1.getTotalSize());
- }
- });
-
- return libraryAllocations;
- }
-
- private static void addtoLibrary(Map<String, NativeLibraryAllocationInfo> libraryAllocations,
- String libName, NativeAllocationInfo info) {
- NativeLibraryAllocationInfo libAllocationInfo = libraryAllocations.get(libName);
- if (libAllocationInfo == null) {
- libAllocationInfo = new NativeLibraryAllocationInfo(libName);
- libraryAllocations.put(libName, libAllocationInfo);
- }
-
- libAllocationInfo.addAllocation(info);
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeStackContentProvider.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeStackContentProvider.java
deleted file mode 100644
index 9a6ddb2..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeStackContentProvider.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.heap;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-import java.util.List;
-
-public class NativeStackContentProvider implements ITreeContentProvider {
- @Override
- public Object[] getElements(Object arg0) {
- return getChildren(arg0);
- }
-
- @Override
- public void dispose() {
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- @Override
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof List<?>) {
- return ((List<?>) parentElement).toArray();
- }
-
- return null;
- }
-
- @Override
- public Object getParent(Object element) {
- return null;
- }
-
- @Override
- public boolean hasChildren(Object element) {
- return false;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeStackLabelProvider.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeStackLabelProvider.java
deleted file mode 100644
index b7428b9..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeStackLabelProvider.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.heap;
-
-import com.android.ddmlib.NativeStackCallInfo;
-
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-public class NativeStackLabelProvider extends LabelProvider implements ITableLabelProvider {
- @Override
- public Image getColumnImage(Object arg0, int arg1) {
- return null;
- }
-
- @Override
- public String getColumnText(Object element, int index) {
- if (element instanceof NativeStackCallInfo) {
- return getResolvedStackTraceColumnText((NativeStackCallInfo) element, index);
- }
-
- if (element instanceof Long) {
- // if the addresses have not been resolved, then just display the
- // addresses alone
- return getStackAddressColumnText((Long) element, index);
- }
-
- return null;
- }
-
- public String getResolvedStackTraceColumnText(NativeStackCallInfo info, int index) {
- switch (index) {
- case 0:
- return String.format("0x%08x", info.getAddress());
- case 1:
- return info.getLibraryName();
- case 2:
- return info.getMethodName();
- case 3:
- return info.getSourceFile();
- case 4:
- int l = info.getLineNumber();
- return l == -1 ? "" : Integer.toString(l);
- }
-
- return null;
- }
-
- private String getStackAddressColumnText(Long address, int index) {
- if (index == 0) {
- return String.format("0x%08x", address);
- }
-
- return null;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeSymbolResolverTask.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeSymbolResolverTask.java
deleted file mode 100644
index 1a75c6e..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/heap/NativeSymbolResolverTask.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.heap;
-
-import com.android.ddmlib.NativeAllocationInfo;
-import com.android.ddmlib.NativeLibraryMapInfo;
-import com.android.ddmlib.NativeStackCallInfo;
-import com.android.ddmuilib.DdmUiPreferences;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-/**
- * A symbol resolver task that can resolve a set of addresses to their corresponding
- * source method name + file name:line number.
- *
- * It first identifies the library that contains the address, and then runs addr2line on
- * the library to get the symbol name + source location.
- */
-public class NativeSymbolResolverTask implements IRunnableWithProgress {
- private static final String ADDR2LINE;
- private static final String DEFAULT_SYMBOLS_FOLDER;
-
- static {
- String addr2lineEnv = System.getenv("ANDROID_ADDR2LINE");
- ADDR2LINE = addr2lineEnv != null ? addr2lineEnv : DdmUiPreferences.getAddr2Line();
-
- String symbols = System.getenv("ANDROID_SYMBOLS");
- DEFAULT_SYMBOLS_FOLDER = symbols != null ? symbols : DdmUiPreferences.getSymbolDirectory();
- }
-
- private List<NativeAllocationInfo> mCallSites;
- private List<NativeLibraryMapInfo> mMappedLibraries;
- private List<String> mSymbolSearchFolders;
-
- /** All unresolved addresses from all the callsites. */
- private SortedSet<Long> mUnresolvedAddresses;
-
- /** Set of all addresses that could were not resolved at the end of the resolution process. */
- private Set<Long> mUnresolvableAddresses;
-
- /** Map of library -> [unresolved addresses mapping to this library]. */
- private Map<NativeLibraryMapInfo, Set<Long>> mUnresolvedAddressesPerLibrary;
-
- /** Addresses that could not be mapped to a library, should be mostly empty. */
- private Set<Long> mUnmappedAddresses;
-
- /** Cache of the resolution for every unresolved address. */
- private Map<Long, NativeStackCallInfo> mAddressResolution;
-
- /** List of libraries that were not located on disk. */
- private Set<String> mNotFoundLibraries;
- private String mAddr2LineErrorMessage = null;
-
- public NativeSymbolResolverTask(List<NativeAllocationInfo> callSites,
- List<NativeLibraryMapInfo> mappedLibraries,
- String symbolSearchPath) {
- mCallSites = callSites;
- mMappedLibraries = mappedLibraries;
- mSymbolSearchFolders = new ArrayList<String>();
- mSymbolSearchFolders.add(DEFAULT_SYMBOLS_FOLDER);
- mSymbolSearchFolders.addAll(Arrays.asList(symbolSearchPath.split(":")));
-
- mUnresolvedAddresses = new TreeSet<Long>();
- mUnresolvableAddresses = new HashSet<Long>();
- mUnresolvedAddressesPerLibrary = new HashMap<NativeLibraryMapInfo, Set<Long>>();
- mUnmappedAddresses = new HashSet<Long>();
- mAddressResolution = new HashMap<Long, NativeStackCallInfo>();
- mNotFoundLibraries = new HashSet<String>();
- }
-
- @Override
- public void run(IProgressMonitor monitor)
- throws InvocationTargetException, InterruptedException {
- monitor.beginTask("Resolving symbols", IProgressMonitor.UNKNOWN);
-
- collectAllUnresolvedAddresses();
- checkCancellation(monitor);
-
- mapUnresolvedAddressesToLibrary();
- checkCancellation(monitor);
-
- resolveLibraryAddresses(monitor);
- checkCancellation(monitor);
-
- resolveCallSites(mCallSites);
-
- monitor.done();
- }
-
- private void collectAllUnresolvedAddresses() {
- for (NativeAllocationInfo callSite : mCallSites) {
- mUnresolvedAddresses.addAll(callSite.getStackCallAddresses());
- }
- }
-
- private void mapUnresolvedAddressesToLibrary() {
- Set<Long> mappedAddresses = new HashSet<Long>();
-
- for (NativeLibraryMapInfo lib : mMappedLibraries) {
- SortedSet<Long> addressesInLibrary = mUnresolvedAddresses.subSet(lib.getStartAddress(),
- lib.getEndAddress() + 1);
- if (addressesInLibrary.size() > 0) {
- mUnresolvedAddressesPerLibrary.put(lib, addressesInLibrary);
- mappedAddresses.addAll(addressesInLibrary);
- }
- }
-
- // unmapped addresses = unresolved addresses - mapped addresses
- mUnmappedAddresses.addAll(mUnresolvedAddresses);
- mUnmappedAddresses.removeAll(mappedAddresses);
- }
-
- private void resolveLibraryAddresses(IProgressMonitor monitor) throws InterruptedException {
- for (NativeLibraryMapInfo lib : mUnresolvedAddressesPerLibrary.keySet()) {
- String libPath = getLibraryLocation(lib);
- Set<Long> addressesToResolve = mUnresolvedAddressesPerLibrary.get(lib);
-
- if (libPath == null) {
- mNotFoundLibraries.add(lib.getLibraryName());
- markAddressesNotResolvable(addressesToResolve, lib);
- } else {
- monitor.subTask(String.format("Resolving addresses mapped to %s.", libPath));
- resolveAddresses(lib, libPath, addressesToResolve);
- }
-
- checkCancellation(monitor);
- }
- }
-
- private void resolveAddresses(NativeLibraryMapInfo lib, String libPath,
- Set<Long> addressesToResolve) {
- Process addr2line = null;
- try {
- addr2line = new ProcessBuilder(ADDR2LINE,
- "-C", // demangle
- "-f", // display function names in addition to file:number
- "-e", libPath).start();
- } catch (IOException e) {
- // Since the library path is known to be valid, the only reason for an exception
- // is that addr2line was not found. We just save the message in this case.
- mAddr2LineErrorMessage = e.getMessage();
- markAddressesNotResolvable(addressesToResolve, lib);
- return;
- }
-
- BufferedReader resultReader = new BufferedReader(new InputStreamReader(
- addr2line.getInputStream()));
- BufferedWriter addressWriter = new BufferedWriter(new OutputStreamWriter(
- addr2line.getOutputStream()));
-
- long libStartAddress = isExecutable(lib) ? 0 : lib.getStartAddress();
- try {
- for (Long addr : addressesToResolve) {
- long offset = addr.longValue() - libStartAddress;
- addressWriter.write(Long.toHexString(offset));
- addressWriter.newLine();
- addressWriter.flush();
- String method = resultReader.readLine();
- String sourceFile = resultReader.readLine();
-
- mAddressResolution.put(addr,
- new NativeStackCallInfo(addr.longValue(),
- lib.getLibraryName(),
- method,
- sourceFile));
- }
- } catch (IOException e) {
- // if there is any error, then mark the addresses not already resolved
- // as unresolvable.
- for (Long addr : addressesToResolve) {
- if (mAddressResolution.get(addr) == null) {
- markAddressNotResolvable(lib, addr);
- }
- }
- }
-
- try {
- resultReader.close();
- addressWriter.close();
- } catch (IOException e) {
- // we can ignore these exceptions
- }
-
- addr2line.destroy();
- }
-
- private boolean isExecutable(NativeLibraryMapInfo object) {
- // TODO: Use a tool like readelf or nm to determine whether this object is a library
- // or an executable.
- // For now, we'll just assume that any object present in the bin folder is an executable.
- String devicePath = object.getLibraryName();
- return devicePath.contains("/bin/");
- }
-
- private void markAddressesNotResolvable(Set<Long> addressesToResolve,
- NativeLibraryMapInfo lib) {
- for (Long addr : addressesToResolve) {
- markAddressNotResolvable(lib, addr);
- }
- }
-
- private void markAddressNotResolvable(NativeLibraryMapInfo lib, Long addr) {
- mAddressResolution.put(addr,
- new NativeStackCallInfo(addr.longValue(),
- lib.getLibraryName(),
- Long.toHexString(addr),
- ""));
- mUnresolvableAddresses.add(addr);
- }
-
- /**
- * Locate on local disk the debug library w/ symbols corresponding to the
- * library on the device. It searches for this library in the symbol path.
- * @return absolute path if found, null otherwise
- */
- private String getLibraryLocation(NativeLibraryMapInfo lib) {
- String pathOnDevice = lib.getLibraryName();
- String libName = new File(pathOnDevice).getName();
-
- for (String p : mSymbolSearchFolders) {
- // try appending the full path on device
- String fullPath = p + File.separator + pathOnDevice;
- if (new File(fullPath).exists()) {
- return fullPath;
- }
-
- // try appending basename(library)
- fullPath = p + File.separator + libName;
- if (new File(fullPath).exists()) {
- return fullPath;
- }
- }
-
- return null;
- }
-
- private void resolveCallSites(List<NativeAllocationInfo> callSites) {
- for (NativeAllocationInfo callSite : callSites) {
- List<NativeStackCallInfo> stackInfo = new ArrayList<NativeStackCallInfo>();
-
- for (Long addr : callSite.getStackCallAddresses()) {
- NativeStackCallInfo info = mAddressResolution.get(addr);
-
- if (info != null) {
- stackInfo.add(info);
- }
- }
-
- callSite.setResolvedStackCall(stackInfo);
- }
- }
-
- private void checkCancellation(IProgressMonitor monitor) throws InterruptedException {
- if (monitor.isCanceled()) {
- throw new InterruptedException();
- }
- }
-
- public String getAddr2LineErrorMessage() {
- return mAddr2LineErrorMessage;
- }
-
- public Set<Long> getUnmappedAddresses() {
- return mUnmappedAddresses;
- }
-
- public Set<Long> getUnresolvableAddresses() {
- return mUnresolvableAddresses;
- }
-
- public Set<String> getNotFoundLibraries() {
- return mNotFoundLibraries;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/CoordinateControls.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/CoordinateControls.java
deleted file mode 100644
index 2aef53c..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/CoordinateControls.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.location;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-
-import java.text.DecimalFormat;
-import java.text.ParseException;
-
-/**
- * Encapsulation of controls handling a location coordinate in decimal and sexagesimal.
- * <p/>This handle the conversion between both modes automatically by using a {@link ModifyListener}
- * on all the {@link Text} widgets.
- * <p/>To get/set the coordinate, use {@link #setValue(double)} and {@link #getValue()} (preceded by
- * a call to {@link #isValueValid()})
- */
-public final class CoordinateControls {
- private double mValue;
- private boolean mValueValidity = false;
- private Text mDecimalText;
- private Text mSexagesimalDegreeText;
- private Text mSexagesimalMinuteText;
- private Text mSexagesimalSecondText;
- private final DecimalFormat mDecimalFormat = new DecimalFormat();
-
- /** Internal flag to prevent {@link ModifyEvent} to be sent when {@link Text#setText(String)}
- * is called. This is an int instead of a boolean to act as a counter. */
- private int mManualTextChange = 0;
-
- /**
- * ModifyListener for the 3 {@link Text} controls of the sexagesimal mode.
- */
- private ModifyListener mSexagesimalListener = new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent event) {
- if (mManualTextChange > 0) {
- return;
- }
- try {
- mValue = getValueFromSexagesimalControls();
- setValueIntoDecimalControl(mValue);
- mValueValidity = true;
- } catch (ParseException e) {
- // wrong format empty the decimal controls.
- mValueValidity = false;
- resetDecimalControls();
- }
- }
- };
-
- /**
- * Creates the {@link Text} control for the decimal display of the coordinate.
- * <p/>The control is expected to be placed in a Composite using a {@link GridLayout}.
- * @param parent The {@link Composite} parent of the control.
- */
- public void createDecimalText(Composite parent) {
- mDecimalText = createTextControl(parent, "-199.999999", new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent event) {
- if (mManualTextChange > 0) {
- return;
- }
- try {
- mValue = mDecimalFormat.parse(mDecimalText.getText()).doubleValue();
- setValueIntoSexagesimalControl(mValue);
- mValueValidity = true;
- } catch (ParseException e) {
- // wrong format empty the sexagesimal controls.
- mValueValidity = false;
- resetSexagesimalControls();
- }
- }
- });
- }
-
- /**
- * Creates the {@link Text} control for the "degree" display of the coordinate in sexagesimal
- * mode.
- * <p/>The control is expected to be placed in a Composite using a {@link GridLayout}.
- * @param parent The {@link Composite} parent of the control.
- */
- public void createSexagesimalDegreeText(Composite parent) {
- mSexagesimalDegreeText = createTextControl(parent, "-199", mSexagesimalListener); //$NON-NLS-1$
- }
-
- /**
- * Creates the {@link Text} control for the "minute" display of the coordinate in sexagesimal
- * mode.
- * <p/>The control is expected to be placed in a Composite using a {@link GridLayout}.
- * @param parent The {@link Composite} parent of the control.
- */
- public void createSexagesimalMinuteText(Composite parent) {
- mSexagesimalMinuteText = createTextControl(parent, "99", mSexagesimalListener); //$NON-NLS-1$
- }
-
- /**
- * Creates the {@link Text} control for the "second" display of the coordinate in sexagesimal
- * mode.
- * <p/>The control is expected to be placed in a Composite using a {@link GridLayout}.
- * @param parent The {@link Composite} parent of the control.
- */
- public void createSexagesimalSecondText(Composite parent) {
- mSexagesimalSecondText = createTextControl(parent, "99.999", mSexagesimalListener); //$NON-NLS-1$
- }
-
- /**
- * Sets the coordinate into the {@link Text} controls.
- * @param value the coordinate value to set.
- */
- public void setValue(double value) {
- mValue = value;
- mValueValidity = true;
- setValueIntoDecimalControl(value);
- setValueIntoSexagesimalControl(value);
- }
-
- /**
- * Returns whether the value in the control(s) is valid.
- */
- public boolean isValueValid() {
- return mValueValidity;
- }
-
- /**
- * Returns the current value set in the control(s).
- * <p/>This value can be erroneous, and a check with {@link #isValueValid()} should be performed
- * before any call to this method.
- */
- public double getValue() {
- return mValue;
- }
-
- /**
- * Enables or disables all the {@link Text} controls.
- * @param enabled the enabled state.
- */
- public void setEnabled(boolean enabled) {
- mDecimalText.setEnabled(enabled);
- mSexagesimalDegreeText.setEnabled(enabled);
- mSexagesimalMinuteText.setEnabled(enabled);
- mSexagesimalSecondText.setEnabled(enabled);
- }
-
- private void resetDecimalControls() {
- mManualTextChange++;
- mDecimalText.setText(""); //$NON-NLS-1$
- mManualTextChange--;
- }
-
- private void resetSexagesimalControls() {
- mManualTextChange++;
- mSexagesimalDegreeText.setText(""); //$NON-NLS-1$
- mSexagesimalMinuteText.setText(""); //$NON-NLS-1$
- mSexagesimalSecondText.setText(""); //$NON-NLS-1$
- mManualTextChange--;
- }
-
- /**
- * Creates a {@link Text} with a given parent, default string and a {@link ModifyListener}
- * @param parent the parent {@link Composite}.
- * @param defaultString the default string to be used to compute the {@link Text} control
- * size hint.
- * @param listener the {@link ModifyListener} to be called when the {@link Text} control is
- * modified.
- */
- private Text createTextControl(Composite parent, String defaultString,
- ModifyListener listener) {
- // create the control
- Text text = new Text(parent, SWT.BORDER | SWT.LEFT | SWT.SINGLE);
-
- // add the standard listener to it.
- text.addModifyListener(listener);
-
- // compute its size/
- mManualTextChange++;
- text.setText(defaultString);
- text.pack();
- Point size = text.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- text.setText(""); //$NON-NLS-1$
- mManualTextChange--;
-
- GridData gridData = new GridData();
- gridData.widthHint = size.x;
- text.setLayoutData(gridData);
-
- return text;
- }
-
- private double getValueFromSexagesimalControls() throws ParseException {
- double degrees = mDecimalFormat.parse(mSexagesimalDegreeText.getText()).doubleValue();
- double minutes = mDecimalFormat.parse(mSexagesimalMinuteText.getText()).doubleValue();
- double seconds = mDecimalFormat.parse(mSexagesimalSecondText.getText()).doubleValue();
-
- boolean isPositive = (degrees >= 0.);
- degrees = Math.abs(degrees);
-
- double value = degrees + minutes / 60. + seconds / 3600.;
- return isPositive ? value : - value;
- }
-
- private void setValueIntoDecimalControl(double value) {
- mManualTextChange++;
- mDecimalText.setText(String.format("%.6f", value));
- mManualTextChange--;
- }
-
- private void setValueIntoSexagesimalControl(double value) {
- // get the sign and make the number positive no matter what.
- boolean isPositive = (value >= 0.);
- value = Math.abs(value);
-
- // get the degree
- double degrees = Math.floor(value);
-
- // get the minutes
- double minutes = Math.floor((value - degrees) * 60.);
-
- // get the seconds.
- double seconds = (value - degrees) * 3600. - minutes * 60.;
-
- mManualTextChange++;
- mSexagesimalDegreeText.setText(
- Integer.toString(isPositive ? (int)degrees : (int)- degrees));
- mSexagesimalMinuteText.setText(Integer.toString((int)minutes));
- mSexagesimalSecondText.setText(String.format("%.3f", seconds)); //$NON-NLS-1$
- mManualTextChange--;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/GpxParser.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/GpxParser.java
deleted file mode 100644
index a30337a..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/GpxParser.java
+++ /dev/null
@@ -1,373 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.location;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.helpers.DefaultHandler;
-
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.List;
-import java.util.TimeZone;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-/**
- * A very basic GPX parser to meet the need of the emulator control panel.
- * <p/>
- * It parses basic waypoint information, and tracks (merging segments).
- */
-public class GpxParser {
-
- private final static String NS_GPX = "http://www.topografix.com/GPX/1/1"; //$NON-NLS-1$
-
- private final static String NODE_WAYPOINT = "wpt"; //$NON-NLS-1$
- private final static String NODE_TRACK = "trk"; //$NON-NLS-1$
- private final static String NODE_TRACK_SEGMENT = "trkseg"; //$NON-NLS-1$
- private final static String NODE_TRACK_POINT = "trkpt"; //$NON-NLS-1$
- private final static String NODE_NAME = "name"; //$NON-NLS-1$
- private final static String NODE_TIME = "time"; //$NON-NLS-1$
- private final static String NODE_ELEVATION = "ele"; //$NON-NLS-1$
- private final static String NODE_DESCRIPTION = "desc"; //$NON-NLS-1$
- private final static String ATTR_LONGITUDE = "lon"; //$NON-NLS-1$
- private final static String ATTR_LATITUDE = "lat"; //$NON-NLS-1$
-
- private static SAXParserFactory sParserFactory;
-
- static {
- sParserFactory = SAXParserFactory.newInstance();
- sParserFactory.setNamespaceAware(true);
- }
-
- private String mFileName;
-
- private GpxHandler mHandler;
-
- /** Pattern to parse time with optional sub-second precision, and optional
- * Z indicating the time is in UTC. */
- private final static Pattern ISO8601_TIME =
- Pattern.compile("(\\d{4})-(\\d\\d)-(\\d\\d)T(\\d\\d):(\\d\\d):(\\d\\d)(?:(\\.\\d+))?(Z)?"); //$NON-NLS-1$
-
- /**
- * Handler for the SAX parser.
- */
- private static class GpxHandler extends DefaultHandler {
- // --------- parsed data ---------
- List<WayPoint> mWayPoints;
- List<Track> mTrackList;
-
- // --------- state for parsing ---------
- Track mCurrentTrack;
- TrackPoint mCurrentTrackPoint;
- WayPoint mCurrentWayPoint;
- final StringBuilder mStringAccumulator = new StringBuilder();
-
- boolean mSuccess = true;
-
- @Override
- public void startElement(String uri, String localName, String name, Attributes attributes)
- throws SAXException {
- // we only care about the standard GPX nodes.
- try {
- if (NS_GPX.equals(uri)) {
- if (NODE_WAYPOINT.equals(localName)) {
- if (mWayPoints == null) {
- mWayPoints = new ArrayList<WayPoint>();
- }
-
- mWayPoints.add(mCurrentWayPoint = new WayPoint());
- handleLocation(mCurrentWayPoint, attributes);
- } else if (NODE_TRACK.equals(localName)) {
- if (mTrackList == null) {
- mTrackList = new ArrayList<Track>();
- }
-
- mTrackList.add(mCurrentTrack = new Track());
- } else if (NODE_TRACK_SEGMENT.equals(localName)) {
- // for now we do nothing here. This will merge all the segments into
- // a single TrackPoint list in the Track.
- } else if (NODE_TRACK_POINT.equals(localName)) {
- if (mCurrentTrack != null) {
- mCurrentTrack.addPoint(mCurrentTrackPoint = new TrackPoint());
- handleLocation(mCurrentTrackPoint, attributes);
- }
- }
- }
- } finally {
- // no matter the node, we empty the StringBuilder accumulator when we start
- // a new node.
- mStringAccumulator.setLength(0);
- }
- }
-
- /**
- * Processes new characters for the node content. The characters are simply stored,
- * and will be processed when {@link #endElement(String, String, String)} is called.
- */
- @Override
- public void characters(char[] ch, int start, int length) throws SAXException {
- mStringAccumulator.append(ch, start, length);
- }
-
- @Override
- public void endElement(String uri, String localName, String name) throws SAXException {
- if (NS_GPX.equals(uri)) {
- if (NODE_WAYPOINT.equals(localName)) {
- mCurrentWayPoint = null;
- } else if (NODE_TRACK.equals(localName)) {
- mCurrentTrack = null;
- } else if (NODE_TRACK_POINT.equals(localName)) {
- mCurrentTrackPoint = null;
- } else if (NODE_NAME.equals(localName)) {
- if (mCurrentTrack != null) {
- mCurrentTrack.setName(mStringAccumulator.toString());
- } else if (mCurrentWayPoint != null) {
- mCurrentWayPoint.setName(mStringAccumulator.toString());
- }
- } else if (NODE_TIME.equals(localName)) {
- if (mCurrentTrackPoint != null) {
- mCurrentTrackPoint.setTime(computeTime(mStringAccumulator.toString()));
- }
- } else if (NODE_ELEVATION.equals(localName)) {
- if (mCurrentTrackPoint != null) {
- mCurrentTrackPoint.setElevation(
- Double.parseDouble(mStringAccumulator.toString()));
- } else if (mCurrentWayPoint != null) {
- mCurrentWayPoint.setElevation(
- Double.parseDouble(mStringAccumulator.toString()));
- }
- } else if (NODE_DESCRIPTION.equals(localName)) {
- if (mCurrentWayPoint != null) {
- mCurrentWayPoint.setDescription(mStringAccumulator.toString());
- }
- }
- }
- }
-
- @Override
- public void error(SAXParseException e) throws SAXException {
- mSuccess = false;
- }
-
- @Override
- public void fatalError(SAXParseException e) throws SAXException {
- mSuccess = false;
- }
-
- /**
- * Converts the string description of the time into milliseconds since epoch.
- * @param timeString the string data.
- * @return date in milliseconds.
- */
- private long computeTime(String timeString) {
- // Time looks like: 2008-04-05T19:24:50Z
- Matcher m = ISO8601_TIME.matcher(timeString);
- if (m.matches()) {
- // get the various elements and reconstruct time as a long.
- try {
- int year = Integer.parseInt(m.group(1));
- int month = Integer.parseInt(m.group(2));
- int date = Integer.parseInt(m.group(3));
- int hourOfDay = Integer.parseInt(m.group(4));
- int minute = Integer.parseInt(m.group(5));
- int second = Integer.parseInt(m.group(6));
-
- // handle the optional parameters.
- int milliseconds = 0;
-
- String subSecondGroup = m.group(7);
- if (subSecondGroup != null) {
- milliseconds = (int)(1000 * Double.parseDouble(subSecondGroup));
- }
-
- boolean utcTime = m.group(8) != null;
-
- // now we convert into milliseconds since epoch.
- Calendar c;
- if (utcTime) {
- c = Calendar.getInstance(TimeZone.getTimeZone("GMT")); //$NON-NLS-1$
- } else {
- c = Calendar.getInstance();
- }
-
- c.set(year, month, date, hourOfDay, minute, second);
-
- return c.getTimeInMillis() + milliseconds;
- } catch (NumberFormatException e) {
- // format is invalid, we'll return -1 below.
- }
-
- }
-
- // invalid time!
- return -1;
- }
-
- /**
- * Handles the location attributes and store them into a {@link LocationPoint}.
- * @param locationNode the {@link LocationPoint} to receive the location data.
- * @param attributes the attributes from the XML node.
- */
- private void handleLocation(LocationPoint locationNode, Attributes attributes) {
- try {
- double longitude = Double.parseDouble(attributes.getValue(ATTR_LONGITUDE));
- double latitude = Double.parseDouble(attributes.getValue(ATTR_LATITUDE));
-
- locationNode.setLocation(longitude, latitude);
- } catch (NumberFormatException e) {
- // wrong data, do nothing.
- }
- }
-
- WayPoint[] getWayPoints() {
- if (mWayPoints != null) {
- return mWayPoints.toArray(new WayPoint[mWayPoints.size()]);
- }
-
- return null;
- }
-
- Track[] getTracks() {
- if (mTrackList != null) {
- return mTrackList.toArray(new Track[mTrackList.size()]);
- }
-
- return null;
- }
-
- boolean getSuccess() {
- return mSuccess;
- }
- }
-
- /**
- * A GPS track.
- * <p/>A track is composed of a list of {@link TrackPoint} and optional name and comment.
- */
- public final static class Track {
- private String mName;
- private String mComment;
- private List<TrackPoint> mPoints = new ArrayList<TrackPoint>();
-
- void setName(String name) {
- mName = name;
- }
-
- public String getName() {
- return mName;
- }
-
- void setComment(String comment) {
- mComment = comment;
- }
-
- public String getComment() {
- return mComment;
- }
-
- void addPoint(TrackPoint trackPoint) {
- mPoints.add(trackPoint);
- }
-
- public TrackPoint[] getPoints() {
- return mPoints.toArray(new TrackPoint[mPoints.size()]);
- }
-
- public long getFirstPointTime() {
- if (mPoints.size() > 0) {
- return mPoints.get(0).getTime();
- }
-
- return -1;
- }
-
- public long getLastPointTime() {
- if (mPoints.size() > 0) {
- return mPoints.get(mPoints.size()-1).getTime();
- }
-
- return -1;
- }
-
- public int getPointCount() {
- return mPoints.size();
- }
- }
-
- /**
- * Creates a new GPX parser for a file specified by its full path.
- * @param fileName The full path of the GPX file to parse.
- */
- public GpxParser(String fileName) {
- mFileName = fileName;
- }
-
- /**
- * Parses the GPX file.
- * @return <code>true</code> if success.
- */
- public boolean parse() {
- try {
- SAXParser parser = sParserFactory.newSAXParser();
-
- mHandler = new GpxHandler();
-
- parser.parse(new InputSource(new FileReader(mFileName)), mHandler);
-
- return mHandler.getSuccess();
- } catch (ParserConfigurationException e) {
- } catch (SAXException e) {
- } catch (IOException e) {
- } finally {
- }
-
- return false;
- }
-
- /**
- * Returns the parsed {@link WayPoint} objects, or <code>null</code> if none were found (or
- * if the parsing failed.
- */
- public WayPoint[] getWayPoints() {
- if (mHandler != null) {
- return mHandler.getWayPoints();
- }
-
- return null;
- }
-
- /**
- * Returns the parsed {@link Track} objects, or <code>null</code> if none were found (or
- * if the parsing failed.
- */
- public Track[] getTracks() {
- if (mHandler != null) {
- return mHandler.getTracks();
- }
-
- return null;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/KmlParser.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/KmlParser.java
deleted file mode 100644
index af485ac..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/KmlParser.java
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.location;
-
-import org.xml.sax.Attributes;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.helpers.DefaultHandler;
-
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-/**
- * A very basic KML parser to meet the need of the emulator control panel.
- * <p/>
- * It parses basic Placemark information.
- */
-public class KmlParser {
-
- private final static String NS_KML_2 = "http://earth.google.com/kml/2."; //$NON-NLS-1$
-
- private final static String NODE_PLACEMARK = "Placemark"; //$NON-NLS-1$
- private final static String NODE_NAME = "name"; //$NON-NLS-1$
- private final static String NODE_COORDINATES = "coordinates"; //$NON-NLS-1$
-
- private final static Pattern sLocationPattern = Pattern.compile("([^,]+),([^,]+)(?:,([^,]+))?");
-
- private static SAXParserFactory sParserFactory;
-
- static {
- sParserFactory = SAXParserFactory.newInstance();
- sParserFactory.setNamespaceAware(true);
- }
-
- private String mFileName;
-
- private KmlHandler mHandler;
-
- /**
- * Handler for the SAX parser.
- */
- private static class KmlHandler extends DefaultHandler {
- // --------- parsed data ---------
- List<WayPoint> mWayPoints;
-
- // --------- state for parsing ---------
- WayPoint mCurrentWayPoint;
- final StringBuilder mStringAccumulator = new StringBuilder();
-
- boolean mSuccess = true;
-
- @Override
- public void startElement(String uri, String localName, String name, Attributes attributes)
- throws SAXException {
- // we only care about the standard GPX nodes.
- try {
- if (uri.startsWith(NS_KML_2)) {
- if (NODE_PLACEMARK.equals(localName)) {
- if (mWayPoints == null) {
- mWayPoints = new ArrayList<WayPoint>();
- }
-
- mWayPoints.add(mCurrentWayPoint = new WayPoint());
- }
- }
- } finally {
- // no matter the node, we empty the StringBuilder accumulator when we start
- // a new node.
- mStringAccumulator.setLength(0);
- }
- }
-
- /**
- * Processes new characters for the node content. The characters are simply stored,
- * and will be processed when {@link #endElement(String, String, String)} is called.
- */
- @Override
- public void characters(char[] ch, int start, int length) throws SAXException {
- mStringAccumulator.append(ch, start, length);
- }
-
- @Override
- public void endElement(String uri, String localName, String name) throws SAXException {
- if (uri.startsWith(NS_KML_2)) {
- if (NODE_PLACEMARK.equals(localName)) {
- mCurrentWayPoint = null;
- } else if (NODE_NAME.equals(localName)) {
- if (mCurrentWayPoint != null) {
- mCurrentWayPoint.setName(mStringAccumulator.toString());
- }
- } else if (NODE_COORDINATES.equals(localName)) {
- if (mCurrentWayPoint != null) {
- parseLocation(mCurrentWayPoint, mStringAccumulator.toString());
- }
- }
- }
- }
-
- @Override
- public void error(SAXParseException e) throws SAXException {
- mSuccess = false;
- }
-
- @Override
- public void fatalError(SAXParseException e) throws SAXException {
- mSuccess = false;
- }
-
- /**
- * Parses the location string and store the information into a {@link LocationPoint}.
- * @param locationNode the {@link LocationPoint} to receive the location data.
- * @param location The string containing the location info.
- */
- private void parseLocation(LocationPoint locationNode, String location) {
- Matcher m = sLocationPattern.matcher(location);
- if (m.matches()) {
- try {
- double longitude = Double.parseDouble(m.group(1));
- double latitude = Double.parseDouble(m.group(2));
-
- locationNode.setLocation(longitude, latitude);
-
- if (m.groupCount() == 3) {
- // looks like we have elevation data.
- locationNode.setElevation(Double.parseDouble(m.group(3)));
- }
- } catch (NumberFormatException e) {
- // wrong data, do nothing.
- }
- }
- }
-
- WayPoint[] getWayPoints() {
- if (mWayPoints != null) {
- return mWayPoints.toArray(new WayPoint[mWayPoints.size()]);
- }
-
- return null;
- }
-
- boolean getSuccess() {
- return mSuccess;
- }
- }
-
- /**
- * Creates a new GPX parser for a file specified by its full path.
- * @param fileName The full path of the GPX file to parse.
- */
- public KmlParser(String fileName) {
- mFileName = fileName;
- }
-
- /**
- * Parses the GPX file.
- * @return <code>true</code> if success.
- */
- public boolean parse() {
- try {
- SAXParser parser = sParserFactory.newSAXParser();
-
- mHandler = new KmlHandler();
-
- parser.parse(new InputSource(new FileReader(mFileName)), mHandler);
-
- return mHandler.getSuccess();
- } catch (ParserConfigurationException e) {
- } catch (SAXException e) {
- } catch (IOException e) {
- } finally {
- }
-
- return false;
- }
-
- /**
- * Returns the parsed {@link WayPoint} objects, or <code>null</code> if none were found (or
- * if the parsing failed.
- */
- public WayPoint[] getWayPoints() {
- if (mHandler != null) {
- return mHandler.getWayPoints();
- }
-
- return null;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/LocationPoint.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/LocationPoint.java
deleted file mode 100644
index dbb8f41..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/LocationPoint.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.location;
-
-/**
- * Base class for Location aware points.
- */
-class LocationPoint {
- private double mLongitude;
- private double mLatitude;
- private boolean mHasElevation = false;
- private double mElevation;
-
- final void setLocation(double longitude, double latitude) {
- mLongitude = longitude;
- mLatitude = latitude;
- }
-
- public final double getLongitude() {
- return mLongitude;
- }
-
- public final double getLatitude() {
- return mLatitude;
- }
-
- final void setElevation(double elevation) {
- mElevation = elevation;
- mHasElevation = true;
- }
-
- public final boolean hasElevation() {
- return mHasElevation;
- }
-
- public final double getElevation() {
- return mElevation;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/TrackContentProvider.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/TrackContentProvider.java
deleted file mode 100644
index da21920..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/TrackContentProvider.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.location;
-
-import com.android.ddmuilib.location.GpxParser.Track;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * Content provider to display {@link Track} objects in a Table.
- * <p/>The expected type for the input is {@link Track}<code>[]</code>.
- */
-public class TrackContentProvider implements IStructuredContentProvider {
-
- @Override
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof Track[]) {
- return (Track[])inputElement;
- }
-
- return new Object[0];
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // pass
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/TrackLabelProvider.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/TrackLabelProvider.java
deleted file mode 100644
index 50acb53..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/TrackLabelProvider.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.location;
-
-import com.android.ddmuilib.location.GpxParser.Track;
-
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Table;
-
-import java.util.Date;
-
-/**
- * Label Provider for {@link Table} objects displaying {@link Track} objects.
- */
-public class TrackLabelProvider implements ITableLabelProvider {
-
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- @Override
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof Track) {
- Track track = (Track)element;
- switch (columnIndex) {
- case 0:
- return track.getName();
- case 1:
- return Integer.toString(track.getPointCount());
- case 2:
- long time = track.getFirstPointTime();
- if (time != -1) {
- return new Date(time).toString();
- }
- break;
- case 3:
- time = track.getLastPointTime();
- if (time != -1) {
- return new Date(time).toString();
- }
- break;
- case 4:
- return track.getComment();
- }
- }
-
- return null;
- }
-
- @Override
- public void addListener(ILabelProviderListener listener) {
- // pass
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- // pass
- return false;
- }
-
- @Override
- public void removeListener(ILabelProviderListener listener) {
- // pass
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/TrackPoint.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/TrackPoint.java
deleted file mode 100644
index 527f4bf..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/TrackPoint.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.location;
-
-
-/**
- * A Track Point.
- * <p/>A track point is a point in time and space.
- */
-public class TrackPoint extends LocationPoint {
- private long mTime;
-
- void setTime(long time) {
- mTime = time;
- }
-
- public long getTime() {
- return mTime;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/WayPoint.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/WayPoint.java
deleted file mode 100644
index 32880bd..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/WayPoint.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.location;
-
-/**
- * A GPS/KML way point.
- * <p/>A waypoint is a user specified location, with a name and an optional description.
- */
-public final class WayPoint extends LocationPoint {
- private String mName;
- private String mDescription;
-
- void setName(String name) {
- mName = name;
- }
-
- public String getName() {
- return mName;
- }
-
- void setDescription(String description) {
- mDescription = description;
- }
-
- public String getDescription() {
- return mDescription;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/WayPointContentProvider.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/WayPointContentProvider.java
deleted file mode 100644
index 1b7fe15..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/WayPointContentProvider.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.location;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * Content provider to display {@link WayPoint} objects in a Table.
- * <p/>The expected type for the input is {@link WayPoint}<code>[]</code>.
- */
-public class WayPointContentProvider implements IStructuredContentProvider {
-
- @Override
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof WayPoint[]) {
- return (WayPoint[])inputElement;
- }
-
- return new Object[0];
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // pass
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/WayPointLabelProvider.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/WayPointLabelProvider.java
deleted file mode 100644
index 9f642f1..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/location/WayPointLabelProvider.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.location;
-
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Table;
-
-/**
- * Label Provider for {@link Table} objects displaying {@link WayPoint} objects.
- */
-public class WayPointLabelProvider implements ITableLabelProvider {
-
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- @Override
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof WayPoint) {
- WayPoint wayPoint = (WayPoint)element;
- switch (columnIndex) {
- case 0:
- return wayPoint.getName();
- case 1:
- return String.format("%.6f", wayPoint.getLongitude());
- case 2:
- return String.format("%.6f", wayPoint.getLatitude());
- case 3:
- if (wayPoint.hasElevation()) {
- return String.format("%.1f", wayPoint.getElevation());
- } else {
- return "-";
- }
- case 4:
- return wayPoint.getDescription();
- }
- }
-
- return null;
- }
-
- @Override
- public void addListener(ILabelProviderListener listener) {
- // pass
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- // pass
- return false;
- }
-
- @Override
- public void removeListener(ILabelProviderListener listener) {
- // pass
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/BugReportImporter.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/BugReportImporter.java
deleted file mode 100644
index da41e70..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/BugReportImporter.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.log.event;
-
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-
-public class BugReportImporter {
-
- private final static String TAG_HEADER = "------ EVENT LOG TAGS ------";
- private final static String LOG_HEADER = "------ EVENT LOG ------";
- private final static String HEADER_TAG = "------";
-
- private String[] mTags;
- private String[] mLog;
-
- public BugReportImporter(String filePath) throws FileNotFoundException {
- BufferedReader reader = new BufferedReader(
- new InputStreamReader(new FileInputStream(filePath)));
-
- try {
- String line;
- while ((line = reader.readLine()) != null) {
- if (TAG_HEADER.equals(line)) {
- readTags(reader);
- return;
- }
- }
- } catch (IOException e) {
- } finally {
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException ignore) {
- }
- }
- }
- }
-
- public String[] getTags() {
- return mTags;
- }
-
- public String[] getLog() {
- return mLog;
- }
-
- private void readTags(BufferedReader reader) throws IOException {
- String line;
-
- ArrayList<String> content = new ArrayList<String>();
- while ((line = reader.readLine()) != null) {
- if (LOG_HEADER.equals(line)) {
- mTags = content.toArray(new String[content.size()]);
- readLog(reader);
- return;
- } else {
- content.add(line);
- }
- }
- }
-
- private void readLog(BufferedReader reader) throws IOException {
- String line;
-
- ArrayList<String> content = new ArrayList<String>();
- while ((line = reader.readLine()) != null) {
- if (line.startsWith(HEADER_TAG) == false) {
- content.add(line);
- } else {
- break;
- }
- }
-
- mLog = content.toArray(new String[content.size()]);
- }
-
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplayFilteredLog.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplayFilteredLog.java
deleted file mode 100644
index 473387a..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplayFilteredLog.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.log.event;
-
-import com.android.ddmlib.log.EventContainer;
-import com.android.ddmlib.log.EventLogParser;
-
-import java.util.ArrayList;
-
-public class DisplayFilteredLog extends DisplayLog {
-
- public DisplayFilteredLog(String name) {
- super(name);
- }
-
- /**
- * Adds event to the display.
- */
- @Override
- void newEvent(EventContainer event, EventLogParser logParser) {
- ArrayList<ValueDisplayDescriptor> valueDescriptors =
- new ArrayList<ValueDisplayDescriptor>();
-
- ArrayList<OccurrenceDisplayDescriptor> occurrenceDescriptors =
- new ArrayList<OccurrenceDisplayDescriptor>();
-
- if (filterEvent(event, valueDescriptors, occurrenceDescriptors)) {
- addToLog(event, logParser, valueDescriptors, occurrenceDescriptors);
- }
- }
-
- /**
- * Gets display type
- *
- * @return display type as an integer
- */
- @Override
- int getDisplayType() {
- return DISPLAY_TYPE_FILTERED_LOG;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplayGraph.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplayGraph.java
deleted file mode 100644
index 0cffd7e..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplayGraph.java
+++ /dev/null
@@ -1,422 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.log.event;
-
-import com.android.ddmlib.log.EventContainer;
-import com.android.ddmlib.log.EventLogParser;
-import com.android.ddmlib.log.EventValueDescription;
-import com.android.ddmlib.log.InvalidTypeException;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.jfree.chart.axis.AxisLocation;
-import org.jfree.chart.axis.NumberAxis;
-import org.jfree.chart.plot.XYPlot;
-import org.jfree.chart.renderer.xy.AbstractXYItemRenderer;
-import org.jfree.chart.renderer.xy.XYAreaRenderer;
-import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
-import org.jfree.data.time.Millisecond;
-import org.jfree.data.time.TimeSeries;
-import org.jfree.data.time.TimeSeriesCollection;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-public class DisplayGraph extends EventDisplay {
-
- public DisplayGraph(String name) {
- super(name);
- }
-
- /**
- * Resets the display.
- */
- @Override
- void resetUI() {
- Collection<TimeSeriesCollection> datasets = mValueTypeDataSetMap.values();
- for (TimeSeriesCollection dataset : datasets) {
- dataset.removeAllSeries();
- }
- if (mOccurrenceDataSet != null) {
- mOccurrenceDataSet.removeAllSeries();
- }
- mValueDescriptorSeriesMap.clear();
- mOcurrenceDescriptorSeriesMap.clear();
- }
-
- /**
- * Creates the UI for the event display.
- * @param parent the parent composite.
- * @param logParser the current log parser.
- * @return the created control (which may have children).
- */
- @Override
- public Control createComposite(final Composite parent, EventLogParser logParser,
- final ILogColumnListener listener) {
- String title = getChartTitle(logParser);
- return createCompositeChart(parent, logParser, title);
- }
-
- /**
- * Adds event to the display.
- */
- @Override
- void newEvent(EventContainer event, EventLogParser logParser) {
- ArrayList<ValueDisplayDescriptor> valueDescriptors =
- new ArrayList<ValueDisplayDescriptor>();
-
- ArrayList<OccurrenceDisplayDescriptor> occurrenceDescriptors =
- new ArrayList<OccurrenceDisplayDescriptor>();
-
- if (filterEvent(event, valueDescriptors, occurrenceDescriptors)) {
- updateChart(event, logParser, valueDescriptors, occurrenceDescriptors);
- }
- }
-
- /**
- * Updates the chart with the {@link EventContainer} by adding the values/occurrences defined
- * by the {@link ValueDisplayDescriptor} and {@link OccurrenceDisplayDescriptor} objects from
- * the two lists.
- * <p/>This method is only called when at least one of the descriptor list is non empty.
- * @param event
- * @param logParser
- * @param valueDescriptors
- * @param occurrenceDescriptors
- */
- private void updateChart(EventContainer event, EventLogParser logParser,
- ArrayList<ValueDisplayDescriptor> valueDescriptors,
- ArrayList<OccurrenceDisplayDescriptor> occurrenceDescriptors) {
- Map<Integer, String> tagMap = logParser.getTagMap();
-
- Millisecond millisecondTime = null;
- long msec = -1;
-
- // If the event container is a cpu container (tag == 2721), and there is no descriptor
- // for the total CPU load, then we do accumulate all the values.
- boolean accumulateValues = false;
- double accumulatedValue = 0;
-
- if (event.mTag == 2721) {
- accumulateValues = true;
- for (ValueDisplayDescriptor descriptor : valueDescriptors) {
- accumulateValues &= (descriptor.valueIndex != 0);
- }
- }
-
- for (ValueDisplayDescriptor descriptor : valueDescriptors) {
- try {
- // get the hashmap for this descriptor
- HashMap<Integer, TimeSeries> map = mValueDescriptorSeriesMap.get(descriptor);
-
- // if it's not there yet, we create it.
- if (map == null) {
- map = new HashMap<Integer, TimeSeries>();
- mValueDescriptorSeriesMap.put(descriptor, map);
- }
-
- // get the TimeSeries for this pid
- TimeSeries timeSeries = map.get(event.pid);
-
- // if it doesn't exist yet, we create it
- if (timeSeries == null) {
- // get the series name
- String seriesFullName = null;
- String seriesLabel = getSeriesLabel(event, descriptor);
-
- switch (mValueDescriptorCheck) {
- case EVENT_CHECK_SAME_TAG:
- seriesFullName = String.format("%1$s / %2$s", seriesLabel,
- descriptor.valueName);
- break;
- case EVENT_CHECK_SAME_VALUE:
- seriesFullName = String.format("%1$s", seriesLabel);
- break;
- default:
- seriesFullName = String.format("%1$s / %2$s: %3$s", seriesLabel,
- tagMap.get(descriptor.eventTag),
- descriptor.valueName);
- break;
- }
-
- // get the data set for this ValueType
- TimeSeriesCollection dataset = getValueDataset(
- logParser.getEventInfoMap().get(event.mTag)[descriptor.valueIndex]
- .getValueType(),
- accumulateValues);
-
- // create the series
- timeSeries = new TimeSeries(seriesFullName, Millisecond.class);
- if (mMaximumChartItemAge != -1) {
- timeSeries.setMaximumItemAge(mMaximumChartItemAge * 1000);
- }
-
- dataset.addSeries(timeSeries);
-
- // add it to the map.
- map.put(event.pid, timeSeries);
- }
-
- // update the timeSeries.
-
- // get the value from the event
- double value = event.getValueAsDouble(descriptor.valueIndex);
-
- // accumulate the values if needed.
- if (accumulateValues) {
- accumulatedValue += value;
- value = accumulatedValue;
- }
-
- // get the time
- if (millisecondTime == null) {
- msec = (long)event.sec * 1000L + (event.nsec / 1000000L);
- millisecondTime = new Millisecond(new Date(msec));
- }
-
- // add the value to the time series
- timeSeries.addOrUpdate(millisecondTime, value);
- } catch (InvalidTypeException e) {
- // just ignore this descriptor if there's a type mismatch
- }
- }
-
- for (OccurrenceDisplayDescriptor descriptor : occurrenceDescriptors) {
- try {
- // get the hashmap for this descriptor
- HashMap<Integer, TimeSeries> map = mOcurrenceDescriptorSeriesMap.get(descriptor);
-
- // if it's not there yet, we create it.
- if (map == null) {
- map = new HashMap<Integer, TimeSeries>();
- mOcurrenceDescriptorSeriesMap.put(descriptor, map);
- }
-
- // get the TimeSeries for this pid
- TimeSeries timeSeries = map.get(event.pid);
-
- // if it doesn't exist yet, we create it.
- if (timeSeries == null) {
- String seriesLabel = getSeriesLabel(event, descriptor);
-
- String seriesFullName = String.format("[%1$s:%2$s]",
- tagMap.get(descriptor.eventTag), seriesLabel);
-
- timeSeries = new TimeSeries(seriesFullName, Millisecond.class);
- if (mMaximumChartItemAge != -1) {
- timeSeries.setMaximumItemAge(mMaximumChartItemAge);
- }
-
- getOccurrenceDataSet().addSeries(timeSeries);
-
- map.put(event.pid, timeSeries);
- }
-
- // update the series
-
- // get the time
- if (millisecondTime == null) {
- msec = (long)event.sec * 1000L + (event.nsec / 1000000L);
- millisecondTime = new Millisecond(new Date(msec));
- }
-
- // add the value to the time series
- timeSeries.addOrUpdate(millisecondTime, 0); // the value is unused
- } catch (InvalidTypeException e) {
- // just ignore this descriptor if there's a type mismatch
- }
- }
-
- // go through all the series and remove old values.
- if (msec != -1 && mMaximumChartItemAge != -1) {
- Collection<HashMap<Integer, TimeSeries>> pidMapValues =
- mValueDescriptorSeriesMap.values();
-
- for (HashMap<Integer, TimeSeries> pidMapValue : pidMapValues) {
- Collection<TimeSeries> seriesCollection = pidMapValue.values();
-
- for (TimeSeries timeSeries : seriesCollection) {
- timeSeries.removeAgedItems(msec, true);
- }
- }
-
- pidMapValues = mOcurrenceDescriptorSeriesMap.values();
- for (HashMap<Integer, TimeSeries> pidMapValue : pidMapValues) {
- Collection<TimeSeries> seriesCollection = pidMapValue.values();
-
- for (TimeSeries timeSeries : seriesCollection) {
- timeSeries.removeAgedItems(msec, true);
- }
- }
- }
- }
-
- /**
- * Returns a {@link TimeSeriesCollection} for a specific {@link com.android.ddmlib.log.EventValueDescription.ValueType}.
- * If the data set is not yet created, it is first allocated and set up into the
- * {@link org.jfree.chart.JFreeChart} object.
- * @param type the {@link com.android.ddmlib.log.EventValueDescription.ValueType} of the data set.
- * @param accumulateValues
- */
- private TimeSeriesCollection getValueDataset(EventValueDescription.ValueType type, boolean accumulateValues) {
- TimeSeriesCollection dataset = mValueTypeDataSetMap.get(type);
- if (dataset == null) {
- // create the data set and store it in the map
- dataset = new TimeSeriesCollection();
- mValueTypeDataSetMap.put(type, dataset);
-
- // create the renderer and configure it depending on the ValueType
- AbstractXYItemRenderer renderer;
- if (type == EventValueDescription.ValueType.PERCENT && accumulateValues) {
- renderer = new XYAreaRenderer();
- } else {
- XYLineAndShapeRenderer r = new XYLineAndShapeRenderer();
- r.setBaseShapesVisible(type != EventValueDescription.ValueType.PERCENT);
-
- renderer = r;
- }
-
- // set both the dataset and the renderer in the plot object.
- XYPlot xyPlot = mChart.getXYPlot();
- xyPlot.setDataset(mDataSetCount, dataset);
- xyPlot.setRenderer(mDataSetCount, renderer);
-
- // put a new axis label, and configure it.
- NumberAxis axis = new NumberAxis(type.toString());
-
- if (type == EventValueDescription.ValueType.PERCENT) {
- // force percent range to be (0,100) fixed.
- axis.setAutoRange(false);
- axis.setRange(0., 100.);
- }
-
- // for the index, we ignore the occurrence dataset
- int count = mDataSetCount;
- if (mOccurrenceDataSet != null) {
- count--;
- }
-
- xyPlot.setRangeAxis(count, axis);
- if ((count % 2) == 0) {
- xyPlot.setRangeAxisLocation(count, AxisLocation.BOTTOM_OR_LEFT);
- } else {
- xyPlot.setRangeAxisLocation(count, AxisLocation.TOP_OR_RIGHT);
- }
-
- // now we link the dataset and the axis
- xyPlot.mapDatasetToRangeAxis(mDataSetCount, count);
-
- mDataSetCount++;
- }
-
- return dataset;
- }
-
- /**
- * Return the series label for this event. This only contains the pid information.
- * @param event the {@link EventContainer}
- * @param descriptor the {@link OccurrenceDisplayDescriptor}
- * @return the series label.
- * @throws InvalidTypeException
- */
- private String getSeriesLabel(EventContainer event, OccurrenceDisplayDescriptor descriptor)
- throws InvalidTypeException {
- if (descriptor.seriesValueIndex != -1) {
- if (descriptor.includePid == false) {
- return event.getValueAsString(descriptor.seriesValueIndex);
- } else {
- return String.format("%1$s (%2$d)",
- event.getValueAsString(descriptor.seriesValueIndex), event.pid);
- }
- }
-
- return Integer.toString(event.pid);
- }
-
- /**
- * Returns the {@link TimeSeriesCollection} for the occurrence display. If the data set is not
- * yet created, it is first allocated and set up into the {@link org.jfree.chart.JFreeChart} object.
- */
- private TimeSeriesCollection getOccurrenceDataSet() {
- if (mOccurrenceDataSet == null) {
- mOccurrenceDataSet = new TimeSeriesCollection();
-
- XYPlot xyPlot = mChart.getXYPlot();
- xyPlot.setDataset(mDataSetCount, mOccurrenceDataSet);
-
- OccurrenceRenderer renderer = new OccurrenceRenderer();
- renderer.setBaseShapesVisible(false);
- xyPlot.setRenderer(mDataSetCount, renderer);
-
- mDataSetCount++;
- }
-
- return mOccurrenceDataSet;
- }
-
- /**
- * Gets display type
- *
- * @return display type as an integer
- */
- @Override
- int getDisplayType() {
- return DISPLAY_TYPE_GRAPH;
- }
-
- /**
- * Sets the current {@link EventLogParser} object.
- */
- @Override
- protected void setNewLogParser(EventLogParser logParser) {
- if (mChart != null) {
- mChart.setTitle(getChartTitle(logParser));
- }
- }
- /**
- * Returns a meaningful chart title based on the value of {@link #mValueDescriptorCheck}.
- *
- * @param logParser the logParser.
- * @return the chart title.
- */
- private String getChartTitle(EventLogParser logParser) {
- if (mValueDescriptors.size() > 0) {
- String chartDesc = null;
- switch (mValueDescriptorCheck) {
- case EVENT_CHECK_SAME_TAG:
- if (logParser != null) {
- chartDesc = logParser.getTagMap().get(mValueDescriptors.get(0).eventTag);
- }
- break;
- case EVENT_CHECK_SAME_VALUE:
- if (logParser != null) {
- chartDesc = String.format("%1$s / %2$s",
- logParser.getTagMap().get(mValueDescriptors.get(0).eventTag),
- mValueDescriptors.get(0).valueName);
- }
- break;
- }
-
- if (chartDesc != null) {
- return String.format("%1$s - %2$s", mName, chartDesc);
- }
- }
-
- return mName;
- }
-} \ No newline at end of file
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplayLog.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplayLog.java
deleted file mode 100644
index 8e7c1ac..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplayLog.java
+++ /dev/null
@@ -1,381 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.log.event;
-
-import com.android.ddmlib.log.EventContainer;
-import com.android.ddmlib.log.EventLogParser;
-import com.android.ddmlib.log.EventValueDescription;
-import com.android.ddmlib.log.InvalidTypeException;
-import com.android.ddmuilib.DdmUiPreferences;
-import com.android.ddmuilib.TableHelper;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-
-import java.util.ArrayList;
-import java.util.Calendar;
-
-public class DisplayLog extends EventDisplay {
- public DisplayLog(String name) {
- super(name);
- }
-
- private final static String PREFS_COL_DATE = "EventLogPanel.log.Col1"; //$NON-NLS-1$
- private final static String PREFS_COL_PID = "EventLogPanel.log.Col2"; //$NON-NLS-1$
- private final static String PREFS_COL_EVENTTAG = "EventLogPanel.log.Col3"; //$NON-NLS-1$
- private final static String PREFS_COL_VALUENAME = "EventLogPanel.log.Col4"; //$NON-NLS-1$
- private final static String PREFS_COL_VALUE = "EventLogPanel.log.Col5"; //$NON-NLS-1$
- private final static String PREFS_COL_TYPE = "EventLogPanel.log.Col6"; //$NON-NLS-1$
-
- /**
- * Resets the display.
- */
- @Override
- void resetUI() {
- mLogTable.removeAll();
- }
-
- /**
- * Adds event to the display.
- */
- @Override
- void newEvent(EventContainer event, EventLogParser logParser) {
- addToLog(event, logParser);
- }
-
- /**
- * Creates the UI for the event display.
- *
- * @param parent the parent composite.
- * @param logParser the current log parser.
- * @return the created control (which may have children).
- */
- @Override
- Control createComposite(Composite parent, EventLogParser logParser, ILogColumnListener listener) {
- return createLogUI(parent, listener);
- }
-
- /**
- * Adds an {@link EventContainer} to the log.
- *
- * @param event the event.
- * @param logParser the log parser.
- */
- private void addToLog(EventContainer event, EventLogParser logParser) {
- ScrollBar bar = mLogTable.getVerticalBar();
- boolean scroll = bar.getMaximum() == bar.getSelection() + bar.getThumb();
-
- // get the date.
- Calendar c = Calendar.getInstance();
- long msec = event.sec * 1000L;
- c.setTimeInMillis(msec);
-
- // convert the time into a string
- String date = String.format("%1$tF %1$tT", c);
-
- String eventName = logParser.getTagMap().get(event.mTag);
- String pidName = Integer.toString(event.pid);
-
- // get the value description
- EventValueDescription[] valueDescription = logParser.getEventInfoMap().get(event.mTag);
- if (valueDescription != null) {
- for (int i = 0; i < valueDescription.length; i++) {
- EventValueDescription description = valueDescription[i];
- try {
- String value = event.getValueAsString(i);
-
- logValue(date, pidName, eventName, description.getName(), value,
- description.getEventValueType(), description.getValueType());
- } catch (InvalidTypeException e) {
- logValue(date, pidName, eventName, description.getName(), e.getMessage(),
- description.getEventValueType(), description.getValueType());
- }
- }
-
- // scroll if needed, by showing the last item
- if (scroll) {
- int itemCount = mLogTable.getItemCount();
- if (itemCount > 0) {
- mLogTable.showItem(mLogTable.getItem(itemCount - 1));
- }
- }
- }
- }
-
- /**
- * Adds an {@link EventContainer} to the log. Only add the values/occurrences defined by
- * the list of descriptors. If an event is configured to be displayed by value and occurrence,
- * only the values are displayed (as they mark an event occurrence anyway).
- * <p/>This method is only called when at least one of the descriptor list is non empty.
- *
- * @param event
- * @param logParser
- * @param valueDescriptors
- * @param occurrenceDescriptors
- */
- protected void addToLog(EventContainer event, EventLogParser logParser,
- ArrayList<ValueDisplayDescriptor> valueDescriptors,
- ArrayList<OccurrenceDisplayDescriptor> occurrenceDescriptors) {
- ScrollBar bar = mLogTable.getVerticalBar();
- boolean scroll = bar.getMaximum() == bar.getSelection() + bar.getThumb();
-
- // get the date.
- Calendar c = Calendar.getInstance();
- long msec = event.sec * 1000L;
- c.setTimeInMillis(msec);
-
- // convert the time into a string
- String date = String.format("%1$tF %1$tT", c);
-
- String eventName = logParser.getTagMap().get(event.mTag);
- String pidName = Integer.toString(event.pid);
-
- if (valueDescriptors.size() > 0) {
- for (ValueDisplayDescriptor descriptor : valueDescriptors) {
- logDescriptor(event, descriptor, date, pidName, eventName, logParser);
- }
- } else {
- // we display the event. Since the StringBuilder contains the header (date, event name,
- // pid) at this point, there isn't anything else to display.
- }
-
- // scroll if needed, by showing the last item
- if (scroll) {
- int itemCount = mLogTable.getItemCount();
- if (itemCount > 0) {
- mLogTable.showItem(mLogTable.getItem(itemCount - 1));
- }
- }
- }
-
-
- /**
- * Logs a value in the ui.
- *
- * @param date
- * @param pid
- * @param event
- * @param valueName
- * @param value
- * @param eventValueType
- * @param valueType
- */
- private void logValue(String date, String pid, String event, String valueName,
- String value, EventContainer.EventValueType eventValueType, EventValueDescription.ValueType valueType) {
-
- TableItem item = new TableItem(mLogTable, SWT.NONE);
- item.setText(0, date);
- item.setText(1, pid);
- item.setText(2, event);
- item.setText(3, valueName);
- item.setText(4, value);
-
- String type;
- if (valueType != EventValueDescription.ValueType.NOT_APPLICABLE) {
- type = String.format("%1$s, %2$s", eventValueType.toString(), valueType.toString());
- } else {
- type = eventValueType.toString();
- }
-
- item.setText(5, type);
- }
-
- /**
- * Logs a value from an {@link EventContainer} as defined by the {@link ValueDisplayDescriptor}.
- *
- * @param event the EventContainer
- * @param descriptor the ValueDisplayDescriptor defining which value to display.
- * @param date the date of the event in a string.
- * @param pidName
- * @param eventName
- * @param logParser
- */
- private void logDescriptor(EventContainer event, ValueDisplayDescriptor descriptor,
- String date, String pidName, String eventName, EventLogParser logParser) {
-
- String value;
- try {
- value = event.getValueAsString(descriptor.valueIndex);
- } catch (InvalidTypeException e) {
- value = e.getMessage();
- }
-
- EventValueDescription[] values = logParser.getEventInfoMap().get(event.mTag);
-
- EventValueDescription valueDescription = values[descriptor.valueIndex];
-
- logValue(date, pidName, eventName, descriptor.valueName, value,
- valueDescription.getEventValueType(), valueDescription.getValueType());
- }
-
- /**
- * Creates the UI for a log display.
- *
- * @param parent the parent {@link Composite}
- * @param listener the {@link ILogColumnListener} to notify on column resize events.
- * @return the top Composite of the UI.
- */
- private Control createLogUI(Composite parent, final ILogColumnListener listener) {
- Composite mainComp = new Composite(parent, SWT.NONE);
- GridLayout gl;
- mainComp.setLayout(gl = new GridLayout(1, false));
- gl.marginHeight = gl.marginWidth = 0;
- mainComp.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- mLogTable = null;
- }
- });
-
- Label l = new Label(mainComp, SWT.CENTER);
- l.setText(mName);
- l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- mLogTable = new Table(mainComp, SWT.MULTI | SWT.FULL_SELECTION | SWT.V_SCROLL |
- SWT.BORDER);
- mLogTable.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- IPreferenceStore store = DdmUiPreferences.getStore();
-
- TableColumn col = TableHelper.createTableColumn(
- mLogTable, "Time",
- SWT.LEFT, "0000-00-00 00:00:00", PREFS_COL_DATE, store); //$NON-NLS-1$
- col.addControlListener(new ControlAdapter() {
- @Override
- public void controlResized(ControlEvent e) {
- Object source = e.getSource();
- if (source instanceof TableColumn) {
- listener.columnResized(0, (TableColumn) source);
- }
- }
- });
-
- col = TableHelper.createTableColumn(
- mLogTable, "pid",
- SWT.LEFT, "0000", PREFS_COL_PID, store); //$NON-NLS-1$
- col.addControlListener(new ControlAdapter() {
- @Override
- public void controlResized(ControlEvent e) {
- Object source = e.getSource();
- if (source instanceof TableColumn) {
- listener.columnResized(1, (TableColumn) source);
- }
- }
- });
-
- col = TableHelper.createTableColumn(
- mLogTable, "Event",
- SWT.LEFT, "abcdejghijklmno", PREFS_COL_EVENTTAG, store); //$NON-NLS-1$
- col.addControlListener(new ControlAdapter() {
- @Override
- public void controlResized(ControlEvent e) {
- Object source = e.getSource();
- if (source instanceof TableColumn) {
- listener.columnResized(2, (TableColumn) source);
- }
- }
- });
-
- col = TableHelper.createTableColumn(
- mLogTable, "Name",
- SWT.LEFT, "Process Name", PREFS_COL_VALUENAME, store); //$NON-NLS-1$
- col.addControlListener(new ControlAdapter() {
- @Override
- public void controlResized(ControlEvent e) {
- Object source = e.getSource();
- if (source instanceof TableColumn) {
- listener.columnResized(3, (TableColumn) source);
- }
- }
- });
-
- col = TableHelper.createTableColumn(
- mLogTable, "Value",
- SWT.LEFT, "0000000", PREFS_COL_VALUE, store); //$NON-NLS-1$
- col.addControlListener(new ControlAdapter() {
- @Override
- public void controlResized(ControlEvent e) {
- Object source = e.getSource();
- if (source instanceof TableColumn) {
- listener.columnResized(4, (TableColumn) source);
- }
- }
- });
-
- col = TableHelper.createTableColumn(
- mLogTable, "Type",
- SWT.LEFT, "long, seconds", PREFS_COL_TYPE, store); //$NON-NLS-1$
- col.addControlListener(new ControlAdapter() {
- @Override
- public void controlResized(ControlEvent e) {
- Object source = e.getSource();
- if (source instanceof TableColumn) {
- listener.columnResized(5, (TableColumn) source);
- }
- }
- });
-
- mLogTable.setHeaderVisible(true);
- mLogTable.setLinesVisible(true);
-
- return mainComp;
- }
-
- /**
- * Resizes the <code>index</code>-th column of the log {@link Table} (if applicable).
- * <p/>
- * This does nothing if the <code>Table</code> object is <code>null</code> (because the display
- * type does not use a column) or if the <code>index</code>-th column is in fact the originating
- * column passed as argument.
- *
- * @param index the index of the column to resize
- * @param sourceColumn the original column that was resize, and on which we need to sync the
- * index-th column width.
- */
- @Override
- void resizeColumn(int index, TableColumn sourceColumn) {
- if (mLogTable != null) {
- TableColumn col = mLogTable.getColumn(index);
- if (col != sourceColumn) {
- col.setWidth(sourceColumn.getWidth());
- }
- }
- }
-
- /**
- * Gets display type
- *
- * @return display type as an integer
- */
- @Override
- int getDisplayType() {
- return DISPLAY_TYPE_LOG_ALL;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplaySync.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplaySync.java
deleted file mode 100644
index 6122513..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplaySync.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.log.event;
-
-import com.android.ddmlib.log.EventContainer;
-import com.android.ddmlib.log.EventLogParser;
-import com.android.ddmlib.log.InvalidTypeException;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.jfree.chart.labels.CustomXYToolTipGenerator;
-import org.jfree.chart.plot.XYPlot;
-import org.jfree.chart.renderer.xy.XYBarRenderer;
-import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
-import org.jfree.data.time.FixedMillisecond;
-import org.jfree.data.time.SimpleTimePeriod;
-import org.jfree.data.time.TimePeriodValues;
-import org.jfree.data.time.TimePeriodValuesCollection;
-import org.jfree.data.time.TimeSeries;
-import org.jfree.data.time.TimeSeriesCollection;
-import org.jfree.util.ShapeUtilities;
-
-import java.awt.Color;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Scanner;
-import java.util.regex.Pattern;
-
-public class DisplaySync extends SyncCommon {
-
- // Information to graph for each authority
- private TimePeriodValues mDatasetsSync[];
- private List<String> mTooltipsSync[];
- private CustomXYToolTipGenerator mTooltipGenerators[];
- private TimeSeries mDatasetsSyncTickle[];
-
- // Dataset of error events to graph
- private TimeSeries mDatasetError;
-
- public DisplaySync(String name) {
- super(name);
- }
-
- /**
- * Creates the UI for the event display.
- * @param parent the parent composite.
- * @param logParser the current log parser.
- * @return the created control (which may have children).
- */
- @Override
- public Control createComposite(final Composite parent, EventLogParser logParser,
- final ILogColumnListener listener) {
- Control composite = createCompositeChart(parent, logParser, "Sync Status");
- resetUI();
- return composite;
- }
-
- /**
- * Resets the display.
- */
- @Override
- void resetUI() {
- super.resetUI();
- XYPlot xyPlot = mChart.getXYPlot();
-
- XYBarRenderer br = new XYBarRenderer();
- mDatasetsSync = new TimePeriodValues[NUM_AUTHS];
-
- @SuppressWarnings("unchecked")
- List<String> mTooltipsSyncTmp[] = new List[NUM_AUTHS];
- mTooltipsSync = mTooltipsSyncTmp;
-
- mTooltipGenerators = new CustomXYToolTipGenerator[NUM_AUTHS];
-
- TimePeriodValuesCollection tpvc = new TimePeriodValuesCollection();
- xyPlot.setDataset(tpvc);
- xyPlot.setRenderer(0, br);
-
- XYLineAndShapeRenderer ls = new XYLineAndShapeRenderer();
- ls.setBaseLinesVisible(false);
- mDatasetsSyncTickle = new TimeSeries[NUM_AUTHS];
- TimeSeriesCollection tsc = new TimeSeriesCollection();
- xyPlot.setDataset(1, tsc);
- xyPlot.setRenderer(1, ls);
-
- mDatasetError = new TimeSeries("Errors", FixedMillisecond.class);
- xyPlot.setDataset(2, new TimeSeriesCollection(mDatasetError));
- XYLineAndShapeRenderer errls = new XYLineAndShapeRenderer();
- errls.setBaseLinesVisible(false);
- errls.setSeriesPaint(0, Color.RED);
- xyPlot.setRenderer(2, errls);
-
- for (int i = 0; i < NUM_AUTHS; i++) {
- br.setSeriesPaint(i, AUTH_COLORS[i]);
- ls.setSeriesPaint(i, AUTH_COLORS[i]);
- mDatasetsSync[i] = new TimePeriodValues(AUTH_NAMES[i]);
- tpvc.addSeries(mDatasetsSync[i]);
- mTooltipsSync[i] = new ArrayList<String>();
- mTooltipGenerators[i] = new CustomXYToolTipGenerator();
- br.setSeriesToolTipGenerator(i, mTooltipGenerators[i]);
- mTooltipGenerators[i].addToolTipSeries(mTooltipsSync[i]);
-
- mDatasetsSyncTickle[i] = new TimeSeries(AUTH_NAMES[i] + " tickle",
- FixedMillisecond.class);
- tsc.addSeries(mDatasetsSyncTickle[i]);
- ls.setSeriesShape(i, ShapeUtilities.createUpTriangle(2.5f));
- }
- }
-
- /**
- * Updates the display with a new event.
- *
- * @param event The event
- * @param logParser The parser providing the event.
- */
- @Override
- void newEvent(EventContainer event, EventLogParser logParser) {
- super.newEvent(event, logParser); // Handle sync operation
- try {
- if (event.mTag == EVENT_TICKLE) {
- int auth = getAuth(event.getValueAsString(0));
- if (auth >= 0) {
- long msec = event.sec * 1000L + (event.nsec / 1000000L);
- mDatasetsSyncTickle[auth].addOrUpdate(new FixedMillisecond(msec), -1);
- }
- }
- } catch (InvalidTypeException e) {
- }
- }
-
- /**
- * Generate the height for an event.
- * Height is somewhat arbitrarily the count of "things" that happened
- * during the sync.
- * When network traffic measurements are available, code should be modified
- * to use that instead.
- * @param details The details string associated with the event
- * @return The height in arbirary units (0-100)
- */
- private int getHeightFromDetails(String details) {
- if (details == null) {
- return 1; // Arbitrary
- }
- int total = 0;
- String parts[] = details.split("[a-zA-Z]");
- for (String part : parts) {
- if ("".equals(part)) continue;
- total += Integer.parseInt(part);
- }
- if (total == 0) {
- total = 1;
- }
- return total;
- }
-
- /**
- * Generates the tooltips text for an event.
- * This method decodes the cryptic details string.
- * @param auth The authority associated with the event
- * @param details The details string
- * @param eventSource server, poll, etc.
- * @return The text to display in the tooltips
- */
- private String getTextFromDetails(int auth, String details, int eventSource) {
-
- StringBuffer sb = new StringBuffer();
- sb.append(AUTH_NAMES[auth]).append(": \n");
-
- Scanner scanner = new Scanner(details);
- Pattern charPat = Pattern.compile("[a-zA-Z]");
- Pattern numPat = Pattern.compile("[0-9]+");
- while (scanner.hasNext()) {
- String key = scanner.findInLine(charPat);
- int val = Integer.parseInt(scanner.findInLine(numPat));
- if (auth == GMAIL && "M".equals(key)) {
- sb.append("messages from server: ").append(val).append("\n");
- } else if (auth == GMAIL && "L".equals(key)) {
- sb.append("labels from server: ").append(val).append("\n");
- } else if (auth == GMAIL && "C".equals(key)) {
- sb.append("check conversation requests from server: ").append(val).append("\n");
- } else if (auth == GMAIL && "A".equals(key)) {
- sb.append("attachments from server: ").append(val).append("\n");
- } else if (auth == GMAIL && "U".equals(key)) {
- sb.append("op updates from server: ").append(val).append("\n");
- } else if (auth == GMAIL && "u".equals(key)) {
- sb.append("op updates to server: ").append(val).append("\n");
- } else if (auth == GMAIL && "S".equals(key)) {
- sb.append("send/receive cycles: ").append(val).append("\n");
- } else if ("Q".equals(key)) {
- sb.append("queries to server: ").append(val).append("\n");
- } else if ("E".equals(key)) {
- sb.append("entries from server: ").append(val).append("\n");
- } else if ("u".equals(key)) {
- sb.append("updates from client: ").append(val).append("\n");
- } else if ("i".equals(key)) {
- sb.append("inserts from client: ").append(val).append("\n");
- } else if ("d".equals(key)) {
- sb.append("deletes from client: ").append(val).append("\n");
- } else if ("f".equals(key)) {
- sb.append("full sync requested\n");
- } else if ("r".equals(key)) {
- sb.append("partial sync unavailable\n");
- } else if ("X".equals(key)) {
- sb.append("hard error\n");
- } else if ("e".equals(key)) {
- sb.append("number of parse exceptions: ").append(val).append("\n");
- } else if ("c".equals(key)) {
- sb.append("number of conflicts: ").append(val).append("\n");
- } else if ("a".equals(key)) {
- sb.append("number of auth exceptions: ").append(val).append("\n");
- } else if ("D".equals(key)) {
- sb.append("too many deletions\n");
- } else if ("R".equals(key)) {
- sb.append("too many retries: ").append(val).append("\n");
- } else if ("b".equals(key)) {
- sb.append("database error\n");
- } else if ("x".equals(key)) {
- sb.append("soft error\n");
- } else if ("l".equals(key)) {
- sb.append("sync already in progress\n");
- } else if ("I".equals(key)) {
- sb.append("io exception\n");
- } else if (auth == CONTACTS && "g".equals(key)) {
- sb.append("aggregation query: ").append(val).append("\n");
- } else if (auth == CONTACTS && "G".equals(key)) {
- sb.append("aggregation merge: ").append(val).append("\n");
- } else if (auth == CONTACTS && "n".equals(key)) {
- sb.append("num entries: ").append(val).append("\n");
- } else if (auth == CONTACTS && "p".equals(key)) {
- sb.append("photos uploaded from server: ").append(val).append("\n");
- } else if (auth == CONTACTS && "P".equals(key)) {
- sb.append("photos downloaded from server: ").append(val).append("\n");
- } else if (auth == CALENDAR && "F".equals(key)) {
- sb.append("server refresh\n");
- } else if (auth == CALENDAR && "s".equals(key)) {
- sb.append("server diffs fetched\n");
- } else {
- sb.append(key).append("=").append(val);
- }
- }
- if (eventSource == 0) {
- sb.append("(server)");
- } else if (eventSource == 1) {
- sb.append("(local)");
- } else if (eventSource == 2) {
- sb.append("(poll)");
- } else if (eventSource == 3) {
- sb.append("(user)");
- }
- return sb.toString();
- }
-
-
- /**
- * Callback to process a sync event.
- */
- @Override
- void processSyncEvent(EventContainer event, int auth, long startTime, long stopTime,
- String details, boolean newEvent, int syncSource) {
- if (!newEvent) {
- // Details arrived for a previous sync event
- // Remove event before reinserting.
- int lastItem = mDatasetsSync[auth].getItemCount();
- mDatasetsSync[auth].delete(lastItem-1, lastItem-1);
- mTooltipsSync[auth].remove(lastItem-1);
- }
- double height = getHeightFromDetails(details);
- height = height / (stopTime - startTime + 1) * 10000;
- if (height > 30) {
- height = 30;
- }
- mDatasetsSync[auth].add(new SimpleTimePeriod(startTime, stopTime), height);
- mTooltipsSync[auth].add(getTextFromDetails(auth, details, syncSource));
- mTooltipGenerators[auth].addToolTipSeries(mTooltipsSync[auth]);
- if (details.indexOf('x') >= 0 || details.indexOf('X') >= 0) {
- long msec = event.sec * 1000L + (event.nsec / 1000000L);
- mDatasetError.addOrUpdate(new FixedMillisecond(msec), -1);
- }
- }
-
- /**
- * Gets display type
- *
- * @return display type as an integer
- */
- @Override
- int getDisplayType() {
- return DISPLAY_TYPE_SYNC;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplaySyncHistogram.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplaySyncHistogram.java
deleted file mode 100644
index 5bfc039..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplaySyncHistogram.java
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.log.event;
-
-import com.android.ddmlib.log.EventContainer;
-import com.android.ddmlib.log.EventLogParser;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.jfree.chart.plot.XYPlot;
-import org.jfree.chart.renderer.xy.AbstractXYItemRenderer;
-import org.jfree.chart.renderer.xy.XYBarRenderer;
-import org.jfree.data.time.RegularTimePeriod;
-import org.jfree.data.time.SimpleTimePeriod;
-import org.jfree.data.time.TimePeriodValues;
-import org.jfree.data.time.TimePeriodValuesCollection;
-
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.TimeZone;
-
-public class DisplaySyncHistogram extends SyncCommon {
-
- Map<SimpleTimePeriod, Integer> mTimePeriodMap[];
-
- // Information to graph for each authority
- private TimePeriodValues mDatasetsSyncHist[];
-
- public DisplaySyncHistogram(String name) {
- super(name);
- }
-
- /**
- * Creates the UI for the event display.
- * @param parent the parent composite.
- * @param logParser the current log parser.
- * @return the created control (which may have children).
- */
- @Override
- public Control createComposite(final Composite parent, EventLogParser logParser,
- final ILogColumnListener listener) {
- Control composite = createCompositeChart(parent, logParser, "Sync Histogram");
- resetUI();
- return composite;
- }
-
- /**
- * Resets the display.
- */
- @Override
- void resetUI() {
- super.resetUI();
- XYPlot xyPlot = mChart.getXYPlot();
-
- AbstractXYItemRenderer br = new XYBarRenderer();
- mDatasetsSyncHist = new TimePeriodValues[NUM_AUTHS+1];
-
- @SuppressWarnings("unchecked")
- Map<SimpleTimePeriod, Integer> mTimePeriodMapTmp[] = new HashMap[NUM_AUTHS + 1];
- mTimePeriodMap = mTimePeriodMapTmp;
-
- TimePeriodValuesCollection tpvc = new TimePeriodValuesCollection();
- xyPlot.setDataset(tpvc);
- xyPlot.setRenderer(br);
-
- for (int i = 0; i < NUM_AUTHS + 1; i++) {
- br.setSeriesPaint(i, AUTH_COLORS[i]);
- mDatasetsSyncHist[i] = new TimePeriodValues(AUTH_NAMES[i]);
- tpvc.addSeries(mDatasetsSyncHist[i]);
- mTimePeriodMap[i] = new HashMap<SimpleTimePeriod, Integer>();
-
- }
- }
-
- /**
- * Callback to process a sync event.
- *
- * @param event The sync event
- * @param startTime Start time (ms) of events
- * @param stopTime Stop time (ms) of events
- * @param details Details associated with the event.
- * @param newEvent True if this event is a new sync event. False if this event
- * @param syncSource
- */
- @Override
- void processSyncEvent(EventContainer event, int auth, long startTime, long stopTime,
- String details, boolean newEvent, int syncSource) {
- if (newEvent) {
- if (details.indexOf('x') >= 0 || details.indexOf('X') >= 0) {
- auth = ERRORS;
- }
- double delta = (stopTime - startTime) * 100. / 1000 / 3600; // Percent of hour
- addHistEvent(0, auth, delta);
- } else {
- // sync_details arrived for an event that has already been graphed.
- if (details.indexOf('x') >= 0 || details.indexOf('X') >= 0) {
- // Item turns out to be in error, so transfer time from old auth to error.
- double delta = (stopTime - startTime) * 100. / 1000 / 3600; // Percent of hour
- addHistEvent(0, auth, -delta);
- addHistEvent(0, ERRORS, delta);
- }
- }
- }
-
- /**
- * Helper to add an event to the data series.
- * Also updates error series if appropriate (x or X in details).
- * @param stopTime Time event ends
- * @param auth Sync authority
- * @param value Value to graph for event
- */
- private void addHistEvent(long stopTime, int auth, double value) {
- SimpleTimePeriod hour = getTimePeriod(stopTime, mHistWidth);
-
- // Loop over all datasets to do the stacking.
- for (int i = auth; i <= ERRORS; i++) {
- addToPeriod(mDatasetsSyncHist, i, hour, value);
- }
- }
-
- private void addToPeriod(TimePeriodValues tpv[], int auth, SimpleTimePeriod period,
- double value) {
- int index;
- if (mTimePeriodMap[auth].containsKey(period)) {
- index = mTimePeriodMap[auth].get(period);
- double oldValue = tpv[auth].getValue(index).doubleValue();
- tpv[auth].update(index, oldValue + value);
- } else {
- index = tpv[auth].getItemCount();
- mTimePeriodMap[auth].put(period, index);
- tpv[auth].add(period, value);
- }
- }
-
- /**
- * Creates a multiple-hour time period for the histogram.
- * @param time Time in milliseconds.
- * @param numHoursWide: should divide into a day.
- * @return SimpleTimePeriod covering the number of hours and containing time.
- */
- private SimpleTimePeriod getTimePeriod(long time, long numHoursWide) {
- Date date = new Date(time);
- TimeZone zone = RegularTimePeriod.DEFAULT_TIME_ZONE;
- Calendar calendar = Calendar.getInstance(zone);
- calendar.setTime(date);
- long hoursOfYear = calendar.get(Calendar.HOUR_OF_DAY) +
- calendar.get(Calendar.DAY_OF_YEAR) * 24;
- int year = calendar.get(Calendar.YEAR);
- hoursOfYear = (hoursOfYear / numHoursWide) * numHoursWide;
- calendar.clear();
- calendar.set(year, 0, 1, 0, 0); // Jan 1
- long start = calendar.getTimeInMillis() + hoursOfYear * 3600 * 1000;
- return new SimpleTimePeriod(start, start + numHoursWide * 3600 * 1000);
- }
-
- /**
- * Gets display type
- *
- * @return display type as an integer
- */
- @Override
- int getDisplayType() {
- return DISPLAY_TYPE_SYNC_HIST;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplaySyncPerf.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplaySyncPerf.java
deleted file mode 100644
index 10176e3..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/DisplaySyncPerf.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.log.event;
-
-import com.android.ddmlib.log.EventContainer;
-import com.android.ddmlib.log.EventLogParser;
-import com.android.ddmlib.log.InvalidTypeException;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.jfree.chart.labels.CustomXYToolTipGenerator;
-import org.jfree.chart.plot.XYPlot;
-import org.jfree.chart.renderer.xy.XYBarRenderer;
-import org.jfree.data.time.SimpleTimePeriod;
-import org.jfree.data.time.TimePeriodValues;
-import org.jfree.data.time.TimePeriodValuesCollection;
-
-import java.awt.Color;
-import java.util.ArrayList;
-import java.util.List;
-
-public class DisplaySyncPerf extends SyncCommon {
-
- CustomXYToolTipGenerator mTooltipGenerator;
-
- List<String> mTooltips[];
-
- // The series number for each graphed item.
- // sync authorities are 0-3
- private static final int DB_QUERY = 4;
- private static final int DB_WRITE = 5;
- private static final int HTTP_NETWORK = 6;
- private static final int HTTP_PROCESSING = 7;
- private static final int NUM_SERIES = (HTTP_PROCESSING + 1);
- private static final String SERIES_NAMES[] = {"Calendar", "Gmail", "Feeds", "Contacts",
- "DB Query", "DB Write", "HTTP Response", "HTTP Processing",};
- private static final Color SERIES_COLORS[] = {Color.MAGENTA, Color.GREEN, Color.BLUE,
- Color.ORANGE, Color.RED, Color.CYAN, Color.PINK, Color.DARK_GRAY};
- private static final double SERIES_YCOORD[] = {0, 0, 0, 0, 1, 1, 2, 2};
-
- // Values from data/etc/event-log-tags
- private static final int EVENT_DB_OPERATION = 52000;
- private static final int EVENT_HTTP_STATS = 52001;
- // op types for EVENT_DB_OPERATION
- final int EVENT_DB_QUERY = 0;
- final int EVENT_DB_WRITE = 1;
-
- // Information to graph for each authority
- private TimePeriodValues mDatasets[];
-
- /**
- * TimePeriodValuesCollection that supports Y intervals. This allows the
- * creation of "floating" bars, rather than bars rooted to the axis.
- */
- class YIntervalTimePeriodValuesCollection extends TimePeriodValuesCollection {
- /** default serial UID */
- private static final long serialVersionUID = 1L;
-
- private double yheight;
-
- /**
- * Constructs a collection of bars with a fixed Y height.
- *
- * @param yheight The height of the bars.
- */
- YIntervalTimePeriodValuesCollection(double yheight) {
- this.yheight = yheight;
- }
-
- /**
- * Returns ending Y value that is a fixed amount greater than the starting value.
- *
- * @param series the series (zero-based index).
- * @param item the item (zero-based index).
- * @return The ending Y value for the specified series and item.
- */
- @Override
- public Number getEndY(int series, int item) {
- return getY(series, item).doubleValue() + yheight;
- }
- }
-
- /**
- * Constructs a graph of network and database stats.
- *
- * @param name The name of this graph in the graph list.
- */
- public DisplaySyncPerf(String name) {
- super(name);
- }
-
- /**
- * Creates the UI for the event display.
- *
- * @param parent the parent composite.
- * @param logParser the current log parser.
- * @return the created control (which may have children).
- */
- @Override
- public Control createComposite(final Composite parent, EventLogParser logParser,
- final ILogColumnListener listener) {
- Control composite = createCompositeChart(parent, logParser, "Sync Performance");
- resetUI();
- return composite;
- }
-
- /**
- * Resets the display.
- */
- @Override
- void resetUI() {
- super.resetUI();
- XYPlot xyPlot = mChart.getXYPlot();
- xyPlot.getRangeAxis().setVisible(false);
- mTooltipGenerator = new CustomXYToolTipGenerator();
-
- @SuppressWarnings("unchecked")
- List<String>[] mTooltipsTmp = new List[NUM_SERIES];
- mTooltips = mTooltipsTmp;
-
- XYBarRenderer br = new XYBarRenderer();
- br.setUseYInterval(true);
- mDatasets = new TimePeriodValues[NUM_SERIES];
-
- TimePeriodValuesCollection tpvc = new YIntervalTimePeriodValuesCollection(1);
- xyPlot.setDataset(tpvc);
- xyPlot.setRenderer(br);
-
- for (int i = 0; i < NUM_SERIES; i++) {
- br.setSeriesPaint(i, SERIES_COLORS[i]);
- mDatasets[i] = new TimePeriodValues(SERIES_NAMES[i]);
- tpvc.addSeries(mDatasets[i]);
- mTooltips[i] = new ArrayList<String>();
- mTooltipGenerator.addToolTipSeries(mTooltips[i]);
- br.setSeriesToolTipGenerator(i, mTooltipGenerator);
- }
- }
-
- /**
- * Updates the display with a new event.
- *
- * @param event The event
- * @param logParser The parser providing the event.
- */
- @Override
- void newEvent(EventContainer event, EventLogParser logParser) {
- super.newEvent(event, logParser); // Handle sync operation
- try {
- if (event.mTag == EVENT_DB_OPERATION) {
- // 52000 db_operation (name|3),(op_type|1|5),(time|2|3)
- String tip = event.getValueAsString(0);
- long endTime = event.sec * 1000L + (event.nsec / 1000000L);
- int opType = Integer.parseInt(event.getValueAsString(1));
- long duration = Long.parseLong(event.getValueAsString(2));
-
- if (opType == EVENT_DB_QUERY) {
- mDatasets[DB_QUERY].add(new SimpleTimePeriod(endTime - duration, endTime),
- SERIES_YCOORD[DB_QUERY]);
- mTooltips[DB_QUERY].add(tip);
- } else if (opType == EVENT_DB_WRITE) {
- mDatasets[DB_WRITE].add(new SimpleTimePeriod(endTime - duration, endTime),
- SERIES_YCOORD[DB_WRITE]);
- mTooltips[DB_WRITE].add(tip);
- }
- } else if (event.mTag == EVENT_HTTP_STATS) {
- // 52001 http_stats (useragent|3),(response|2|3),(processing|2|3),(tx|1|2),(rx|1|2)
- String tip = event.getValueAsString(0) + ", tx:" + event.getValueAsString(3) +
- ", rx: " + event.getValueAsString(4);
- long endTime = event.sec * 1000L + (event.nsec / 1000000L);
- long netEndTime = endTime - Long.parseLong(event.getValueAsString(2));
- long netStartTime = netEndTime - Long.parseLong(event.getValueAsString(1));
- mDatasets[HTTP_NETWORK].add(new SimpleTimePeriod(netStartTime, netEndTime),
- SERIES_YCOORD[HTTP_NETWORK]);
- mDatasets[HTTP_PROCESSING].add(new SimpleTimePeriod(netEndTime, endTime),
- SERIES_YCOORD[HTTP_PROCESSING]);
- mTooltips[HTTP_NETWORK].add(tip);
- mTooltips[HTTP_PROCESSING].add(tip);
- }
- } catch (NumberFormatException e) {
- // This can happen when parsing events from froyo+ where the event with id 52000
- // as a completely different format. For now, skip this event if this happens.
- } catch (InvalidTypeException e) {
- }
- }
-
- /**
- * Callback from super.newEvent to process a sync event.
- *
- * @param event The sync event
- * @param startTime Start time (ms) of events
- * @param stopTime Stop time (ms) of events
- * @param details Details associated with the event.
- * @param newEvent True if this event is a new sync event. False if this event
- * @param syncSource
- */
- @Override
- void processSyncEvent(EventContainer event, int auth, long startTime, long stopTime,
- String details, boolean newEvent, int syncSource) {
- if (newEvent) {
- mDatasets[auth].add(new SimpleTimePeriod(startTime, stopTime), SERIES_YCOORD[auth]);
- }
- }
-
- /**
- * Gets display type
- *
- * @return display type as an integer
- */
- @Override
- int getDisplayType() {
- return DISPLAY_TYPE_SYNC_PERF;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventDisplay.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventDisplay.java
deleted file mode 100644
index d0d2789..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventDisplay.java
+++ /dev/null
@@ -1,975 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.log.event;
-
-import com.android.ddmlib.Log;
-import com.android.ddmlib.log.EventContainer;
-import com.android.ddmlib.log.EventContainer.CompareMethod;
-import com.android.ddmlib.log.EventContainer.EventValueType;
-import com.android.ddmlib.log.EventLogParser;
-import com.android.ddmlib.log.EventValueDescription.ValueType;
-import com.android.ddmlib.log.InvalidTypeException;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.jfree.chart.ChartFactory;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.event.ChartChangeEvent;
-import org.jfree.chart.event.ChartChangeEventType;
-import org.jfree.chart.event.ChartChangeListener;
-import org.jfree.chart.plot.XYPlot;
-import org.jfree.chart.title.TextTitle;
-import org.jfree.data.time.Millisecond;
-import org.jfree.data.time.TimeSeries;
-import org.jfree.data.time.TimeSeriesCollection;
-import org.jfree.experimental.chart.swt.ChartComposite;
-import org.jfree.experimental.swt.SWTUtils;
-
-import java.security.InvalidParameterException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-/**
- * Represents a custom display of one or more events.
- */
-abstract class EventDisplay {
-
- private final static String DISPLAY_DATA_STORAGE_SEPARATOR = ":"; //$NON-NLS-1$
- private final static String PID_STORAGE_SEPARATOR = ","; //$NON-NLS-1$
- private final static String DESCRIPTOR_STORAGE_SEPARATOR = "$"; //$NON-NLS-1$
- private final static String DESCRIPTOR_DATA_STORAGE_SEPARATOR = "!"; //$NON-NLS-1$
-
- private final static String FILTER_VALUE_NULL = "<null>"; //$NON-NLS-1$
-
- public final static int DISPLAY_TYPE_LOG_ALL = 0;
- public final static int DISPLAY_TYPE_FILTERED_LOG = 1;
- public final static int DISPLAY_TYPE_GRAPH = 2;
- public final static int DISPLAY_TYPE_SYNC = 3;
- public final static int DISPLAY_TYPE_SYNC_HIST = 4;
- public final static int DISPLAY_TYPE_SYNC_PERF = 5;
-
- private final static int EVENT_CHECK_FAILED = 0;
- protected final static int EVENT_CHECK_SAME_TAG = 1;
- protected final static int EVENT_CHECK_SAME_VALUE = 2;
-
- /**
- * Creates the appropriate EventDisplay subclass.
- *
- * @param type the type of display (DISPLAY_TYPE_LOG_ALL, etc)
- * @param name the name of the display
- * @return the created object
- */
- public static EventDisplay eventDisplayFactory(int type, String name) {
- switch (type) {
- case DISPLAY_TYPE_LOG_ALL:
- return new DisplayLog(name);
- case DISPLAY_TYPE_FILTERED_LOG:
- return new DisplayFilteredLog(name);
- case DISPLAY_TYPE_SYNC:
- return new DisplaySync(name);
- case DISPLAY_TYPE_SYNC_HIST:
- return new DisplaySyncHistogram(name);
- case DISPLAY_TYPE_GRAPH:
- return new DisplayGraph(name);
- case DISPLAY_TYPE_SYNC_PERF:
- return new DisplaySyncPerf(name);
- default:
- throw new InvalidParameterException("Unknown Display Type " + type); //$NON-NLS-1$
- }
- }
-
- /**
- * Adds event to the display.
- * @param event The event
- * @param logParser The log parser.
- */
- abstract void newEvent(EventContainer event, EventLogParser logParser);
-
- /**
- * Resets the display.
- */
- abstract void resetUI();
-
- /**
- * Gets display type
- *
- * @return display type as an integer
- */
- abstract int getDisplayType();
-
- /**
- * Creates the UI for the event display.
- *
- * @param parent the parent composite.
- * @param logParser the current log parser.
- * @return the created control (which may have children).
- */
- abstract Control createComposite(final Composite parent, EventLogParser logParser,
- final ILogColumnListener listener);
-
- interface ILogColumnListener {
- void columnResized(int index, TableColumn sourceColumn);
- }
-
- /**
- * Describes an event to be displayed.
- */
- static class OccurrenceDisplayDescriptor {
-
- int eventTag = -1;
- int seriesValueIndex = -1;
- boolean includePid = false;
- int filterValueIndex = -1;
- CompareMethod filterCompareMethod = CompareMethod.EQUAL_TO;
- Object filterValue = null;
-
- OccurrenceDisplayDescriptor() {
- }
-
- OccurrenceDisplayDescriptor(OccurrenceDisplayDescriptor descriptor) {
- replaceWith(descriptor);
- }
-
- OccurrenceDisplayDescriptor(int eventTag) {
- this.eventTag = eventTag;
- }
-
- OccurrenceDisplayDescriptor(int eventTag, int seriesValueIndex) {
- this.eventTag = eventTag;
- this.seriesValueIndex = seriesValueIndex;
- }
-
- void replaceWith(OccurrenceDisplayDescriptor descriptor) {
- eventTag = descriptor.eventTag;
- seriesValueIndex = descriptor.seriesValueIndex;
- includePid = descriptor.includePid;
- filterValueIndex = descriptor.filterValueIndex;
- filterCompareMethod = descriptor.filterCompareMethod;
- filterValue = descriptor.filterValue;
- }
-
- /**
- * Loads the descriptor parameter from a storage string. The storage string must have
- * been generated with {@link #getStorageString()}.
- *
- * @param storageString the storage string
- */
- final void loadFrom(String storageString) {
- String[] values = storageString.split(Pattern.quote(DESCRIPTOR_DATA_STORAGE_SEPARATOR));
- loadFrom(values, 0);
- }
-
- /**
- * Loads the parameters from an array of strings.
- *
- * @param storageStrings the strings representing each parameter.
- * @param index the starting index in the array of strings.
- * @return the new index in the array.
- */
- protected int loadFrom(String[] storageStrings, int index) {
- eventTag = Integer.parseInt(storageStrings[index++]);
- seriesValueIndex = Integer.parseInt(storageStrings[index++]);
- includePid = Boolean.parseBoolean(storageStrings[index++]);
- filterValueIndex = Integer.parseInt(storageStrings[index++]);
- try {
- filterCompareMethod = CompareMethod.valueOf(storageStrings[index++]);
- } catch (IllegalArgumentException e) {
- // if the name does not match any known CompareMethod, we init it to the default one
- filterCompareMethod = CompareMethod.EQUAL_TO;
- }
- String value = storageStrings[index++];
- if (filterValueIndex != -1 && FILTER_VALUE_NULL.equals(value) == false) {
- filterValue = EventValueType.getObjectFromStorageString(value);
- }
-
- return index;
- }
-
- /**
- * Returns the storage string for the receiver.
- */
- String getStorageString() {
- StringBuilder sb = new StringBuilder();
- sb.append(eventTag);
- sb.append(DESCRIPTOR_DATA_STORAGE_SEPARATOR);
- sb.append(seriesValueIndex);
- sb.append(DESCRIPTOR_DATA_STORAGE_SEPARATOR);
- sb.append(Boolean.toString(includePid));
- sb.append(DESCRIPTOR_DATA_STORAGE_SEPARATOR);
- sb.append(filterValueIndex);
- sb.append(DESCRIPTOR_DATA_STORAGE_SEPARATOR);
- sb.append(filterCompareMethod.name());
- sb.append(DESCRIPTOR_DATA_STORAGE_SEPARATOR);
- if (filterValue != null) {
- String value = EventValueType.getStorageString(filterValue);
- if (value != null) {
- sb.append(value);
- } else {
- sb.append(FILTER_VALUE_NULL);
- }
- } else {
- sb.append(FILTER_VALUE_NULL);
- }
-
- return sb.toString();
- }
- }
-
- /**
- * Describes an event value to be displayed.
- */
- static final class ValueDisplayDescriptor extends OccurrenceDisplayDescriptor {
- String valueName;
- int valueIndex = -1;
-
- ValueDisplayDescriptor() {
- super();
- }
-
- ValueDisplayDescriptor(ValueDisplayDescriptor descriptor) {
- super();
- replaceWith(descriptor);
- }
-
- ValueDisplayDescriptor(int eventTag, String valueName, int valueIndex) {
- super(eventTag);
- this.valueName = valueName;
- this.valueIndex = valueIndex;
- }
-
- ValueDisplayDescriptor(int eventTag, String valueName, int valueIndex,
- int seriesValueIndex) {
- super(eventTag, seriesValueIndex);
- this.valueName = valueName;
- this.valueIndex = valueIndex;
- }
-
- @Override
- void replaceWith(OccurrenceDisplayDescriptor descriptor) {
- super.replaceWith(descriptor);
- if (descriptor instanceof ValueDisplayDescriptor) {
- ValueDisplayDescriptor valueDescriptor = (ValueDisplayDescriptor) descriptor;
- valueName = valueDescriptor.valueName;
- valueIndex = valueDescriptor.valueIndex;
- }
- }
-
- /**
- * Loads the parameters from an array of strings.
- *
- * @param storageStrings the strings representing each parameter.
- * @param index the starting index in the array of strings.
- * @return the new index in the array.
- */
- @Override
- protected int loadFrom(String[] storageStrings, int index) {
- index = super.loadFrom(storageStrings, index);
- valueName = storageStrings[index++];
- valueIndex = Integer.parseInt(storageStrings[index++]);
- return index;
- }
-
- /**
- * Returns the storage string for the receiver.
- */
- @Override
- String getStorageString() {
- String superStorage = super.getStorageString();
-
- StringBuilder sb = new StringBuilder();
- sb.append(superStorage);
- sb.append(DESCRIPTOR_DATA_STORAGE_SEPARATOR);
- sb.append(valueName);
- sb.append(DESCRIPTOR_DATA_STORAGE_SEPARATOR);
- sb.append(valueIndex);
-
- return sb.toString();
- }
- }
-
- /* ==================
- * Event Display parameters.
- * ================== */
- protected String mName;
-
- private boolean mPidFiltering = false;
-
- private ArrayList<Integer> mPidFilterList = null;
-
- protected final ArrayList<ValueDisplayDescriptor> mValueDescriptors =
- new ArrayList<ValueDisplayDescriptor>();
- private final ArrayList<OccurrenceDisplayDescriptor> mOccurrenceDescriptors =
- new ArrayList<OccurrenceDisplayDescriptor>();
-
- /* ==================
- * Event Display members for display purpose.
- * ================== */
- // chart objects
- /**
- * This is a map of (descriptor, map2) where map2 is a map of (pid, chart-series)
- */
- protected final HashMap<ValueDisplayDescriptor, HashMap<Integer, TimeSeries>> mValueDescriptorSeriesMap =
- new HashMap<ValueDisplayDescriptor, HashMap<Integer, TimeSeries>>();
- /**
- * This is a map of (descriptor, map2) where map2 is a map of (pid, chart-series)
- */
- protected final HashMap<OccurrenceDisplayDescriptor, HashMap<Integer, TimeSeries>> mOcurrenceDescriptorSeriesMap =
- new HashMap<OccurrenceDisplayDescriptor, HashMap<Integer, TimeSeries>>();
-
- /**
- * This is a map of (ValueType, dataset)
- */
- protected final HashMap<ValueType, TimeSeriesCollection> mValueTypeDataSetMap =
- new HashMap<ValueType, TimeSeriesCollection>();
-
- protected JFreeChart mChart;
- protected TimeSeriesCollection mOccurrenceDataSet;
- protected int mDataSetCount;
- private ChartComposite mChartComposite;
- protected long mMaximumChartItemAge = -1;
- protected long mHistWidth = 1;
-
- // log objects.
- protected Table mLogTable;
-
- /* ==================
- * Misc data.
- * ================== */
- protected int mValueDescriptorCheck = EVENT_CHECK_FAILED;
-
- EventDisplay(String name) {
- mName = name;
- }
-
- static EventDisplay clone(EventDisplay from) {
- EventDisplay ed = eventDisplayFactory(from.getDisplayType(), from.getName());
- ed.mName = from.mName;
- ed.mPidFiltering = from.mPidFiltering;
- ed.mMaximumChartItemAge = from.mMaximumChartItemAge;
- ed.mHistWidth = from.mHistWidth;
-
- if (from.mPidFilterList != null) {
- ed.mPidFilterList = new ArrayList<Integer>();
- ed.mPidFilterList.addAll(from.mPidFilterList);
- }
-
- for (ValueDisplayDescriptor desc : from.mValueDescriptors) {
- ed.mValueDescriptors.add(new ValueDisplayDescriptor(desc));
- }
- ed.mValueDescriptorCheck = from.mValueDescriptorCheck;
-
- for (OccurrenceDisplayDescriptor desc : from.mOccurrenceDescriptors) {
- ed.mOccurrenceDescriptors.add(new OccurrenceDisplayDescriptor(desc));
- }
- return ed;
- }
-
- /**
- * Returns the parameters of the receiver as a single String for storage.
- */
- String getStorageString() {
- StringBuilder sb = new StringBuilder();
-
- sb.append(mName);
- sb.append(DISPLAY_DATA_STORAGE_SEPARATOR);
- sb.append(getDisplayType());
- sb.append(DISPLAY_DATA_STORAGE_SEPARATOR);
- sb.append(Boolean.toString(mPidFiltering));
- sb.append(DISPLAY_DATA_STORAGE_SEPARATOR);
- sb.append(getPidStorageString());
- sb.append(DISPLAY_DATA_STORAGE_SEPARATOR);
- sb.append(getDescriptorStorageString(mValueDescriptors));
- sb.append(DISPLAY_DATA_STORAGE_SEPARATOR);
- sb.append(getDescriptorStorageString(mOccurrenceDescriptors));
- sb.append(DISPLAY_DATA_STORAGE_SEPARATOR);
- sb.append(mMaximumChartItemAge);
- sb.append(DISPLAY_DATA_STORAGE_SEPARATOR);
- sb.append(mHistWidth);
- sb.append(DISPLAY_DATA_STORAGE_SEPARATOR);
-
- return sb.toString();
- }
-
- void setName(String name) {
- mName = name;
- }
-
- String getName() {
- return mName;
- }
-
- void setPidFiltering(boolean filterByPid) {
- mPidFiltering = filterByPid;
- }
-
- boolean getPidFiltering() {
- return mPidFiltering;
- }
-
- void setPidFilterList(ArrayList<Integer> pids) {
- if (mPidFiltering == false) {
- throw new InvalidParameterException();
- }
-
- mPidFilterList = pids;
- }
-
- ArrayList<Integer> getPidFilterList() {
- return mPidFilterList;
- }
-
- void addPidFiler(int pid) {
- if (mPidFiltering == false) {
- throw new InvalidParameterException();
- }
-
- if (mPidFilterList == null) {
- mPidFilterList = new ArrayList<Integer>();
- }
-
- mPidFilterList.add(pid);
- }
-
- /**
- * Returns an iterator to the list of {@link ValueDisplayDescriptor}.
- */
- Iterator<ValueDisplayDescriptor> getValueDescriptors() {
- return mValueDescriptors.iterator();
- }
-
- /**
- * Update checks on the descriptors. Must be called whenever a descriptor is modified outside
- * of this class.
- */
- void updateValueDescriptorCheck() {
- mValueDescriptorCheck = checkDescriptors();
- }
-
- /**
- * Returns an iterator to the list of {@link OccurrenceDisplayDescriptor}.
- */
- Iterator<OccurrenceDisplayDescriptor> getOccurrenceDescriptors() {
- return mOccurrenceDescriptors.iterator();
- }
-
- /**
- * Adds a descriptor. This can be a {@link OccurrenceDisplayDescriptor} or a
- * {@link ValueDisplayDescriptor}.
- *
- * @param descriptor the descriptor to be added.
- */
- void addDescriptor(OccurrenceDisplayDescriptor descriptor) {
- if (descriptor instanceof ValueDisplayDescriptor) {
- mValueDescriptors.add((ValueDisplayDescriptor) descriptor);
- mValueDescriptorCheck = checkDescriptors();
- } else {
- mOccurrenceDescriptors.add(descriptor);
- }
- }
-
- /**
- * Returns a descriptor by index and class (extending {@link OccurrenceDisplayDescriptor}).
- *
- * @param descriptorClass the class of the descriptor to return.
- * @param index the index of the descriptor to return.
- * @return either a {@link OccurrenceDisplayDescriptor} or a {@link ValueDisplayDescriptor}
- * or <code>null</code> if <code>descriptorClass</code> is another class.
- */
- OccurrenceDisplayDescriptor getDescriptor(
- Class<? extends OccurrenceDisplayDescriptor> descriptorClass, int index) {
-
- if (descriptorClass == OccurrenceDisplayDescriptor.class) {
- return mOccurrenceDescriptors.get(index);
- } else if (descriptorClass == ValueDisplayDescriptor.class) {
- return mValueDescriptors.get(index);
- }
-
- return null;
- }
-
- /**
- * Removes a descriptor based on its class and index.
- *
- * @param descriptorClass the class of the descriptor.
- * @param index the index of the descriptor to be removed.
- */
- void removeDescriptor(Class<? extends OccurrenceDisplayDescriptor> descriptorClass, int index) {
- if (descriptorClass == OccurrenceDisplayDescriptor.class) {
- mOccurrenceDescriptors.remove(index);
- } else if (descriptorClass == ValueDisplayDescriptor.class) {
- mValueDescriptors.remove(index);
- mValueDescriptorCheck = checkDescriptors();
- }
- }
-
- Control createCompositeChart(final Composite parent, EventLogParser logParser,
- String title) {
- mChart = ChartFactory.createTimeSeriesChart(
- null,
- null /* timeAxisLabel */,
- null /* valueAxisLabel */,
- null, /* dataset. set below */
- true /* legend */,
- false /* tooltips */,
- false /* urls */);
-
- // get the font to make a proper title. We need to convert the swt font,
- // into an awt font.
- Font f = parent.getFont();
- FontData[] fData = f.getFontData();
-
- // event though on Mac OS there could be more than one fontData, we'll only use
- // the first one.
- FontData firstFontData = fData[0];
-
- java.awt.Font awtFont = SWTUtils.toAwtFont(parent.getDisplay(),
- firstFontData, true /* ensureSameSize */);
-
-
- mChart.setTitle(new TextTitle(title, awtFont));
-
- final XYPlot xyPlot = mChart.getXYPlot();
- xyPlot.setRangeCrosshairVisible(true);
- xyPlot.setRangeCrosshairLockedOnData(true);
- xyPlot.setDomainCrosshairVisible(true);
- xyPlot.setDomainCrosshairLockedOnData(true);
-
- mChart.addChangeListener(new ChartChangeListener() {
- @Override
- public void chartChanged(ChartChangeEvent event) {
- ChartChangeEventType type = event.getType();
- if (type == ChartChangeEventType.GENERAL) {
- // because the value we need (rangeCrosshair and domainCrosshair) are
- // updated on the draw, but the notification happens before the draw,
- // we process the click in a future runnable!
- parent.getDisplay().asyncExec(new Runnable() {
- @Override
- public void run() {
- processClick(xyPlot);
- }
- });
- }
- }
- });
-
- mChartComposite = new ChartComposite(parent, SWT.BORDER, mChart,
- ChartComposite.DEFAULT_WIDTH,
- ChartComposite.DEFAULT_HEIGHT,
- ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH,
- ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT,
- 3000, // max draw width. We don't want it to zoom, so we put a big number
- 3000, // max draw height. We don't want it to zoom, so we put a big number
- true, // off-screen buffer
- true, // properties
- true, // save
- true, // print
- true, // zoom
- true); // tooltips
-
- mChartComposite.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- mValueTypeDataSetMap.clear();
- mDataSetCount = 0;
- mOccurrenceDataSet = null;
- mChart = null;
- mChartComposite = null;
- mValueDescriptorSeriesMap.clear();
- mOcurrenceDescriptorSeriesMap.clear();
- }
- });
-
- return mChartComposite;
-
- }
-
- private void processClick(XYPlot xyPlot) {
- double rangeValue = xyPlot.getRangeCrosshairValue();
- if (rangeValue != 0) {
- double domainValue = xyPlot.getDomainCrosshairValue();
-
- Millisecond msec = new Millisecond(new Date((long) domainValue));
-
- // look for values in the dataset that contains data at this TimePeriod
- Set<ValueDisplayDescriptor> descKeys = mValueDescriptorSeriesMap.keySet();
-
- for (ValueDisplayDescriptor descKey : descKeys) {
- HashMap<Integer, TimeSeries> map = mValueDescriptorSeriesMap.get(descKey);
-
- Set<Integer> pidKeys = map.keySet();
-
- for (Integer pidKey : pidKeys) {
- TimeSeries series = map.get(pidKey);
-
- Number value = series.getValue(msec);
- if (value != null) {
- // found a match. lets check against the actual value.
- if (value.doubleValue() == rangeValue) {
-
- return;
- }
- }
- }
- }
- }
- }
-
-
- /**
- * Resizes the <code>index</code>-th column of the log {@link Table} (if applicable).
- * Subclasses can override if necessary.
- * <p/>
- * This does nothing if the <code>Table</code> object is <code>null</code> (because the display
- * type does not use a column) or if the <code>index</code>-th column is in fact the originating
- * column passed as argument.
- *
- * @param index the index of the column to resize
- * @param sourceColumn the original column that was resize, and on which we need to sync the
- * index-th column width.
- */
- void resizeColumn(int index, TableColumn sourceColumn) {
- }
-
- /**
- * Sets the current {@link EventLogParser} object.
- * Subclasses can override if necessary.
- */
- protected void setNewLogParser(EventLogParser logParser) {
- }
-
- /**
- * Prepares the {@link EventDisplay} for a multi event display.
- */
- void startMultiEventDisplay() {
- if (mLogTable != null) {
- mLogTable.setRedraw(false);
- }
- }
-
- /**
- * Finalizes the {@link EventDisplay} after a multi event display.
- */
- void endMultiEventDisplay() {
- if (mLogTable != null) {
- mLogTable.setRedraw(true);
- }
- }
-
- /**
- * Returns the {@link Table} object used to display events, if any.
- *
- * @return a Table object or <code>null</code>.
- */
- Table getTable() {
- return mLogTable;
- }
-
- /**
- * Loads a new {@link EventDisplay} from a storage string. The string must have been created
- * with {@link #getStorageString()}.
- *
- * @param storageString the storage string
- * @return a new {@link EventDisplay} or null if the load failed.
- */
- static EventDisplay load(String storageString) {
- if (storageString.length() > 0) {
- // the storage string is separated by ':'
- String[] values = storageString.split(Pattern.quote(DISPLAY_DATA_STORAGE_SEPARATOR));
-
- try {
- int index = 0;
-
- String name = values[index++];
- int displayType = Integer.parseInt(values[index++]);
- boolean pidFiltering = Boolean.parseBoolean(values[index++]);
-
- EventDisplay ed = eventDisplayFactory(displayType, name);
- ed.setPidFiltering(pidFiltering);
-
- // because empty sections are removed by String.split(), we have to check
- // the index for those.
- if (index < values.length) {
- ed.loadPidFilters(values[index++]);
- }
-
- if (index < values.length) {
- ed.loadValueDescriptors(values[index++]);
- }
-
- if (index < values.length) {
- ed.loadOccurrenceDescriptors(values[index++]);
- }
-
- ed.updateValueDescriptorCheck();
-
- if (index < values.length) {
- ed.mMaximumChartItemAge = Long.parseLong(values[index++]);
- }
-
- if (index < values.length) {
- ed.mHistWidth = Long.parseLong(values[index++]);
- }
-
- return ed;
- } catch (RuntimeException re) {
- // we'll return null below.
- Log.e("ddms", re);
- }
- }
-
- return null;
- }
-
- private String getPidStorageString() {
- if (mPidFilterList != null) {
- StringBuilder sb = new StringBuilder();
- boolean first = true;
- for (Integer i : mPidFilterList) {
- if (first == false) {
- sb.append(PID_STORAGE_SEPARATOR);
- } else {
- first = false;
- }
- sb.append(i);
- }
-
- return sb.toString();
- }
- return ""; //$NON-NLS-1$
- }
-
-
- private void loadPidFilters(String storageString) {
- if (storageString.length() > 0) {
- String[] values = storageString.split(Pattern.quote(PID_STORAGE_SEPARATOR));
-
- for (String value : values) {
- if (mPidFilterList == null) {
- mPidFilterList = new ArrayList<Integer>();
- }
- mPidFilterList.add(Integer.parseInt(value));
- }
- }
- }
-
- private String getDescriptorStorageString(
- ArrayList<? extends OccurrenceDisplayDescriptor> descriptorList) {
- StringBuilder sb = new StringBuilder();
- boolean first = true;
-
- for (OccurrenceDisplayDescriptor descriptor : descriptorList) {
- if (first == false) {
- sb.append(DESCRIPTOR_STORAGE_SEPARATOR);
- } else {
- first = false;
- }
- sb.append(descriptor.getStorageString());
- }
-
- return sb.toString();
- }
-
- private void loadOccurrenceDescriptors(String storageString) {
- if (storageString.length() == 0) {
- return;
- }
-
- String[] values = storageString.split(Pattern.quote(DESCRIPTOR_STORAGE_SEPARATOR));
-
- for (String value : values) {
- OccurrenceDisplayDescriptor desc = new OccurrenceDisplayDescriptor();
- desc.loadFrom(value);
- mOccurrenceDescriptors.add(desc);
- }
- }
-
- private void loadValueDescriptors(String storageString) {
- if (storageString.length() == 0) {
- return;
- }
-
- String[] values = storageString.split(Pattern.quote(DESCRIPTOR_STORAGE_SEPARATOR));
-
- for (String value : values) {
- ValueDisplayDescriptor desc = new ValueDisplayDescriptor();
- desc.loadFrom(value);
- mValueDescriptors.add(desc);
- }
- }
-
- /**
- * Fills a list with {@link OccurrenceDisplayDescriptor} (or a subclass of it) from another
- * list if they are configured to display the {@link EventContainer}
- *
- * @param event the event container
- * @param fullList the list with all the descriptors.
- * @param outList the list to fill.
- */
- @SuppressWarnings("unchecked")
- private void getDescriptors(EventContainer event,
- ArrayList<? extends OccurrenceDisplayDescriptor> fullList,
- ArrayList outList) {
- for (OccurrenceDisplayDescriptor descriptor : fullList) {
- try {
- // first check the event tag.
- if (descriptor.eventTag == event.mTag) {
- // now check if we have a filter on a value
- if (descriptor.filterValueIndex == -1 ||
- event.testValue(descriptor.filterValueIndex, descriptor.filterValue,
- descriptor.filterCompareMethod)) {
- outList.add(descriptor);
- }
- }
- } catch (InvalidTypeException ite) {
- // if the filter for the descriptor was incorrect, we ignore the descriptor.
- } catch (ArrayIndexOutOfBoundsException aioobe) {
- // if the index was wrong (the event content may have changed since we setup the
- // display), we do nothing but log the error
- Log.e("Event Log", String.format(
- "ArrayIndexOutOfBoundsException occured when checking %1$d-th value of event %2$d", //$NON-NLS-1$
- descriptor.filterValueIndex, descriptor.eventTag));
- }
- }
- }
-
- /**
- * Filters the {@link com.android.ddmlib.log.EventContainer}, and fills two list of {@link com.android.ddmuilib.log.event.EventDisplay.ValueDisplayDescriptor}
- * and {@link com.android.ddmuilib.log.event.EventDisplay.OccurrenceDisplayDescriptor} configured to display the event.
- *
- * @param event
- * @param valueDescriptors
- * @param occurrenceDescriptors
- * @return true if the event should be displayed.
- */
-
- protected boolean filterEvent(EventContainer event,
- ArrayList<ValueDisplayDescriptor> valueDescriptors,
- ArrayList<OccurrenceDisplayDescriptor> occurrenceDescriptors) {
-
- // test the pid first (if needed)
- if (mPidFiltering && mPidFilterList != null) {
- boolean found = false;
- for (int pid : mPidFilterList) {
- if (pid == event.pid) {
- found = true;
- break;
- }
- }
-
- if (found == false) {
- return false;
- }
- }
-
- // now get the list of matching descriptors
- getDescriptors(event, mValueDescriptors, valueDescriptors);
- getDescriptors(event, mOccurrenceDescriptors, occurrenceDescriptors);
-
- // and return whether there is at least one match in either list.
- return (valueDescriptors.size() > 0 || occurrenceDescriptors.size() > 0);
- }
-
- /**
- * Checks all the {@link ValueDisplayDescriptor} for similarity.
- * If all the event values are from the same tag, the method will return EVENT_CHECK_SAME_TAG.
- * If all the event/value are the same, the method will return EVENT_CHECK_SAME_VALUE
- *
- * @return flag as described above
- */
- private int checkDescriptors() {
- if (mValueDescriptors.size() < 2) {
- return EVENT_CHECK_SAME_VALUE;
- }
-
- int tag = -1;
- int index = -1;
- for (ValueDisplayDescriptor display : mValueDescriptors) {
- if (tag == -1) {
- tag = display.eventTag;
- index = display.valueIndex;
- } else {
- if (tag != display.eventTag) {
- return EVENT_CHECK_FAILED;
- } else {
- if (index != -1) {
- if (index != display.valueIndex) {
- index = -1;
- }
- }
- }
- }
- }
-
- if (index == -1) {
- return EVENT_CHECK_SAME_TAG;
- }
-
- return EVENT_CHECK_SAME_VALUE;
- }
-
- /**
- * Resets the time limit on the chart to be infinite.
- */
- void resetChartTimeLimit() {
- mMaximumChartItemAge = -1;
- }
-
- /**
- * Sets the time limit on the charts.
- *
- * @param timeLimit the time limit in seconds.
- */
- void setChartTimeLimit(long timeLimit) {
- mMaximumChartItemAge = timeLimit;
- }
-
- long getChartTimeLimit() {
- return mMaximumChartItemAge;
- }
-
- /**
- * m
- * Resets the histogram width
- */
- void resetHistWidth() {
- mHistWidth = 1;
- }
-
- /**
- * Sets the histogram width
- *
- * @param histWidth the width in hours
- */
- void setHistWidth(long histWidth) {
- mHistWidth = histWidth;
- }
-
- long getHistWidth() {
- return mHistWidth;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventDisplayOptions.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventDisplayOptions.java
deleted file mode 100644
index b13f3f4..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventDisplayOptions.java
+++ /dev/null
@@ -1,961 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.log.event;
-
-import com.android.ddmlib.log.EventContainer;
-import com.android.ddmlib.log.EventLogParser;
-import com.android.ddmlib.log.EventValueDescription;
-import com.android.ddmuilib.DdmUiPreferences;
-import com.android.ddmuilib.ImageLoader;
-import com.android.ddmuilib.log.event.EventDisplay.OccurrenceDisplayDescriptor;
-import com.android.ddmuilib.log.event.EventDisplay.ValueDisplayDescriptor;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.Map;
-
-class EventDisplayOptions extends Dialog {
- private static final int DLG_WIDTH = 700;
- private static final int DLG_HEIGHT = 700;
-
- private Shell mParent;
- private Shell mShell;
-
- private boolean mEditStatus = false;
- private final ArrayList<EventDisplay> mDisplayList = new ArrayList<EventDisplay>();
-
- /* LEFT LIST */
- private List mEventDisplayList;
- private Button mEventDisplayNewButton;
- private Button mEventDisplayDeleteButton;
- private Button mEventDisplayUpButton;
- private Button mEventDisplayDownButton;
- private Text mDisplayWidthText;
- private Text mDisplayHeightText;
-
- /* WIDGETS ON THE RIGHT */
- private Text mDisplayNameText;
- private Combo mDisplayTypeCombo;
- private Group mChartOptions;
- private Group mHistOptions;
- private Button mPidFilterCheckBox;
- private Text mPidText;
-
- /** Map with (event-tag, event name) */
- private Map<Integer, String> mEventTagMap;
-
- /** Map with (event-tag, array of value info for the event) */
- private Map<Integer, EventValueDescription[]> mEventDescriptionMap;
-
- /** list of current pids */
- private ArrayList<Integer> mPidList;
-
- private EventLogParser mLogParser;
-
- private Group mInfoGroup;
-
- private static class SelectionWidgets {
- private List mList;
- private Button mNewButton;
- private Button mEditButton;
- private Button mDeleteButton;
-
- private void setEnabled(boolean enable) {
- mList.setEnabled(enable);
- mNewButton.setEnabled(enable);
- mEditButton.setEnabled(enable);
- mDeleteButton.setEnabled(enable);
- }
- }
-
- private SelectionWidgets mValueSelection;
- private SelectionWidgets mOccurrenceSelection;
-
- /** flag to temporarly disable processing of {@link Text} changes, so that
- * {@link Text#setText(String)} can be called safely. */
- private boolean mProcessTextChanges = true;
- private Text mTimeLimitText;
- private Text mHistWidthText;
-
- EventDisplayOptions(Shell parent) {
- super(parent, SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
- }
-
- /**
- * Opens the display option dialog, to edit the {@link EventDisplay} objects provided in the
- * list.
- * @param logParser
- * @param displayList
- * @param eventList
- * @return true if the list of {@link EventDisplay} objects was updated.
- */
- boolean open(EventLogParser logParser, ArrayList<EventDisplay> displayList,
- ArrayList<EventContainer> eventList) {
- mLogParser = logParser;
-
- if (logParser != null) {
- // we need 2 things from the parser.
- // the event tag / event name map
- mEventTagMap = logParser.getTagMap();
-
- // the event info map
- mEventDescriptionMap = logParser.getEventInfoMap();
- }
-
- // make a copy of the EventDisplay list since we'll use working copies.
- duplicateEventDisplay(displayList);
-
- // build a list of pid from the list of events.
- buildPidList(eventList);
-
- createUI();
-
- if (mParent == null || mShell == null) {
- return false;
- }
-
- // Set the dialog size.
- mShell.setMinimumSize(DLG_WIDTH, DLG_HEIGHT);
- Rectangle r = mParent.getBounds();
- // get the center new top left.
- int cx = r.x + r.width/2;
- int x = cx - DLG_WIDTH / 2;
- int cy = r.y + r.height/2;
- int y = cy - DLG_HEIGHT / 2;
- mShell.setBounds(x, y, DLG_WIDTH, DLG_HEIGHT);
-
- mShell.layout();
-
- // actually open the dialog
- mShell.open();
-
- // event loop until the dialog is closed.
- Display display = mParent.getDisplay();
- while (!mShell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- return mEditStatus;
- }
-
- ArrayList<EventDisplay> getEventDisplays() {
- return mDisplayList;
- }
-
- private void createUI() {
- mParent = getParent();
- mShell = new Shell(mParent, getStyle());
- mShell.setText("Event Display Configuration");
-
- mShell.setLayout(new GridLayout(1, true));
-
- final Composite topPanel = new Composite(mShell, SWT.NONE);
- topPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
- topPanel.setLayout(new GridLayout(2, false));
-
- // create the tree on the left and the controls on the right.
- Composite leftPanel = new Composite(topPanel, SWT.NONE);
- Composite rightPanel = new Composite(topPanel, SWT.NONE);
-
- createLeftPanel(leftPanel);
- createRightPanel(rightPanel);
-
- mShell.addListener(SWT.Close, new Listener() {
- @Override
- public void handleEvent(Event event) {
- event.doit = true;
- }
- });
-
- Label separator = new Label(mShell, SWT.SEPARATOR | SWT.HORIZONTAL);
- separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite bottomButtons = new Composite(mShell, SWT.NONE);
- bottomButtons.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- GridLayout gl;
- bottomButtons.setLayout(gl = new GridLayout(2, true));
- gl.marginHeight = gl.marginWidth = 0;
-
- Button okButton = new Button(bottomButtons, SWT.PUSH);
- okButton.setText("OK");
- okButton.addSelectionListener(new SelectionAdapter() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- mShell.close();
- }
- });
-
- Button cancelButton = new Button(bottomButtons, SWT.PUSH);
- cancelButton.setText("Cancel");
- cancelButton.addSelectionListener(new SelectionAdapter() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- // cancel the modification flag.
- mEditStatus = false;
-
- // and close
- mShell.close();
- }
- });
-
- enable(false);
-
- // fill the list with the current display
- fillEventDisplayList();
- }
-
- private void createLeftPanel(Composite leftPanel) {
- final IPreferenceStore store = DdmUiPreferences.getStore();
-
- GridLayout gl;
-
- leftPanel.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- leftPanel.setLayout(gl = new GridLayout(1, false));
- gl.verticalSpacing = 1;
-
- mEventDisplayList = new List(leftPanel,
- SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL | SWT.FULL_SELECTION);
- mEventDisplayList.setLayoutData(new GridData(GridData.FILL_BOTH));
- mEventDisplayList.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- handleEventDisplaySelection();
- }
- });
-
- Composite bottomControls = new Composite(leftPanel, SWT.NONE);
- bottomControls.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- bottomControls.setLayout(gl = new GridLayout(5, false));
- gl.marginHeight = gl.marginWidth = 0;
- gl.verticalSpacing = 0;
- gl.horizontalSpacing = 0;
-
- ImageLoader loader = ImageLoader.getDdmUiLibLoader();
- mEventDisplayNewButton = new Button(bottomControls, SWT.PUSH | SWT.FLAT);
- mEventDisplayNewButton.setImage(loader.loadImage("add.png", //$NON-NLS-1$
- leftPanel.getDisplay()));
- mEventDisplayNewButton.setToolTipText("Adds a new event display");
- mEventDisplayNewButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
- mEventDisplayNewButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- createNewEventDisplay();
- }
- });
-
- mEventDisplayDeleteButton = new Button(bottomControls, SWT.PUSH | SWT.FLAT);
- mEventDisplayDeleteButton.setImage(loader.loadImage("delete.png", //$NON-NLS-1$
- leftPanel.getDisplay()));
- mEventDisplayDeleteButton.setToolTipText("Deletes the selected event display");
- mEventDisplayDeleteButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
- mEventDisplayDeleteButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- deleteEventDisplay();
- }
- });
-
- mEventDisplayUpButton = new Button(bottomControls, SWT.PUSH | SWT.FLAT);
- mEventDisplayUpButton.setImage(loader.loadImage("up.png", //$NON-NLS-1$
- leftPanel.getDisplay()));
- mEventDisplayUpButton.setToolTipText("Moves the selected event display up");
- mEventDisplayUpButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // get current selection.
- int selection = mEventDisplayList.getSelectionIndex();
- if (selection > 0) {
- // update the list of EventDisplay.
- EventDisplay display = mDisplayList.remove(selection);
- mDisplayList.add(selection - 1, display);
-
- // update the list widget
- mEventDisplayList.remove(selection);
- mEventDisplayList.add(display.getName(), selection - 1);
-
- // update the selection and reset the ui.
- mEventDisplayList.select(selection - 1);
- handleEventDisplaySelection();
- mEventDisplayList.showSelection();
-
- setModified();
- }
- }
- });
-
- mEventDisplayDownButton = new Button(bottomControls, SWT.PUSH | SWT.FLAT);
- mEventDisplayDownButton.setImage(loader.loadImage("down.png", //$NON-NLS-1$
- leftPanel.getDisplay()));
- mEventDisplayDownButton.setToolTipText("Moves the selected event display down");
- mEventDisplayDownButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // get current selection.
- int selection = mEventDisplayList.getSelectionIndex();
- if (selection != -1 && selection < mEventDisplayList.getItemCount() - 1) {
- // update the list of EventDisplay.
- EventDisplay display = mDisplayList.remove(selection);
- mDisplayList.add(selection + 1, display);
-
- // update the list widget
- mEventDisplayList.remove(selection);
- mEventDisplayList.add(display.getName(), selection + 1);
-
- // update the selection and reset the ui.
- mEventDisplayList.select(selection + 1);
- handleEventDisplaySelection();
- mEventDisplayList.showSelection();
-
- setModified();
- }
- }
- });
-
- Group sizeGroup = new Group(leftPanel, SWT.NONE);
- sizeGroup.setText("Display Size:");
- sizeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- sizeGroup.setLayout(new GridLayout(2, false));
-
- Label l = new Label(sizeGroup, SWT.NONE);
- l.setText("Width:");
-
- mDisplayWidthText = new Text(sizeGroup, SWT.LEFT | SWT.SINGLE | SWT.BORDER);
- mDisplayWidthText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mDisplayWidthText.setText(Integer.toString(
- store.getInt(EventLogPanel.PREFS_DISPLAY_WIDTH)));
- mDisplayWidthText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- String text = mDisplayWidthText.getText().trim();
- try {
- store.setValue(EventLogPanel.PREFS_DISPLAY_WIDTH, Integer.parseInt(text));
- setModified();
- } catch (NumberFormatException nfe) {
- // do something?
- }
- }
- });
-
- l = new Label(sizeGroup, SWT.NONE);
- l.setText("Height:");
-
- mDisplayHeightText = new Text(sizeGroup, SWT.LEFT | SWT.SINGLE | SWT.BORDER);
- mDisplayHeightText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mDisplayHeightText.setText(Integer.toString(
- store.getInt(EventLogPanel.PREFS_DISPLAY_HEIGHT)));
- mDisplayHeightText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- String text = mDisplayHeightText.getText().trim();
- try {
- store.setValue(EventLogPanel.PREFS_DISPLAY_HEIGHT, Integer.parseInt(text));
- setModified();
- } catch (NumberFormatException nfe) {
- // do something?
- }
- }
- });
- }
-
- private void createRightPanel(Composite rightPanel) {
- rightPanel.setLayout(new GridLayout(1, true));
- rightPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- mInfoGroup = new Group(rightPanel, SWT.NONE);
- mInfoGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mInfoGroup.setLayout(new GridLayout(2, false));
-
- Label nameLabel = new Label(mInfoGroup, SWT.LEFT);
- nameLabel.setText("Name:");
-
- mDisplayNameText = new Text(mInfoGroup, SWT.BORDER | SWT.LEFT | SWT.SINGLE);
- mDisplayNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mDisplayNameText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- if (mProcessTextChanges) {
- EventDisplay eventDisplay = getCurrentEventDisplay();
- if (eventDisplay != null) {
- eventDisplay.setName(mDisplayNameText.getText());
- int index = mEventDisplayList.getSelectionIndex();
- mEventDisplayList.remove(index);
- mEventDisplayList.add(eventDisplay.getName(), index);
- mEventDisplayList.select(index);
- handleEventDisplaySelection();
- setModified();
- }
- }
- }
- });
-
- Label displayLabel = new Label(mInfoGroup, SWT.LEFT);
- displayLabel.setText("Type:");
-
- mDisplayTypeCombo = new Combo(mInfoGroup, SWT.READ_ONLY | SWT.DROP_DOWN);
- mDisplayTypeCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- // add the combo values. This must match the values EventDisplay.DISPLAY_TYPE_*
- mDisplayTypeCombo.add("Log All");
- mDisplayTypeCombo.add("Filtered Log");
- mDisplayTypeCombo.add("Graph");
- mDisplayTypeCombo.add("Sync");
- mDisplayTypeCombo.add("Sync Histogram");
- mDisplayTypeCombo.add("Sync Performance");
- mDisplayTypeCombo.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- EventDisplay eventDisplay = getCurrentEventDisplay();
- if (eventDisplay != null && eventDisplay.getDisplayType() != mDisplayTypeCombo.getSelectionIndex()) {
- /* Replace the EventDisplay object with a different subclass */
- setModified();
- String name = eventDisplay.getName();
- EventDisplay newEventDisplay = EventDisplay.eventDisplayFactory(mDisplayTypeCombo.getSelectionIndex(), name);
- setCurrentEventDisplay(newEventDisplay);
- fillUiWith(newEventDisplay);
- }
- }
- });
-
- mChartOptions = new Group(mInfoGroup, SWT.NONE);
- mChartOptions.setText("Chart Options");
- GridData gd;
- mChartOptions.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
- gd.horizontalSpan = 2;
- mChartOptions.setLayout(new GridLayout(2, false));
-
- Label l = new Label(mChartOptions, SWT.NONE);
- l.setText("Time Limit (seconds):");
-
- mTimeLimitText = new Text(mChartOptions, SWT.BORDER);
- mTimeLimitText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mTimeLimitText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent arg0) {
- String text = mTimeLimitText.getText().trim();
- EventDisplay eventDisplay = getCurrentEventDisplay();
- if (eventDisplay != null) {
- try {
- if (text.length() == 0) {
- eventDisplay.resetChartTimeLimit();
- } else {
- eventDisplay.setChartTimeLimit(Long.parseLong(text));
- }
- } catch (NumberFormatException nfe) {
- eventDisplay.resetChartTimeLimit();
- } finally {
- setModified();
- }
- }
- }
- });
-
- mHistOptions = new Group(mInfoGroup, SWT.NONE);
- mHistOptions.setText("Histogram Options");
- GridData gdh;
- mHistOptions.setLayoutData(gdh = new GridData(GridData.FILL_HORIZONTAL));
- gdh.horizontalSpan = 2;
- mHistOptions.setLayout(new GridLayout(2, false));
-
- Label lh = new Label(mHistOptions, SWT.NONE);
- lh.setText("Histogram width (hours):");
-
- mHistWidthText = new Text(mHistOptions, SWT.BORDER);
- mHistWidthText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mHistWidthText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent arg0) {
- String text = mHistWidthText.getText().trim();
- EventDisplay eventDisplay = getCurrentEventDisplay();
- if (eventDisplay != null) {
- try {
- if (text.length() == 0) {
- eventDisplay.resetHistWidth();
- } else {
- eventDisplay.setHistWidth(Long.parseLong(text));
- }
- } catch (NumberFormatException nfe) {
- eventDisplay.resetHistWidth();
- } finally {
- setModified();
- }
- }
- }
- });
-
- mPidFilterCheckBox = new Button(mInfoGroup, SWT.CHECK);
- mPidFilterCheckBox.setText("Enable filtering by pid");
- mPidFilterCheckBox.setLayoutData(gd = new GridData(GridData.FILL_HORIZONTAL));
- gd.horizontalSpan = 2;
- mPidFilterCheckBox.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- EventDisplay eventDisplay = getCurrentEventDisplay();
- if (eventDisplay != null) {
- eventDisplay.setPidFiltering(mPidFilterCheckBox.getSelection());
- mPidText.setEnabled(mPidFilterCheckBox.getSelection());
- setModified();
- }
- }
- });
-
- Label pidLabel = new Label(mInfoGroup, SWT.NONE);
- pidLabel.setText("Pid Filter:");
- pidLabel.setToolTipText("Enter all pids, separated by commas");
-
- mPidText = new Text(mInfoGroup, SWT.BORDER);
- mPidText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mPidText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- if (mProcessTextChanges) {
- EventDisplay eventDisplay = getCurrentEventDisplay();
- if (eventDisplay != null && eventDisplay.getPidFiltering()) {
- String pidText = mPidText.getText().trim();
- String[] pids = pidText.split("\\s*,\\s*"); //$NON-NLS-1$
-
- ArrayList<Integer> list = new ArrayList<Integer>();
- for (String pid : pids) {
- try {
- list.add(Integer.valueOf(pid));
- } catch (NumberFormatException nfe) {
- // just ignore non valid pid
- }
- }
-
- eventDisplay.setPidFilterList(list);
- setModified();
- }
- }
- }
- });
-
- /* ------------------
- * EVENT VALUE/OCCURRENCE SELECTION
- * ------------------ */
- mValueSelection = createEventSelection(rightPanel, ValueDisplayDescriptor.class,
- "Event Value Display");
- mOccurrenceSelection = createEventSelection(rightPanel, OccurrenceDisplayDescriptor.class,
- "Event Occurrence Display");
- }
-
- private SelectionWidgets createEventSelection(Composite rightPanel,
- final Class<? extends OccurrenceDisplayDescriptor> descriptorClass,
- String groupMessage) {
-
- Group eventSelectionPanel = new Group(rightPanel, SWT.NONE);
- eventSelectionPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout gl;
- eventSelectionPanel.setLayout(gl = new GridLayout(2, false));
- gl.marginHeight = gl.marginWidth = 0;
- eventSelectionPanel.setText(groupMessage);
-
- final SelectionWidgets widgets = new SelectionWidgets();
-
- widgets.mList = new List(eventSelectionPanel, SWT.BORDER | SWT.SINGLE | SWT.V_SCROLL);
- widgets.mList.setLayoutData(new GridData(GridData.FILL_BOTH));
- widgets.mList.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- int index = widgets.mList.getSelectionIndex();
- if (index != -1) {
- widgets.mDeleteButton.setEnabled(true);
- widgets.mEditButton.setEnabled(true);
- } else {
- widgets.mDeleteButton.setEnabled(false);
- widgets.mEditButton.setEnabled(false);
- }
- }
- });
-
- Composite rightControls = new Composite(eventSelectionPanel, SWT.NONE);
- rightControls.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- rightControls.setLayout(gl = new GridLayout(1, false));
- gl.marginHeight = gl.marginWidth = 0;
- gl.verticalSpacing = 0;
- gl.horizontalSpacing = 0;
-
- widgets.mNewButton = new Button(rightControls, SWT.PUSH | SWT.FLAT);
- widgets.mNewButton.setText("New...");
- widgets.mNewButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- widgets.mNewButton.setEnabled(false);
- widgets.mNewButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // current event
- try {
- EventDisplay eventDisplay = getCurrentEventDisplay();
- if (eventDisplay != null) {
- EventValueSelector dialog = new EventValueSelector(mShell);
- if (dialog.open(descriptorClass, mLogParser)) {
- eventDisplay.addDescriptor(dialog.getDescriptor());
- fillUiWith(eventDisplay);
- setModified();
- }
- }
- } catch (Exception e1) {
- e1.printStackTrace();
- }
- }
- });
-
- widgets.mEditButton = new Button(rightControls, SWT.PUSH | SWT.FLAT);
- widgets.mEditButton.setText("Edit...");
- widgets.mEditButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- widgets.mEditButton.setEnabled(false);
- widgets.mEditButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // current event
- EventDisplay eventDisplay = getCurrentEventDisplay();
- if (eventDisplay != null) {
- // get the current descriptor index
- int index = widgets.mList.getSelectionIndex();
- if (index != -1) {
- // get the descriptor itself
- OccurrenceDisplayDescriptor descriptor = eventDisplay.getDescriptor(
- descriptorClass, index);
-
- // open the edit dialog.
- EventValueSelector dialog = new EventValueSelector(mShell);
- if (dialog.open(descriptor, mLogParser)) {
- descriptor.replaceWith(dialog.getDescriptor());
- eventDisplay.updateValueDescriptorCheck();
- fillUiWith(eventDisplay);
-
- // reselect the item since fillUiWith remove the selection.
- widgets.mList.select(index);
- widgets.mList.notifyListeners(SWT.Selection, null);
-
- setModified();
- }
- }
- }
- }
- });
-
- widgets.mDeleteButton = new Button(rightControls, SWT.PUSH | SWT.FLAT);
- widgets.mDeleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- widgets.mDeleteButton.setText("Delete");
- widgets.mDeleteButton.setEnabled(false);
- widgets.mDeleteButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // current event
- EventDisplay eventDisplay = getCurrentEventDisplay();
- if (eventDisplay != null) {
- // get the current descriptor index
- int index = widgets.mList.getSelectionIndex();
- if (index != -1) {
- eventDisplay.removeDescriptor(descriptorClass, index);
- fillUiWith(eventDisplay);
- setModified();
- }
- }
- }
- });
-
- return widgets;
- }
-
-
- private void duplicateEventDisplay(ArrayList<EventDisplay> displayList) {
- for (EventDisplay eventDisplay : displayList) {
- mDisplayList.add(EventDisplay.clone(eventDisplay));
- }
- }
-
- private void buildPidList(ArrayList<EventContainer> eventList) {
- mPidList = new ArrayList<Integer>();
- for (EventContainer event : eventList) {
- if (mPidList.indexOf(event.pid) == -1) {
- mPidList.add(event.pid);
- }
- }
- }
-
- private void setModified() {
- mEditStatus = true;
- }
-
-
- private void enable(boolean status) {
- mEventDisplayDeleteButton.setEnabled(status);
-
- // enable up/down
- int selection = mEventDisplayList.getSelectionIndex();
- int count = mEventDisplayList.getItemCount();
- mEventDisplayUpButton.setEnabled(status && selection > 0);
- mEventDisplayDownButton.setEnabled(status && selection != -1 && selection < count - 1);
-
- mDisplayNameText.setEnabled(status);
- mDisplayTypeCombo.setEnabled(status);
- mPidFilterCheckBox.setEnabled(status);
-
- mValueSelection.setEnabled(status);
- mOccurrenceSelection.setEnabled(status);
- mValueSelection.mNewButton.setEnabled(status);
- mOccurrenceSelection.mNewButton.setEnabled(status);
- if (status == false) {
- mPidText.setEnabled(false);
- }
- }
-
- private void fillEventDisplayList() {
- for (EventDisplay eventDisplay : mDisplayList) {
- mEventDisplayList.add(eventDisplay.getName());
- }
- }
-
- private void createNewEventDisplay() {
- int count = mDisplayList.size();
-
- String name = String.format("display %1$d", count + 1);
-
- EventDisplay eventDisplay = EventDisplay.eventDisplayFactory(0 /* type*/, name);
-
- mDisplayList.add(eventDisplay);
- mEventDisplayList.add(name);
-
- mEventDisplayList.select(count);
- handleEventDisplaySelection();
- mEventDisplayList.showSelection();
-
- setModified();
- }
-
- private void deleteEventDisplay() {
- int selection = mEventDisplayList.getSelectionIndex();
- if (selection != -1) {
- mDisplayList.remove(selection);
- mEventDisplayList.remove(selection);
- if (mDisplayList.size() < selection) {
- selection--;
- }
- mEventDisplayList.select(selection);
- handleEventDisplaySelection();
-
- setModified();
- }
- }
-
- private EventDisplay getCurrentEventDisplay() {
- int selection = mEventDisplayList.getSelectionIndex();
- if (selection != -1) {
- return mDisplayList.get(selection);
- }
-
- return null;
- }
-
- private void setCurrentEventDisplay(EventDisplay eventDisplay) {
- int selection = mEventDisplayList.getSelectionIndex();
- if (selection != -1) {
- mDisplayList.set(selection, eventDisplay);
- }
- }
-
- private void handleEventDisplaySelection() {
- EventDisplay eventDisplay = getCurrentEventDisplay();
- if (eventDisplay != null) {
- // enable the UI
- enable(true);
-
- // and fill it
- fillUiWith(eventDisplay);
- } else {
- // disable the UI
- enable(false);
-
- // and empty it.
- emptyUi();
- }
- }
-
- private void emptyUi() {
- mDisplayNameText.setText("");
- mDisplayTypeCombo.clearSelection();
- mValueSelection.mList.removeAll();
- mOccurrenceSelection.mList.removeAll();
- }
-
- private void fillUiWith(EventDisplay eventDisplay) {
- mProcessTextChanges = false;
-
- mDisplayNameText.setText(eventDisplay.getName());
- int displayMode = eventDisplay.getDisplayType();
- mDisplayTypeCombo.select(displayMode);
- if (displayMode == EventDisplay.DISPLAY_TYPE_GRAPH) {
- GridData gd = (GridData) mChartOptions.getLayoutData();
- gd.exclude = false;
- mChartOptions.setVisible(!gd.exclude);
- long limit = eventDisplay.getChartTimeLimit();
- if (limit != -1) {
- mTimeLimitText.setText(Long.toString(limit));
- } else {
- mTimeLimitText.setText(""); //$NON-NLS-1$
- }
- } else {
- GridData gd = (GridData) mChartOptions.getLayoutData();
- gd.exclude = true;
- mChartOptions.setVisible(!gd.exclude);
- mTimeLimitText.setText(""); //$NON-NLS-1$
- }
-
- if (displayMode == EventDisplay.DISPLAY_TYPE_SYNC_HIST) {
- GridData gd = (GridData) mHistOptions.getLayoutData();
- gd.exclude = false;
- mHistOptions.setVisible(!gd.exclude);
- long limit = eventDisplay.getHistWidth();
- if (limit != -1) {
- mHistWidthText.setText(Long.toString(limit));
- } else {
- mHistWidthText.setText(""); //$NON-NLS-1$
- }
- } else {
- GridData gd = (GridData) mHistOptions.getLayoutData();
- gd.exclude = true;
- mHistOptions.setVisible(!gd.exclude);
- mHistWidthText.setText(""); //$NON-NLS-1$
- }
- mInfoGroup.layout(true);
- mShell.layout(true);
- mShell.pack();
-
- if (eventDisplay.getPidFiltering()) {
- mPidFilterCheckBox.setSelection(true);
- mPidText.setEnabled(true);
-
- // build the pid list.
- ArrayList<Integer> list = eventDisplay.getPidFilterList();
- if (list != null) {
- StringBuilder sb = new StringBuilder();
- int count = list.size();
- for (int i = 0 ; i < count ; i++) {
- sb.append(list.get(i));
- if (i < count - 1) {
- sb.append(", ");//$NON-NLS-1$
- }
- }
- mPidText.setText(sb.toString());
- } else {
- mPidText.setText(""); //$NON-NLS-1$
- }
- } else {
- mPidFilterCheckBox.setSelection(false);
- mPidText.setEnabled(false);
- mPidText.setText(""); //$NON-NLS-1$
- }
-
- mProcessTextChanges = true;
-
- mValueSelection.mList.removeAll();
- mOccurrenceSelection.mList.removeAll();
-
- if (eventDisplay.getDisplayType() == EventDisplay.DISPLAY_TYPE_FILTERED_LOG ||
- eventDisplay.getDisplayType() == EventDisplay.DISPLAY_TYPE_GRAPH) {
- mOccurrenceSelection.setEnabled(true);
- mValueSelection.setEnabled(true);
-
- Iterator<ValueDisplayDescriptor> valueIterator = eventDisplay.getValueDescriptors();
-
- while (valueIterator.hasNext()) {
- ValueDisplayDescriptor descriptor = valueIterator.next();
- mValueSelection.mList.add(String.format("%1$s: %2$s [%3$s]%4$s",
- mEventTagMap.get(descriptor.eventTag), descriptor.valueName,
- getSeriesLabelDescription(descriptor), getFilterDescription(descriptor)));
- }
-
- Iterator<OccurrenceDisplayDescriptor> occurrenceIterator =
- eventDisplay.getOccurrenceDescriptors();
-
- while (occurrenceIterator.hasNext()) {
- OccurrenceDisplayDescriptor descriptor = occurrenceIterator.next();
-
- mOccurrenceSelection.mList.add(String.format("%1$s [%2$s]%3$s",
- mEventTagMap.get(descriptor.eventTag),
- getSeriesLabelDescription(descriptor),
- getFilterDescription(descriptor)));
- }
-
- mValueSelection.mList.notifyListeners(SWT.Selection, null);
- mOccurrenceSelection.mList.notifyListeners(SWT.Selection, null);
- } else {
- mOccurrenceSelection.setEnabled(false);
- mValueSelection.setEnabled(false);
- }
-
- }
-
- /**
- * Returns a String describing what is used as the series label
- * @param descriptor the descriptor of the display.
- */
- private String getSeriesLabelDescription(OccurrenceDisplayDescriptor descriptor) {
- if (descriptor.seriesValueIndex != -1) {
- if (descriptor.includePid) {
- return String.format("%1$s + pid",
- mEventDescriptionMap.get(
- descriptor.eventTag)[descriptor.seriesValueIndex].getName());
- } else {
- return mEventDescriptionMap.get(descriptor.eventTag)[descriptor.seriesValueIndex]
- .getName();
- }
- }
- return "pid";
- }
-
- private String getFilterDescription(OccurrenceDisplayDescriptor descriptor) {
- if (descriptor.filterValueIndex != -1) {
- return String.format(" [%1$s %2$s %3$s]",
- mEventDescriptionMap.get(
- descriptor.eventTag)[descriptor.filterValueIndex].getName(),
- descriptor.filterCompareMethod.testString(),
- descriptor.filterValue != null ?
- descriptor.filterValue.toString() : "?"); //$NON-NLS-1$
- }
- return ""; //$NON-NLS-1$
- }
-
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogImporter.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogImporter.java
deleted file mode 100644
index 011bcf1..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogImporter.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.log.event;
-
-import com.android.ddmlib.Log;
-
-import java.io.BufferedReader;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.util.ArrayList;
-
-/**
- * Imports a textual event log. Gets tags from build path.
- */
-public class EventLogImporter {
-
- private String[] mTags;
- private String[] mLog;
-
- public EventLogImporter(String filePath) throws FileNotFoundException {
- String top = System.getenv("ANDROID_BUILD_TOP");
- if (top == null) {
- throw new FileNotFoundException();
- }
- final String tagFile = top + "/system/core/logcat/event-log-tags";
- BufferedReader tagReader = new BufferedReader(
- new InputStreamReader(new FileInputStream(tagFile)));
- BufferedReader eventReader = new BufferedReader(
- new InputStreamReader(new FileInputStream(filePath)));
- try {
- readTags(tagReader);
- readLog(eventReader);
- } catch (IOException e) {
- } finally {
- if (tagReader != null) {
- try {
- tagReader.close();
- } catch (IOException ignore) {
- }
- }
- if (eventReader != null) {
- try {
- eventReader.close();
- } catch (IOException ignore) {
- }
- }
- }
- }
-
- public String[] getTags() {
- return mTags;
- }
-
- public String[] getLog() {
- return mLog;
- }
-
- private void readTags(BufferedReader reader) throws IOException {
- String line;
-
- ArrayList<String> content = new ArrayList<String>();
- while ((line = reader.readLine()) != null) {
- content.add(line);
- }
- mTags = content.toArray(new String[content.size()]);
- }
-
- private void readLog(BufferedReader reader) throws IOException {
- String line;
-
- ArrayList<String> content = new ArrayList<String>();
- while ((line = reader.readLine()) != null) {
- content.add(line);
- }
-
- mLog = content.toArray(new String[content.size()]);
- }
-
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogPanel.java
deleted file mode 100644
index 937ee40..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventLogPanel.java
+++ /dev/null
@@ -1,938 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.log.event;
-
-import com.android.ddmlib.Client;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.log.EventContainer;
-import com.android.ddmlib.log.EventLogParser;
-import com.android.ddmlib.log.LogReceiver;
-import com.android.ddmlib.log.LogReceiver.ILogListener;
-import com.android.ddmlib.log.LogReceiver.LogEntry;
-import com.android.ddmuilib.DdmUiPreferences;
-import com.android.ddmuilib.TablePanel;
-import com.android.ddmuilib.actions.ICommonAction;
-import com.android.ddmuilib.annotation.UiThread;
-import com.android.ddmuilib.annotation.WorkerThread;
-import com.android.ddmuilib.log.event.EventDisplay.ILogColumnListener;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.RowData;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.text.NumberFormat;
-import java.util.ArrayList;
-import java.util.regex.Pattern;
-
-/**
- * Event log viewer
- */
-public class EventLogPanel extends TablePanel implements ILogListener,
- ILogColumnListener {
-
- private final static String TAG_FILE_EXT = ".tag"; //$NON-NLS-1$
-
- private final static String PREFS_EVENT_DISPLAY = "EventLogPanel.eventDisplay"; //$NON-NLS-1$
- private final static String EVENT_DISPLAY_STORAGE_SEPARATOR = "|"; //$NON-NLS-1$
-
- static final String PREFS_DISPLAY_WIDTH = "EventLogPanel.width"; //$NON-NLS-1$
- static final String PREFS_DISPLAY_HEIGHT = "EventLogPanel.height"; //$NON-NLS-1$
-
- private final static int DEFAULT_DISPLAY_WIDTH = 500;
- private final static int DEFAULT_DISPLAY_HEIGHT = 400;
-
- private IDevice mCurrentLoggedDevice;
- private String mCurrentLogFile;
- private LogReceiver mCurrentLogReceiver;
- private EventLogParser mCurrentEventLogParser;
-
- private Object mLock = new Object();
-
- /** list of all the events. */
- private final ArrayList<EventContainer> mEvents = new ArrayList<EventContainer>();
-
- /** list of all the new events, that have yet to be displayed by the ui */
- private final ArrayList<EventContainer> mNewEvents = new ArrayList<EventContainer>();
- /** indicates a pending ui thread display */
- private boolean mPendingDisplay = false;
-
- /** list of all the custom event displays */
- private final ArrayList<EventDisplay> mEventDisplays = new ArrayList<EventDisplay>();
-
- private final NumberFormat mFormatter = NumberFormat.getInstance();
- private Composite mParent;
- private ScrolledComposite mBottomParentPanel;
- private Composite mBottomPanel;
- private ICommonAction mOptionsAction;
- private ICommonAction mClearAction;
- private ICommonAction mSaveAction;
- private ICommonAction mLoadAction;
- private ICommonAction mImportAction;
-
- /** file containing the current log raw data. */
- private File mTempFile = null;
-
- public EventLogPanel() {
- super();
- mFormatter.setGroupingUsed(true);
- }
-
- /**
- * Sets the external actions.
- * <p/>This method sets up the {@link ICommonAction} objects to execute the proper code
- * when triggered by using {@link ICommonAction#setRunnable(Runnable)}.
- * <p/>It will also make sure they are enabled only when possible.
- * @param optionsAction
- * @param clearAction
- * @param saveAction
- * @param loadAction
- * @param importAction
- */
- public void setActions(ICommonAction optionsAction, ICommonAction clearAction,
- ICommonAction saveAction, ICommonAction loadAction, ICommonAction importAction) {
- mOptionsAction = optionsAction;
- mOptionsAction.setRunnable(new Runnable() {
- @Override
- public void run() {
- openOptionPanel();
- }
- });
-
- mClearAction = clearAction;
- mClearAction.setRunnable(new Runnable() {
- @Override
- public void run() {
- clearLog();
- }
- });
-
- mSaveAction = saveAction;
- mSaveAction.setRunnable(new Runnable() {
- @Override
- public void run() {
- try {
- FileDialog fileDialog = new FileDialog(mParent.getShell(), SWT.SAVE);
-
- fileDialog.setText("Save Event Log");
- fileDialog.setFileName("event.log");
-
- String fileName = fileDialog.open();
- if (fileName != null) {
- saveLog(fileName);
- }
- } catch (IOException e1) {
- }
- }
- });
-
- mLoadAction = loadAction;
- mLoadAction.setRunnable(new Runnable() {
- @Override
- public void run() {
- FileDialog fileDialog = new FileDialog(mParent.getShell(), SWT.OPEN);
-
- fileDialog.setText("Load Event Log");
-
- String fileName = fileDialog.open();
- if (fileName != null) {
- loadLog(fileName);
- }
- }
- });
-
- mImportAction = importAction;
- mImportAction.setRunnable(new Runnable() {
- @Override
- public void run() {
- FileDialog fileDialog = new FileDialog(mParent.getShell(), SWT.OPEN);
-
- fileDialog.setText("Import Bug Report");
-
- String fileName = fileDialog.open();
- if (fileName != null) {
- importBugReport(fileName);
- }
- }
- });
-
- mOptionsAction.setEnabled(false);
- mClearAction.setEnabled(false);
- mSaveAction.setEnabled(false);
- }
-
- /**
- * Opens the option panel.
- * </p>
- * <b>This must be called from the UI thread</b>
- */
- @UiThread
- public void openOptionPanel() {
- try {
- EventDisplayOptions dialog = new EventDisplayOptions(mParent.getShell());
- if (dialog.open(mCurrentEventLogParser, mEventDisplays, mEvents)) {
- synchronized (mLock) {
- // get the new EventDisplay list
- mEventDisplays.clear();
- mEventDisplays.addAll(dialog.getEventDisplays());
-
- // since the list of EventDisplay changed, we store it.
- saveEventDisplays();
-
- rebuildUi();
- }
- }
- } catch (SWTException e) {
- Log.e("EventLog", e); //$NON-NLS-1$
- }
- }
-
- /**
- * Clears the log.
- * <p/>
- * <b>This must be called from the UI thread</b>
- */
- public void clearLog() {
- try {
- synchronized (mLock) {
- mEvents.clear();
- mNewEvents.clear();
- mPendingDisplay = false;
- for (EventDisplay eventDisplay : mEventDisplays) {
- eventDisplay.resetUI();
- }
- }
- } catch (SWTException e) {
- Log.e("EventLog", e); //$NON-NLS-1$
- }
- }
-
- /**
- * Saves the content of the event log into a file. The log is saved in the same
- * binary format than on the device.
- * @param filePath
- * @throws IOException
- */
- public void saveLog(String filePath) throws IOException {
- if (mCurrentLoggedDevice != null && mCurrentEventLogParser != null) {
- File destFile = new File(filePath);
- destFile.createNewFile();
- FileInputStream fis = new FileInputStream(mTempFile);
- FileOutputStream fos = new FileOutputStream(destFile);
- byte[] buffer = new byte[1024];
-
- int count;
-
- while ((count = fis.read(buffer)) != -1) {
- fos.write(buffer, 0, count);
- }
-
- fos.close();
- fis.close();
-
- // now we save the tag file
- filePath = filePath + TAG_FILE_EXT;
- mCurrentEventLogParser.saveTags(filePath);
- }
- }
-
- /**
- * Loads a binary event log (if has associated .tag file) or
- * otherwise loads a textual event log.
- * @param filePath Event log path (and base of potential tag file)
- */
- public void loadLog(String filePath) {
- if ((new File(filePath + TAG_FILE_EXT)).exists()) {
- startEventLogFromFiles(filePath);
- } else {
- try {
- EventLogImporter importer = new EventLogImporter(filePath);
- String[] tags = importer.getTags();
- String[] log = importer.getLog();
- startEventLogFromContent(tags, log);
- } catch (FileNotFoundException e) {
- // If this fails, display the error message from startEventLogFromFiles,
- // and pretend we never tried EventLogImporter
- Log.logAndDisplay(Log.LogLevel.ERROR, "EventLog",
- String.format("Failure to read %1$s", filePath + TAG_FILE_EXT));
- }
-
- }
- }
-
- public void importBugReport(String filePath) {
- try {
- BugReportImporter importer = new BugReportImporter(filePath);
-
- String[] tags = importer.getTags();
- String[] log = importer.getLog();
-
- startEventLogFromContent(tags, log);
-
- } catch (FileNotFoundException e) {
- Log.logAndDisplay(LogLevel.ERROR, "Import",
- "Unable to import bug report: " + e.getMessage());
- }
- }
-
- /* (non-Javadoc)
- * @see com.android.ddmuilib.SelectionDependentPanel#clientSelected()
- */
- @Override
- public void clientSelected() {
- // pass
- }
-
- /* (non-Javadoc)
- * @see com.android.ddmuilib.SelectionDependentPanel#deviceSelected()
- */
- @Override
- public void deviceSelected() {
- startEventLog(getCurrentDevice());
- }
-
- /*
- * (non-Javadoc)
- * @see com.android.ddmlib.AndroidDebugBridge.IClientChangeListener#clientChanged(com.android.ddmlib.Client, int)
- */
- @Override
- public void clientChanged(Client client, int changeMask) {
- // pass
- }
-
- /* (non-Javadoc)
- * @see com.android.ddmuilib.Panel#createControl(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createControl(Composite parent) {
- mParent = parent;
- mParent.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- synchronized (mLock) {
- if (mCurrentLogReceiver != null) {
- mCurrentLogReceiver.cancel();
- mCurrentLogReceiver = null;
- mCurrentEventLogParser = null;
- mCurrentLoggedDevice = null;
- mEventDisplays.clear();
- mEvents.clear();
- }
- }
- }
- });
-
- final IPreferenceStore store = DdmUiPreferences.getStore();
-
- // init some store stuff
- store.setDefault(PREFS_DISPLAY_WIDTH, DEFAULT_DISPLAY_WIDTH);
- store.setDefault(PREFS_DISPLAY_HEIGHT, DEFAULT_DISPLAY_HEIGHT);
-
- mBottomParentPanel = new ScrolledComposite(parent, SWT.V_SCROLL);
- mBottomParentPanel.setLayoutData(new GridData(GridData.FILL_BOTH));
- mBottomParentPanel.setExpandHorizontal(true);
- mBottomParentPanel.setExpandVertical(true);
-
- mBottomParentPanel.addControlListener(new ControlAdapter() {
- @Override
- public void controlResized(ControlEvent e) {
- if (mBottomPanel != null) {
- Rectangle r = mBottomParentPanel.getClientArea();
- mBottomParentPanel.setMinSize(mBottomPanel.computeSize(r.width,
- SWT.DEFAULT));
- }
- }
- });
-
- prepareDisplayUi();
-
- // load the EventDisplay from storage.
- loadEventDisplays();
-
- // create the ui
- createDisplayUi();
-
- return mBottomParentPanel;
- }
-
- /* (non-Javadoc)
- * @see com.android.ddmuilib.Panel#postCreation()
- */
- @Override
- protected void postCreation() {
- // pass
- }
-
- /* (non-Javadoc)
- * @see com.android.ddmuilib.Panel#setFocus()
- */
- @Override
- public void setFocus() {
- mBottomParentPanel.setFocus();
- }
-
- /**
- * Starts a new logcat and set mCurrentLogCat as the current receiver.
- * @param device the device to connect logcat to.
- */
- private void startEventLog(final IDevice device) {
- if (device == mCurrentLoggedDevice) {
- return;
- }
-
- // if we have a logcat already running
- if (mCurrentLogReceiver != null) {
- stopEventLog(false);
- }
- mCurrentLoggedDevice = null;
- mCurrentLogFile = null;
-
- if (device != null) {
- // create a new output receiver
- mCurrentLogReceiver = new LogReceiver(this);
-
- // start the logcat in a different thread
- new Thread("EventLog") { //$NON-NLS-1$
- @Override
- public void run() {
- while (device.isOnline() == false &&
- mCurrentLogReceiver != null &&
- mCurrentLogReceiver.isCancelled() == false) {
- try {
- sleep(2000);
- } catch (InterruptedException e) {
- return;
- }
- }
-
- if (mCurrentLogReceiver == null || mCurrentLogReceiver.isCancelled()) {
- // logcat was stopped/cancelled before the device became ready.
- return;
- }
-
- try {
- mCurrentLoggedDevice = device;
- synchronized (mLock) {
- mCurrentEventLogParser = new EventLogParser();
- mCurrentEventLogParser.init(device);
- }
-
- // update the event display with the new parser.
- updateEventDisplays();
-
- // prepare the temp file that will contain the raw data
- mTempFile = File.createTempFile("android-event-", ".log");
-
- device.runEventLogService(mCurrentLogReceiver);
- } catch (Exception e) {
- Log.e("EventLog", e);
- } finally {
- }
- }
- }.start();
- }
- }
-
- private void startEventLogFromFiles(final String fileName) {
- // if we have a logcat already running
- if (mCurrentLogReceiver != null) {
- stopEventLog(false);
- }
- mCurrentLoggedDevice = null;
- mCurrentLogFile = null;
-
- // create a new output receiver
- mCurrentLogReceiver = new LogReceiver(this);
-
- mSaveAction.setEnabled(false);
-
- // start the logcat in a different thread
- new Thread("EventLog") { //$NON-NLS-1$
- @Override
- public void run() {
- try {
- mCurrentLogFile = fileName;
- synchronized (mLock) {
- mCurrentEventLogParser = new EventLogParser();
- if (mCurrentEventLogParser.init(fileName + TAG_FILE_EXT) == false) {
- mCurrentEventLogParser = null;
- Log.logAndDisplay(LogLevel.ERROR, "EventLog",
- String.format("Failure to read %1$s", fileName + TAG_FILE_EXT));
- return;
- }
- }
-
- // update the event display with the new parser.
- updateEventDisplays();
-
- runLocalEventLogService(fileName, mCurrentLogReceiver);
- } catch (Exception e) {
- Log.e("EventLog", e);
- } finally {
- }
- }
- }.start();
- }
-
- private void startEventLogFromContent(final String[] tags, final String[] log) {
- // if we have a logcat already running
- if (mCurrentLogReceiver != null) {
- stopEventLog(false);
- }
- mCurrentLoggedDevice = null;
- mCurrentLogFile = null;
-
- // create a new output receiver
- mCurrentLogReceiver = new LogReceiver(this);
-
- mSaveAction.setEnabled(false);
-
- // start the logcat in a different thread
- new Thread("EventLog") { //$NON-NLS-1$
- @Override
- public void run() {
- try {
- synchronized (mLock) {
- mCurrentEventLogParser = new EventLogParser();
- if (mCurrentEventLogParser.init(tags) == false) {
- mCurrentEventLogParser = null;
- return;
- }
- }
-
- // update the event display with the new parser.
- updateEventDisplays();
-
- runLocalEventLogService(log, mCurrentLogReceiver);
- } catch (Exception e) {
- Log.e("EventLog", e);
- } finally {
- }
- }
- }.start();
- }
-
-
- public void stopEventLog(boolean inUiThread) {
- if (mCurrentLogReceiver != null) {
- mCurrentLogReceiver.cancel();
-
- // when the thread finishes, no one will reference that object
- // and it'll be destroyed
- synchronized (mLock) {
- mCurrentLogReceiver = null;
- mCurrentEventLogParser = null;
-
- mCurrentLoggedDevice = null;
- mEvents.clear();
- mNewEvents.clear();
- mPendingDisplay = false;
- }
-
- resetUI(inUiThread);
- }
-
- if (mTempFile != null) {
- mTempFile.delete();
- mTempFile = null;
- }
- }
-
- private void resetUI(boolean inUiThread) {
- mEvents.clear();
-
- // the ui is static we just empty it.
- if (inUiThread) {
- resetUiFromUiThread();
- } else {
- try {
- Display d = mBottomParentPanel.getDisplay();
-
- // run sync as we need to update right now.
- d.syncExec(new Runnable() {
- @Override
- public void run() {
- if (mBottomParentPanel.isDisposed() == false) {
- resetUiFromUiThread();
- }
- }
- });
- } catch (SWTException e) {
- // display is disposed, we're quitting. Do nothing.
- }
- }
- }
-
- private void resetUiFromUiThread() {
- synchronized (mLock) {
- for (EventDisplay eventDisplay : mEventDisplays) {
- eventDisplay.resetUI();
- }
- }
- mOptionsAction.setEnabled(false);
- mClearAction.setEnabled(false);
- mSaveAction.setEnabled(false);
- }
-
- private void prepareDisplayUi() {
- mBottomPanel = new Composite(mBottomParentPanel, SWT.NONE);
- mBottomParentPanel.setContent(mBottomPanel);
- }
-
- private void createDisplayUi() {
- RowLayout rowLayout = new RowLayout();
- rowLayout.wrap = true;
- rowLayout.pack = false;
- rowLayout.justify = true;
- rowLayout.fill = true;
- rowLayout.type = SWT.HORIZONTAL;
- mBottomPanel.setLayout(rowLayout);
-
- IPreferenceStore store = DdmUiPreferences.getStore();
- int displayWidth = store.getInt(PREFS_DISPLAY_WIDTH);
- int displayHeight = store.getInt(PREFS_DISPLAY_HEIGHT);
-
- for (EventDisplay eventDisplay : mEventDisplays) {
- Control c = eventDisplay.createComposite(mBottomPanel, mCurrentEventLogParser, this);
- if (c != null) {
- RowData rd = new RowData();
- rd.height = displayHeight;
- rd.width = displayWidth;
- c.setLayoutData(rd);
- }
-
- Table table = eventDisplay.getTable();
- if (table != null) {
- addTableToFocusListener(table);
- }
- }
-
- mBottomPanel.layout();
- mBottomParentPanel.setMinSize(mBottomPanel.computeSize(SWT.DEFAULT, SWT.DEFAULT));
- mBottomParentPanel.layout();
- }
-
- /**
- * Rebuild the display ui.
- */
- @UiThread
- private void rebuildUi() {
- synchronized (mLock) {
- // we need to rebuild the ui. First we get rid of it.
- mBottomPanel.dispose();
- mBottomPanel = null;
-
- prepareDisplayUi();
- createDisplayUi();
-
- // and fill it
-
- boolean start_event = false;
- synchronized (mNewEvents) {
- mNewEvents.addAll(0, mEvents);
-
- if (mPendingDisplay == false) {
- mPendingDisplay = true;
- start_event = true;
- }
- }
-
- if (start_event) {
- scheduleUIEventHandler();
- }
-
- Rectangle r = mBottomParentPanel.getClientArea();
- mBottomParentPanel.setMinSize(mBottomPanel.computeSize(r.width,
- SWT.DEFAULT));
- }
- }
-
-
- /**
- * Processes a new {@link LogEntry} by parsing it with {@link EventLogParser} and displaying it.
- * @param entry The new log entry
- * @see LogReceiver.ILogListener#newEntry(LogEntry)
- */
- @Override
- @WorkerThread
- public void newEntry(LogEntry entry) {
- synchronized (mLock) {
- if (mCurrentEventLogParser != null) {
- EventContainer event = mCurrentEventLogParser.parse(entry);
- if (event != null) {
- handleNewEvent(event);
- }
- }
- }
- }
-
- @WorkerThread
- private void handleNewEvent(EventContainer event) {
- // add the event to the generic list
- mEvents.add(event);
-
- // add to the list of events that needs to be displayed, and trigger a
- // new display if needed.
- boolean start_event = false;
- synchronized (mNewEvents) {
- mNewEvents.add(event);
-
- if (mPendingDisplay == false) {
- mPendingDisplay = true;
- start_event = true;
- }
- }
-
- if (start_event == false) {
- // we're done
- return;
- }
-
- scheduleUIEventHandler();
- }
-
- /**
- * Schedules the UI thread to execute a {@link Runnable} calling {@link #displayNewEvents()}.
- */
- private void scheduleUIEventHandler() {
- try {
- Display d = mBottomParentPanel.getDisplay();
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (mBottomParentPanel.isDisposed() == false) {
- if (mCurrentEventLogParser != null) {
- displayNewEvents();
- }
- }
- }
- });
- } catch (SWTException e) {
- // if the ui is disposed, do nothing
- }
- }
-
- /**
- * Processes raw data coming from the log service.
- * @see LogReceiver.ILogListener#newData(byte[], int, int)
- */
- @Override
- public void newData(byte[] data, int offset, int length) {
- if (mTempFile != null) {
- try {
- FileOutputStream fos = new FileOutputStream(mTempFile, true /* append */);
- fos.write(data, offset, length);
- fos.close();
- } catch (FileNotFoundException e) {
- } catch (IOException e) {
- }
- }
- }
-
- @UiThread
- private void displayNewEvents() {
- // never display more than 1,000 events in this loop. We can't do too much in the UI thread.
- int count = 0;
-
- // prepare the displays
- for (EventDisplay eventDisplay : mEventDisplays) {
- eventDisplay.startMultiEventDisplay();
- }
-
- // display the new events
- EventContainer event = null;
- boolean need_to_reloop = false;
- do {
- // get the next event to display.
- synchronized (mNewEvents) {
- if (mNewEvents.size() > 0) {
- if (count > 200) {
- // there are still events to be displayed, but we don't want to hog the
- // UI thread for too long, so we stop this runnable, but launch a new
- // one to keep going.
- need_to_reloop = true;
- event = null;
- } else {
- event = mNewEvents.remove(0);
- count++;
- }
- } else {
- // we're done.
- event = null;
- mPendingDisplay = false;
- }
- }
-
- if (event != null) {
- // notify the event display
- for (EventDisplay eventDisplay : mEventDisplays) {
- eventDisplay.newEvent(event, mCurrentEventLogParser);
- }
- }
- } while (event != null);
-
- // we're done displaying events.
- for (EventDisplay eventDisplay : mEventDisplays) {
- eventDisplay.endMultiEventDisplay();
- }
-
- // if needed, ask the UI thread to re-run this method.
- if (need_to_reloop) {
- scheduleUIEventHandler();
- }
- }
-
- /**
- * Loads the {@link EventDisplay}s from the preference store.
- */
- private void loadEventDisplays() {
- IPreferenceStore store = DdmUiPreferences.getStore();
- String storage = store.getString(PREFS_EVENT_DISPLAY);
-
- if (storage.length() > 0) {
- String[] values = storage.split(Pattern.quote(EVENT_DISPLAY_STORAGE_SEPARATOR));
-
- for (String value : values) {
- EventDisplay eventDisplay = EventDisplay.load(value);
- if (eventDisplay != null) {
- mEventDisplays.add(eventDisplay);
- }
- }
- }
- }
-
- /**
- * Saves the {@link EventDisplay}s into the {@link DdmUiPreferences} store.
- */
- private void saveEventDisplays() {
- IPreferenceStore store = DdmUiPreferences.getStore();
-
- boolean first = true;
- StringBuilder sb = new StringBuilder();
-
- for (EventDisplay eventDisplay : mEventDisplays) {
- String storage = eventDisplay.getStorageString();
- if (storage != null) {
- if (first == false) {
- sb.append(EVENT_DISPLAY_STORAGE_SEPARATOR);
- } else {
- first = false;
- }
-
- sb.append(storage);
- }
- }
-
- store.setValue(PREFS_EVENT_DISPLAY, sb.toString());
- }
-
- /**
- * Updates the {@link EventDisplay} with the new {@link EventLogParser}.
- * <p/>
- * This will run asynchronously in the UI thread.
- */
- @WorkerThread
- private void updateEventDisplays() {
- try {
- Display d = mBottomParentPanel.getDisplay();
-
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- if (mBottomParentPanel.isDisposed() == false) {
- for (EventDisplay eventDisplay : mEventDisplays) {
- eventDisplay.setNewLogParser(mCurrentEventLogParser);
- }
-
- mOptionsAction.setEnabled(true);
- mClearAction.setEnabled(true);
- if (mCurrentLogFile == null) {
- mSaveAction.setEnabled(true);
- } else {
- mSaveAction.setEnabled(false);
- }
- }
- }
- });
- } catch (SWTException e) {
- // display is disposed: do nothing.
- }
- }
-
- @Override
- @UiThread
- public void columnResized(int index, TableColumn sourceColumn) {
- for (EventDisplay eventDisplay : mEventDisplays) {
- eventDisplay.resizeColumn(index, sourceColumn);
- }
- }
-
- /**
- * Runs an event log service out of a local file.
- * @param fileName the full file name of the local file containing the event log.
- * @param logReceiver the receiver that will handle the log
- * @throws IOException
- */
- @WorkerThread
- private void runLocalEventLogService(String fileName, LogReceiver logReceiver)
- throws IOException {
- byte[] buffer = new byte[256];
-
- FileInputStream fis = new FileInputStream(fileName);
- try {
- int count;
- while ((count = fis.read(buffer)) != -1) {
- logReceiver.parseNewData(buffer, 0, count);
- }
- } finally {
- fis.close();
- }
- }
-
- @WorkerThread
- private void runLocalEventLogService(String[] log, LogReceiver currentLogReceiver) {
- synchronized (mLock) {
- for (String line : log) {
- EventContainer event = mCurrentEventLogParser.parse(line);
- if (event != null) {
- handleNewEvent(event);
- }
- }
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventValueSelector.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventValueSelector.java
deleted file mode 100644
index e7c5196..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/EventValueSelector.java
+++ /dev/null
@@ -1,630 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.log.event;
-
-import com.android.ddmlib.log.EventContainer.CompareMethod;
-import com.android.ddmlib.log.EventContainer.EventValueType;
-import com.android.ddmlib.log.EventLogParser;
-import com.android.ddmlib.log.EventValueDescription;
-import com.android.ddmuilib.log.event.EventDisplay.OccurrenceDisplayDescriptor;
-import com.android.ddmuilib.log.event.EventDisplay.ValueDisplayDescriptor;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import java.util.ArrayList;
-import java.util.Map;
-import java.util.Set;
-
-final class EventValueSelector extends Dialog {
- private static final int DLG_WIDTH = 400;
- private static final int DLG_HEIGHT = 300;
-
- private Shell mParent;
- private Shell mShell;
- private boolean mEditStatus;
- private Combo mEventCombo;
- private Combo mValueCombo;
- private Combo mSeriesCombo;
- private Button mDisplayPidCheckBox;
- private Combo mFilterCombo;
- private Combo mFilterMethodCombo;
- private Text mFilterValue;
- private Button mOkButton;
-
- private EventLogParser mLogParser;
- private OccurrenceDisplayDescriptor mDescriptor;
-
- /** list of event integer in the order of the combo. */
- private Integer[] mEventTags;
-
- /** list of indices in the {@link EventValueDescription} array of the current event
- * that are of type string. This lets us get back the {@link EventValueDescription} from the
- * index in the Series {@link Combo}.
- */
- private final ArrayList<Integer> mSeriesIndices = new ArrayList<Integer>();
-
- public EventValueSelector(Shell parent) {
- super(parent, SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
- }
-
- /**
- * Opens the display option dialog to edit a new descriptor.
- * @param decriptorClass the class of the object to instantiate. Must extend
- * {@link OccurrenceDisplayDescriptor}
- * @param logParser
- * @return true if the object is to be created, false if the creation was canceled.
- */
- boolean open(Class<? extends OccurrenceDisplayDescriptor> descriptorClass,
- EventLogParser logParser) {
- try {
- OccurrenceDisplayDescriptor descriptor = descriptorClass.newInstance();
- setModified();
- return open(descriptor, logParser);
- } catch (InstantiationException e) {
- return false;
- } catch (IllegalAccessException e) {
- return false;
- }
- }
-
- /**
- * Opens the display option dialog, to edit a {@link OccurrenceDisplayDescriptor} object or
- * a {@link ValueDisplayDescriptor} object.
- * @param descriptor The descriptor to edit.
- * @return true if the object was modified.
- */
- boolean open(OccurrenceDisplayDescriptor descriptor, EventLogParser logParser) {
- // make a copy of the descriptor as we'll use a working copy.
- if (descriptor instanceof ValueDisplayDescriptor) {
- mDescriptor = new ValueDisplayDescriptor((ValueDisplayDescriptor)descriptor);
- } else if (descriptor instanceof OccurrenceDisplayDescriptor) {
- mDescriptor = new OccurrenceDisplayDescriptor(descriptor);
- } else {
- return false;
- }
-
- mLogParser = logParser;
-
- createUI();
-
- if (mParent == null || mShell == null) {
- return false;
- }
-
- loadValueDescriptor();
-
- checkValidity();
-
- // Set the dialog size.
- try {
- mShell.setMinimumSize(DLG_WIDTH, DLG_HEIGHT);
- Rectangle r = mParent.getBounds();
- // get the center new top left.
- int cx = r.x + r.width/2;
- int x = cx - DLG_WIDTH / 2;
- int cy = r.y + r.height/2;
- int y = cy - DLG_HEIGHT / 2;
- mShell.setBounds(x, y, DLG_WIDTH, DLG_HEIGHT);
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- mShell.layout();
-
- // actually open the dialog
- mShell.open();
-
- // event loop until the dialog is closed.
- Display display = mParent.getDisplay();
- while (!mShell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- return mEditStatus;
- }
-
- OccurrenceDisplayDescriptor getDescriptor() {
- return mDescriptor;
- }
-
- private void createUI() {
- GridData gd;
-
- mParent = getParent();
- mShell = new Shell(mParent, getStyle());
- mShell.setText("Event Display Configuration");
-
- mShell.setLayout(new GridLayout(2, false));
-
- Label l = new Label(mShell, SWT.NONE);
- l.setText("Event:");
-
- mEventCombo = new Combo(mShell, SWT.DROP_DOWN | SWT.READ_ONLY);
- mEventCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // the event tag / event name map
- Map<Integer, String> eventTagMap = mLogParser.getTagMap();
- Map<Integer, EventValueDescription[]> eventInfoMap = mLogParser.getEventInfoMap();
- Set<Integer> keys = eventTagMap.keySet();
- ArrayList<Integer> list = new ArrayList<Integer>();
- for (Integer i : keys) {
- if (eventInfoMap.get(i) != null) {
- String eventName = eventTagMap.get(i);
- mEventCombo.add(eventName);
-
- list.add(i);
- }
- }
- mEventTags = list.toArray(new Integer[list.size()]);
-
- mEventCombo.addSelectionListener(new SelectionAdapter() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- handleEventComboSelection();
- setModified();
- }
- });
-
- l = new Label(mShell, SWT.NONE);
- l.setText("Value:");
-
- mValueCombo = new Combo(mShell, SWT.DROP_DOWN | SWT.READ_ONLY);
- mValueCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mValueCombo.addSelectionListener(new SelectionAdapter() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- handleValueComboSelection();
- setModified();
- }
- });
-
- l = new Label(mShell, SWT.NONE);
- l.setText("Series Name:");
-
- mSeriesCombo = new Combo(mShell, SWT.DROP_DOWN | SWT.READ_ONLY);
- mSeriesCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mSeriesCombo.addSelectionListener(new SelectionAdapter() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- handleSeriesComboSelection();
- setModified();
- }
- });
-
- // empty comp
- new Composite(mShell, SWT.NONE).setLayoutData(gd = new GridData());
- gd.heightHint = gd.widthHint = 0;
-
- mDisplayPidCheckBox = new Button(mShell, SWT.CHECK);
- mDisplayPidCheckBox.setText("Also Show pid");
- mDisplayPidCheckBox.setEnabled(false);
- mDisplayPidCheckBox.addSelectionListener(new SelectionAdapter() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- mDescriptor.includePid = mDisplayPidCheckBox.getSelection();
- setModified();
- }
- });
-
- l = new Label(mShell, SWT.NONE);
- l.setText("Filter By:");
-
- mFilterCombo = new Combo(mShell, SWT.DROP_DOWN | SWT.READ_ONLY);
- mFilterCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mFilterCombo.addSelectionListener(new SelectionAdapter() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- handleFilterComboSelection();
- setModified();
- }
- });
-
- l = new Label(mShell, SWT.NONE);
- l.setText("Filter Method:");
-
- mFilterMethodCombo = new Combo(mShell, SWT.DROP_DOWN | SWT.READ_ONLY);
- mFilterMethodCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- for (CompareMethod method : CompareMethod.values()) {
- mFilterMethodCombo.add(method.toString());
- }
- mFilterMethodCombo.select(0);
- mFilterMethodCombo.addSelectionListener(new SelectionAdapter() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- handleFilterMethodComboSelection();
- setModified();
- }
- });
-
- l = new Label(mShell, SWT.NONE);
- l.setText("Filter Value:");
-
- mFilterValue = new Text(mShell, SWT.BORDER | SWT.SINGLE);
- mFilterValue.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mFilterValue.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- if (mDescriptor.filterValueIndex != -1) {
- // get the current selection in the event combo
- int index = mEventCombo.getSelectionIndex();
-
- if (index != -1) {
- // match it to an event
- int eventTag = mEventTags[index];
- mDescriptor.eventTag = eventTag;
-
- // get the EventValueDescription for this tag
- EventValueDescription valueDesc = mLogParser.getEventInfoMap()
- .get(eventTag)[mDescriptor.filterValueIndex];
-
- // let the EventValueDescription convert the String value into an object
- // of the proper type.
- mDescriptor.filterValue = valueDesc.getObjectFromString(
- mFilterValue.getText().trim());
- setModified();
- }
- }
- }
- });
-
- // add a separator spanning the 2 columns
-
- l = new Label(mShell, SWT.SEPARATOR | SWT.HORIZONTAL);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- l.setLayoutData(gd);
-
- // add a composite to hold the ok/cancel button, no matter what the columns size are.
- Composite buttonComp = new Composite(mShell, SWT.NONE);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- buttonComp.setLayoutData(gd);
- GridLayout gl;
- buttonComp.setLayout(gl = new GridLayout(6, true));
- gl.marginHeight = gl.marginWidth = 0;
-
- Composite padding = new Composite(mShell, SWT.NONE);
- padding.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- mOkButton = new Button(buttonComp, SWT.PUSH);
- mOkButton.setText("OK");
- mOkButton.setLayoutData(new GridData(GridData.CENTER));
- mOkButton.addSelectionListener(new SelectionAdapter() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- mShell.close();
- }
- });
-
- padding = new Composite(mShell, SWT.NONE);
- padding.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- padding = new Composite(mShell, SWT.NONE);
- padding.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Button cancelButton = new Button(buttonComp, SWT.PUSH);
- cancelButton.setText("Cancel");
- cancelButton.setLayoutData(new GridData(GridData.CENTER));
- cancelButton.addSelectionListener(new SelectionAdapter() {
- /* (non-Javadoc)
- * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- @Override
- public void widgetSelected(SelectionEvent e) {
- // cancel the edit
- mEditStatus = false;
- mShell.close();
- }
- });
-
- padding = new Composite(mShell, SWT.NONE);
- padding.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- mShell.addListener(SWT.Close, new Listener() {
- @Override
- public void handleEvent(Event event) {
- event.doit = true;
- }
- });
- }
-
- private void setModified() {
- mEditStatus = true;
- }
-
- private void handleEventComboSelection() {
- // get the current selection in the event combo
- int index = mEventCombo.getSelectionIndex();
-
- if (index != -1) {
- // match it to an event
- int eventTag = mEventTags[index];
- mDescriptor.eventTag = eventTag;
-
- // get the EventValueDescription for this tag
- EventValueDescription[] values = mLogParser.getEventInfoMap().get(eventTag);
-
- // fill the combo for the values
- mValueCombo.removeAll();
- if (values != null) {
- if (mDescriptor instanceof ValueDisplayDescriptor) {
- ValueDisplayDescriptor valueDescriptor = (ValueDisplayDescriptor)mDescriptor;
-
- mValueCombo.setEnabled(true);
- for (EventValueDescription value : values) {
- mValueCombo.add(value.toString());
- }
-
- if (valueDescriptor.valueIndex != -1) {
- mValueCombo.select(valueDescriptor.valueIndex);
- } else {
- mValueCombo.clearSelection();
- }
- } else {
- mValueCombo.setEnabled(false);
- }
-
- // fill the axis combo
- mSeriesCombo.removeAll();
- mSeriesCombo.setEnabled(false);
- mSeriesIndices.clear();
- int axisIndex = 0;
- int selectionIndex = -1;
- for (EventValueDescription value : values) {
- if (value.getEventValueType() == EventValueType.STRING) {
- mSeriesCombo.add(value.getName());
- mSeriesCombo.setEnabled(true);
- mSeriesIndices.add(axisIndex);
-
- if (mDescriptor.seriesValueIndex != -1 &&
- mDescriptor.seriesValueIndex == axisIndex) {
- selectionIndex = axisIndex;
- }
- }
- axisIndex++;
- }
-
- if (mSeriesCombo.isEnabled()) {
- mSeriesCombo.add("default (pid)", 0 /* index */);
- mSeriesIndices.add(0 /* index */, -1 /* value */);
-
- // +1 because we added another item at index 0
- mSeriesCombo.select(selectionIndex + 1);
-
- if (selectionIndex >= 0) {
- mDisplayPidCheckBox.setSelection(mDescriptor.includePid);
- mDisplayPidCheckBox.setEnabled(true);
- } else {
- mDisplayPidCheckBox.setEnabled(false);
- mDisplayPidCheckBox.setSelection(false);
- }
- } else {
- mDisplayPidCheckBox.setSelection(false);
- mDisplayPidCheckBox.setEnabled(false);
- }
-
- // fill the filter combo
- mFilterCombo.setEnabled(true);
- mFilterCombo.removeAll();
- mFilterCombo.add("(no filter)");
- for (EventValueDescription value : values) {
- mFilterCombo.add(value.toString());
- }
-
- // select the current filter
- mFilterCombo.select(mDescriptor.filterValueIndex + 1);
- mFilterMethodCombo.select(getFilterMethodIndex(mDescriptor.filterCompareMethod));
-
- // fill the current filter value
- if (mDescriptor.filterValueIndex != -1) {
- EventValueDescription valueInfo = values[mDescriptor.filterValueIndex];
- if (valueInfo.checkForType(mDescriptor.filterValue)) {
- mFilterValue.setText(mDescriptor.filterValue.toString());
- } else {
- mFilterValue.setText("");
- }
- } else {
- mFilterValue.setText("");
- }
- } else {
- disableSubCombos();
- }
- } else {
- disableSubCombos();
- }
-
- checkValidity();
- }
-
- /**
- *
- */
- private void disableSubCombos() {
- mValueCombo.removeAll();
- mValueCombo.clearSelection();
- mValueCombo.setEnabled(false);
-
- mSeriesCombo.removeAll();
- mSeriesCombo.clearSelection();
- mSeriesCombo.setEnabled(false);
-
- mDisplayPidCheckBox.setEnabled(false);
- mDisplayPidCheckBox.setSelection(false);
-
- mFilterCombo.removeAll();
- mFilterCombo.clearSelection();
- mFilterCombo.setEnabled(false);
-
- mFilterValue.setEnabled(false);
- mFilterValue.setText("");
- mFilterMethodCombo.setEnabled(false);
- }
-
- private void handleValueComboSelection() {
- ValueDisplayDescriptor valueDescriptor = (ValueDisplayDescriptor)mDescriptor;
-
- // get the current selection in the value combo
- int index = mValueCombo.getSelectionIndex();
- valueDescriptor.valueIndex = index;
-
- // for now set the built-in name
-
- // get the current selection in the event combo
- int eventIndex = mEventCombo.getSelectionIndex();
-
- // match it to an event
- int eventTag = mEventTags[eventIndex];
-
- // get the EventValueDescription for this tag
- EventValueDescription[] values = mLogParser.getEventInfoMap().get(eventTag);
-
- valueDescriptor.valueName = values[index].getName();
-
- checkValidity();
- }
-
- private void handleSeriesComboSelection() {
- // get the current selection in the axis combo
- int index = mSeriesCombo.getSelectionIndex();
-
- // get the actual value index from the list.
- int valueIndex = mSeriesIndices.get(index);
-
- mDescriptor.seriesValueIndex = valueIndex;
-
- if (index > 0) {
- mDisplayPidCheckBox.setEnabled(true);
- mDisplayPidCheckBox.setSelection(mDescriptor.includePid);
- } else {
- mDisplayPidCheckBox.setSelection(false);
- mDisplayPidCheckBox.setEnabled(false);
- }
- }
-
- private void handleFilterComboSelection() {
- // get the current selection in the axis combo
- int index = mFilterCombo.getSelectionIndex();
-
- // decrement index by 1 since the item 0 means
- // no filter (index = -1), and the rest is offset by 1
- index--;
-
- mDescriptor.filterValueIndex = index;
-
- if (index != -1) {
- mFilterValue.setEnabled(true);
- mFilterMethodCombo.setEnabled(true);
- if (mDescriptor.filterValue instanceof String) {
- mFilterValue.setText((String)mDescriptor.filterValue);
- }
- } else {
- mFilterValue.setText("");
- mFilterValue.setEnabled(false);
- mFilterMethodCombo.setEnabled(false);
- }
- }
-
- private void handleFilterMethodComboSelection() {
- // get the current selection in the axis combo
- int index = mFilterMethodCombo.getSelectionIndex();
- CompareMethod method = CompareMethod.values()[index];
-
- mDescriptor.filterCompareMethod = method;
- }
-
- /**
- * Returns the index of the filter method
- * @param filterCompareMethod the {@link CompareMethod} enum.
- */
- private int getFilterMethodIndex(CompareMethod filterCompareMethod) {
- CompareMethod[] values = CompareMethod.values();
- for (int i = 0 ; i < values.length ; i++) {
- if (values[i] == filterCompareMethod) {
- return i;
- }
- }
- return -1;
- }
-
-
- private void loadValueDescriptor() {
- // get the index from the eventTag.
- int eventIndex = 0;
- int comboIndex = -1;
- for (int i : mEventTags) {
- if (i == mDescriptor.eventTag) {
- comboIndex = eventIndex;
- break;
- }
- eventIndex++;
- }
-
- if (comboIndex == -1) {
- mEventCombo.clearSelection();
- } else {
- mEventCombo.select(comboIndex);
- }
-
- // get the event from the descriptor
- handleEventComboSelection();
- }
-
- private void checkValidity() {
- mOkButton.setEnabled(mEventCombo.getSelectionIndex() != -1 &&
- (((mDescriptor instanceof ValueDisplayDescriptor) == false) ||
- mValueCombo.getSelectionIndex() != -1));
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/OccurrenceRenderer.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/OccurrenceRenderer.java
deleted file mode 100644
index 3af1447..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/OccurrenceRenderer.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.log.event;
-
-import org.jfree.chart.axis.ValueAxis;
-import org.jfree.chart.plot.CrosshairState;
-import org.jfree.chart.plot.PlotOrientation;
-import org.jfree.chart.plot.PlotRenderingInfo;
-import org.jfree.chart.plot.XYPlot;
-import org.jfree.chart.renderer.xy.XYItemRendererState;
-import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
-import org.jfree.data.time.TimeSeriesCollection;
-import org.jfree.data.xy.XYDataset;
-import org.jfree.ui.RectangleEdge;
-
-import java.awt.Graphics2D;
-import java.awt.Paint;
-import java.awt.Stroke;
-import java.awt.geom.Line2D;
-import java.awt.geom.Rectangle2D;
-
-/**
- * Custom renderer to render event occurrence. This rendered ignores the y value, and simply
- * draws a line from min to max at the time of the item.
- */
-public class OccurrenceRenderer extends XYLineAndShapeRenderer {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public void drawItem(Graphics2D g2,
- XYItemRendererState state,
- Rectangle2D dataArea,
- PlotRenderingInfo info,
- XYPlot plot,
- ValueAxis domainAxis,
- ValueAxis rangeAxis,
- XYDataset dataset,
- int series,
- int item,
- CrosshairState crosshairState,
- int pass) {
- TimeSeriesCollection timeDataSet = (TimeSeriesCollection)dataset;
-
- // get the x value for the series/item.
- double x = timeDataSet.getX(series, item).doubleValue();
-
- // get the min/max of the range axis
- double yMin = rangeAxis.getLowerBound();
- double yMax = rangeAxis.getUpperBound();
-
- RectangleEdge domainEdge = plot.getDomainAxisEdge();
- RectangleEdge rangeEdge = plot.getRangeAxisEdge();
-
- // convert the coordinates to java2d.
- double x2D = domainAxis.valueToJava2D(x, dataArea, domainEdge);
- double yMin2D = rangeAxis.valueToJava2D(yMin, dataArea, rangeEdge);
- double yMax2D = rangeAxis.valueToJava2D(yMax, dataArea, rangeEdge);
-
- // get the paint information for the series/item
- Paint p = getItemPaint(series, item);
- Stroke s = getItemStroke(series, item);
-
- Line2D line = null;
- PlotOrientation orientation = plot.getOrientation();
- if (orientation == PlotOrientation.HORIZONTAL) {
- line = new Line2D.Double(yMin2D, x2D, yMax2D, x2D);
- }
- else if (orientation == PlotOrientation.VERTICAL) {
- line = new Line2D.Double(x2D, yMin2D, x2D, yMax2D);
- }
- g2.setPaint(p);
- g2.setStroke(s);
- g2.draw(line);
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/SyncCommon.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/SyncCommon.java
deleted file mode 100644
index 0fa6f28..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/log/event/SyncCommon.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.log.event;
-
-import com.android.ddmlib.log.EventContainer;
-import com.android.ddmlib.log.EventLogParser;
-import com.android.ddmlib.log.InvalidTypeException;
-
-import java.awt.Color;
-
-abstract public class SyncCommon extends EventDisplay {
-
- // State information while processing the event stream
- private int mLastState; // 0 if event started, 1 if event stopped
- private long mLastStartTime; // ms
- private long mLastStopTime; //ms
- private String mLastDetails;
- private int mLastSyncSource; // poll, server, user, etc.
-
- // Some common variables for sync display. These define the sync backends
- //and how they should be displayed.
- protected static final int CALENDAR = 0;
- protected static final int GMAIL = 1;
- protected static final int FEEDS = 2;
- protected static final int CONTACTS = 3;
- protected static final int ERRORS = 4;
- protected static final int NUM_AUTHS = (CONTACTS + 1);
- protected static final String AUTH_NAMES[] = {"Calendar", "Gmail", "Feeds", "Contacts",
- "Errors"};
- protected static final Color AUTH_COLORS[] = {Color.MAGENTA, Color.GREEN, Color.BLUE,
- Color.ORANGE, Color.RED};
-
- // Values from data/etc/event-log-tags
- final int EVENT_SYNC = 2720;
- final int EVENT_TICKLE = 2742;
- final int EVENT_SYNC_DETAILS = 2743;
- final int EVENT_CONTACTS_AGGREGATION = 2747;
-
- protected SyncCommon(String name) {
- super(name);
- }
-
- /**
- * Resets the display.
- */
- @Override
- void resetUI() {
- mLastStartTime = 0;
- mLastStopTime = 0;
- mLastState = -1;
- mLastSyncSource = -1;
- mLastDetails = "";
- }
-
- /**
- * Updates the display with a new event. This is the main entry point for
- * each event. This method has the logic to tie together the start event,
- * stop event, and details event into one graph item. The combined sync event
- * is handed to the subclass via processSycnEvent. Note that the details
- * can happen before or after the stop event.
- *
- * @param event The event
- * @param logParser The parser providing the event.
- */
- @Override
- void newEvent(EventContainer event, EventLogParser logParser) {
- try {
- if (event.mTag == EVENT_SYNC) {
- int state = Integer.parseInt(event.getValueAsString(1));
- if (state == 0) { // start
- mLastStartTime = (long) event.sec * 1000L + (event.nsec / 1000000L);
- mLastState = 0;
- mLastSyncSource = Integer.parseInt(event.getValueAsString(2));
- mLastDetails = "";
- } else if (state == 1) { // stop
- if (mLastState == 0) {
- mLastStopTime = (long) event.sec * 1000L + (event.nsec / 1000000L);
- if (mLastStartTime == 0) {
- // Log starts with a stop event
- mLastStartTime = mLastStopTime;
- }
- int auth = getAuth(event.getValueAsString(0));
- processSyncEvent(event, auth, mLastStartTime, mLastStopTime, mLastDetails,
- true, mLastSyncSource);
- mLastState = 1;
- }
- }
- } else if (event.mTag == EVENT_SYNC_DETAILS) {
- mLastDetails = event.getValueAsString(3);
- if (mLastState != 0) { // Not inside event
- long updateTime = (long) event.sec * 1000L + (event.nsec / 1000000L);
- if (updateTime - mLastStopTime <= 250) {
- // Got details within 250ms after event, so delete and re-insert
- // Details later than 250ms (arbitrary) are discarded as probably
- // unrelated.
- int auth = getAuth(event.getValueAsString(0));
- processSyncEvent(event, auth, mLastStartTime, mLastStopTime, mLastDetails,
- false, mLastSyncSource);
- }
- }
- } else if (event.mTag == EVENT_CONTACTS_AGGREGATION) {
- long stopTime = (long) event.sec * 1000L + (event.nsec / 1000000L);
- long startTime = stopTime - Long.parseLong(event.getValueAsString(0));
- String details;
- int count = Integer.parseInt(event.getValueAsString(1));
- if (count < 0) {
- details = "g" + (-count);
- } else {
- details = "G" + count;
- }
- processSyncEvent(event, CONTACTS, startTime, stopTime, details,
- true /* newEvent */, mLastSyncSource);
- }
- } catch (InvalidTypeException e) {
- }
- }
-
- /**
- * Callback hook for subclass to process a sync event. newEvent has the logic
- * to combine start and stop events and passes a processed event to the
- * subclass.
- *
- * @param event The sync event
- * @param auth The sync authority
- * @param startTime Start time (ms) of events
- * @param stopTime Stop time (ms) of events
- * @param details Details associated with the event.
- * @param newEvent True if this event is a new sync event. False if this event
- * @param syncSource Poll, user, server, etc.
- */
- abstract void processSyncEvent(EventContainer event, int auth, long startTime, long stopTime,
- String details, boolean newEvent, int syncSource);
-
- /**
- * Converts authority name to auth number.
- *
- * @param authname "calendar", etc.
- * @return number series number associated with the authority
- */
- protected int getAuth(String authname) throws InvalidTypeException {
- if ("calendar".equals(authname) || "cl".equals(authname) ||
- "com.android.calendar".equals(authname)) {
- return CALENDAR;
- } else if ("contacts".equals(authname) || "cp".equals(authname) ||
- "com.android.contacts".equals(authname)) {
- return CONTACTS;
- } else if ("subscribedfeeds".equals(authname)) {
- return FEEDS;
- } else if ("gmail-ls".equals(authname) || "mail".equals(authname)) {
- return GMAIL;
- } else if ("gmail-live".equals(authname)) {
- return GMAIL;
- } else if ("unknown".equals(authname)) {
- return -1; // Unknown tickles; discard
- } else {
- throw new InvalidTypeException("Unknown authname " + authname);
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/EditFilterDialog.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/EditFilterDialog.java
deleted file mode 100644
index 0e302ce..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/EditFilterDialog.java
+++ /dev/null
@@ -1,397 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmuilib.ImageLoader;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Dialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * Small dialog box to edit a static port number.
- */
-public class EditFilterDialog extends Dialog {
-
- private static final int DLG_WIDTH = 400;
- private static final int DLG_HEIGHT = 260;
-
- private static final String IMAGE_WARNING = "warning.png"; //$NON-NLS-1$
- private static final String IMAGE_EMPTY = "empty.png"; //$NON-NLS-1$
-
- private Shell mParent;
-
- private Shell mShell;
-
- private boolean mOk = false;
-
- /**
- * Filter being edited or created
- */
- private LogFilter mFilter;
-
- private String mName;
- private String mTag;
- private String mPid;
-
- /** Log level as an index of the drop-down combo
- * @see getLogLevel
- * @see getComboIndex
- */
- private int mLogLevel;
-
- private Button mOkButton;
-
- private Label mNameWarning;
- private Label mTagWarning;
- private Label mPidWarning;
-
- public EditFilterDialog(Shell parent) {
- super(parent, SWT.DIALOG_TRIM | SWT.BORDER | SWT.APPLICATION_MODAL);
- }
-
- public EditFilterDialog(Shell shell, LogFilter filter) {
- this(shell);
- mFilter = filter;
- }
-
- /**
- * Opens the dialog. The method will return when the user closes the dialog
- * somehow.
- *
- * @return true if ok was pressed, false if cancelled.
- */
- public boolean open() {
- createUI();
-
- if (mParent == null || mShell == null) {
- return false;
- }
-
- mShell.setMinimumSize(DLG_WIDTH, DLG_HEIGHT);
- Rectangle r = mParent.getBounds();
- // get the center new top left.
- int cx = r.x + r.width/2;
- int x = cx - DLG_WIDTH / 2;
- int cy = r.y + r.height/2;
- int y = cy - DLG_HEIGHT / 2;
- mShell.setBounds(x, y, DLG_WIDTH, DLG_HEIGHT);
-
- mShell.open();
-
- Display display = mParent.getDisplay();
- while (!mShell.isDisposed()) {
- if (!display.readAndDispatch())
- display.sleep();
- }
-
- // we're quitting with OK.
- // Lets update the filter if needed
- if (mOk) {
- // if it was a "Create filter" action we need to create it first.
- if (mFilter == null) {
- mFilter = new LogFilter(mName);
- }
-
- // setup the filter
- mFilter.setTagMode(mTag);
-
- if (mPid != null && mPid.length() > 0) {
- mFilter.setPidMode(Integer.parseInt(mPid));
- } else {
- mFilter.setPidMode(-1);
- }
-
- mFilter.setLogLevel(getLogLevel(mLogLevel));
- }
-
- return mOk;
- }
-
- public LogFilter getFilter() {
- return mFilter;
- }
-
- private void createUI() {
- mParent = getParent();
- mShell = new Shell(mParent, getStyle());
- mShell.setText("Log Filter");
-
- mShell.setLayout(new GridLayout(1, false));
-
- mShell.addListener(SWT.Close, new Listener() {
- @Override
- public void handleEvent(Event event) {
- }
- });
-
- // top part with the filter name
- Composite nameComposite = new Composite(mShell, SWT.NONE);
- nameComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
- nameComposite.setLayout(new GridLayout(3, false));
-
- Label l = new Label(nameComposite, SWT.NONE);
- l.setText("Filter Name:");
-
- final Text filterNameText = new Text(nameComposite,
- SWT.SINGLE | SWT.BORDER);
- if (mFilter != null) {
- mName = mFilter.getName();
- if (mName != null) {
- filterNameText.setText(mName);
- }
- }
- filterNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- filterNameText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- mName = filterNameText.getText().trim();
- validate();
- }
- });
-
- mNameWarning = new Label(nameComposite, SWT.NONE);
- mNameWarning.setImage(ImageLoader.getDdmUiLibLoader().loadImage(IMAGE_EMPTY,
- mShell.getDisplay()));
-
- // separator
- l = new Label(mShell, SWT.SEPARATOR | SWT.HORIZONTAL);
- l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
-
- // center part with the filter parameters
- Composite main = new Composite(mShell, SWT.NONE);
- main.setLayoutData(new GridData(GridData.FILL_BOTH));
- main.setLayout(new GridLayout(3, false));
-
- l = new Label(main, SWT.NONE);
- l.setText("by Log Tag:");
-
- final Text tagText = new Text(main, SWT.SINGLE | SWT.BORDER);
- if (mFilter != null) {
- mTag = mFilter.getTagFilter();
- if (mTag != null) {
- tagText.setText(mTag);
- }
- }
-
- tagText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- tagText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- mTag = tagText.getText().trim();
- validate();
- }
- });
-
- mTagWarning = new Label(main, SWT.NONE);
- mTagWarning.setImage(ImageLoader.getDdmUiLibLoader().loadImage(IMAGE_EMPTY,
- mShell.getDisplay()));
-
- l = new Label(main, SWT.NONE);
- l.setText("by pid:");
-
- final Text pidText = new Text(main, SWT.SINGLE | SWT.BORDER);
- if (mFilter != null) {
- if (mFilter.getPidFilter() != -1) {
- mPid = Integer.toString(mFilter.getPidFilter());
- } else {
- mPid = "";
- }
- pidText.setText(mPid);
- }
- pidText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- pidText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- mPid = pidText.getText().trim();
- validate();
- }
- });
-
- mPidWarning = new Label(main, SWT.NONE);
- mPidWarning.setImage(ImageLoader.getDdmUiLibLoader().loadImage(IMAGE_EMPTY,
- mShell.getDisplay()));
-
- l = new Label(main, SWT.NONE);
- l.setText("by Log level:");
-
- final Combo logCombo = new Combo(main, SWT.DROP_DOWN | SWT.READ_ONLY);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- logCombo.setLayoutData(gd);
-
- // add the labels
- logCombo.add("<none>");
- logCombo.add("Error");
- logCombo.add("Warning");
- logCombo.add("Info");
- logCombo.add("Debug");
- logCombo.add("Verbose");
-
- if (mFilter != null) {
- mLogLevel = getComboIndex(mFilter.getLogLevel());
- logCombo.select(mLogLevel);
- } else {
- logCombo.select(0);
- }
-
- logCombo.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- // get the selection
- mLogLevel = logCombo.getSelectionIndex();
- validate();
- }
- });
-
- // separator
- l = new Label(mShell, SWT.SEPARATOR | SWT.HORIZONTAL);
- l.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // bottom part with the ok/cancel
- Composite bottomComp = new Composite(mShell, SWT.NONE);
- bottomComp
- .setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_CENTER));
- bottomComp.setLayout(new GridLayout(2, true));
-
- mOkButton = new Button(bottomComp, SWT.NONE);
- mOkButton.setText("OK");
- mOkButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mOk = true;
- mShell.close();
- }
- });
- mOkButton.setEnabled(false);
- mShell.setDefaultButton(mOkButton);
-
- Button cancelButton = new Button(bottomComp, SWT.NONE);
- cancelButton.setText("Cancel");
- cancelButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- mShell.close();
- }
- });
-
- validate();
- }
-
- /**
- * Returns the log level from a combo index.
- * @param index the Combo index
- * @return a log level valid for the Log class.
- */
- protected int getLogLevel(int index) {
- if (index == 0) {
- return -1;
- }
-
- return 7 - index;
- }
-
- /**
- * Returns the index in the combo that matches the log level
- * @param logLevel The Log level.
- * @return the combo index
- */
- private int getComboIndex(int logLevel) {
- if (logLevel == -1) {
- return 0;
- }
-
- return 7 - logLevel;
- }
-
- /**
- * Validates the content of the 2 text fields and enable/disable "ok", while
- * setting up the warning/error message.
- */
- private void validate() {
-
- boolean result = true;
-
- // then we check it only contains digits.
- if (mPid != null) {
- if (mPid.matches("[0-9]*") == false) { //$NON-NLS-1$
- mPidWarning.setImage(ImageLoader.getDdmUiLibLoader().loadImage(
- IMAGE_WARNING,
- mShell.getDisplay()));
- mPidWarning.setToolTipText("PID must be a number"); //$NON-NLS-1$
- result = false;
- } else {
- mPidWarning.setImage(ImageLoader.getDdmUiLibLoader().loadImage(
- IMAGE_EMPTY,
- mShell.getDisplay()));
- mPidWarning.setToolTipText(null);
- }
- }
-
- // then we check it not contains character | or :
- if (mTag != null) {
- if (mTag.matches(".*[:|].*") == true) { //$NON-NLS-1$
- mTagWarning.setImage(ImageLoader.getDdmUiLibLoader().loadImage(
- IMAGE_WARNING,
- mShell.getDisplay()));
- mTagWarning.setToolTipText("Tag cannot contain | or :"); //$NON-NLS-1$
- result = false;
- } else {
- mTagWarning.setImage(ImageLoader.getDdmUiLibLoader().loadImage(
- IMAGE_EMPTY,
- mShell.getDisplay()));
- mTagWarning.setToolTipText(null);
- }
- }
-
- // then we check it not contains character | or :
- if (mName != null && mName.length() > 0) {
- if (mName.matches(".*[:|].*") == true) { //$NON-NLS-1$
- mNameWarning.setImage(ImageLoader.getDdmUiLibLoader().loadImage(
- IMAGE_WARNING,
- mShell.getDisplay()));
- mNameWarning.setToolTipText("Name cannot contain | or :"); //$NON-NLS-1$
- result = false;
- } else {
- mNameWarning.setImage(ImageLoader.getDdmUiLibLoader().loadImage(
- IMAGE_EMPTY,
- mShell.getDisplay()));
- mNameWarning.setToolTipText(null);
- }
- } else {
- result = false;
- }
-
- mOkButton.setEnabled(result);
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/ILogCatBufferChangeListener.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/ILogCatBufferChangeListener.java
deleted file mode 100644
index 2804629..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/ILogCatBufferChangeListener.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmlib.logcat.LogCatMessage;
-
-import java.util.List;
-
-/**
- * Listeners interested in changes in the logcat buffer should implement this interface.
- */
-public interface ILogCatBufferChangeListener {
- /**
- * Called when the logcat buffer changes.
- * @param addedMessages list of messages that were added to the logcat buffer
- * @param deletedMessages list of messages that were removed from the logcat buffer
- */
- void bufferChanged(List<LogCatMessage> addedMessages, List<LogCatMessage> deletedMessages);
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/ILogCatMessageSelectionListener.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/ILogCatMessageSelectionListener.java
deleted file mode 100644
index 728b518..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/ILogCatMessageSelectionListener.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmlib.logcat.LogCatMessage;
-
-/**
- * Classes interested in listening to user selection of logcat
- * messages should implement this interface.
- */
-public interface ILogCatMessageSelectionListener {
- void messageDoubleClicked(LogCatMessage m);
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterContentProvider.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterContentProvider.java
deleted file mode 100644
index 629b0e0..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterContentProvider.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmlib.logcat.LogCatFilter;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-import java.util.List;
-
-/**
- * A JFace content provider for logcat filter list, used in {@link LogCatPanel}.
- */
-public final class LogCatFilterContentProvider implements IStructuredContentProvider {
- @Override
- public void dispose() {
- }
-
- @Override
- public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
- }
-
- /**
- * Obtain the list of filters currently in use.
- * @param model list of {@link LogCatFilter}'s
- * @return array of {@link LogCatFilter} objects, or null.
- */
- @Override
- public Object[] getElements(Object model) {
- return ((List<?>) model).toArray();
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterData.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterData.java
deleted file mode 100644
index dbc34d8..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterData.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmlib.logcat.LogCatFilter;
-import com.android.ddmlib.logcat.LogCatMessage;
-
-import java.util.List;
-
-public class LogCatFilterData {
- private final LogCatFilter mFilter;
-
- /** Indicates the number of messages that match this filter, but have not
- * yet been read by the user. This is really metadata about this filter
- * necessary for the UI. If we ever end up needing to store more metadata,
- * then it is probably better to move it out into a separate class. */
- private int mUnreadCount;
-
- /** Indicates that this filter is transient, and should not be persisted
- * across Eclipse sessions. */
- private boolean mTransient;
-
- public LogCatFilterData(LogCatFilter f) {
- mFilter = f;
-
- // By default, all filters are persistent. Transient filters should explicitly
- // mark it so by calling setTransient.
- mTransient = false;
- }
-
- /**
- * Update the unread count based on new messages received. The unread count
- * is incremented by the count of messages in the received list that will be
- * accepted by this filter.
- * @param newMessages list of new messages.
- */
- public void updateUnreadCount(List<LogCatMessage> newMessages) {
- for (LogCatMessage m : newMessages) {
- if (mFilter.matches(m)) {
- mUnreadCount++;
- }
- }
- }
-
- /**
- * Reset count of unread messages.
- */
- public void resetUnreadCount() {
- mUnreadCount = 0;
- }
-
- /**
- * Get current value for the unread message counter.
- */
- public int getUnreadCount() {
- return mUnreadCount;
- }
-
- /** Make this filter transient: It will not be persisted across sessions. */
- public void setTransient() {
- mTransient = true;
- }
-
- public boolean isTransient() {
- return mTransient;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterLabelProvider.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterLabelProvider.java
deleted file mode 100644
index fe24ddd..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterLabelProvider.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmlib.logcat.LogCatFilter;
-
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-
-import java.util.Map;
-
-/**
- * A JFace label provider for the LogCat filters. It expects elements of type
- * {@link LogCatFilter}.
- */
-public final class LogCatFilterLabelProvider extends LabelProvider implements ITableLabelProvider {
- private Map<LogCatFilter, LogCatFilterData> mFilterData;
-
- public LogCatFilterLabelProvider(Map<LogCatFilter, LogCatFilterData> filterData) {
- mFilterData = filterData;
- }
-
- @Override
- public Image getColumnImage(Object arg0, int arg1) {
- return null;
- }
-
- /**
- * Implements {@link ITableLabelProvider#getColumnText(Object, int)}.
- * @param element an instance of {@link LogCatFilter}
- * @param index index of the column
- * @return text to use in the column
- */
- @Override
- public String getColumnText(Object element, int index) {
- if (!(element instanceof LogCatFilter)) {
- return null;
- }
-
- LogCatFilter f = (LogCatFilter) element;
- LogCatFilterData fd = mFilterData.get(f);
-
- if (fd != null && fd.getUnreadCount() > 0) {
- return String.format("%s (%d)", f.getName(), fd.getUnreadCount());
- } else {
- return f.getName();
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterSettingsDialog.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterSettingsDialog.java
deleted file mode 100644
index 39b3fa9..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterSettingsDialog.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmlib.Log.LogLevel;
-
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.TitleAreaDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-/**
- * Dialog used to create or edit settings for a logcat filter.
- */
-public final class LogCatFilterSettingsDialog extends TitleAreaDialog {
- private static final String TITLE = "Logcat Message Filter Settings";
- private static final String DEFAULT_MESSAGE =
- "Filter logcat messages by the source's tag, pid or minimum log level.\n"
- + "Empty fields will match all messages.";
-
- private String mFilterName;
- private String mTag;
- private String mText;
- private String mPid;
- private String mAppName;
- private String mLogLevel;
-
- private Text mFilterNameText;
- private Text mTagFilterText;
- private Text mTextFilterText;
- private Text mPidFilterText;
- private Text mAppNameFilterText;
- private Combo mLogLevelCombo;
- private Button mOkButton;
-
- /**
- * Construct the filter settings dialog with default values for all fields.
- * @param parentShell .
- */
- public LogCatFilterSettingsDialog(Shell parentShell) {
- super(parentShell);
- setDefaults("", "", "", "", "", LogLevel.VERBOSE);
- }
-
- /**
- * Set the default values to show when the dialog is opened.
- * @param filterName name for the filter.
- * @param tag value for filter by tag
- * @param text value for filter by text
- * @param pid value for filter by pid
- * @param appName value for filter by app name
- * @param level value for filter by log level
- */
- public void setDefaults(String filterName, String tag, String text, String pid, String appName,
- LogLevel level) {
- mFilterName = filterName;
- mTag = tag;
- mText = text;
- mPid = pid;
- mAppName = appName;
- mLogLevel = level.getStringValue();
- }
-
- @Override
- protected Control createDialogArea(Composite shell) {
- setTitle(TITLE);
- setMessage(DEFAULT_MESSAGE);
-
- Composite parent = (Composite) super.createDialogArea(shell);
- Composite c = new Composite(parent, SWT.BORDER);
- c.setLayout(new GridLayout(2, false));
- c.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createLabel(c, "Filter Name:");
- mFilterNameText = new Text(c, SWT.BORDER);
- mFilterNameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mFilterNameText.setText(mFilterName);
-
- createSeparator(c);
-
- createLabel(c, "by Log Tag:");
- mTagFilterText = new Text(c, SWT.BORDER);
- mTagFilterText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mTagFilterText.setText(mTag);
-
- createLabel(c, "by Log Message:");
- mTextFilterText = new Text(c, SWT.BORDER);
- mTextFilterText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mTextFilterText.setText(mText);
-
- createLabel(c, "by PID:");
- mPidFilterText = new Text(c, SWT.BORDER);
- mPidFilterText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mPidFilterText.setText(mPid);
-
- createLabel(c, "by Application Name:");
- mAppNameFilterText = new Text(c, SWT.BORDER);
- mAppNameFilterText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mAppNameFilterText.setText(mAppName);
-
- createLabel(c, "by Log Level:");
- mLogLevelCombo = new Combo(c, SWT.READ_ONLY | SWT.DROP_DOWN);
- mLogLevelCombo.setItems(getLogLevels().toArray(new String[0]));
- mLogLevelCombo.select(getLogLevels().indexOf(mLogLevel));
-
- /* call validateDialog() whenever user modifies any text field */
- ModifyListener m = new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent arg0) {
- DialogStatus status = validateDialog();
- mOkButton.setEnabled(status.valid);
- setErrorMessage(status.message);
- }
- };
- mFilterNameText.addModifyListener(m);
- mTagFilterText.addModifyListener(m);
- mTextFilterText.addModifyListener(m);
- mPidFilterText.addModifyListener(m);
- mAppNameFilterText.addModifyListener(m);
-
- return c;
- }
-
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- super.createButtonsForButtonBar(parent);
-
- mOkButton = getButton(IDialogConstants.OK_ID);
-
- DialogStatus status = validateDialog();
- mOkButton.setEnabled(status.valid);
- }
-
- /**
- * A tuple that specifies whether the current state of the inputs
- * on the dialog is valid or not. If it is not valid, the message
- * field stores the reason why it isn't.
- */
- private static final class DialogStatus {
- final boolean valid;
- final String message;
-
- private DialogStatus(boolean isValid, String errMessage) {
- valid = isValid;
- message = errMessage;
- }
- }
-
- private DialogStatus validateDialog() {
- /* check that there is some name for the filter */
- if (mFilterNameText.getText().trim().equals("")) {
- return new DialogStatus(false,
- "Please provide a name for this filter.");
- }
-
- /* if a pid is provided, it should be a +ve integer */
- String pidText = mPidFilterText.getText().trim();
- if (pidText.trim().length() > 0) {
- int pid = 0;
- try {
- pid = Integer.parseInt(pidText);
- } catch (NumberFormatException e) {
- return new DialogStatus(false,
- "PID should be a positive integer.");
- }
-
- if (pid < 0) {
- return new DialogStatus(false,
- "PID should be a positive integer.");
- }
- }
-
- /* tag field must use a valid regex pattern */
- String tagText = mTagFilterText.getText().trim();
- if (tagText.trim().length() > 0) {
- try {
- Pattern.compile(tagText);
- } catch (PatternSyntaxException e) {
- return new DialogStatus(false,
- "Invalid regex used in tag field: " + e.getMessage());
- }
- }
-
- /* text field must use a valid regex pattern */
- String messageText = mTextFilterText.getText().trim();
- if (messageText.trim().length() > 0) {
- try {
- Pattern.compile(messageText);
- } catch (PatternSyntaxException e) {
- return new DialogStatus(false,
- "Invalid regex used in text field: " + e.getMessage());
- }
- }
-
- /* app name field must use a valid regex pattern */
- String appNameText = mAppNameFilterText.getText().trim();
- if (appNameText.trim().length() > 0) {
- try {
- Pattern.compile(appNameText);
- } catch (PatternSyntaxException e) {
- return new DialogStatus(false,
- "Invalid regex used in application name field: " + e.getMessage());
- }
- }
-
- return new DialogStatus(true, null);
- }
-
- private void createSeparator(Composite c) {
- Label l = new Label(c, SWT.SEPARATOR | SWT.HORIZONTAL);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- l.setLayoutData(gd);
- }
-
- private void createLabel(Composite c, String text) {
- Label l = new Label(c, SWT.NONE);
- l.setText(text);
- GridData gd = new GridData();
- gd.horizontalAlignment = SWT.RIGHT;
- l.setLayoutData(gd);
- }
-
- @Override
- protected void okPressed() {
- /* save values from the widgets before the shell is closed. */
- mFilterName = mFilterNameText.getText();
- mTag = mTagFilterText.getText();
- mText = mTextFilterText.getText();
- mLogLevel = mLogLevelCombo.getText();
- mPid = mPidFilterText.getText();
- mAppName = mAppNameFilterText.getText();
-
- super.okPressed();
- }
-
- /**
- * Obtain the name for this filter.
- * @return user provided filter name, maybe empty.
- */
- public String getFilterName() {
- return mFilterName;
- }
-
- /**
- * Obtain the tag regex to filter by.
- * @return user provided tag regex, maybe empty.
- */
- public String getTag() {
- return mTag;
- }
-
- /**
- * Obtain the text regex to filter by.
- * @return user provided tag regex, maybe empty.
- */
- public String getText() {
- return mText;
- }
-
- /**
- * Obtain user provided PID to filter by.
- * @return user provided pid, maybe empty.
- */
- public String getPid() {
- return mPid;
- }
-
- /**
- * Obtain user provided application name to filter by.
- * @return user provided app name regex, maybe empty
- */
- public String getAppName() {
- return mAppName;
- }
-
- /**
- * Obtain log level to filter by.
- * @return log level string.
- */
- public String getLogLevel() {
- return mLogLevel;
- }
-
- /**
- * Obtain the string representation of all supported log levels.
- * @return an array of strings, each representing a certain log level.
- */
- public static List<String> getLogLevels() {
- List<String> logLevels = new ArrayList<String>();
-
- for (LogLevel l : LogLevel.values()) {
- logLevels.add(l.getStringValue());
- }
-
- return logLevels;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterSettingsSerializer.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterSettingsSerializer.java
deleted file mode 100644
index de35162..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatFilterSettingsSerializer.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.logcat.LogCatFilter;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-/**
- * Class to help save/restore user created filters.
- *
- * Users can create multiple filters in the logcat view. These filters could have regexes
- * in their settings. All of the user created filters are saved into a single Eclipse
- * preference. This class helps in generating the string to be saved given a list of
- * {@link LogCatFilter}'s, and also does the reverse of creating the list of filters
- * given the encoded string.
- */
-public final class LogCatFilterSettingsSerializer {
- private static final char SINGLE_QUOTE = '\'';
- private static final char ESCAPE_CHAR = '\\';
-
- private static final String ATTR_DELIM = ", ";
- private static final String KW_DELIM = ": ";
-
- private static final String KW_NAME = "name";
- private static final String KW_TAG = "tag";
- private static final String KW_TEXT = "text";
- private static final String KW_PID = "pid";
- private static final String KW_APP = "app";
- private static final String KW_LOGLEVEL = "level";
-
- /**
- * Encode the settings from a list of {@link LogCatFilter}'s into a string for saving to
- * the preference store. See
- * {@link LogCatFilterSettingsSerializer#decodeFromPreferenceString(String)} for the
- * reverse operation.
- * @param filters list of filters to save.
- * @param filterData mapping from filter to per filter UI data
- * @return an encoded string that can be saved in Eclipse preference store. The encoded string
- * is of a list of key:'value' pairs.
- */
- public String encodeToPreferenceString(List<LogCatFilter> filters,
- Map<LogCatFilter, LogCatFilterData> filterData) {
- StringBuffer sb = new StringBuffer();
-
- for (LogCatFilter f : filters) {
- LogCatFilterData fd = filterData.get(f);
- if (fd != null && fd.isTransient()) {
- // do not persist transient filters
- continue;
- }
-
- sb.append(KW_NAME); sb.append(KW_DELIM); sb.append(quoteString(f.getName()));
- sb.append(ATTR_DELIM);
- sb.append(KW_TAG); sb.append(KW_DELIM); sb.append(quoteString(f.getTag()));
- sb.append(ATTR_DELIM);
- sb.append(KW_TEXT); sb.append(KW_DELIM); sb.append(quoteString(f.getText()));
- sb.append(ATTR_DELIM);
- sb.append(KW_PID); sb.append(KW_DELIM); sb.append(quoteString(f.getPid()));
- sb.append(ATTR_DELIM);
- sb.append(KW_APP); sb.append(KW_DELIM); sb.append(quoteString(f.getAppName()));
- sb.append(ATTR_DELIM);
- sb.append(KW_LOGLEVEL); sb.append(KW_DELIM);
- sb.append(quoteString(f.getLogLevel().getStringValue()));
- sb.append(ATTR_DELIM);
- }
- return sb.toString();
- }
-
- /**
- * Decode an encoded string representing the settings of a list of logcat
- * filters into a list of {@link LogCatFilter}'s.
- * @param pref encoded preference string
- * @return a list of {@link LogCatFilter}
- */
- public List<LogCatFilter> decodeFromPreferenceString(String pref) {
- List<LogCatFilter> fs = new ArrayList<LogCatFilter>();
-
- /* first split the string into a list of key, value pairs */
- List<String> kv = getKeyValues(pref);
- if (kv.size() == 0) {
- return fs;
- }
-
- /* construct filter settings from the key value pairs */
- int index = 0;
- while (index < kv.size()) {
- String name = "";
- String tag = "";
- String pid = "";
- String app = "";
- String text = "";
- LogLevel level = LogLevel.VERBOSE;
-
- assert kv.get(index).equals(KW_NAME);
- name = kv.get(index + 1);
-
- index += 2;
- while (index < kv.size() && !kv.get(index).equals(KW_NAME)) {
- String key = kv.get(index);
- String value = kv.get(index + 1);
- index += 2;
-
- if (key.equals(KW_TAG)) {
- tag = value;
- } else if (key.equals(KW_TEXT)) {
- text = value;
- } else if (key.equals(KW_PID)) {
- pid = value;
- } else if (key.equals(KW_APP)) {
- app = value;
- } else if (key.equals(KW_LOGLEVEL)) {
- level = LogLevel.getByString(value);
- }
- }
-
- fs.add(new LogCatFilter(name, tag, text, pid, app, level));
- }
-
- return fs;
- }
-
- private List<String> getKeyValues(String pref) {
- List<String> kv = new ArrayList<String>();
- int index = 0;
- while (index < pref.length()) {
- String kw = getKeyword(pref.substring(index));
- if (kw == null) {
- break;
- }
- index += kw.length() + KW_DELIM.length();
-
- String value = getNextString(pref.substring(index));
- index += value.length() + ATTR_DELIM.length();
-
- value = unquoteString(value);
-
- kv.add(kw);
- kv.add(value);
- }
-
- return kv;
- }
-
- /**
- * Enclose a string in quotes, escaping all the quotes within the string.
- */
- private String quoteString(String s) {
- return SINGLE_QUOTE + s.replace(Character.toString(SINGLE_QUOTE), "\\'")
- + SINGLE_QUOTE;
- }
-
- /**
- * Recover original string from its escaped version created using
- * {@link LogCatFilterSettingsSerializer#quoteString(String)}.
- */
- private String unquoteString(String s) {
- s = s.substring(1, s.length() - 1); /* remove start and end QUOTES */
- return s.replace("\\'", Character.toString(SINGLE_QUOTE));
- }
-
- private String getKeyword(String pref) {
- int kwlen = pref.indexOf(KW_DELIM);
- if (kwlen == -1) {
- return null;
- }
-
- return pref.substring(0, kwlen);
- }
-
- /**
- * Get the next quoted string from the input stream of characters.
- */
- private String getNextString(String s) {
- assert s.charAt(0) == SINGLE_QUOTE;
-
- StringBuffer sb = new StringBuffer();
-
- int index = 0;
- while (index < s.length()) {
- sb.append(s.charAt(index));
-
- if (index > 0
- && s.charAt(index) == SINGLE_QUOTE // current char is a single quote
- && s.charAt(index - 1) != ESCAPE_CHAR) { // prev char wasn't a backslash
- /* break if an unescaped SINGLE QUOTE (end of string) is seen */
- break;
- }
-
- index++;
- }
-
- return sb.toString();
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatMessageList.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatMessageList.java
deleted file mode 100644
index c5cd548..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatMessageList.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmlib.logcat.LogCatMessage;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.ArrayBlockingQueue;
-import java.util.concurrent.BlockingQueue;
-
-/**
- * Container for a list of log messages. The list of messages are
- * maintained in a circular buffer (FIFO).
- */
-public final class LogCatMessageList {
- /** Preference key for size of the FIFO. */
- public static final String MAX_MESSAGES_PREFKEY =
- "logcat.messagelist.max.size";
-
- /** Default value for max # of messages. */
- public static final int MAX_MESSAGES_DEFAULT = 5000;
-
- private int mFifoSize;
- private BlockingQueue<LogCatMessage> mQ;
-
- /**
- * Construct an empty message list.
- * @param maxMessages capacity of the circular buffer
- */
- public LogCatMessageList(int maxMessages) {
- mFifoSize = maxMessages;
-
- mQ = new ArrayBlockingQueue<LogCatMessage>(mFifoSize);
- }
-
- /**
- * Resize the message list.
- * @param n new size for the list
- */
- public synchronized void resize(int n) {
- mFifoSize = n;
-
- if (mFifoSize > mQ.size()) {
- /* if resizing to a bigger fifo, we can copy over all elements from the current mQ */
- mQ = new ArrayBlockingQueue<LogCatMessage>(mFifoSize, true, mQ);
- } else {
- /* for a smaller fifo, copy over the last n entries */
- LogCatMessage[] curMessages = mQ.toArray(new LogCatMessage[mQ.size()]);
- mQ = new ArrayBlockingQueue<LogCatMessage>(mFifoSize);
- for (int i = curMessages.length - mFifoSize; i < curMessages.length; i++) {
- mQ.offer(curMessages[i]);
- }
- }
- }
-
- /**
- * Append a message to the list. If the list is full, the first
- * message will be popped off of it.
- * @param m log to be inserted
- */
- public synchronized void appendMessages(final List<LogCatMessage> messages) {
- ensureSpace(messages.size());
- for (LogCatMessage m: messages) {
- mQ.offer(m);
- }
- }
-
- /**
- * Ensure that there is sufficient space for given number of messages.
- * @return list of messages that were deleted to create additional space.
- */
- public synchronized List<LogCatMessage> ensureSpace(int messageCount) {
- List<LogCatMessage> l = new ArrayList<LogCatMessage>(messageCount);
-
- while (mQ.remainingCapacity() < messageCount) {
- l.add(mQ.poll());
- }
-
- return l;
- }
-
- /**
- * Returns the number of additional elements that this queue can
- * ideally (in the absence of memory or resource constraints)
- * accept without blocking.
- * @return the remaining capacity
- */
- public synchronized int remainingCapacity() {
- return mQ.remainingCapacity();
- }
-
- /** Clear all messages in the list. */
- public synchronized void clear() {
- mQ.clear();
- }
-
- /** Obtain a copy of the message list. */
- public synchronized List<LogCatMessage> getAllMessages() {
- return new ArrayList<LogCatMessage>(mQ);
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java
deleted file mode 100644
index bda742c..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatPanel.java
+++ /dev/null
@@ -1,1607 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmlib.DdmConstants;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.logcat.LogCatFilter;
-import com.android.ddmlib.logcat.LogCatMessage;
-import com.android.ddmuilib.AbstractBufferFindTarget;
-import com.android.ddmuilib.FindDialog;
-import com.android.ddmuilib.ITableFocusListener;
-import com.android.ddmuilib.ITableFocusListener.IFocusedTableActivator;
-import com.android.ddmuilib.ImageLoader;
-import com.android.ddmuilib.SelectionDependentPanel;
-import com.android.ddmuilib.TableHelper;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.ToolBar;
-import org.eclipse.swt.widgets.ToolItem;
-
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.regex.Pattern;
-import java.util.regex.PatternSyntaxException;
-
-/**
- * LogCatPanel displays a table listing the logcat messages.
- */
-public final class LogCatPanel extends SelectionDependentPanel
- implements ILogCatBufferChangeListener {
- /** Preference key to use for storing list of logcat filters. */
- public static final String LOGCAT_FILTERS_LIST = "logcat.view.filters.list";
-
- /** Preference key to use for storing font settings. */
- public static final String LOGCAT_VIEW_FONT_PREFKEY = "logcat.view.font";
-
- /** Preference key to use for deciding whether to automatically en/disable scroll lock. */
- public static final String AUTO_SCROLL_LOCK_PREFKEY = "logcat.view.auto-scroll-lock";
-
- // Preference keys for message colors based on severity level
- private static final String MSG_COLOR_PREFKEY_PREFIX = "logcat.msg.color.";
- public static final String VERBOSE_COLOR_PREFKEY = MSG_COLOR_PREFKEY_PREFIX + "verbose"; //$NON-NLS-1$
- public static final String DEBUG_COLOR_PREFKEY = MSG_COLOR_PREFKEY_PREFIX + "debug"; //$NON-NLS-1$
- public static final String INFO_COLOR_PREFKEY = MSG_COLOR_PREFKEY_PREFIX + "info"; //$NON-NLS-1$
- public static final String WARN_COLOR_PREFKEY = MSG_COLOR_PREFKEY_PREFIX + "warn"; //$NON-NLS-1$
- public static final String ERROR_COLOR_PREFKEY = MSG_COLOR_PREFKEY_PREFIX + "error"; //$NON-NLS-1$
- public static final String ASSERT_COLOR_PREFKEY = MSG_COLOR_PREFKEY_PREFIX + "assert"; //$NON-NLS-1$
-
- // Use a monospace font family
- private static final String FONT_FAMILY =
- DdmConstants.CURRENT_PLATFORM == DdmConstants.PLATFORM_DARWIN ? "Monaco":"Courier New";
-
- // Use the default system font size
- private static final FontData DEFAULT_LOGCAT_FONTDATA;
- static {
- int h = Display.getDefault().getSystemFont().getFontData()[0].getHeight();
- DEFAULT_LOGCAT_FONTDATA = new FontData(FONT_FAMILY, h, SWT.NORMAL);
- }
-
- private static final String LOGCAT_VIEW_COLSIZE_PREFKEY_PREFIX = "logcat.view.colsize.";
- private static final String DISPLAY_FILTERS_COLUMN_PREFKEY = "logcat.view.display.filters";
-
- /** Default message to show in the message search field. */
- private static final String DEFAULT_SEARCH_MESSAGE =
- "Search for messages. Accepts Java regexes. "
- + "Prefix with pid:, app:, tag: or text: to limit scope.";
-
- /** Tooltip to show in the message search field. */
- private static final String DEFAULT_SEARCH_TOOLTIP =
- "Example search patterns:\n"
- + " sqlite (search for sqlite in text field)\n"
- + " app:browser (search for messages generated by the browser application)";
-
- private static final String IMAGE_ADD_FILTER = "add.png"; //$NON-NLS-1$
- private static final String IMAGE_DELETE_FILTER = "delete.png"; //$NON-NLS-1$
- private static final String IMAGE_EDIT_FILTER = "edit.png"; //$NON-NLS-1$
- private static final String IMAGE_SAVE_LOG_TO_FILE = "save.png"; //$NON-NLS-1$
- private static final String IMAGE_CLEAR_LOG = "clear.png"; //$NON-NLS-1$
- private static final String IMAGE_DISPLAY_FILTERS = "displayfilters.png"; //$NON-NLS-1$
- private static final String IMAGE_SCROLL_LOCK = "scroll_lock.png"; //$NON-NLS-1$
-
- private static final int[] WEIGHTS_SHOW_FILTERS = new int[] {15, 85};
- private static final int[] WEIGHTS_LOGCAT_ONLY = new int[] {0, 100};
-
- /** Index of the default filter in the saved filters column. */
- private static final int DEFAULT_FILTER_INDEX = 0;
-
- /* Text colors for the filter box */
- private static final Color VALID_FILTER_REGEX_COLOR =
- Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
- private static final Color INVALID_FILTER_REGEX_COLOR =
- Display.getDefault().getSystemColor(SWT.COLOR_RED);
-
- private LogCatReceiver mReceiver;
- private IPreferenceStore mPrefStore;
-
- private List<LogCatFilter> mLogCatFilters;
- private Map<LogCatFilter, LogCatFilterData> mLogCatFilterData;
- private int mCurrentSelectedFilterIndex;
-
- private ToolItem mNewFilterToolItem;
- private ToolItem mDeleteFilterToolItem;
- private ToolItem mEditFilterToolItem;
- private TableViewer mFiltersTableViewer;
-
- private Combo mLiveFilterLevelCombo;
- private Text mLiveFilterText;
-
- private List<LogCatFilter> mCurrentFilters = Collections.emptyList();
-
- private Table mTable;
-
- private boolean mShouldScrollToLatestLog = true;
- private ToolItem mScrollLockCheckBox;
- private boolean mAutoScrollLock;
-
- // Lock under which the vertical scroll bar listener should be added
- private final Object mScrollBarSelectionListenerLock = new Object();
- private SelectionListener mScrollBarSelectionListener;
- private boolean mScrollBarListenerSet = false;
-
- private String mLogFileExportFolder;
-
- private Font mFont;
- private int mWrapWidthInChars;
-
- private Color mVerboseColor;
- private Color mDebugColor;
- private Color mInfoColor;
- private Color mWarnColor;
- private Color mErrorColor;
- private Color mAssertColor;
-
- private SashForm mSash;
-
- // messages added since last refresh, synchronized on mLogBuffer
- private List<LogCatMessage> mLogBuffer;
-
- // # of messages deleted since last refresh, synchronized on mLogBuffer
- private int mDeletedLogCount;
-
- /**
- * Construct a logcat panel.
- * @param prefStore preference store where UI preferences will be saved
- */
- public LogCatPanel(IPreferenceStore prefStore) {
- mPrefStore = prefStore;
- mLogBuffer = new ArrayList<LogCatMessage>(LogCatMessageList.MAX_MESSAGES_DEFAULT);
-
- initializeFilters();
-
- setupDefaultPreferences();
- initializePreferenceUpdateListeners();
-
- mFont = getFontFromPrefStore();
- loadMessageColorPreferences();
- mAutoScrollLock = mPrefStore.getBoolean(AUTO_SCROLL_LOCK_PREFKEY);
- }
-
- private void loadMessageColorPreferences() {
- if (mVerboseColor != null) {
- disposeMessageColors();
- }
-
- mVerboseColor = getColorFromPrefStore(VERBOSE_COLOR_PREFKEY);
- mDebugColor = getColorFromPrefStore(DEBUG_COLOR_PREFKEY);
- mInfoColor = getColorFromPrefStore(INFO_COLOR_PREFKEY);
- mWarnColor = getColorFromPrefStore(WARN_COLOR_PREFKEY);
- mErrorColor = getColorFromPrefStore(ERROR_COLOR_PREFKEY);
- mAssertColor = getColorFromPrefStore(ASSERT_COLOR_PREFKEY);
- }
-
- private void initializeFilters() {
- mLogCatFilters = new ArrayList<LogCatFilter>();
- mLogCatFilterData = new ConcurrentHashMap<LogCatFilter, LogCatFilterData>();
-
- /* add default filter matching all messages */
- String tag = "";
- String text = "";
- String pid = "";
- String app = "";
- LogCatFilter defaultFilter = new LogCatFilter("All messages (no filters)",
- tag, text, pid, app, LogLevel.VERBOSE);
-
- mLogCatFilters.add(defaultFilter);
- mLogCatFilterData.put(defaultFilter, new LogCatFilterData(defaultFilter));
-
- /* restore saved filters from prefStore */
- List<LogCatFilter> savedFilters = getSavedFilters();
- for (LogCatFilter f: savedFilters) {
- mLogCatFilters.add(f);
- mLogCatFilterData.put(f, new LogCatFilterData(f));
- }
- }
-
- private void setupDefaultPreferences() {
- PreferenceConverter.setDefault(mPrefStore, LogCatPanel.LOGCAT_VIEW_FONT_PREFKEY,
- DEFAULT_LOGCAT_FONTDATA);
- mPrefStore.setDefault(LogCatMessageList.MAX_MESSAGES_PREFKEY,
- LogCatMessageList.MAX_MESSAGES_DEFAULT);
- mPrefStore.setDefault(DISPLAY_FILTERS_COLUMN_PREFKEY, true);
- mPrefStore.setDefault(AUTO_SCROLL_LOCK_PREFKEY, true);
-
- /* Default Colors for different log levels. */
- PreferenceConverter.setDefault(mPrefStore, LogCatPanel.VERBOSE_COLOR_PREFKEY,
- new RGB(0, 0, 0));
- PreferenceConverter.setDefault(mPrefStore, LogCatPanel.DEBUG_COLOR_PREFKEY,
- new RGB(0, 0, 127));
- PreferenceConverter.setDefault(mPrefStore, LogCatPanel.INFO_COLOR_PREFKEY,
- new RGB(0, 127, 0));
- PreferenceConverter.setDefault(mPrefStore, LogCatPanel.WARN_COLOR_PREFKEY,
- new RGB(255, 127, 0));
- PreferenceConverter.setDefault(mPrefStore, LogCatPanel.ERROR_COLOR_PREFKEY,
- new RGB(255, 0, 0));
- PreferenceConverter.setDefault(mPrefStore, LogCatPanel.ASSERT_COLOR_PREFKEY,
- new RGB(255, 0, 0));
- }
-
- private void initializePreferenceUpdateListeners() {
- mPrefStore.addPropertyChangeListener(new IPropertyChangeListener() {
- @Override
- public void propertyChange(PropertyChangeEvent event) {
- String changedProperty = event.getProperty();
- if (changedProperty.equals(LogCatPanel.LOGCAT_VIEW_FONT_PREFKEY)) {
- if (mFont != null) {
- mFont.dispose();
- }
- mFont = getFontFromPrefStore();
- recomputeWrapWidth();
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- for (TableItem it: mTable.getItems()) {
- it.setFont(mFont);
- }
- }
- });
- } else if (changedProperty.startsWith(MSG_COLOR_PREFKEY_PREFIX)) {
- loadMessageColorPreferences();
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- Color c = mVerboseColor;
- for (TableItem it: mTable.getItems()) {
- Object data = it.getData();
- if (data instanceof LogCatMessage) {
- c = getForegroundColor((LogCatMessage) data);
- }
- it.setForeground(c);
- }
- }
- });
- } else if (changedProperty.equals(LogCatMessageList.MAX_MESSAGES_PREFKEY)) {
- mReceiver.resizeFifo(mPrefStore.getInt(
- LogCatMessageList.MAX_MESSAGES_PREFKEY));
- reloadLogBuffer();
- } else if (changedProperty.equals(AUTO_SCROLL_LOCK_PREFKEY)) {
- mAutoScrollLock = mPrefStore.getBoolean(AUTO_SCROLL_LOCK_PREFKEY);
- }
- }
- });
- }
-
- private void saveFilterPreferences() {
- LogCatFilterSettingsSerializer serializer = new LogCatFilterSettingsSerializer();
-
- /* save all filter settings except the first one which is the default */
- String e = serializer.encodeToPreferenceString(
- mLogCatFilters.subList(1, mLogCatFilters.size()), mLogCatFilterData);
- mPrefStore.setValue(LOGCAT_FILTERS_LIST, e);
- }
-
- private List<LogCatFilter> getSavedFilters() {
- LogCatFilterSettingsSerializer serializer = new LogCatFilterSettingsSerializer();
- String e = mPrefStore.getString(LOGCAT_FILTERS_LIST);
- return serializer.decodeFromPreferenceString(e);
- }
-
- @Override
- public void deviceSelected() {
- IDevice device = getCurrentDevice();
- if (device == null) {
- // If the device is not working properly, getCurrentDevice() could return null.
- // In such a case, we don't launch logcat, nor switch the display.
- return;
- }
-
- if (mReceiver != null) {
- // Don't need to listen to new logcat messages from previous device anymore.
- mReceiver.removeMessageReceivedEventListener(this);
-
- // When switching between devices, existing filter match count should be reset.
- for (LogCatFilter f : mLogCatFilters) {
- LogCatFilterData fd = mLogCatFilterData.get(f);
- fd.resetUnreadCount();
- }
- }
-
- mReceiver = LogCatReceiverFactory.INSTANCE.newReceiver(device, mPrefStore);
- mReceiver.addMessageReceivedEventListener(this);
- reloadLogBuffer();
-
- // Always scroll to last line whenever the selected device changes.
- // Run this in a separate async thread to give the table some time to update after the
- // setInput above.
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- scrollToLatestLog();
- }
- });
- }
-
- @Override
- public void clientSelected() {
- }
-
- @Override
- protected void postCreation() {
- }
-
- @Override
- protected Control createControl(Composite parent) {
- GridLayout layout = new GridLayout(1, false);
- parent.setLayout(layout);
-
- createViews(parent);
- setupDefaults();
-
- return null;
- }
-
- private void createViews(Composite parent) {
- mSash = createSash(parent);
-
- createListOfFilters(mSash);
- createLogTableView(mSash);
-
- boolean showFilters = mPrefStore.getBoolean(DISPLAY_FILTERS_COLUMN_PREFKEY);
- updateFiltersColumn(showFilters);
- }
-
- private SashForm createSash(Composite parent) {
- SashForm sash = new SashForm(parent, SWT.HORIZONTAL);
- sash.setLayoutData(new GridData(GridData.FILL_BOTH));
- return sash;
- }
-
- private void createListOfFilters(SashForm sash) {
- Composite c = new Composite(sash, SWT.BORDER);
- GridLayout layout = new GridLayout(2, false);
- c.setLayout(layout);
- c.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createFiltersToolbar(c);
- createFiltersTable(c);
- }
-
- private void createFiltersToolbar(Composite parent) {
- Label l = new Label(parent, SWT.NONE);
- l.setText("Saved Filters");
- GridData gd = new GridData();
- gd.horizontalAlignment = SWT.LEFT;
- l.setLayoutData(gd);
-
- ToolBar t = new ToolBar(parent, SWT.FLAT);
- gd = new GridData();
- gd.horizontalAlignment = SWT.RIGHT;
- t.setLayoutData(gd);
-
- /* new filter */
- mNewFilterToolItem = new ToolItem(t, SWT.PUSH);
- mNewFilterToolItem.setImage(
- ImageLoader.getDdmUiLibLoader().loadImage(IMAGE_ADD_FILTER, t.getDisplay()));
- mNewFilterToolItem.setToolTipText("Add a new logcat filter");
- mNewFilterToolItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- addNewFilter();
- }
- });
-
- /* delete filter */
- mDeleteFilterToolItem = new ToolItem(t, SWT.PUSH);
- mDeleteFilterToolItem.setImage(
- ImageLoader.getDdmUiLibLoader().loadImage(IMAGE_DELETE_FILTER, t.getDisplay()));
- mDeleteFilterToolItem.setToolTipText("Delete selected logcat filter");
- mDeleteFilterToolItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- deleteSelectedFilter();
- }
- });
-
- /* edit filter */
- mEditFilterToolItem = new ToolItem(t, SWT.PUSH);
- mEditFilterToolItem.setImage(
- ImageLoader.getDdmUiLibLoader().loadImage(IMAGE_EDIT_FILTER, t.getDisplay()));
- mEditFilterToolItem.setToolTipText("Edit selected logcat filter");
- mEditFilterToolItem.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- editSelectedFilter();
- }
- });
- }
-
- private void addNewFilter(String defaultTag, String defaultText, String defaultPid,
- String defaultAppName, LogLevel defaultLevel) {
- LogCatFilterSettingsDialog d = new LogCatFilterSettingsDialog(
- Display.getCurrent().getActiveShell());
- d.setDefaults("", defaultTag, defaultText, defaultPid, defaultAppName, defaultLevel);
- if (d.open() != Window.OK) {
- return;
- }
-
- LogCatFilter f = new LogCatFilter(d.getFilterName().trim(),
- d.getTag().trim(),
- d.getText().trim(),
- d.getPid().trim(),
- d.getAppName().trim(),
- LogLevel.getByString(d.getLogLevel()));
-
- mLogCatFilters.add(f);
- mLogCatFilterData.put(f, new LogCatFilterData(f));
- mFiltersTableViewer.refresh();
-
- /* select the newly added entry */
- int idx = mLogCatFilters.size() - 1;
- mFiltersTableViewer.getTable().setSelection(idx);
-
- filterSelectionChanged();
- saveFilterPreferences();
- }
-
- private void addNewFilter() {
- addNewFilter("", "", "", "", LogLevel.VERBOSE);
- }
-
- private void deleteSelectedFilter() {
- int selectedIndex = mFiltersTableViewer.getTable().getSelectionIndex();
- if (selectedIndex <= 0) {
- /* return if no selected filter, or the default filter was selected (0th). */
- return;
- }
-
- LogCatFilter f = mLogCatFilters.get(selectedIndex);
- mLogCatFilters.remove(selectedIndex);
- mLogCatFilterData.remove(f);
-
- mFiltersTableViewer.refresh();
- mFiltersTableViewer.getTable().setSelection(selectedIndex - 1);
-
- filterSelectionChanged();
- saveFilterPreferences();
- }
-
- private void editSelectedFilter() {
- int selectedIndex = mFiltersTableViewer.getTable().getSelectionIndex();
- if (selectedIndex < 0) {
- return;
- }
-
- LogCatFilter curFilter = mLogCatFilters.get(selectedIndex);
-
- LogCatFilterSettingsDialog dialog = new LogCatFilterSettingsDialog(
- Display.getCurrent().getActiveShell());
- dialog.setDefaults(curFilter.getName(), curFilter.getTag(), curFilter.getText(),
- curFilter.getPid(), curFilter.getAppName(), curFilter.getLogLevel());
- if (dialog.open() != Window.OK) {
- return;
- }
-
- LogCatFilter f = new LogCatFilter(dialog.getFilterName(),
- dialog.getTag(),
- dialog.getText(),
- dialog.getPid(),
- dialog.getAppName(),
- LogLevel.getByString(dialog.getLogLevel()));
- mLogCatFilters.set(selectedIndex, f);
- mFiltersTableViewer.refresh();
-
- mFiltersTableViewer.getTable().setSelection(selectedIndex);
- filterSelectionChanged();
- saveFilterPreferences();
- }
-
- /**
- * Select the transient filter for the specified application. If no such filter
- * exists, then create one and then select that. This method should be called from
- * the UI thread.
- * @param appName application name to filter by
- */
- public void selectTransientAppFilter(String appName) {
- assert mTable.getDisplay().getThread() == Thread.currentThread();
-
- LogCatFilter f = findTransientAppFilter(appName);
- if (f == null) {
- f = createTransientAppFilter(appName);
- mLogCatFilters.add(f);
-
- LogCatFilterData fd = new LogCatFilterData(f);
- fd.setTransient();
- mLogCatFilterData.put(f, fd);
- }
-
- selectFilterAt(mLogCatFilters.indexOf(f));
- }
-
- private LogCatFilter findTransientAppFilter(String appName) {
- for (LogCatFilter f : mLogCatFilters) {
- LogCatFilterData fd = mLogCatFilterData.get(f);
- if (fd != null && fd.isTransient() && f.getAppName().equals(appName)) {
- return f;
- }
- }
- return null;
- }
-
- private LogCatFilter createTransientAppFilter(String appName) {
- LogCatFilter f = new LogCatFilter(appName + " (Session Filter)",
- "",
- "",
- "",
- appName,
- LogLevel.VERBOSE);
- return f;
- }
-
- private void selectFilterAt(final int index) {
- mFiltersTableViewer.refresh();
-
- if (index != mFiltersTableViewer.getTable().getSelectionIndex()) {
- mFiltersTableViewer.getTable().setSelection(index);
- filterSelectionChanged();
- }
- }
-
- private void createFiltersTable(Composite parent) {
- final Table table = new Table(parent, SWT.FULL_SELECTION);
-
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan = 2;
- table.setLayoutData(gd);
-
- mFiltersTableViewer = new TableViewer(table);
- mFiltersTableViewer.setContentProvider(new LogCatFilterContentProvider());
- mFiltersTableViewer.setLabelProvider(new LogCatFilterLabelProvider(mLogCatFilterData));
- mFiltersTableViewer.setInput(mLogCatFilters);
-
- mFiltersTableViewer.getTable().addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- filterSelectionChanged();
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
- editSelectedFilter();
- }
- });
- }
-
- private void createLogTableView(SashForm sash) {
- Composite c = new Composite(sash, SWT.NONE);
- c.setLayout(new GridLayout());
- c.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- createLiveFilters(c);
- createLogcatViewTable(c);
- }
-
- /** Create the search bar at the top of the logcat messages table. */
- private void createLiveFilters(Composite parent) {
- Composite c = new Composite(parent, SWT.NONE);
- c.setLayout(new GridLayout(3, false));
- c.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- mLiveFilterText = new Text(c, SWT.BORDER | SWT.SEARCH);
- mLiveFilterText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mLiveFilterText.setMessage(DEFAULT_SEARCH_MESSAGE);
- mLiveFilterText.setToolTipText(DEFAULT_SEARCH_TOOLTIP);
- mLiveFilterText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent arg0) {
- updateFilterTextColor();
- updateAppliedFilters();
- }
- });
-
- mLiveFilterLevelCombo = new Combo(c, SWT.READ_ONLY | SWT.DROP_DOWN);
- mLiveFilterLevelCombo.setItems(
- LogCatFilterSettingsDialog.getLogLevels().toArray(new String[0]));
- mLiveFilterLevelCombo.select(0);
- mLiveFilterLevelCombo.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- updateAppliedFilters();
- }
- });
-
- ToolBar toolBar = new ToolBar(c, SWT.FLAT);
-
- ToolItem saveToLog = new ToolItem(toolBar, SWT.PUSH);
- saveToLog.setImage(ImageLoader.getDdmUiLibLoader().loadImage(IMAGE_SAVE_LOG_TO_FILE,
- toolBar.getDisplay()));
- saveToLog.setToolTipText("Export Selected Items To Text File..");
- saveToLog.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- saveLogToFile();
- }
- });
-
- ToolItem clearLog = new ToolItem(toolBar, SWT.PUSH);
- clearLog.setImage(
- ImageLoader.getDdmUiLibLoader().loadImage(IMAGE_CLEAR_LOG, toolBar.getDisplay()));
- clearLog.setToolTipText("Clear Log");
- clearLog.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- if (mReceiver != null) {
- mReceiver.clearMessages();
- refreshLogCatTable();
- resetUnreadCountForAllFilters();
-
- // the filters view is not cleared unless the filters are re-applied.
- updateAppliedFilters();
- }
- }
- });
-
- final ToolItem showFiltersColumn = new ToolItem(toolBar, SWT.CHECK);
- showFiltersColumn.setImage(
- ImageLoader.getDdmUiLibLoader().loadImage(IMAGE_DISPLAY_FILTERS,
- toolBar.getDisplay()));
- showFiltersColumn.setSelection(mPrefStore.getBoolean(DISPLAY_FILTERS_COLUMN_PREFKEY));
- showFiltersColumn.setToolTipText("Display Saved Filters View");
- showFiltersColumn.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- boolean showFilters = showFiltersColumn.getSelection();
- mPrefStore.setValue(DISPLAY_FILTERS_COLUMN_PREFKEY, showFilters);
- updateFiltersColumn(showFilters);
- }
- });
-
- mScrollLockCheckBox = new ToolItem(toolBar, SWT.CHECK);
- mScrollLockCheckBox.setImage(
- ImageLoader.getDdmUiLibLoader().loadImage(IMAGE_SCROLL_LOCK,
- toolBar.getDisplay()));
- mScrollLockCheckBox.setSelection(true);
- mScrollLockCheckBox.setToolTipText("Scroll Lock");
- mScrollLockCheckBox.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- boolean scrollLock = mScrollLockCheckBox.getSelection();
- setScrollToLatestLog(scrollLock);
- }
- });
- }
-
- /** Sets the foreground color of filter text based on whether the regex is valid. */
- private void updateFilterTextColor() {
- String text = mLiveFilterText.getText();
- Color c;
- try {
- Pattern.compile(text.trim());
- c = VALID_FILTER_REGEX_COLOR;
- } catch (PatternSyntaxException e) {
- c = INVALID_FILTER_REGEX_COLOR;
- }
- mLiveFilterText.setForeground(c);
- }
-
- private void updateFiltersColumn(boolean showFilters) {
- if (showFilters) {
- mSash.setWeights(WEIGHTS_SHOW_FILTERS);
- } else {
- mSash.setWeights(WEIGHTS_LOGCAT_ONLY);
- }
- }
-
- /**
- * Save logcat messages selected in the table to a file.
- */
- private void saveLogToFile() {
- /* show dialog box and get target file name */
- final String fName = getLogFileTargetLocation();
- if (fName == null) {
- return;
- }
-
- /* obtain list of selected messages */
- final List<LogCatMessage> selectedMessages = getSelectedLogCatMessages();
-
- /* save messages to file in a different (non UI) thread */
- Thread t = new Thread(new Runnable() {
- @Override
- public void run() {
- BufferedWriter w = null;
- try {
- w = new BufferedWriter(new FileWriter(fName));
- for (LogCatMessage m : selectedMessages) {
- w.append(m.toString());
- w.newLine();
- }
- } catch (final IOException e) {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- MessageDialog.openError(Display.getCurrent().getActiveShell(),
- "Unable to export selection to file.",
- "Unexpected error while saving selected messages to file: "
- + e.getMessage());
- }
- });
- } finally {
- if (w != null) {
- try {
- w.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
- }
- });
- t.setName("Saving selected items to logfile..");
- t.start();
- }
-
- /**
- * Display a {@link FileDialog} to the user and obtain the location for the log file.
- * @return path to target file, null if user canceled the dialog
- */
- private String getLogFileTargetLocation() {
- FileDialog fd = new FileDialog(Display.getCurrent().getActiveShell(), SWT.SAVE);
-
- fd.setText("Save Log..");
- fd.setFileName("log.txt");
-
- if (mLogFileExportFolder == null) {
- mLogFileExportFolder = System.getProperty("user.home");
- }
- fd.setFilterPath(mLogFileExportFolder);
-
- fd.setFilterNames(new String[] {
- "Text Files (*.txt)"
- });
- fd.setFilterExtensions(new String[] {
- "*.txt"
- });
-
- String fName = fd.open();
- if (fName != null) {
- mLogFileExportFolder = fd.getFilterPath(); /* save path to restore on future calls */
- }
-
- return fName;
- }
-
- private List<LogCatMessage> getSelectedLogCatMessages() {
- int[] indices = mTable.getSelectionIndices();
- Arrays.sort(indices); /* Table.getSelectionIndices() does not specify an order */
-
- List<LogCatMessage> selectedMessages = new ArrayList<LogCatMessage>(indices.length);
- for (int i : indices) {
- Object data = mTable.getItem(i).getData();
- if (data instanceof LogCatMessage) {
- selectedMessages.add((LogCatMessage) data);
- }
- }
-
- return selectedMessages;
- }
-
- private List<LogCatMessage> applyCurrentFilters(List<LogCatMessage> msgList) {
- List<LogCatMessage> filteredItems = new ArrayList<LogCatMessage>(msgList.size());
-
- for (LogCatMessage msg: msgList) {
- if (isMessageAccepted(msg, mCurrentFilters)) {
- filteredItems.add(msg);
- }
- }
-
- return filteredItems;
- }
-
- private boolean isMessageAccepted(LogCatMessage msg, List<LogCatFilter> filters) {
- for (LogCatFilter f : filters) {
- if (!f.matches(msg)) {
- // not accepted by this filter
- return false;
- }
- }
-
- // accepted by all filters
- return true;
- }
-
- private void createLogcatViewTable(Composite parent) {
- mTable = new Table(parent, SWT.FULL_SELECTION | SWT.MULTI);
-
- mTable.setLayoutData(new GridData(GridData.FILL_BOTH));
- mTable.getHorizontalBar().setVisible(true);
-
- /** Columns to show in the table. */
- String[] properties = {
- "Level",
- "Time",
- "PID",
- "TID",
- "Application",
- "Tag",
- "Text",
- };
-
- /** The sampleText for each column is used to determine the default widths
- * for each column. The contents do not matter, only their lengths are needed. */
- String[] sampleText = {
- " ",
- " 00-00 00:00:00.0000 ",
- " 0000",
- " 0000",
- " com.android.launcher",
- " SampleTagText",
- " Log Message field should be pretty long by default. As long as possible for correct display on Mac.",
- };
-
- for (int i = 0; i < properties.length; i++) {
- TableHelper.createTableColumn(mTable,
- properties[i], /* Column title */
- SWT.LEFT, /* Column Style */
- sampleText[i], /* String to compute default col width */
- getColPreferenceKey(properties[i]), /* Preference Store key for this column */
- mPrefStore);
- }
-
- // don't zebra stripe the table: When the buffer is full, and scroll lock is on, having
- // zebra striping means that the background could keep changing depending on the number
- // of new messages added to the bottom of the log.
- mTable.setLinesVisible(false);
- mTable.setHeaderVisible(true);
-
- // Set the row height to be sufficient enough to display the current font.
- // This is not strictly necessary, except that on WinXP, the rows showed up clipped. So
- // we explicitly set it to be sure.
- mTable.addListener(SWT.MeasureItem, new Listener() {
- @Override
- public void handleEvent(Event event) {
- event.height = event.gc.getFontMetrics().getHeight();
- }
- });
-
- // Update the label provider whenever the text column's width changes
- TableColumn textColumn = mTable.getColumn(properties.length - 1);
- textColumn.addControlListener(new ControlAdapter() {
- @Override
- public void controlResized(ControlEvent event) {
- recomputeWrapWidth();
- }
- });
-
- addRightClickMenu(mTable);
- initDoubleClickListener();
- recomputeWrapWidth();
-
- mTable.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent arg0) {
- dispose();
- }
- });
-
- final ScrollBar vbar = mTable.getVerticalBar();
- mScrollBarSelectionListener = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (!mAutoScrollLock) {
- return;
- }
-
- // thumb + selection < max => bar is not at the bottom.
- // We subtract an arbitrary amount (thumbSize/2) from this difference to allow
- // for cases like half a line being displayed at the end from affecting this
- // calculation. The thumbSize/2 number seems to work experimentally across
- // Linux/Mac & Windows, but might possibly need tweaking.
- int diff = vbar.getThumb() + vbar.getSelection() - vbar.getMaximum();
- boolean isAtBottom = Math.abs(diff) < vbar.getThumb() / 2;
-
- if (isAtBottom != mShouldScrollToLatestLog) {
- setScrollToLatestLog(isAtBottom);
- mScrollLockCheckBox.setSelection(isAtBottom);
- }
- }
- };
- startScrollBarMonitor(vbar);
-
- // Explicitly set the values to use for the scroll bar. In particular, we want these values
- // to have a high enough accuracy that even small movements of the scroll bar have an
- // effect on the selection. The auto scroll lock detection assumes that the scroll bar is
- // at the bottom iff selection + thumb == max.
- final int MAX = 10000;
- final int THUMB = 10;
- vbar.setValues(MAX - THUMB, // selection
- 0, // min
- MAX, // max
- THUMB, // thumb
- 1, // increment
- THUMB); // page increment
- }
-
- private void startScrollBarMonitor(ScrollBar vbar) {
- synchronized (mScrollBarSelectionListenerLock) {
- if (!mScrollBarListenerSet) {
- mScrollBarListenerSet = true;
- vbar.addSelectionListener(mScrollBarSelectionListener);
- }
- }
- }
-
- private void stopScrollBarMonitor(ScrollBar vbar) {
- synchronized (mScrollBarSelectionListenerLock) {
- if (mScrollBarListenerSet) {
- mScrollBarListenerSet = false;
- vbar.removeSelectionListener(mScrollBarSelectionListener);
- }
- }
- }
-
- /** Setup menu to be displayed when right clicking a log message. */
- private void addRightClickMenu(final Table table) {
- // This action will pop up a create filter dialog pre-populated with current selection
- final Action filterAction = new Action("Filter similar messages...") {
- @Override
- public void run() {
- List<LogCatMessage> selectedMessages = getSelectedLogCatMessages();
- if (selectedMessages.size() == 0) {
- addNewFilter();
- } else {
- LogCatMessage m = selectedMessages.get(0);
- addNewFilter(m.getTag(), m.getMessage(), m.getPid(), m.getAppName(),
- m.getLogLevel());
- }
- }
- };
-
- final Action findAction = new Action("Find...") {
- @Override
- public void run() {
- showFindDialog();
- };
- };
-
- final MenuManager mgr = new MenuManager();
- mgr.add(filterAction);
- mgr.add(findAction);
- final Menu menu = mgr.createContextMenu(table);
-
- table.addListener(SWT.MenuDetect, new Listener() {
- @Override
- public void handleEvent(Event event) {
- Point pt = table.getDisplay().map(null, table, new Point(event.x, event.y));
- Rectangle clientArea = table.getClientArea();
-
- // The click location is in the header if it is between
- // clientArea.y and clientArea.y + header height
- boolean header = pt.y > clientArea.y
- && pt.y < (clientArea.y + table.getHeaderHeight());
-
- // Show the menu only if it is not inside the header
- table.setMenu(header ? null : menu);
- }
- });
- }
-
- public void recomputeWrapWidth() {
- if (mTable == null || mTable.isDisposed()) {
- return;
- }
-
- // get width of the last column (log message)
- TableColumn tc = mTable.getColumn(mTable.getColumnCount() - 1);
- int colWidth = tc.getWidth();
-
- // get font width
- GC gc = new GC(tc.getParent());
- gc.setFont(mFont);
- int avgCharWidth = gc.getFontMetrics().getAverageCharWidth();
- gc.dispose();
-
- int MIN_CHARS_PER_LINE = 50; // show atleast these many chars per line
- mWrapWidthInChars = Math.max(colWidth/avgCharWidth, MIN_CHARS_PER_LINE);
-
- int OFFSET_AT_END_OF_LINE = 10; // leave some space at the end of the line
- mWrapWidthInChars -= OFFSET_AT_END_OF_LINE;
- }
-
- private void setScrollToLatestLog(boolean scroll) {
- mShouldScrollToLatestLog = scroll;
- if (scroll) {
- scrollToLatestLog();
- }
- }
-
- private String getColPreferenceKey(String field) {
- return LOGCAT_VIEW_COLSIZE_PREFKEY_PREFIX + field;
- }
-
- private Font getFontFromPrefStore() {
- FontData fd = PreferenceConverter.getFontData(mPrefStore,
- LogCatPanel.LOGCAT_VIEW_FONT_PREFKEY);
- return new Font(Display.getDefault(), fd);
- }
-
- private Color getColorFromPrefStore(String key) {
- RGB rgb = PreferenceConverter.getColor(mPrefStore, key);
- return new Color(Display.getDefault(), rgb);
- }
-
- private void setupDefaults() {
- int defaultFilterIndex = 0;
- mFiltersTableViewer.getTable().setSelection(defaultFilterIndex);
-
- filterSelectionChanged();
- }
-
- /**
- * Perform all necessary updates whenever a filter is selected (by user or programmatically).
- */
- private void filterSelectionChanged() {
- int idx = mFiltersTableViewer.getTable().getSelectionIndex();
- if (idx == -1) {
- /* One of the filters should always be selected.
- * On Linux, there is no way to deselect an item.
- * On Mac, clicking inside the list view, but not an any item will result
- * in all items being deselected. In such a case, we simply reselect the
- * first entry. */
- idx = 0;
- mFiltersTableViewer.getTable().setSelection(idx);
- }
-
- mCurrentSelectedFilterIndex = idx;
-
- resetUnreadCountForAllFilters();
- updateFiltersToolBar();
- updateAppliedFilters();
- }
-
- private void resetUnreadCountForAllFilters() {
- for (LogCatFilterData fd: mLogCatFilterData.values()) {
- fd.resetUnreadCount();
- }
- refreshFiltersTable();
- }
-
- private void updateFiltersToolBar() {
- /* The default filter at index 0 can neither be edited, nor removed. */
- boolean en = mCurrentSelectedFilterIndex != DEFAULT_FILTER_INDEX;
- mEditFilterToolItem.setEnabled(en);
- mDeleteFilterToolItem.setEnabled(en);
- }
-
- private void updateAppliedFilters() {
- mCurrentFilters = getFiltersToApply();
- reloadLogBuffer();
- }
-
- private List<LogCatFilter> getFiltersToApply() {
- /* list of filters to apply = saved filter + live filters */
- List<LogCatFilter> filters = new ArrayList<LogCatFilter>();
-
- if (mCurrentSelectedFilterIndex != DEFAULT_FILTER_INDEX) {
- filters.add(getSelectedSavedFilter());
- }
-
- filters.addAll(getCurrentLiveFilters());
- return filters;
- }
-
- private List<LogCatFilter> getCurrentLiveFilters() {
- return LogCatFilter.fromString(
- mLiveFilterText.getText(), /* current query */
- LogLevel.getByString(mLiveFilterLevelCombo.getText())); /* current log level */
- }
-
- private LogCatFilter getSelectedSavedFilter() {
- return mLogCatFilters.get(mCurrentSelectedFilterIndex);
- }
-
- @Override
- public void setFocus() {
- }
-
- @Override
- public void bufferChanged(List<LogCatMessage> addedMessages,
- List<LogCatMessage> deletedMessages) {
- updateUnreadCount(addedMessages);
- refreshFiltersTable();
-
- synchronized (mLogBuffer) {
- addedMessages = applyCurrentFilters(addedMessages);
- deletedMessages = applyCurrentFilters(deletedMessages);
-
- mLogBuffer.addAll(addedMessages);
- mDeletedLogCount += deletedMessages.size();
- }
-
- refreshLogCatTable();
- }
-
- private void reloadLogBuffer() {
- mTable.removeAll();
-
- synchronized (mLogBuffer) {
- mLogBuffer.clear();
- mDeletedLogCount = 0;
- }
-
- if (mReceiver == null || mReceiver.getMessages() == null) {
- return;
- }
-
- List<LogCatMessage> addedMessages = mReceiver.getMessages().getAllMessages();
- List<LogCatMessage> deletedMessages = Collections.emptyList();
- bufferChanged(addedMessages, deletedMessages);
- }
-
- /**
- * When new messages are received, and they match a saved filter, update
- * the unread count associated with that filter.
- * @param receivedMessages list of new messages received
- */
- private void updateUnreadCount(List<LogCatMessage> receivedMessages) {
- for (int i = 0; i < mLogCatFilters.size(); i++) {
- if (i == mCurrentSelectedFilterIndex) {
- /* no need to update unread count for currently selected filter */
- continue;
- }
- LogCatFilter f = mLogCatFilters.get(i);
- LogCatFilterData fd = mLogCatFilterData.get(f);
- fd.updateUnreadCount(receivedMessages);
- }
- }
-
- private void refreshFiltersTable() {
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (mFiltersTableViewer.getTable().isDisposed()) {
- return;
- }
- mFiltersTableViewer.refresh();
- }
- });
- }
-
- /** Task currently submitted to {@link Display#asyncExec} to be run in UI thread. */
- private LogCatTableRefresherTask mCurrentRefresher;
-
- /**
- * Refresh the logcat table asynchronously from the UI thread.
- * This method adds a new async refresh only if there are no pending refreshes for the table.
- * Doing so eliminates redundant refresh threads from being queued up to be run on the
- * display thread.
- */
- private void refreshLogCatTable() {
- synchronized (this) {
- if (mCurrentRefresher == null) {
- mCurrentRefresher = new LogCatTableRefresherTask();
- Display.getDefault().asyncExec(mCurrentRefresher);
- }
- }
- }
-
- /**
- * The {@link LogCatTableRefresherTask} takes care of refreshing the table with the
- * new log messages that have been received. Since the log behaves like a circular buffer,
- * the first step is to remove items from the top of the table (if necessary). This step
- * is complicated by the fact that a single log message may span multiple rows if the message
- * was wrapped. Once the deleted items are removed, the new messages are added to the bottom
- * of the table. If scroll lock is enabled, the item that was original visible is made visible
- * again, if not, the last item is made visible.
- */
- private class LogCatTableRefresherTask implements Runnable {
- @Override
- public void run() {
- if (mTable.isDisposed()) {
- return;
- }
- synchronized (LogCatPanel.this) {
- mCurrentRefresher = null;
- }
-
- // Current topIndex so that it can be restored if scroll locked.
- int topIndex = mTable.getTopIndex();
-
- mTable.setRedraw(false);
-
- // the scroll bar should only listen to user generated scroll events, not the
- // scroll events that happen due to the addition of logs
- stopScrollBarMonitor(mTable.getVerticalBar());
-
- // Obtain the list of new messages, and the number of deleted messages.
- List<LogCatMessage> newMessages;
- int deletedMessageCount;
- synchronized (mLogBuffer) {
- newMessages = new ArrayList<LogCatMessage>(mLogBuffer);
- mLogBuffer.clear();
-
- deletedMessageCount = mDeletedLogCount;
- mDeletedLogCount = 0;
-
- mFindTarget.scrollBy(deletedMessageCount);
- }
-
- int originalItemCount = mTable.getItemCount();
-
- // Remove entries from the start of the table if they were removed in the log buffer
- // This is complicated by the fact that a single message may span multiple TableItems
- // if it was word-wrapped.
- deletedMessageCount -= removeFromTable(mTable, deletedMessageCount);
-
- // Compute number of table items that were deleted from the table.
- int deletedItemCount = originalItemCount - mTable.getItemCount();
-
- // If there are more messages to delete (after deleting messages from the table),
- // then delete them from the start of the newly added messages list
- if (deletedMessageCount > 0) {
- assert deletedMessageCount < newMessages.size();
- for (int i = 0; i < deletedMessageCount; i++) {
- newMessages.remove(0);
- }
- }
-
- // Add the remaining messages to the table.
- for (LogCatMessage m: newMessages) {
- List<String> wrappedMessageList = wrapMessage(m.getMessage(), mWrapWidthInChars);
- Color c = getForegroundColor(m);
- for (int i = 0; i < wrappedMessageList.size(); i++) {
- TableItem item = new TableItem(mTable, SWT.NONE);
-
- if (i == 0) {
- // Only set the message data in the first item. This allows code that
- // examines the table item data (such as copy selection) to distinguish
- // between real messages versus lines that are really just wrapped
- // content from the previous message.
- item.setData(m);
-
- item.setText(new String[] {
- Character.toString(m.getLogLevel().getPriorityLetter()),
- m.getTime(),
- m.getPid(),
- m.getTid(),
- m.getAppName(),
- m.getTag(),
- wrappedMessageList.get(i)
- });
- } else {
- item.setText(new String[] {
- "", "", "", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "", "", "", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- wrappedMessageList.get(i)
- });
- }
- item.setForeground(c);
- item.setFont(mFont);
- }
- }
-
- if (mShouldScrollToLatestLog) {
- scrollToLatestLog();
- } else {
- // If scroll locked, show the same item that was original visible in the table.
- int index = Math.max(topIndex - deletedItemCount, 0);
- mTable.setTopIndex(index);
- }
-
- mTable.setRedraw(true);
-
- // re-enable listening to scroll bar events, but do so in a separate thread to make
- // sure that the current task (LogCatRefresherTask) has completed first
- Display.getDefault().asyncExec(new Runnable() {
- @Override
- public void run() {
- if (!mTable.isDisposed()) {
- startScrollBarMonitor(mTable.getVerticalBar());
- }
- }
- });
- }
-
- /**
- * Removes given number of messages from the table, starting at the top of the table.
- * Note that the number of messages deleted is not equal to the number of rows
- * deleted since a single message could span multiple rows. This method first calculates
- * the number of rows that correspond to the number of messages to delete, and then
- * removes all those rows.
- * @param table table from which messages should be removed
- * @param msgCount number of messages to be removed
- * @return number of messages that were actually removed
- */
- private int removeFromTable(Table table, int msgCount) {
- int deletedMessageCount = 0; // # of messages that have been deleted
- int lastItemToDelete = 0; // index of the last item that should be deleted
-
- while (deletedMessageCount < msgCount && lastItemToDelete < table.getItemCount()) {
- // only rows that begin a message have their item data set
- TableItem item = table.getItem(lastItemToDelete);
- if (item.getData() != null) {
- deletedMessageCount++;
- }
-
- lastItemToDelete++;
- }
-
- // If there are any table items left over at the end that are wrapped over from the
- // previous message, mark them for deletion as well.
- if (lastItemToDelete < table.getItemCount()
- && table.getItem(lastItemToDelete).getData() == null) {
- lastItemToDelete++;
- }
-
- table.remove(0, lastItemToDelete - 1);
-
- return deletedMessageCount;
- }
- }
-
- /** Scroll to the last line. */
- private void scrollToLatestLog() {
- if (!mTable.isDisposed()) {
- mTable.setTopIndex(mTable.getItemCount() - 1);
- }
- }
-
- /**
- * Splits the message into multiple lines if the message length exceeds given width.
- * If the message was split, then a wrap character \u23ce is appended to the end of all
- * lines but the last one.
- */
- private List<String> wrapMessage(String msg, int wrapWidth) {
- if (msg.length() < wrapWidth) {
- return Collections.singletonList(msg);
- }
-
- List<String> wrappedMessages = new ArrayList<String>();
-
- int offset = 0;
- int len = msg.length();
-
- while (len > 0) {
- int copylen = Math.min(wrapWidth, len);
- String s = msg.substring(offset, offset + copylen);
-
- offset += copylen;
- len -= copylen;
-
- if (len > 0) { // if there are more lines following, then append a wrap marker
- s += " \u23ce"; //$NON-NLS-1$
- }
-
- wrappedMessages.add(s);
- }
-
- return wrappedMessages;
- }
-
- private Color getForegroundColor(LogCatMessage m) {
- LogLevel l = m.getLogLevel();
-
- if (l.equals(LogLevel.VERBOSE)) {
- return mVerboseColor;
- } else if (l.equals(LogLevel.INFO)) {
- return mInfoColor;
- } else if (l.equals(LogLevel.DEBUG)) {
- return mDebugColor;
- } else if (l.equals(LogLevel.ERROR)) {
- return mErrorColor;
- } else if (l.equals(LogLevel.WARN)) {
- return mWarnColor;
- } else if (l.equals(LogLevel.ASSERT)) {
- return mAssertColor;
- }
-
- return mVerboseColor;
- }
-
- private List<ILogCatMessageSelectionListener> mMessageSelectionListeners;
-
- private void initDoubleClickListener() {
- mMessageSelectionListeners = new ArrayList<ILogCatMessageSelectionListener>(1);
-
- mTable.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetDefaultSelected(SelectionEvent arg0) {
- List<LogCatMessage> selectedMessages = getSelectedLogCatMessages();
- if (selectedMessages.size() == 0) {
- return;
- }
-
- for (ILogCatMessageSelectionListener l : mMessageSelectionListeners) {
- l.messageDoubleClicked(selectedMessages.get(0));
- }
- }
- });
- }
-
- public void addLogCatMessageSelectionListener(ILogCatMessageSelectionListener l) {
- mMessageSelectionListeners.add(l);
- }
-
- private ITableFocusListener mTableFocusListener;
-
- /**
- * Specify the listener to be called when the logcat view gets focus. This interface is
- * required by DDMS to hook up the menu items for Copy and Select All.
- * @param listener listener to be notified when logcat view is in focus
- */
- public void setTableFocusListener(ITableFocusListener listener) {
- mTableFocusListener = listener;
-
- final IFocusedTableActivator activator = new IFocusedTableActivator() {
- @Override
- public void copy(Clipboard clipboard) {
- copySelectionToClipboard(clipboard);
- }
-
- @Override
- public void selectAll() {
- mTable.selectAll();
- }
- };
-
- mTable.addFocusListener(new FocusListener() {
- @Override
- public void focusGained(FocusEvent e) {
- mTableFocusListener.focusGained(activator);
- }
-
- @Override
- public void focusLost(FocusEvent e) {
- mTableFocusListener.focusLost(activator);
- }
- });
- }
-
- /** Copy all selected messages to clipboard. */
- public void copySelectionToClipboard(Clipboard clipboard) {
- StringBuilder sb = new StringBuilder();
-
- for (LogCatMessage m : getSelectedLogCatMessages()) {
- sb.append(m.toString());
- sb.append('\n');
- }
-
- if (sb.length() > 0) {
- clipboard.setContents(
- new Object[] {sb.toString()},
- new Transfer[] {TextTransfer.getInstance()}
- );
- }
- }
-
- /** Select all items in the logcat table. */
- public void selectAll() {
- mTable.selectAll();
- }
-
- private void dispose() {
- if (mFont != null && !mFont.isDisposed()) {
- mFont.dispose();
- }
-
- if (mVerboseColor != null && !mVerboseColor.isDisposed()) {
- disposeMessageColors();
- }
- }
-
- private void disposeMessageColors() {
- mVerboseColor.dispose();
- mDebugColor.dispose();
- mInfoColor.dispose();
- mWarnColor.dispose();
- mErrorColor.dispose();
- mAssertColor.dispose();
- }
-
- private class LogcatFindTarget extends AbstractBufferFindTarget {
- @Override
- public void selectAndReveal(int index) {
- mTable.deselectAll();
- mTable.select(index);
- mTable.showSelection();
- }
-
- @Override
- public int getItemCount() {
- return mTable.getItemCount();
- }
-
- @Override
- public String getItem(int index) {
- Object data = mTable.getItem(index).getData();
- if (data != null) {
- return data.toString();
- }
-
- return null;
- }
-
- @Override
- public int getStartingIndex() {
- // start searches from current selection if present, otherwise from the tail end
- // of the buffer
- int s = mTable.getSelectionIndex();
- if (s != -1) {
- return s;
- } else {
- return getItemCount() - 1;
- }
- };
- };
-
- private FindDialog mFindDialog;
- private LogcatFindTarget mFindTarget = new LogcatFindTarget();
- public void showFindDialog() {
- if (mFindDialog != null) {
- // if the dialog is already displayed
- return;
- }
-
- mFindDialog = new FindDialog(Display.getDefault().getActiveShell(), mFindTarget);
- mFindDialog.open(); // blocks until find dialog is closed
- mFindDialog = null;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatReceiver.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatReceiver.java
deleted file mode 100644
index a85cd03..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatReceiver.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.logcat.LogCatListener;
-import com.android.ddmlib.logcat.LogCatMessage;
-import com.android.ddmlib.logcat.LogCatReceiverTask;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * A class to monitor a device for logcat messages. It stores the received
- * log messages in a circular buffer.
- */
-public final class LogCatReceiver implements LogCatListener {
- private static LogCatMessage DEVICE_DISCONNECTED_MESSAGE =
- new LogCatMessage(LogLevel.ERROR, "", "", "",
- "", "", "Device disconnected");
-
- private LogCatMessageList mLogMessages;
- private IDevice mCurrentDevice;
- private LogCatReceiverTask mLogCatReceiverTask;
- private Set<ILogCatBufferChangeListener> mLogCatMessageListeners;
- private IPreferenceStore mPrefStore;
-
- /**
- * Construct a LogCat message receiver for provided device. This will launch a
- * logcat command on the device, and monitor the output of that command in
- * a separate thread. All logcat messages are then stored in a circular
- * buffer, which can be retrieved using {@link LogCatReceiver#getMessages()}.
- * @param device device to monitor for logcat messages
- * @param prefStore
- */
- public LogCatReceiver(IDevice device, IPreferenceStore prefStore) {
- mCurrentDevice = device;
- mPrefStore = prefStore;
-
- mLogCatMessageListeners = new HashSet<ILogCatBufferChangeListener>();
- mLogMessages = new LogCatMessageList(getFifoSize());
-
- startReceiverThread();
- }
-
- /**
- * Stop receiving messages from currently active device.
- */
- public void stop() {
- if (mLogCatReceiverTask != null) {
- /* stop the current logcat command */
- mLogCatReceiverTask.removeLogCatListener(this);
- mLogCatReceiverTask.stop();
- mLogCatReceiverTask = null;
-
- // add a message to the log indicating that the device has been disconnected.
- log(Collections.singletonList(DEVICE_DISCONNECTED_MESSAGE));
- }
-
- mCurrentDevice = null;
- }
-
- private int getFifoSize() {
- int n = mPrefStore.getInt(LogCatMessageList.MAX_MESSAGES_PREFKEY);
- return n == 0 ? LogCatMessageList.MAX_MESSAGES_DEFAULT : n;
- }
-
- private void startReceiverThread() {
- if (mCurrentDevice == null) {
- return;
- }
-
- mLogCatReceiverTask = new LogCatReceiverTask(mCurrentDevice);
- mLogCatReceiverTask.addLogCatListener(this);
-
- Thread t = new Thread(mLogCatReceiverTask);
- t.setName("LogCat output receiver for " + mCurrentDevice.getSerialNumber());
- t.start();
- }
-
- @Override
- public void log(List<LogCatMessage> newMessages) {
- List<LogCatMessage> deletedMessages;
- synchronized (mLogMessages) {
- deletedMessages = mLogMessages.ensureSpace(newMessages.size());
- mLogMessages.appendMessages(newMessages);
- }
- sendLogChangedEvent(newMessages, deletedMessages);
- }
-
- /**
- * Get the list of logcat messages received from currently active device.
- * @return list of messages if currently listening, null otherwise
- */
- public LogCatMessageList getMessages() {
- return mLogMessages;
- }
-
- /**
- * Clear the list of messages received from the currently active device.
- */
- public void clearMessages() {
- mLogMessages.clear();
- }
-
- /**
- * Add to list of message event listeners.
- * @param l listener to notified when messages are received from the device
- */
- public void addMessageReceivedEventListener(ILogCatBufferChangeListener l) {
- mLogCatMessageListeners.add(l);
- }
-
- public void removeMessageReceivedEventListener(ILogCatBufferChangeListener l) {
- mLogCatMessageListeners.remove(l);
- }
-
- private void sendLogChangedEvent(List<LogCatMessage> addedMessages,
- List<LogCatMessage> deletedMessages) {
- for (ILogCatBufferChangeListener l : mLogCatMessageListeners) {
- l.bufferChanged(addedMessages, deletedMessages);
- }
- }
-
- /**
- * Resize the internal FIFO.
- * @param size new size
- */
- public void resizeFifo(int size) {
- mLogMessages.resize(size);
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatReceiverFactory.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatReceiverFactory.java
deleted file mode 100644
index 5b25e17..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatReceiverFactory.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmlib.AndroidDebugBridge;
-import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
-import com.android.ddmlib.IDevice;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * A factory for {@link LogCatReceiver} objects. Its primary objective is to cache
- * constructed {@link LogCatReceiver}'s per device and hand them back when requested.
- */
-public class LogCatReceiverFactory {
- /** Singleton instance. */
- public static final LogCatReceiverFactory INSTANCE = new LogCatReceiverFactory();
-
- private Map<String, LogCatReceiver> mReceiverCache = new HashMap<String, LogCatReceiver>();
-
- /** Private constructor: cannot instantiate. */
- private LogCatReceiverFactory() {
- AndroidDebugBridge.addDeviceChangeListener(new IDeviceChangeListener() {
- @Override
- public void deviceDisconnected(final IDevice device) {
- // The deviceDisconnected() is called from DDMS code that holds
- // multiple locks regarding list of clients, etc.
- // It so happens that #newReceiver() below adds a clientChangeListener
- // which requires those locks as well. So if we call
- // #removeReceiverFor from a DDMS/Monitor thread, we could end up
- // in a deadlock. As a result, we spawn a separate thread that
- // doesn't hold any of the DDMS locks to remove the receiver.
- Thread t = new Thread(new Runnable() {
- @Override
- public void run() {
- removeReceiverFor(device); }
- }, "Remove logcat receiver for " + device.getSerialNumber());
- t.start();
- }
-
- @Override
- public void deviceConnected(IDevice device) {
- }
-
- @Override
- public void deviceChanged(IDevice device, int changeMask) {
- }
- });
- }
-
- /**
- * Remove existing logcat receivers. This method should not be called from a DDMS thread
- * context that might be holding locks. Doing so could result in a deadlock with the following
- * two threads locked up: <ul>
- * <li> {@link #removeReceiverFor(IDevice)} waiting to lock {@link LogCatReceiverFactory},
- * while holding a DDMS monitor internal lock. </li>
- * <li> {@link #newReceiver(IDevice, IPreferenceStore)} holding {@link LogCatReceiverFactory}
- * while attempting to obtain a DDMS monitor lock. </li>
- * </ul>
- */
- private synchronized void removeReceiverFor(IDevice device) {
- LogCatReceiver r = mReceiverCache.get(device.getSerialNumber());
- if (r != null) {
- r.stop();
- mReceiverCache.remove(device.getSerialNumber());
- }
- }
-
- public synchronized LogCatReceiver newReceiver(IDevice device, IPreferenceStore prefs) {
- LogCatReceiver r = mReceiverCache.get(device.getSerialNumber());
- if (r != null) {
- return r;
- }
-
- r = new LogCatReceiver(device, prefs);
- mReceiverCache.put(device.getSerialNumber(), r);
- return r;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatStackTraceParser.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatStackTraceParser.java
deleted file mode 100644
index 3da9fd0..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogCatStackTraceParser.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ddmuilib.logcat;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * Helper class that can determine if a string matches the exception
- * stack trace pattern, and if so, can provide the java source file
- * and line where the exception occured.
- */
-public final class LogCatStackTraceParser {
- /** Regex to match a stack trace line. E.g.:
- * at com.foo.Class.method(FileName.extension:10)
- * extension is typically java, but can be anything (java/groovy/scala/..).
- */
- private static final String EXCEPTION_LINE_REGEX =
- "\\s*at\\ (.*)\\((.*)\\..*\\:(\\d+)\\)"; //$NON-NLS-1$
-
- private static final Pattern EXCEPTION_LINE_PATTERN =
- Pattern.compile(EXCEPTION_LINE_REGEX);
-
- /**
- * Identify if a input line matches the expected pattern
- * for a stack trace from an exception.
- */
- public boolean isValidExceptionTrace(String line) {
- return EXCEPTION_LINE_PATTERN.matcher(line).find();
- }
-
- /**
- * Get fully qualified method name that threw the exception.
- * @param line line from the stack trace, must have been validated with
- * {@link LogCatStackTraceParser#isValidExceptionTrace(String)} before calling this method.
- * @return fully qualified method name
- */
- public String getMethodName(String line) {
- Matcher m = EXCEPTION_LINE_PATTERN.matcher(line);
- m.find();
- return m.group(1);
- }
-
- /**
- * Get source file name where exception was generated. Input line must be first validated with
- * {@link LogCatStackTraceParser#isValidExceptionTrace(String)}.
- */
- public String getFileName(String line) {
- Matcher m = EXCEPTION_LINE_PATTERN.matcher(line);
- m.find();
- return m.group(2);
- }
-
- /**
- * Get line number where exception was generated. Input line must be first validated with
- * {@link LogCatStackTraceParser#isValidExceptionTrace(String)}.
- */
- public int getLineNumber(String line) {
- Matcher m = EXCEPTION_LINE_PATTERN.matcher(line);
- m.find();
- try {
- return Integer.parseInt(m.group(3));
- } catch (NumberFormatException e) {
- return 0;
- }
- }
-
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogColors.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogColors.java
deleted file mode 100644
index 9cff656..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogColors.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.logcat;
-
-import org.eclipse.swt.graphics.Color;
-
-public class LogColors {
- public Color infoColor;
- public Color debugColor;
- public Color errorColor;
- public Color warningColor;
- public Color verboseColor;
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogFilter.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogFilter.java
deleted file mode 100644
index 74a5e37..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogFilter.java
+++ /dev/null
@@ -1,556 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmlib.Log;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmuilib.annotation.UiThread;
-import com.android.ddmuilib.logcat.LogPanel.LogMessage;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.widgets.ScrollBar;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-
-import java.util.ArrayList;
-import java.util.regex.PatternSyntaxException;
-
-/** logcat output filter class */
-public class LogFilter {
-
- public final static int MODE_PID = 0x01;
- public final static int MODE_TAG = 0x02;
- public final static int MODE_LEVEL = 0x04;
-
- private String mName;
-
- /**
- * Filtering mode. Value can be a mix of MODE_PID, MODE_TAG, MODE_LEVEL
- */
- private int mMode = 0;
-
- /**
- * pid used for filtering. Only valid if mMode is MODE_PID.
- */
- private int mPid;
-
- /** Single level log level as defined in Log.mLevelChar. Only valid
- * if mMode is MODE_LEVEL */
- private int mLogLevel;
-
- /**
- * log tag filtering. Only valid if mMode is MODE_TAG
- */
- private String mTag;
-
- private Table mTable;
- private TabItem mTabItem;
- private boolean mIsCurrentTabItem = false;
- private int mUnreadCount = 0;
-
- /** Temp keyword filtering */
- private String[] mTempKeywordFilters;
-
- /** temp pid filtering */
- private int mTempPid = -1;
-
- /** temp tag filtering */
- private String mTempTag;
-
- /** temp log level filtering */
- private int mTempLogLevel = -1;
-
- private LogColors mColors;
-
- private boolean mTempFilteringStatus = false;
-
- private final ArrayList<LogMessage> mMessages = new ArrayList<LogMessage>();
- private final ArrayList<LogMessage> mNewMessages = new ArrayList<LogMessage>();
-
- private boolean mSupportsDelete = true;
- private boolean mSupportsEdit = true;
- private int mRemovedMessageCount = 0;
-
- /**
- * Creates a filter with a particular mode.
- * @param name The name to be displayed in the UI
- */
- public LogFilter(String name) {
- mName = name;
- }
-
- public LogFilter() {
-
- }
-
- @Override
- public String toString() {
- StringBuilder sb = new StringBuilder(mName);
-
- sb.append(':');
- sb.append(mMode);
- if ((mMode & MODE_PID) == MODE_PID) {
- sb.append(':');
- sb.append(mPid);
- }
-
- if ((mMode & MODE_LEVEL) == MODE_LEVEL) {
- sb.append(':');
- sb.append(mLogLevel);
- }
-
- if ((mMode & MODE_TAG) == MODE_TAG) {
- sb.append(':');
- sb.append(mTag);
- }
-
- return sb.toString();
- }
-
- public boolean loadFromString(String string) {
- String[] segments = string.split(":"); //$NON-NLS-1$
- int index = 0;
-
- // get the name
- mName = segments[index++];
-
- // get the mode
- mMode = Integer.parseInt(segments[index++]);
-
- if ((mMode & MODE_PID) == MODE_PID) {
- mPid = Integer.parseInt(segments[index++]);
- }
-
- if ((mMode & MODE_LEVEL) == MODE_LEVEL) {
- mLogLevel = Integer.parseInt(segments[index++]);
- }
-
- if ((mMode & MODE_TAG) == MODE_TAG) {
- mTag = segments[index++];
- }
-
- return true;
- }
-
-
- /** Sets the name of the filter. */
- void setName(String name) {
- mName = name;
- }
-
- /**
- * Returns the UI display name.
- */
- public String getName() {
- return mName;
- }
-
- /**
- * Set the Table ui widget associated with this filter.
- * @param tabItem The item in the TabFolder
- * @param table The Table object
- */
- public void setWidgets(TabItem tabItem, Table table) {
- mTable = table;
- mTabItem = tabItem;
- }
-
- /**
- * Returns true if the filter is ready for ui.
- */
- public boolean uiReady() {
- return (mTable != null && mTabItem != null);
- }
-
- /**
- * Returns the UI table object.
- * @return
- */
- public Table getTable() {
- return mTable;
- }
-
- public void dispose() {
- mTable.dispose();
- mTabItem.dispose();
- mTable = null;
- mTabItem = null;
- }
-
- /**
- * Resets the filtering mode to be 0 (i.e. no filter).
- */
- public void resetFilteringMode() {
- mMode = 0;
- }
-
- /**
- * Returns the current filtering mode.
- * @return A bitmask. Possible values are MODE_PID, MODE_TAG, MODE_LEVEL
- */
- public int getFilteringMode() {
- return mMode;
- }
-
- /**
- * Adds PID to the current filtering mode.
- * @param pid
- */
- public void setPidMode(int pid) {
- if (pid != -1) {
- mMode |= MODE_PID;
- } else {
- mMode &= ~MODE_PID;
- }
- mPid = pid;
- }
-
- /** Returns the pid filter if valid, otherwise -1 */
- public int getPidFilter() {
- if ((mMode & MODE_PID) == MODE_PID)
- return mPid;
- return -1;
- }
-
- public void setTagMode(String tag) {
- if (tag != null && tag.length() > 0) {
- mMode |= MODE_TAG;
- } else {
- mMode &= ~MODE_TAG;
- }
- mTag = tag;
- }
-
- public String getTagFilter() {
- if ((mMode & MODE_TAG) == MODE_TAG)
- return mTag;
- return null;
- }
-
- public void setLogLevel(int level) {
- if (level == -1) {
- mMode &= ~MODE_LEVEL;
- } else {
- mMode |= MODE_LEVEL;
- mLogLevel = level;
- }
-
- }
-
- public int getLogLevel() {
- if ((mMode & MODE_LEVEL) == MODE_LEVEL) {
- return mLogLevel;
- }
-
- return -1;
- }
-
-
- public boolean supportsDelete() {
- return mSupportsDelete ;
- }
-
- public boolean supportsEdit() {
- return mSupportsEdit;
- }
-
- /**
- * Sets the selected state of the filter.
- * @param selected selection state.
- */
- public void setSelectedState(boolean selected) {
- if (selected) {
- if (mTabItem != null) {
- mTabItem.setText(mName);
- }
- mUnreadCount = 0;
- }
- mIsCurrentTabItem = selected;
- }
-
- /**
- * Adds a new message and optionally removes an old message.
- * <p/>The new message is filtered through {@link #accept(LogMessage)}.
- * Calls to {@link #flush()} from a UI thread will display it (and other
- * pending messages) to the associated {@link Table}.
- * @param logMessage the MessageData object to filter
- * @return true if the message was accepted.
- */
- public boolean addMessage(LogMessage newMessage, LogMessage oldMessage) {
- synchronized (mMessages) {
- if (oldMessage != null) {
- int index = mMessages.indexOf(oldMessage);
- if (index != -1) {
- // TODO check that index will always be -1 or 0, as only the oldest message is ever removed.
- mMessages.remove(index);
- mRemovedMessageCount++;
- }
-
- // now we look for it in mNewMessages. This can happen if the new message is added
- // and then removed because too many messages are added between calls to #flush()
- index = mNewMessages.indexOf(oldMessage);
- if (index != -1) {
- // TODO check that index will always be -1 or 0, as only the oldest message is ever removed.
- mNewMessages.remove(index);
- }
- }
-
- boolean filter = accept(newMessage);
-
- if (filter) {
- // at this point the message is accepted, we add it to the list
- mMessages.add(newMessage);
- mNewMessages.add(newMessage);
- }
-
- return filter;
- }
- }
-
- /**
- * Removes all the items in the filter and its {@link Table}.
- */
- public void clear() {
- mRemovedMessageCount = 0;
- mNewMessages.clear();
- mMessages.clear();
- mTable.removeAll();
- }
-
- /**
- * Filters a message.
- * @param logMessage the Message
- * @return true if the message is accepted by the filter.
- */
- boolean accept(LogMessage logMessage) {
- // do the regular filtering now
- if ((mMode & MODE_PID) == MODE_PID && mPid != logMessage.data.pid) {
- return false;
- }
-
- if ((mMode & MODE_TAG) == MODE_TAG && (
- logMessage.data.tag == null ||
- logMessage.data.tag.equals(mTag) == false)) {
- return false;
- }
-
- int msgLogLevel = logMessage.data.logLevel.getPriority();
-
- // test the temp log filtering first, as it replaces the old one
- if (mTempLogLevel != -1) {
- if (mTempLogLevel > msgLogLevel) {
- return false;
- }
- } else if ((mMode & MODE_LEVEL) == MODE_LEVEL &&
- mLogLevel > msgLogLevel) {
- return false;
- }
-
- // do the temp filtering now.
- if (mTempKeywordFilters != null) {
- String msg = logMessage.msg;
-
- for (String kw : mTempKeywordFilters) {
- try {
- if (msg.contains(kw) == false && msg.matches(kw) == false) {
- return false;
- }
- } catch (PatternSyntaxException e) {
- // if the string is not a valid regular expression,
- // this exception is thrown.
- return false;
- }
- }
- }
-
- if (mTempPid != -1 && mTempPid != logMessage.data.pid) {
- return false;
- }
-
- if (mTempTag != null && mTempTag.length() > 0) {
- if (mTempTag.equals(logMessage.data.tag) == false) {
- return false;
- }
- }
-
- return true;
- }
-
- /**
- * Takes all the accepted messages and display them.
- * This must be called from a UI thread.
- */
- @UiThread
- public void flush() {
- // if scroll bar is at the bottom, we will scroll
- ScrollBar bar = mTable.getVerticalBar();
- boolean scroll = bar.getMaximum() == bar.getSelection() + bar.getThumb();
-
- // if we are not going to scroll, get the current first item being shown.
- int topIndex = mTable.getTopIndex();
-
- // disable drawing
- mTable.setRedraw(false);
-
- int totalCount = mNewMessages.size();
-
- try {
- // remove the items of the old messages.
- for (int i = 0 ; i < mRemovedMessageCount && mTable.getItemCount() > 0 ; i++) {
- mTable.remove(0);
- }
- mRemovedMessageCount = 0;
-
- if (mUnreadCount > mTable.getItemCount()) {
- mUnreadCount = mTable.getItemCount();
- }
-
- // add the new items
- for (int i = 0 ; i < totalCount ; i++) {
- LogMessage msg = mNewMessages.get(i);
- addTableItem(msg);
- }
- } catch (SWTException e) {
- // log the error and keep going. Content of the logcat table maybe unexpected
- // but at least ddms won't crash.
- Log.e("LogFilter", e);
- }
-
- // redraw
- mTable.setRedraw(true);
-
- // scroll if needed, by showing the last item
- if (scroll) {
- totalCount = mTable.getItemCount();
- if (totalCount > 0) {
- mTable.showItem(mTable.getItem(totalCount-1));
- }
- } else if (mRemovedMessageCount > 0) {
- // we need to make sure the topIndex is still visible.
- // Because really old items are removed from the list, this could make it disappear
- // if we don't change the scroll value at all.
-
- topIndex -= mRemovedMessageCount;
- if (topIndex < 0) {
- // looks like it disappeared. Lets just show the first item
- mTable.showItem(mTable.getItem(0));
- } else {
- mTable.showItem(mTable.getItem(topIndex));
- }
- }
-
- // if this filter is not the current one, we update the tab text
- // with the amount of unread message
- if (mIsCurrentTabItem == false) {
- mUnreadCount += mNewMessages.size();
- totalCount = mTable.getItemCount();
- if (mUnreadCount > 0) {
- mTabItem.setText(mName + " (" //$NON-NLS-1$
- + (mUnreadCount > totalCount ? totalCount : mUnreadCount)
- + ")"); //$NON-NLS-1$
- } else {
- mTabItem.setText(mName); //$NON-NLS-1$
- }
- }
-
- mNewMessages.clear();
- }
-
- void setColors(LogColors colors) {
- mColors = colors;
- }
-
- int getUnreadCount() {
- return mUnreadCount;
- }
-
- void setUnreadCount(int unreadCount) {
- mUnreadCount = unreadCount;
- }
-
- void setSupportsDelete(boolean support) {
- mSupportsDelete = support;
- }
-
- void setSupportsEdit(boolean support) {
- mSupportsEdit = support;
- }
-
- void setTempKeywordFiltering(String[] segments) {
- mTempKeywordFilters = segments;
- mTempFilteringStatus = true;
- }
-
- void setTempPidFiltering(int pid) {
- mTempPid = pid;
- mTempFilteringStatus = true;
- }
-
- void setTempTagFiltering(String tag) {
- mTempTag = tag;
- mTempFilteringStatus = true;
- }
-
- void resetTempFiltering() {
- if (mTempPid != -1 || mTempTag != null || mTempKeywordFilters != null) {
- mTempFilteringStatus = true;
- }
-
- mTempPid = -1;
- mTempTag = null;
- mTempKeywordFilters = null;
- }
-
- void resetTempFilteringStatus() {
- mTempFilteringStatus = false;
- }
-
- boolean getTempFilterStatus() {
- return mTempFilteringStatus;
- }
-
-
- /**
- * Add a TableItem for the index-th item of the buffer
- * @param filter The index of the table in which to insert the item.
- */
- private void addTableItem(LogMessage msg) {
- TableItem item = new TableItem(mTable, SWT.NONE);
- item.setText(0, msg.data.time);
- item.setText(1, new String(new char[] { msg.data.logLevel.getPriorityLetter() }));
- item.setText(2, msg.data.pidString);
- item.setText(3, msg.data.tag);
- item.setText(4, msg.msg);
-
- // add the buffer index as data
- item.setData(msg);
-
- if (msg.data.logLevel == LogLevel.INFO) {
- item.setForeground(mColors.infoColor);
- } else if (msg.data.logLevel == LogLevel.DEBUG) {
- item.setForeground(mColors.debugColor);
- } else if (msg.data.logLevel == LogLevel.ERROR) {
- item.setForeground(mColors.errorColor);
- } else if (msg.data.logLevel == LogLevel.WARN) {
- item.setForeground(mColors.warningColor);
- } else {
- item.setForeground(mColors.verboseColor);
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogPanel.java
deleted file mode 100644
index a347155..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/logcat/LogPanel.java
+++ /dev/null
@@ -1,1626 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmlib.AdbCommandRejectedException;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.ShellCommandUnresponsiveException;
-import com.android.ddmlib.TimeoutException;
-import com.android.ddmuilib.DdmUiPreferences;
-import com.android.ddmuilib.ITableFocusListener;
-import com.android.ddmuilib.ITableFocusListener.IFocusedTableActivator;
-import com.android.ddmuilib.SelectionDependentPanel;
-import com.android.ddmuilib.TableHelper;
-import com.android.ddmuilib.actions.ICommonAction;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class LogPanel extends SelectionDependentPanel {
-
- private static final int STRING_BUFFER_LENGTH = 10000;
-
- /** no filtering. Only one tab with everything. */
- public static final int FILTER_NONE = 0;
- /** manual mode for filter. all filters are manually created. */
- public static final int FILTER_MANUAL = 1;
- /** automatic mode for filter (pid mode).
- * All filters are automatically created. */
- public static final int FILTER_AUTO_PID = 2;
- /** automatic mode for filter (tag mode).
- * All filters are automatically created. */
- public static final int FILTER_AUTO_TAG = 3;
- /** Manual filtering mode + new filter for debug app, if needed */
- public static final int FILTER_DEBUG = 4;
-
- public static final int COLUMN_MODE_MANUAL = 0;
- public static final int COLUMN_MODE_AUTO = 1;
-
- public static String PREFS_TIME;
- public static String PREFS_LEVEL;
- public static String PREFS_PID;
- public static String PREFS_TAG;
- public static String PREFS_MESSAGE;
-
- /**
- * This pattern is meant to parse the first line of a log message with the option
- * 'logcat -v long'. The first line represents the date, tag, severity, etc.. while the
- * following lines are the message (can be several line).<br>
- * This first line looks something like<br>
- * <code>"[ 00-00 00:00:00.000 &lt;pid&gt;:0x&lt;???&gt; &lt;severity&gt;/&lt;tag&gt;]"</code>
- * <br>
- * Note: severity is one of V, D, I, W, or EM<br>
- * Note: the fraction of second value can have any number of digit.
- * Note the tag should be trim as it may have spaces at the end.
- */
- private static Pattern sLogPattern = Pattern.compile(
- "^\\[\\s(\\d\\d-\\d\\d\\s\\d\\d:\\d\\d:\\d\\d\\.\\d+)" + //$NON-NLS-1$
- "\\s+(\\d*):(0x[0-9a-fA-F]+)\\s([VDIWE])/(.*)\\]$"); //$NON-NLS-1$
-
- /**
- * Interface for Storage Filter manager. Implementation of this interface
- * provide a custom way to archive an reload filters.
- */
- public interface ILogFilterStorageManager {
-
- public LogFilter[] getFilterFromStore();
-
- public void saveFilters(LogFilter[] filters);
-
- public boolean requiresDefaultFilter();
- }
-
- private Composite mParent;
- private IPreferenceStore mStore;
-
- /** top object in the view */
- private TabFolder mFolders;
-
- private LogColors mColors;
-
- private ILogFilterStorageManager mFilterStorage;
-
- private LogCatOuputReceiver mCurrentLogCat;
-
- /**
- * Circular buffer containing the logcat output. This is unfiltered.
- * The valid content goes from <code>mBufferStart</code> to
- * <code>mBufferEnd - 1</code>. Therefore its number of item is
- * <code>mBufferEnd - mBufferStart</code>.
- */
- private LogMessage[] mBuffer = new LogMessage[STRING_BUFFER_LENGTH];
-
- /** Represents the oldest message in the buffer */
- private int mBufferStart = -1;
-
- /**
- * Represents the next usable item in the buffer to receive new message.
- * This can be equal to mBufferStart, but when used mBufferStart will be
- * incremented as well.
- */
- private int mBufferEnd = -1;
-
- /** Filter list */
- private LogFilter[] mFilters;
-
- /** Default filter */
- private LogFilter mDefaultFilter;
-
- /** Current filter being displayed */
- private LogFilter mCurrentFilter;
-
- /** Filtering mode */
- private int mFilterMode = FILTER_NONE;
-
- /** Device currently running logcat */
- private IDevice mCurrentLoggedDevice = null;
-
- private ICommonAction mDeleteFilterAction;
- private ICommonAction mEditFilterAction;
-
- private ICommonAction[] mLogLevelActions;
-
- /** message data, separated from content for multi line messages */
- protected static class LogMessageInfo {
- public LogLevel logLevel;
- public int pid;
- public String pidString;
- public String tag;
- public String time;
- }
-
- /** pointer to the latest LogMessageInfo. this is used for multi line
- * log message, to reuse the info regarding level, pid, etc...
- */
- private LogMessageInfo mLastMessageInfo = null;
-
- private boolean mPendingAsyncRefresh = false;
-
- private String mDefaultLogSave;
-
- private int mColumnMode = COLUMN_MODE_MANUAL;
- private Font mDisplayFont;
-
- private ITableFocusListener mGlobalListener;
-
- private LogCatViewInterface mLogCatViewInterface = null;
-
- /** message data, separated from content for multi line messages */
- protected static class LogMessage {
- public LogMessageInfo data;
- public String msg;
-
- @Override
- public String toString() {
- return data.time + ": " //$NON-NLS-1$
- + data.logLevel + "/" //$NON-NLS-1$
- + data.tag + "(" //$NON-NLS-1$
- + data.pidString + "): " //$NON-NLS-1$
- + msg;
- }
- }
-
- /**
- * objects able to receive the output of a remote shell command,
- * specifically a logcat command in this case
- */
- private final class LogCatOuputReceiver extends MultiLineReceiver {
-
- public boolean isCancelled = false;
-
- public LogCatOuputReceiver() {
- super();
-
- setTrimLine(false);
- }
-
- @Override
- public void processNewLines(String[] lines) {
- if (isCancelled == false) {
- processLogLines(lines);
- }
- }
-
- @Override
- public boolean isCancelled() {
- return isCancelled;
- }
- }
-
- /**
- * Parser class for the output of a "ps" shell command executed on a device.
- * This class looks for a specific pid to find the process name from it.
- * Once found, the name is used to update a filter and a tab object
- *
- */
- private class PsOutputReceiver extends MultiLineReceiver {
-
- private LogFilter mFilter;
-
- private TabItem mTabItem;
-
- private int mPid;
-
- /** set to true when we've found the pid we're looking for */
- private boolean mDone = false;
-
- PsOutputReceiver(int pid, LogFilter filter, TabItem tabItem) {
- mPid = pid;
- mFilter = filter;
- mTabItem = tabItem;
- }
-
- @Override
- public boolean isCancelled() {
- return mDone;
- }
-
- @Override
- public void processNewLines(String[] lines) {
- for (String line : lines) {
- if (line.startsWith("USER")) { //$NON-NLS-1$
- continue;
- }
- // get the pid.
- int index = line.indexOf(' ');
- if (index == -1) {
- continue;
- }
- // look for the next non blank char
- index++;
- while (line.charAt(index) == ' ') {
- index++;
- }
-
- // this is the start of the pid.
- // look for the end.
- int index2 = line.indexOf(' ', index);
-
- // get the line
- String pidStr = line.substring(index, index2);
- int pid = Integer.parseInt(pidStr);
- if (pid != mPid) {
- continue;
- } else {
- // get the process name
- index = line.lastIndexOf(' ');
- final String name = line.substring(index + 1);
-
- mFilter.setName(name);
-
- // update the tab
- Display d = mFolders.getDisplay();
- d.asyncExec(new Runnable() {
- @Override
- public void run() {
- mTabItem.setText(name);
- }
- });
-
- // we're done with this ps.
- mDone = true;
- return;
- }
- }
- }
-
- }
-
- /**
- * Interface implemented by the LogCatView in Eclipse for particular action on double-click.
- */
- public interface LogCatViewInterface {
- public void onDoubleClick();
- }
-
- /**
- * Create the log view with some default parameters
- * @param colors The display color object
- * @param filterStorage the storage for user defined filters.
- * @param mode The filtering mode
- */
- public LogPanel(LogColors colors,
- ILogFilterStorageManager filterStorage, int mode) {
- mColors = colors;
- mFilterMode = mode;
- mFilterStorage = filterStorage;
- mStore = DdmUiPreferences.getStore();
- }
-
- public void setActions(ICommonAction deleteAction, ICommonAction editAction,
- ICommonAction[] logLevelActions) {
- mDeleteFilterAction = deleteAction;
- mEditFilterAction = editAction;
- mLogLevelActions = logLevelActions;
- }
-
- /**
- * Sets the column mode. Must be called before creatUI
- * @param mode the column mode. Valid values are COLUMN_MOD_MANUAL and
- * COLUMN_MODE_AUTO
- */
- public void setColumnMode(int mode) {
- mColumnMode = mode;
- }
-
- /**
- * Sets the display font.
- * @param font The display font.
- */
- public void setFont(Font font) {
- mDisplayFont = font;
-
- if (mFilters != null) {
- for (LogFilter f : mFilters) {
- Table table = f.getTable();
- if (table != null) {
- table.setFont(font);
- }
- }
- }
-
- if (mDefaultFilter != null) {
- Table table = mDefaultFilter.getTable();
- if (table != null) {
- table.setFont(font);
- }
- }
- }
-
- /**
- * Sent when a new device is selected. The new device can be accessed
- * with {@link #getCurrentDevice()}.
- */
- @Override
- public void deviceSelected() {
- startLogCat(getCurrentDevice());
- }
-
- /**
- * Sent when a new client is selected. The new client can be accessed
- * with {@link #getCurrentClient()}.
- */
- @Override
- public void clientSelected() {
- // pass
- }
-
-
- /**
- * Creates a control capable of displaying some information. This is
- * called once, when the application is initializing, from the UI thread.
- */
- @Override
- protected Control createControl(Composite parent) {
- mParent = parent;
-
- Composite top = new Composite(parent, SWT.NONE);
- top.setLayoutData(new GridData(GridData.FILL_BOTH));
- top.setLayout(new GridLayout(1, false));
-
- // create the tab folder
- mFolders = new TabFolder(top, SWT.NONE);
- mFolders.setLayoutData(new GridData(GridData.FILL_BOTH));
- mFolders.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mCurrentFilter != null) {
- mCurrentFilter.setSelectedState(false);
- }
- mCurrentFilter = getCurrentFilter();
- mCurrentFilter.setSelectedState(true);
- updateColumns(mCurrentFilter.getTable());
- if (mCurrentFilter.getTempFilterStatus()) {
- initFilter(mCurrentFilter);
- }
- selectionChanged(mCurrentFilter);
- }
- });
-
-
- Composite bottom = new Composite(top, SWT.NONE);
- bottom.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- bottom.setLayout(new GridLayout(3, false));
-
- Label label = new Label(bottom, SWT.NONE);
- label.setText("Filter:");
-
- final Text filterText = new Text(bottom, SWT.SINGLE | SWT.BORDER);
- filterText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- filterText.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- updateFilteringWith(filterText.getText());
- }
- });
-
- /*
- Button addFilterBtn = new Button(bottom, SWT.NONE);
- addFilterBtn.setImage(mImageLoader.loadImage("add.png", //$NON-NLS-1$
- addFilterBtn.getDisplay()));
- */
-
- // get the filters
- createFilters();
-
- // for each filter, create a tab.
- int index = 0;
-
- if (mDefaultFilter != null) {
- createTab(mDefaultFilter, index++, false);
- }
-
- if (mFilters != null) {
- for (LogFilter f : mFilters) {
- createTab(f, index++, false);
- }
- }
-
- return top;
- }
-
- @Override
- protected void postCreation() {
- // pass
- }
-
- /**
- * Sets the focus to the proper object.
- */
- @Override
- public void setFocus() {
- mFolders.setFocus();
- }
-
-
- /**
- * Starts a new logcat and set mCurrentLogCat as the current receiver.
- * @param device the device to connect logcat to.
- */
- public void startLogCat(final IDevice device) {
- if (device == mCurrentLoggedDevice) {
- return;
- }
-
- // if we have a logcat already running
- if (mCurrentLoggedDevice != null) {
- stopLogCat(false);
- mCurrentLoggedDevice = null;
- }
-
- resetUI(false);
-
- if (device != null) {
- // create a new output receiver
- mCurrentLogCat = new LogCatOuputReceiver();
-
- // start the logcat in a different thread
- new Thread("Logcat") { //$NON-NLS-1$
- @Override
- public void run() {
-
- while (device.isOnline() == false &&
- mCurrentLogCat != null &&
- mCurrentLogCat.isCancelled == false) {
- try {
- sleep(2000);
- } catch (InterruptedException e) {
- return;
- }
- }
-
- if (mCurrentLogCat == null || mCurrentLogCat.isCancelled) {
- // logcat was stopped/cancelled before the device became ready.
- return;
- }
-
- try {
- mCurrentLoggedDevice = device;
- device.executeShellCommand("logcat -v long", mCurrentLogCat, 0 /*timeout*/); //$NON-NLS-1$
- } catch (Exception e) {
- Log.e("Logcat", e);
- } finally {
- // at this point the command is terminated.
- mCurrentLogCat = null;
- mCurrentLoggedDevice = null;
- }
- }
- }.start();
- }
- }
-
- /** Stop the current logcat */
- public void stopLogCat(boolean inUiThread) {
- if (mCurrentLogCat != null) {
- mCurrentLogCat.isCancelled = true;
-
- // when the thread finishes, no one will reference that object
- // and it'll be destroyed
- mCurrentLogCat = null;
-
- // reset the content buffer
- for (int i = 0 ; i < STRING_BUFFER_LENGTH; i++) {
- mBuffer[i] = null;
- }
-
- // because it's a circular buffer, it's hard to know if
- // the array is empty with both start/end at 0 or if it's full
- // with both start/end at 0 as well. So to mean empty, we use -1
- mBufferStart = -1;
- mBufferEnd = -1;
-
- resetFilters();
- resetUI(inUiThread);
- }
- }
-
- /**
- * Adds a new Filter. This methods displays the UI to create the filter
- * and set up its parameters.<br>
- * <b>MUST</b> be called from the ui thread.
- *
- */
- public void addFilter() {
- EditFilterDialog dlg = new EditFilterDialog(mFolders.getShell());
- if (dlg.open()) {
- synchronized (mBuffer) {
- // get the new filter in the array
- LogFilter filter = dlg.getFilter();
- addFilterToArray(filter);
-
- int index = mFilters.length - 1;
- if (mDefaultFilter != null) {
- index++;
- }
-
- if (false) {
-
- for (LogFilter f : mFilters) {
- if (f.uiReady()) {
- f.dispose();
- }
- }
- if (mDefaultFilter != null && mDefaultFilter.uiReady()) {
- mDefaultFilter.dispose();
- }
-
- // for each filter, create a tab.
- int i = 0;
- if (mFilters != null) {
- for (LogFilter f : mFilters) {
- createTab(f, i++, true);
- }
- }
- if (mDefaultFilter != null) {
- createTab(mDefaultFilter, i++, true);
- }
- } else {
-
- // create ui for the filter.
- createTab(filter, index, true);
-
- // reset the default as it shouldn't contain the content of
- // this new filter.
- if (mDefaultFilter != null) {
- initDefaultFilter();
- }
- }
-
- // select the new filter
- if (mCurrentFilter != null) {
- mCurrentFilter.setSelectedState(false);
- }
- mFolders.setSelection(index);
- filter.setSelectedState(true);
- mCurrentFilter = filter;
-
- selectionChanged(filter);
-
- // finally we update the filtering mode if needed
- if (mFilterMode == FILTER_NONE) {
- mFilterMode = FILTER_MANUAL;
- }
-
- mFilterStorage.saveFilters(mFilters);
-
- }
- }
- }
-
- /**
- * Edits the current filter. The method displays the UI to edit the filter.
- */
- public void editFilter() {
- if (mCurrentFilter != null && mCurrentFilter != mDefaultFilter) {
- EditFilterDialog dlg = new EditFilterDialog(
- mFolders.getShell(), mCurrentFilter);
- if (dlg.open()) {
- synchronized (mBuffer) {
- // at this point the filter has been updated.
- // so we update its content
- initFilter(mCurrentFilter);
-
- // and the content of the "other" filter as well.
- if (mDefaultFilter != null) {
- initDefaultFilter();
- }
-
- mFilterStorage.saveFilters(mFilters);
- }
- }
- }
- }
-
- /**
- * Deletes the current filter.
- */
- public void deleteFilter() {
- synchronized (mBuffer) {
- if (mCurrentFilter != null && mCurrentFilter != mDefaultFilter) {
- // remove the filter from the list
- removeFilterFromArray(mCurrentFilter);
- mCurrentFilter.dispose();
-
- // select the new filter
- mFolders.setSelection(0);
- if (mFilters.length > 0) {
- mCurrentFilter = mFilters[0];
- } else {
- mCurrentFilter = mDefaultFilter;
- }
-
- selectionChanged(mCurrentFilter);
-
- // update the content of the "other" filter to include what was filtered out
- // by the deleted filter.
- if (mDefaultFilter != null) {
- initDefaultFilter();
- }
-
- mFilterStorage.saveFilters(mFilters);
- }
- }
- }
-
- /**
- * saves the current selection in a text file.
- * @return false if the saving failed.
- */
- public boolean save() {
- synchronized (mBuffer) {
- FileDialog dlg = new FileDialog(mParent.getShell(), SWT.SAVE);
- String fileName;
-
- dlg.setText("Save log...");
- dlg.setFileName("log.txt");
- String defaultPath = mDefaultLogSave;
- if (defaultPath == null) {
- defaultPath = System.getProperty("user.home"); //$NON-NLS-1$
- }
- dlg.setFilterPath(defaultPath);
- dlg.setFilterNames(new String[] {
- "Text Files (*.txt)"
- });
- dlg.setFilterExtensions(new String[] {
- "*.txt"
- });
-
- fileName = dlg.open();
- if (fileName != null) {
- mDefaultLogSave = dlg.getFilterPath();
-
- // get the current table and its selection
- Table currentTable = mCurrentFilter.getTable();
-
- int[] selection = currentTable.getSelectionIndices();
-
- // we need to sort the items to be sure.
- Arrays.sort(selection);
-
- // loop on the selection and output the file.
- FileWriter writer = null;
- try {
- writer = new FileWriter(fileName);
-
- for (int i : selection) {
- TableItem item = currentTable.getItem(i);
- LogMessage msg = (LogMessage)item.getData();
- String line = msg.toString();
- writer.write(line);
- writer.write('\n');
- }
- writer.flush();
-
- } catch (IOException e) {
- return false;
- } finally {
- if (writer != null) {
- try {
- writer.close();
- } catch (IOException e) {
- // ignore
- }
- }
- }
- }
- }
-
- return true;
- }
-
- /**
- * Empty the current circular buffer.
- */
- public void clear() {
- synchronized (mBuffer) {
- for (int i = 0 ; i < STRING_BUFFER_LENGTH; i++) {
- mBuffer[i] = null;
- }
-
- mBufferStart = -1;
- mBufferEnd = -1;
-
- // now we clear the existing filters
- for (LogFilter filter : mFilters) {
- filter.clear();
- }
-
- // and the default one
- if (mDefaultFilter != null) {
- mDefaultFilter.clear();
- }
- }
- }
-
- /**
- * Copies the current selection of the current filter as multiline text.
- *
- * @param clipboard The clipboard to place the copied content.
- */
- public void copy(Clipboard clipboard) {
- // get the current table and its selection
- Table currentTable = mCurrentFilter.getTable();
-
- copyTable(clipboard, currentTable);
- }
-
- /**
- * Selects all lines.
- */
- public void selectAll() {
- Table currentTable = mCurrentFilter.getTable();
- currentTable.selectAll();
- }
-
- /**
- * Sets a TableFocusListener which will be notified when one of the tables
- * gets or loses focus.
- *
- * @param listener
- */
- public void setTableFocusListener(ITableFocusListener listener) {
- // record the global listener, to make sure table created after
- // this call will still be setup.
- mGlobalListener = listener;
-
- // now we setup the existing filters
- for (LogFilter filter : mFilters) {
- Table table = filter.getTable();
-
- addTableToFocusListener(table);
- }
-
- // and the default one
- if (mDefaultFilter != null) {
- addTableToFocusListener(mDefaultFilter.getTable());
- }
- }
-
- /**
- * Sets up a Table object to notify the global Table Focus listener when it
- * gets or loses the focus.
- *
- * @param table the Table object.
- */
- private void addTableToFocusListener(final Table table) {
- // create the activator for this table
- final IFocusedTableActivator activator = new IFocusedTableActivator() {
- @Override
- public void copy(Clipboard clipboard) {
- copyTable(clipboard, table);
- }
-
- @Override
- public void selectAll() {
- table.selectAll();
- }
- };
-
- // add the focus listener on the table to notify the global listener
- table.addFocusListener(new FocusListener() {
- @Override
- public void focusGained(FocusEvent e) {
- mGlobalListener.focusGained(activator);
- }
-
- @Override
- public void focusLost(FocusEvent e) {
- mGlobalListener.focusLost(activator);
- }
- });
- }
-
- /**
- * Copies the current selection of a Table into the provided Clipboard, as
- * multi-line text.
- *
- * @param clipboard The clipboard to place the copied content.
- * @param table The table to copy from.
- */
- private static void copyTable(Clipboard clipboard, Table table) {
- int[] selection = table.getSelectionIndices();
-
- // we need to sort the items to be sure.
- Arrays.sort(selection);
-
- // all lines must be concatenated.
- StringBuilder sb = new StringBuilder();
-
- // loop on the selection and output the file.
- for (int i : selection) {
- TableItem item = table.getItem(i);
- LogMessage msg = (LogMessage)item.getData();
- String line = msg.toString();
- sb.append(line);
- sb.append('\n');
- }
-
- // now add that to the clipboard
- clipboard.setContents(new Object[] {
- sb.toString()
- }, new Transfer[] {
- TextTransfer.getInstance()
- });
- }
-
- /**
- * Sets the log level for the current filter, but does not save it.
- * @param i
- */
- public void setCurrentFilterLogLevel(int i) {
- LogFilter filter = getCurrentFilter();
-
- filter.setLogLevel(i);
-
- initFilter(filter);
- }
-
- /**
- * Creates a new tab in the folderTab item. Must be called from the ui
- * thread.
- * @param filter The filter associated with the tab.
- * @param index the index of the tab. if -1, the tab will be added at the
- * end.
- * @param fillTable If true the table is filled with the current content of
- * the buffer.
- * @return The TabItem object that was created.
- */
- private TabItem createTab(LogFilter filter, int index, boolean fillTable) {
- synchronized (mBuffer) {
- TabItem item = null;
- if (index != -1) {
- item = new TabItem(mFolders, SWT.NONE, index);
- } else {
- item = new TabItem(mFolders, SWT.NONE);
- }
- item.setText(filter.getName());
-
- // set the control (the parent is the TabFolder item, always)
- Composite top = new Composite(mFolders, SWT.NONE);
- item.setControl(top);
-
- top.setLayout(new FillLayout());
-
- // create the ui, first the table
- final Table t = new Table(top, SWT.MULTI | SWT.FULL_SELECTION);
- t.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- if (mLogCatViewInterface != null) {
- mLogCatViewInterface.onDoubleClick();
- }
- }
- });
-
- if (mDisplayFont != null) {
- t.setFont(mDisplayFont);
- }
-
- // give the ui objects to the filters.
- filter.setWidgets(item, t);
-
- t.setHeaderVisible(true);
- t.setLinesVisible(false);
-
- if (mGlobalListener != null) {
- addTableToFocusListener(t);
- }
-
- // create a controllistener that will handle the resizing of all the
- // columns (except the last) and of the table itself.
- ControlListener listener = null;
- if (mColumnMode == COLUMN_MODE_AUTO) {
- listener = new ControlListener() {
- @Override
- public void controlMoved(ControlEvent e) {
- }
-
- @Override
- public void controlResized(ControlEvent e) {
- Rectangle r = t.getClientArea();
-
- // get the size of all but the last column
- int total = t.getColumn(0).getWidth();
- total += t.getColumn(1).getWidth();
- total += t.getColumn(2).getWidth();
- total += t.getColumn(3).getWidth();
-
- if (r.width > total) {
- t.getColumn(4).setWidth(r.width-total);
- }
- }
- };
-
- t.addControlListener(listener);
- }
-
- // then its column
- TableColumn col = TableHelper.createTableColumn(t, "Time", SWT.LEFT,
- "00-00 00:00:00", //$NON-NLS-1$
- PREFS_TIME, mStore);
- if (mColumnMode == COLUMN_MODE_AUTO) {
- col.addControlListener(listener);
- }
-
- col = TableHelper.createTableColumn(t, "", SWT.CENTER,
- "D", //$NON-NLS-1$
- PREFS_LEVEL, mStore);
- if (mColumnMode == COLUMN_MODE_AUTO) {
- col.addControlListener(listener);
- }
-
- col = TableHelper.createTableColumn(t, "pid", SWT.LEFT,
- "9999", //$NON-NLS-1$
- PREFS_PID, mStore);
- if (mColumnMode == COLUMN_MODE_AUTO) {
- col.addControlListener(listener);
- }
-
- col = TableHelper.createTableColumn(t, "tag", SWT.LEFT,
- "abcdefgh", //$NON-NLS-1$
- PREFS_TAG, mStore);
- if (mColumnMode == COLUMN_MODE_AUTO) {
- col.addControlListener(listener);
- }
-
- col = TableHelper.createTableColumn(t, "Message", SWT.LEFT,
- "abcdefghijklmnopqrstuvwxyz0123456789", //$NON-NLS-1$
- PREFS_MESSAGE, mStore);
- if (mColumnMode == COLUMN_MODE_AUTO) {
- // instead of listening on resize for the last column, we make
- // it non resizable.
- col.setResizable(false);
- }
-
- if (fillTable) {
- initFilter(filter);
- }
- return item;
- }
- }
-
- protected void updateColumns(Table table) {
- if (table != null) {
- int index = 0;
- TableColumn col;
-
- col = table.getColumn(index++);
- col.setWidth(mStore.getInt(PREFS_TIME));
-
- col = table.getColumn(index++);
- col.setWidth(mStore.getInt(PREFS_LEVEL));
-
- col = table.getColumn(index++);
- col.setWidth(mStore.getInt(PREFS_PID));
-
- col = table.getColumn(index++);
- col.setWidth(mStore.getInt(PREFS_TAG));
-
- col = table.getColumn(index++);
- col.setWidth(mStore.getInt(PREFS_MESSAGE));
- }
- }
-
- public void resetUI(boolean inUiThread) {
- if (mFilterMode == FILTER_AUTO_PID || mFilterMode == FILTER_AUTO_TAG) {
- if (inUiThread) {
- mFolders.dispose();
- mParent.pack(true);
- createControl(mParent);
- } else {
- Display d = mFolders.getDisplay();
-
- // run sync as we need to update right now.
- d.syncExec(new Runnable() {
- @Override
- public void run() {
- mFolders.dispose();
- mParent.pack(true);
- createControl(mParent);
- }
- });
- }
- } else {
- // the ui is static we just empty it.
- if (mFolders.isDisposed() == false) {
- if (inUiThread) {
- emptyTables();
- } else {
- Display d = mFolders.getDisplay();
-
- // run sync as we need to update right now.
- d.syncExec(new Runnable() {
- @Override
- public void run() {
- if (mFolders.isDisposed() == false) {
- emptyTables();
- }
- }
- });
- }
- }
- }
- }
-
- /**
- * Process new Log lines coming from {@link LogCatOuputReceiver}.
- * @param lines the new lines
- */
- protected void processLogLines(String[] lines) {
- // WARNING: this will not work if the string contains more line than
- // the buffer holds.
-
- if (lines.length > STRING_BUFFER_LENGTH) {
- Log.e("LogCat", "Receiving more lines than STRING_BUFFER_LENGTH");
- }
-
- // parse the lines and create LogMessage that are stored in a temporary list
- final ArrayList<LogMessage> newMessages = new ArrayList<LogMessage>();
-
- synchronized (mBuffer) {
- for (String line : lines) {
- // ignore empty lines.
- if (line.length() > 0) {
- // check for header lines.
- Matcher matcher = sLogPattern.matcher(line);
- if (matcher.matches()) {
- // this is a header line, parse the header and keep it around.
- mLastMessageInfo = new LogMessageInfo();
-
- mLastMessageInfo.time = matcher.group(1);
- mLastMessageInfo.pidString = matcher.group(2);
- mLastMessageInfo.pid = Integer.valueOf(mLastMessageInfo.pidString);
- mLastMessageInfo.logLevel = LogLevel.getByLetterString(matcher.group(4));
- mLastMessageInfo.tag = matcher.group(5).trim();
- } else {
- // This is not a header line.
- // Create a new LogMessage and process it.
- LogMessage mc = new LogMessage();
-
- if (mLastMessageInfo == null) {
- // The first line of output wasn't preceded
- // by a header line; make something up so
- // that users of mc.data don't NPE.
- mLastMessageInfo = new LogMessageInfo();
- mLastMessageInfo.time = "??-?? ??:??:??.???"; //$NON-NLS1$
- mLastMessageInfo.pidString = "<unknown>"; //$NON-NLS1$
- mLastMessageInfo.pid = 0;
- mLastMessageInfo.logLevel = LogLevel.INFO;
- mLastMessageInfo.tag = "<unknown>"; //$NON-NLS1$
- }
-
- // If someone printed a log message with
- // embedded '\n' characters, there will
- // one header line followed by multiple text lines.
- // Use the last header that we saw.
- mc.data = mLastMessageInfo;
-
- // tabs seem to display as only 1 tab so we replace the leading tabs
- // by 4 spaces.
- mc.msg = line.replaceAll("\t", " "); //$NON-NLS-1$ //$NON-NLS-2$
-
- // process the new LogMessage.
- processNewMessage(mc);
-
- // store the new LogMessage
- newMessages.add(mc);
- }
- }
- }
-
- // if we don't have a pending Runnable that will do the refresh, we ask the Display
- // to run one in the UI thread.
- if (mPendingAsyncRefresh == false) {
- mPendingAsyncRefresh = true;
-
- try {
- Display display = mFolders.getDisplay();
-
- // run in sync because this will update the buffer start/end indices
- display.asyncExec(new Runnable() {
- @Override
- public void run() {
- asyncRefresh();
- }
- });
- } catch (SWTException e) {
- // display is disposed, we're probably quitting. Let's stop.
- stopLogCat(false);
- }
- }
- }
- }
-
- /**
- * Refreshes the UI with new messages.
- */
- private void asyncRefresh() {
- if (mFolders.isDisposed() == false) {
- synchronized (mBuffer) {
- try {
- // the circular buffer has been updated, let have the filter flush their
- // display with the new messages.
- if (mFilters != null) {
- for (LogFilter f : mFilters) {
- f.flush();
- }
- }
-
- if (mDefaultFilter != null) {
- mDefaultFilter.flush();
- }
- } finally {
- // the pending refresh is done.
- mPendingAsyncRefresh = false;
- }
- }
- } else {
- stopLogCat(true);
- }
- }
-
- /**
- * Processes a new Message.
- * <p/>This adds the new message to the buffer, and gives it to the existing filters.
- * @param newMessage
- */
- private void processNewMessage(LogMessage newMessage) {
- // if we are in auto filtering mode, make sure we have
- // a filter for this
- if (mFilterMode == FILTER_AUTO_PID ||
- mFilterMode == FILTER_AUTO_TAG) {
- checkFilter(newMessage.data);
- }
-
- // compute the index where the message goes.
- // was the buffer empty?
- int messageIndex = -1;
- if (mBufferStart == -1) {
- messageIndex = mBufferStart = 0;
- mBufferEnd = 1;
- } else {
- messageIndex = mBufferEnd;
-
- // increment the next usable slot index
- mBufferEnd = (mBufferEnd + 1) % STRING_BUFFER_LENGTH;
-
- // check we aren't overwriting start
- if (mBufferEnd == mBufferStart) {
- mBufferStart = (mBufferStart + 1) % STRING_BUFFER_LENGTH;
- }
- }
-
- LogMessage oldMessage = null;
-
- // record the message that was there before
- if (mBuffer[messageIndex] != null) {
- oldMessage = mBuffer[messageIndex];
- }
-
- // then add the new one
- mBuffer[messageIndex] = newMessage;
-
- // give the new message to every filters.
- boolean filtered = false;
- if (mFilters != null) {
- for (LogFilter f : mFilters) {
- filtered |= f.addMessage(newMessage, oldMessage);
- }
- }
- if (filtered == false && mDefaultFilter != null) {
- mDefaultFilter.addMessage(newMessage, oldMessage);
- }
- }
-
- private void createFilters() {
- if (mFilterMode == FILTER_DEBUG || mFilterMode == FILTER_MANUAL) {
- // unarchive the filters.
- mFilters = mFilterStorage.getFilterFromStore();
-
- // set the colors
- if (mFilters != null) {
- for (LogFilter f : mFilters) {
- f.setColors(mColors);
- }
- }
-
- if (mFilterStorage.requiresDefaultFilter()) {
- mDefaultFilter = new LogFilter("Log");
- mDefaultFilter.setColors(mColors);
- mDefaultFilter.setSupportsDelete(false);
- mDefaultFilter.setSupportsEdit(false);
- }
- } else if (mFilterMode == FILTER_NONE) {
- // if the filtering mode is "none", we create a single filter that
- // will receive all
- mDefaultFilter = new LogFilter("Log");
- mDefaultFilter.setColors(mColors);
- mDefaultFilter.setSupportsDelete(false);
- mDefaultFilter.setSupportsEdit(false);
- }
- }
-
- /** Checks if there's an automatic filter for this md and if not
- * adds the filter and the ui.
- * This must be called from the UI!
- * @param md
- * @return true if the filter existed already
- */
- private boolean checkFilter(final LogMessageInfo md) {
- if (true)
- return true;
- // look for a filter that matches the pid
- if (mFilterMode == FILTER_AUTO_PID) {
- for (LogFilter f : mFilters) {
- if (f.getPidFilter() == md.pid) {
- return true;
- }
- }
- } else if (mFilterMode == FILTER_AUTO_TAG) {
- for (LogFilter f : mFilters) {
- if (f.getTagFilter().equals(md.tag)) {
- return true;
- }
- }
- }
-
- // if we reach this point, no filter was found.
- // create a filter with a temporary name of the pid
- final LogFilter newFilter = new LogFilter(md.pidString);
- String name = null;
- if (mFilterMode == FILTER_AUTO_PID) {
- newFilter.setPidMode(md.pid);
-
- // ask the monitor thread if it knows the pid.
- name = mCurrentLoggedDevice.getClientName(md.pid);
- } else {
- newFilter.setTagMode(md.tag);
- name = md.tag;
- }
- addFilterToArray(newFilter);
-
- final String fname = name;
-
- // create the tabitem
- final TabItem newTabItem = createTab(newFilter, -1, true);
-
- // if the name is unknown
- if (fname == null) {
- // we need to find the process running under that pid.
- // launch a thread do a ps on the device
- new Thread("remote PS") { //$NON-NLS-1$
- @Override
- public void run() {
- // create the receiver
- PsOutputReceiver psor = new PsOutputReceiver(md.pid,
- newFilter, newTabItem);
-
- // execute ps
- try {
- mCurrentLoggedDevice.executeShellCommand("ps", psor); //$NON-NLS-1$
- } catch (IOException e) {
- // Ignore
- } catch (TimeoutException e) {
- // Ignore
- } catch (AdbCommandRejectedException e) {
- // Ignore
- } catch (ShellCommandUnresponsiveException e) {
- // Ignore
- }
- }
- }.start();
- }
-
- return false;
- }
-
- /**
- * Adds a new filter to the current filter array, and set its colors
- * @param newFilter The filter to add
- */
- private void addFilterToArray(LogFilter newFilter) {
- // set the colors
- newFilter.setColors(mColors);
-
- // add it to the array.
- if (mFilters != null && mFilters.length > 0) {
- LogFilter[] newFilters = new LogFilter[mFilters.length+1];
- System.arraycopy(mFilters, 0, newFilters, 0, mFilters.length);
- newFilters[mFilters.length] = newFilter;
- mFilters = newFilters;
- } else {
- mFilters = new LogFilter[1];
- mFilters[0] = newFilter;
- }
- }
-
- private void removeFilterFromArray(LogFilter oldFilter) {
- // look for the index
- int index = -1;
- for (int i = 0 ; i < mFilters.length ; i++) {
- if (mFilters[i] == oldFilter) {
- index = i;
- break;
- }
- }
-
- if (index != -1) {
- LogFilter[] newFilters = new LogFilter[mFilters.length-1];
- System.arraycopy(mFilters, 0, newFilters, 0, index);
- System.arraycopy(mFilters, index + 1, newFilters, index,
- newFilters.length-index);
- mFilters = newFilters;
- }
- }
-
- /**
- * Initialize the filter with already existing buffer.
- * @param filter
- */
- private void initFilter(LogFilter filter) {
- // is it empty
- if (filter.uiReady() == false) {
- return;
- }
-
- if (filter == mDefaultFilter) {
- initDefaultFilter();
- return;
- }
-
- filter.clear();
-
- if (mBufferStart != -1) {
- int max = mBufferEnd;
- if (mBufferEnd < mBufferStart) {
- max += STRING_BUFFER_LENGTH;
- }
-
- for (int i = mBufferStart; i < max; i++) {
- int realItemIndex = i % STRING_BUFFER_LENGTH;
-
- filter.addMessage(mBuffer[realItemIndex], null /* old message */);
- }
- }
-
- filter.flush();
- filter.resetTempFilteringStatus();
- }
-
- /**
- * Refill the default filter. Not to be called directly.
- * @see initFilter()
- */
- private void initDefaultFilter() {
- mDefaultFilter.clear();
-
- if (mBufferStart != -1) {
- int max = mBufferEnd;
- if (mBufferEnd < mBufferStart) {
- max += STRING_BUFFER_LENGTH;
- }
-
- for (int i = mBufferStart; i < max; i++) {
- int realItemIndex = i % STRING_BUFFER_LENGTH;
- LogMessage msg = mBuffer[realItemIndex];
-
- // first we check that the other filters don't take this message
- boolean filtered = false;
- for (LogFilter f : mFilters) {
- filtered |= f.accept(msg);
- }
-
- if (filtered == false) {
- mDefaultFilter.addMessage(msg, null /* old message */);
- }
- }
- }
-
- mDefaultFilter.flush();
- mDefaultFilter.resetTempFilteringStatus();
- }
-
- /**
- * Reset the filters, to handle change in device in automatic filter mode
- */
- private void resetFilters() {
- // if we are in automatic mode, then we need to rmove the current
- // filter.
- if (mFilterMode == FILTER_AUTO_PID || mFilterMode == FILTER_AUTO_TAG) {
- mFilters = null;
-
- // recreate the filters.
- createFilters();
- }
- }
-
-
- private LogFilter getCurrentFilter() {
- int index = mFolders.getSelectionIndex();
-
- // if mFilters is null or index is invalid, we return the default
- // filter. It doesn't matter if that one is null as well, since we
- // would return null anyway.
- if (index == 0 || mFilters == null) {
- return mDefaultFilter;
- }
-
- return mFilters[index-1];
- }
-
-
- private void emptyTables() {
- for (LogFilter f : mFilters) {
- f.getTable().removeAll();
- }
-
- if (mDefaultFilter != null) {
- mDefaultFilter.getTable().removeAll();
- }
- }
-
- protected void updateFilteringWith(String text) {
- synchronized (mBuffer) {
- // reset the temp filtering for all the filters
- for (LogFilter f : mFilters) {
- f.resetTempFiltering();
- }
- if (mDefaultFilter != null) {
- mDefaultFilter.resetTempFiltering();
- }
-
- // now we need to figure out the new temp filtering
- // split each word
- String[] segments = text.split(" "); //$NON-NLS-1$
-
- ArrayList<String> keywords = new ArrayList<String>(segments.length);
-
- // loop and look for temp id/tag
- int tempPid = -1;
- String tempTag = null;
- for (int i = 0 ; i < segments.length; i++) {
- String s = segments[i];
- if (tempPid == -1 && s.startsWith("pid:")) { //$NON-NLS-1$
- // get the pid
- String[] seg = s.split(":"); //$NON-NLS-1$
- if (seg.length == 2) {
- if (seg[1].matches("^[0-9]*$")) { //$NON-NLS-1$
- tempPid = Integer.valueOf(seg[1]);
- }
- }
- } else if (tempTag == null && s.startsWith("tag:")) { //$NON-NLS-1$
- String seg[] = segments[i].split(":"); //$NON-NLS-1$
- if (seg.length == 2) {
- tempTag = seg[1];
- }
- } else {
- keywords.add(s);
- }
- }
-
- // set the temp filtering in the filters
- if (tempPid != -1 || tempTag != null || keywords.size() > 0) {
- String[] keywordsArray = keywords.toArray(
- new String[keywords.size()]);
-
- for (LogFilter f : mFilters) {
- if (tempPid != -1) {
- f.setTempPidFiltering(tempPid);
- }
- if (tempTag != null) {
- f.setTempTagFiltering(tempTag);
- }
- f.setTempKeywordFiltering(keywordsArray);
- }
-
- if (mDefaultFilter != null) {
- if (tempPid != -1) {
- mDefaultFilter.setTempPidFiltering(tempPid);
- }
- if (tempTag != null) {
- mDefaultFilter.setTempTagFiltering(tempTag);
- }
- mDefaultFilter.setTempKeywordFiltering(keywordsArray);
-
- }
- }
-
- initFilter(mCurrentFilter);
- }
- }
-
- /**
- * Called when the current filter selection changes.
- * @param selectedFilter
- */
- private void selectionChanged(LogFilter selectedFilter) {
- if (mLogLevelActions != null) {
- // get the log level
- int level = selectedFilter.getLogLevel();
- for (int i = 0 ; i < mLogLevelActions.length; i++) {
- ICommonAction a = mLogLevelActions[i];
- if (i == level - 2) {
- a.setChecked(true);
- } else {
- a.setChecked(false);
- }
- }
- }
-
- if (mDeleteFilterAction != null) {
- mDeleteFilterAction.setEnabled(selectedFilter.supportsDelete());
- }
- if (mEditFilterAction != null) {
- mEditFilterAction.setEnabled(selectedFilter.supportsEdit());
- }
- }
-
- public String getSelectedErrorLineMessage() {
- Table table = mCurrentFilter.getTable();
- int[] selection = table.getSelectionIndices();
-
- if (selection.length == 1) {
- TableItem item = table.getItem(selection[0]);
- LogMessage msg = (LogMessage)item.getData();
- if (msg.data.logLevel == LogLevel.ERROR || msg.data.logLevel == LogLevel.WARN)
- return msg.msg;
- }
- return null;
- }
-
- public void setLogCatViewInterface(LogCatViewInterface i) {
- mLogCatViewInterface = i;
- }
-}
diff --git a/ddms/libs/ddmuilib/src/com/android/ddmuilib/net/NetworkPanel.java b/ddms/libs/ddmuilib/src/com/android/ddmuilib/net/NetworkPanel.java
deleted file mode 100644
index 15b8b56..0000000
--- a/ddms/libs/ddmuilib/src/com/android/ddmuilib/net/NetworkPanel.java
+++ /dev/null
@@ -1,1125 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.net;
-
-import com.android.ddmlib.AdbCommandRejectedException;
-import com.android.ddmlib.Client;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.ShellCommandUnresponsiveException;
-import com.android.ddmlib.TimeoutException;
-import com.android.ddmuilib.DdmUiPreferences;
-import com.android.ddmuilib.TableHelper;
-import com.android.ddmuilib.TablePanel;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.jfree.chart.ChartFactory;
-import org.jfree.chart.JFreeChart;
-import org.jfree.chart.axis.AxisLocation;
-import org.jfree.chart.axis.NumberAxis;
-import org.jfree.chart.axis.ValueAxis;
-import org.jfree.chart.plot.DatasetRenderingOrder;
-import org.jfree.chart.plot.ValueMarker;
-import org.jfree.chart.plot.XYPlot;
-import org.jfree.chart.renderer.xy.StackedXYAreaRenderer2;
-import org.jfree.chart.renderer.xy.XYAreaRenderer;
-import org.jfree.data.DefaultKeyedValues2D;
-import org.jfree.data.time.Millisecond;
-import org.jfree.data.time.TimePeriod;
-import org.jfree.data.time.TimeSeries;
-import org.jfree.data.time.TimeSeriesCollection;
-import org.jfree.data.xy.AbstractIntervalXYDataset;
-import org.jfree.data.xy.TableXYDataset;
-import org.jfree.experimental.chart.swt.ChartComposite;
-import org.jfree.ui.RectangleAnchor;
-import org.jfree.ui.TextAnchor;
-
-import java.io.IOException;
-import java.text.DecimalFormat;
-import java.text.FieldPosition;
-import java.text.NumberFormat;
-import java.text.ParsePosition;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Formatter;
-import java.util.Iterator;
-
-/**
- * Displays live network statistics for currently selected {@link Client}.
- */
-public class NetworkPanel extends TablePanel {
-
- // TODO: enable view of packets and bytes/packet
- // TODO: add sash to resize chart and table
- // TODO: let user edit tags to be meaningful
-
- /** Amount of historical data to display. */
- private static final long HISTORY_MILLIS = 30 * 1000;
-
- private final static String PREFS_NETWORK_COL_TITLE = "networkPanel.title";
- private final static String PREFS_NETWORK_COL_RX_BYTES = "networkPanel.rxBytes";
- private final static String PREFS_NETWORK_COL_RX_PACKETS = "networkPanel.rxPackets";
- private final static String PREFS_NETWORK_COL_TX_BYTES = "networkPanel.txBytes";
- private final static String PREFS_NETWORK_COL_TX_PACKETS = "networkPanel.txPackets";
-
- /** Path to network statistics on remote device. */
- private static final String PROC_XT_QTAGUID = "/proc/net/xt_qtaguid/stats";
-
- private static final java.awt.Color TOTAL_COLOR = java.awt.Color.GRAY;
-
- /** Colors used for tag series data. */
- private static final java.awt.Color[] SERIES_COLORS = new java.awt.Color[] {
- java.awt.Color.decode("0x2bc4c1"), // teal
- java.awt.Color.decode("0xD50F25"), // red
- java.awt.Color.decode("0x3369E8"), // blue
- java.awt.Color.decode("0xEEB211"), // orange
- java.awt.Color.decode("0x00bd2e"), // green
- java.awt.Color.decode("0xae26ae"), // purple
- };
-
- private Display mDisplay;
-
- private Composite mPanel;
-
- /** Header panel with configuration options. */
- private Composite mHeader;
-
- private Label mSpeedLabel;
- private Combo mSpeedCombo;
-
- /** Current sleep between each sample, from {@link #mSpeedCombo}. */
- private long mSpeedMillis;
-
- private Button mRunningButton;
- private Button mResetButton;
-
- /** Chart of recent network activity. */
- private JFreeChart mChart;
- private ChartComposite mChartComposite;
-
- private ValueAxis mDomainAxis;
-
- /** Data for total traffic (tag 0x0). */
- private TimeSeriesCollection mTotalCollection;
- private TimeSeries mRxTotalSeries;
- private TimeSeries mTxTotalSeries;
-
- /** Data for detailed tagged traffic. */
- private LiveTimeTableXYDataset mRxDetailDataset;
- private LiveTimeTableXYDataset mTxDetailDataset;
-
- private XYAreaRenderer mTotalRenderer;
- private StackedXYAreaRenderer2 mRenderer;
-
- /** Table showing summary of network activity. */
- private Table mTable;
- private TableViewer mTableViewer;
-
- /** UID of currently selected {@link Client}. */
- private int mActiveUid = -1;
-
- /** List of traffic flows being actively tracked. */
- private ArrayList<TrackedItem> mTrackedItems = new ArrayList<TrackedItem>();
-
- private SampleThread mSampleThread;
-
- private class SampleThread extends Thread {
- private volatile boolean mFinish;
-
- public void finish() {
- mFinish = true;
- interrupt();
- }
-
- @Override
- public void run() {
- while (!mFinish && !mDisplay.isDisposed()) {
- performSample();
-
- try {
- Thread.sleep(mSpeedMillis);
- } catch (InterruptedException e) {
- // ignored
- }
- }
- }
- }
-
- /** Last snapshot taken by {@link #performSample()}. */
- private NetworkSnapshot mLastSnapshot;
-
- @Override
- protected Control createControl(Composite parent) {
- mDisplay = parent.getDisplay();
-
- mPanel = new Composite(parent, SWT.NONE);
-
- final FormLayout formLayout = new FormLayout();
- mPanel.setLayout(formLayout);
-
- createHeader();
- createChart();
- createTable();
-
- return mPanel;
- }
-
- /**
- * Create header panel with configuration options.
- */
- private void createHeader() {
-
- mHeader = new Composite(mPanel, SWT.NONE);
- final RowLayout layout = new RowLayout();
- layout.center = true;
- mHeader.setLayout(layout);
-
- mSpeedLabel = new Label(mHeader, SWT.NONE);
- mSpeedLabel.setText("Speed:");
- mSpeedCombo = new Combo(mHeader, SWT.PUSH);
- mSpeedCombo.add("Fast (100ms)");
- mSpeedCombo.add("Medium (250ms)");
- mSpeedCombo.add("Slow (500ms)");
- mSpeedCombo.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- updateSpeed();
- }
- });
-
- mSpeedCombo.select(1);
- updateSpeed();
-
- mRunningButton = new Button(mHeader, SWT.PUSH);
- mRunningButton.setText("Start");
- mRunningButton.setEnabled(false);
- mRunningButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- final boolean alreadyRunning = mSampleThread != null;
- updateRunning(!alreadyRunning);
- }
- });
-
- mResetButton = new Button(mHeader, SWT.PUSH);
- mResetButton.setText("Reset");
- mResetButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- clearTrackedItems();
- }
- });
-
- final FormData data = new FormData();
- data.top = new FormAttachment(0);
- data.left = new FormAttachment(0);
- data.right = new FormAttachment(100);
- mHeader.setLayoutData(data);
- }
-
- /**
- * Create chart of recent network activity.
- */
- private void createChart() {
-
- mChart = ChartFactory.createTimeSeriesChart(null, null, null, null, false, false, false);
-
- // create backing datasets and series
- mRxTotalSeries = new TimeSeries("RX total");
- mTxTotalSeries = new TimeSeries("TX total");
-
- mRxTotalSeries.setMaximumItemAge(HISTORY_MILLIS);
- mTxTotalSeries.setMaximumItemAge(HISTORY_MILLIS);
-
- mTotalCollection = new TimeSeriesCollection();
- mTotalCollection.addSeries(mRxTotalSeries);
- mTotalCollection.addSeries(mTxTotalSeries);
-
- mRxDetailDataset = new LiveTimeTableXYDataset();
- mTxDetailDataset = new LiveTimeTableXYDataset();
-
- mTotalRenderer = new XYAreaRenderer(XYAreaRenderer.AREA);
- mRenderer = new StackedXYAreaRenderer2();
-
- final XYPlot xyPlot = mChart.getXYPlot();
-
- xyPlot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD);
-
- xyPlot.setDataset(0, mTotalCollection);
- xyPlot.setDataset(1, mRxDetailDataset);
- xyPlot.setDataset(2, mTxDetailDataset);
- xyPlot.setRenderer(0, mTotalRenderer);
- xyPlot.setRenderer(1, mRenderer);
- xyPlot.setRenderer(2, mRenderer);
-
- // we control domain axis manually when taking samples
- mDomainAxis = xyPlot.getDomainAxis();
- mDomainAxis.setAutoRange(false);
-
- final NumberAxis axis = new NumberAxis();
- axis.setNumberFormatOverride(new BytesFormat(true));
- axis.setAutoRangeMinimumSize(50);
- xyPlot.setRangeAxis(axis);
- xyPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
-
- // draw thick line to separate RX versus TX traffic
- xyPlot.addRangeMarker(
- new ValueMarker(0, java.awt.Color.BLACK, new java.awt.BasicStroke(2)));
-
- // label to indicate that positive axis is RX traffic
- final ValueMarker rxMarker = new ValueMarker(0);
- rxMarker.setStroke(new java.awt.BasicStroke(0));
- rxMarker.setLabel("RX");
- rxMarker.setLabelFont(rxMarker.getLabelFont().deriveFont(30f));
- rxMarker.setLabelPaint(java.awt.Color.LIGHT_GRAY);
- rxMarker.setLabelAnchor(RectangleAnchor.TOP_RIGHT);
- rxMarker.setLabelTextAnchor(TextAnchor.BOTTOM_RIGHT);
- xyPlot.addRangeMarker(rxMarker);
-
- // label to indicate that negative axis is TX traffic
- final ValueMarker txMarker = new ValueMarker(0);
- txMarker.setStroke(new java.awt.BasicStroke(0));
- txMarker.setLabel("TX");
- txMarker.setLabelFont(txMarker.getLabelFont().deriveFont(30f));
- txMarker.setLabelPaint(java.awt.Color.LIGHT_GRAY);
- txMarker.setLabelAnchor(RectangleAnchor.BOTTOM_RIGHT);
- txMarker.setLabelTextAnchor(TextAnchor.TOP_RIGHT);
- xyPlot.addRangeMarker(txMarker);
-
- mChartComposite = new ChartComposite(mPanel, SWT.BORDER, mChart,
- ChartComposite.DEFAULT_WIDTH, ChartComposite.DEFAULT_HEIGHT,
- ChartComposite.DEFAULT_MINIMUM_DRAW_WIDTH,
- ChartComposite.DEFAULT_MINIMUM_DRAW_HEIGHT, 4096, 4096, true, true, true, true,
- false, true);
-
- final FormData data = new FormData();
- data.top = new FormAttachment(mHeader);
- data.left = new FormAttachment(0);
- data.bottom = new FormAttachment(70);
- data.right = new FormAttachment(100);
- mChartComposite.setLayoutData(data);
- }
-
- /**
- * Create table showing summary of network activity.
- */
- private void createTable() {
- mTable = new Table(mPanel, SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION);
-
- final FormData data = new FormData();
- data.top = new FormAttachment(mChartComposite);
- data.left = new FormAttachment(mChartComposite, 0, SWT.CENTER);
- data.bottom = new FormAttachment(100);
- mTable.setLayoutData(data);
-
- mTable.setHeaderVisible(true);
- mTable.setLinesVisible(true);
-
- final IPreferenceStore store = DdmUiPreferences.getStore();
-
- TableHelper.createTableColumn(mTable, "", SWT.CENTER, buildSampleText(2), null, null);
- TableHelper.createTableColumn(
- mTable, "Tag", SWT.LEFT, buildSampleText(32), PREFS_NETWORK_COL_TITLE, store);
- TableHelper.createTableColumn(mTable, "RX bytes", SWT.RIGHT, buildSampleText(12),
- PREFS_NETWORK_COL_RX_BYTES, store);
- TableHelper.createTableColumn(mTable, "RX packets", SWT.RIGHT, buildSampleText(12),
- PREFS_NETWORK_COL_RX_PACKETS, store);
- TableHelper.createTableColumn(mTable, "TX bytes", SWT.RIGHT, buildSampleText(12),
- PREFS_NETWORK_COL_TX_BYTES, store);
- TableHelper.createTableColumn(mTable, "TX packets", SWT.RIGHT, buildSampleText(12),
- PREFS_NETWORK_COL_TX_PACKETS, store);
-
- mTableViewer = new TableViewer(mTable);
- mTableViewer.setContentProvider(new ContentProvider());
- mTableViewer.setLabelProvider(new LabelProvider());
- }
-
- /**
- * Update {@link #mSpeedMillis} to match {@link #mSpeedCombo} selection.
- */
- private void updateSpeed() {
- switch (mSpeedCombo.getSelectionIndex()) {
- case 0:
- mSpeedMillis = 100;
- break;
- case 1:
- mSpeedMillis = 250;
- break;
- case 2:
- mSpeedMillis = 500;
- break;
- }
- }
-
- /**
- * Update if {@link SampleThread} should be actively running. Will create
- * new thread or finish existing thread to match requested state.
- */
- private void updateRunning(boolean shouldRun) {
- final boolean alreadyRunning = mSampleThread != null;
- if (alreadyRunning && !shouldRun) {
- mSampleThread.finish();
- mSampleThread = null;
-
- mRunningButton.setText("Start");
- mHeader.pack();
- } else if (!alreadyRunning && shouldRun) {
- mSampleThread = new SampleThread();
- mSampleThread.start();
-
- mRunningButton.setText("Stop");
- mHeader.pack();
- }
- }
-
- @Override
- public void setFocus() {
- mPanel.setFocus();
- }
-
- private static java.awt.Color nextSeriesColor(int index) {
- return SERIES_COLORS[index % SERIES_COLORS.length];
- }
-
- /**
- * Find a {@link TrackedItem} that matches the requested UID and tag, or
- * create one if none exists.
- */
- public TrackedItem findOrCreateTrackedItem(int uid, int tag) {
- // try searching for existing item
- for (TrackedItem item : mTrackedItems) {
- if (item.uid == uid && item.tag == tag) {
- return item;
- }
- }
-
- // nothing found; create new item
- final TrackedItem item = new TrackedItem(uid, tag);
- if (item.isTotal()) {
- item.color = TOTAL_COLOR;
- item.label = "Total";
- } else {
- final int size = mTrackedItems.size();
- item.color = nextSeriesColor(size);
- Formatter formatter = new Formatter();
- item.label = "0x" + formatter.format("%08x", tag);
- formatter.close();
- }
-
- // create color chip to display as legend in table
- item.colorImage = new Image(mDisplay, 20, 20);
- final GC gc = new GC(item.colorImage);
- gc.setBackground(new org.eclipse.swt.graphics.Color(mDisplay, item.color
- .getRed(), item.color.getGreen(), item.color.getBlue()));
- gc.fillRectangle(item.colorImage.getBounds());
- gc.dispose();
-
- mTrackedItems.add(item);
- return item;
- }
-
- /**
- * Clear all {@link TrackedItem} and chart history.
- */
- public void clearTrackedItems() {
- mRxTotalSeries.clear();
- mTxTotalSeries.clear();
-
- mRxDetailDataset.clear();
- mTxDetailDataset.clear();
-
- mTrackedItems.clear();
- mTableViewer.setInput(mTrackedItems);
- }
-
- /**
- * Update the {@link #mRenderer} colors to match {@link TrackedItem#color}.
- */
- private void updateSeriesPaint() {
- for (TrackedItem item : mTrackedItems) {
- final int seriesIndex = mRxDetailDataset.getColumnIndex(item.label);
- if (seriesIndex >= 0) {
- mRenderer.setSeriesPaint(seriesIndex, item.color);
- mRenderer.setSeriesFillPaint(seriesIndex, item.color);
- }
- }
-
- // series data is always the same color
- final int count = mTotalCollection.getSeriesCount();
- for (int i = 0; i < count; i++) {
- mTotalRenderer.setSeriesPaint(i, TOTAL_COLOR);
- mTotalRenderer.setSeriesFillPaint(i, TOTAL_COLOR);
- }
- }
-
- /**
- * Traffic flow being actively tracked, uniquely defined by UID and tag. Can
- * record {@link NetworkSnapshot} deltas into {@link TimeSeries} for
- * charting, and into summary statistics for {@link Table} display.
- */
- private class TrackedItem {
- public final int uid;
- public final int tag;
-
- public java.awt.Color color;
- public Image colorImage;
-
- public String label;
- public long rxBytes;
- public long rxPackets;
- public long txBytes;
- public long txPackets;
-
- public TrackedItem(int uid, int tag) {
- this.uid = uid;
- this.tag = tag;
- }
-
- public boolean isTotal() {
- return tag == 0x0;
- }
-
- /**
- * Record the given {@link NetworkSnapshot} delta, updating
- * {@link TimeSeries} and summary statistics.
- *
- * @param time Timestamp when delta was observed.
- * @param deltaMillis Time duration covered by delta, in milliseconds.
- */
- public void recordDelta(Millisecond time, long deltaMillis, NetworkSnapshot.Entry delta) {
- final long rxBytesPerSecond = (delta.rxBytes * 1000) / deltaMillis;
- final long txBytesPerSecond = (delta.txBytes * 1000) / deltaMillis;
-
- // record values under correct series
- if (isTotal()) {
- mRxTotalSeries.addOrUpdate(time, rxBytesPerSecond);
- mTxTotalSeries.addOrUpdate(time, -txBytesPerSecond);
- } else {
- mRxDetailDataset.addValue(rxBytesPerSecond, time, label);
- mTxDetailDataset.addValue(-txBytesPerSecond, time, label);
- }
-
- rxBytes += delta.rxBytes;
- rxPackets += delta.rxPackets;
- txBytes += delta.txBytes;
- txPackets += delta.txPackets;
- }
- }
-
- @Override
- public void deviceSelected() {
- // treat as client selection to update enabled states
- clientSelected();
- }
-
- @Override
- public void clientSelected() {
- mActiveUid = -1;
-
- final Client client = getCurrentClient();
- if (client != null) {
- final int pid = client.getClientData().getPid();
- try {
- // map PID to UID from device
- final UidParser uidParser = new UidParser();
- getCurrentDevice().executeShellCommand("cat /proc/" + pid + "/status", uidParser);
- mActiveUid = uidParser.uid;
- } catch (TimeoutException e) {
- e.printStackTrace();
- } catch (AdbCommandRejectedException e) {
- e.printStackTrace();
- } catch (ShellCommandUnresponsiveException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- clearTrackedItems();
- updateRunning(false);
-
- final boolean validUid = mActiveUid != -1;
- mRunningButton.setEnabled(validUid);
- }
-
- @Override
- public void clientChanged(Client client, int changeMask) {
- // ignored
- }
-
- /**
- * Take a snapshot from {@link #getCurrentDevice()}, recording any delta
- * network traffic to {@link TrackedItem}.
- */
- public void performSample() {
- final IDevice device = getCurrentDevice();
- if (device == null) return;
-
- try {
- final NetworkSnapshotParser parser = new NetworkSnapshotParser();
- device.executeShellCommand("cat " + PROC_XT_QTAGUID, parser);
-
- if (parser.isError()) {
- mDisplay.asyncExec(new Runnable() {
- @Override
- public void run() {
- updateRunning(false);
-
- final String title = "Problem reading stats";
- final String message = "Problem reading xt_qtaguid network "
- + "statistics from selected device.";
- Status status = new Status(IStatus.ERROR, "NetworkPanel", 0, message, null);
- ErrorDialog.openError(mPanel.getShell(), title, title, status);
- }
- });
-
- return;
- }
-
- final NetworkSnapshot snapshot = parser.getParsedSnapshot();
-
- // use first snapshot as baseline
- if (mLastSnapshot == null) {
- mLastSnapshot = snapshot;
- return;
- }
-
- final NetworkSnapshot delta = NetworkSnapshot.subtract(snapshot, mLastSnapshot);
- mLastSnapshot = snapshot;
-
- // perform delta updates over on UI thread
- if (!mDisplay.isDisposed()) {
- mDisplay.syncExec(new UpdateDeltaRunnable(delta, snapshot.timestamp));
- }
-
- } catch (TimeoutException e) {
- e.printStackTrace();
- } catch (AdbCommandRejectedException e) {
- e.printStackTrace();
- } catch (ShellCommandUnresponsiveException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Task that updates UI with given {@link NetworkSnapshot} delta.
- */
- private class UpdateDeltaRunnable implements Runnable {
- private final NetworkSnapshot mDelta;
- private final long mEndTime;
-
- public UpdateDeltaRunnable(NetworkSnapshot delta, long endTime) {
- mDelta = delta;
- mEndTime = endTime;
- }
-
- @Override
- public void run() {
- if (mDisplay.isDisposed()) return;
-
- final Millisecond time = new Millisecond(new Date(mEndTime));
- for (NetworkSnapshot.Entry entry : mDelta) {
- if (mActiveUid != entry.uid) continue;
-
- final TrackedItem item = findOrCreateTrackedItem(entry.uid, entry.tag);
- item.recordDelta(time, mDelta.timestamp, entry);
- }
-
- // remove any historical detail data
- final long beforeMillis = mEndTime - HISTORY_MILLIS;
- mRxDetailDataset.removeBefore(beforeMillis);
- mTxDetailDataset.removeBefore(beforeMillis);
-
- // trigger refresh from bulk changes above
- mRxDetailDataset.fireDatasetChanged();
- mTxDetailDataset.fireDatasetChanged();
-
- // update axis to show latest 30 second time period
- mDomainAxis.setRange(mEndTime - HISTORY_MILLIS, mEndTime);
-
- updateSeriesPaint();
-
- // kick table viewer to update
- mTableViewer.setInput(mTrackedItems);
- }
- }
-
- /**
- * Parser that extracts UID from remote {@code /proc/pid/status} file.
- */
- private static class UidParser extends MultiLineReceiver {
- public int uid = -1;
-
- @Override
- public boolean isCancelled() {
- return false;
- }
-
- @Override
- public void processNewLines(String[] lines) {
- for (String line : lines) {
- if (line.startsWith("Uid:")) {
- // we care about the "real" UID
- final String[] cols = line.split("\t");
- uid = Integer.parseInt(cols[1]);
- }
- }
- }
- }
-
- /**
- * Parser that populates {@link NetworkSnapshot} based on contents of remote
- * {@link NetworkPanel#PROC_XT_QTAGUID} file.
- */
- private static class NetworkSnapshotParser extends MultiLineReceiver {
- private NetworkSnapshot mSnapshot;
-
- public NetworkSnapshotParser() {
- mSnapshot = new NetworkSnapshot(System.currentTimeMillis());
- }
-
- public boolean isError() {
- return mSnapshot == null;
- }
-
- public NetworkSnapshot getParsedSnapshot() {
- return mSnapshot;
- }
-
- @Override
- public boolean isCancelled() {
- return false;
- }
-
- @Override
- public void processNewLines(String[] lines) {
- for (String line : lines) {
- if (line.endsWith("No such file or directory")) {
- mSnapshot = null;
- return;
- }
-
- // ignore header line
- if (line.startsWith("idx")) {
- continue;
- }
-
- final String[] cols = line.split(" ");
- if (cols.length < 9) continue;
-
- // iface and set are currently ignored, which groups those
- // entries together.
- final NetworkSnapshot.Entry entry = new NetworkSnapshot.Entry();
-
- entry.iface = null; //cols[1];
- entry.uid = Integer.parseInt(cols[3]);
- entry.set = -1; //Integer.parseInt(cols[4]);
- entry.tag = kernelToTag(cols[2]);
- entry.rxBytes = Long.parseLong(cols[5]);
- entry.rxPackets = Long.parseLong(cols[6]);
- entry.txBytes = Long.parseLong(cols[7]);
- entry.txPackets = Long.parseLong(cols[8]);
-
- mSnapshot.combine(entry);
- }
- }
-
- /**
- * Convert {@code /proc/} tag format to {@link Integer}. Assumes incoming
- * format like {@code 0x7fffffff00000000}.
- * Matches code in android.server.NetworkManagementSocketTagger
- */
- public static int kernelToTag(String string) {
- int length = string.length();
- if (length > 10) {
- return Long.decode(string.substring(0, length - 8)).intValue();
- } else {
- return 0;
- }
- }
- }
-
- /**
- * Parsed snapshot of {@link NetworkPanel#PROC_XT_QTAGUID} at specific time.
- */
- private static class NetworkSnapshot implements Iterable<NetworkSnapshot.Entry> {
- private ArrayList<Entry> mStats = new ArrayList<Entry>();
-
- public final long timestamp;
-
- /** Single parsed statistics row. */
- public static class Entry {
- public String iface;
- public int uid;
- public int set;
- public int tag;
- public long rxBytes;
- public long rxPackets;
- public long txBytes;
- public long txPackets;
-
- public boolean isEmpty() {
- return rxBytes == 0 && rxPackets == 0 && txBytes == 0 && txPackets == 0;
- }
- }
-
- public NetworkSnapshot(long timestamp) {
- this.timestamp = timestamp;
- }
-
- public void clear() {
- mStats.clear();
- }
-
- /**
- * Combine the given {@link Entry} with any existing {@link Entry}, or
- * insert if none exists.
- */
- public void combine(Entry entry) {
- final Entry existing = findEntry(entry.iface, entry.uid, entry.set, entry.tag);
- if (existing != null) {
- existing.rxBytes += entry.rxBytes;
- existing.rxPackets += entry.rxPackets;
- existing.txBytes += entry.txBytes;
- existing.txPackets += entry.txPackets;
- } else {
- mStats.add(entry);
- }
- }
-
- @Override
- public Iterator<Entry> iterator() {
- return mStats.iterator();
- }
-
- public Entry findEntry(String iface, int uid, int set, int tag) {
- for (Entry entry : mStats) {
- if (entry.uid == uid && entry.set == set && entry.tag == tag
- && equal(entry.iface, iface)) {
- return entry;
- }
- }
- return null;
- }
-
- /**
- * Subtract the two given {@link NetworkSnapshot} objects, returning the
- * delta between them.
- */
- public static NetworkSnapshot subtract(NetworkSnapshot left, NetworkSnapshot right) {
- final NetworkSnapshot result = new NetworkSnapshot(left.timestamp - right.timestamp);
-
- // for each row on left, subtract value from right side
- for (Entry leftEntry : left) {
- final Entry rightEntry = right.findEntry(
- leftEntry.iface, leftEntry.uid, leftEntry.set, leftEntry.tag);
- if (rightEntry == null) continue;
-
- final Entry resultEntry = new Entry();
- resultEntry.iface = leftEntry.iface;
- resultEntry.uid = leftEntry.uid;
- resultEntry.set = leftEntry.set;
- resultEntry.tag = leftEntry.tag;
- resultEntry.rxBytes = leftEntry.rxBytes - rightEntry.rxBytes;
- resultEntry.rxPackets = leftEntry.rxPackets - rightEntry.rxPackets;
- resultEntry.txBytes = leftEntry.txBytes - rightEntry.txBytes;
- resultEntry.txPackets = leftEntry.txPackets - rightEntry.txPackets;
-
- result.combine(resultEntry);
- }
-
- return result;
- }
- }
-
- /**
- * Provider of {@link #mTrackedItems}.
- */
- private class ContentProvider implements IStructuredContentProvider {
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // pass
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public Object[] getElements(Object inputElement) {
- return mTrackedItems.toArray();
- }
- }
-
- /**
- * Provider of labels for {@Link TrackedItem} values.
- */
- private static class LabelProvider implements ITableLabelProvider {
- private final DecimalFormat mFormat = new DecimalFormat("#,###");
-
- @Override
- public Image getColumnImage(Object element, int columnIndex) {
- if (element instanceof TrackedItem) {
- final TrackedItem item = (TrackedItem) element;
- switch (columnIndex) {
- case 0:
- return item.colorImage;
- }
- }
- return null;
- }
-
- @Override
- public String getColumnText(Object element, int columnIndex) {
- if (element instanceof TrackedItem) {
- final TrackedItem item = (TrackedItem) element;
- switch (columnIndex) {
- case 0:
- return null;
- case 1:
- return item.label;
- case 2:
- return mFormat.format(item.rxBytes);
- case 3:
- return mFormat.format(item.rxPackets);
- case 4:
- return mFormat.format(item.txBytes);
- case 5:
- return mFormat.format(item.txPackets);
- }
- }
- return null;
- }
-
- @Override
- public void addListener(ILabelProviderListener listener) {
- // pass
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- // pass
- return false;
- }
-
- @Override
- public void removeListener(ILabelProviderListener listener) {
- // pass
- }
- }
-
- /**
- * Format that displays simplified byte units for when given values are
- * large enough.
- */
- private static class BytesFormat extends NumberFormat {
- private final String[] mUnits;
- private final DecimalFormat mFormat = new DecimalFormat("#.#");
-
- public BytesFormat(boolean perSecond) {
- if (perSecond) {
- mUnits = new String[] { "B/s", "KB/s", "MB/s" };
- } else {
- mUnits = new String[] { "B", "KB", "MB" };
- }
- }
-
- @Override
- public StringBuffer format(long number, StringBuffer toAppendTo, FieldPosition pos) {
- double value = Math.abs(number);
-
- int i = 0;
- while (value > 1024 && i < mUnits.length - 1) {
- value /= 1024;
- i++;
- }
-
- toAppendTo.append(mFormat.format(value));
- toAppendTo.append(mUnits[i]);
-
- return toAppendTo;
- }
-
- @Override
- public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
- return format((long) number, toAppendTo, pos);
- }
-
- @Override
- public Number parse(String source, ParsePosition parsePosition) {
- return null;
- }
- }
-
- public static boolean equal(Object a, Object b) {
- return a == b || (a != null && a.equals(b));
- }
-
- /**
- * Build stub string of requested length, usually for measurement.
- */
- private static String buildSampleText(int length) {
- final StringBuilder builder = new StringBuilder(length);
- for (int i = 0; i < length; i++) {
- builder.append("X");
- }
- return builder.toString();
- }
-
- /**
- * Dataset that contains live measurements. Exposes
- * {@link #removeBefore(long)} to efficiently remove old data, and enables
- * batched {@link #fireDatasetChanged()} events.
- */
- public static class LiveTimeTableXYDataset extends AbstractIntervalXYDataset implements
- TableXYDataset {
- private DefaultKeyedValues2D mValues = new DefaultKeyedValues2D(true);
-
- /**
- * Caller is responsible for triggering {@link #fireDatasetChanged()}.
- */
- public void addValue(Number value, TimePeriod rowKey, String columnKey) {
- mValues.addValue(value, rowKey, columnKey);
- }
-
- /**
- * Caller is responsible for triggering {@link #fireDatasetChanged()}.
- */
- public void removeBefore(long beforeMillis) {
- while(mValues.getRowCount() > 0) {
- final TimePeriod period = (TimePeriod) mValues.getRowKey(0);
- if (period.getEnd().getTime() < beforeMillis) {
- mValues.removeRow(0);
- } else {
- break;
- }
- }
- }
-
- public int getColumnIndex(String key) {
- return mValues.getColumnIndex(key);
- }
-
- public void clear() {
- mValues.clear();
- fireDatasetChanged();
- }
-
- @Override
- public void fireDatasetChanged() {
- super.fireDatasetChanged();
- }
-
- @Override
- public int getItemCount() {
- return mValues.getRowCount();
- }
-
- @Override
- public int getItemCount(int series) {
- return mValues.getRowCount();
- }
-
- @Override
- public int getSeriesCount() {
- return mValues.getColumnCount();
- }
-
- @Override
- public Comparable getSeriesKey(int series) {
- return mValues.getColumnKey(series);
- }
-
- @Override
- public double getXValue(int series, int item) {
- final TimePeriod period = (TimePeriod) mValues.getRowKey(item);
- return period.getStart().getTime();
- }
-
- @Override
- public double getStartXValue(int series, int item) {
- return getXValue(series, item);
- }
-
- @Override
- public double getEndXValue(int series, int item) {
- return getXValue(series, item);
- }
-
- @Override
- public Number getX(int series, int item) {
- return getXValue(series, item);
- }
-
- @Override
- public Number getStartX(int series, int item) {
- return getXValue(series, item);
- }
-
- @Override
- public Number getEndX(int series, int item) {
- return getXValue(series, item);
- }
-
- @Override
- public Number getY(int series, int item) {
- return mValues.getValue(item, series);
- }
-
- @Override
- public Number getStartY(int series, int item) {
- return getY(series, item);
- }
-
- @Override
- public Number getEndY(int series, int item) {
- return getY(series, item);
- }
- }
-}
diff --git a/ddms/libs/ddmuilib/src/images/add.png b/ddms/libs/ddmuilib/src/images/add.png
deleted file mode 100644
index eefc2ca..0000000
--- a/ddms/libs/ddmuilib/src/images/add.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/android.png b/ddms/libs/ddmuilib/src/images/android.png
deleted file mode 100644
index 3779d4d..0000000
--- a/ddms/libs/ddmuilib/src/images/android.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/backward.png b/ddms/libs/ddmuilib/src/images/backward.png
deleted file mode 100644
index 90a9713..0000000
--- a/ddms/libs/ddmuilib/src/images/backward.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/capture.png b/ddms/libs/ddmuilib/src/images/capture.png
deleted file mode 100644
index da5c10b..0000000
--- a/ddms/libs/ddmuilib/src/images/capture.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/clear.png b/ddms/libs/ddmuilib/src/images/clear.png
deleted file mode 100644
index 0009cf6..0000000
--- a/ddms/libs/ddmuilib/src/images/clear.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/d.png b/ddms/libs/ddmuilib/src/images/d.png
deleted file mode 100644
index d45506e..0000000
--- a/ddms/libs/ddmuilib/src/images/d.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/debug-attach.png b/ddms/libs/ddmuilib/src/images/debug-attach.png
deleted file mode 100644
index 9b8a11c..0000000
--- a/ddms/libs/ddmuilib/src/images/debug-attach.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/debug-error.png b/ddms/libs/ddmuilib/src/images/debug-error.png
deleted file mode 100644
index f22da1f..0000000
--- a/ddms/libs/ddmuilib/src/images/debug-error.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/debug-wait.png b/ddms/libs/ddmuilib/src/images/debug-wait.png
deleted file mode 100644
index 322be63..0000000
--- a/ddms/libs/ddmuilib/src/images/debug-wait.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/delete.png b/ddms/libs/ddmuilib/src/images/delete.png
deleted file mode 100644
index db5fab8..0000000
--- a/ddms/libs/ddmuilib/src/images/delete.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/device.png b/ddms/libs/ddmuilib/src/images/device.png
deleted file mode 100644
index 7dbbbb6..0000000
--- a/ddms/libs/ddmuilib/src/images/device.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/diff.png b/ddms/libs/ddmuilib/src/images/diff.png
deleted file mode 100644
index bdd9e5c..0000000
--- a/ddms/libs/ddmuilib/src/images/diff.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/displayfilters.png b/ddms/libs/ddmuilib/src/images/displayfilters.png
deleted file mode 100644
index d110c2c..0000000
--- a/ddms/libs/ddmuilib/src/images/displayfilters.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/down.png b/ddms/libs/ddmuilib/src/images/down.png
deleted file mode 100644
index f9426cb..0000000
--- a/ddms/libs/ddmuilib/src/images/down.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/e.png b/ddms/libs/ddmuilib/src/images/e.png
deleted file mode 100644
index dee7c97..0000000
--- a/ddms/libs/ddmuilib/src/images/e.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/edit.png b/ddms/libs/ddmuilib/src/images/edit.png
deleted file mode 100644
index b8f65bc..0000000
--- a/ddms/libs/ddmuilib/src/images/edit.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/empty.png b/ddms/libs/ddmuilib/src/images/empty.png
deleted file mode 100644
index f021542..0000000
--- a/ddms/libs/ddmuilib/src/images/empty.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/emulator.png b/ddms/libs/ddmuilib/src/images/emulator.png
deleted file mode 100644
index a718042..0000000
--- a/ddms/libs/ddmuilib/src/images/emulator.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/file.png b/ddms/libs/ddmuilib/src/images/file.png
deleted file mode 100644
index 043a814..0000000
--- a/ddms/libs/ddmuilib/src/images/file.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/folder.png b/ddms/libs/ddmuilib/src/images/folder.png
deleted file mode 100644
index 7e29b1a..0000000
--- a/ddms/libs/ddmuilib/src/images/folder.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/forward.png b/ddms/libs/ddmuilib/src/images/forward.png
deleted file mode 100644
index a97a605..0000000
--- a/ddms/libs/ddmuilib/src/images/forward.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/gc.png b/ddms/libs/ddmuilib/src/images/gc.png
deleted file mode 100644
index 5194806..0000000
--- a/ddms/libs/ddmuilib/src/images/gc.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/groupby.png b/ddms/libs/ddmuilib/src/images/groupby.png
deleted file mode 100644
index 250b982..0000000
--- a/ddms/libs/ddmuilib/src/images/groupby.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/halt.png b/ddms/libs/ddmuilib/src/images/halt.png
deleted file mode 100644
index 10e3720..0000000
--- a/ddms/libs/ddmuilib/src/images/halt.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/heap.png b/ddms/libs/ddmuilib/src/images/heap.png
deleted file mode 100644
index e3aa3f0..0000000
--- a/ddms/libs/ddmuilib/src/images/heap.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/hprof.png b/ddms/libs/ddmuilib/src/images/hprof.png
deleted file mode 100644
index 123d062..0000000
--- a/ddms/libs/ddmuilib/src/images/hprof.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/i.png b/ddms/libs/ddmuilib/src/images/i.png
deleted file mode 100644
index 98385c5..0000000
--- a/ddms/libs/ddmuilib/src/images/i.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/importBug.png b/ddms/libs/ddmuilib/src/images/importBug.png
deleted file mode 100644
index f5da179..0000000
--- a/ddms/libs/ddmuilib/src/images/importBug.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/load.png b/ddms/libs/ddmuilib/src/images/load.png
deleted file mode 100644
index 9e7bf6e..0000000
--- a/ddms/libs/ddmuilib/src/images/load.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/pause.png b/ddms/libs/ddmuilib/src/images/pause.png
deleted file mode 100644
index 19d286d..0000000
--- a/ddms/libs/ddmuilib/src/images/pause.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/play.png b/ddms/libs/ddmuilib/src/images/play.png
deleted file mode 100644
index d54f013..0000000
--- a/ddms/libs/ddmuilib/src/images/play.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/pull.png b/ddms/libs/ddmuilib/src/images/pull.png
deleted file mode 100644
index f48f1b1..0000000
--- a/ddms/libs/ddmuilib/src/images/pull.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/push.png b/ddms/libs/ddmuilib/src/images/push.png
deleted file mode 100644
index 6222864..0000000
--- a/ddms/libs/ddmuilib/src/images/push.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/save.png b/ddms/libs/ddmuilib/src/images/save.png
deleted file mode 100644
index 040ebda..0000000
--- a/ddms/libs/ddmuilib/src/images/save.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/scroll_lock.png b/ddms/libs/ddmuilib/src/images/scroll_lock.png
deleted file mode 100644
index 5d26689..0000000
--- a/ddms/libs/ddmuilib/src/images/scroll_lock.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/sort_down.png b/ddms/libs/ddmuilib/src/images/sort_down.png
deleted file mode 100644
index 2d4ccc1..0000000
--- a/ddms/libs/ddmuilib/src/images/sort_down.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/sort_up.png b/ddms/libs/ddmuilib/src/images/sort_up.png
deleted file mode 100644
index 3a0bc3c..0000000
--- a/ddms/libs/ddmuilib/src/images/sort_up.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/thread.png b/ddms/libs/ddmuilib/src/images/thread.png
deleted file mode 100644
index ac839e8..0000000
--- a/ddms/libs/ddmuilib/src/images/thread.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/tracing_start.png b/ddms/libs/ddmuilib/src/images/tracing_start.png
deleted file mode 100644
index 88771cc..0000000
--- a/ddms/libs/ddmuilib/src/images/tracing_start.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/tracing_stop.png b/ddms/libs/ddmuilib/src/images/tracing_stop.png
deleted file mode 100644
index 71bd215..0000000
--- a/ddms/libs/ddmuilib/src/images/tracing_stop.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/up.png b/ddms/libs/ddmuilib/src/images/up.png
deleted file mode 100644
index 92edf5a..0000000
--- a/ddms/libs/ddmuilib/src/images/up.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/v.png b/ddms/libs/ddmuilib/src/images/v.png
deleted file mode 100644
index 8044051..0000000
--- a/ddms/libs/ddmuilib/src/images/v.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/w.png b/ddms/libs/ddmuilib/src/images/w.png
deleted file mode 100644
index 129d0f9..0000000
--- a/ddms/libs/ddmuilib/src/images/w.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/warning.png b/ddms/libs/ddmuilib/src/images/warning.png
deleted file mode 100644
index ca3b6ed..0000000
--- a/ddms/libs/ddmuilib/src/images/warning.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/src/images/zygote.png b/ddms/libs/ddmuilib/src/images/zygote.png
deleted file mode 100644
index 5cbb1d2..0000000
--- a/ddms/libs/ddmuilib/src/images/zygote.png
+++ /dev/null
Binary files differ
diff --git a/ddms/libs/ddmuilib/tests/.classpath b/ddms/libs/ddmuilib/tests/.classpath
deleted file mode 100644
index 83429f8..0000000
--- a/ddms/libs/ddmuilib/tests/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/swt.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.equinox.common_3.6.0.v20100503.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/ddms/libs/ddmuilib/tests/.project b/ddms/libs/ddmuilib/tests/.project
deleted file mode 100644
index ca60a57..0000000
--- a/ddms/libs/ddmuilib/tests/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>ddmuilib-tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/ddms/libs/ddmuilib/tests/Android.mk b/ddms/libs/ddmuilib/tests/Android.mk
deleted file mode 100644
index 6bbff34..0000000
--- a/ddms/libs/ddmuilib/tests/Android.mk
+++ /dev/null
@@ -1,37 +0,0 @@
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-# Only compile source java files in this lib.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_MODULE := ddmuilib-tests
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_JAVA_LIBRARIES := \
- ddmlib \
- ddmuilib \
- swt \
- org.eclipse.jface_3.6.2.M20110210-1200 \
- org.eclipse.equinox.common_3.6.0.v20100503 \
- org.eclipse.core.commands_3.6.0.I20100512-1500 \
- junit
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-# Build all sub-directories
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/BugReportParserTest.java b/ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/BugReportParserTest.java
deleted file mode 100644
index 7894965..0000000
--- a/ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/BugReportParserTest.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib;
-
-import com.android.ddmuilib.SysinfoPanel.BugReportParser;
-import com.android.ddmuilib.SysinfoPanel.BugReportParser.DataValue;
-import com.android.ddmuilib.SysinfoPanel.BugReportParser.GfxProfileData;
-
-import junit.framework.TestCase;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.StringReader;
-import java.util.List;
-
-public class BugReportParserTest extends TestCase {
- public void testParseEclairCpuDataSet() throws IOException {
- String cpuInfo =
- "Currently running services:\n" +
- " cpuinfo\n" +
- " ----------------------------------------------------------------------------\n" +
- " DUMP OF SERVICE cpuinfo:\n" +
- " Load: 0.53 / 0.11 / 0.04\n" +
- " CPU usage from 33406ms to 28224ms ago:\n" +
- " system_server: 56% = 42% user + 13% kernel / faults: 6724 minor 9 major\n" +
- " bootanimation: 1% = 0% user + 0% kernel\n" +
- " zygote: 0% = 0% user + 0% kernel / faults: 146 minor\n" +
- " TOTAL: 98% = 67% user + 30% kernel;\n";
- BufferedReader br = new BufferedReader(new StringReader(cpuInfo));
- List<DataValue> data = BugReportParser.readCpuDataset(br);
-
- assertEquals(4, data.size());
- assertEquals("system_server (user)", data.get(0).name);
- assertEquals("Idle", data.get(3).name);
- }
-
- public void testParseJbCpuDataSet() throws IOException {
- String cpuInfo =
- "Load: 1.0 / 1.02 / 0.97\n" +
- "CPU usage from 96307ms to 36303ms ago:\n" +
- " 0.4% 675/system_server: 0.3% user + 0.1% kernel / faults: 198 minor\n" +
- " 0.1% 173/mpdecision: 0% user + 0.1% kernel\n" +
- " 0% 2856/kworker/0:2: 0% user + 0% kernel\n" +
- " 0% 3128/kworker/0:0: 0% user + 0% kernel\n" +
- "0.3% TOTAL: 0.1% user + 0% kernel + 0% iowait\n";
- BufferedReader br = new BufferedReader(new StringReader(cpuInfo));
- List<DataValue> data = BugReportParser.readCpuDataset(br);
-
- assertEquals(4, data.size());
- assertEquals("675/system_server (user)", data.get(0).name);
- assertEquals("Idle", data.get(3).name);
- }
-
- public void testParseProcRankEclair() throws IOException {
- String memInfo =
- " 51 39408K 37908K 18731K 14936K system_server\n" +
- " 96 27432K 27432K 9501K 6816K android.process.acore\n" +
- " 27 248K 248K 83K 76K /system/bin/debuggerd\n";
- BufferedReader br = new BufferedReader(new StringReader(memInfo));
- List<DataValue> data = BugReportParser.readProcRankDataset(br,
- " PID Vss Rss Pss Uss cmdline\n");
-
- assertEquals(3, data.size());
- assertEquals("debuggerd", data.get(2).name);
- if (data.get(0).value - 18731 > 0.0002) {
- fail("Unexpected PSS Value " + data.get(0).value);
- }
- }
-
- public void testParseProcRankJb() throws IOException {
- String memInfo =
- " 675 101120K 100928K 63452K 52624K system_server\n" +
- "10170 82100K 82012K 58246K 53580K com.android.chrome:sandboxed_process0\n" +
- " 8742 27296K 27224K 6849K 5620K com.google.android.apps.walletnfcrel\n" +
- " ------ ------ ------\n" +
- " 480598K 394172K TOTAL\n" +
- "\n" +
- "RAM: 1916984K total, 886404K free, 72036K buffers, 482544K cached, 456K shmem, 34864K slab\n";
- BufferedReader br = new BufferedReader(new StringReader(memInfo));
- List<DataValue> data = BugReportParser.readProcRankDataset(br,
- " PID Vss Rss Pss Uss cmdline\n");
-
- assertEquals(3, data.size());
- }
-
- public void testParseMeminfoEclair() throws IOException {
- String memInfo =
- "------ MEMORY INFO ------\n" +
- "MemTotal: 516528 kB\n" +
- "MemFree: 401036 kB\n" +
- "Buffers: 0 kB\n" +
- " PID Vss Rss Pss Uss cmdline\n" +
- " 51 39408K 37908K 18731K 14936K system_server\n" +
- " 96 27432K 27432K 9501K 6816K android.process.acore\n" +
- " 297 23348K 23348K 5245K 2276K com.android.gallery\n";
- BufferedReader br = new BufferedReader(new StringReader(memInfo));
- List<DataValue> data = BugReportParser.readMeminfoDataset(br);
- assertEquals(5, data.size());
-
- assertEquals("Free", data.get(0).name);
- }
-
- public void testParseMeminfoJb() throws IOException {
-
- String memInfo = // note: This dataset does not have all entries, so the totals will be off
- "------ MEMORY INFO ------\n" +
- "MemTotal: 1916984 kB\n" +
- "MemFree: 888048 kB\n" +
- "Buffers: 72036 kB\n" +
- " PID Vss Rss Pss Uss cmdline\n" +
- " 675 101120K 100928K 63452K 52624K system_server\n" +
- "10170 82100K 82012K 58246K 53580K com.android.chrome:sandboxed_process0\n" +
- " 8742 27296K 27224K 6849K 5620K com.google.android.apps.walletnfcrel\n" +
- " ------ ------ ------\n" +
- " 480598K 394172K TOTAL\n" +
- "\n" +
- "RAM: 1916984K total, 886404K free, 72036K buffers, 482544K cached, 456K shmem, 34864K slab\n";
-
- BufferedReader br = new BufferedReader(new StringReader(memInfo));
- List<DataValue> data = BugReportParser.readMeminfoDataset(br);
-
- assertEquals(6, data.size());
- }
-
- public void testParseGfxInfo() throws IOException {
- String gfxinfo =
- "Applications Graphics Acceleration Info:\n" +
- "Uptime: 78455570 Realtime: 78455565\n" +
- "\n" +
- "** Graphics info for pid 20517 [com.android.launcher] **\n" +
- "\n" +
- "Recent DisplayList operations\n" +
- " DrawDisplayList\n" +
- " <snip>\n" +
- " RestoreToCount\n" +
- "\n" +
- "Caches:\n" +
- "Current memory usage / total memory usage (bytes):\n" +
- " TextureCache 4663920 / 25165824\n" +
- " <snip>\n" +
- " FontRenderer 0 262144 / 262144\n" +
- "Other:\n" +
- " FboCache 2 / 16\n" +
- " PatchCache 9 / 512\n" +
- "Total memory usage:\n" +
- " 13274756 bytes, 12.66 MB\n" +
- "\n" +
- "Profile data in ms:\n" +
- "\n" +
- " com.android.launcher/com.android.launcher2.Launcher/android.view.ViewRootImpl@4265d918\n" +
- " Draw Process Execute\n" +
- " 0.85 1.10 0.61\n" +
- " 54.45 0.85 0.52\n" +
- " 1.04 2.17 0.73\n" +
- " 0.15 0.46 1.01\n" +
- "\n" +
- "View hierarchy:\n" +
- "\n" +
- " com.android.launcher/com.android.launcher2.Launcher/android.view.ViewRootImpl@4265d918\n" +
- " 276 views, 27.16 kB of display lists, 228 frames rendered\n" +
- "\n" +
- "\n" +
- "Total ViewRootImpl: 1\n" +
- "Total Views: 276\n" +
- "Total DisplayList: 27.16 kB\n";
-
- BufferedReader br = new BufferedReader(new StringReader(gfxinfo));
- List<GfxProfileData> gfxProfile = BugReportParser.parseGfxInfo(br);
-
- assertEquals(4, gfxProfile.size());
- assertEquals(0.85, gfxProfile.get(0).draw);
- assertEquals(1.01, gfxProfile.get(3).execute);
- }
-}
diff --git a/ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/heap/NativeHeapDataImporterTest.java b/ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/heap/NativeHeapDataImporterTest.java
deleted file mode 100644
index 4487454..0000000
--- a/ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/heap/NativeHeapDataImporterTest.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.heap;
-
-import com.android.ddmlib.NativeAllocationInfo;
-import com.android.ddmlib.NativeStackCallInfo;
-
-import junit.framework.TestCase;
-
-import org.eclipse.core.runtime.NullProgressMonitor;
-
-import java.io.StringReader;
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-
-public class NativeHeapDataImporterTest extends TestCase {
- private static final String BASIC_TEXT =
- "Allocations: 1\n" +
- "Size: 524292\n" +
- "TotalSize: 524292\n" +
- "BeginStacktrace:\n" +
- " 40170bd8 /libc_malloc_leak.so --- getbacktrace --- /b/malloc_leak.c:258\n" +
- " 400910d6 /lib/libc.so --- ca110c --- /bionic/malloc_debug_common.c:227\n" +
- " 5dd6abfe /lib/libcgdrv.so --- 5dd6abfe ---\n" +
- " 5dd98a8e /lib/libcgdrv.so --- 5dd98a8e ---\n" +
- "EndStacktrace\n";
-
- private NativeHeapDataImporter mImporter;
-
- public void testImportValidAllocation() {
- mImporter = createImporter(BASIC_TEXT);
- try {
- mImporter.run(new NullProgressMonitor());
- } catch (InvocationTargetException e) {
- fail("Unexpected exception while parsing text: " + e.getTargetException().getMessage());
- } catch (InterruptedException e) {
- fail("Tests are not interrupted!");
- }
-
- NativeHeapSnapshot snapshot = mImporter.getImportedSnapshot();
- assertNotNull(snapshot);
-
- // check whether all details have been parsed correctly
- assertEquals(1, snapshot.getAllocations().size());
-
- NativeAllocationInfo info = snapshot.getAllocations().get(0);
-
- assertEquals(1, info.getAllocationCount());
- assertEquals(524292, info.getSize());
- assertEquals(true, info.isStackCallResolved());
-
- List<NativeStackCallInfo> stack = info.getResolvedStackCall();
- assertEquals(4, stack.size());
- }
-
- private NativeHeapDataImporter createImporter(String contentsToParse) {
- StringReader r = new StringReader(contentsToParse);
- return new NativeHeapDataImporter(r);
- }
-}
diff --git a/ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/logcat/LogCatFilterSettingsSerializerTest.java b/ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/logcat/LogCatFilterSettingsSerializerTest.java
deleted file mode 100644
index e6c0e76..0000000
--- a/ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/logcat/LogCatFilterSettingsSerializerTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmlib.Log.LogLevel;
-import com.android.ddmlib.logcat.LogCatFilter;
-
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-public class LogCatFilterSettingsSerializerTest extends TestCase {
- /* test that decode(encode(f)) = f */
- public void testSerializer() {
- LogCatFilter fs = new LogCatFilter(
- "TestFilter", //$NON-NLS-1$
- "Tag'.*Regex", //$NON-NLS-1$
- "regexForTextField..''", //$NON-NLS-1$
- "123", //$NON-NLS-1$
- "TestAppName.*", //$NON-NLS-1$
- LogLevel.ERROR);
-
- LogCatFilterSettingsSerializer serializer = new LogCatFilterSettingsSerializer();
- String s = serializer.encodeToPreferenceString(Arrays.asList(fs),
- new HashMap<LogCatFilter, LogCatFilterData>());
- List<LogCatFilter> decodedFiltersList = serializer.decodeFromPreferenceString(s);
-
- assertEquals(1, decodedFiltersList.size());
-
- LogCatFilter dfs = decodedFiltersList.get(0);
- assertEquals(fs.getName(), dfs.getName());
- assertEquals(fs.getTag(), dfs.getTag());
- assertEquals(fs.getText(), dfs.getText());
- assertEquals(fs.getPid(), dfs.getPid());
- assertEquals(fs.getAppName(), dfs.getAppName());
- assertEquals(fs.getLogLevel(), dfs.getLogLevel());
- }
-
- /* test that transient filters are not persisted */
- public void testTransientFilters() {
- LogCatFilter fs = new LogCatFilter(
- "TestFilter", //$NON-NLS-1$
- "Tag'.*Regex", //$NON-NLS-1$
- "regexForTextField..''", //$NON-NLS-1$
- "123", //$NON-NLS-1$
- "TestAppName.*", //$NON-NLS-1$
- LogLevel.ERROR);
- LogCatFilterData fd = new LogCatFilterData(fs);
- fd.setTransient();
- HashMap<LogCatFilter, LogCatFilterData> fdMap =
- new HashMap<LogCatFilter, LogCatFilterData>();
- fdMap.put(fs, fd);
-
- LogCatFilterSettingsSerializer serializer = new LogCatFilterSettingsSerializer();
- String s = serializer.encodeToPreferenceString(Arrays.asList(fs), fdMap);
- List<LogCatFilter> decodedFiltersList = serializer.decodeFromPreferenceString(s);
-
- assertEquals(0, decodedFiltersList.size());
- }
-}
diff --git a/ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/logcat/LogCatStackTraceParserTest.java b/ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/logcat/LogCatStackTraceParserTest.java
deleted file mode 100644
index 7d9869a..0000000
--- a/ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/logcat/LogCatStackTraceParserTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ddmuilib.logcat;
-
-import junit.framework.TestCase;
-
-public class LogCatStackTraceParserTest extends TestCase {
- private LogCatStackTraceParser mTranslator;
-
- private static final String SAMPLE_METHOD = "com.foo.Class.method"; //$NON-NLS-1$
- private static final String SAMPLE_FNAME = "FileName"; //$NON-NLS-1$
- private static final int SAMPLE_LINENUM = 20;
- private static final String SAMPLE_TRACE =
- String.format(" at %s(%s.groovy:%d)", //$NON-NLS-1$
- SAMPLE_METHOD, SAMPLE_FNAME, SAMPLE_LINENUM);
-
- @Override
- protected void setUp() throws Exception {
- mTranslator = new LogCatStackTraceParser();
- }
-
- public void testIsValidExceptionTrace() {
- assertTrue(mTranslator.isValidExceptionTrace(SAMPLE_TRACE));
- assertFalse(mTranslator.isValidExceptionTrace(
- "java.lang.RuntimeException: message")); //$NON-NLS-1$
- assertFalse(mTranslator.isValidExceptionTrace(
- "at com.foo.test(Ins.java:unknown)")); //$NON-NLS-1$
- }
-
- public void testGetMethodName() {
- assertEquals(SAMPLE_METHOD, mTranslator.getMethodName(SAMPLE_TRACE));
- }
-
- public void testGetFileName() {
- assertEquals(SAMPLE_FNAME, mTranslator.getFileName(SAMPLE_TRACE));
- }
-
- public void testGetLineNumber() {
- assertEquals(SAMPLE_LINENUM, mTranslator.getLineNumber(SAMPLE_TRACE));
- }
-}
diff --git a/ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/logcat/RollingBufferFindTest.java b/ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/logcat/RollingBufferFindTest.java
deleted file mode 100644
index 32a36c4..0000000
--- a/ddms/libs/ddmuilib/tests/src/com/android/ddmuilib/logcat/RollingBufferFindTest.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ddmuilib.logcat;
-
-import com.android.ddmuilib.AbstractBufferFindTarget;
-
-import junit.framework.TestCase;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class RollingBufferFindTest extends TestCase {
- public class FindTarget extends AbstractBufferFindTarget {
- private int mSelectedItem = -1;
- private int mItemReadCount = 0;
- private List<String> mItems = Arrays.asList(
- "abc",
- "def",
- "abc",
- null,
- "xyz"
- );
-
- @Override
- public int getItemCount() {
- return mItems.size();
- }
-
- @Override
- public String getItem(int index) {
- mItemReadCount++;
- return mItems.get(index);
- }
-
- @Override
- public void selectAndReveal(int index) {
- mSelectedItem = index;
- }
-
- @Override
- public int getStartingIndex() {
- return mItems.size() - 1;
- }
- }
- FindTarget mFindTarget = new FindTarget();
-
- public void testMultipleMatch() {
- mFindTarget.mSelectedItem = -1;
-
- String text = "abc";
- int lastIndex = mFindTarget.mItems.lastIndexOf(text);
- int firstIndex = mFindTarget.mItems.indexOf(text);
-
- // the first time we search through the buffer we should hit the item at lastIndex
- assertTrue(mFindTarget.findAndSelect(text, true, false));
- assertEquals(lastIndex, mFindTarget.mSelectedItem);
-
- // subsequent search should hit the item at first index
- assertTrue(mFindTarget.findAndSelect(text, false, false));
- assertEquals(firstIndex, mFindTarget.mSelectedItem);
-
- // search again should roll over and hit the last index
- assertTrue(mFindTarget.findAndSelect(text, false, false));
- assertEquals(lastIndex, mFindTarget.mSelectedItem);
- }
-
- public void testMissingItem() {
- mFindTarget.mSelectedItem = -1;
- mFindTarget.mItemReadCount = 0;
-
- // should not match
- assertFalse(mFindTarget.findAndSelect("nonexistent", true, false));
-
- // no item should be selected
- assertEquals(-1, mFindTarget.mSelectedItem);
-
- // but all items should have been read in once
- assertEquals(mFindTarget.getItemCount(), mFindTarget.mItemReadCount);
- }
-
- public void testSearchDirection() {
- String text = "abc";
- int lastIndex = mFindTarget.mItems.lastIndexOf(text);
- int firstIndex = mFindTarget.mItems.indexOf(text);
-
- // the first time we search through the buffer we should hit the "abc" from the last
- assertTrue(mFindTarget.findAndSelect(text, true, false));
- assertEquals(lastIndex, mFindTarget.mSelectedItem);
-
- // searching forward from there should also hit the first index
- assertTrue(mFindTarget.findAndSelect(text, false, true));
- assertEquals(firstIndex, mFindTarget.mSelectedItem);
- }
-}
diff --git a/device_validator/.gitignore b/device_validator/.gitignore
deleted file mode 100644
index 42afabf..0000000
--- a/device_validator/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-/build \ No newline at end of file
diff --git a/device_validator/Android.mk b/device_validator/Android.mk
deleted file mode 100644
index 9e32461..0000000
--- a/device_validator/Android.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2012 The Android Open Source Project
-
-DEVICE_VALIDATOR_LOCAL_DIR := $(call my-dir)
-include $(DEVICE_VALIDATOR_LOCAL_DIR)/dvlib/Android.mk
-include $(DEVICE_VALIDATOR_LOCAL_DIR)/app/Android.mk
diff --git a/device_validator/MODULE_LICENSE_APACHE2 b/device_validator/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/device_validator/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/device_validator/app/.classpath b/device_validator/app/.classpath
deleted file mode 100644
index a1d7856..0000000
--- a/device_validator/app/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry combineaccessrules="false" kind="src" path="/dvlib"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/device_validator/app/.project b/device_validator/app/.project
deleted file mode 100644
index fda9e3d..0000000
--- a/device_validator/app/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>device_validator</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/device_validator/app/.settings/org.eclipse.jdt.ui.prefs b/device_validator/app/.settings/org.eclipse.jdt.ui.prefs
deleted file mode 100644
index c0fbc32..0000000
--- a/device_validator/app/.settings/org.eclipse.jdt.ui.prefs
+++ /dev/null
@@ -1,3 +0,0 @@
-#Fri May 25 10:41:24 PDT 2012
-eclipse.preferences.version=1
-formatter_settings_version=11
diff --git a/device_validator/app/Android.mk b/device_validator/app/Android.mk
deleted file mode 100644
index 93e6226..0000000
--- a/device_validator/app/Android.mk
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-
-LOCAL_JAR_MANIFEST := etc/manifest.txt
-
-LOCAL_JAVA_LIBRARIES := \
- dvlib
-
-LOCAL_MODULE := device_validator
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-# Build all sub-directories
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/device_validator/app/etc/Android.mk b/device_validator/app/etc/Android.mk
deleted file mode 100644
index 69a948c..0000000
--- a/device_validator/app/etc/Android.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2012 The Android Open Source Project
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_PREBUILT_EXECUTABLES := device_validator
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/device_validator/app/etc/README b/device_validator/app/etc/README
deleted file mode 100644
index 7cf0a0b..0000000
--- a/device_validator/app/etc/README
+++ /dev/null
@@ -1,19 +0,0 @@
-Device Validator
-================
- The device validator is a simple tool for validating XML that contains
- information about a list of Android devices. Simply run the tool from the
- command-line with the names of the XML files to validate as the arguments.
- If an XML file fails to validate, the errors will be printed to standard
- out and the program will terminate with a non-zero exit status.
-
- See device_example.xml for an example valid XML file, and devices.xsd
- for the schema the XML must conform to.
-
-Usage (Linux/OSX/BSD)
----------------------
- ./device_validator [files...]
-
-Usage (Windows)
----------------
- (from the untar'd directory)
- java -cp . -jar device_validator.jar [files...]
diff --git a/device_validator/app/etc/device_validator b/device_validator/app/etc/device_validator
deleted file mode 100755
index 08a1023..0000000
--- a/device_validator/app/etc/device_validator
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/bin/bash
-# Copyright 2012, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
- newProg=`/bin/ls -ld "${prog}"`
- newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
- if expr "x${newProg}" : 'x/' >/dev/null; then
- prog="${newProg}"
- else
- progdir=`dirname "${prog}"`
- prog="${progdir}/${newProg}"
- fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/`basename "${prog}"`
-cd "${oldwd}"
-
-jarfile=device_validator.jar
-frameworkdir="$progdir"
-libdir="$progdir"
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/tools/lib
- libdir=`dirname "$progdir"`/tools/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/framework
- libdir=`dirname "$progdir"`/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- echo `basename "$prog"`": can't find $jarfile"
- exit 1
-fi
-
-
-# Check args.
-if [ debug = "$1" ]; then
- # add this in for debugging
- java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
- shift 1
-else
- java_debug=
-fi
-
-javaCmd="java"
-
-# Mac OS X needs an additional arg, or you get an "illegal thread" complaint.
-if [ `uname` = "Darwin" ]; then
- os_opts="-XstartOnFirstThread"
-else
- os_opts=
-fi
-
-jarpath="$frameworkdir/$jarfile"
-
-exec "$javaCmd" \
- -Xmx256M $os_opts $java_debug \
- -classpath "$jarpath" \
- com.android.validator.DeviceValidator "$@"
diff --git a/device_validator/app/etc/manifest.txt b/device_validator/app/etc/manifest.txt
deleted file mode 100644
index 55b9038..0000000
--- a/device_validator/app/etc/manifest.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-Main-Class: com.android.validator.DeviceValidator
-Class-Path: dvlib.jar
-
diff --git a/device_validator/app/src/com/android/validator/DeviceValidator.java b/device_validator/app/src/com/android/validator/DeviceValidator.java
deleted file mode 100644
index 8ca6afe..0000000
--- a/device_validator/app/src/com/android/validator/DeviceValidator.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.validator;
-
-import com.android.dvlib.DeviceSchema;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
-public class DeviceValidator {
-
- public static void main(String[] args) {
- if (args.length == 0){
- printHelp();
- System.exit(1);
- }
- int ret = 0;
- for (String a : args) {
- File f = (new File(a)).getAbsoluteFile();
- try {
- if (!DeviceSchema.validate(new FileInputStream(f), System.err, f.getParentFile())) {
- System.err.println("Error validating " + f.getAbsolutePath());
- System.out.println();
- ret = 1;
- } else {
- System.out.println(f.getAbsolutePath() + " validated successfully.");
- }
- } catch (FileNotFoundException e) {
- System.err.println("File not found: " + a);
- ret = 1;
- }
- }
- System.exit(ret);
- }
-
- private static void printHelp() {
- System.err.printf("Usage: device_validator [files to validate]...\n");
- }
-
-}
diff --git a/device_validator/dvlib/.classpath b/device_validator/dvlib/.classpath
deleted file mode 100644
index 9cae787..0000000
--- a/device_validator/dvlib/.classpath
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/test/java"/>
- <classpathentry kind="src" path="src/main/resources"/>
- <classpathentry kind="src" path="src/test/resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/device_validator/dvlib/.gitignore b/device_validator/dvlib/.gitignore
deleted file mode 100644
index 3558c56..0000000
--- a/device_validator/dvlib/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-bin/
-build/
diff --git a/device_validator/dvlib/.project b/device_validator/dvlib/.project
deleted file mode 100644
index 13abbdf..0000000
--- a/device_validator/dvlib/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>dvlib</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/device_validator/dvlib/Android.mk b/device_validator/dvlib/Android.mk
deleted file mode 100644
index 658c69b..0000000
--- a/device_validator/dvlib/Android.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# The dvlib code has moved to tools/base/dvlib.
-# The rule below uses the prebuilt dvlib.jar.
-#
-# If you want to run the tests, cd to tools/base/dvlib
-# and run ./gradlew :dvlib:test
-
-LOCAL_JAVA_RESOURCE_DIRS := src/main/resources
-
-LOCAL_MODULE := dvlib
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PREBUILT_JAVA_LIBRARIES := \
- ../../../prebuilts/devtools/tools/lib/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-
-include $(BUILD_HOST_PREBUILT)
-
-
diff --git a/draw9patch/.gitignore b/draw9patch/.gitignore
deleted file mode 100644
index ee936c7..0000000
--- a/draw9patch/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-*.iml
-out
-.idea
diff --git a/draw9patch/Android.mk b/draw9patch/Android.mk
deleted file mode 100644
index 444e582..0000000
--- a/draw9patch/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src/main/java)
-LOCAL_JAVA_RESOURCE_DIRS := src/main/resources
-
-LOCAL_JAR_MANIFEST := etc/manifest.txt
-
-LOCAL_MODULE := draw9patch
-LOCAL_MODULE_TAGS := debug
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-# Build all sub-directories
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/draw9patch/MODULE_LICENSE_APACHE2 b/draw9patch/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/draw9patch/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/draw9patch/NOTICE b/draw9patch/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/draw9patch/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/draw9patch/etc/Android.mk b/draw9patch/etc/Android.mk
deleted file mode 100644
index c2b1f78..0000000
--- a/draw9patch/etc/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_PREBUILT_EXECUTABLES := draw9patch
-LOCAL_MODULE_TAGS := debug
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/draw9patch/etc/draw9patch b/draw9patch/etc/draw9patch
deleted file mode 100755
index 5d272a6..0000000
--- a/draw9patch/etc/draw9patch
+++ /dev/null
@@ -1,63 +0,0 @@
-#!/bin/sh
-# Copyright 2008, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
- newProg=`/bin/ls -ld "${prog}"`
- newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
- if expr "x${newProg}" : 'x/' >/dev/null; then
- prog="${newProg}"
- else
- progdir=`dirname "${prog}"`
- prog="${progdir}/${newProg}"
- fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/`basename "${prog}"`
-cd "${oldwd}"
-
-jarfile=draw9patch.jar
-frameworkdir="$progdir"
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/tools/lib
- libdir=`dirname "$progdir"`/tools/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/framework
- libdir=`dirname "$progdir"`/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- echo `basename "$prog"`": can't find $jarfile"
- exit 1
-fi
-
-if [ "$OSTYPE" = "cygwin" ] ; then
- jarpath=`cygpath -w "$frameworkdir/$jarfile"`
- progdir=`cygpath -w "$progdir"`
-else
- jarpath="$frameworkdir/$jarfile"
-fi
-
-# need to use "java.ext.dirs" because "-jar" causes classpath to be ignored
-# might need more memory, e.g. -Xmx128M
-exec java -Djava.ext.dirs="$frameworkdir" -jar "$jarpath" "$@"
diff --git a/draw9patch/etc/draw9patch.bat b/draw9patch/etc/draw9patch.bat
deleted file mode 100755
index b6826fc..0000000
--- a/draw9patch/etc/draw9patch.bat
+++ /dev/null
@@ -1,46 +0,0 @@
-@echo off
-rem Copyright (C) 2008 The Android Open Source Project
-rem
-rem Licensed under the Apache License, Version 2.0 (the "License");
-rem you may not use this file except in compliance with the License.
-rem You may obtain a copy of the License at
-rem
-rem http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-
-rem don't modify the caller's environment
-setlocal
-
-rem Set up prog to be the path of this script, including following symlinks,
-rem and set up progdir to be the fully-qualified pathname of its directory.
-set prog=%~f0
-
-rem Change current directory and drive to where the script is, to avoid
-rem issues with directories containing whitespaces.
-cd /d %~dp0
-
-rem Check we have a valid Java.exe in the path.
-set java_exe=
-call lib\find_java.bat
-if not defined java_exe goto :EOF
-
-set jarfile=draw9patch.jar
-set frameworkdir=
-set libdir=
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=lib\
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=..\framework\
-
-:JarFileOk
-
-set jarpath=%frameworkdir%%jarfile%
-
-call %java_exe% -Djava.ext.dirs=%frameworkdir% -jar %jarpath% %*
diff --git a/draw9patch/etc/manifest.txt b/draw9patch/etc/manifest.txt
deleted file mode 100644
index 2616706..0000000
--- a/draw9patch/etc/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Main-Class: com.android.draw9patch.Application
diff --git a/draw9patch/src/main/java/com/android/draw9patch/Application.java b/draw9patch/src/main/java/com/android/draw9patch/Application.java
deleted file mode 100644
index 68c792a..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/Application.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.draw9patch;
-
-import com.android.draw9patch.ui.MainFrame;
-
-import javax.swing.SwingUtilities;
-import javax.swing.UIManager;
-import javax.swing.UnsupportedLookAndFeelException;
-
-public class Application {
- private static void initUserInterface() {
- System.setProperty("apple.laf.useScreenMenuBar", "true");
- System.setProperty("com.apple.mrj.application.apple.menu.about.name", "Draw 9-patch");
-
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch (ClassNotFoundException e) {
- e.printStackTrace();
- } catch (InstantiationException e) {
- e.printStackTrace();
- } catch (IllegalAccessException e) {
- e.printStackTrace();
- } catch (UnsupportedLookAndFeelException e) {
- e.printStackTrace();
- }
- }
-
- public static void main(final String... args) {
- initUserInterface();
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- String arg = args.length > 0 ? args[0] : null;
- MainFrame frame = new MainFrame(arg);
- frame.setDefaultCloseOperation(MainFrame.EXIT_ON_CLOSE);
- frame.setLocationRelativeTo(null);
- frame.setVisible(true);
- }
- });
- }
-}
diff --git a/draw9patch/src/main/java/com/android/draw9patch/graphics/GraphicsUtilities.java b/draw9patch/src/main/java/com/android/draw9patch/graphics/GraphicsUtilities.java
deleted file mode 100644
index c6c182c..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/graphics/GraphicsUtilities.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.draw9patch.graphics;
-
-import javax.imageio.ImageIO;
-import java.awt.image.BufferedImage;
-import java.awt.image.Raster;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsEnvironment;
-import java.awt.Graphics;
-import java.awt.Transparency;
-import java.net.URL;
-import java.io.IOException;
-
-public class GraphicsUtilities {
- public static BufferedImage loadCompatibleImage(URL resource) throws IOException {
- BufferedImage image = ImageIO.read(resource);
- return toCompatibleImage(image);
- }
-
- public static BufferedImage createCompatibleImage(int width, int height) {
- return getGraphicsConfiguration().createCompatibleImage(width, height);
- }
-
- public static BufferedImage toCompatibleImage(BufferedImage image) {
- if (isHeadless()) {
- return image;
- }
-
- if (image.getColorModel().equals(getGraphicsConfiguration().getColorModel())) {
- return image;
- }
-
- BufferedImage compatibleImage = getGraphicsConfiguration().createCompatibleImage(
- image.getWidth(), image.getHeight(), image.getTransparency());
- Graphics g = compatibleImage.getGraphics();
- g.drawImage(image, 0, 0, null);
- g.dispose();
-
- return compatibleImage;
- }
-
- public static BufferedImage createCompatibleImage(BufferedImage image, int width, int height) {
- return getGraphicsConfiguration().createCompatibleImage(width, height,
- image.getTransparency());
- }
-
- private static GraphicsConfiguration getGraphicsConfiguration() {
- GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
- return environment.getDefaultScreenDevice().getDefaultConfiguration();
- }
-
- private static boolean isHeadless() {
- return GraphicsEnvironment.isHeadless();
- }
-
- public static BufferedImage createTranslucentCompatibleImage(int width, int height) {
- return getGraphicsConfiguration().createCompatibleImage(width, height,
- Transparency.TRANSLUCENT);
- }
-
- public static int[] getPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) {
- if (w == 0 || h == 0) {
- return new int[0];
- }
-
- if (pixels == null) {
- pixels = new int[w * h];
- } else if (pixels.length < w * h) {
- throw new IllegalArgumentException("Pixels array must have a length >= w * h");
- }
-
- int imageType = img.getType();
- if (imageType == BufferedImage.TYPE_INT_ARGB || imageType == BufferedImage.TYPE_INT_RGB) {
- Raster raster = img.getRaster();
- return (int[]) raster.getDataElements(x, y, w, h, pixels);
- }
-
- // Unmanages the image
- return img.getRGB(x, y, w, h, pixels, 0, w);
- }
-}
diff --git a/draw9patch/src/main/java/com/android/draw9patch/ui/CorruptPatch.java b/draw9patch/src/main/java/com/android/draw9patch/ui/CorruptPatch.java
deleted file mode 100644
index 4f0763a..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/ui/CorruptPatch.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.draw9patch.ui;
-
-import com.android.draw9patch.graphics.GraphicsUtilities;
-
-import java.awt.Rectangle;
-import java.awt.image.BufferedImage;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-public class CorruptPatch {
- public static List<Rectangle> findBadPatches(BufferedImage image, PatchInfo patchInfo) {
- List<Rectangle> corruptedPatches = new ArrayList<Rectangle>();
-
- for (Rectangle patch : patchInfo.patches) {
- if (corruptPatch(image, patch)) {
- corruptedPatches.add(patch);
- }
- }
-
- for (Rectangle patch : patchInfo.horizontalPatches) {
- if (corruptHorizontalPatch(image, patch)) {
- corruptedPatches.add(patch);
- }
- }
-
- for (Rectangle patch : patchInfo.verticalPatches) {
- if (corruptVerticalPatch(image, patch)) {
- corruptedPatches.add(patch);
- }
- }
-
- return corruptedPatches;
- }
-
- private static boolean corruptPatch(BufferedImage image, Rectangle patch) {
- int[] pixels = GraphicsUtilities.getPixels(image, patch.x, patch.y,
- patch.width, patch.height, null);
-
- if (pixels.length > 0) {
- int reference = pixels[0];
- for (int pixel : pixels) {
- if (pixel != reference) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- private static boolean corruptHorizontalPatch(BufferedImage image, Rectangle patch) {
- int[] reference = new int[patch.height];
- int[] column = new int[patch.height];
- reference = GraphicsUtilities.getPixels(image, patch.x, patch.y,
- 1, patch.height, reference);
-
- for (int i = 1; i < patch.width; i++) {
- column = GraphicsUtilities.getPixels(image, patch.x + i, patch.y,
- 1, patch.height, column);
- if (!Arrays.equals(reference, column)) {
- return true;
- }
- }
-
- return false;
- }
-
- private static boolean corruptVerticalPatch(BufferedImage image, Rectangle patch) {
- int[] reference = new int[patch.width];
- int[] row = new int[patch.width];
- reference = GraphicsUtilities.getPixels(image, patch.x, patch.y,
- patch.width, 1, reference);
-
- for (int i = 1; i < patch.height; i++) {
- row = GraphicsUtilities.getPixels(image, patch.x, patch.y + i, patch.width, 1, row);
- if (!Arrays.equals(reference, row)) {
- return true;
- }
- }
-
- return false;
- }
-}
diff --git a/draw9patch/src/main/java/com/android/draw9patch/ui/GradientPanel.java b/draw9patch/src/main/java/com/android/draw9patch/ui/GradientPanel.java
deleted file mode 100644
index bc1465f..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/ui/GradientPanel.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.draw9patch.ui;
-
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.Paint;
-import java.awt.GradientPaint;
-import java.awt.Color;
-import java.awt.Rectangle;
-import java.awt.BorderLayout;
-import javax.swing.JPanel;
-
-class GradientPanel extends JPanel {
- private static final int DARK_BLUE = 0x202737;
-
- GradientPanel() {
- super(new BorderLayout());
- }
-
- @Override
- protected void paintComponent(Graphics g) {
- Graphics2D g2 = (Graphics2D) g;
- Rectangle clip = g2.getClipBounds();
- Paint paint = g2.getPaint();
-
- g2.setPaint(new GradientPaint(0.0f, getHeight() * 0.22f, new Color(DARK_BLUE),
- 0.0f, getHeight() * 0.9f, Color.BLACK));
- g2.fillRect(clip.x, clip.y, clip.width, clip.height);
-
- g2.setPaint(paint);
- }
-}
diff --git a/draw9patch/src/main/java/com/android/draw9patch/ui/ImageEditorPanel.java b/draw9patch/src/main/java/com/android/draw9patch/ui/ImageEditorPanel.java
deleted file mode 100644
index 3529542..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/ui/ImageEditorPanel.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.draw9patch.ui;
-
-import com.android.draw9patch.graphics.GraphicsUtilities;
-
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Graphics2D;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.TexturePaint;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.geom.Rectangle2D;
-import java.awt.image.BufferedImage;
-import java.awt.image.RenderedImage;
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-
-import javax.swing.Box;
-import javax.swing.JCheckBox;
-import javax.swing.JComponent;
-import javax.swing.JFileChooser;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JSlider;
-import javax.swing.JSplitPane;
-import javax.swing.event.AncestorEvent;
-import javax.swing.event.AncestorListener;
-import javax.swing.event.ChangeEvent;
-import javax.swing.event.ChangeListener;
-
-public class ImageEditorPanel extends JPanel {
- private static final String EXTENSION_9PATCH = ".9.png";
-
- private String name;
- private BufferedImage image;
- private boolean is9Patch;
-
- private ImageViewer viewer;
- private StretchesViewer stretchesViewer;
- private JLabel xLabel;
- private JLabel yLabel;
-
- private TexturePaint texture;
- private JSlider zoomSlider;
-
- public ImageEditorPanel(MainFrame mainFrame, BufferedImage image, String name) {
- this.image = image;
- this.name = name;
-
- if (mainFrame != null) {
- setTransferHandler(new ImageTransferHandler(mainFrame));
- }
-
- setOpaque(false);
- setLayout(new BorderLayout());
-
- loadSupport();
- buildImageViewer();
- buildStatusPanel();
-
- checkImage();
-
- addAncestorListener(new AncestorListener() {
- @Override
- public void ancestorAdded(AncestorEvent event) {
- }
-
- @Override
- public void ancestorRemoved(AncestorEvent event) {
- }
-
- @Override
- public void ancestorMoved(AncestorEvent event) {
- // allow the image viewer to set the optimal zoom level and ensure that the
- // zoom slider's setting is in sync with the image viewer's zoom
- removeAncestorListener(this);
- synchronizeImageViewerZoomLevel();
- }
- });
- }
-
- private void synchronizeImageViewerZoomLevel() {
- zoomSlider.setValue(viewer.getZoom());
- }
-
- public ImageViewer getViewer() {
- return viewer;
- }
-
- private void loadSupport() {
- try {
- URL resource = getClass().getResource("/images/checker.png");
- BufferedImage checker = GraphicsUtilities.loadCompatibleImage(resource);
- texture = new TexturePaint(checker, new Rectangle2D.Double(0, 0,
- checker.getWidth(), checker.getHeight()));
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- private void buildImageViewer() {
- viewer = new ImageViewer(this, texture, image, new ImageViewer.StatusBar() {
- @Override
- public void setPointerLocation(int x, int y) {
- xLabel.setText(x + " px");
- yLabel.setText(y + " px");
- }
- });
-
- JSplitPane splitter = new JSplitPane();
- splitter.setContinuousLayout(true);
- splitter.setResizeWeight(0.8);
- splitter.setBorder(null);
-
- JScrollPane scroller = new JScrollPane(viewer);
- scroller.setOpaque(false);
- scroller.setBorder(null);
- scroller.getViewport().setBorder(null);
- scroller.getViewport().setOpaque(false);
-
- splitter.setLeftComponent(scroller);
- splitter.setRightComponent(buildStretchesViewer());
-
- add(splitter);
- }
-
- private JComponent buildStretchesViewer() {
- stretchesViewer = new StretchesViewer(this, viewer, texture);
- JScrollPane scroller = new JScrollPane(stretchesViewer);
- scroller.setBorder(null);
- scroller.getViewport().setBorder(null);
- scroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
- scroller.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
- return scroller;
- }
-
- private void buildStatusPanel() {
- JPanel status = new JPanel(new GridBagLayout());
- status.setOpaque(false);
-
- JLabel label = new JLabel();
- label.setForeground(Color.WHITE);
- label.setText("Zoom: ");
- label.putClientProperty("JComponent.sizeVariant", "small");
- status.add(label, new GridBagConstraints(0, 0, 1, 1, 0.0f, 0.0f,
- GridBagConstraints.LINE_END, GridBagConstraints.NONE,
- new Insets(0, 6, 0, 0), 0, 0));
-
- label = new JLabel();
- label.setForeground(Color.WHITE);
- label.setText("100%");
- label.putClientProperty("JComponent.sizeVariant", "small");
- status.add(label, new GridBagConstraints(1, 0, 1, 1, 0.0f, 0.0f,
- GridBagConstraints.LINE_END, GridBagConstraints.NONE,
- new Insets(0, 0, 0, 0), 0, 0));
-
- zoomSlider = new JSlider(ImageViewer.MIN_ZOOM, ImageViewer.MAX_ZOOM,
- ImageViewer.DEFAULT_ZOOM);
- zoomSlider.setSnapToTicks(true);
- zoomSlider.putClientProperty("JComponent.sizeVariant", "small");
- zoomSlider.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent evt) {
- viewer.setZoom(((JSlider) evt.getSource()).getValue());
- }
- });
- status.add(zoomSlider, new GridBagConstraints(2, 0, 1, 1, 0.0f, 0.0f,
- GridBagConstraints.LINE_START, GridBagConstraints.NONE,
- new Insets(0, 0, 0, 0), 0, 0));
-
- JLabel maxZoomLabel = new JLabel();
- maxZoomLabel.setForeground(Color.WHITE);
- maxZoomLabel.putClientProperty("JComponent.sizeVariant", "small");
- maxZoomLabel.setText("800%");
- status.add(maxZoomLabel, new GridBagConstraints(3, 0, 1, 1, 0.0f, 0.0f,
- GridBagConstraints.LINE_START, GridBagConstraints.NONE,
- new Insets(0, 0, 0, 0), 0, 0));
-
- label = new JLabel();
- label.setForeground(Color.WHITE);
- label.setText("Patch scale: ");
- label.putClientProperty("JComponent.sizeVariant", "small");
- status.add(label, new GridBagConstraints(0, 1, 1, 1, 0.0f, 0.0f,
- GridBagConstraints.LINE_START, GridBagConstraints.NONE,
- new Insets(0, 6, 0, 0), 0, 0));
-
- label = new JLabel();
- label.setForeground(Color.WHITE);
- label.setText("2x");
- label.putClientProperty("JComponent.sizeVariant", "small");
- status.add(label, new GridBagConstraints(1, 1, 1, 1, 0.0f, 0.0f,
- GridBagConstraints.LINE_END, GridBagConstraints.NONE,
- new Insets(0, 0, 0, 0), 0, 0));
-
- JSlider jSlider = new JSlider(200, 600, (int) (StretchesViewer.DEFAULT_SCALE * 100.0f));
- jSlider.setSnapToTicks(true);
- jSlider.putClientProperty("JComponent.sizeVariant", "small");
- jSlider.addChangeListener(new ChangeListener() {
- public void stateChanged(ChangeEvent evt) {
- stretchesViewer.setScale(((JSlider) evt.getSource()).getValue() / 100.0f);
- }
- });
- status.add(jSlider, new GridBagConstraints(2, 1, 1, 1, 0.0f, 0.0f,
- GridBagConstraints.LINE_START, GridBagConstraints.NONE,
- new Insets(0, 0, 0, 0), 0, 0));
-
- maxZoomLabel = new JLabel();
- maxZoomLabel.setForeground(Color.WHITE);
- maxZoomLabel.putClientProperty("JComponent.sizeVariant", "small");
- maxZoomLabel.setText("6x");
- status.add(maxZoomLabel, new GridBagConstraints(3, 1, 1, 1, 0.0f, 0.0f,
- GridBagConstraints.LINE_START, GridBagConstraints.NONE,
- new Insets(0, 0, 0, 0), 0, 0));
-
- JCheckBox showLock = new JCheckBox("Show lock");
- showLock.setOpaque(false);
- showLock.setForeground(Color.WHITE);
- showLock.setSelected(false);
- showLock.putClientProperty("JComponent.sizeVariant", "small");
- showLock.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- viewer.setLockVisible(((JCheckBox) event.getSource()).isSelected());
- }
- });
- status.add(showLock, new GridBagConstraints(4, 0, 1, 1, 0.0f, 0.0f,
- GridBagConstraints.LINE_START, GridBagConstraints.NONE,
- new Insets(0, 12, 0, 0), 0, 0));
-
- JCheckBox showPatches = new JCheckBox("Show patches");
- showPatches.setOpaque(false);
- showPatches.setForeground(Color.WHITE);
- showPatches.putClientProperty("JComponent.sizeVariant", "small");
- showPatches.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- viewer.setPatchesVisible(((JCheckBox) event.getSource()).isSelected());
- }
- });
- status.add(showPatches, new GridBagConstraints(4, 1, 1, 1, 0.0f, 0.0f,
- GridBagConstraints.LINE_START, GridBagConstraints.NONE,
- new Insets(0, 12, 0, 0), 0, 0));
-
- JCheckBox showPadding = new JCheckBox("Show content");
- showPadding.setOpaque(false);
- showPadding.setForeground(Color.WHITE);
- showPadding.putClientProperty("JComponent.sizeVariant", "small");
- showPadding.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- stretchesViewer.setPaddingVisible(((JCheckBox) event.getSource()).isSelected());
- }
- });
- status.add(showPadding, new GridBagConstraints(5, 0, 1, 1, 0.0f, 0.0f,
- GridBagConstraints.LINE_START, GridBagConstraints.NONE,
- new Insets(0, 12, 0, 0), 0, 0));
-
- status.add(Box.createHorizontalGlue(), new GridBagConstraints(6, 0, 1, 1, 1.0f, 1.0f,
- GridBagConstraints.LINE_START, GridBagConstraints.BOTH,
- new Insets(0, 0, 0, 0), 0, 0));
-
- label = new JLabel("X: ");
- label.setForeground(Color.WHITE);
- label.putClientProperty("JComponent.sizeVariant", "small");
- status.add(label, new GridBagConstraints(7, 0, 1, 1, 0.0f, 0.0f,
- GridBagConstraints.LINE_END, GridBagConstraints.NONE,
- new Insets(0, 0, 0, 0), 0, 0));
-
- xLabel = new JLabel("0px");
- xLabel.setForeground(Color.WHITE);
- xLabel.putClientProperty("JComponent.sizeVariant", "small");
- status.add(xLabel, new GridBagConstraints(8, 0, 1, 1, 0.0f, 0.0f,
- GridBagConstraints.LINE_END, GridBagConstraints.NONE,
- new Insets(0, 0, 0, 6), 0, 0));
-
- label = new JLabel("Y: ");
- label.setForeground(Color.WHITE);
- label.putClientProperty("JComponent.sizeVariant", "small");
- status.add(label, new GridBagConstraints(7, 1, 1, 1, 0.0f, 0.0f,
- GridBagConstraints.LINE_END, GridBagConstraints.NONE,
- new Insets(0, 0, 0, 0), 0, 0));
-
- yLabel = new JLabel("0px");
- yLabel.setForeground(Color.WHITE);
- yLabel.putClientProperty("JComponent.sizeVariant", "small");
- status.add(yLabel, new GridBagConstraints(8, 1, 1, 1, 0.0f, 0.0f,
- GridBagConstraints.LINE_END, GridBagConstraints.NONE,
- new Insets(0, 0, 0, 6), 0, 0));
-
- add(status, BorderLayout.SOUTH);
- }
-
- private void checkImage() {
- is9Patch = name.endsWith(EXTENSION_9PATCH);
- if (!is9Patch) {
- convertTo9Patch();
- } else {
- ensure9Patch();
- }
- }
-
- private void ensure9Patch() {
- int width = image.getWidth();
- int height = image.getHeight();
- for (int i = 0; i < width; i++) {
- int pixel = image.getRGB(i, 0);
- if (pixel != 0 && pixel != PatchInfo.BLACK_TICK && pixel != PatchInfo.RED_TICK) {
- image.setRGB(i, 0, 0);
- }
- pixel = image.getRGB(i, height - 1);
- if (pixel != 0 && pixel != PatchInfo.BLACK_TICK && pixel != PatchInfo.RED_TICK) {
- image.setRGB(i, height - 1, 0);
- }
- }
- for (int i = 0; i < height; i++) {
- int pixel = image.getRGB(0, i);
- if (pixel != 0 && pixel != PatchInfo.BLACK_TICK && pixel != PatchInfo.RED_TICK) {
- image.setRGB(0, i, 0);
- }
- pixel = image.getRGB(width - 1, i);
- if (pixel != 0 && pixel != PatchInfo.BLACK_TICK && pixel != PatchInfo.RED_TICK) {
- image.setRGB(width - 1, i, 0);
- }
- }
- }
-
- private void convertTo9Patch() {
- BufferedImage buffer = GraphicsUtilities.createTranslucentCompatibleImage(
- image.getWidth() + 2, image.getHeight() + 2);
-
- Graphics2D g2 = buffer.createGraphics();
- g2.drawImage(image, 1, 1, null);
- g2.dispose();
-
- image = buffer;
- viewer.setImage(image);
- name = name.substring(0, name.lastIndexOf('.')) + ".9.png";
- }
-
- File chooseSaveFile() {
- if (is9Patch) {
- return new File(name);
- } else {
- JFileChooser chooser = new JFileChooser(
- name.substring(0, name.lastIndexOf(File.separatorChar)));
- chooser.setFileFilter(new PngFileFilter());
- int choice = chooser.showSaveDialog(this);
- if (choice == JFileChooser.APPROVE_OPTION) {
- File file = chooser.getSelectedFile();
- if (!file.getAbsolutePath().endsWith(EXTENSION_9PATCH)) {
- String path = file.getAbsolutePath();
- if (path.endsWith(".png")) {
- path = path.substring(0, path.lastIndexOf(".png")) + EXTENSION_9PATCH;
- } else {
- path = path + EXTENSION_9PATCH;
- }
- name = path;
- is9Patch = true;
- return new File(path);
- }
- is9Patch = true;
- return file;
- }
- }
- return null;
- }
-
- RenderedImage getImage() {
- return image;
- }
-}
diff --git a/draw9patch/src/main/java/com/android/draw9patch/ui/ImageTransferHandler.java b/draw9patch/src/main/java/com/android/draw9patch/ui/ImageTransferHandler.java
deleted file mode 100644
index bb1cdb3..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/ui/ImageTransferHandler.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.draw9patch.ui;
-
-import javax.swing.TransferHandler;
-import javax.swing.JComponent;
-import java.awt.datatransfer.Transferable;
-import java.awt.datatransfer.DataFlavor;
-import java.awt.datatransfer.UnsupportedFlavorException;
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-import java.net.MalformedURLException;
-
-class ImageTransferHandler extends TransferHandler {
- private final MainFrame mainFrame;
-
- ImageTransferHandler(MainFrame mainFrame) {
- this.mainFrame = mainFrame;
- }
-
- @Override
- public boolean importData(JComponent component, Transferable transferable) {
- try {
- for (DataFlavor flavor : transferable.getTransferDataFlavors()) {
- if (flavor.isFlavorJavaFileListType()) {
- Object data = transferable.getTransferData(DataFlavor.javaFileListFlavor);
- //noinspection unchecked
- final File file = ((List<File>) data).get(0);
- mainFrame.open(file).execute();
- return true;
- } else if (flavor.isFlavorTextType()) {
- if (flavor.getRepresentationClass() == String.class) {
- String mime = flavor.getMimeType();
- DataFlavor flave = new DataFlavor(mime);
- Object data = transferable.getTransferData(flave);
- final String path = convertPath(data.toString());
- mainFrame.open(new File(path)).execute();
- return true;
- }
- }
- }
- } catch (UnsupportedFlavorException e) {
- // Ignore
- } catch (MalformedURLException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return false;
- }
-
- private static String convertPath(String path) {
- if (path.startsWith("file://")) path = path.substring("file://".length());
- if (path.indexOf('\n') != -1) path = path.substring(0, path.indexOf('\n'));
- if (path.indexOf('\r') != -1) path = path.substring(0, path.indexOf('\r'));
- return path;
- }
-
- @Override
- public boolean canImport(TransferSupport support) {
- boolean isCopySupported
- = (COPY & support.getSourceDropActions()) == COPY;
- if (!isCopySupported) {
- return false;
- }
- for (DataFlavor flavor : support.getDataFlavors()) {
- if (flavor.isFlavorJavaFileListType() || flavor.isFlavorTextType()) {
- support.setDropAction(COPY);
- return true;
- }
- }
- return false;
- }
-}
diff --git a/draw9patch/src/main/java/com/android/draw9patch/ui/ImageViewer.java b/draw9patch/src/main/java/com/android/draw9patch/ui/ImageViewer.java
deleted file mode 100644
index 58b20b7..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/ui/ImageViewer.java
+++ /dev/null
@@ -1,1190 +0,0 @@
-/*
- *
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.android.draw9patch.ui;
-
-import java.awt.AWTEvent;
-import java.awt.BasicStroke;
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Container;
-import java.awt.Cursor;
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.Point;
-import java.awt.Rectangle;
-import java.awt.RenderingHints;
-import java.awt.Shape;
-import java.awt.TexturePaint;
-import java.awt.Toolkit;
-import java.awt.event.AWTEventListener;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.ComponentAdapter;
-import java.awt.event.ComponentEvent;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.event.MouseMotionAdapter;
-import java.awt.geom.Area;
-import java.awt.geom.Line2D;
-import java.awt.geom.RoundRectangle2D;
-import java.awt.image.BufferedImage;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.swing.JButton;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.border.EmptyBorder;
-import javax.swing.event.AncestorEvent;
-import javax.swing.event.AncestorListener;
-
-public class ImageViewer extends JComponent {
- private final Color CORRUPTED_COLOR = new Color(1.0f, 0.0f, 0.0f, 0.7f);
- private final Color LOCK_COLOR = new Color(0.0f, 0.0f, 0.0f, 0.7f);
- private final Color STRIPES_COLOR = new Color(1.0f, 0.0f, 0.0f, 0.5f);
- private final Color BACK_COLOR = new Color(0xc0c0c0);
- private final Color HELP_COLOR = new Color(0xffffe1);
- private final Color PATCH_COLOR = new Color(1.0f, 0.37f, 0.99f, 0.5f);
- private final Color PATCH_ONEWAY_COLOR = new Color(0.37f, 1.0f, 0.37f, 0.5f);
- private final Color HIGHLIGHT_REGION_COLOR = new Color(0.5f, 0.5f, 0.5f, 0.5f);
-
- private static final float STRIPES_WIDTH = 4.0f;
- private static final double STRIPES_SPACING = 6.0;
- private static final int STRIPES_ANGLE = 45;
-
- /** The fraction of the window size that the 9patch should occupy. */
- private static final float IDEAL_IMAGE_FRACTION_OF_WINDOW = 0.7f;
-
- /** Default zoom level for the 9patch image. */
- public static final int DEFAULT_ZOOM = 8;
-
- /** Minimum zoom level for the 9patch image. */
- public static final int MIN_ZOOM = 1;
-
- /** Maximum zoom level for the 9patch image. */
- public static final int MAX_ZOOM = 16;
-
- /** Current 9patch zoom level, {@link #MIN_ZOOM} <= zoom <= {@link #MAX_ZOOM} */
- private int zoom = DEFAULT_ZOOM;
- private boolean showPatches;
- private boolean showLock = false;
-
- private final TexturePaint texture;
- private final Container container;
- private final StatusBar statusBar;
-
- private final Dimension size;
-
- private boolean locked;
-
- private int lastPositionX;
- private int lastPositionY;
- private boolean showCursor;
-
- private JLabel helpLabel;
- private boolean eraseMode;
-
- private JButton checkButton;
- private List<Rectangle> corruptedPatches;
- private boolean showBadPatches;
-
- private JPanel helpPanel;
- private boolean drawingLine;
- private int lineFromX;
- private int lineFromY;
- private int lineToX;
- private int lineToY;
- private boolean showDrawingLine;
-
- private final List<Rectangle> hoverHighlightRegions = new ArrayList<Rectangle>();
- private String toolTipText;
-
- /**
- * Indicates whether we are currently in edit mode.
- * All fields with the prefix 'edit' are valid only when in edit mode.
- */
- private boolean isEditMode;
-
- /** Region being edited. */
- private UpdateRegion editRegion;
-
- /**
- * The start and end points corresponding to the region being edited.
- * During an edit sequence, the start point is constant and the end varies based on the
- * mouse location.
- */
- private final Pair<Integer> editSegment = new Pair<Integer>(0, 0);
-
- /** Regions to highlight based on the current edit. */
- private final List<Rectangle> editHighlightRegions = new ArrayList<Rectangle>();
-
- /** The actual patch location in the image being edited. */
- private Rectangle editPatchRegion = new Rectangle();
-
- private BufferedImage image;
- private PatchInfo patchInfo;
-
- /** The types of edit actions that can be performed on the image. */
- private enum DrawMode {
- PATCH, // drawing a patch or a padding
- LAYOUT_BOUND, // drawing layout bounds
- ERASE, // erasing whatever has been drawn
- }
-
- /**
- * Current drawing mode. The mode is changed by using either the Shift or Ctrl keys while
- * drawing.
- */
- private DrawMode currentMode = DrawMode.PATCH;
-
- ImageViewer(Container container, TexturePaint texture, BufferedImage image,
- StatusBar statusBar) {
- this.container = container;
- this.texture = texture;
- this.image = image;
- this.statusBar = statusBar;
-
- setLayout(new GridBagLayout());
- helpPanel = new JPanel(new BorderLayout());
- helpPanel.setBorder(new EmptyBorder(0, 6, 0, 6));
- helpPanel.setBackground(HELP_COLOR);
- helpLabel = new JLabel("Press Shift to erase pixels."
- + " Press Control to draw layout bounds");
- helpLabel.putClientProperty("JComponent.sizeVariant", "small");
- helpPanel.add(helpLabel, BorderLayout.WEST);
- checkButton = new JButton("Show bad patches");
- checkButton.putClientProperty("JComponent.sizeVariant", "small");
- checkButton.putClientProperty("JButton.buttonType", "roundRect");
- helpPanel.add(checkButton, BorderLayout.EAST);
-
- add(helpPanel, new GridBagConstraints(0, 0, 1, 1,
- 1.0f, 1.0f, GridBagConstraints.FIRST_LINE_START, GridBagConstraints.HORIZONTAL,
- new Insets(0, 0, 0, 0), 0, 0));
-
- setOpaque(true);
-
- // Exact size will be set by setZoom() in AncestorListener#ancestorMoved.
- size = new Dimension(0, 0);
-
- addAncestorListener(new AncestorListener() {
- @Override
- public void ancestorRemoved(AncestorEvent event) {
- }
- @Override
- public void ancestorMoved(AncestorEvent event) {
- removeAncestorListener(this);
- setDefaultZoom();
- }
- @Override
- public void ancestorAdded(AncestorEvent event) {
- }
- });
-
- updatePatchInfo();
-
- addMouseListener(new MouseAdapter() {
- @Override
- public void mousePressed(MouseEvent event) {
- // Update the drawing mode looking at the current state of modifier (shift/ctrl)
- // keys. This is done here instead of retrieving it again in MouseDragged
- // below, because on linux, calling MouseEvent.getButton() for the drag
- // event returns 0, which appears to be technically correct (no button
- // changed state).
- updateDrawMode(event);
-
- int x = imageXCoordinate(event.getX());
- int y = imageYCoordinate(event.getY());
-
- startDrawingLine(x, y);
-
- if (currentMode == DrawMode.PATCH) {
- startEditingRegion(x, y);
- } else {
- hoverHighlightRegions.clear();
- setCursor(Cursor.getDefaultCursor());
- repaint();
- }
- }
-
- @Override
- public void mouseReleased(MouseEvent event) {
- int x = imageXCoordinate(event.getX());
- int y = imageYCoordinate(event.getY());
-
- endDrawingLine();
- endEditingRegion(x, y);
-
- resetDrawMode();
- }
- });
- addMouseMotionListener(new MouseMotionAdapter() {
- @Override
- public void mouseDragged(MouseEvent event) {
- int x = imageXCoordinate(event.getX());
- int y = imageYCoordinate(event.getY());
-
- if (!checkLockedRegion(x, y)) {
- // use the stored button, see note above
- moveLine(x, y);
- }
-
- updateEditRegion(x, y);
- }
-
- @Override
- public void mouseMoved(MouseEvent event) {
- int x = imageXCoordinate(event.getX());
- int y = imageYCoordinate(event.getY());
-
- checkLockedRegion(x, y);
-
- updateHoverRegion(x, y);
- repaint();
- }
- });
-
- addComponentListener(new ComponentAdapter() {
- @Override
- public void componentResized(ComponentEvent e) {
- hoverHighlightRegions.clear();
- updateSize();
- repaint();
- }
- });
-
- Toolkit.getDefaultToolkit().addAWTEventListener(new AWTEventListener() {
- public void eventDispatched(AWTEvent event) {
- enableEraseMode((KeyEvent) event);
- }
- }, AWTEvent.KEY_EVENT_MASK);
-
- checkButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent event) {
- if (!showBadPatches) {
- corruptedPatches = CorruptPatch.findBadPatches(ImageViewer.this.image,
- patchInfo);
- checkButton.setText("Hide bad patches");
- } else {
- checkButton.setText("Show bad patches");
- corruptedPatches = null;
- }
- repaint();
- showBadPatches = !showBadPatches;
- }
- });
- }
-
- private void updateDrawMode(MouseEvent event) {
- if (event.isShiftDown()) {
- currentMode = DrawMode.ERASE;
- } else if (event.isControlDown()) {
- currentMode = DrawMode.LAYOUT_BOUND;
- } else {
- currentMode = DrawMode.PATCH;
- }
- }
-
- private void resetDrawMode() {
- currentMode = DrawMode.PATCH;
- }
-
- private enum UpdateRegion {
- LEFT_PATCH,
- TOP_PATCH,
- RIGHT_PADDING,
- BOTTOM_PADDING,
- }
-
- private static class UpdateRegionInfo {
- public final UpdateRegion region;
- public final Pair<Integer> segment;
-
- private UpdateRegionInfo(UpdateRegion region, Pair<Integer> segment) {
- this.region = region;
- this.segment = segment;
- }
- }
-
- private UpdateRegionInfo findVerticalPatch(int x, int y) {
- List<Pair<Integer>> markers;
- UpdateRegion region;
-
- // Given the mouse x location, we need to determine if we need to map this edit to
- // the patch info at the left, or the padding info at the right. We make this decision
- // based on whichever is closer, so if the mouse x is in the left half of the image,
- // we are editing the left patch, else the right padding.
- if (x < image.getWidth() / 2) {
- markers = patchInfo.verticalPatchMarkers;
- region = UpdateRegion.LEFT_PATCH;
- } else {
- markers = patchInfo.verticalPaddingMarkers;
- region = UpdateRegion.RIGHT_PADDING;
- }
-
- return getContainingPatch(markers, y, region);
- }
-
- private UpdateRegionInfo findHorizontalPatch(int x, int y) {
- List<Pair<Integer>> markers;
- UpdateRegion region;
-
- if (y < image.getHeight() / 2) {
- markers = patchInfo.horizontalPatchMarkers;
- region = UpdateRegion.TOP_PATCH;
- } else {
- markers = patchInfo.horizontalPaddingMarkers;
- region = UpdateRegion.BOTTOM_PADDING;
- }
-
- return getContainingPatch(markers, x, region);
- }
-
- private UpdateRegionInfo getContainingPatch(List<Pair<Integer>> patches, int a,
- UpdateRegion region) {
- for (Pair<Integer> p: patches) {
- if (p.first <= a && p.second > a) {
- return new UpdateRegionInfo(region, p);
- }
-
- if (p.first > a) {
- break;
- }
- }
-
- return new UpdateRegionInfo(region, null);
- }
-
- private void updateHoverRegion(int x, int y) {
- // find regions to highlight based on the horizontal and vertical patches that
- // cover this (x, y)
- UpdateRegionInfo vertical = findVerticalPatch(x, y);
- UpdateRegionInfo horizontal = findHorizontalPatch(x, y);
- computeHoverHighlightRegions(vertical, horizontal);
- computeHoverRegionTooltip(vertical, horizontal);
-
- // change cursor if (x,y) is at the edge of either of the regions
- UpdateRegionInfo updateRegion = pickUpdateRegion(x, y, vertical, horizontal);
- setCursorForRegion(x, y, updateRegion);
- }
-
- private void startEditingRegion(int x, int y) {
- hoverHighlightRegions.clear();
- isEditMode = false;
- editRegion = null;
-
- UpdateRegionInfo vertical = findVerticalPatch(x, y);
- UpdateRegionInfo horizontal = findHorizontalPatch(x, y);
- UpdateRegionInfo updateRegion = pickUpdateRegion(x, y, vertical, horizontal);
- setCursorForRegion(x, y, updateRegion);
-
- if (updateRegion != null) { // edit an existing patch
- editRegion = updateRegion.region;
- isEditMode = true;
-
- Edge e = null;
- switch (this.editRegion) {
- case LEFT_PATCH:
- case RIGHT_PADDING:
- e = getClosestEdge(y, updateRegion.segment);
- break;
- case TOP_PATCH:
- case BOTTOM_PADDING:
- e = getClosestEdge(x, updateRegion.segment);
- break;
- default:
- assert false : this.editRegion;
- }
-
- int first = updateRegion.segment.first;
- int second = updateRegion.segment.second;
-
- // The edge being edited should always be the end point in editSegment.
- boolean start = e == Edge.START;
- editSegment.first = start ? second : first;
- editSegment.second = start ? first : second;
-
- // clear the current patch data
- flushEditPatchData(0);
- } else if ((editRegion = findNewPatchRegion(x, y)) != null) { // create a new patch
- isEditMode = true;
-
- boolean verticalPatch = editRegion == UpdateRegion.LEFT_PATCH
- || editRegion == UpdateRegion.RIGHT_PADDING;
-
- x = clamp(x, 1, image.getWidth() - 1);
- y = clamp(y, 1, image.getHeight() - 1);
-
- editSegment.first = editSegment.second = verticalPatch ? y : x;
- }
-
- if (isEditMode) {
- computeEditHighlightRegions();
- }
-
- repaint();
- }
-
- private void endEditingRegion(int x, int y) {
- if (!isEditMode) {
- return;
- }
-
- x = clamp(x, 1, image.getWidth() - 1);
- y = clamp(y, 1, image.getHeight() - 1);
-
- switch (editRegion) {
- case LEFT_PATCH:
- case RIGHT_PADDING:
- editSegment.second = y;
- break;
- case TOP_PATCH:
- case BOTTOM_PADDING:
- editSegment.second = x;
- break;
- default:
- assert false : editRegion;
- }
-
- flushEditPatchData(PatchInfo.BLACK_TICK);
-
- hoverHighlightRegions.clear();
- setCursor(Cursor.getDefaultCursor());
- patchesChanged();
- repaint();
-
- isEditMode = false;
- editRegion = null;
- }
-
- private void updateEditRegion(int x, int y) {
- if (!isEditMode) {
- return;
- }
-
- x = clamp(x, 1, image.getWidth() - 1);
- y = clamp(y, 1, image.getHeight() - 1);
-
- switch (editRegion) {
- case LEFT_PATCH:
- case RIGHT_PADDING:
- editSegment.second = y;
- break;
- case TOP_PATCH:
- case BOTTOM_PADDING:
- editSegment.second = x;
- break;
- }
-
- computeEditHighlightRegions();
- repaint();
- }
-
- private int clamp(int i, int min, int max) {
- if (i < min) {
- return min;
- }
-
- if (i > max) {
- return max;
- }
-
- return i;
- }
-
- /** Returns the type of patch that should be created given the initial mouse location. */
- private UpdateRegion findNewPatchRegion(int x, int y) {
- boolean verticalPatch = y >= 0 && y <= image.getHeight();
- boolean horizontalPatch = x >= 0 && x <= image.getWidth();
-
- // Heuristic: If the pointer is within the vertical bounds of the image,
- // then we create a patch on the left or right depending on which side of the image
- // the pointer is on
- if (verticalPatch) {
- if (x < 0) {
- return UpdateRegion.LEFT_PATCH;
- } else if (x > image.getWidth()) {
- return UpdateRegion.RIGHT_PADDING;
- }
- }
-
- // Similarly, if it is within the horizontal bounds of the image,
- // then create a patch at the top or bottom depending on its location relative to the image
- if (horizontalPatch) {
- if (y < 0) {
- return UpdateRegion.TOP_PATCH;
- } else if (y > image.getHeight()) {
- return UpdateRegion.BOTTOM_PADDING;
- }
- }
-
- return null;
- }
-
- private void computeHoverHighlightRegions(UpdateRegionInfo vertical,
- UpdateRegionInfo horizontal) {
- hoverHighlightRegions.clear();
- if (vertical != null && vertical.segment != null) {
- hoverHighlightRegions.addAll(
- getHorizontalHighlightRegions(0,
- vertical.segment.first,
- image.getWidth(),
- vertical.segment.second - vertical.segment.first));
- }
- if (horizontal != null && horizontal.segment != null) {
- hoverHighlightRegions.addAll(
- getVerticalHighlightRegions(horizontal.segment.first,
- 0,
- horizontal.segment.second - horizontal.segment.first,
- image.getHeight()));
- }
- }
-
- private void computeHoverRegionTooltip(UpdateRegionInfo vertical, UpdateRegionInfo horizontal) {
- StringBuilder sb = new StringBuilder(50);
-
- if (vertical != null && vertical.segment != null) {
- if (vertical.region == UpdateRegion.LEFT_PATCH) {
- sb.append("Vertical Patch: ");
- } else {
- sb.append("Vertical Padding: ");
- }
- sb.append(String.format("%d - %d px",
- vertical.segment.first, vertical.segment.second));
- }
-
- if (horizontal != null && horizontal.segment != null) {
- if (sb.length() > 0) {
- sb.append(", ");
- }
- if (horizontal.region == UpdateRegion.TOP_PATCH) {
- sb.append("Horizontal Patch: ");
- } else {
- sb.append("Horizontal Padding: ");
- }
- sb.append(String.format("%d - %d px",
- horizontal.segment.first, horizontal.segment.second));
- }
-
- toolTipText = sb.length() > 0 ? sb.toString() : null;
- }
-
- private void computeEditHighlightRegions() {
- editHighlightRegions.clear();
-
- int f = editSegment.first;
- int s = editSegment.second;
- int min = Math.min(f, s);
- int diff = Math.abs(f - s);
-
- int imageWidth = image.getWidth();
- int imageHeight = image.getHeight();
-
- switch (editRegion) {
- case LEFT_PATCH:
- editPatchRegion = displayCoordinates(new Rectangle(0, min, 1, diff));
- editHighlightRegions.addAll(
- getHorizontalHighlightRegions(0, min, imageWidth, diff));
- break;
- case RIGHT_PADDING:
- editPatchRegion = displayCoordinates(new Rectangle(imageWidth - 1, min, 1, diff));
- editHighlightRegions.addAll(
- getHorizontalHighlightRegions(0, min, imageWidth, diff));
- break;
- case TOP_PATCH:
- editPatchRegion = displayCoordinates(new Rectangle(min, 0, diff, 1));
- editHighlightRegions.addAll(
- getVerticalHighlightRegions(min, 0, diff, imageHeight));
- break;
- case BOTTOM_PADDING:
- editPatchRegion = displayCoordinates(new Rectangle(min, imageHeight - 1, diff, 1));
- editHighlightRegions.addAll(
- getVerticalHighlightRegions(min, 0, diff, imageHeight));
- default:
- assert false : editRegion;
- }
- }
-
- private List<Rectangle> getHorizontalHighlightRegions(int x, int y, int w, int h) {
- List<Rectangle> l = new ArrayList<Rectangle>(3);
-
- // highlight the region within the image
- Rectangle r = displayCoordinates(new Rectangle(x, y, w, h));
- l.add(r);
-
- // add a 1 pixel line at the top and bottom that extends outside the image
- l.add(new Rectangle(0, r.y, getWidth(), 1));
- l.add(new Rectangle(0, r.y + r.height, getWidth(), 1));
- return l;
- }
-
- private List<Rectangle> getVerticalHighlightRegions(int x, int y, int w, int h) {
- List<Rectangle> l = new ArrayList<Rectangle>(3);
-
-
- // highlight the region within the image
- Rectangle r = displayCoordinates(new Rectangle(x, y, w, h));
- l.add(r);
-
- // add a 1 pixel line at the top and bottom that extends outside the image
- l.add(new Rectangle(r.x, 0, 1, getHeight()));
- l.add(new Rectangle(r.x + r.width, 0, 1, getHeight()));
-
- return l;
- }
-
- private void setCursorForRegion(int x, int y, UpdateRegionInfo region) {
- if (region != null) {
- Cursor c = getCursor(x, y, region);
- setCursor(c);
- } else {
- setCursor(Cursor.getDefaultCursor());
- }
- }
-
- private Cursor getCursor(int x, int y, UpdateRegionInfo editRegion) {
- Edge e;
- int cursor = Cursor.DEFAULT_CURSOR;
- switch (editRegion.region) {
- case LEFT_PATCH:
- case RIGHT_PADDING:
- e = getClosestEdge(y, editRegion.segment);
- cursor = (e == Edge.START) ? Cursor.N_RESIZE_CURSOR : Cursor.S_RESIZE_CURSOR;
- break;
- case TOP_PATCH:
- case BOTTOM_PADDING:
- e = getClosestEdge(x, editRegion.segment);
- cursor = (e == Edge.START) ? Cursor.W_RESIZE_CURSOR : Cursor.E_RESIZE_CURSOR;
- break;
- default:
- assert false : this.editRegion;
- }
-
- return Cursor.getPredefinedCursor(cursor);
- }
-
- /**
- * Returns whether the horizontal or the vertical region should be updated based on the
- * mouse pointer's location relative to the edges of either region. If no edge is close to
- * the mouse pointer, then it returns null.
- */
- private UpdateRegionInfo pickUpdateRegion(int x, int y, UpdateRegionInfo vertical,
- UpdateRegionInfo horizontal) {
- if (vertical != null && vertical.segment != null) {
- Edge e = getClosestEdge(y, vertical.segment);
- if (e != Edge.NONE) {
- return vertical;
- }
- }
-
- if (horizontal != null && horizontal.segment != null) {
- Edge e = getClosestEdge(x, horizontal.segment);
- if (e != Edge.NONE) {
- return horizontal;
- }
- }
-
- return null;
- }
-
- private enum Edge {
- START,
- END,
- NONE,
- }
-
- private static final int EDGE_DELTA = 1;
- private Edge getClosestEdge(int x, Pair<Integer> range) {
- if (Math.abs(x - range.first) <= EDGE_DELTA) {
- return Edge.START;
- } else if (Math.abs(range.second - x) <= EDGE_DELTA) {
- return Edge.END;
- } else {
- return Edge.NONE;
- }
- }
-
- private int imageYCoordinate(int y) {
- int top = helpPanel.getHeight() + (getHeight() - size.height) / 2;
- return (y - top) / zoom;
- }
-
- private int imageXCoordinate(int x) {
- int left = (getWidth() - size.width) / 2;
- return (x - left) / zoom;
- }
-
- private Point getImageOrigin() {
- int left = (getWidth() - size.width) / 2;
- int top = helpPanel.getHeight() + (getHeight() - size.height) / 2;
- return new Point(left, top);
- }
-
- private Rectangle displayCoordinates(Rectangle r) {
- Point imageOrigin = getImageOrigin();
-
- int x = r.x * zoom + imageOrigin.x;
- int y = r.y * zoom + imageOrigin.y;
- int w = r.width * zoom;
- int h = r.height * zoom;
-
- return new Rectangle(x, y, w, h);
- }
-
- private void updatePatchInfo() {
- patchInfo = new PatchInfo(image);
- }
-
- private void enableEraseMode(KeyEvent event) {
- boolean oldEraseMode = eraseMode;
- eraseMode = event.isShiftDown();
- if (eraseMode != oldEraseMode) {
- if (eraseMode) {
- helpLabel.setText("Release Shift to draw pixels");
- } else {
- helpLabel.setText("Press Shift to erase pixels."
- + " Press Control to draw layout bounds");
- }
- }
- }
-
- private void startDrawingLine(int x, int y) {
- int width = image.getWidth();
- int height = image.getHeight();
- if (((x == 0 || x == width - 1) && (y > 0 && y < height - 1))
- || ((x > 0 && x < width - 1) && (y == 0 || y == height - 1))) {
- drawingLine = true;
- lineFromX = x;
- lineFromY = y;
- lineToX = x;
- lineToY = y;
-
- showDrawingLine = true;
-
- showCursor = false;
-
- repaint();
- }
- }
-
- private void moveLine(int x, int y) {
- if (!drawingLine) {
- return;
- }
-
- int width = image.getWidth();
- int height = image.getHeight();
-
- showDrawingLine = false;
-
- if (((x == lineFromX) && (y > 0 && y < height - 1))
- || ((x > 0 && x < width - 1) && (y == lineFromY))) {
- lineToX = x;
- lineToY = y;
-
- showDrawingLine = true;
- }
-
- repaint();
- }
-
- private void endDrawingLine() {
- if (!drawingLine) {
- return;
- }
-
- drawingLine = false;
-
- if (!showDrawingLine) {
- return;
- }
-
- int color;
- switch (currentMode) {
- case PATCH:
- color = PatchInfo.BLACK_TICK;
- break;
- case LAYOUT_BOUND:
- color = PatchInfo.RED_TICK;
- break;
- case ERASE:
- color = 0;
- break;
- default:
- return;
- }
-
- setPatchData(color, lineFromX, lineFromY, lineToX, lineToY, true);
-
- patchesChanged();
- repaint();
- }
-
- /**
- * Set the color of pixels on the line from (x1, y1) to (x2, y2) to given color.
- * @param inclusive indicates whether the range is inclusive. If true, the last pixel (x2, y2)
- * will be set to the given color as well.
- */
- private void setPatchData(int color, int x1, int y1, int x2, int y2, boolean inclusive) {
- int x = x1;
- int y = y1;
-
- int dx = 0;
- int dy = 0;
-
- if (x2 != x1) {
- dx = x2 > x1 ? 1 : -1;
- } else if (y2 != y1) {
- dy = y2 > y1 ? 1 : -1;
- }
-
- while (x != x2 || y != y2) {
- image.setRGB(x, y, color);
- x += dx;
- y += dy;
- }
-
- if (inclusive) {
- image.setRGB(x, y, color);
- }
- }
-
- /** Flushes current edit data to the image. */
- private void flushEditPatchData(int color) {
- int x1, y1, x2, y2;
- x1 = x2 = y1 = y2 = 0;
- int min = Math.min(editSegment.first, editSegment.second);
- int max = Math.max(editSegment.first, editSegment.second);
- switch (editRegion) {
- case LEFT_PATCH:
- x1 = x2 = 0;
- y1 = min;
- y2 = max;
- break;
- case RIGHT_PADDING:
- x1 = x2 = image.getWidth() - 1;
- y1 = min;
- y2 = max;
- break;
- case TOP_PATCH:
- x1 = min;
- x2 = max;
- y1 = y2 = 0;
- break;
- case BOTTOM_PADDING:
- x1 = min;
- x2 = max;
- y1 = y2 = image.getHeight() - 1;
- break;
- default:
- assert false : editRegion;
- }
-
- setPatchData(color, x1, y1, x2, y2, false);
- }
-
- private void patchesChanged() {
- updatePatchInfo();
- notifyPatchesUpdated();
- if (showBadPatches) {
- corruptedPatches = CorruptPatch.findBadPatches(image, patchInfo);
- }
- }
-
- private boolean checkLockedRegion(int x, int y) {
- int oldX = lastPositionX;
- int oldY = lastPositionY;
- lastPositionX = x;
- lastPositionY = y;
-
- int width = image.getWidth();
- int height = image.getHeight();
-
- statusBar.setPointerLocation(Math.max(0, Math.min(x, width - 1)),
- Math.max(0, Math.min(y, height - 1)));
-
- boolean previousLock = locked;
- locked = x > 0 && x < width - 1 && y > 0 && y < height - 1;
-
- boolean previousCursor = showCursor;
- showCursor =
- !drawingLine &&
- ( ((x == 0 || x == width - 1) && (y > 0 && y < height - 1)) ||
- ((x > 0 && x < width - 1) && (y == 0 || y == height - 1)) );
-
- if (locked != previousLock) {
- repaint();
- } else if (showCursor || (showCursor != previousCursor)) {
- Rectangle clip = new Rectangle(lastPositionX - 1 - zoom / 2,
- lastPositionY - 1 - zoom / 2, zoom + 2, zoom + 2);
- clip = clip.union(new Rectangle(oldX - 1 - zoom / 2,
- oldY - 1 - zoom / 2, zoom + 2, zoom + 2));
- repaint(clip);
- }
-
- return locked;
- }
-
- @Override
- protected void paintComponent(Graphics g) {
- int x = (getWidth() - size.width) / 2;
- int y = helpPanel.getHeight() + (getHeight() - size.height) / 2;
-
- Graphics2D g2 = (Graphics2D) g.create();
- g2.setColor(BACK_COLOR);
- g2.fillRect(0, 0, getWidth(), getHeight());
-
- g2.translate(x, y);
- g2.setPaint(texture);
- g2.fillRect(0, 0, size.width, size.height);
- g2.scale(zoom, zoom);
- g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
- RenderingHints.VALUE_ANTIALIAS_ON);
- g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
- RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
- g2.drawImage(image, 0, 0, null);
-
- if (showPatches) {
- g2.setColor(PATCH_COLOR);
- for (Rectangle patch : patchInfo.patches) {
- g2.fillRect(patch.x, patch.y, patch.width, patch.height);
- }
- g2.setColor(PATCH_ONEWAY_COLOR);
- for (Rectangle patch : patchInfo.horizontalPatches) {
- g2.fillRect(patch.x, patch.y, patch.width, patch.height);
- }
- for (Rectangle patch : patchInfo.verticalPatches) {
- g2.fillRect(patch.x, patch.y, patch.width, patch.height);
- }
- }
-
- if (corruptedPatches != null) {
- g2.setColor(CORRUPTED_COLOR);
- g2.setStroke(new BasicStroke(3.0f / zoom));
- for (Rectangle patch : corruptedPatches) {
- g2.draw(new RoundRectangle2D.Float(patch.x - 2.0f / zoom, patch.y - 2.0f / zoom,
- patch.width + 2.0f / zoom, patch.height + 2.0f / zoom,
- 6.0f / zoom, 6.0f / zoom));
- }
- }
-
- if (showLock && locked) {
- int width = image.getWidth();
- int height = image.getHeight();
-
- g2.setColor(LOCK_COLOR);
- g2.fillRect(1, 1, width - 2, height - 2);
-
- g2.setColor(STRIPES_COLOR);
- g2.translate(1, 1);
- paintStripes(g2, width - 2, height - 2);
- g2.translate(-1, -1);
- }
-
- g2.dispose();
-
- if (drawingLine && showDrawingLine) {
- Graphics cursor = g.create();
- cursor.setXORMode(Color.WHITE);
- cursor.setColor(Color.BLACK);
-
- x = Math.min(lineFromX, lineToX);
- y = Math.min(lineFromY, lineToY);
- int w = Math.abs(lineFromX - lineToX) + 1;
- int h = Math.abs(lineFromY - lineToY) + 1;
-
- x = x * zoom;
- y = y * zoom;
- w = w * zoom;
- h = h * zoom;
-
- int left = (getWidth() - size.width) / 2;
- int top = helpPanel.getHeight() + (getHeight() - size.height)
- / 2;
-
- x += left;
- y += top;
-
- cursor.drawRect(x, y, w, h);
- cursor.dispose();
- }
-
- if (showCursor) {
- Graphics cursor = g.create();
- cursor.setXORMode(Color.WHITE);
- cursor.setColor(Color.BLACK);
- cursor.drawRect(lastPositionX - zoom / 2, lastPositionY - zoom / 2, zoom, zoom);
- cursor.dispose();
- }
-
- g2 = (Graphics2D) g.create();
- g2.setColor(HIGHLIGHT_REGION_COLOR);
- for (Rectangle r: hoverHighlightRegions) {
- g2.fillRect(r.x, r.y, r.width, r.height);
- }
-
- if (!hoverHighlightRegions.isEmpty()) {
- setToolTipText(toolTipText);
- } else {
- setToolTipText(null);
- }
-
- if (isEditMode && editRegion != null) {
- g2.setColor(HIGHLIGHT_REGION_COLOR);
- for (Rectangle r: editHighlightRegions) {
- g2.fillRect(r.x, r.y, r.width, r.height);
- }
- g2.setColor(Color.BLACK);
- g2.fillRect(editPatchRegion.x, editPatchRegion.y,
- editPatchRegion.width, editPatchRegion.height);
- }
-
- g2.dispose();
- }
-
- private void paintStripes(Graphics2D g, int width, int height) {
- //draws pinstripes at the angle specified in this class
- //and at the given distance apart
- Shape oldClip = g.getClip();
- Area area = new Area(new Rectangle(0, 0, width, height));
- if(oldClip != null) {
- area = new Area(oldClip);
- }
- area.intersect(new Area(new Rectangle(0,0,width,height)));
- g.setClip(area);
-
- g.setStroke(new BasicStroke(STRIPES_WIDTH));
-
- double hypLength = Math.sqrt((width * width) +
- (height * height));
-
- double radians = Math.toRadians(STRIPES_ANGLE);
- g.rotate(radians);
-
- double spacing = STRIPES_SPACING;
- spacing += STRIPES_WIDTH;
- int numLines = (int)(hypLength / spacing);
-
- for (int i=0; i<numLines; i++) {
- double x = i * spacing;
- Line2D line = new Line2D.Double(x, -hypLength, x, hypLength);
- g.draw(line);
- }
- g.setClip(oldClip);
- }
-
- @Override
- public Dimension getPreferredSize() {
- return size;
- }
-
- private void setDefaultZoom() {
- int frameWidth = getWidth(), frameHeight = getHeight();
- int z = DEFAULT_ZOOM;
- if (frameWidth > 0 && frameHeight > 0) {
- float w = (float) image.getWidth() / frameWidth;
- float h = (float) image.getHeight() / frameHeight;
-
- float current = Math.max(w, h);
- float ideal = IDEAL_IMAGE_FRACTION_OF_WINDOW;
-
- z = clamp(Math.round(ideal / current), 1, MAX_ZOOM);
- }
- setZoom(z);
- }
-
- void setZoom(int value) {
- zoom = value;
- updateSize();
- if (!size.equals(getSize())) {
- setSize(size);
- container.validate();
- repaint();
- }
- }
-
- int getZoom() {
- return zoom;
- }
-
- private void updateSize() {
- int width = image.getWidth();
- int height = image.getHeight();
-
- if (size.height == 0 || (getHeight() - size.height) == 0) {
- size.setSize(width * zoom, height * zoom + helpPanel.getHeight());
- } else {
- size.setSize(width * zoom, height * zoom);
- }
- }
-
- void setPatchesVisible(boolean visible) {
- showPatches = visible;
- updatePatchInfo();
- repaint();
- }
-
- void setLockVisible(boolean visible) {
- showLock = visible;
- repaint();
- }
-
- public void setImage(BufferedImage image) {
- this.image = image;
- }
-
- public BufferedImage getImage() {
- return image;
- }
-
- public PatchInfo getPatchInfo() {
- return patchInfo;
- }
-
- public interface StatusBar {
- void setPointerLocation(int x, int y);
- }
-
- public interface PatchUpdateListener {
- void patchesUpdated();
- }
-
- private final Set<PatchUpdateListener> listeners = new HashSet<PatchUpdateListener>();
-
- public void addPatchUpdateListener(PatchUpdateListener p) {
- listeners.add(p);
- }
-
- public void removePatchUpdateListener(PatchUpdateListener p) {
- listeners.remove(p);
- }
-
- private void notifyPatchesUpdated() {
- for (PatchUpdateListener p: listeners) {
- p.patchesUpdated();
- }
- }
-} \ No newline at end of file
diff --git a/draw9patch/src/main/java/com/android/draw9patch/ui/MainFrame.java b/draw9patch/src/main/java/com/android/draw9patch/ui/MainFrame.java
deleted file mode 100644
index ff749f4..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/ui/MainFrame.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.draw9patch.ui;
-
-import com.android.draw9patch.graphics.GraphicsUtilities;
-import com.android.draw9patch.ui.action.ExitAction;
-import com.android.draw9patch.ui.action.OpenAction;
-import com.android.draw9patch.ui.action.SaveAction;
-
-import java.awt.HeadlessException;
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.util.concurrent.ExecutionException;
-
-import javax.imageio.ImageIO;
-import javax.swing.ActionMap;
-import javax.swing.JFileChooser;
-import javax.swing.JFrame;
-import javax.swing.JMenu;
-import javax.swing.JMenuBar;
-import javax.swing.JMenuItem;
-import javax.swing.SwingWorker;
-
-public class MainFrame extends JFrame {
- private ActionMap actionsMap;
- private JMenuItem saveMenuItem;
- private ImageEditorPanel imageEditor;
-
- private static final String TITLE_FORMAT = "Draw 9-patch: %s";
-
- public MainFrame(String path) throws HeadlessException {
- super("Draw 9-patch");
-
- buildActions();
- buildMenuBar();
- buildContent();
-
- if (path == null) {
- showOpenFilePanel();
- } else {
- try {
- File file = new File(path);
- BufferedImage img = GraphicsUtilities.loadCompatibleImage(file.toURI().toURL());
- showImageEditor(img, file.getAbsolutePath());
-
- setTitle(String.format(TITLE_FORMAT, path));
- } catch (Exception ex) {
- showOpenFilePanel();
- }
- }
-
- // pack();
- setSize(1024, 600);
- }
-
- private void buildActions() {
- actionsMap = new ActionMap();
- actionsMap.put(OpenAction.ACTION_NAME, new OpenAction(this));
- actionsMap.put(SaveAction.ACTION_NAME, new SaveAction(this));
- actionsMap.put(ExitAction.ACTION_NAME, new ExitAction(this));
- }
-
- private void buildMenuBar() {
- JMenu fileMenu = new JMenu("File");
- JMenuItem openMenuItem = new JMenuItem();
- saveMenuItem = new JMenuItem();
- JMenuItem exitMenuItem = new JMenuItem();
-
- openMenuItem.setAction(actionsMap.get(OpenAction.ACTION_NAME));
- fileMenu.add(openMenuItem);
-
- saveMenuItem.setAction(actionsMap.get(SaveAction.ACTION_NAME));
- saveMenuItem.setEnabled(false);
- fileMenu.add(saveMenuItem);
-
- exitMenuItem.setAction(actionsMap.get(ExitAction.ACTION_NAME));
- fileMenu.add(exitMenuItem);
-
- JMenuBar menuBar = new JMenuBar();
- menuBar.add(fileMenu);
- setJMenuBar(menuBar);
- }
-
- private void buildContent() {
- setContentPane(new GradientPanel());
- }
-
- private void showOpenFilePanel() {
- add(new OpenFilePanel(this));
- }
-
- public SwingWorker<?, ?> open(File file) {
- if (file == null) {
- JFileChooser chooser = new JFileChooser();
- chooser.setFileFilter(new PngFileFilter());
- int choice = chooser.showOpenDialog(this);
- if (choice == JFileChooser.APPROVE_OPTION) {
- return new OpenTask(chooser.getSelectedFile());
- } else {
- return null;
- }
- } else {
- return new OpenTask(file);
- }
- }
-
- void showImageEditor(BufferedImage image, String name) {
- getContentPane().removeAll();
- imageEditor = new ImageEditorPanel(this, image, name);
- add(imageEditor);
- saveMenuItem.setEnabled(true);
- validate();
- repaint();
- }
-
- public SwingWorker<?, ?> save() {
- if (imageEditor == null) {
- return null;
- }
-
- File file = imageEditor.chooseSaveFile();
- return file != null ? new SaveTask(file) : null;
- }
-
- private class SaveTask extends SwingWorker<Boolean, Void> {
- private final File file;
-
- SaveTask(File file) {
- this.file = file;
- }
-
- protected Boolean doInBackground() throws Exception {
- try {
- ImageIO.write(imageEditor.getImage(), "PNG", file);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return true;
- }
- }
-
- private class OpenTask extends SwingWorker<BufferedImage, Void> {
- private final File file;
-
- OpenTask(File file) {
- this.file = file;
- }
-
- protected BufferedImage doInBackground() throws Exception {
- return GraphicsUtilities.loadCompatibleImage(file.toURI().toURL());
- }
-
- @Override
- protected void done() {
- try {
- showImageEditor(get(), file.getAbsolutePath());
- setTitle(String.format(TITLE_FORMAT, file.getAbsolutePath()));
- } catch (InterruptedException e) {
- e.printStackTrace();
- } catch (ExecutionException e) {
- e.printStackTrace();
- }
- }
- }
-}
diff --git a/draw9patch/src/main/java/com/android/draw9patch/ui/OpenFilePanel.java b/draw9patch/src/main/java/com/android/draw9patch/ui/OpenFilePanel.java
deleted file mode 100644
index a444332..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/ui/OpenFilePanel.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.android.draw9patch.ui;
-
-import com.android.draw9patch.graphics.GraphicsUtilities;
-
-import javax.swing.JComponent;
-import java.awt.image.BufferedImage;
-import java.awt.Graphics;
-import java.io.IOException;
-import java.net.URL;/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-class OpenFilePanel extends JComponent {
- private BufferedImage dropHere;
-
- OpenFilePanel(MainFrame mainFrame) {
- setOpaque(false);
- loadSupportImage();
- setTransferHandler(new ImageTransferHandler(mainFrame));
- }
-
- private void loadSupportImage() {
- try {
- URL resource = getClass().getResource("/images/drop.png");
- dropHere = GraphicsUtilities.loadCompatibleImage(resource);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
- @Override
- protected void paintComponent(Graphics g) {
- int x = (getWidth() - dropHere.getWidth()) / 2;
- int y = (getHeight() - dropHere.getHeight()) / 2;
-
- g.drawImage(dropHere, x, y, null);
- }
-
-}
diff --git a/draw9patch/src/main/java/com/android/draw9patch/ui/Pair.java b/draw9patch/src/main/java/com/android/draw9patch/ui/Pair.java
deleted file mode 100644
index bc38671..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/ui/Pair.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.draw9patch.ui;
-
-public class Pair<E> {
- E first;
- E second;
-
- Pair(E first, E second) {
- this.first = first;
- this.second = second;
- }
-
- @Override
- public String toString() {
- return "Pair[" + first + ", " + second + "]";
- }
-}
diff --git a/draw9patch/src/main/java/com/android/draw9patch/ui/PatchInfo.java b/draw9patch/src/main/java/com/android/draw9patch/ui/PatchInfo.java
deleted file mode 100644
index 0cca67b..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/ui/PatchInfo.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.draw9patch.ui;
-
-import com.android.draw9patch.graphics.GraphicsUtilities;
-
-import java.awt.Rectangle;
-import java.awt.image.BufferedImage;
-import java.util.ArrayList;
-import java.util.List;
-
-public class PatchInfo {
- /** Color used to indicate stretch regions and padding. */
- public static final int BLACK_TICK = 0xFF000000;
-
- /** Color used to indicate layout bounds. */
- public static final int RED_TICK = 0xFFFF0000;
-
- /** Areas of the image that are stretchable in both directions. */
- public final List<Rectangle> patches;
-
- /** Areas of the image that are not stretchable in either direction. */
- public final List<Rectangle> fixed;
-
- /** Areas of image stretchable horizontally. */
- public final List<Rectangle> horizontalPatches;
-
- /** Areas of image stretchable vertically. */
- public final List<Rectangle> verticalPatches;
-
- /** Bounds of horizontal patch markers. */
- public final List<Pair<Integer>> horizontalPatchMarkers;
-
- /** Bounds of horizontal padding markers. */
- public final List<Pair<Integer>> horizontalPaddingMarkers;
-
- /** Bounds of vertical patch markers. */
- public final List<Pair<Integer>> verticalPatchMarkers;
-
- /** Bounds of vertical padding markers. */
- public final List<Pair<Integer>> verticalPaddingMarkers;
-
- public final boolean verticalStartWithPatch;
- public final boolean horizontalStartWithPatch;
-
- /** Beginning and end padding in the horizontal direction */
- public final Pair<Integer> horizontalPadding;
-
- /** Beginning and end padding in the vertical direction */
- public final Pair<Integer> verticalPadding;
-
- private BufferedImage image;
-
- public PatchInfo(BufferedImage image) {
- this.image = image;
-
- int width = image.getWidth();
- int height = image.getHeight();
-
- int[] row = GraphicsUtilities.getPixels(image, 0, 0, width, 1, null);
- int[] column = GraphicsUtilities.getPixels(image, 0, 0, 1, height, null);
-
- P left = getPatches(column);
- verticalStartWithPatch = left.startsWithPatch;
- verticalPatchMarkers = left.patches;
-
- P top = getPatches(row);
- horizontalStartWithPatch = top.startsWithPatch;
- horizontalPatchMarkers = top.patches;
-
- fixed = getRectangles(left.fixed, top.fixed);
- patches = getRectangles(left.patches, top.patches);
-
- if (fixed.size() > 0) {
- horizontalPatches = getRectangles(left.fixed, top.patches);
- verticalPatches = getRectangles(left.patches, top.fixed);
- } else {
- if (top.fixed.size() > 0) {
- horizontalPatches = new ArrayList<Rectangle>(0);
- verticalPatches = getVerticalRectangles(top.fixed);
- } else if (left.fixed.size() > 0) {
- horizontalPatches = getHorizontalRectangles(left.fixed);
- verticalPatches = new ArrayList<Rectangle>(0);
- } else {
- horizontalPatches = verticalPatches = new ArrayList<Rectangle>(0);
- }
- }
-
- row = GraphicsUtilities.getPixels(image, 0, height - 1, width, 1, row);
- column = GraphicsUtilities.getPixels(image, width - 1, 0, 1, height, column);
-
- top = PatchInfo.getPatches(row);
- horizontalPaddingMarkers = top.patches;
- horizontalPadding = getPadding(top.fixed);
-
- left = PatchInfo.getPatches(column);
- verticalPaddingMarkers = left.patches;
- verticalPadding = getPadding(left.fixed);
- }
-
- private List<Rectangle> getVerticalRectangles(List<Pair<Integer>> topPairs) {
- List<Rectangle> rectangles = new ArrayList<Rectangle>();
- for (Pair<Integer> top : topPairs) {
- int x = top.first;
- int width = top.second - top.first;
-
- rectangles.add(new Rectangle(x, 1, width, image.getHeight() - 2));
- }
- return rectangles;
- }
-
- private List<Rectangle> getHorizontalRectangles(List<Pair<Integer>> leftPairs) {
- List<Rectangle> rectangles = new ArrayList<Rectangle>();
- for (Pair<Integer> left : leftPairs) {
- int y = left.first;
- int height = left.second - left.first;
-
- rectangles.add(new Rectangle(1, y, image.getWidth() - 2, height));
- }
- return rectangles;
- }
-
- private Pair<Integer> getPadding(List<Pair<Integer>> pairs) {
- if (pairs.size() == 0) {
- return new Pair<Integer>(0, 0);
- } else if (pairs.size() == 1) {
- if (pairs.get(0).first == 1) {
- return new Pair<Integer>(pairs.get(0).second - pairs.get(0).first, 0);
- } else {
- return new Pair<Integer>(0, pairs.get(0).second - pairs.get(0).first);
- }
- } else {
- int index = pairs.size() - 1;
- return new Pair<Integer>(pairs.get(0).second - pairs.get(0).first,
- pairs.get(index).second - pairs.get(index).first);
- }
- }
-
- private List<Rectangle> getRectangles(List<Pair<Integer>> leftPairs,
- List<Pair<Integer>> topPairs) {
- List<Rectangle> rectangles = new ArrayList<Rectangle>();
- for (Pair<Integer> left : leftPairs) {
- int y = left.first;
- int height = left.second - left.first;
- for (Pair<Integer> top : topPairs) {
- int x = top.first;
- int width = top.second - top.first;
-
- rectangles.add(new Rectangle(x, y, width, height));
- }
- }
- return rectangles;
- }
-
- private static class P {
- public final List<Pair<Integer>> fixed;
- public final List<Pair<Integer>> patches;
- public final boolean startsWithPatch;
-
- private P(List<Pair<Integer>> f, List<Pair<Integer>> p, boolean s) {
- fixed = f;
- patches = p;
- startsWithPatch = s;
- }
- }
-
- private static P getPatches(int[] pixels) {
- int lastIndex = 1;
- int lastPixel;
- boolean first = true;
- boolean startWithPatch = false;
-
- List<Pair<Integer>> fixed = new ArrayList<Pair<Integer>>();
- List<Pair<Integer>> patches = new ArrayList<Pair<Integer>>();
-
- // ignore layout bound markers for the purpose of patch calculation
- lastPixel = pixels[1] != PatchInfo.RED_TICK ? pixels[1] : 0;
-
- for (int i = 1; i < pixels.length - 1; i++) {
- // ignore layout bound markers for the purpose of patch calculation
- int pixel = pixels[i] != PatchInfo.RED_TICK ? pixels[i] : 0;
-
- if (pixel != lastPixel) {
- if (lastPixel == BLACK_TICK) {
- if (first) startWithPatch = true;
- patches.add(new Pair<Integer>(lastIndex, i));
- } else {
- fixed.add(new Pair<Integer>(lastIndex, i));
- }
- first = false;
-
- lastIndex = i;
- lastPixel = pixel;
- }
- }
- if (lastPixel == BLACK_TICK) {
- if (first) startWithPatch = true;
- patches.add(new Pair<Integer>(lastIndex, pixels.length - 1));
- } else {
- fixed.add(new Pair<Integer>(lastIndex, pixels.length - 1));
- }
-
- if (patches.size() == 0) {
- patches.add(new Pair<Integer>(1, pixels.length - 1));
- startWithPatch = true;
- fixed.clear();
- }
-
- return new P(fixed, patches, startWithPatch);
- }
-}
diff --git a/draw9patch/src/main/java/com/android/draw9patch/ui/PngFileFilter.java b/draw9patch/src/main/java/com/android/draw9patch/ui/PngFileFilter.java
deleted file mode 100644
index 8f8885a..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/ui/PngFileFilter.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.draw9patch.ui;
-
-import javax.swing.filechooser.FileFilter;
-import java.io.File;
-
-class PngFileFilter extends FileFilter {
- @Override
- public boolean accept(File f) {
- return f.isDirectory() || f.getName().toLowerCase().endsWith(".png");
- }
-
- @Override
- public String getDescription() {
- return "PNG Image (*.png)";
- }
-}
diff --git a/draw9patch/src/main/java/com/android/draw9patch/ui/StretchesViewer.java b/draw9patch/src/main/java/com/android/draw9patch/ui/StretchesViewer.java
deleted file mode 100644
index efe0055..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/ui/StretchesViewer.java
+++ /dev/null
@@ -1,326 +0,0 @@
-/*
- *
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.android.draw9patch.ui;
-
-import java.awt.Color;
-import java.awt.Container;
-import java.awt.Dimension;
-import java.awt.Graphics;
-import java.awt.Graphics2D;
-import java.awt.GridBagConstraints;
-import java.awt.GridBagLayout;
-import java.awt.Insets;
-import java.awt.Rectangle;
-import java.awt.RenderingHints;
-import java.awt.TexturePaint;
-import java.awt.image.BufferedImage;
-
-import javax.swing.BorderFactory;
-import javax.swing.JComponent;
-import javax.swing.JPanel;
-
-public class StretchesViewer extends JPanel {
- public static final float DEFAULT_SCALE = 2.0f;
- private static final int MARGIN = 24;
-
- private final Container container;
- private final ImageViewer viewer;
- private final TexturePaint texture;
-
- private BufferedImage image;
- private PatchInfo patchInfo;
-
- private StretchView horizontal;
- private StretchView vertical;
- private StretchView both;
-
- private Dimension size;
-
- private float horizontalPatchesSum;
- private float verticalPatchesSum;
-
- private boolean showPadding;
-
- StretchesViewer(Container container, ImageViewer viewer, TexturePaint texture) {
- this.container = container;
- this.viewer = viewer;
- this.texture = texture;
-
- image = viewer.getImage();
- patchInfo = viewer.getPatchInfo();
-
- viewer.addPatchUpdateListener(new ImageViewer.PatchUpdateListener() {
- @Override
- public void patchesUpdated() {
- computePatches();
- }
- });
-
- setOpaque(false);
- setLayout(new GridBagLayout());
- setBorder(BorderFactory.createEmptyBorder(MARGIN, MARGIN, MARGIN, MARGIN));
-
- horizontal = new StretchView();
- vertical = new StretchView();
- both = new StretchView();
-
- setScale(DEFAULT_SCALE);
-
- add(vertical, new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
- GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
- add(horizontal, new GridBagConstraints(0, 1, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
- GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
- add(both, new GridBagConstraints(0, 2, 1, 1, 1.0, 1.0, GridBagConstraints.CENTER,
- GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
- }
-
- @Override
- protected void paintComponent(Graphics g) {
- Graphics2D g2 = (Graphics2D) g.create();
- g2.setPaint(texture);
- g2.fillRect(0, 0, getWidth(), getHeight());
- g2.dispose();
- }
-
- void setScale(float scale) {
- int patchWidth = image.getWidth() - 2;
- int patchHeight = image.getHeight() - 2;
-
- int scaledWidth = (int) (patchWidth * scale);
- int scaledHeight = (int) (patchHeight * scale);
-
- horizontal.scaledWidth = scaledWidth;
- vertical.scaledHeight = scaledHeight;
- both.scaledWidth = scaledWidth;
- both.scaledHeight = scaledHeight;
-
- size = new Dimension(scaledWidth, scaledHeight);
-
- computePatches();
- }
-
- void computePatches() {
- image = viewer.getImage();
- patchInfo = viewer.getPatchInfo();
-
- boolean measuredWidth = false;
- boolean endRow = true;
-
- int remainderHorizontal = 0;
- int remainderVertical = 0;
-
- if (patchInfo.fixed.size() > 0) {
- int start = patchInfo.fixed.get(0).y;
- for (Rectangle rect : patchInfo.fixed) {
- if (rect.y > start) {
- endRow = true;
- measuredWidth = true;
- }
- if (!measuredWidth) {
- remainderHorizontal += rect.width;
- }
- if (endRow) {
- remainderVertical += rect.height;
- endRow = false;
- start = rect.y;
- }
- }
- }
-
- horizontal.remainderHorizontal = horizontal.scaledWidth - remainderHorizontal;
- vertical.remainderHorizontal = vertical.scaledWidth - remainderHorizontal;
- both.remainderHorizontal = both.scaledWidth - remainderHorizontal;
-
- horizontal.remainderVertical = horizontal.scaledHeight - remainderVertical;
- vertical.remainderVertical = vertical.scaledHeight - remainderVertical;
- both.remainderVertical = both.scaledHeight - remainderVertical;
-
- horizontalPatchesSum = 0;
- if (patchInfo.horizontalPatches.size() > 0) {
- int start = -1;
- for (Rectangle rect : patchInfo.horizontalPatches) {
- if (rect.x > start) {
- horizontalPatchesSum += rect.width;
- start = rect.x;
- }
- }
- } else {
- int start = -1;
- for (Rectangle rect : patchInfo.patches) {
- if (rect.x > start) {
- horizontalPatchesSum += rect.width;
- start = rect.x;
- }
- }
- }
-
- verticalPatchesSum = 0;
- if (patchInfo.verticalPatches.size() > 0) {
- int start = -1;
- for (Rectangle rect : patchInfo.verticalPatches) {
- if (rect.y > start) {
- verticalPatchesSum += rect.height;
- start = rect.y;
- }
- }
- } else {
- int start = -1;
- for (Rectangle rect : patchInfo.patches) {
- if (rect.y > start) {
- verticalPatchesSum += rect.height;
- start = rect.y;
- }
- }
- }
-
- setSize(size);
- container.validate();
- repaint();
- }
-
- void setPaddingVisible(boolean visible) {
- showPadding = visible;
- repaint();
- }
-
- private class StretchView extends JComponent {
- private final Color PADDING_COLOR = new Color(0.37f, 0.37f, 1.0f, 0.5f);
-
- int scaledWidth;
- int scaledHeight;
-
- int remainderHorizontal;
- int remainderVertical;
-
- StretchView() {
- scaledWidth = image.getWidth();
- scaledHeight = image.getHeight();
- }
-
- @Override
- protected void paintComponent(Graphics g) {
- int x = (getWidth() - scaledWidth) / 2;
- int y = (getHeight() - scaledHeight) / 2;
-
- Graphics2D g2 = (Graphics2D) g.create();
- g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
- RenderingHints.VALUE_INTERPOLATION_BILINEAR);
- g.translate(x, y);
-
- x = 0;
- y = 0;
-
- if (patchInfo.patches.size() == 0) {
- g.drawImage(image, 0, 0, scaledWidth, scaledHeight, null);
- g2.dispose();
- return;
- }
-
- int fixedIndex = 0;
- int horizontalIndex = 0;
- int verticalIndex = 0;
- int patchIndex = 0;
-
- boolean hStretch;
- boolean vStretch;
-
- float vWeightSum = 1.0f;
- float vRemainder = remainderVertical;
-
- vStretch = patchInfo.verticalStartWithPatch;
- while (y < scaledHeight - 1) {
- hStretch = patchInfo.horizontalStartWithPatch;
-
- int height = 0;
- float vExtra = 0.0f;
-
- float hWeightSum = 1.0f;
- float hRemainder = remainderHorizontal;
-
- while (x < scaledWidth - 1) {
- Rectangle r;
- if (!vStretch) {
- if (hStretch) {
- r = patchInfo.horizontalPatches.get(horizontalIndex++);
- float extra = r.width / horizontalPatchesSum;
- int width = (int) (extra * hRemainder / hWeightSum);
- hWeightSum -= extra;
- hRemainder -= width;
- g.drawImage(image, x, y, x + width, y + r.height, r.x, r.y,
- r.x + r.width, r.y + r.height, null);
- x += width;
- } else {
- r = patchInfo.fixed.get(fixedIndex++);
- g.drawImage(image, x, y, x + r.width, y + r.height, r.x, r.y,
- r.x + r.width, r.y + r.height, null);
- x += r.width;
- }
- height = r.height;
- } else {
- if (hStretch) {
- r = patchInfo.patches.get(patchIndex++);
- vExtra = r.height / verticalPatchesSum;
- height = (int) (vExtra * vRemainder / vWeightSum);
- float extra = r.width / horizontalPatchesSum;
- int width = (int) (extra * hRemainder / hWeightSum);
- hWeightSum -= extra;
- hRemainder -= width;
- g.drawImage(image, x, y, x + width, y + height, r.x, r.y,
- r.x + r.width, r.y + r.height, null);
- x += width;
- } else {
- r = patchInfo.verticalPatches.get(verticalIndex++);
- vExtra = r.height / verticalPatchesSum;
- height = (int) (vExtra * vRemainder / vWeightSum);
- g.drawImage(image, x, y, x + r.width, y + height, r.x, r.y,
- r.x + r.width, r.y + r.height, null);
- x += r.width;
- }
-
- }
- hStretch = !hStretch;
- }
- x = 0;
- y += height;
- if (vStretch) {
- vWeightSum -= vExtra;
- vRemainder -= height;
- }
- vStretch = !vStretch;
- }
-
- if (showPadding) {
- g.setColor(PADDING_COLOR);
- g.fillRect(patchInfo.horizontalPadding.first,
- patchInfo.verticalPadding.first,
- scaledWidth - patchInfo.horizontalPadding.first
- - patchInfo.horizontalPadding.second,
- scaledHeight - patchInfo.verticalPadding.first
- - patchInfo.verticalPadding.second);
- }
-
- g2.dispose();
- }
-
- @Override
- public Dimension getPreferredSize() {
- return size;
- }
- }
-} \ No newline at end of file
diff --git a/draw9patch/src/main/java/com/android/draw9patch/ui/action/BackgroundAction.java b/draw9patch/src/main/java/com/android/draw9patch/ui/action/BackgroundAction.java
deleted file mode 100644
index 11bf261..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/ui/action/BackgroundAction.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.draw9patch.ui.action;
-
-import javax.swing.AbstractAction;
-import javax.swing.SwingWorker;
-
-public abstract class BackgroundAction extends AbstractAction {
- protected void executeBackgroundTask(SwingWorker<?, ?> worker) {
- if (worker != null) {
- worker.execute();
- }
- }
-}
diff --git a/draw9patch/src/main/java/com/android/draw9patch/ui/action/ExitAction.java b/draw9patch/src/main/java/com/android/draw9patch/ui/action/ExitAction.java
deleted file mode 100644
index b6f047d..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/ui/action/ExitAction.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.draw9patch.ui.action;
-
-import javax.swing.AbstractAction;
-import javax.swing.KeyStroke;
-import javax.swing.JFrame;
-import java.awt.event.KeyEvent;
-import java.awt.event.ActionEvent;
-import java.awt.Toolkit;
-
-public class ExitAction extends AbstractAction {
- public static final String ACTION_NAME = "exit";
- private JFrame frame;
-
- public ExitAction(JFrame frame) {
- putValue(NAME, "Quit");
- putValue(SHORT_DESCRIPTION, "Quit");
- putValue(LONG_DESCRIPTION, "Quit");
- putValue(MNEMONIC_KEY, KeyEvent.VK_Q);
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Q,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
- this.frame = frame;
- }
-
- public void actionPerformed(ActionEvent e) {
- frame.dispose();
- System.exit(0);
- }
-}
diff --git a/draw9patch/src/main/java/com/android/draw9patch/ui/action/OpenAction.java b/draw9patch/src/main/java/com/android/draw9patch/ui/action/OpenAction.java
deleted file mode 100644
index 45ee5be..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/ui/action/OpenAction.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.draw9patch.ui.action;
-
-import com.android.draw9patch.ui.MainFrame;
-
-import javax.swing.KeyStroke;
-import java.awt.event.KeyEvent;
-import java.awt.event.ActionEvent;
-import java.awt.Toolkit;
-
-public class OpenAction extends BackgroundAction {
- public static final String ACTION_NAME = "open";
- private MainFrame frame;
-
- public OpenAction(MainFrame frame) {
- this.frame = frame;
- putValue(NAME, "Open 9-patch...");
- putValue(SHORT_DESCRIPTION, "Open...");
- putValue(LONG_DESCRIPTION, "Open 9-patch...");
- putValue(MNEMONIC_KEY, KeyEvent.VK_O);
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_O,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
- }
-
- public void actionPerformed(ActionEvent e) {
- executeBackgroundTask(frame.open(null));
- }
-}
diff --git a/draw9patch/src/main/java/com/android/draw9patch/ui/action/SaveAction.java b/draw9patch/src/main/java/com/android/draw9patch/ui/action/SaveAction.java
deleted file mode 100644
index 5c1dc52..0000000
--- a/draw9patch/src/main/java/com/android/draw9patch/ui/action/SaveAction.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.draw9patch.ui.action;
-
-import com.android.draw9patch.ui.MainFrame;
-
-import javax.swing.KeyStroke;
-import java.awt.event.KeyEvent;
-import java.awt.event.ActionEvent;
-import java.awt.Toolkit;
-
-public class SaveAction extends BackgroundAction {
- public static final String ACTION_NAME = "save";
- private MainFrame frame;
-
- public SaveAction(MainFrame frame) {
- this.frame = frame;
- putValue(NAME, "Save 9-patch...");
- putValue(SHORT_DESCRIPTION, "Save...");
- putValue(LONG_DESCRIPTION, "Save 9-patch...");
- putValue(MNEMONIC_KEY, KeyEvent.VK_S);
- putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_S,
- Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
- }
-
- public void actionPerformed(ActionEvent e) {
- executeBackgroundTask(frame.save());
- }
-}
diff --git a/draw9patch/src/main/resources/images/checker.png b/draw9patch/src/main/resources/images/checker.png
deleted file mode 100644
index 78908f4..0000000
--- a/draw9patch/src/main/resources/images/checker.png
+++ /dev/null
Binary files differ
diff --git a/draw9patch/src/main/resources/images/drop.png b/draw9patch/src/main/resources/images/drop.png
deleted file mode 100644
index 7a7436a..0000000
--- a/draw9patch/src/main/resources/images/drop.png
+++ /dev/null
Binary files differ
diff --git a/draw9patch/src/test/java/com/android/draw9patch/ui/PatchInfoTest.java b/draw9patch/src/test/java/com/android/draw9patch/ui/PatchInfoTest.java
deleted file mode 100644
index 7350b82..0000000
--- a/draw9patch/src/test/java/com/android/draw9patch/ui/PatchInfoTest.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- *
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-package com.android.draw9patch.ui;
-
-import junit.framework.TestCase;
-
-import java.awt.Rectangle;
-import java.awt.image.BufferedImage;
-
-public class PatchInfoTest extends TestCase {
- private BufferedImage createImage(String[] data) {
- int h = data.length;
- int w = data[0].length();
- BufferedImage image = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
-
- for (int row = 0; row < h; row++) {
- for (int col = 0; col < w; col++) {
- char c = data[row].charAt(col);
- int color = 0;
- if (c == '*') {
- color = PatchInfo.BLACK_TICK;
- } else if (c == 'R') {
- color = PatchInfo.RED_TICK;
- }
- image.setRGB(col, row, color);
- }
- }
- return image;
- }
-
- public void testPatchInfo() {
- BufferedImage image = createImage(new String[] {
- "0123**6789",
- "1........*",
- "*........*",
- "3........*",
- "412*****89",
- });
- PatchInfo pi = new PatchInfo(image);
-
- // The left and top patch markers don't begin from the first pixel
- assertFalse(pi.horizontalStartWithPatch);
- assertFalse(pi.verticalStartWithPatch);
-
- // There should be one patch in the middle where the left and top patch markers intersect
- assertEquals(1, pi.patches.size());
- assertEquals(new Rectangle(4, 2, 2, 1), pi.patches.get(0));
-
- // There should be 2 horizontal stretchable areas - area below the top marker but excluding
- // the main patch
- assertEquals(2, pi.horizontalPatches.size());
- assertEquals(new Rectangle(4, 1, 2, 1), pi.horizontalPatches.get(0));
- assertEquals(new Rectangle(4, 3, 2, 1), pi.horizontalPatches.get(1));
-
- // Similarly, there should be 2 vertical stretchable areas
- assertEquals(2, pi.verticalPatches.size());
- assertEquals(new Rectangle(1, 2, 3, 1), pi.verticalPatches.get(0));
- assertEquals(new Rectangle(6, 2, 3, 1), pi.verticalPatches.get(1));
-
- // The should be 4 fixed regions - the regions that don't fall under the patches
- assertEquals(4, pi.fixed.size());
-
- // The horizontal padding is described by the bottom bar.
- // In this case, there is a 2 pixel (pixels 1 & 2) padding at start and 1 pixel (pixel 8)
- // padding at end
- assertEquals(2, pi.horizontalPadding.first.intValue());
- assertEquals(1, pi.horizontalPadding.second.intValue());
-
- // The vertical padding is described by the bar at the right.
- // In this case, there is no padding as the content area matches the image area
- assertEquals(0, pi.verticalPadding.first.intValue());
- assertEquals(0, pi.verticalPadding.second.intValue());
- }
-
- public void testPadding() {
- BufferedImage image = createImage(new String[] {
- "0123**6789",
- "1.........",
- "2.........",
- "3........*",
- "4........*",
- "5***456789",
- });
- PatchInfo pi = new PatchInfo(image);
-
- // 0 pixel padding at start and 5 pixel padding at the end (pixels 4 through 8 inclusive)
- assertEquals(0, pi.horizontalPadding.first.intValue());
- assertEquals(5, pi.horizontalPadding.second.intValue());
-
- // 2 pixel padding at the start and 0 at the end
- assertEquals(2, pi.verticalPadding.first.intValue());
- assertEquals(0, pi.verticalPadding.second.intValue());
- }
-
- // make sure that the presence of layout bound markers doesn't affect patch/padding info
- public void testIgnoreLayoutBoundMarkers() {
- BufferedImage image = createImage(new String[] {
- "0RR3**6789",
- "R........R",
- "*.........",
- "*........*",
- "4........*",
- "5***456R89",
- });
- PatchInfo pi = new PatchInfo(image);
-
- assertFalse(pi.horizontalStartWithPatch);
-
- assertEquals(1, pi.patches.size());
- assertEquals(2, pi.verticalPatches.size());
- assertEquals(2, pi.horizontalPatches.size());
- }
-}
diff --git a/hierarchyviewer2/.gitignore b/hierarchyviewer2/.gitignore
deleted file mode 100644
index 7c59e86..0000000
--- a/hierarchyviewer2/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-app/bin
-libs/hierarchyviewerlib/bin
-
diff --git a/hierarchyviewer2/Android.mk b/hierarchyviewer2/Android.mk
deleted file mode 100644
index 411fbba..0000000
--- a/hierarchyviewer2/Android.mk
+++ /dev/null
@@ -1,17 +0,0 @@
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-HIERARCHYVIEWER_LOCAL_DIR := $(call my-dir)
-include $(HIERARCHYVIEWER_LOCAL_DIR)/app/Android.mk
-include $(HIERARCHYVIEWER_LOCAL_DIR)/libs/Android.mk
diff --git a/hierarchyviewer2/MODULE_LICENSE_APACHE2 b/hierarchyviewer2/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/hierarchyviewer2/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/hierarchyviewer2/app/.classpath b/hierarchyviewer2/app/.classpath
deleted file mode 100644
index 2d4a26d..0000000
--- a/hierarchyviewer2/app/.classpath
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/hierarchyviewerlib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/sdklib"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/swtmenubar.jar" sourcepath="/ANDROID_SRC/sdk/swtmenubar/src"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/linux-x86/swt/swt.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.core.commands_3.6.0.I20100512-1500.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.equinox.common_3.6.0.v20100503.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.jface_3.6.2.M20110210-1200.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/hierarchyviewer2/app/.gitignore b/hierarchyviewer2/app/.gitignore
deleted file mode 100644
index e660fd9..0000000
--- a/hierarchyviewer2/app/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bin/
diff --git a/hierarchyviewer2/app/.project b/hierarchyviewer2/app/.project
deleted file mode 100644
index 9a663d4..0000000
--- a/hierarchyviewer2/app/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>hierarchyviewer</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/hierarchyviewer2/app/.settings/README.txt b/hierarchyviewer2/app/.settings/README.txt
deleted file mode 100644
index 9120b20..0000000
--- a/hierarchyviewer2/app/.settings/README.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Copy this in eclipse project as a .settings folder at the root.
-This ensure proper compilation compliance and warning/error levels. \ No newline at end of file
diff --git a/hierarchyviewer2/app/.settings/org.eclipse.jdt.core.prefs b/hierarchyviewer2/app/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/hierarchyviewer2/app/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/hierarchyviewer2/app/Android.mk b/hierarchyviewer2/app/Android.mk
deleted file mode 100644
index 6d6b4a2..0000000
--- a/hierarchyviewer2/app/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_RESOURCE_DIRS := src
-
-LOCAL_JAR_MANIFEST := etc/manifest.txt
-
-LOCAL_JAVA_LIBRARIES := \
- common \
- ddmlib \
- ddmuilib \
- hierarchyviewerlib \
- swt \
- org.eclipse.jface_3.6.2.M20110210-1200 \
- org.eclipse.core.commands_3.6.0.I20100512-1500 \
- sdklib \
- swtmenubar
-
-LOCAL_MODULE := hierarchyviewer2
-LOCAL_MODULE_TAGS := debug
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-# Build all sub-directories
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/hierarchyviewer2/app/NOTICE b/hierarchyviewer2/app/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/hierarchyviewer2/app/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/hierarchyviewer2/app/README b/hierarchyviewer2/app/README
deleted file mode 100755
index c00ef99..0000000
--- a/hierarchyviewer2/app/README
+++ /dev/null
@@ -1,69 +0,0 @@
-Using the Eclipse project HierarchyViewer
------------------------------------------
-
-HierarchyViewer requires some external libraries to compile.
-If you build HierarchyViewer using the makefile, you have nothing
-to configure. However if you want to develop on HierarchyViewer
-using Eclipse, you need to perform the following configuration.
-
-
--------
-1- Projects required in Eclipse
--------
-
-To run HierarchyViewer from Eclipse, you need to import the following 5 projects:
-
- - sdk/hierarchyviewer2/app
- - sdk/hierarchyviewer2/libs/hierarchyviewerlib/
- - sdk/ddms/libs/ddmlib
- - sdk/ddms/libs/ddmuilib
- - sdk/sdkmanager/libs/sdklib
-
-
--------
-2- HierarchyViewer requires some SWT JARs to compile.
--------
-
-SWT is available in the tree under prebuild/<platform>/swt
-
-Because the build path cannot contain relative path that are not inside
-the project directory, the .classpath file references a user library
-called ANDROID_SWT.
-
-In order to compile the project:
-- Open Preferences > Java > Build Path > User Libraries
-
-- Create a new user library named ANDROID_SWT
-- Add the following 4 JAR files:
-
- - prebuilt/<platform>/swt/swt.jar
- - prebuilt/common/eclipse/org.eclipse.core.commands_3.*.jar
- - prebuilt/common/eclipse/org.eclipse.equinox.common_3.*.jar
- - prebuilt/common/eclipse/org.eclipse.jface_3.*.jar
-
-
--------
-3- HierarchyViewer also requires the compiled SwtMenuBar library.
--------
-
-Build the swtmenubar library:
-$ cd $TOP (top of Android tree)
-$ . build/envsetup.sh && lunch sdk-eng
-$ sdk/eclipse/scripts/create_sdkman_symlinks.sh
-
-Define a classpath variable in Eclipse:
-- Open Preferences > Java > Build Path > Classpath Variables
-- Create a new classpath variable named ANDROID_OUT_FRAMEWORK
-- Set its folder value to <Android tree>/out/host/<platform>/framework
-- Create a new classpath variable named ANDROID_SRC
-- Set its folder value to <Android tree>
-
-You might need to clean the ddms project (Project > Clean...) after
-you add the new classpath variable, otherwise previous errors might not
-go away automatically.
-
-The ANDROID_SRC part should be optional. It allows you to have access to
-the SwtMenuBar generic parts from the Java editor.
-
---
-EOF
diff --git a/hierarchyviewer2/app/etc/Android.mk b/hierarchyviewer2/app/etc/Android.mk
deleted file mode 100644
index 07f716c..0000000
--- a/hierarchyviewer2/app/etc/Android.mk
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_PREBUILT_EXECUTABLES := hierarchyviewer
-LOCAL_MODULE_TAGS := debug
-include $(BUILD_HOST_PREBUILT)
diff --git a/hierarchyviewer2/app/etc/hierarchyviewer b/hierarchyviewer2/app/etc/hierarchyviewer
deleted file mode 100755
index a0cc5f9..0000000
--- a/hierarchyviewer2/app/etc/hierarchyviewer
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/bin/sh
-# Copyright 2008, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-
-prog="$0"
-while [ -h "${prog}" ]; do
- newProg=`/bin/ls -ld "${prog}"`
- newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
- if expr "x${newProg}" : 'x/' >/dev/null; then
- prog="${newProg}"
- else
- progdir=`dirname "${prog}"`
- prog="${progdir}/${newProg}"
- fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/`basename "${prog}"`
-cd "${oldwd}"
-
-jarfile=hierarchyviewer2.jar
-frameworkdir="$progdir"
-libdir="$progdir"
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/tools/lib
- libdir=`dirname "$progdir"`/tools/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/framework
- libdir=`dirname "$progdir"`/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- echo `basename "$prog"`": can't find $jarfile"
- exit 1
-fi
-
-
-# Check args.
-if [ debug = "$1" ]; then
- # add this in for debugging
- java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
- shift 1
-else
- java_debug=
-fi
-
-javaCmd="java"
-
-# Mac OS X needs an additional arg, or you get an "illegal thread" complaint.
-if [ `uname` = "Darwin" ]; then
- os_opts="-XstartOnFirstThread"
-else
- os_opts=
-fi
-
-if [ `uname` = "Linux" ]; then
- export GDK_NATIVE_WINDOWS=true
-fi
-
-jarpath="$frameworkdir/$jarfile:$frameworkdir/swtmenubar.jar"
-
-# Figure out the path to the swt.jar for the current architecture.
-# if ANDROID_SWT is defined, then just use this.
-# else, if running in the Android source tree, then look for the correct swt folder in prebuilt
-# else, look for the correct swt folder in the SDK under tools/lib/
-swtpath=""
-if [ -n "$ANDROID_SWT" ]; then
- swtpath="$ANDROID_SWT"
-else
- vmarch=`${javaCmd} -jar "${frameworkdir}"/archquery.jar`
- if [ -n "$ANDROID_BUILD_TOP" ]; then
- osname=`uname -s | tr A-Z a-z`
- swtpath="${ANDROID_BUILD_TOP}/prebuilts/tools/${osname}-${vmarch}/swt"
- else
- swtpath="${frameworkdir}/${vmarch}"
- fi
-fi
-
-if [ ! -d "$swtpath" ]; then
- echo "SWT folder '${swtpath}' does not exist."
- echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform."
- exit 1
-fi
-
-if [ -x $progdir/monitor ]; then
- echo "The standalone version of hieararchyviewer is deprecated."
- echo "Please use Android Device Monitor (tools/monitor) instead."
-fi
-# need to use "java.ext.dirs" because "-jar" causes classpath to be ignored
-# might need more memory, e.g. -Xmx128M
-exec "$javaCmd" \
- -Xmx512M $os_opts $java_debug \
- -Dcom.android.hierarchyviewer.bindir="$progdir" \
- -classpath "$jarpath:$swtpath/swt.jar" \
- com.android.hierarchyviewer.HierarchyViewerApplication "$@"
diff --git a/hierarchyviewer2/app/etc/hierarchyviewer.bat b/hierarchyviewer2/app/etc/hierarchyviewer.bat
deleted file mode 100755
index 432294d..0000000
--- a/hierarchyviewer2/app/etc/hierarchyviewer.bat
+++ /dev/null
@@ -1,75 +0,0 @@
-@echo off
-rem Copyright (C) 2008 The Android Open Source Project
-rem
-rem Licensed under the Apache License, Version 2.0 (the "License");
-rem you may not use this file except in compliance with the License.
-rem You may obtain a copy of the License at
-rem
-rem http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-
-rem don't modify the caller's environment
-setlocal
-
-rem Set up prog to be the path of this script, including following symlinks,
-rem and set up progdir to be the fully-qualified pathname of its directory.
-set prog=%~f0
-
-rem Change current directory and drive to where the script is, to avoid
-rem issues with directories containing whitespaces.
-cd /d %~dp0
-
-rem Get the CWD as a full path with short names only (without spaces)
-for %%i in ("%cd%") do set prog_dir=%%~fsi
-
-rem Check we have a valid Java.exe in the path.
-set java_exe=
-call lib\find_java.bat
-if not defined java_exe goto :EOF
-
-set jarfile=hierarchyviewer2.jar
-set frameworkdir=
-set libdir=
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=lib\
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=..\framework\
-
-:JarFileOk
-
-if debug NEQ "%1" goto NoDebug
- set java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
- shift 1
-:NoDebug
-
-set jarpath=%frameworkdir%%jarfile%;%frameworkdir%hierarchyviewerlib.jar;%frameworkdir%swtmenubar.jar
-
-if not defined ANDROID_SWT goto QueryArch
- set swt_path=%ANDROID_SWT%
- goto SwtDone
-
-:QueryArch
-
- for /f %%a in ('%java_exe% -jar %frameworkdir%archquery.jar') do set swt_path=%frameworkdir%%%a
-
-:SwtDone
-
-if exist %swt_path% goto SetPath
- echo SWT folder '%swt_path%' does not exist.
- echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
- exit /B
-
-:SetPath
-
-echo The standalone version of hieararchyviewer is deprecated.
-echo Please use Android Device Monitor (tools/monitor.bat) instead.
-call %java_exe% %java_debug% -Xmx512m -Dcom.android.hierarchyviewer.bindir=%prog_dir% -classpath "%jarpath%;%swt_path%\swt.jar" com.android.hierarchyviewer.HierarchyViewerApplication %*
-
-
diff --git a/hierarchyviewer2/app/etc/manifest.txt b/hierarchyviewer2/app/etc/manifest.txt
deleted file mode 100644
index 68222bd..0000000
--- a/hierarchyviewer2/app/etc/manifest.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Main-Class: com.android.hierarchyviewer.HierarchyViewerApplication
-Class-Path: ddmlib.jar ddmuilib.jar hierarchyviewerlib.jar sdklib.jar org.eclipse.jface_3.6.2.M20110210-1200.jar org.eclipse.core.commands_3.6.0.I20100512-1500.jar org.eclipse.equinox.common_3.6.0.v20100503.jar guava-tools.jar
diff --git a/hierarchyviewer2/app/src/com/android/hierarchyviewer/AboutDialog.java b/hierarchyviewer2/app/src/com/android/hierarchyviewer/AboutDialog.java
deleted file mode 100644
index 9968788..0000000
--- a/hierarchyviewer2/app/src/com/android/hierarchyviewer/AboutDialog.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewer;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CLabel;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-public class AboutDialog extends Dialog {
- private Image mAboutImage;
-
- private Image mSmallImage;
-
- public AboutDialog(Shell shell) {
- super(shell);
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mSmallImage = imageLoader.loadImage("sdk-hierarchyviewer-16.png", Display.getDefault()); //$NON-NLS-1$
- mAboutImage = imageLoader.loadImage("sdk-hierarchyviewer-128.png", Display.getDefault()); //$NON-NLS-1$
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite control = new Composite(parent, SWT.NONE);
- control.setLayout(new GridLayout(2, true));
- Composite imageControl = new Composite(control, SWT.BORDER);
- imageControl.setLayout(new FillLayout());
- imageControl.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- Label imageLabel = new Label(imageControl, SWT.CENTER);
- imageLabel.setImage(mAboutImage);
-
- CLabel textLabel = new CLabel(control, SWT.NONE);
- // TODO: update with new year date (search this to find other occurrences to update)
- textLabel.setText("Hierarchy Viewer\nCopyright 2012, The Android Open Source Project\nAll Rights Reserved.");
- textLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, true, true));
- getShell().setText("About...");
- getShell().setImage(mSmallImage);
- return control;
-
- }
-}
diff --git a/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplication.java b/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplication.java
deleted file mode 100644
index 8983f67..0000000
--- a/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplication.java
+++ /dev/null
@@ -1,942 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewer;
-
-import com.android.ddmlib.Log;
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewer.actions.AboutAction;
-import com.android.hierarchyviewer.actions.LoadAllViewsAction;
-import com.android.hierarchyviewer.actions.QuitAction;
-import com.android.hierarchyviewer.actions.ShowOverlayAction;
-import com.android.hierarchyviewer.util.ActionButton;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-import com.android.hierarchyviewerlib.actions.CapturePSDAction;
-import com.android.hierarchyviewerlib.actions.DisplayViewAction;
-import com.android.hierarchyviewerlib.actions.DumpDisplayListAction;
-import com.android.hierarchyviewerlib.actions.InspectScreenshotAction;
-import com.android.hierarchyviewerlib.actions.InvalidateAction;
-import com.android.hierarchyviewerlib.actions.LoadOverlayAction;
-import com.android.hierarchyviewerlib.actions.LoadViewHierarchyAction;
-import com.android.hierarchyviewerlib.actions.PixelPerfectAutoRefreshAction;
-import com.android.hierarchyviewerlib.actions.ProfileNodesAction;
-import com.android.hierarchyviewerlib.actions.RefreshPixelPerfectAction;
-import com.android.hierarchyviewerlib.actions.RefreshPixelPerfectTreeAction;
-import com.android.hierarchyviewerlib.actions.RefreshViewAction;
-import com.android.hierarchyviewerlib.actions.RefreshWindowsAction;
-import com.android.hierarchyviewerlib.actions.RequestLayoutAction;
-import com.android.hierarchyviewerlib.actions.SavePixelPerfectAction;
-import com.android.hierarchyviewerlib.actions.SaveTreeViewAction;
-import com.android.hierarchyviewerlib.device.IHvDevice;
-import com.android.hierarchyviewerlib.models.DeviceSelectionModel;
-import com.android.hierarchyviewerlib.models.PixelPerfectModel;
-import com.android.hierarchyviewerlib.models.PixelPerfectModel.IImageChangeListener;
-import com.android.hierarchyviewerlib.models.TreeViewModel;
-import com.android.hierarchyviewerlib.models.TreeViewModel.ITreeChangeListener;
-import com.android.hierarchyviewerlib.ui.DeviceSelector;
-import com.android.hierarchyviewerlib.ui.InvokeMethodPrompt;
-import com.android.hierarchyviewerlib.ui.LayoutViewer;
-import com.android.hierarchyviewerlib.ui.PixelPerfect;
-import com.android.hierarchyviewerlib.ui.PixelPerfectControls;
-import com.android.hierarchyviewerlib.ui.PixelPerfectLoupe;
-import com.android.hierarchyviewerlib.ui.PixelPerfectPixelPanel;
-import com.android.hierarchyviewerlib.ui.PixelPerfectTree;
-import com.android.hierarchyviewerlib.ui.PropertyViewer;
-import com.android.hierarchyviewerlib.ui.TreeView;
-import com.android.hierarchyviewerlib.ui.TreeViewControls;
-import com.android.hierarchyviewerlib.ui.TreeViewOverview;
-import com.android.menubar.IMenuBarEnhancer;
-import com.android.menubar.IMenuBarEnhancer.MenuBarMode;
-import com.android.menubar.MenuBarEnhancer;
-
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.ProgressBar;
-import org.eclipse.swt.widgets.Shell;
-
-public class HierarchyViewerApplication extends ApplicationWindow {
-
- private static final String APP_NAME = "Hierarchy Viewer";
- private static final int INITIAL_WIDTH = 1280;
- private static final int INITIAL_HEIGHT = 800;
-
- private static HierarchyViewerApplication sMainWindow;
-
- // Images for moving between the 3 main windows.
- private Image mDeviceViewImage;
- private Image mPixelPerfectImage;
- private Image mTreeViewImage;
- private Image mDeviceViewSelectedImage;
- private Image mPixelPerfectSelectedImage;
- private Image mTreeViewSelectedImage;
-
- // And their buttons
- private Button mTreeViewButton;
- private Button mPixelPerfectButton;
- private Button mDeviceViewButton;
-
- private Label mProgressLabel;
- private ProgressBar mProgressBar;
- private String mProgressString;
-
- private Composite mDeviceSelectorPanel;
- private Composite mTreeViewPanel;
- private Composite mPixelPerfectPanel;
- private StackLayout mMainWindowStackLayout;
- private DeviceSelector mDeviceSelector;
- private Composite mStatusBar;
- private TreeView mTreeView;
- private Composite mMainWindow;
- private Image mOnBlackImage;
- private Image mOnWhiteImage;
- private Button mOnBlackWhiteButton;
- private Button mShowExtras;
- private LayoutViewer mLayoutViewer;
- private PixelPerfectLoupe mPixelPerfectLoupe;
- private Composite mTreeViewControls;
- private InvokeMethodPrompt mInvokeMethodPrompt;
-
- private ActionButton dumpDisplayList;
-
- private HierarchyViewerDirector mDirector;
-
- /*
- * If a thread bails with an uncaught exception, bring the whole
- * thing down.
- */
- private static class UncaughtHandler implements Thread.UncaughtExceptionHandler {
- @Override
- public void uncaughtException(Thread t, Throwable e) {
- Log.e("HierarchyViewer", "shutting down due to uncaught exception");
- Log.e("HierarchyViewer", e);
- System.exit(1);
- }
- }
-
- public static final HierarchyViewerApplication getMainWindow() {
- return sMainWindow;
- }
-
- public HierarchyViewerApplication() {
- super(null /*shell*/);
-
- sMainWindow = this;
-
- addMenuBar();
- }
-
- @Override
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText(APP_NAME);
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- Image image = imageLoader.loadImage("sdk-hierarchyviewer-128.png", Display.getDefault()); //$NON-NLS-1$
- shell.setImage(image);
- }
-
- @Override
- public MenuManager createMenuManager() {
- return new MenuManager();
- }
-
- public void run() {
- setBlockOnOpen(true);
-
- try {
- open();
- } catch (SWTException e) {
- // Ignore "widget disposed" errors after we closed.
- if (!getShell().isDisposed()) {
- throw e;
- }
- }
-
- TreeViewModel.getModel().removeTreeChangeListener(mTreeChangeListener);
- PixelPerfectModel.getModel().removeImageChangeListener(mImageChangeListener);
-
- ImageLoader.dispose();
- mDirector.stopListenForDevices();
- mDirector.stopDebugBridge();
- mDirector.terminate();
- }
-
- @Override
- protected void initializeBounds() {
- Rectangle monitorArea = Display.getDefault().getPrimaryMonitor().getBounds();
- getShell().setSize(Math.min(monitorArea.width, INITIAL_WIDTH),
- Math.min(monitorArea.height, INITIAL_HEIGHT));
- getShell().setLocation(monitorArea.x + (monitorArea.width - INITIAL_WIDTH) / 2,
- monitorArea.y + (monitorArea.height - INITIAL_HEIGHT) / 2);
- }
-
- private void loadResources() {
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mTreeViewImage = imageLoader.loadImage("tree-view.png", Display.getDefault()); //$NON-NLS-1$
- mTreeViewSelectedImage =
- imageLoader.loadImage("tree-view-selected.png", Display.getDefault()); //$NON-NLS-1$
- mPixelPerfectImage = imageLoader.loadImage("pixel-perfect-view.png", Display.getDefault()); //$NON-NLS-1$
- mPixelPerfectSelectedImage =
- imageLoader.loadImage("pixel-perfect-view-selected.png", Display.getDefault()); //$NON-NLS-1$
- mDeviceViewImage = imageLoader.loadImage("device-view.png", Display.getDefault()); //$NON-NLS-1$
- mDeviceViewSelectedImage =
- imageLoader.loadImage("device-view-selected.png", Display.getDefault()); //$NON-NLS-1$
- mOnBlackImage = imageLoader.loadImage("on-black.png", Display.getDefault()); //$NON-NLS-1$
- mOnWhiteImage = imageLoader.loadImage("on-white.png", Display.getDefault()); //$NON-NLS-1$
- }
-
- @Override
- protected Control createContents(Composite parent) {
- // create this only once the window is opened to please SWT on Mac
- mDirector = HierarchyViewerApplicationDirector.createDirector();
- mDirector.initDebugBridge();
- mDirector.startListenForDevices();
- mDirector.populateDeviceSelectionModel();
-
- TreeViewModel.getModel().addTreeChangeListener(mTreeChangeListener);
- PixelPerfectModel.getModel().addImageChangeListener(mImageChangeListener);
-
- loadResources();
-
- Composite control = new Composite(parent, SWT.NONE);
- GridLayout mainLayout = new GridLayout();
- mainLayout.marginHeight = mainLayout.marginWidth = 0;
- mainLayout.verticalSpacing = mainLayout.horizontalSpacing = 0;
- control.setLayout(mainLayout);
- mMainWindow = new Composite(control, SWT.NONE);
- mMainWindow.setLayoutData(new GridData(GridData.FILL_BOTH));
- mMainWindowStackLayout = new StackLayout();
- mMainWindow.setLayout(mMainWindowStackLayout);
-
- buildDeviceSelectorPanel(mMainWindow);
- buildTreeViewPanel(mMainWindow);
- buildPixelPerfectPanel(mMainWindow);
-
- buildStatusBar(control);
-
- showDeviceSelector();
-
- return control;
- }
-
-
- private void buildStatusBar(Composite parent) {
- mStatusBar = new Composite(parent, SWT.NONE);
- mStatusBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- FormLayout statusBarLayout = new FormLayout();
- statusBarLayout.marginHeight = statusBarLayout.marginWidth = 2;
-
- mStatusBar.setLayout(statusBarLayout);
-
- mDeviceViewButton = new Button(mStatusBar, SWT.TOGGLE);
- mDeviceViewButton.setImage(mDeviceViewImage);
- mDeviceViewButton.setToolTipText("Switch to the window selection view");
- mDeviceViewButton.addSelectionListener(deviceViewButtonSelectionListener);
- FormData deviceViewButtonFormData = new FormData();
- deviceViewButtonFormData.left = new FormAttachment();
- mDeviceViewButton.setLayoutData(deviceViewButtonFormData);
-
- mTreeViewButton = new Button(mStatusBar, SWT.TOGGLE);
- mTreeViewButton.setImage(mTreeViewImage);
- mTreeViewButton.setEnabled(false);
- mTreeViewButton.setToolTipText("Switch to the tree view");
- mTreeViewButton.addSelectionListener(treeViewButtonSelectionListener);
- FormData treeViewButtonFormData = new FormData();
- treeViewButtonFormData.left = new FormAttachment(mDeviceViewButton, 2);
- mTreeViewButton.setLayoutData(treeViewButtonFormData);
-
- mPixelPerfectButton = new Button(mStatusBar, SWT.TOGGLE);
- mPixelPerfectButton.setImage(mPixelPerfectImage);
- mPixelPerfectButton.setEnabled(false);
- mPixelPerfectButton.setToolTipText("Switch to the pixel perfect view");
- mPixelPerfectButton.addSelectionListener(pixelPerfectButtonSelectionListener);
- FormData pixelPerfectButtonFormData = new FormData();
- pixelPerfectButtonFormData.left = new FormAttachment(mTreeViewButton, 2);
- mPixelPerfectButton.setLayoutData(pixelPerfectButtonFormData);
-
- // Tree View control panel...
- mTreeViewControls = new TreeViewControls(mStatusBar);
- FormData treeViewControlsFormData = new FormData();
- treeViewControlsFormData.left = new FormAttachment(mPixelPerfectButton, 2);
- treeViewControlsFormData.top = new FormAttachment(mTreeViewButton, 0, SWT.CENTER);
- treeViewControlsFormData.width = 552;
- mTreeViewControls.setLayoutData(treeViewControlsFormData);
-
- // Progress stuff
- mProgressLabel = new Label(mStatusBar, SWT.RIGHT);
-
- mProgressBar = new ProgressBar(mStatusBar, SWT.HORIZONTAL | SWT.INDETERMINATE | SWT.SMOOTH);
- FormData progressBarFormData = new FormData();
- progressBarFormData.right = new FormAttachment(100, 0);
- progressBarFormData.top = new FormAttachment(mTreeViewButton, 0, SWT.CENTER);
- mProgressBar.setLayoutData(progressBarFormData);
-
- FormData progressLabelFormData = new FormData();
- progressLabelFormData.right = new FormAttachment(mProgressBar, -2);
- progressLabelFormData.top = new FormAttachment(mTreeViewButton, 0, SWT.CENTER);
- mProgressLabel.setLayoutData(progressLabelFormData);
-
- if (mProgressString == null) {
- mProgressLabel.setVisible(false);
- mProgressBar.setVisible(false);
- } else {
- mProgressLabel.setText(mProgressString);
- }
- }
-
- private void buildDeviceSelectorPanel(Composite parent) {
- mDeviceSelectorPanel = new Composite(parent, SWT.NONE);
- GridLayout gridLayout = new GridLayout();
- gridLayout.marginWidth = gridLayout.marginHeight = 0;
- gridLayout.horizontalSpacing = gridLayout.verticalSpacing = 0;
- mDeviceSelectorPanel.setLayout(gridLayout);
-
- Composite buttonPanel = new Composite(mDeviceSelectorPanel, SWT.NONE);
- buttonPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- GridLayout buttonLayout = new GridLayout();
- buttonLayout.marginWidth = buttonLayout.marginHeight = 0;
- buttonLayout.horizontalSpacing = buttonLayout.verticalSpacing = 0;
- buttonPanel.setLayout(buttonLayout);
-
- Composite innerButtonPanel = new Composite(buttonPanel, SWT.NONE);
- innerButtonPanel.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- GridLayout innerButtonPanelLayout = new GridLayout(3, true);
- innerButtonPanelLayout.marginWidth = innerButtonPanelLayout.marginHeight = 2;
- innerButtonPanelLayout.horizontalSpacing = innerButtonPanelLayout.verticalSpacing = 2;
- innerButtonPanel.setLayout(innerButtonPanelLayout);
-
- ActionButton refreshWindows =
- new ActionButton(innerButtonPanel, RefreshWindowsAction.getAction());
- refreshWindows.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- ActionButton loadViewHierarchyButton =
- new ActionButton(innerButtonPanel, LoadViewHierarchyAction.getAction());
- loadViewHierarchyButton.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- ActionButton inspectScreenshotButton =
- new ActionButton(innerButtonPanel, InspectScreenshotAction.getAction());
- inspectScreenshotButton.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Composite deviceSelectorContainer = new Composite(mDeviceSelectorPanel, SWT.BORDER);
- deviceSelectorContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
- deviceSelectorContainer.setLayout(new FillLayout());
- mDeviceSelector = new DeviceSelector(deviceSelectorContainer, true, true);
- }
-
- public void buildTreeViewPanel(Composite parent) {
- mTreeViewPanel = new Composite(parent, SWT.NONE);
- GridLayout gridLayout = new GridLayout();
- gridLayout.marginWidth = gridLayout.marginHeight = 0;
- gridLayout.horizontalSpacing = gridLayout.verticalSpacing = 0;
- mTreeViewPanel.setLayout(gridLayout);
-
- Composite buttonPanel = new Composite(mTreeViewPanel, SWT.NONE);
- buttonPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- GridLayout buttonLayout = new GridLayout();
- buttonLayout.marginWidth = buttonLayout.marginHeight = 0;
- buttonLayout.horizontalSpacing = buttonLayout.verticalSpacing = 0;
- buttonPanel.setLayout(buttonLayout);
-
- Composite innerButtonPanel = new Composite(buttonPanel, SWT.NONE);
- innerButtonPanel.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- GridLayout innerButtonPanelLayout = new GridLayout(8, true);
- innerButtonPanelLayout.marginWidth = innerButtonPanelLayout.marginHeight = 2;
- innerButtonPanelLayout.horizontalSpacing = innerButtonPanelLayout.verticalSpacing = 2;
- innerButtonPanel.setLayout(innerButtonPanelLayout);
-
- ActionButton saveTreeView =
- new ActionButton(innerButtonPanel, SaveTreeViewAction.getAction(getShell()));
- saveTreeView.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- ActionButton capturePSD =
- new ActionButton(innerButtonPanel, CapturePSDAction.getAction(getShell()));
- capturePSD.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- ActionButton refreshViewAction =
- new ActionButton(innerButtonPanel, RefreshViewAction.getAction());
- refreshViewAction.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- ActionButton displayView =
- new ActionButton(innerButtonPanel, DisplayViewAction.getAction(getShell()));
- displayView.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- ActionButton invalidate = new ActionButton(innerButtonPanel, InvalidateAction.getAction());
- invalidate.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- ActionButton requestLayout =
- new ActionButton(innerButtonPanel, RequestLayoutAction.getAction());
- requestLayout.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- dumpDisplayList =
- new ActionButton(innerButtonPanel, DumpDisplayListAction.getAction());
- dumpDisplayList.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- ActionButton profileNodes =
- new ActionButton(innerButtonPanel, ProfileNodesAction.getAction());
- profileNodes.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- SashForm mainSash = new SashForm(mTreeViewPanel, SWT.HORIZONTAL | SWT.SMOOTH);
- mainSash.setLayoutData(new GridData(GridData.FILL_BOTH));
- Composite treeViewContainer = new Composite(mainSash, SWT.BORDER);
- treeViewContainer.setLayout(new FillLayout());
- mTreeView = new TreeView(treeViewContainer);
-
- SashForm sideSash = new SashForm(mainSash, SWT.VERTICAL | SWT.SMOOTH);
-
- mainSash.SASH_WIDTH = 4;
- mainSash.setWeights(new int[] {
- 7, 3
- });
-
- Composite treeViewOverviewContainer = new Composite(sideSash, SWT.BORDER);
- treeViewOverviewContainer.setLayout(new FillLayout());
- new TreeViewOverview(treeViewOverviewContainer);
-
- Composite propertyViewerContainer = new Composite(sideSash, SWT.BORDER);
- propertyViewerContainer.setLayout(new GridLayout());
-
- PropertyViewer pv = new PropertyViewer(propertyViewerContainer);
- pv.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- mInvokeMethodPrompt = new InvokeMethodPrompt(propertyViewerContainer);
- mInvokeMethodPrompt.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Composite layoutViewerContainer = new Composite(sideSash, SWT.NONE);
- GridLayout layoutViewerLayout = new GridLayout();
- layoutViewerLayout.marginWidth = layoutViewerLayout.marginHeight = 0;
- layoutViewerLayout.horizontalSpacing = layoutViewerLayout.verticalSpacing = 1;
- layoutViewerContainer.setLayout(layoutViewerLayout);
-
- Composite fullButtonBar = new Composite(layoutViewerContainer, SWT.NONE);
- fullButtonBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- GridLayout fullButtonBarLayout = new GridLayout(2, false);
- fullButtonBarLayout.marginWidth = fullButtonBarLayout.marginHeight = 0;
- fullButtonBarLayout.marginRight = 2;
- fullButtonBarLayout.horizontalSpacing = fullButtonBarLayout.verticalSpacing = 0;
- fullButtonBar.setLayout(fullButtonBarLayout);
-
- Composite buttonBar = new Composite(fullButtonBar, SWT.NONE);
- buttonBar.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
- rowLayout.marginLeft =
- rowLayout.marginRight = rowLayout.marginTop = rowLayout.marginBottom = 0;
- rowLayout.pack = true;
- rowLayout.center = true;
- buttonBar.setLayout(rowLayout);
-
- mOnBlackWhiteButton = new Button(buttonBar, SWT.PUSH);
- mOnBlackWhiteButton.setImage(mOnWhiteImage);
- mOnBlackWhiteButton.addSelectionListener(onBlackWhiteSelectionListener);
- mOnBlackWhiteButton.setToolTipText("Change layout viewer background color");
-
- mShowExtras = new Button(buttonBar, SWT.CHECK);
- mShowExtras.setText("Show Extras");
- mShowExtras.addSelectionListener(showExtrasSelectionListener);
- mShowExtras.setToolTipText("Show images");
-
- ActionButton loadAllViewsButton =
- new ActionButton(fullButtonBar, LoadAllViewsAction.getAction());
- loadAllViewsButton.setLayoutData(new GridData(GridData.END, GridData.CENTER, true, true));
- loadAllViewsButton.addSelectionListener(loadAllViewsSelectionListener);
-
- Composite layoutViewerMainContainer = new Composite(layoutViewerContainer, SWT.BORDER);
- layoutViewerMainContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
- layoutViewerMainContainer.setLayout(new FillLayout());
- mLayoutViewer = new LayoutViewer(layoutViewerMainContainer);
-
- sideSash.SASH_WIDTH = 4;
- sideSash.setWeights(new int[] {
- 238, 332, 416
- });
-
- }
-
- private void buildPixelPerfectPanel(Composite parent) {
- mPixelPerfectPanel = new Composite(parent, SWT.NONE);
- GridLayout gridLayout = new GridLayout();
- gridLayout.marginWidth = gridLayout.marginHeight = 0;
- gridLayout.horizontalSpacing = gridLayout.verticalSpacing = 0;
- mPixelPerfectPanel.setLayout(gridLayout);
-
- Composite buttonPanel = new Composite(mPixelPerfectPanel, SWT.NONE);
- buttonPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- GridLayout buttonLayout = new GridLayout();
- buttonLayout.marginWidth = buttonLayout.marginHeight = 0;
- buttonLayout.horizontalSpacing = buttonLayout.verticalSpacing = 0;
- buttonPanel.setLayout(buttonLayout);
-
- Composite innerButtonPanel = new Composite(buttonPanel, SWT.NONE);
- innerButtonPanel.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- GridLayout innerButtonPanelLayout = new GridLayout(6, true);
- innerButtonPanelLayout.marginWidth = innerButtonPanelLayout.marginHeight = 2;
- innerButtonPanelLayout.horizontalSpacing = innerButtonPanelLayout.verticalSpacing = 2;
- innerButtonPanel.setLayout(innerButtonPanelLayout);
-
- ActionButton saveTreeView =
- new ActionButton(innerButtonPanel, SavePixelPerfectAction.getAction(getShell()));
- saveTreeView.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- ActionButton refreshPixelPerfect =
- new ActionButton(innerButtonPanel, RefreshPixelPerfectAction.getAction());
- refreshPixelPerfect.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- ActionButton refreshPixelPerfectTree =
- new ActionButton(innerButtonPanel, RefreshPixelPerfectTreeAction.getAction());
- refreshPixelPerfectTree.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- ActionButton loadOverlay =
- new ActionButton(innerButtonPanel, LoadOverlayAction.getAction(getShell()));
- loadOverlay.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- ActionButton showInLoupe =
- new ActionButton(innerButtonPanel, ShowOverlayAction.getAction());
- showInLoupe.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- ActionButton autoRefresh =
- new ActionButton(innerButtonPanel, PixelPerfectAutoRefreshAction.getAction());
- autoRefresh.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- SashForm mainSash = new SashForm(mPixelPerfectPanel, SWT.HORIZONTAL | SWT.SMOOTH);
- mainSash.setLayoutData(new GridData(GridData.FILL_BOTH));
- mainSash.SASH_WIDTH = 4;
-
- Composite pixelPerfectTreeContainer = new Composite(mainSash, SWT.BORDER);
- pixelPerfectTreeContainer.setLayout(new FillLayout());
- new PixelPerfectTree(pixelPerfectTreeContainer);
-
- Composite pixelPerfectLoupeContainer = new Composite(mainSash, SWT.NONE);
- GridLayout loupeLayout = new GridLayout();
- loupeLayout.marginWidth = loupeLayout.marginHeight = 0;
- loupeLayout.horizontalSpacing = loupeLayout.verticalSpacing = 0;
- pixelPerfectLoupeContainer.setLayout(loupeLayout);
-
- Composite pixelPerfectLoupeBorder = new Composite(pixelPerfectLoupeContainer, SWT.BORDER);
- pixelPerfectLoupeBorder.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout pixelPerfectLoupeBorderGridLayout = new GridLayout();
- pixelPerfectLoupeBorderGridLayout.marginWidth =
- pixelPerfectLoupeBorderGridLayout.marginHeight = 0;
- pixelPerfectLoupeBorderGridLayout.horizontalSpacing =
- pixelPerfectLoupeBorderGridLayout.verticalSpacing = 0;
- pixelPerfectLoupeBorder.setLayout(pixelPerfectLoupeBorderGridLayout);
-
- mPixelPerfectLoupe = new PixelPerfectLoupe(pixelPerfectLoupeBorder);
- mPixelPerfectLoupe.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- PixelPerfectPixelPanel pixelPerfectPixelPanel =
- new PixelPerfectPixelPanel(pixelPerfectLoupeBorder);
- pixelPerfectPixelPanel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- PixelPerfectControls pixelPerfectControls =
- new PixelPerfectControls(pixelPerfectLoupeContainer);
- pixelPerfectControls.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
-
- Composite pixelPerfectContainer = new Composite(mainSash, SWT.BORDER);
- pixelPerfectContainer.setLayout(new FillLayout());
- new PixelPerfect(pixelPerfectContainer);
-
- mainSash.setWeights(new int[] {
- 272, 376, 346
- });
-
- }
-
- public void showOverlayInLoupe(boolean value) {
- mPixelPerfectLoupe.setShowOverlay(value);
- }
-
- // Shows the progress notification...
- public void startTask(final String taskName) {
- mProgressString = taskName;
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- if (mProgressLabel != null && mProgressBar != null) {
- mProgressLabel.setText(taskName);
- mProgressLabel.setVisible(true);
- mProgressBar.setVisible(true);
- mStatusBar.layout();
- }
- }
- });
- }
-
- // And hides it!
- public void endTask() {
- mProgressString = null;
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- if (mProgressLabel != null && mProgressBar != null) {
- mProgressLabel.setVisible(false);
- mProgressBar.setVisible(false);
- }
- }
- });
- }
-
- public void showDeviceSelector() {
- // Show the menus.
- MenuManager mm = getMenuBarManager();
- mm.removeAll();
-
- MenuManager file = new MenuManager("&File");
- IMenuBarEnhancer enhancer = MenuBarEnhancer.setupMenuManager(
- APP_NAME,
- getShell().getDisplay(),
- file,
- AboutAction.getAction(getShell()),
- null /*preferencesAction*/,
- QuitAction.getAction());
- if (enhancer.getMenuBarMode() == MenuBarMode.GENERIC) {
- mm.add(file);
- }
-
- MenuManager device = new MenuManager("&Devices");
- mm.add(device);
-
- device.add(RefreshWindowsAction.getAction());
- device.add(LoadViewHierarchyAction.getAction());
- device.add(InspectScreenshotAction.getAction());
-
- mm.updateAll(true);
-
- mDeviceViewButton.setSelection(true);
- mDeviceViewButton.setImage(mDeviceViewSelectedImage);
-
- mTreeViewButton.setSelection(false);
- mTreeViewButton.setImage(mTreeViewImage);
-
- mPixelPerfectButton.setSelection(false);
- mPixelPerfectButton.setImage(mPixelPerfectImage);
-
- mMainWindowStackLayout.topControl = mDeviceSelectorPanel;
-
- mMainWindow.layout();
-
- mDeviceSelector.setFocus();
-
- mTreeViewControls.setVisible(false);
- }
-
- public void showTreeView() {
- // Show the menus.
- MenuManager mm = getMenuBarManager();
- mm.removeAll();
-
- MenuManager file = new MenuManager("&File");
- IMenuBarEnhancer enhancer = MenuBarEnhancer.setupMenuManager(
- APP_NAME,
- getShell().getDisplay(),
- file,
- AboutAction.getAction(getShell()),
- null /*preferencesAction*/,
- QuitAction.getAction());
- if (enhancer.getMenuBarMode() == MenuBarMode.GENERIC) {
- mm.add(file);
- }
-
- MenuManager treeViewMenu = new MenuManager("&Tree View");
- mm.add(treeViewMenu);
-
- treeViewMenu.add(SaveTreeViewAction.getAction(getShell()));
- treeViewMenu.add(CapturePSDAction.getAction(getShell()));
- treeViewMenu.add(new Separator());
- treeViewMenu.add(RefreshViewAction.getAction());
- treeViewMenu.add(DisplayViewAction.getAction(getShell()));
-
- IHvDevice hvDevice = DeviceSelectionModel.getModel().getSelectedDevice();
- if (hvDevice.supportsDisplayListDump()) {
- treeViewMenu.add(DumpDisplayListAction.getAction());
- dumpDisplayList.setVisible(true);
- } else {
- dumpDisplayList.setVisible(false);
- }
- treeViewMenu.add(new Separator());
- treeViewMenu.add(InvalidateAction.getAction());
- treeViewMenu.add(RequestLayoutAction.getAction());
-
- mm.updateAll(true);
-
- mDeviceViewButton.setSelection(false);
- mDeviceViewButton.setImage(mDeviceViewImage);
-
- mTreeViewButton.setSelection(true);
- mTreeViewButton.setImage(mTreeViewSelectedImage);
-
- mInvokeMethodPrompt.setEnabled(hvDevice.isViewUpdateEnabled());
-
- mPixelPerfectButton.setSelection(false);
- mPixelPerfectButton.setImage(mPixelPerfectImage);
-
- mMainWindowStackLayout.topControl = mTreeViewPanel;
-
- mMainWindow.layout();
-
- mTreeView.setFocus();
-
- mTreeViewControls.setVisible(true);
- }
-
- public void showPixelPerfect() {
- // Show the menus.
- MenuManager mm = getMenuBarManager();
- mm.removeAll();
-
- MenuManager file = new MenuManager("&File");
- IMenuBarEnhancer enhancer = MenuBarEnhancer.setupMenuManager(
- APP_NAME,
- getShell().getDisplay(),
- file,
- AboutAction.getAction(getShell()),
- null /*preferencesAction*/,
- QuitAction.getAction());
- if (enhancer.getMenuBarMode() == MenuBarMode.GENERIC) {
- mm.add(file);
- }
-
- MenuManager pixelPerfect = new MenuManager("&Pixel Perfect");
- pixelPerfect.add(SavePixelPerfectAction.getAction(getShell()));
- pixelPerfect.add(RefreshPixelPerfectAction.getAction());
- pixelPerfect.add(RefreshPixelPerfectTreeAction.getAction());
- pixelPerfect.add(PixelPerfectAutoRefreshAction.getAction());
- pixelPerfect.add(new Separator());
- pixelPerfect.add(LoadOverlayAction.getAction(getShell()));
- pixelPerfect.add(ShowOverlayAction.getAction());
-
- mm.add(pixelPerfect);
-
- mm.updateAll(true);
-
- mDeviceViewButton.setSelection(false);
- mDeviceViewButton.setImage(mDeviceViewImage);
-
- mTreeViewButton.setSelection(false);
- mTreeViewButton.setImage(mTreeViewImage);
-
- mPixelPerfectButton.setSelection(true);
- mPixelPerfectButton.setImage(mPixelPerfectSelectedImage);
-
- mMainWindowStackLayout.topControl = mPixelPerfectPanel;
-
- mMainWindow.layout();
-
- mPixelPerfectLoupe.setFocus();
-
- mTreeViewControls.setVisible(false);
- }
-
- private SelectionListener deviceViewButtonSelectionListener = new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // pass
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- mDeviceViewButton.setSelection(true);
- showDeviceSelector();
- }
- };
-
- private SelectionListener treeViewButtonSelectionListener = new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // pass
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- mTreeViewButton.setSelection(true);
- showTreeView();
- }
- };
-
- private SelectionListener pixelPerfectButtonSelectionListener = new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // pass
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- mPixelPerfectButton.setSelection(true);
- showPixelPerfect();
- }
- };
-
- private SelectionListener onBlackWhiteSelectionListener = new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // pass
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mLayoutViewer.getOnBlack()) {
- mLayoutViewer.setOnBlack(false);
- mOnBlackWhiteButton.setImage(mOnBlackImage);
- } else {
- mLayoutViewer.setOnBlack(true);
- mOnBlackWhiteButton.setImage(mOnWhiteImage);
- }
- }
- };
-
- private SelectionListener showExtrasSelectionListener = new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // pass
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- mLayoutViewer.setShowExtras(mShowExtras.getSelection());
- }
- };
-
- private SelectionListener loadAllViewsSelectionListener = new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // pass
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- mShowExtras.setSelection(true);
- showExtrasSelectionListener.widgetSelected(null);
- }
- };
-
- private ITreeChangeListener mTreeChangeListener = new ITreeChangeListener() {
- @Override
- public void selectionChanged() {
- // pass
- }
-
- @Override
- public void treeChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- if (TreeViewModel.getModel().getTree() == null) {
- showDeviceSelector();
- mTreeViewButton.setEnabled(false);
- } else {
- showTreeView();
- mTreeViewButton.setEnabled(true);
- }
- }
- });
- }
-
- @Override
- public void viewportChanged() {
- // pass
- }
-
- @Override
- public void zoomChanged() {
- // pass
- }
- };
-
- private IImageChangeListener mImageChangeListener = new IImageChangeListener() {
-
- @Override
- public void crosshairMoved() {
- // pass
- }
-
- @Override
- public void treeChanged() {
- // pass
- }
-
- @Override
- public void imageChanged() {
- // pass
- }
-
- @Override
- public void imageLoaded() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- if (PixelPerfectModel.getModel().getImage() == null) {
- mPixelPerfectButton.setEnabled(false);
- showDeviceSelector();
- } else {
- mPixelPerfectButton.setEnabled(true);
- showPixelPerfect();
- }
- }
- });
- }
-
- @Override
- public void overlayChanged() {
- // pass
- }
-
- @Override
- public void overlayTransparencyChanged() {
- // pass
- }
-
- @Override
- public void selectionChanged() {
- // pass
- }
-
- @Override
- public void zoomChanged() {
- // pass
- }
-
- };
-
- public static void main(String[] args) {
- Thread.setDefaultUncaughtExceptionHandler(new UncaughtHandler());
-
- Display.setAppName("HierarchyViewer");
- new HierarchyViewerApplication().run();
- }
-}
diff --git a/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplicationDirector.java b/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplicationDirector.java
deleted file mode 100644
index 07fa917..0000000
--- a/hierarchyviewer2/app/src/com/android/hierarchyviewer/HierarchyViewerApplicationDirector.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewer;
-
-import com.android.SdkConstants;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import java.io.File;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * This is the application version of the director.
- */
-public class HierarchyViewerApplicationDirector extends HierarchyViewerDirector {
-
- private final ExecutorService mExecutor = Executors.newSingleThreadExecutor();
-
- public static HierarchyViewerDirector createDirector() {
- return sDirector = new HierarchyViewerApplicationDirector();
- }
-
- @Override
- public void terminate() {
- super.terminate();
- mExecutor.shutdown();
- }
-
- /*
- * Gets the location of adb. The script that runs the hierarchy viewer
- * defines com.android.hierarchyviewer.bindir.
- */
- @Override
- public String getAdbLocation() {
- String hvParentLocation = System.getProperty("com.android.hierarchyviewer.bindir"); //$NON-NLS-1$
-
- // in the new SDK, adb is in the platform-tools, but when run from the command line
- // in the Android source tree, then adb is next to hierarchyviewer.
- if (hvParentLocation != null && hvParentLocation.length() != 0) {
- // check if there's a platform-tools folder
- File platformTools = new File(new File(hvParentLocation).getParent(),
- SdkConstants.FD_PLATFORM_TOOLS);
- if (platformTools.isDirectory()) {
- return platformTools.getAbsolutePath() + File.separator + SdkConstants.FN_ADB;
- }
-
- return hvParentLocation + File.separator + SdkConstants.FN_ADB;
- }
-
- return SdkConstants.FN_ADB;
- }
-
- /*
- * In the application, we handle background tasks using a single thread,
- * just to get rid of possible race conditions that can occur. We update the
- * progress bar to show that we are doing something in the background.
- */
- @Override
- public void executeInBackground(final String taskName, final Runnable task) {
- mExecutor.execute(new Runnable() {
- @Override
- public void run() {
- HierarchyViewerApplication.getMainWindow().startTask(taskName);
- task.run();
- HierarchyViewerApplication.getMainWindow().endTask();
- }
- });
- }
-
-}
diff --git a/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/AboutAction.java b/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/AboutAction.java
deleted file mode 100644
index 4aff6e0..0000000
--- a/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/AboutAction.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewer.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewer.AboutDialog;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-import com.android.hierarchyviewerlib.actions.ImageAction;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class AboutAction extends Action implements ImageAction {
-
- private static AboutAction sAction;
-
- private Image mImage;
-
- private Shell mShell;
-
- private AboutAction(Shell shell) {
- super("&About");
- this.mShell = shell;
- setAccelerator(SWT.MOD1 + 'A');
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("sdk-hierarchyviewer-16.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Shows the about dialog");
- }
-
- public static AboutAction getAction(Shell shell) {
- if (sAction == null) {
- sAction = new AboutAction(shell);
- }
- return sAction;
- }
-
- @Override
- public void run() {
- new AboutDialog(mShell).open();
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/LoadAllViewsAction.java b/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/LoadAllViewsAction.java
deleted file mode 100644
index fd3ce9e..0000000
--- a/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/LoadAllViewsAction.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewer.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-import com.android.hierarchyviewerlib.actions.ImageAction;
-import com.android.hierarchyviewerlib.actions.TreeViewEnabledAction;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class LoadAllViewsAction extends TreeViewEnabledAction implements ImageAction {
-
- private static LoadAllViewsAction sAction;
-
- private Image mImage;
-
- private LoadAllViewsAction() {
- super("Load All &Views");
- setAccelerator(SWT.MOD1 + 'V');
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("load-all-views.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Load all view images");
- }
-
- public static LoadAllViewsAction getAction() {
- if (sAction == null) {
- sAction = new LoadAllViewsAction();
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().loadAllViews();
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/QuitAction.java b/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/QuitAction.java
deleted file mode 100644
index b5a8c5f..0000000
--- a/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/QuitAction.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewer.actions;
-
-import com.android.hierarchyviewer.HierarchyViewerApplication;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.SWT;
-
-public class QuitAction extends Action {
-
- private static QuitAction sAction;
-
- private QuitAction() {
- super("E&xit");
- setAccelerator(SWT.MOD1 + 'Q');
- }
-
- public static QuitAction getAction() {
- if (sAction == null) {
- sAction = new QuitAction();
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerApplication.getMainWindow().close();
- }
-}
diff --git a/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/ShowOverlayAction.java b/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/ShowOverlayAction.java
deleted file mode 100644
index fb06f36..0000000
--- a/hierarchyviewer2/app/src/com/android/hierarchyviewer/actions/ShowOverlayAction.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewer.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewer.HierarchyViewerApplication;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-import com.android.hierarchyviewerlib.actions.ImageAction;
-import com.android.hierarchyviewerlib.models.PixelPerfectModel;
-import com.android.hierarchyviewerlib.models.PixelPerfectModel.IImageChangeListener;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class ShowOverlayAction extends Action implements ImageAction, IImageChangeListener {
-
- private static ShowOverlayAction sAction;
-
- private Image mImage;
-
- private ShowOverlayAction() {
- super("Show In &Loupe", Action.AS_CHECK_BOX);
- setAccelerator(SWT.MOD1 + 'L');
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("show-overlay.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Show the overlay in the loupe view");
- setEnabled(PixelPerfectModel.getModel().getOverlayImage() != null);
- PixelPerfectModel.getModel().addImageChangeListener(this);
- }
-
- public static ShowOverlayAction getAction() {
- if (sAction == null) {
- sAction = new ShowOverlayAction();
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerApplication.getMainWindow().showOverlayInLoupe(sAction.isChecked());
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-
- @Override
- public void crosshairMoved() {
- // pass
- }
-
- @Override
- public void treeChanged() {
- // pass
- }
-
- @Override
- public void imageChanged() {
- // pass
- }
-
- @Override
- public void imageLoaded() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- Image overlayImage = PixelPerfectModel.getModel().getOverlayImage();
- setEnabled(overlayImage != null);
- }
- });
- }
-
- @Override
- public void overlayChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- setEnabled(PixelPerfectModel.getModel().getOverlayImage() != null);
- }
- });
- }
-
- @Override
- public void overlayTransparencyChanged() {
- // pass
- }
-
- @Override
- public void selectionChanged() {
- // pass
- }
-
- @Override
- public void zoomChanged() {
- // pass
- }
-}
diff --git a/hierarchyviewer2/app/src/com/android/hierarchyviewer/util/ActionButton.java b/hierarchyviewer2/app/src/com/android/hierarchyviewer/util/ActionButton.java
deleted file mode 100644
index cd15efc..0000000
--- a/hierarchyviewer2/app/src/com/android/hierarchyviewer/util/ActionButton.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewer.util;
-
-import com.android.hierarchyviewerlib.actions.ImageAction;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-
-public class ActionButton implements IPropertyChangeListener, SelectionListener {
- private Button mButton;
-
- private Action mAction;
-
- public ActionButton(Composite parent, ImageAction action) {
- this.mAction = (Action) action;
- if (this.mAction.getStyle() == Action.AS_CHECK_BOX) {
- mButton = new Button(parent, SWT.CHECK);
- } else {
- mButton = new Button(parent, SWT.PUSH);
- }
- mButton.setText(action.getText());
- mButton.setImage(action.getImage());
- this.mAction.addPropertyChangeListener(this);
- mButton.addSelectionListener(this);
- mButton.setToolTipText(action.getToolTipText());
- mButton.setEnabled(this.mAction.isEnabled());
- }
-
- @Override
- public void propertyChange(PropertyChangeEvent e) {
- if (e.getProperty().toUpperCase().equals("ENABLED")) { //$NON-NLS-1$
- mButton.setEnabled((Boolean) e.getNewValue());
- } else if (e.getProperty().toUpperCase().equals("CHECKED")) { //$NON-NLS-1$
- mButton.setSelection(mAction.isChecked());
- }
- }
-
- public void setLayoutData(Object data) {
- mButton.setLayoutData(data);
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // pass
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- if (mAction.getStyle() == Action.AS_CHECK_BOX) {
- mAction.setChecked(mButton.getSelection());
- }
- mAction.run();
- }
-
- public void addSelectionListener(SelectionListener listener) {
- mButton.addSelectionListener(listener);
- }
-
- public void setVisible(boolean visible) {
- mButton.setVisible(visible);
- }
-}
diff --git a/hierarchyviewer2/libs/Android.mk b/hierarchyviewer2/libs/Android.mk
deleted file mode 100644
index f4b34cd..0000000
--- a/hierarchyviewer2/libs/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-HIERARCHYVIEWERLIBS_LOCAL_DIR := $(call my-dir)
-include $(HIERARCHYVIEWERLIBS_LOCAL_DIR)/hierarchyviewerlib/Android.mk
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/.classpath b/hierarchyviewer2/libs/hierarchyviewerlib/.classpath
deleted file mode 100644
index 779f384..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/.classpath
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmuilib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/linux-x86/swt/swt.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.core.commands_3.6.0.I20100512-1500.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.equinox.common_3.6.0.v20100503.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.jface_3.6.2.M20110210-1200.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/.gitignore b/hierarchyviewer2/libs/hierarchyviewerlib/.gitignore
deleted file mode 100644
index e660fd9..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bin/
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/.project b/hierarchyviewer2/libs/hierarchyviewerlib/.project
deleted file mode 100644
index b3c994a..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>hierarchyviewerlib</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/.settings/README.txt b/hierarchyviewer2/libs/hierarchyviewerlib/.settings/README.txt
deleted file mode 100644
index 9120b20..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/.settings/README.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Copy this in eclipse project as a .settings folder at the root.
-This ensure proper compilation compliance and warning/error levels. \ No newline at end of file
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/.settings/org.eclipse.jdt.core.prefs b/hierarchyviewer2/libs/hierarchyviewerlib/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/Android.mk b/hierarchyviewer2/libs/hierarchyviewerlib/Android.mk
deleted file mode 100644
index b76c127..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/Android.mk
+++ /dev/null
@@ -1,16 +0,0 @@
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-HIERARCHYVIEWERLIB_LOCAL_DIR := $(call my-dir)
-include $(HIERARCHYVIEWERLIB_LOCAL_DIR)/src/Android.mk
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/NOTICE b/hierarchyviewer2/libs/hierarchyviewerlib/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/manifest.txt b/hierarchyviewer2/libs/hierarchyviewerlib/manifest.txt
deleted file mode 100644
index 984261a..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Class-Path: ddmlib.jar ddmuilib.jar hierarchyviewerlib.jar org.eclipse.jface_3.6.2.M20110210-1200.jar org.eclipse.core.commands_3.6.0.I20100512-1500.jar org.eclipse.equinox.common_3.6.0.v20100503.jar guava-13.0.1.jar common.jar
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/Android.mk b/hierarchyviewer2/libs/hierarchyviewerlib/src/Android.mk
deleted file mode 100644
index 59753e1..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/Android.mk
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_JAVA_RESOURCE_DIRS := ../src
-
-LOCAL_JAR_MANIFEST := ../manifest.txt
-
-LOCAL_JAVA_LIBRARIES := common \
- ddmlib \
- ddmuilib \
- guava-tools \
- swt \
- org.eclipse.jface_3.6.2.M20110210-1200 \
- org.eclipse.core.commands_3.6.0.I20100512-1500
-
-LOCAL_MODULE := hierarchyviewerlib
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/HierarchyViewerDirector.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/HierarchyViewerDirector.java
deleted file mode 100644
index cba35f2..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/HierarchyViewerDirector.java
+++ /dev/null
@@ -1,722 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib;
-
-import com.android.ddmlib.AndroidDebugBridge;
-import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log;
-import com.android.hierarchyviewerlib.device.DeviceBridge;
-import com.android.hierarchyviewerlib.device.HvDeviceFactory;
-import com.android.hierarchyviewerlib.device.IHvDevice;
-import com.android.hierarchyviewerlib.device.WindowUpdater;
-import com.android.hierarchyviewerlib.device.WindowUpdater.IWindowChangeListener;
-import com.android.hierarchyviewerlib.models.DeviceSelectionModel;
-import com.android.hierarchyviewerlib.models.PixelPerfectModel;
-import com.android.hierarchyviewerlib.models.TreeViewModel;
-import com.android.hierarchyviewerlib.models.ViewNode;
-import com.android.hierarchyviewerlib.models.Window;
-import com.android.hierarchyviewerlib.ui.CaptureDisplay;
-import com.android.hierarchyviewerlib.ui.TreeView;
-import com.android.hierarchyviewerlib.ui.util.DrawableViewNode;
-import com.android.hierarchyviewerlib.ui.util.PsdFile;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.ImageLoader;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
-
-/**
- * This is the class where most of the logic resides.
- */
-public abstract class HierarchyViewerDirector implements IDeviceChangeListener,
- IWindowChangeListener {
-
- protected static HierarchyViewerDirector sDirector;
-
- public static final String TAG = "hierarchyviewer";
-
- private int mPixelPerfectRefreshesInProgress = 0;
-
- private Timer mPixelPerfectRefreshTimer = new Timer();
-
- private boolean mAutoRefresh = false;
-
- public static final int DEFAULT_PIXEL_PERFECT_AUTOREFRESH_INTERVAL = 5;
-
- private int mPixelPerfectAutoRefreshInterval = DEFAULT_PIXEL_PERFECT_AUTOREFRESH_INTERVAL;
-
- private PixelPerfectAutoRefreshTask mCurrentAutoRefreshTask;
-
- private String mFilterText = ""; //$NON-NLS-1$
-
- private static final Object mDevicesLock = new Object();
- private Map<IDevice, IHvDevice> mDevices = new HashMap<IDevice, IHvDevice>(10);
-
- public void terminate() {
- WindowUpdater.terminate();
- mPixelPerfectRefreshTimer.cancel();
- }
-
- public abstract String getAdbLocation();
-
- public static HierarchyViewerDirector getDirector() {
- return sDirector;
- }
-
- /**
- * Init the DeviceBridge with an existing {@link AndroidDebugBridge}.
- * @param bridge the bridge object to use
- */
- public void acquireBridge(AndroidDebugBridge bridge) {
- DeviceBridge.acquireBridge(bridge);
- }
-
- /**
- * Creates an {@link AndroidDebugBridge} connected to adb at the given location.
- *
- * If a bridge is already running, this disconnects it and creates a new one.
- *
- * @param adbLocation the location to adb.
- */
- public void initDebugBridge() {
- DeviceBridge.initDebugBridge(getAdbLocation());
- }
-
- public void stopDebugBridge() {
- DeviceBridge.terminate();
- }
-
- public void populateDeviceSelectionModel() {
- IDevice[] devices = DeviceBridge.getDevices();
- for (IDevice device : devices) {
- deviceConnected(device);
- }
- }
-
- public void startListenForDevices() {
- DeviceBridge.startListenForDevices(this);
- }
-
- public void stopListenForDevices() {
- DeviceBridge.stopListenForDevices(this);
- }
-
- public abstract void executeInBackground(String taskName, Runnable task);
-
- @Override
- public void deviceConnected(final IDevice device) {
- executeInBackground("Connecting device", new Runnable() {
- @Override
- public void run() {
- if (!device.isOnline()) {
- return;
- }
-
- IHvDevice hvDevice;
- synchronized (mDevicesLock) {
- hvDevice = mDevices.get(device);
- if (hvDevice == null) {
- hvDevice = HvDeviceFactory.create(device);
- hvDevice.initializeViewDebug();
- hvDevice.addWindowChangeListener(getDirector());
- mDevices.put(device, hvDevice);
- } else {
- // attempt re-initializing view server if device state has changed
- hvDevice.initializeViewDebug();
- }
- }
-
- DeviceSelectionModel.getModel().addDevice(hvDevice);
- focusChanged(device);
- }
- });
- }
-
- @Override
- public void deviceDisconnected(final IDevice device) {
- executeInBackground("Disconnecting device", new Runnable() {
- @Override
- public void run() {
- IHvDevice hvDevice;
- synchronized (mDevicesLock) {
- hvDevice = mDevices.get(device);
- if (hvDevice != null) {
- mDevices.remove(device);
- }
- }
-
- if (hvDevice == null) {
- return;
- }
-
- hvDevice.terminateViewDebug();
- hvDevice.removeWindowChangeListener(getDirector());
- DeviceSelectionModel.getModel().removeDevice(hvDevice);
- if (PixelPerfectModel.getModel().getDevice() == device) {
- PixelPerfectModel.getModel().setData(null, null, null);
- }
- Window treeViewWindow = TreeViewModel.getModel().getWindow();
- if (treeViewWindow != null && treeViewWindow.getDevice() == device) {
- TreeViewModel.getModel().setData(null, null);
- mFilterText = ""; //$NON-NLS-1$
- }
- }
- });
- }
-
- @Override
- public void windowsChanged(final IDevice device) {
- executeInBackground("Refreshing windows", new Runnable() {
- @Override
- public void run() {
- IHvDevice hvDevice = getHvDevice(device);
- hvDevice.reloadWindows();
- DeviceSelectionModel.getModel().updateDevice(hvDevice);
- }
- });
- }
-
- @Override
- public void focusChanged(final IDevice device) {
- executeInBackground("Updating focus", new Runnable() {
- @Override
- public void run() {
- IHvDevice hvDevice = getHvDevice(device);
- int focusedWindow = hvDevice.getFocusedWindow();
- DeviceSelectionModel.getModel().updateFocusedWindow(hvDevice, focusedWindow);
- }
- });
- }
-
- @Override
- public void deviceChanged(IDevice device, int changeMask) {
- if ((changeMask & IDevice.CHANGE_STATE) != 0 && device.isOnline()) {
- deviceConnected(device);
- }
- }
-
- public void refreshPixelPerfect() {
- final IDevice device = PixelPerfectModel.getModel().getDevice();
- if (device != null) {
- // Some interesting logic here. We don't want to refresh the pixel
- // perfect view 1000 times in a row if the focus keeps changing. We
- // just
- // want it to refresh following the last focus change.
- boolean proceed = false;
- synchronized (this) {
- if (mPixelPerfectRefreshesInProgress <= 1) {
- proceed = true;
- mPixelPerfectRefreshesInProgress++;
- }
- }
- if (proceed) {
- executeInBackground("Refreshing pixel perfect screenshot", new Runnable() {
- @Override
- public void run() {
- Image screenshotImage = getScreenshotImage(getHvDevice(device));
- if (screenshotImage != null) {
- PixelPerfectModel.getModel().setImage(screenshotImage);
- }
- synchronized (HierarchyViewerDirector.this) {
- mPixelPerfectRefreshesInProgress--;
- }
- }
-
- });
- }
- }
- }
-
- public void refreshPixelPerfectTree() {
- final IDevice device = PixelPerfectModel.getModel().getDevice();
- if (device != null) {
- executeInBackground("Refreshing pixel perfect tree", new Runnable() {
- @Override
- public void run() {
- IHvDevice hvDevice = getHvDevice(device);
- ViewNode viewNode =
- hvDevice.loadWindowData(Window.getFocusedWindow(hvDevice));
- if (viewNode != null) {
- PixelPerfectModel.getModel().setTree(viewNode);
- }
- }
-
- });
- }
- }
-
- public void loadPixelPerfectData(final IHvDevice hvDevice) {
- executeInBackground("Loading pixel perfect data", new Runnable() {
- @Override
- public void run() {
- Image screenshotImage = getScreenshotImage(hvDevice);
- if (screenshotImage != null) {
- ViewNode viewNode =
- hvDevice.loadWindowData(Window.getFocusedWindow(hvDevice));
- if (viewNode != null) {
- PixelPerfectModel.getModel().setData(hvDevice.getDevice(),
- screenshotImage, viewNode);
- }
- }
- }
- });
- }
-
- private IHvDevice getHvDevice(IDevice device) {
- synchronized (mDevicesLock) {
- return mDevices.get(device);
- }
- }
-
- private Image getScreenshotImage(IHvDevice hvDevice) {
- return (hvDevice == null) ? null : hvDevice.getScreenshotImage();
- }
-
- public void loadViewTreeData(final Window window) {
- executeInBackground("Loading view hierarchy", new Runnable() {
- @Override
- public void run() {
- mFilterText = ""; //$NON-NLS-1$
-
- IHvDevice hvDevice = window.getHvDevice();
- ViewNode viewNode = hvDevice.loadWindowData(window);
- if (viewNode != null) {
- viewNode.setViewCount();
- TreeViewModel.getModel().setData(window, viewNode);
- }
- }
- });
- }
-
- public void loadOverlay(final Shell shell) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- FileDialog fileDialog = new FileDialog(shell, SWT.OPEN);
- fileDialog.setFilterExtensions(new String[] {
- "*.jpg;*.jpeg;*.png;*.gif;*.bmp" //$NON-NLS-1$
- });
- fileDialog.setFilterNames(new String[] {
- "Image (*.jpg, *.jpeg, *.png, *.gif, *.bmp)"
- });
- fileDialog.setText("Choose an overlay image");
- String fileName = fileDialog.open();
- if (fileName != null) {
- try {
- Image image = new Image(Display.getDefault(), fileName);
- PixelPerfectModel.getModel().setOverlayImage(image);
- } catch (SWTException e) {
- Log.e(TAG, "Unable to load image from " + fileName);
- }
- }
- }
- });
- }
-
- public void showCapture(final Shell shell, final ViewNode viewNode) {
- executeInBackground("Capturing node", new Runnable() {
- @Override
- public void run() {
- final Image image = loadCapture(viewNode);
- if (image != null) {
-
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- CaptureDisplay.show(shell, viewNode, image);
- }
- });
- }
- }
- });
- }
-
- public Image loadCapture(ViewNode viewNode) {
- IHvDevice hvDevice = viewNode.window.getHvDevice();
- final Image image = hvDevice.loadCapture(viewNode.window, viewNode);
- if (image != null) {
- viewNode.image = image;
-
- // Force the layout viewer to redraw.
- TreeViewModel.getModel().notifySelectionChanged();
- }
- return image;
- }
-
- public void loadCaptureInBackground(final ViewNode viewNode) {
- executeInBackground("Capturing node", new Runnable() {
- @Override
- public void run() {
- loadCapture(viewNode);
- }
- });
- }
-
- public void showCapture(Shell shell) {
- DrawableViewNode viewNode = TreeViewModel.getModel().getSelection();
- if (viewNode != null) {
- showCapture(shell, viewNode.viewNode);
- }
- }
-
- public void refreshWindows() {
- executeInBackground("Refreshing windows", new Runnable() {
- @Override
- public void run() {
- IHvDevice[] hvDevicesA = DeviceSelectionModel.getModel().getDevices();
- IDevice[] devicesA = new IDevice[hvDevicesA.length];
- for (int i = 0; i < hvDevicesA.length; i++) {
- devicesA[i] = hvDevicesA[i].getDevice();
- }
- IDevice[] devicesB = DeviceBridge.getDevices();
- HashSet<IDevice> deviceSet = new HashSet<IDevice>();
- for (int i = 0; i < devicesB.length; i++) {
- deviceSet.add(devicesB[i]);
- }
- for (int i = 0; i < devicesA.length; i++) {
- if (deviceSet.contains(devicesA[i])) {
- windowsChanged(devicesA[i]);
- deviceSet.remove(devicesA[i]);
- } else {
- deviceDisconnected(devicesA[i]);
- }
- }
- for (IDevice device : deviceSet) {
- deviceConnected(device);
- }
- }
- });
- }
-
- public void loadViewHierarchy() {
- Window window = DeviceSelectionModel.getModel().getSelectedWindow();
- if (window != null) {
- loadViewTreeData(window);
- }
- }
-
- public void inspectScreenshot() {
- IHvDevice device = DeviceSelectionModel.getModel().getSelectedDevice();
- if (device != null) {
- loadPixelPerfectData(device);
- }
- }
-
- public void saveTreeView(final Shell shell) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- final DrawableViewNode viewNode = TreeViewModel.getModel().getTree();
- if (viewNode != null) {
- FileDialog fileDialog = new FileDialog(shell, SWT.SAVE);
- fileDialog.setFilterExtensions(new String[] {
- "*.png" //$NON-NLS-1$
- });
- fileDialog.setFilterNames(new String[] {
- "Portable Network Graphics File (*.png)"
- });
- fileDialog.setText("Choose where to save the tree image");
- final String fileName = fileDialog.open();
- if (fileName != null) {
- executeInBackground("Saving tree view", new Runnable() {
- @Override
- public void run() {
- Image image = TreeView.paintToImage(viewNode);
- ImageLoader imageLoader = new ImageLoader();
- imageLoader.data = new ImageData[] {
- image.getImageData()
- };
- String extensionedFileName = fileName;
- if (!extensionedFileName.toLowerCase().endsWith(".png")) { //$NON-NLS-1$
- extensionedFileName += ".png"; //$NON-NLS-1$
- }
- try {
- imageLoader.save(extensionedFileName, SWT.IMAGE_PNG);
- } catch (SWTException e) {
- Log.e(TAG, "Unable to save tree view as a PNG image at "
- + fileName);
- }
- image.dispose();
- }
- });
- }
- }
- }
- });
- }
-
- public void savePixelPerfect(final Shell shell) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- Image untouchableImage = PixelPerfectModel.getModel().getImage();
- if (untouchableImage != null) {
- final ImageData imageData = untouchableImage.getImageData();
- FileDialog fileDialog = new FileDialog(shell, SWT.SAVE);
- fileDialog.setFilterExtensions(new String[] {
- "*.png" //$NON-NLS-1$
- });
- fileDialog.setFilterNames(new String[] {
- "Portable Network Graphics File (*.png)"
- });
- fileDialog.setText("Choose where to save the screenshot");
- final String fileName = fileDialog.open();
- if (fileName != null) {
- executeInBackground("Saving pixel perfect", new Runnable() {
- @Override
- public void run() {
- ImageLoader imageLoader = new ImageLoader();
- imageLoader.data = new ImageData[] {
- imageData
- };
- String extensionedFileName = fileName;
- if (!extensionedFileName.toLowerCase().endsWith(".png")) { //$NON-NLS-1$
- extensionedFileName += ".png"; //$NON-NLS-1$
- }
- try {
- imageLoader.save(extensionedFileName, SWT.IMAGE_PNG);
- } catch (SWTException e) {
- Log.e(TAG, "Unable to save tree view as a PNG image at "
- + fileName);
- }
- }
- });
- }
- }
- }
- });
- }
-
- public void capturePSD(final Shell shell) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- final Window window = TreeViewModel.getModel().getWindow();
- if (window != null) {
- FileDialog fileDialog = new FileDialog(shell, SWT.SAVE);
- fileDialog.setFilterExtensions(new String[] {
- "*.psd" //$NON-NLS-1$
- });
- fileDialog.setFilterNames(new String[] {
- "Photoshop Document (*.psd)"
- });
- fileDialog.setText("Choose where to save the window layers");
- final String fileName = fileDialog.open();
- if (fileName != null) {
- executeInBackground("Saving window layers", new Runnable() {
- @Override
- public void run() {
- IHvDevice hvDevice = getHvDevice(window.getDevice());
- PsdFile psdFile = hvDevice.captureLayers(window);
- if (psdFile != null) {
- String extensionedFileName = fileName;
- if (!extensionedFileName.toLowerCase().endsWith(".psd")) { //$NON-NLS-1$
- extensionedFileName += ".psd"; //$NON-NLS-1$
- }
- try {
- psdFile.write(new FileOutputStream(extensionedFileName));
- } catch (FileNotFoundException e) {
- Log.e(TAG, "Unable to write to file " + fileName);
- }
- }
- }
- });
- }
- }
- }
- });
- }
-
- public void reloadViewHierarchy() {
- Window window = TreeViewModel.getModel().getWindow();
- if (window != null) {
- loadViewTreeData(window);
- }
- }
-
- public void invalidateCurrentNode() {
- final DrawableViewNode selectedNode = TreeViewModel.getModel().getSelection();
- if (selectedNode != null) {
- executeInBackground("Invalidating view", new Runnable() {
- @Override
- public void run() {
- IHvDevice hvDevice = getHvDevice(selectedNode.viewNode.window.getDevice());
- hvDevice.invalidateView(selectedNode.viewNode);
- }
- });
- }
- }
-
- public void relayoutCurrentNode() {
- final DrawableViewNode selectedNode = TreeViewModel.getModel().getSelection();
- if (selectedNode != null) {
- executeInBackground("Request layout", new Runnable() {
- @Override
- public void run() {
- IHvDevice hvDevice = getHvDevice(selectedNode.viewNode.window.getDevice());
- hvDevice.requestLayout(selectedNode.viewNode);
- }
- });
- }
- }
-
- public void dumpDisplayListForCurrentNode() {
- final DrawableViewNode selectedNode = TreeViewModel.getModel().getSelection();
- if (selectedNode != null) {
- executeInBackground("Dump displaylist", new Runnable() {
- @Override
- public void run() {
- IHvDevice hvDevice = getHvDevice(selectedNode.viewNode.window.getDevice());
- hvDevice.outputDisplayList(selectedNode.viewNode);
- }
- });
- }
- }
-
- public void profileCurrentNode() {
- final DrawableViewNode selectedNode = TreeViewModel.getModel().getSelection();
- if (selectedNode != null) {
- executeInBackground("Profile Node", new Runnable() {
- @Override
- public void run() {
- IHvDevice hvDevice = getHvDevice(selectedNode.viewNode.window.getDevice());
- hvDevice.loadProfileData(selectedNode.viewNode.window, selectedNode.viewNode);
- // Force the layout viewer to redraw.
- TreeViewModel.getModel().notifySelectionChanged();
- }
- });
- }
- }
-
- public void invokeMethodOnSelectedView(final String method, final List<Object> args) {
- final DrawableViewNode selectedNode = TreeViewModel.getModel().getSelection();
- if (selectedNode != null) {
- executeInBackground("Invoke View Method", new Runnable() {
- @Override
- public void run() {
- IHvDevice hvDevice = getHvDevice(selectedNode.viewNode.window.getDevice());
- hvDevice.invokeViewMethod(selectedNode.viewNode.window, selectedNode.viewNode,
- method, args);
- }
- });
- }
- }
-
- public void loadAllViews() {
- executeInBackground("Loading all views", new Runnable() {
- @Override
- public void run() {
- DrawableViewNode tree = TreeViewModel.getModel().getTree();
- if (tree != null) {
- loadViewRecursive(tree.viewNode);
- // Force the layout viewer to redraw.
- TreeViewModel.getModel().notifySelectionChanged();
- }
- }
- });
- }
-
- private void loadViewRecursive(ViewNode viewNode) {
- IHvDevice hvDevice = getHvDevice(viewNode.window.getDevice());
- Image image = hvDevice.loadCapture(viewNode.window, viewNode);
- if (image == null) {
- return;
- }
- viewNode.image = image;
- final int N = viewNode.children.size();
- for (int i = 0; i < N; i++) {
- loadViewRecursive(viewNode.children.get(i));
- }
- }
-
- public void filterNodes(String filterText) {
- this.mFilterText = filterText;
- DrawableViewNode tree = TreeViewModel.getModel().getTree();
- if (tree != null) {
- tree.viewNode.filter(filterText);
- // Force redraw
- TreeViewModel.getModel().notifySelectionChanged();
- }
- }
-
- public String getFilterText() {
- return mFilterText;
- }
-
- private static class PixelPerfectAutoRefreshTask extends TimerTask {
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().refreshPixelPerfect();
- }
- };
-
- public void setPixelPerfectAutoRefresh(boolean value) {
- synchronized (mPixelPerfectRefreshTimer) {
- if (value == mAutoRefresh) {
- return;
- }
- mAutoRefresh = value;
- if (mAutoRefresh) {
- mCurrentAutoRefreshTask = new PixelPerfectAutoRefreshTask();
- mPixelPerfectRefreshTimer.schedule(mCurrentAutoRefreshTask,
- mPixelPerfectAutoRefreshInterval * 1000,
- mPixelPerfectAutoRefreshInterval * 1000);
- } else {
- mCurrentAutoRefreshTask.cancel();
- mCurrentAutoRefreshTask = null;
- }
- }
- }
-
- public void setPixelPerfectAutoRefreshInterval(int value) {
- synchronized (mPixelPerfectRefreshTimer) {
- if (mPixelPerfectAutoRefreshInterval == value) {
- return;
- }
- mPixelPerfectAutoRefreshInterval = value;
- if (mAutoRefresh) {
- mCurrentAutoRefreshTask.cancel();
- long timeLeft =
- Math.max(0, mPixelPerfectAutoRefreshInterval
- * 1000
- - (System.currentTimeMillis() - mCurrentAutoRefreshTask
- .scheduledExecutionTime()));
- mCurrentAutoRefreshTask = new PixelPerfectAutoRefreshTask();
- mPixelPerfectRefreshTimer.schedule(mCurrentAutoRefreshTask, timeLeft,
- mPixelPerfectAutoRefreshInterval * 1000);
- }
- }
- }
-
- public int getPixelPerfectAutoRefreshInverval() {
- return mPixelPerfectAutoRefreshInterval;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/CapturePSDAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/CapturePSDAction.java
deleted file mode 100644
index f1f7ad6..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/CapturePSDAction.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class CapturePSDAction extends TreeViewEnabledAction implements ImageAction {
-
- private static CapturePSDAction sAction;
-
- private Image mImage;
-
- private Shell mShell;
-
- private CapturePSDAction(Shell shell) {
- super("&Capture Layers");
- this.mShell = shell;
- setAccelerator(SWT.MOD1 + 'C');
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("capture-psd.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Capture the window layers as a photoshop document");
- }
-
- public static CapturePSDAction getAction(Shell shell) {
- if (sAction == null) {
- sAction = new CapturePSDAction(shell);
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().capturePSD(mShell);
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/DisplayViewAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/DisplayViewAction.java
deleted file mode 100644
index 7da02d7..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/DisplayViewAction.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class DisplayViewAction extends SelectedNodeEnabledAction implements ImageAction {
-
- private static DisplayViewAction sAction;
-
- private Image mImage;
-
- private Shell mShell;
-
- private DisplayViewAction(Shell shell) {
- super("&Display View");
- this.mShell = shell;
- setAccelerator(SWT.MOD1 + 'D');
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("display.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Display the selected view image in a separate window");
- }
-
- public static DisplayViewAction getAction(Shell shell) {
- if (sAction == null) {
- sAction = new DisplayViewAction(shell);
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().showCapture(mShell);
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/DumpDisplayListAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/DumpDisplayListAction.java
deleted file mode 100644
index fdbc7ef..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/DumpDisplayListAction.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class DumpDisplayListAction extends SelectedNodeEnabledAction implements ImageAction {
-
- private static DumpDisplayListAction sAction;
-
- private Image mImage;
-
- private DumpDisplayListAction() {
- super("Dump DisplayList");
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("load-view-hierarchy.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Request the view to output its displaylist to logcat");
- }
-
- public static DumpDisplayListAction getAction() {
- if (sAction == null) {
- sAction = new DumpDisplayListAction();
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().dumpDisplayListForCurrentNode();
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/ImageAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/ImageAction.java
deleted file mode 100644
index 08320fd..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/ImageAction.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import org.eclipse.swt.graphics.Image;
-
-public interface ImageAction {
- public Image getImage();
-
- public String getText();
-
- public String getToolTipText();
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/InspectScreenshotAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/InspectScreenshotAction.java
deleted file mode 100644
index 388c057..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/InspectScreenshotAction.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-import com.android.hierarchyviewerlib.device.IHvDevice;
-import com.android.hierarchyviewerlib.models.DeviceSelectionModel;
-import com.android.hierarchyviewerlib.models.DeviceSelectionModel.IWindowChangeListener;
-import com.android.hierarchyviewerlib.models.Window;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class InspectScreenshotAction extends Action implements ImageAction, IWindowChangeListener {
-
- private static InspectScreenshotAction sAction;
-
- private Image mImage;
-
- private InspectScreenshotAction() {
- super("Inspect &Screenshot");
- setAccelerator(SWT.MOD1 + 'S');
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("inspect-screenshot.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Inspect a screenshot in the pixel perfect view");
- setEnabled(
- DeviceSelectionModel.getModel().getSelectedDevice() != null);
- DeviceSelectionModel.getModel().addWindowChangeListener(this);
- }
-
- public static InspectScreenshotAction getAction() {
- if (sAction == null) {
- sAction = new InspectScreenshotAction();
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().inspectScreenshot();
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-
- @Override
- public void deviceChanged(IHvDevice device) {
- // pass
- }
-
- @Override
- public void deviceConnected(IHvDevice device) {
- // pass
- }
-
- @Override
- public void deviceDisconnected(IHvDevice device) {
- // pass
- }
-
- @Override
- public void focusChanged(IHvDevice device) {
- // pass
- }
-
- @Override
- public void selectionChanged(final IHvDevice device, final Window window) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- InspectScreenshotAction.getAction().setEnabled(device != null);
- }
- });
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/InvalidateAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/InvalidateAction.java
deleted file mode 100644
index b884220..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/InvalidateAction.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class InvalidateAction extends SelectedNodeEnabledAction implements ImageAction {
-
- private static InvalidateAction sAction;
-
- private Image mImage;
-
- private InvalidateAction() {
- super("&Invalidate Layout");
- setAccelerator(SWT.MOD1 + 'I');
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("invalidate.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Invalidate the layout for the current window");
- }
-
- public static InvalidateAction getAction() {
- if (sAction == null) {
- sAction = new InvalidateAction();
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().invalidateCurrentNode();
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/LoadOverlayAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/LoadOverlayAction.java
deleted file mode 100644
index 1876358..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/LoadOverlayAction.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class LoadOverlayAction extends PixelPerfectEnabledAction implements ImageAction {
-
- private static LoadOverlayAction sAction;
-
- private Image mImage;
-
- private Shell mShell;
-
- private LoadOverlayAction(Shell shell) {
- super("Load &Overlay");
- this.mShell = shell;
- setAccelerator(SWT.MOD1 + 'O');
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("load-overlay.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Load an image to overlay the screenshot");
- }
-
- public static LoadOverlayAction getAction(Shell shell) {
- if (sAction == null) {
- sAction = new LoadOverlayAction(shell);
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().loadOverlay(mShell);
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/LoadViewHierarchyAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/LoadViewHierarchyAction.java
deleted file mode 100644
index 6666315..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/LoadViewHierarchyAction.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-import com.android.hierarchyviewerlib.device.IHvDevice;
-import com.android.hierarchyviewerlib.models.DeviceSelectionModel;
-import com.android.hierarchyviewerlib.models.DeviceSelectionModel.IWindowChangeListener;
-import com.android.hierarchyviewerlib.models.Window;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class LoadViewHierarchyAction extends Action implements ImageAction, IWindowChangeListener {
-
- private static LoadViewHierarchyAction sAction;
-
- private Image mImage;
-
- private LoadViewHierarchyAction() {
- super("Load View &Hierarchy");
- setAccelerator(SWT.MOD1 + 'H');
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("load-view-hierarchy.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Load the view hierarchy into the tree view");
- setEnabled(
- DeviceSelectionModel.getModel().getSelectedWindow() != null);
- DeviceSelectionModel.getModel().addWindowChangeListener(this);
- }
-
- public static LoadViewHierarchyAction getAction() {
- if (sAction == null) {
- sAction = new LoadViewHierarchyAction();
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().loadViewHierarchy();
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-
- @Override
- public void deviceChanged(IHvDevice device) {
- // pass
- }
-
- @Override
- public void deviceConnected(IHvDevice device) {
- // pass
- }
-
- @Override
- public void deviceDisconnected(IHvDevice device) {
- // pass
- }
-
- @Override
- public void focusChanged(IHvDevice device) {
- // pass
- }
-
- @Override
- public void selectionChanged(final IHvDevice device, final Window window) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- LoadViewHierarchyAction.getAction().setEnabled(window != null);
- }
- });
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/PixelPerfectAutoRefreshAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/PixelPerfectAutoRefreshAction.java
deleted file mode 100644
index a47c143..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/PixelPerfectAutoRefreshAction.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class PixelPerfectAutoRefreshAction extends PixelPerfectEnabledAction implements ImageAction {
-
- private static PixelPerfectAutoRefreshAction sAction;
-
- private Image mImage;
-
- private PixelPerfectAutoRefreshAction() {
- super("Auto &Refresh", Action.AS_CHECK_BOX);
- setAccelerator(SWT.MOD1 + 'R');
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("auto-refresh.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Automatically refresh the screenshot");
- }
-
- public static PixelPerfectAutoRefreshAction getAction() {
- if (sAction == null) {
- sAction = new PixelPerfectAutoRefreshAction();
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().setPixelPerfectAutoRefresh(sAction.isChecked());
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/PixelPerfectEnabledAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/PixelPerfectEnabledAction.java
deleted file mode 100644
index 33cb343..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/PixelPerfectEnabledAction.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.hierarchyviewerlib.models.PixelPerfectModel;
-import com.android.hierarchyviewerlib.models.PixelPerfectModel.IImageChangeListener;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.widgets.Display;
-
-public class PixelPerfectEnabledAction extends Action implements IImageChangeListener {
- public PixelPerfectEnabledAction(String name) {
- super(name);
- setEnabled(PixelPerfectModel.getModel().getImage() != null);
- PixelPerfectModel.getModel().addImageChangeListener(this);
- }
-
- public PixelPerfectEnabledAction(String name, int type) {
- super(name, type);
- setEnabled(PixelPerfectModel.getModel().getImage() != null);
- PixelPerfectModel.getModel().addImageChangeListener(this);
- }
-
- @Override
- public void crosshairMoved() {
- // pass
- }
-
- @Override
- public void imageChanged() {
- //
- }
-
- @Override
- public void imageLoaded() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- setEnabled(PixelPerfectModel.getModel().getImage() != null);
- }
- });
- }
-
- @Override
- public void overlayChanged() {
- // pass
- }
-
- @Override
- public void overlayTransparencyChanged() {
- // pass
- }
-
- @Override
- public void selectionChanged() {
- // pass
- }
-
- @Override
- public void treeChanged() {
- // pass
- }
-
- @Override
- public void zoomChanged() {
- // pass
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/ProfileNodesAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/ProfileNodesAction.java
deleted file mode 100644
index 4bf93e8..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/ProfileNodesAction.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class ProfileNodesAction extends SelectedNodeEnabledAction implements ImageAction {
- private static ProfileNodesAction sAction;
-
- private Image mImage;
-
- public ProfileNodesAction() {
- super("Profile Node");
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("profile.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Obtain layout times for tree rooted at selected node");
- }
-
- public static ProfileNodesAction getAction() {
- if (sAction == null) {
- sAction = new ProfileNodesAction();
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().profileCurrentNode();
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshPixelPerfectAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshPixelPerfectAction.java
deleted file mode 100644
index 54f53c8..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshPixelPerfectAction.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class RefreshPixelPerfectAction extends PixelPerfectEnabledAction implements ImageAction {
-
- private static RefreshPixelPerfectAction sAction;
-
- private Image mImage;
-
- private RefreshPixelPerfectAction() {
- super("&Refresh Screenshot");
- setAccelerator(SWT.F5);
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("refresh-windows.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Refresh the screenshot");
- }
-
- public static RefreshPixelPerfectAction getAction() {
- if (sAction == null) {
- sAction = new RefreshPixelPerfectAction();
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().refreshPixelPerfect();
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshPixelPerfectTreeAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshPixelPerfectTreeAction.java
deleted file mode 100644
index e9d1c56..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshPixelPerfectTreeAction.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class RefreshPixelPerfectTreeAction extends PixelPerfectEnabledAction implements ImageAction {
-
- private static RefreshPixelPerfectTreeAction sAction;
-
- private Image mImage;
-
- private RefreshPixelPerfectTreeAction() {
- super("Refresh &Tree");
- setAccelerator(SWT.MOD1 + 'T');
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("load-view-hierarchy.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Refresh the tree");
- }
-
- public static RefreshPixelPerfectTreeAction getAction() {
- if (sAction == null) {
- sAction = new RefreshPixelPerfectTreeAction();
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().refreshPixelPerfectTree();
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshViewAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshViewAction.java
deleted file mode 100644
index 01c2527..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshViewAction.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class RefreshViewAction extends TreeViewEnabledAction implements ImageAction {
-
- private static RefreshViewAction sAction;
-
- private Image mImage;
-
- private RefreshViewAction() {
- super("Load View &Hierarchy");
- setAccelerator(SWT.MOD1 + 'H');
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("load-view-hierarchy.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Reload the view hierarchy");
- }
-
- public static RefreshViewAction getAction() {
- if (sAction == null) {
- sAction = new RefreshViewAction();
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().reloadViewHierarchy();
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshWindowsAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshWindowsAction.java
deleted file mode 100644
index 561f4ea..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RefreshWindowsAction.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class RefreshWindowsAction extends Action implements ImageAction {
-
- private static RefreshWindowsAction sAction;
-
- private Image mImage;
-
- private RefreshWindowsAction() {
- super("&Refresh");
- setAccelerator(SWT.F5);
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("refresh-windows.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Refresh the list of devices");
- }
-
- public static RefreshWindowsAction getAction() {
- if (sAction == null) {
- sAction = new RefreshWindowsAction();
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().refreshWindows();
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RequestLayoutAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RequestLayoutAction.java
deleted file mode 100644
index 6fc7867..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/RequestLayoutAction.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-public class RequestLayoutAction extends SelectedNodeEnabledAction implements ImageAction {
-
- private static RequestLayoutAction sAction;
-
- private Image mImage;
-
- private RequestLayoutAction() {
- super("Request &Layout");
- setAccelerator(SWT.MOD1 + 'L');
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("request-layout.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Request the view to lay out");
- }
-
- public static RequestLayoutAction getAction() {
- if (sAction == null) {
- sAction = new RequestLayoutAction();
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().relayoutCurrentNode();
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/SavePixelPerfectAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/SavePixelPerfectAction.java
deleted file mode 100644
index 57e0094..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/SavePixelPerfectAction.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class SavePixelPerfectAction extends PixelPerfectEnabledAction implements ImageAction {
-
- private static SavePixelPerfectAction sAction;
-
- private Image mImage;
-
- private Shell mShell;
-
- private SavePixelPerfectAction(Shell shell) {
- super("&Save as PNG");
- this.mShell = shell;
- setAccelerator(SWT.MOD1 + 'S');
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("save.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Save the screenshot as a PNG image");
- }
-
- public static SavePixelPerfectAction getAction(Shell shell) {
- if (sAction == null) {
- sAction = new SavePixelPerfectAction(shell);
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().savePixelPerfect(mShell);
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/SaveTreeViewAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/SaveTreeViewAction.java
deleted file mode 100644
index 9e11919..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/SaveTreeViewAction.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class SaveTreeViewAction extends TreeViewEnabledAction implements ImageAction {
-
- private static SaveTreeViewAction sAction;
-
- private Image mImage;
-
- private Shell mShell;
-
- private SaveTreeViewAction(Shell shell) {
- super("&Save as PNG");
- this.mShell = shell;
- setAccelerator(SWT.MOD1 + 'S');
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("save.png", Display.getDefault()); //$NON-NLS-1$
- setImageDescriptor(ImageDescriptor.createFromImage(mImage));
- setToolTipText("Save the tree view as a PNG image");
- }
-
- public static SaveTreeViewAction getAction(Shell shell) {
- if (sAction == null) {
- sAction = new SaveTreeViewAction(shell);
- }
- return sAction;
- }
-
- @Override
- public void run() {
- HierarchyViewerDirector.getDirector().saveTreeView(mShell);
- }
-
- @Override
- public Image getImage() {
- return mImage;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/SelectedNodeEnabledAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/SelectedNodeEnabledAction.java
deleted file mode 100644
index eee28b9..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/SelectedNodeEnabledAction.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.hierarchyviewerlib.models.TreeViewModel;
-import com.android.hierarchyviewerlib.models.TreeViewModel.ITreeChangeListener;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.widgets.Display;
-
-public class SelectedNodeEnabledAction extends Action implements ITreeChangeListener {
- public SelectedNodeEnabledAction(String name) {
- super(name);
- setEnabled(TreeViewModel.getModel().getTree() != null
- && TreeViewModel.getModel().getSelection() != null);
- TreeViewModel.getModel().addTreeChangeListener(this);
- }
-
- @Override
- public void selectionChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- setEnabled(TreeViewModel.getModel().getTree() != null
- && TreeViewModel.getModel().getSelection() != null);
- }
- });
- }
-
- @Override
- public void treeChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- setEnabled(TreeViewModel.getModel().getTree() != null
- && TreeViewModel.getModel().getSelection() != null);
- }
- });
- }
-
- @Override
- public void viewportChanged() {
- }
-
- @Override
- public void zoomChanged() {
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/TreeViewEnabledAction.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/TreeViewEnabledAction.java
deleted file mode 100644
index 4b9c02c..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/actions/TreeViewEnabledAction.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.actions;
-
-import com.android.hierarchyviewerlib.models.TreeViewModel;
-import com.android.hierarchyviewerlib.models.TreeViewModel.ITreeChangeListener;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.widgets.Display;
-
-public class TreeViewEnabledAction extends Action implements ITreeChangeListener {
- public TreeViewEnabledAction(String name) {
- super(name);
- setEnabled(TreeViewModel.getModel().getTree() != null);
- TreeViewModel.getModel().addTreeChangeListener(this);
- }
-
- @Override
- public void selectionChanged() {
- // pass
- }
-
- @Override
- public void treeChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- setEnabled(TreeViewModel.getModel().getTree() != null);
- }
- });
- }
-
- @Override
- public void viewportChanged() {
- }
-
- @Override
- public void zoomChanged() {
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/AbstractHvDevice.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/AbstractHvDevice.java
deleted file mode 100644
index e330168..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/AbstractHvDevice.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.device;
-
-import com.android.ddmlib.AdbCommandRejectedException;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.RawImage;
-import com.android.ddmlib.TimeoutException;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.PaletteData;
-import org.eclipse.swt.widgets.Display;
-
-import java.io.IOException;
-import java.util.concurrent.atomic.AtomicReference;
-
-public abstract class AbstractHvDevice implements IHvDevice {
- private static final String TAG = "HierarchyViewer";
-
- @Override
- public Image getScreenshotImage() {
- IDevice device = getDevice();
- final AtomicReference<Image> imageRef = new AtomicReference<Image>();
-
- try {
- final RawImage screenshot = device.getScreenshot();
- if (screenshot == null) {
- return null;
- }
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- ImageData imageData =
- new ImageData(screenshot.width, screenshot.height, screenshot.bpp,
- new PaletteData(screenshot.getRedMask(), screenshot
- .getGreenMask(), screenshot.getBlueMask()), 1,
- screenshot.data);
- imageRef.set(new Image(Display.getDefault(), imageData));
- }
- });
- return imageRef.get();
- } catch (IOException e) {
- Log.e(TAG, "Unable to load screenshot from device " + device.getName());
- } catch (TimeoutException e) {
- Log.e(TAG, "Timeout loading screenshot from device " + device.getName());
- } catch (AdbCommandRejectedException e) {
- Log.e(TAG, "Adb rejected command to load screenshot from device " + device.getName());
- }
- return null;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/DdmViewDebugDevice.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/DdmViewDebugDevice.java
deleted file mode 100644
index 0172995..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/DdmViewDebugDevice.java
+++ /dev/null
@@ -1,417 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.device;
-
-import com.android.ddmlib.AndroidDebugBridge;
-import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
-import com.android.ddmlib.Client;
-import com.android.ddmlib.ClientData;
-import com.android.ddmlib.HandleViewDebug;
-import com.android.ddmlib.HandleViewDebug.ViewDumpHandler;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log;
-import com.android.hierarchyviewerlib.device.WindowUpdater.IWindowChangeListener;
-import com.android.hierarchyviewerlib.models.ViewNode;
-import com.android.hierarchyviewerlib.models.Window;
-import com.android.hierarchyviewerlib.ui.util.PsdFile;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.io.StringReader;
-import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
-
-public class DdmViewDebugDevice extends AbstractHvDevice implements IDeviceChangeListener {
- private static final String TAG = "DdmViewDebugDevice";
-
- private final IDevice mDevice;
- private Map<Client, List<String>> mViewRootsPerClient = new HashMap<Client, List<String>>(40);
-
- public DdmViewDebugDevice(IDevice device) {
- mDevice = device;
- }
-
- @Override
- public boolean initializeViewDebug() {
- AndroidDebugBridge.addDeviceChangeListener(this);
- return reloadWindows();
- }
-
- private static class ListViewRootsHandler extends ViewDumpHandler {
- private List<String> mViewRoots = Collections.synchronizedList(new ArrayList<String>(10));
-
- public ListViewRootsHandler() {
- super(HandleViewDebug.CHUNK_VULW);
- }
-
- @Override
- protected void handleViewDebugResult(ByteBuffer data) {
- int nWindows = data.getInt();
-
- for (int i = 0; i < nWindows; i++) {
- int len = data.getInt();
- mViewRoots.add(getString(data, len));
- }
- }
-
- public List<String> getViewRoots(long timeout, TimeUnit unit) {
- waitForResult(timeout, unit);
- return mViewRoots;
- }
- }
-
- private static class CaptureByteArrayHandler extends ViewDumpHandler {
- public CaptureByteArrayHandler(int type) {
- super(type);
- }
-
- private AtomicReference<byte[]> mData = new AtomicReference<byte[]>();
-
- @Override
- protected void handleViewDebugResult(ByteBuffer data) {
- byte[] b = new byte[data.remaining()];
- data.get(b);
- mData.set(b);
-
- }
-
- public byte[] getData(long timeout, TimeUnit unit) {
- waitForResult(timeout, unit);
- return mData.get();
- }
- }
-
- private static class CaptureLayersHandler extends ViewDumpHandler {
- private AtomicReference<PsdFile> mPsd = new AtomicReference<PsdFile>();
-
- public CaptureLayersHandler() {
- super(HandleViewDebug.CHUNK_VURT);
- }
-
- @Override
- protected void handleViewDebugResult(ByteBuffer data) {
- byte[] b = new byte[data.remaining()];
- data.get(b);
- DataInputStream dis = new DataInputStream(new ByteArrayInputStream(b));
- try {
- mPsd.set(DeviceBridge.parsePsd(dis));
- } catch (IOException e) {
- Log.e(TAG, e);
- }
- }
-
- public PsdFile getPsdFile(long timeout, TimeUnit unit) {
- waitForResult(timeout, unit);
- return mPsd.get();
- }
- }
-
- @Override
- public boolean reloadWindows() {
- mViewRootsPerClient = new HashMap<Client, List<String>>(40);
-
- for (Client c : mDevice.getClients()) {
- ClientData cd = c.getClientData();
- if (cd != null && cd.hasFeature(ClientData.FEATURE_VIEW_HIERARCHY)) {
- ListViewRootsHandler handler = new ListViewRootsHandler();
-
- try {
- HandleViewDebug.listViewRoots(c, handler);
- } catch (IOException e) {
- Log.i(TAG, "No connection to client: " + cd.getClientDescription());
- continue;
- }
-
- List<String> viewRoots = new ArrayList<String>(
- handler.getViewRoots(200, TimeUnit.MILLISECONDS));
- mViewRootsPerClient.put(c, viewRoots);
- }
- }
-
- return true;
- }
-
- @Override
- public void terminateViewDebug() {
- // nothing to terminate
- }
-
- @Override
- public boolean isViewDebugEnabled() {
- return true;
- }
-
- @Override
- public boolean supportsDisplayListDump() {
- return true;
- }
-
- @Override
- public Window[] getWindows() {
- List<Window> windows = new ArrayList<Window>(10);
-
- for (Client c: mViewRootsPerClient.keySet()) {
- for (String viewRoot: mViewRootsPerClient.get(c)) {
- windows.add(new Window(this, viewRoot, c));
- }
- }
-
- return windows.toArray(new Window[windows.size()]);
- }
-
- @Override
- public int getFocusedWindow() {
- // TODO: add support for identifying view in focus
- return -1;
- }
-
- @Override
- public IDevice getDevice() {
- return mDevice;
- }
-
- @Override
- public ViewNode loadWindowData(Window window) {
- Client c = window.getClient();
- if (c == null) {
- return null;
- }
-
- String viewRoot = window.getTitle();
- CaptureByteArrayHandler handler = new CaptureByteArrayHandler(HandleViewDebug.CHUNK_VURT);
- try {
- HandleViewDebug.dumpViewHierarchy(c, viewRoot,
- false /* skipChildren */,
- true /* includeProperties */,
- handler);
- } catch (IOException e) {
- Log.e(TAG, e);
- return null;
- }
-
- byte[] data = handler.getData(20, TimeUnit.SECONDS);
- if (data == null) {
- return null;
- }
-
- String viewHierarchy = new String(data, Charset.forName("UTF-8"));
- return DeviceBridge.parseViewHierarchy(new BufferedReader(new StringReader(viewHierarchy)),
- window);
- }
-
- @Override
- public void loadProfileData(Window window, ViewNode viewNode) {
- Client c = window.getClient();
- if (c == null) {
- return;
- }
-
- String viewRoot = window.getTitle();
- CaptureByteArrayHandler handler = new CaptureByteArrayHandler(HandleViewDebug.CHUNK_VUOP);
- try {
- HandleViewDebug.profileView(c, viewRoot, viewNode.toString(), handler);
- } catch (IOException e) {
- Log.e(TAG, e);
- return;
- }
-
- byte[] data = handler.getData(30, TimeUnit.SECONDS);
- if (data == null) {
- Log.e(TAG, "Timed out waiting for profile data");
- return;
- }
-
- try {
- boolean success = DeviceBridge.loadProfileDataRecursive(viewNode,
- new BufferedReader(new StringReader(new String(data))));
- if (success) {
- viewNode.setProfileRatings();
- }
- } catch (IOException e) {
- Log.e(TAG, e);
- return;
- }
- }
-
- @Override
- public Image loadCapture(Window window, ViewNode viewNode) {
- Client c = window.getClient();
- if (c == null) {
- return null;
- }
-
- String viewRoot = window.getTitle();
- CaptureByteArrayHandler handler = new CaptureByteArrayHandler(HandleViewDebug.CHUNK_VUOP);
-
- try {
- HandleViewDebug.captureView(c, viewRoot, viewNode.toString(), handler);
- } catch (IOException e) {
- Log.e(TAG, e);
- return null;
- }
-
- byte[] data = handler.getData(10, TimeUnit.SECONDS);
- return (data == null) ? null :
- new Image(Display.getDefault(), new ByteArrayInputStream(data));
- }
-
- @Override
- public PsdFile captureLayers(Window window) {
- Client c = window.getClient();
- if (c == null) {
- return null;
- }
-
- String viewRoot = window.getTitle();
- CaptureLayersHandler handler = new CaptureLayersHandler();
- try {
- HandleViewDebug.captureLayers(c, viewRoot, handler);
- } catch (IOException e) {
- Log.e(TAG, e);
- return null;
- }
-
- return handler.getPsdFile(20, TimeUnit.SECONDS);
- }
-
- @Override
- public void invalidateView(ViewNode viewNode) {
- Window window = viewNode.window;
- Client c = window.getClient();
- if (c == null) {
- return;
- }
-
- String viewRoot = window.getTitle();
- try {
- HandleViewDebug.invalidateView(c, viewRoot, viewNode.toString());
- } catch (IOException e) {
- Log.e(TAG, e);
- }
- }
-
- @Override
- public void requestLayout(ViewNode viewNode) {
- Window window = viewNode.window;
- Client c = window.getClient();
- if (c == null) {
- return;
- }
-
- String viewRoot = window.getTitle();
- try {
- HandleViewDebug.requestLayout(c, viewRoot, viewNode.toString());
- } catch (IOException e) {
- Log.e(TAG, e);
- }
- }
-
- @Override
- public void outputDisplayList(ViewNode viewNode) {
- Window window = viewNode.window;
- Client c = window.getClient();
- if (c == null) {
- return;
- }
-
- String viewRoot = window.getTitle();
- try {
- HandleViewDebug.dumpDisplayList(c, viewRoot, viewNode.toString());
- } catch (IOException e) {
- Log.e(TAG, e);
- }
- }
-
- @Override
- public void addWindowChangeListener(IWindowChangeListener l) {
- // TODO: add support for listening to view root changes
- }
-
- @Override
- public void removeWindowChangeListener(IWindowChangeListener l) {
- // TODO: add support for listening to view root changes
- }
-
- @Override
- public void deviceConnected(IDevice device) {
- // pass
- }
-
- @Override
- public void deviceDisconnected(IDevice device) {
- // pass
- }
-
- @Override
- public void deviceChanged(IDevice device, int changeMask) {
- if ((changeMask & IDevice.CHANGE_CLIENT_LIST) != 0) {
- reloadWindows();
- }
- }
-
- @Override
- public boolean isViewUpdateEnabled() {
- return true;
- }
-
- @Override
- public void invokeViewMethod(Window window, ViewNode viewNode, String method,
- List<?> args) {
- Client c = window.getClient();
- if (c == null) {
- return;
- }
-
- String viewRoot = window.getTitle();
- try {
- HandleViewDebug.invokeMethod(c, viewRoot, viewNode.toString(), method, args.toArray());
- } catch (IOException e) {
- Log.e(TAG, e);
- }
- }
-
- @Override
- public boolean setLayoutParameter(Window window, ViewNode viewNode, String property,
- int value) {
- Client c = window.getClient();
- if (c == null) {
- return false;
- }
-
- String viewRoot = window.getTitle();
- try {
- HandleViewDebug.setLayoutParameter(c, viewRoot, viewNode.toString(), property, value);
- } catch (IOException e) {
- Log.e(TAG, e);
- return false;
- }
-
- return true;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/DeviceBridge.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/DeviceBridge.java
deleted file mode 100644
index 30fa6f6..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/DeviceBridge.java
+++ /dev/null
@@ -1,695 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.device;
-
-import com.android.ddmlib.AdbCommandRejectedException;
-import com.android.ddmlib.AndroidDebugBridge;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.MultiLineReceiver;
-import com.android.ddmlib.ShellCommandUnresponsiveException;
-import com.android.ddmlib.TimeoutException;
-import com.android.hierarchyviewerlib.models.ViewNode;
-import com.android.hierarchyviewerlib.models.Window;
-import com.android.hierarchyviewerlib.ui.util.PsdFile;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-
-import java.awt.Graphics2D;
-import java.awt.Point;
-import java.awt.image.BufferedImage;
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import javax.imageio.ImageIO;
-
-/**
- * A bridge to the device.
- */
-public class DeviceBridge {
-
- public static final String TAG = "hierarchyviewer";
-
- private static final int DEFAULT_SERVER_PORT = 4939;
-
- // These codes must match the auto-generated codes in IWindowManager.java
- // See IWindowManager.aidl as well
- private static final int SERVICE_CODE_START_SERVER = 1;
-
- private static final int SERVICE_CODE_STOP_SERVER = 2;
-
- private static final int SERVICE_CODE_IS_SERVER_RUNNING = 3;
-
- private static AndroidDebugBridge sBridge;
-
- private static final HashMap<IDevice, Integer> sDevicePortMap = new HashMap<IDevice, Integer>();
-
- private static final HashMap<IDevice, ViewServerInfo> sViewServerInfo =
- new HashMap<IDevice, ViewServerInfo>();
-
- private static int sNextLocalPort = DEFAULT_SERVER_PORT;
-
- public static class ViewServerInfo {
- public final int protocolVersion;
-
- public final int serverVersion;
-
- ViewServerInfo(int serverVersion, int protocolVersion) {
- this.protocolVersion = protocolVersion;
- this.serverVersion = serverVersion;
- }
- }
-
- /**
- * Init the DeviceBridge with an existing {@link AndroidDebugBridge}.
- * @param bridge the bridge object to use
- */
- public static void acquireBridge(AndroidDebugBridge bridge) {
- sBridge = bridge;
- }
-
- /**
- * Creates an {@link AndroidDebugBridge} connected to adb at the given location.
- *
- * If a bridge is already running, this disconnects it and creates a new one.
- *
- * @param adbLocation the location to adb.
- */
- public static void initDebugBridge(String adbLocation) {
- if (sBridge == null) {
- AndroidDebugBridge.init(true /* debugger support */);
- }
- if (sBridge == null || !sBridge.isConnected()) {
- sBridge = AndroidDebugBridge.createBridge(adbLocation, true);
- }
- }
-
- /** Disconnects the current {@link AndroidDebugBridge}. */
- public static void terminate() {
- AndroidDebugBridge.terminate();
- }
-
- public static IDevice[] getDevices() {
- if (sBridge == null) {
- return new IDevice[0];
- }
- return sBridge.getDevices();
- }
-
- /*
- * This adds a listener to the debug bridge. The listener is notified of
- * connecting/disconnecting devices, devices coming online, etc.
- */
- public static void startListenForDevices(AndroidDebugBridge.IDeviceChangeListener listener) {
- AndroidDebugBridge.addDeviceChangeListener(listener);
- }
-
- public static void stopListenForDevices(AndroidDebugBridge.IDeviceChangeListener listener) {
- AndroidDebugBridge.removeDeviceChangeListener(listener);
- }
-
- /**
- * Sets up a just-connected device to work with the view server.
- * <p/>
- * This starts a port forwarding between a local port and a port on the
- * device.
- *
- * @param device
- */
- public static void setupDeviceForward(IDevice device) {
- synchronized (sDevicePortMap) {
- if (device.getState() == IDevice.DeviceState.ONLINE) {
- int localPort = sNextLocalPort++;
- try {
- device.createForward(localPort, DEFAULT_SERVER_PORT);
- sDevicePortMap.put(device, localPort);
- } catch (TimeoutException e) {
- Log.e(TAG, "Timeout setting up port forwarding for " + device);
- } catch (AdbCommandRejectedException e) {
- Log.e(TAG, String.format("Adb rejected forward command for device %1$s: %2$s",
- device, e.getMessage()));
- } catch (IOException e) {
- Log.e(TAG, String.format("Failed to create forward for device %1$s: %2$s",
- device, e.getMessage()));
- }
- }
- }
- }
-
- public static void removeDeviceForward(IDevice device) {
- synchronized (sDevicePortMap) {
- final Integer localPort = sDevicePortMap.get(device);
- if (localPort != null) {
- try {
- device.removeForward(localPort, DEFAULT_SERVER_PORT);
- sDevicePortMap.remove(device);
- } catch (TimeoutException e) {
- Log.e(TAG, "Timeout removing port forwarding for " + device);
- } catch (AdbCommandRejectedException e) {
- // In this case, we want to fail silently.
- } catch (IOException e) {
- Log.e(TAG, String.format("Failed to remove forward for device %1$s: %2$s",
- device, e.getMessage()));
- }
- }
- }
- }
-
- public static int getDeviceLocalPort(IDevice device) {
- synchronized (sDevicePortMap) {
- Integer port = sDevicePortMap.get(device);
- if (port != null) {
- return port;
- }
-
- Log.e(TAG, "Missing forwarded port for " + device.getSerialNumber());
- return -1;
- }
-
- }
-
- public static boolean isViewServerRunning(IDevice device) {
- final boolean[] result = new boolean[1];
- try {
- if (device.isOnline()) {
- device.executeShellCommand(buildIsServerRunningShellCommand(),
- new BooleanResultReader(result));
- if (!result[0]) {
- ViewServerInfo serverInfo = loadViewServerInfo(device);
- if (serverInfo != null && serverInfo.protocolVersion > 2) {
- result[0] = true;
- }
- }
- }
- } catch (TimeoutException e) {
- Log.e(TAG, "Timeout checking status of view server on device " + device);
- } catch (IOException e) {
- Log.e(TAG, "Unable to check status of view server on device " + device);
- } catch (AdbCommandRejectedException e) {
- Log.e(TAG, "Adb rejected command to check status of view server on device " + device);
- } catch (ShellCommandUnresponsiveException e) {
- Log.e(TAG, "Unable to execute command to check status of view server on device "
- + device);
- }
- return result[0];
- }
-
- public static boolean startViewServer(IDevice device) {
- return startViewServer(device, DEFAULT_SERVER_PORT);
- }
-
- public static boolean startViewServer(IDevice device, int port) {
- final boolean[] result = new boolean[1];
- try {
- if (device.isOnline()) {
- device.executeShellCommand(buildStartServerShellCommand(port),
- new BooleanResultReader(result));
- }
- } catch (TimeoutException e) {
- Log.e(TAG, "Timeout starting view server on device " + device);
- } catch (IOException e) {
- Log.e(TAG, "Unable to start view server on device " + device);
- } catch (AdbCommandRejectedException e) {
- Log.e(TAG, "Adb rejected command to start view server on device " + device);
- } catch (ShellCommandUnresponsiveException e) {
- Log.e(TAG, "Unable to execute command to start view server on device " + device);
- }
- return result[0];
- }
-
- public static boolean stopViewServer(IDevice device) {
- final boolean[] result = new boolean[1];
- try {
- if (device.isOnline()) {
- device.executeShellCommand(buildStopServerShellCommand(), new BooleanResultReader(
- result));
- }
- } catch (TimeoutException e) {
- Log.e(TAG, "Timeout stopping view server on device " + device);
- } catch (IOException e) {
- Log.e(TAG, "Unable to stop view server on device " + device);
- } catch (AdbCommandRejectedException e) {
- Log.e(TAG, "Adb rejected command to stop view server on device " + device);
- } catch (ShellCommandUnresponsiveException e) {
- Log.e(TAG, "Unable to execute command to stop view server on device " + device);
- }
- return result[0];
- }
-
- private static String buildStartServerShellCommand(int port) {
- return String.format("service call window %d i32 %d", SERVICE_CODE_START_SERVER, port); //$NON-NLS-1$
- }
-
- private static String buildStopServerShellCommand() {
- return String.format("service call window %d", SERVICE_CODE_STOP_SERVER); //$NON-NLS-1$
- }
-
- private static String buildIsServerRunningShellCommand() {
- return String.format("service call window %d", SERVICE_CODE_IS_SERVER_RUNNING); //$NON-NLS-1$
- }
-
- private static class BooleanResultReader extends MultiLineReceiver {
- private final boolean[] mResult;
-
- public BooleanResultReader(boolean[] result) {
- mResult = result;
- }
-
- @Override
- public void processNewLines(String[] strings) {
- if (strings.length > 0) {
- Pattern pattern = Pattern.compile(".*?\\([0-9]{8} ([0-9]{8}).*"); //$NON-NLS-1$
- Matcher matcher = pattern.matcher(strings[0]);
- if (matcher.matches()) {
- if (Integer.parseInt(matcher.group(1)) == 1) {
- mResult[0] = true;
- }
- }
- }
- }
-
- @Override
- public boolean isCancelled() {
- return false;
- }
- }
-
- public static ViewServerInfo loadViewServerInfo(IDevice device) {
- int server = -1;
- int protocol = -1;
- DeviceConnection connection = null;
- try {
- connection = new DeviceConnection(device);
- connection.sendCommand("SERVER"); //$NON-NLS-1$
- String line = connection.getInputStream().readLine();
- if (line != null) {
- server = Integer.parseInt(line);
- }
- } catch (Exception e) {
- Log.e(TAG, "Unable to get view server version from device " + device);
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
- connection = null;
- try {
- connection = new DeviceConnection(device);
- connection.sendCommand("PROTOCOL"); //$NON-NLS-1$
- String line = connection.getInputStream().readLine();
- if (line != null) {
- protocol = Integer.parseInt(line);
- }
- } catch (Exception e) {
- Log.e(TAG, "Unable to get view server protocol version from device " + device);
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
- if (server == -1 || protocol == -1) {
- return null;
- }
- ViewServerInfo returnValue = new ViewServerInfo(server, protocol);
- synchronized (sViewServerInfo) {
- sViewServerInfo.put(device, returnValue);
- }
- return returnValue;
- }
-
- public static ViewServerInfo getViewServerInfo(IDevice device) {
- synchronized (sViewServerInfo) {
- return sViewServerInfo.get(device);
- }
- }
-
- public static void removeViewServerInfo(IDevice device) {
- synchronized (sViewServerInfo) {
- sViewServerInfo.remove(device);
- }
- }
-
- /*
- * This loads the list of windows from the specified device. The format is:
- * hashCode1 title1 hashCode2 title2 ... hashCodeN titleN DONE.
- */
- public static Window[] loadWindows(IHvDevice hvDevice, IDevice device) {
- ArrayList<Window> windows = new ArrayList<Window>();
- DeviceConnection connection = null;
- ViewServerInfo serverInfo = getViewServerInfo(device);
- try {
- connection = new DeviceConnection(device);
- connection.sendCommand("LIST"); //$NON-NLS-1$
- BufferedReader in = connection.getInputStream();
- String line;
- while ((line = in.readLine()) != null) {
- if ("DONE.".equalsIgnoreCase(line)) { //$NON-NLS-1$
- break;
- }
-
- int index = line.indexOf(' ');
- if (index != -1) {
- String windowId = line.substring(0, index);
-
- int id;
- if (serverInfo.serverVersion > 2) {
- id = (int) Long.parseLong(windowId, 16);
- } else {
- id = Integer.parseInt(windowId, 16);
- }
-
- Window w = new Window(hvDevice, line.substring(index + 1), id);
- windows.add(w);
- }
- }
- // Automatic refreshing of windows was added in protocol version 3.
- // Before, the user needed to specify explicitly that he wants to
- // get the focused window, which was done using a special type of
- // window with hash code -1.
- if (serverInfo.protocolVersion < 3) {
- windows.add(Window.getFocusedWindow(hvDevice));
- }
- } catch (Exception e) {
- Log.e(TAG, "Unable to load the window list from device " + device);
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
- // The server returns the list of windows from the window at the bottom
- // to the top. We want the reverse order to put the top window on top of
- // the list.
- Window[] returnValue = new Window[windows.size()];
- for (int i = windows.size() - 1; i >= 0; i--) {
- returnValue[returnValue.length - i - 1] = windows.get(i);
- }
- return returnValue;
- }
-
- /*
- * This gets the hash code of the window that has focus. Only works with
- * protocol version 3 and above.
- */
- public static int getFocusedWindow(IDevice device) {
- DeviceConnection connection = null;
- try {
- connection = new DeviceConnection(device);
- connection.sendCommand("GET_FOCUS"); //$NON-NLS-1$
- String line = connection.getInputStream().readLine();
- if (line == null || line.length() == 0) {
- return -1;
- }
- return (int) Long.parseLong(line.substring(0, line.indexOf(' ')), 16);
- } catch (Exception e) {
- Log.e(TAG, "Unable to get the focused window from device " + device);
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
- return -1;
- }
-
- public static ViewNode loadWindowData(Window window) {
- DeviceConnection connection = null;
- try {
- connection = new DeviceConnection(window.getDevice());
- connection.sendCommand("DUMP " + window.encode()); //$NON-NLS-1$
- BufferedReader in = connection.getInputStream();
- ViewNode currentNode = parseViewHierarchy(in, window);
- ViewServerInfo serverInfo = getViewServerInfo(window.getDevice());
- if (serverInfo != null) {
- currentNode.protocolVersion = serverInfo.protocolVersion;
- }
- return currentNode;
- } catch (Exception e) {
- Log.e(TAG, "Unable to load window data for window " + window.getTitle() + " on device "
- + window.getDevice());
- Log.e(TAG, e.getMessage());
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
- return null;
- }
-
- public static ViewNode parseViewHierarchy(BufferedReader in, Window window) {
- ViewNode currentNode = null;
- int currentDepth = -1;
- String line;
- try {
- while ((line = in.readLine()) != null) {
- if ("DONE.".equalsIgnoreCase(line)) {
- break;
- }
- int depth = 0;
- while (line.charAt(depth) == ' ') {
- depth++;
- }
- while (depth <= currentDepth) {
- if (currentNode != null) {
- currentNode = currentNode.parent;
- }
- currentDepth--;
- }
- currentNode = new ViewNode(window, currentNode, line.substring(depth));
- currentDepth = depth;
- }
- } catch (IOException e) {
- Log.e(TAG, "Error reading view hierarchy stream: " + e.getMessage());
- return null;
- }
- if (currentNode == null) {
- return null;
- }
- while (currentNode.parent != null) {
- currentNode = currentNode.parent;
- }
-
- return currentNode;
- }
-
- public static boolean loadProfileData(Window window, ViewNode viewNode) {
- DeviceConnection connection = null;
- try {
- connection = new DeviceConnection(window.getDevice());
- connection.sendCommand("PROFILE " + window.encode() + " " + viewNode.toString()); //$NON-NLS-1$
- BufferedReader in = connection.getInputStream();
- int protocol;
- synchronized (sViewServerInfo) {
- protocol = sViewServerInfo.get(window.getDevice()).protocolVersion;
- }
- if (protocol < 3) {
- return loadProfileData(viewNode, in);
- } else {
- boolean ret = loadProfileDataRecursive(viewNode, in);
- if (ret) {
- viewNode.setProfileRatings();
- }
- return ret;
- }
- } catch (Exception e) {
- Log.e(TAG, "Unable to load profiling data for window " + window.getTitle()
- + " on device " + window.getDevice());
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
- return false;
- }
-
- private static boolean loadProfileData(ViewNode node, BufferedReader in) throws IOException {
- String line;
- if ((line = in.readLine()) == null || line.equalsIgnoreCase("-1 -1 -1") //$NON-NLS-1$
- || line.equalsIgnoreCase("DONE.")) { //$NON-NLS-1$
- return false;
- }
- String[] data = line.split(" ");
- node.measureTime = (Long.parseLong(data[0]) / 1000.0) / 1000.0;
- node.layoutTime = (Long.parseLong(data[1]) / 1000.0) / 1000.0;
- node.drawTime = (Long.parseLong(data[2]) / 1000.0) / 1000.0;
- return true;
- }
-
- public static boolean loadProfileDataRecursive(ViewNode node, BufferedReader in)
- throws IOException {
- if (!loadProfileData(node, in)) {
- return false;
- }
- for (int i = 0; i < node.children.size(); i++) {
- if (!loadProfileDataRecursive(node.children.get(i), in)) {
- return false;
- }
- }
- return true;
- }
-
- public static Image loadCapture(Window window, ViewNode viewNode) {
- DeviceConnection connection = null;
- try {
- connection = new DeviceConnection(window.getDevice());
- connection.getSocket().setSoTimeout(5000);
- connection.sendCommand("CAPTURE " + window.encode() + " " + viewNode.toString()); //$NON-NLS-1$
- return new Image(Display.getDefault(), connection.getSocket().getInputStream());
- } catch (Exception e) {
- Log.e(TAG, "Unable to capture data for node " + viewNode + " in window "
- + window.getTitle() + " on device " + window.getDevice());
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
- return null;
- }
-
- public static PsdFile captureLayers(Window window) {
- DeviceConnection connection = null;
- DataInputStream in = null;
-
- try {
- connection = new DeviceConnection(window.getDevice());
- connection.sendCommand("CAPTURE_LAYERS " + window.encode()); //$NON-NLS-1$
-
- in =
- new DataInputStream(new BufferedInputStream(connection.getSocket()
- .getInputStream()));
-
- return parsePsd(in);
- } catch (IOException e) {
- Log.e(TAG, "Unable to capture layers for window " + window.getTitle() + " on device "
- + window.getDevice());
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (Exception ex) {
- }
- }
-
- if (connection != null) {
- connection.close();
- }
- }
-
- return null;
- }
-
- public static PsdFile parsePsd(DataInputStream in) throws IOException {
- int width = in.readInt();
- int height = in.readInt();
-
- PsdFile psd = new PsdFile(width, height);
-
- while (readLayer(in, psd)) {
- }
-
- return psd;
- }
-
- private static boolean readLayer(DataInputStream in, PsdFile psd) {
- try {
- if (in.read() == 2) {
- return false;
- }
- String name = in.readUTF();
- boolean visible = in.read() == 1;
- int x = in.readInt();
- int y = in.readInt();
- int dataSize = in.readInt();
-
- byte[] data = new byte[dataSize];
- int read = 0;
- while (read < dataSize) {
- read += in.read(data, read, dataSize - read);
- }
-
- ByteArrayInputStream arrayIn = new ByteArrayInputStream(data);
- BufferedImage chunk = ImageIO.read(arrayIn);
-
- // Ensure the image is in the right format
- BufferedImage image =
- new BufferedImage(chunk.getWidth(), chunk.getHeight(),
- BufferedImage.TYPE_INT_ARGB);
- Graphics2D g = image.createGraphics();
- g.drawImage(chunk, null, 0, 0);
- g.dispose();
-
- psd.addLayer(name, image, new Point(x, y), visible);
-
- return true;
- } catch (Exception e) {
- return false;
- }
- }
-
- public static void invalidateView(ViewNode viewNode) {
- DeviceConnection connection = null;
- try {
- connection = new DeviceConnection(viewNode.window.getDevice());
- connection.sendCommand("INVALIDATE " + viewNode.window.encode() + " " + viewNode); //$NON-NLS-1$
- } catch (Exception e) {
- Log.e(TAG, "Unable to invalidate view " + viewNode + " in window " + viewNode.window
- + " on device " + viewNode.window.getDevice());
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
- }
-
- public static void requestLayout(ViewNode viewNode) {
- DeviceConnection connection = null;
- try {
- connection = new DeviceConnection(viewNode.window.getDevice());
- connection.sendCommand("REQUEST_LAYOUT " + viewNode.window.encode() + " " + viewNode); //$NON-NLS-1$
- } catch (Exception e) {
- Log.e(TAG, "Unable to request layout for node " + viewNode + " in window "
- + viewNode.window + " on device " + viewNode.window.getDevice());
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
- }
-
- public static void outputDisplayList(ViewNode viewNode) {
- DeviceConnection connection = null;
- try {
- connection = new DeviceConnection(viewNode.window.getDevice());
- connection.sendCommand("OUTPUT_DISPLAYLIST " +
- viewNode.window.encode() + " " + viewNode); //$NON-NLS-1$
- } catch (Exception e) {
- Log.e(TAG, "Unable to dump displaylist for node " + viewNode + " in window "
- + viewNode.window + " on device " + viewNode.window.getDevice());
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
- }
-
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/DeviceConnection.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/DeviceConnection.java
deleted file mode 100644
index f750d5c..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/DeviceConnection.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.device;
-
-import com.android.ddmlib.IDevice;
-
-import java.io.BufferedReader;
-import java.io.BufferedWriter;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.net.InetSocketAddress;
-import java.net.Socket;
-import java.nio.channels.SocketChannel;
-
-/**
- * This class is used for connecting to a device in debug mode running the view
- * server.
- */
-public class DeviceConnection {
-
- // Now a socket channel, since socket channels are friendly with interrupts.
- private SocketChannel mSocketChannel;
-
- private BufferedReader mIn;
-
- private BufferedWriter mOut;
-
- public DeviceConnection(IDevice device) throws IOException {
- mSocketChannel = SocketChannel.open();
- int port = DeviceBridge.getDeviceLocalPort(device);
-
- if (port == -1) {
- throw new IOException();
- }
-
- mSocketChannel.connect(new InetSocketAddress("127.0.0.1", port)); //$NON-NLS-1$
- mSocketChannel.socket().setSoTimeout(40000);
- }
-
- public BufferedReader getInputStream() throws IOException {
- if (mIn == null) {
- mIn = new BufferedReader(new InputStreamReader(mSocketChannel.socket().getInputStream()));
- }
- return mIn;
- }
-
- public BufferedWriter getOutputStream() throws IOException {
- if (mOut == null) {
- mOut =
- new BufferedWriter(new OutputStreamWriter(mSocketChannel.socket()
- .getOutputStream()));
- }
- return mOut;
- }
-
- public Socket getSocket() {
- return mSocketChannel.socket();
- }
-
- public void sendCommand(String command) throws IOException {
- BufferedWriter out = getOutputStream();
- out.write(command);
- out.newLine();
- out.flush();
- }
-
- public void close() {
- try {
- if (mIn != null) {
- mIn.close();
- }
- } catch (IOException e) {
- }
- try {
- if (mOut != null) {
- mOut.close();
- }
- } catch (IOException e) {
- }
- try {
- mSocketChannel.close();
- } catch (IOException e) {
- }
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/HvDeviceFactory.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/HvDeviceFactory.java
deleted file mode 100644
index 24a5a4f..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/HvDeviceFactory.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.device;
-
-import com.android.ddmlib.Client;
-import com.android.ddmlib.ClientData;
-import com.android.ddmlib.IDevice;
-
-public class HvDeviceFactory {
- private static final String sHvProtoEnvVar =
- System.getenv("ANDROID_HVPROTO"); //$NON-NLS-1$
-
- public static IHvDevice create(IDevice device) {
- // default to old mechanism until the new one is fully tested
- if (sHvProtoEnvVar == null ||
- !"ddm".equalsIgnoreCase(sHvProtoEnvVar)) { //$NON-NLS-1$
- return new ViewServerDevice(device);
- }
-
- // Wait for a few seconds after the device has been connected to
- // allow all the clients to be initialized. Specifically, we need to wait
- // until the client data is filled with the list of features supported
- // by the client.
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- // ignore
- }
-
- boolean ddmViewHierarchy = false;
-
- // see if any of the clients on the device support view hierarchy via DDMS
- for (Client c : device.getClients()) {
- ClientData cd = c.getClientData();
- if (cd != null && cd.hasFeature(ClientData.FEATURE_VIEW_HIERARCHY)) {
- ddmViewHierarchy = true;
- break;
- }
- }
-
- return ddmViewHierarchy ? new DdmViewDebugDevice(device) : new ViewServerDevice(device);
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/IHvDevice.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/IHvDevice.java
deleted file mode 100644
index 6f1fd37..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/IHvDevice.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.device;
-
-import com.android.ddmlib.IDevice;
-import com.android.hierarchyviewerlib.device.WindowUpdater.IWindowChangeListener;
-import com.android.hierarchyviewerlib.models.ViewNode;
-import com.android.hierarchyviewerlib.models.Window;
-import com.android.hierarchyviewerlib.ui.util.PsdFile;
-
-import org.eclipse.swt.graphics.Image;
-
-import java.util.List;
-
-/** Represents a device that can perform view debug operations. */
-public interface IHvDevice {
- /**
- * Initializes view debugging on the device.
- * @return true if the on device component was successfully initialized
- */
- boolean initializeViewDebug();
- boolean reloadWindows();
-
- void terminateViewDebug();
- boolean isViewDebugEnabled();
- boolean supportsDisplayListDump();
-
- Window[] getWindows();
- int getFocusedWindow();
-
- IDevice getDevice();
-
- Image getScreenshotImage();
- ViewNode loadWindowData(Window window);
- void loadProfileData(Window window, ViewNode viewNode);
- Image loadCapture(Window window, ViewNode viewNode);
- PsdFile captureLayers(Window window);
- void invalidateView(ViewNode viewNode);
- void requestLayout(ViewNode viewNode);
- void outputDisplayList(ViewNode viewNode);
-
- boolean isViewUpdateEnabled();
- void invokeViewMethod(Window window, ViewNode viewNode, String method, List<?> args);
- boolean setLayoutParameter(Window window, ViewNode viewNode, String property, int value);
-
- void addWindowChangeListener(IWindowChangeListener l);
- void removeWindowChangeListener(IWindowChangeListener l);
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/ViewServerDevice.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/ViewServerDevice.java
deleted file mode 100644
index 4445e9a..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/ViewServerDevice.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.device;
-
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log;
-import com.android.hierarchyviewerlib.device.DeviceBridge.ViewServerInfo;
-import com.android.hierarchyviewerlib.device.WindowUpdater.IWindowChangeListener;
-import com.android.hierarchyviewerlib.models.ViewNode;
-import com.android.hierarchyviewerlib.models.Window;
-import com.android.hierarchyviewerlib.ui.util.PsdFile;
-
-import org.eclipse.swt.graphics.Image;
-
-import java.util.List;
-
-public class ViewServerDevice extends AbstractHvDevice {
- static final String TAG = "ViewServerDevice";
-
- final IDevice mDevice;
- private ViewServerInfo mViewServerInfo;
- private Window[] mWindows;
-
- public ViewServerDevice(IDevice device) {
- mDevice = device;
- }
-
- @Override
- public boolean initializeViewDebug() {
- if (!mDevice.isOnline()) {
- return false;
- }
-
- DeviceBridge.setupDeviceForward(mDevice);
-
- return reloadWindows();
- }
-
- @Override
- public boolean reloadWindows() {
- if (!DeviceBridge.isViewServerRunning(mDevice)) {
- if (!DeviceBridge.startViewServer(mDevice)) {
- Log.e(TAG, "Unable to debug device: " + mDevice.getName());
- DeviceBridge.removeDeviceForward(mDevice);
- return false;
- }
- }
-
- mViewServerInfo = DeviceBridge.loadViewServerInfo(mDevice);
- if (mViewServerInfo == null) {
- return false;
- }
-
- mWindows = DeviceBridge.loadWindows(this, mDevice);
- return true;
- }
-
- @Override
- public boolean supportsDisplayListDump() {
- return mViewServerInfo != null && mViewServerInfo.protocolVersion >= 4;
- }
-
- @Override
- public void terminateViewDebug() {
- DeviceBridge.removeDeviceForward(mDevice);
- DeviceBridge.removeViewServerInfo(mDevice);
- }
-
- @Override
- public boolean isViewDebugEnabled() {
- return mViewServerInfo != null;
- }
-
- @Override
- public Window[] getWindows() {
- return mWindows;
- }
-
- @Override
- public int getFocusedWindow() {
- return DeviceBridge.getFocusedWindow(mDevice);
- }
-
- @Override
- public IDevice getDevice() {
- return mDevice;
- }
-
- @Override
- public ViewNode loadWindowData(Window window) {
- return DeviceBridge.loadWindowData(window);
- }
-
- @Override
- public void loadProfileData(Window window, ViewNode viewNode) {
- DeviceBridge.loadProfileData(window, viewNode);
- }
-
- @Override
- public Image loadCapture(Window window, ViewNode viewNode) {
- return DeviceBridge.loadCapture(window, viewNode);
- }
-
- @Override
- public PsdFile captureLayers(Window window) {
- return DeviceBridge.captureLayers(window);
- }
-
- @Override
- public void invalidateView(ViewNode viewNode) {
- DeviceBridge.invalidateView(viewNode);
- }
-
- @Override
- public void requestLayout(ViewNode viewNode) {
- DeviceBridge.requestLayout(viewNode);
- }
-
- @Override
- public void outputDisplayList(ViewNode viewNode) {
- DeviceBridge.outputDisplayList(viewNode);
- }
-
- @Override
- public void addWindowChangeListener(IWindowChangeListener l) {
- if (mViewServerInfo != null && mViewServerInfo.protocolVersion >= 3) {
- WindowUpdater.startListenForWindowChanges(l, mDevice);
- }
- }
-
- @Override
- public void removeWindowChangeListener(IWindowChangeListener l) {
- if (mViewServerInfo != null && mViewServerInfo.protocolVersion >= 3) {
- WindowUpdater.stopListenForWindowChanges(l, mDevice);
- }
- }
-
- @Override
- public boolean isViewUpdateEnabled() {
- return false;
- }
-
- @Override
- public void invokeViewMethod(Window window, ViewNode viewNode, String method,
- List<?> args) {
- // not supported
- }
-
- @Override
- public boolean setLayoutParameter(Window window, ViewNode viewNode, String property,
- int value) {
- // not supported
- return false;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/WindowUpdater.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/WindowUpdater.java
deleted file mode 100644
index a67d400..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/device/WindowUpdater.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.device;
-
-import com.android.ddmlib.IDevice;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.HashMap;
-
-/**
- * This class handles automatic updating of the list of windows in the device
- * selector for device with protocol version 3 or above of the view server. It
- * connects to the devices, keeps the connection open and listens for messages.
- * It notifies all it's listeners of changes.
- */
-public class WindowUpdater {
- private static HashMap<IDevice, ArrayList<IWindowChangeListener>> sWindowChangeListeners =
- new HashMap<IDevice, ArrayList<IWindowChangeListener>>();
-
- private static HashMap<IDevice, Thread> sListeningThreads = new HashMap<IDevice, Thread>();
-
- public static interface IWindowChangeListener {
- public void windowsChanged(IDevice device);
-
- public void focusChanged(IDevice device);
- }
-
- public static void terminate() {
- synchronized (sListeningThreads) {
- for (IDevice device : sListeningThreads.keySet()) {
- sListeningThreads.get(device).interrupt();
-
- }
- }
- }
-
- public static void startListenForWindowChanges(IWindowChangeListener listener, IDevice device) {
- synchronized (sWindowChangeListeners) {
- // In this case, a listening thread already exists, so we don't need
- // to create another one.
- if (sWindowChangeListeners.containsKey(device)) {
- sWindowChangeListeners.get(device).add(listener);
- return;
- }
- ArrayList<IWindowChangeListener> listeners = new ArrayList<IWindowChangeListener>();
- listeners.add(listener);
- sWindowChangeListeners.put(device, listeners);
- }
- // Start listening
- Thread listeningThread = new Thread(new WindowChangeMonitor(device));
- synchronized (sListeningThreads) {
- sListeningThreads.put(device, listeningThread);
- }
- listeningThread.start();
- }
-
- public static void stopListenForWindowChanges(IWindowChangeListener listener, IDevice device) {
- synchronized (sWindowChangeListeners) {
- ArrayList<IWindowChangeListener> listeners = sWindowChangeListeners.get(device);
- if (listeners == null) {
- return;
- }
- listeners.remove(listener);
- // There are more listeners, so don't stop the listening thread.
- if (listeners.size() != 0) {
- return;
- }
- sWindowChangeListeners.remove(device);
- }
- // Everybody left, so the party's over!
- Thread listeningThread;
- synchronized (sListeningThreads) {
- listeningThread = sListeningThreads.get(device);
- sListeningThreads.remove(device);
- }
- listeningThread.interrupt();
- }
-
- private static IWindowChangeListener[] getWindowChangeListenersAsArray(IDevice device) {
- IWindowChangeListener[] listeners;
- synchronized (sWindowChangeListeners) {
- ArrayList<IWindowChangeListener> windowChangeListenerList =
- sWindowChangeListeners.get(device);
- if (windowChangeListenerList == null) {
- return null;
- }
- listeners =
- windowChangeListenerList
- .toArray(new IWindowChangeListener[windowChangeListenerList.size()]);
- }
- return listeners;
- }
-
- public static void notifyWindowsChanged(IDevice device) {
- IWindowChangeListener[] listeners = getWindowChangeListenersAsArray(device);
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].windowsChanged(device);
- }
- }
- }
-
- public static void notifyFocusChanged(IDevice device) {
- IWindowChangeListener[] listeners = getWindowChangeListenersAsArray(device);
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].focusChanged(device);
- }
- }
- }
-
- private static class WindowChangeMonitor implements Runnable {
- private IDevice device;
-
- public WindowChangeMonitor(IDevice device) {
- this.device = device;
- }
-
- @Override
- public void run() {
- while (!Thread.currentThread().isInterrupted()) {
- DeviceConnection connection = null;
- try {
- connection = new DeviceConnection(device);
- connection.sendCommand("AUTOLIST");
- String line;
- while (!Thread.currentThread().isInterrupted()
- && (line = connection.getInputStream().readLine()) != null) {
- if (line.equalsIgnoreCase("LIST UPDATE")) {
- notifyWindowsChanged(device);
- } else if (line.equalsIgnoreCase("FOCUS UPDATE")) {
- notifyFocusChanged(device);
- }
- }
-
- } catch (IOException e) {
- } finally {
- if (connection != null) {
- connection.close();
- }
- }
- }
- }
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/DeviceSelectionModel.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/DeviceSelectionModel.java
deleted file mode 100644
index 9ac9b40..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/DeviceSelectionModel.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.models;
-
-import com.android.hierarchyviewerlib.device.IHvDevice;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * This class stores the list of windows for each connected device. It notifies
- * listeners of any changes as well as knows which window is currently selected
- * in the device selector.
- */
-public class DeviceSelectionModel {
- private final Map<IHvDevice, DeviceInfo> mDeviceMap = new HashMap<IHvDevice, DeviceInfo>(10);
- private final Map<IHvDevice, Integer> mFocusedWindowHashes =
- new HashMap<IHvDevice, Integer>(20);
-
- private final ArrayList<IWindowChangeListener> mWindowChangeListeners =
- new ArrayList<IWindowChangeListener>();
-
- private IHvDevice mSelectedDevice;
-
- private Window mSelectedWindow;
-
- private static DeviceSelectionModel sModel;
-
- private static class DeviceInfo {
- Window[] windows;
-
- private DeviceInfo(Window[] windows) {
- this.windows = windows;
- }
- }
- public static DeviceSelectionModel getModel() {
- if (sModel == null) {
- sModel = new DeviceSelectionModel();
- }
- return sModel;
- }
-
- public void addDevice(IHvDevice hvDevice) {
- synchronized (mDeviceMap) {
- DeviceInfo info = new DeviceInfo(hvDevice.getWindows());
- mDeviceMap.put(hvDevice, info);
- }
-
- notifyDeviceConnected(hvDevice);
- }
-
- public void removeDevice(IHvDevice hvDevice) {
- boolean selectionChanged = false;
- synchronized (mDeviceMap) {
- mDeviceMap.remove(hvDevice);
- mFocusedWindowHashes.remove(hvDevice);
- if (mSelectedDevice == hvDevice) {
- mSelectedDevice = null;
- mSelectedWindow = null;
- selectionChanged = true;
- }
- }
- notifyDeviceDisconnected(hvDevice);
- if (selectionChanged) {
- notifySelectionChanged(mSelectedDevice, mSelectedWindow);
- }
- }
-
- public void updateDevice(IHvDevice hvDevice) {
- boolean selectionChanged = false;
- synchronized (mDeviceMap) {
- Window[] windows = hvDevice.getWindows();
- mDeviceMap.put(hvDevice, new DeviceInfo(windows));
-
- // If the selected window no longer exists, we clear the selection.
- if (mSelectedDevice == hvDevice && mSelectedWindow != null) {
- boolean windowStillExists = false;
- for (int i = 0; i < windows.length && !windowStillExists; i++) {
- if (windows[i].equals(mSelectedWindow)) {
- windowStillExists = true;
- }
- }
- if (!windowStillExists) {
- mSelectedDevice = null;
- mSelectedWindow = null;
- selectionChanged = true;
- }
- }
- }
-
- notifyDeviceChanged(hvDevice);
- if (selectionChanged) {
- notifySelectionChanged(mSelectedDevice, mSelectedWindow);
- }
- }
-
- /*
- * Change which window has focus and notify the listeners.
- */
- public void updateFocusedWindow(IHvDevice device, int focusedWindow) {
- Integer oldValue = null;
- synchronized (mDeviceMap) {
- oldValue = mFocusedWindowHashes.put(device, new Integer(focusedWindow));
- }
- // Only notify if the values are different. It would be cool if Java
- // containers accepted basic types like int.
- if (oldValue == null || (oldValue != null && oldValue.intValue() != focusedWindow)) {
- notifyFocusChanged(device);
- }
- }
-
- public static interface IWindowChangeListener {
- public void deviceConnected(IHvDevice device);
-
- public void deviceChanged(IHvDevice device);
-
- public void deviceDisconnected(IHvDevice device);
-
- public void focusChanged(IHvDevice device);
-
- public void selectionChanged(IHvDevice device, Window window);
- }
-
- private IWindowChangeListener[] getWindowChangeListenerList() {
- IWindowChangeListener[] listeners = null;
- synchronized (mWindowChangeListeners) {
- if (mWindowChangeListeners.size() == 0) {
- return null;
- }
- listeners =
- mWindowChangeListeners.toArray(new IWindowChangeListener[mWindowChangeListeners
- .size()]);
- }
- return listeners;
- }
-
- private void notifyDeviceConnected(IHvDevice device) {
- IWindowChangeListener[] listeners = getWindowChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].deviceConnected(device);
- }
- }
- }
-
- private void notifyDeviceChanged(IHvDevice device) {
- IWindowChangeListener[] listeners = getWindowChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].deviceChanged(device);
- }
- }
- }
-
- private void notifyDeviceDisconnected(IHvDevice device) {
- IWindowChangeListener[] listeners = getWindowChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].deviceDisconnected(device);
- }
- }
- }
-
- private void notifyFocusChanged(IHvDevice device) {
- IWindowChangeListener[] listeners = getWindowChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].focusChanged(device);
- }
- }
- }
-
- private void notifySelectionChanged(IHvDevice device, Window window) {
- IWindowChangeListener[] listeners = getWindowChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].selectionChanged(device, window);
- }
- }
- }
-
- public void addWindowChangeListener(IWindowChangeListener listener) {
- synchronized (mWindowChangeListeners) {
- mWindowChangeListeners.add(listener);
- }
- }
-
- public void removeWindowChangeListener(IWindowChangeListener listener) {
- synchronized (mWindowChangeListeners) {
- mWindowChangeListeners.remove(listener);
- }
- }
-
- public IHvDevice[] getDevices() {
- synchronized (mDeviceMap) {
- Set<IHvDevice> devices = mDeviceMap.keySet();
- return devices.toArray(new IHvDevice[devices.size()]);
- }
- }
-
- public Window[] getWindows(IHvDevice device) {
- synchronized (mDeviceMap) {
- DeviceInfo info = mDeviceMap.get(device);
- if (info != null) {
- return info.windows;
- }
- }
-
- return null;
- }
-
- // Returns the window that currently has focus or -1. Note that this means
- // that a window with hashcode -1 gets highlighted. If you remember, this is
- // the infamous <Focused Window>
- public int getFocusedWindow(IHvDevice device) {
- synchronized (mDeviceMap) {
- Integer focusedWindow = mFocusedWindowHashes.get(device);
- if (focusedWindow == null) {
- return -1;
- }
- return focusedWindow.intValue();
- }
- }
-
- public void setSelection(IHvDevice device, Window window) {
- synchronized (mDeviceMap) {
- mSelectedDevice = device;
- mSelectedWindow = window;
- }
- notifySelectionChanged(device, window);
- }
-
- public IHvDevice getSelectedDevice() {
- synchronized (mDeviceMap) {
- return mSelectedDevice;
- }
- }
-
- public Window getSelectedWindow() {
- synchronized (mDeviceMap) {
- return mSelectedWindow;
- }
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/PixelPerfectModel.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/PixelPerfectModel.java
deleted file mode 100644
index a425b47..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/PixelPerfectModel.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.models;
-
-import com.android.ddmlib.IDevice;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Display;
-
-import java.util.ArrayList;
-
-public class PixelPerfectModel {
-
- public static final int MIN_ZOOM = 2;
-
- public static final int MAX_ZOOM = 24;
-
- public static final int DEFAULT_ZOOM = 8;
-
- public static final int DEFAULT_OVERLAY_TRANSPARENCY_PERCENTAGE = 50;
-
- private IDevice mDevice;
-
- private Image mImage;
-
- private Point mCrosshairLocation;
-
- private ViewNode mViewNode;
-
- private ViewNode mSelectedNode;
-
- private int mZoom;
-
- private final ArrayList<IImageChangeListener> mImageChangeListeners =
- new ArrayList<IImageChangeListener>();
-
- private Image mOverlayImage;
-
- private double mOverlayTransparency = DEFAULT_OVERLAY_TRANSPARENCY_PERCENTAGE / 100.0;
-
- private static PixelPerfectModel sModel;
-
- public static PixelPerfectModel getModel() {
- if (sModel == null) {
- sModel = new PixelPerfectModel();
- }
- return sModel;
- }
-
- public void setData(final IDevice device, final Image image, final ViewNode viewNode) {
- final Image toDispose = this.mImage;
- final Image toDispose2 = this.mOverlayImage;
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (PixelPerfectModel.this) {
- PixelPerfectModel.this.mDevice = device;
- PixelPerfectModel.this.mImage = image;
- PixelPerfectModel.this.mViewNode = viewNode;
- if (image != null) {
- PixelPerfectModel.this.mCrosshairLocation =
- new Point(image.getBounds().width / 2, image.getBounds().height / 2);
- } else {
- PixelPerfectModel.this.mCrosshairLocation = null;
- }
- mOverlayImage = null;
- PixelPerfectModel.this.mSelectedNode = null;
- mZoom = DEFAULT_ZOOM;
- }
- }
- });
- notifyImageLoaded();
- if (toDispose != null) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- toDispose.dispose();
- }
- });
- }
- if (toDispose2 != null) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- toDispose2.dispose();
- }
- });
- }
-
- }
-
- public void setCrosshairLocation(int x, int y) {
- synchronized (this) {
- mCrosshairLocation = new Point(x, y);
- }
- notifyCrosshairMoved();
- }
-
- public void setSelected(ViewNode selected) {
- synchronized (this) {
- this.mSelectedNode = selected;
- }
- notifySelectionChanged();
- }
-
- public void setTree(final ViewNode viewNode) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (PixelPerfectModel.this) {
- PixelPerfectModel.this.mViewNode = viewNode;
- PixelPerfectModel.this.mSelectedNode = null;
- }
- }
- });
- notifyTreeChanged();
- }
-
- public void setImage(final Image image) {
- final Image toDispose = this.mImage;
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (PixelPerfectModel.this) {
- PixelPerfectModel.this.mImage = image;
- }
- }
- });
- notifyImageChanged();
- if (toDispose != null) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- toDispose.dispose();
- }
- });
- }
- }
-
- public void setZoom(int newZoom) {
- synchronized (this) {
- if (newZoom < MIN_ZOOM) {
- newZoom = MIN_ZOOM;
- }
- if (newZoom > MAX_ZOOM) {
- newZoom = MAX_ZOOM;
- }
- mZoom = newZoom;
- }
- notifyZoomChanged();
- }
-
- public void setOverlayImage(final Image overlayImage) {
- final Image toDispose = this.mOverlayImage;
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (PixelPerfectModel.this) {
- PixelPerfectModel.this.mOverlayImage = overlayImage;
- }
- }
- });
- notifyOverlayChanged();
- if (toDispose != null) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- toDispose.dispose();
- }
- });
- }
- }
-
- public void setOverlayTransparency(double value) {
- synchronized (this) {
- value = Math.max(value, 0);
- value = Math.min(value, 1);
- mOverlayTransparency = value;
- }
- notifyOverlayTransparencyChanged();
- }
-
- public ViewNode getViewNode() {
- synchronized (this) {
- return mViewNode;
- }
- }
-
- public Point getCrosshairLocation() {
- synchronized (this) {
- return mCrosshairLocation;
- }
- }
-
- public Image getImage() {
- synchronized (this) {
- return mImage;
- }
- }
-
- public ViewNode getSelected() {
- synchronized (this) {
- return mSelectedNode;
- }
- }
-
- public IDevice getDevice() {
- synchronized (this) {
- return mDevice;
- }
- }
-
- public int getZoom() {
- synchronized (this) {
- return mZoom;
- }
- }
-
- public Image getOverlayImage() {
- synchronized (this) {
- return mOverlayImage;
- }
- }
-
- public double getOverlayTransparency() {
- synchronized (this) {
- return mOverlayTransparency;
- }
- }
-
- public static interface IImageChangeListener {
- public void imageLoaded();
-
- public void imageChanged();
-
- public void crosshairMoved();
-
- public void selectionChanged();
-
- public void treeChanged();
-
- public void zoomChanged();
-
- public void overlayChanged();
-
- public void overlayTransparencyChanged();
- }
-
- private IImageChangeListener[] getImageChangeListenerList() {
- IImageChangeListener[] listeners = null;
- synchronized (mImageChangeListeners) {
- if (mImageChangeListeners.size() == 0) {
- return null;
- }
- listeners =
- mImageChangeListeners.toArray(new IImageChangeListener[mImageChangeListeners
- .size()]);
- }
- return listeners;
- }
-
- public void notifyImageLoaded() {
- IImageChangeListener[] listeners = getImageChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].imageLoaded();
- }
- }
- }
-
- public void notifyImageChanged() {
- IImageChangeListener[] listeners = getImageChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].imageChanged();
- }
- }
- }
-
- public void notifyCrosshairMoved() {
- IImageChangeListener[] listeners = getImageChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].crosshairMoved();
- }
- }
- }
-
- public void notifySelectionChanged() {
- IImageChangeListener[] listeners = getImageChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].selectionChanged();
- }
- }
- }
-
- public void notifyTreeChanged() {
- IImageChangeListener[] listeners = getImageChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].treeChanged();
- }
- }
- }
-
- public void notifyZoomChanged() {
- IImageChangeListener[] listeners = getImageChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].zoomChanged();
- }
- }
- }
-
- public void notifyOverlayChanged() {
- IImageChangeListener[] listeners = getImageChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].overlayChanged();
- }
- }
- }
-
- public void notifyOverlayTransparencyChanged() {
- IImageChangeListener[] listeners = getImageChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].overlayTransparencyChanged();
- }
- }
- }
-
- public void addImageChangeListener(IImageChangeListener listener) {
- synchronized (mImageChangeListeners) {
- mImageChangeListeners.add(listener);
- }
- }
-
- public void removeImageChangeListener(IImageChangeListener listener) {
- synchronized (mImageChangeListeners) {
- mImageChangeListeners.remove(listener);
- }
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/TreeViewModel.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/TreeViewModel.java
deleted file mode 100644
index 6dac1e6..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/TreeViewModel.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.models;
-
-import com.android.hierarchyviewerlib.ui.util.DrawableViewNode;
-import com.android.hierarchyviewerlib.ui.util.DrawableViewNode.Point;
-import com.android.hierarchyviewerlib.ui.util.DrawableViewNode.Rectangle;
-
-import java.util.ArrayList;
-
-public class TreeViewModel {
- public static final double MAX_ZOOM = 2;
-
- public static final double MIN_ZOOM = 0.2;
-
- private Window mWindow;
-
- private DrawableViewNode mTree;
-
- private DrawableViewNode mSelectedNode;
-
- private Rectangle mViewport;
-
- private double mZoom;
-
- private final ArrayList<ITreeChangeListener> mTreeChangeListeners =
- new ArrayList<ITreeChangeListener>();
-
- private static TreeViewModel sModel;
-
- public static TreeViewModel getModel() {
- if (sModel == null) {
- sModel = new TreeViewModel();
- }
- return sModel;
- }
-
- public void setData(Window window, ViewNode viewNode) {
- synchronized (this) {
- if (mTree != null) {
- mTree.viewNode.dispose();
- }
- this.mWindow = window;
- if (viewNode == null) {
- mTree = null;
- } else {
- mTree = new DrawableViewNode(viewNode);
- mTree.setLeft();
- mTree.placeRoot();
- }
- mViewport = null;
- mZoom = 1;
- mSelectedNode = null;
- }
- notifyTreeChanged();
- }
-
- public void setSelection(DrawableViewNode selectedNode) {
- synchronized (this) {
- this.mSelectedNode = selectedNode;
- }
- notifySelectionChanged();
- }
-
- public void setViewport(Rectangle viewport) {
- synchronized (this) {
- this.mViewport = viewport;
- }
- notifyViewportChanged();
- }
-
- public void setZoom(double newZoom) {
- Point zoomPoint = null;
- synchronized (this) {
- if (mTree != null && mViewport != null) {
- zoomPoint =
- new Point(mViewport.x + mViewport.width / 2, mViewport.y + mViewport.height / 2);
- }
- }
- zoomOnPoint(newZoom, zoomPoint);
- }
-
- public void zoomOnPoint(double newZoom, Point zoomPoint) {
- synchronized (this) {
- if (mTree != null && this.mViewport != null) {
- if (newZoom < MIN_ZOOM) {
- newZoom = MIN_ZOOM;
- }
- if (newZoom > MAX_ZOOM) {
- newZoom = MAX_ZOOM;
- }
- mViewport.x = zoomPoint.x - (zoomPoint.x - mViewport.x) * mZoom / newZoom;
- mViewport.y = zoomPoint.y - (zoomPoint.y - mViewport.y) * mZoom / newZoom;
- mViewport.width = mViewport.width * mZoom / newZoom;
- mViewport.height = mViewport.height * mZoom / newZoom;
- mZoom = newZoom;
- }
- }
- notifyZoomChanged();
- }
-
- public DrawableViewNode getTree() {
- synchronized (this) {
- return mTree;
- }
- }
-
- public Window getWindow() {
- synchronized (this) {
- return mWindow;
- }
- }
-
- public Rectangle getViewport() {
- synchronized (this) {
- return mViewport;
- }
- }
-
- public double getZoom() {
- synchronized (this) {
- return mZoom;
- }
- }
-
- public DrawableViewNode getSelection() {
- synchronized (this) {
- return mSelectedNode;
- }
- }
-
- public static interface ITreeChangeListener {
- public void treeChanged();
-
- public void selectionChanged();
-
- public void viewportChanged();
-
- public void zoomChanged();
- }
-
- private ITreeChangeListener[] getTreeChangeListenerList() {
- ITreeChangeListener[] listeners = null;
- synchronized (mTreeChangeListeners) {
- if (mTreeChangeListeners.size() == 0) {
- return null;
- }
- listeners =
- mTreeChangeListeners.toArray(new ITreeChangeListener[mTreeChangeListeners.size()]);
- }
- return listeners;
- }
-
- public void notifyTreeChanged() {
- ITreeChangeListener[] listeners = getTreeChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].treeChanged();
- }
- }
- }
-
- public void notifySelectionChanged() {
- ITreeChangeListener[] listeners = getTreeChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].selectionChanged();
- }
- }
- }
-
- public void notifyViewportChanged() {
- ITreeChangeListener[] listeners = getTreeChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].viewportChanged();
- }
- }
- }
-
- public void notifyZoomChanged() {
- ITreeChangeListener[] listeners = getTreeChangeListenerList();
- if (listeners != null) {
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].zoomChanged();
- }
- }
- }
-
- public void addTreeChangeListener(ITreeChangeListener listener) {
- synchronized (mTreeChangeListeners) {
- mTreeChangeListeners.add(listener);
- }
- }
-
- public void removeTreeChangeListener(ITreeChangeListener listener) {
- synchronized (mTreeChangeListeners) {
- mTreeChangeListeners.remove(listener);
- }
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/ViewNode.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/ViewNode.java
deleted file mode 100644
index e38da00..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/ViewNode.java
+++ /dev/null
@@ -1,369 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.models;
-
-import org.eclipse.swt.graphics.Image;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-
-public class ViewNode {
-
- public static enum ProfileRating {
- RED, YELLOW, GREEN, NONE
- };
-
- private static final double RED_THRESHOLD = 0.8;
-
- private static final double YELLOW_THRESHOLD = 0.5;
-
- public static final String MISCELLANIOUS = "miscellaneous";
-
- public String id;
-
- public String name;
-
- public String hashCode;
-
- public List<Property> properties = new ArrayList<Property>();
-
- public Map<String, Property> namedProperties = new HashMap<String, Property>();
-
- public ViewNode parent;
-
- public List<ViewNode> children = new ArrayList<ViewNode>();
-
- public int left;
-
- public int top;
-
- public int width;
-
- public int height;
-
- public int scrollX;
-
- public int scrollY;
-
- public int paddingLeft;
-
- public int paddingRight;
-
- public int paddingTop;
-
- public int paddingBottom;
-
- public int marginLeft;
-
- public int marginRight;
-
- public int marginTop;
-
- public int marginBottom;
-
- public int baseline;
-
- public boolean willNotDraw;
-
- public boolean hasMargins;
-
- public boolean hasFocus;
-
- public int index;
-
- public double measureTime;
-
- public double layoutTime;
-
- public double drawTime;
-
- public ProfileRating measureRating = ProfileRating.NONE;
-
- public ProfileRating layoutRating = ProfileRating.NONE;
-
- public ProfileRating drawRating = ProfileRating.NONE;
-
- public Set<String> categories = new TreeSet<String>();
-
- public Window window;
-
- public Image image;
-
- public int imageReferences = 1;
-
- public int viewCount;
-
- public boolean filtered;
-
- public int protocolVersion;
-
- public ViewNode(Window window, ViewNode parent, String data) {
- this.window = window;
- this.parent = parent;
- index = this.parent == null ? 0 : this.parent.children.size();
- if (this.parent != null) {
- this.parent.children.add(this);
- }
- int delimIndex = data.indexOf('@');
- if (delimIndex < 0) {
- throw new IllegalArgumentException("Invalid format for ViewNode, missing @: " + data);
- }
- name = data.substring(0, delimIndex);
- data = data.substring(delimIndex + 1);
- delimIndex = data.indexOf(' ');
- hashCode = data.substring(0, delimIndex);
-
- if (data.length() > delimIndex + 1) {
- loadProperties(data.substring(delimIndex + 1).trim());
- } else {
- // defaults in case properties are not available
- id = "unknown";
- width = height = 10;
- }
-
- measureTime = -1;
- layoutTime = -1;
- drawTime = -1;
- }
-
- public void dispose() {
- final int N = children.size();
- for (int i = 0; i < N; i++) {
- children.get(i).dispose();
- }
- dereferenceImage();
- }
-
- public void referenceImage() {
- imageReferences++;
- }
-
- public void dereferenceImage() {
- imageReferences--;
- if (image != null && imageReferences == 0) {
- image.dispose();
- }
- }
-
- private void loadProperties(String data) {
- int start = 0;
- boolean stop;
- do {
- int index = data.indexOf('=', start);
- ViewNode.Property property = new ViewNode.Property();
- property.name = data.substring(start, index);
-
- int index2 = data.indexOf(',', index + 1);
- int length = Integer.parseInt(data.substring(index + 1, index2));
- start = index2 + 1 + length;
- property.value = data.substring(index2 + 1, index2 + 1 + length);
-
- properties.add(property);
- namedProperties.put(property.name, property);
-
- stop = start >= data.length();
- if (!stop) {
- start += 1;
- }
- } while (!stop);
-
- Collections.sort(properties, new Comparator<ViewNode.Property>() {
- @Override
- public int compare(ViewNode.Property source, ViewNode.Property destination) {
- return source.name.compareTo(destination.name);
- }
- });
-
- id = namedProperties.get("mID").value; //$NON-NLS-1$
-
- left =
- namedProperties.containsKey("mLeft") ? getInt("mLeft", 0) : getInt("layout:mLeft", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- 0);
- top = namedProperties.containsKey("mTop") ? getInt("mTop", 0) : getInt("layout:mTop", 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- width =
- namedProperties.containsKey("getWidth()") ? getInt("getWidth()", 0) : getInt( //$NON-NLS-1$ //$NON-NLS-2$
- "layout:getWidth()", 0); //$NON-NLS-1$
- height =
- namedProperties.containsKey("getHeight()") ? getInt("getHeight()", 0) : getInt( //$NON-NLS-1$ //$NON-NLS-2$
- "layout:getHeight()", 0); //$NON-NLS-1$
- scrollX =
- namedProperties.containsKey("mScrollX") ? getInt("mScrollX", 0) : getInt( //$NON-NLS-1$ //$NON-NLS-2$
- "scrolling:mScrollX", 0); //$NON-NLS-1$
- scrollY =
- namedProperties.containsKey("mScrollY") ? getInt("mScrollY", 0) : getInt( //$NON-NLS-1$ //$NON-NLS-2$
- "scrolling:mScrollY", 0); //$NON-NLS-1$
- paddingLeft =
- namedProperties.containsKey("mPaddingLeft") ? getInt("mPaddingLeft", 0) : getInt( //$NON-NLS-1$ //$NON-NLS-2$
- "padding:mPaddingLeft", 0); //$NON-NLS-1$
- paddingRight =
- namedProperties.containsKey("mPaddingRight") ? getInt("mPaddingRight", 0) : getInt( //$NON-NLS-1$ //$NON-NLS-2$
- "padding:mPaddingRight", 0); //$NON-NLS-1$
- paddingTop =
- namedProperties.containsKey("mPaddingTop") ? getInt("mPaddingTop", 0) : getInt( //$NON-NLS-1$ //$NON-NLS-2$
- "padding:mPaddingTop", 0); //$NON-NLS-1$
- paddingBottom =
- namedProperties.containsKey("mPaddingBottom") ? getInt("mPaddingBottom", 0) //$NON-NLS-1$ //$NON-NLS-2$
- : getInt("padding:mPaddingBottom", 0); //$NON-NLS-1$
- marginLeft =
- namedProperties.containsKey("layout_leftMargin") ? getInt("layout_leftMargin", //$NON-NLS-1$ //$NON-NLS-2$
- Integer.MIN_VALUE) : getInt("layout:layout_leftMargin", Integer.MIN_VALUE); //$NON-NLS-1$
- marginRight =
- namedProperties.containsKey("layout_rightMargin") ? getInt("layout_rightMargin", //$NON-NLS-1$ //$NON-NLS-2$
- Integer.MIN_VALUE) : getInt("layout:layout_rightMargin", Integer.MIN_VALUE); //$NON-NLS-1$
- marginTop =
- namedProperties.containsKey("layout_topMargin") ? getInt("layout_topMargin", //$NON-NLS-1$ //$NON-NLS-2$
- Integer.MIN_VALUE) : getInt("layout:layout_topMargin", Integer.MIN_VALUE); //$NON-NLS-1$
- marginBottom =
- namedProperties.containsKey("layout_bottomMargin") ? getInt("layout_bottomMargin", //$NON-NLS-1$ //$NON-NLS-2$
- Integer.MIN_VALUE)
- : getInt("layout:layout_bottomMargin", Integer.MIN_VALUE); //$NON-NLS-1$
- baseline =
- namedProperties.containsKey("getBaseline()") ? getInt("getBaseline()", 0) : getInt( //$NON-NLS-1$ //$NON-NLS-2$
- "layout:getBaseline()", 0); //$NON-NLS-1$
- willNotDraw =
- namedProperties.containsKey("willNotDraw()") ? getBoolean("willNotDraw()", false) //$NON-NLS-1$ //$NON-NLS-2$
- : getBoolean("drawing:willNotDraw()", false); //$NON-NLS-1$
- hasFocus =
- namedProperties.containsKey("hasFocus()") ? getBoolean("hasFocus()", false) //$NON-NLS-1$ //$NON-NLS-2$
- : getBoolean("focus:hasFocus()", false); //$NON-NLS-1$
-
- hasMargins =
- marginLeft != Integer.MIN_VALUE && marginRight != Integer.MIN_VALUE
- && marginTop != Integer.MIN_VALUE && marginBottom != Integer.MIN_VALUE;
-
- for (String name : namedProperties.keySet()) {
- int index = name.indexOf(':');
- if (index != -1) {
- categories.add(name.substring(0, index));
- }
- }
- if (categories.size() != 0) {
- categories.add(MISCELLANIOUS);
- }
- }
-
- public void setProfileRatings() {
- final int N = children.size();
- if (N > 1) {
- double totalMeasure = 0;
- double totalLayout = 0;
- double totalDraw = 0;
- for (int i = 0; i < N; i++) {
- ViewNode child = children.get(i);
- totalMeasure += child.measureTime;
- totalLayout += child.layoutTime;
- totalDraw += child.drawTime;
- }
- for (int i = 0; i < N; i++) {
- ViewNode child = children.get(i);
- if (child.measureTime / totalMeasure >= RED_THRESHOLD) {
- child.measureRating = ProfileRating.RED;
- } else if (child.measureTime / totalMeasure >= YELLOW_THRESHOLD) {
- child.measureRating = ProfileRating.YELLOW;
- } else {
- child.measureRating = ProfileRating.GREEN;
- }
- if (child.layoutTime / totalLayout >= RED_THRESHOLD) {
- child.layoutRating = ProfileRating.RED;
- } else if (child.layoutTime / totalLayout >= YELLOW_THRESHOLD) {
- child.layoutRating = ProfileRating.YELLOW;
- } else {
- child.layoutRating = ProfileRating.GREEN;
- }
- if (child.drawTime / totalDraw >= RED_THRESHOLD) {
- child.drawRating = ProfileRating.RED;
- } else if (child.drawTime / totalDraw >= YELLOW_THRESHOLD) {
- child.drawRating = ProfileRating.YELLOW;
- } else {
- child.drawRating = ProfileRating.GREEN;
- }
- }
- }
- for (int i = 0; i < N; i++) {
- children.get(i).setProfileRatings();
- }
- }
-
- public void setViewCount() {
- viewCount = 1;
- final int N = children.size();
- for (int i = 0; i < N; i++) {
- ViewNode child = children.get(i);
- child.setViewCount();
- viewCount += child.viewCount;
- }
- }
-
- public void filter(String text) {
- int dotIndex = name.lastIndexOf('.');
- String shortName = (dotIndex == -1) ? name : name.substring(dotIndex + 1);
- filtered =
- !text.equals("") //$NON-NLS-1$
- && (shortName.toLowerCase().contains(text.toLowerCase()) || (!id
- .equals("NO_ID") && id.toLowerCase().contains(text.toLowerCase()))); //$NON-NLS-1$
- final int N = children.size();
- for (int i = 0; i < N; i++) {
- children.get(i).filter(text);
- }
- }
-
- private boolean getBoolean(String name, boolean defaultValue) {
- Property p = namedProperties.get(name);
- if (p != null) {
- try {
- return Boolean.parseBoolean(p.value);
- } catch (NumberFormatException e) {
- return defaultValue;
- }
- }
- return defaultValue;
- }
-
- private int getInt(String name, int defaultValue) {
- Property p = namedProperties.get(name);
- if (p != null) {
- try {
- return Integer.parseInt(p.value);
- } catch (NumberFormatException e) {
- return defaultValue;
- }
- }
- return defaultValue;
- }
-
- @Override
- public String toString() {
- return name + "@" + hashCode; //$NON-NLS-1$
- }
-
- public static class Property {
- public String name;
-
- public String value;
-
- @Override
- public String toString() {
- return name + '=' + value;
- }
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/Window.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/Window.java
deleted file mode 100644
index 4e260a9..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/models/Window.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.models;
-
-import com.android.ddmlib.Client;
-import com.android.ddmlib.IDevice;
-import com.android.hierarchyviewerlib.device.IHvDevice;
-
-/**
- * Used for storing a window from the window manager service on the device.
- * These are the windows that the device selector shows.
- */
-public class Window {
- private final String mTitle;
- private final int mHashCode;
- private final IHvDevice mHvDevice;
- private final Client mClient;
-
- public Window(IHvDevice device, String title, int hashCode) {
- mHvDevice = device;
- mTitle = title;
- mHashCode = hashCode;
- mClient = null;
- }
-
- public Window(IHvDevice device, String title, Client c) {
- mHvDevice = device;
- mTitle = title;
- mClient = c;
- mHashCode = c.hashCode();
- }
-
- public String getTitle() {
- return mTitle;
- }
-
- public int getHashCode() {
- return mHashCode;
- }
-
- public String encode() {
- return Integer.toHexString(mHashCode);
- }
-
- @Override
- public String toString() {
- return mTitle;
- }
-
- public IHvDevice getHvDevice() {
- return mHvDevice;
- }
-
- public IDevice getDevice() {
- return mHvDevice.getDevice();
- }
-
- public Client getClient() {
- return mClient;
- }
-
- public static Window getFocusedWindow(IHvDevice device) {
- return new Window(device, "<Focused Window>", -1);
- }
-
- /*
- * After each refresh of the windows in the device selector, the windows are
- * different instances and automatically reselecting the same window doesn't
- * work in the device selector unless the equals method is defined here.
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj)
- return true;
- if (obj == null)
- return false;
- if (getClass() != obj.getClass())
- return false;
-
- Window other = (Window) obj;
- if (mHvDevice == null) {
- if (other.mHvDevice != null)
- return false;
- } else if (!mHvDevice.getDevice().getSerialNumber().equals(
- other.mHvDevice.getDevice().getSerialNumber()))
- return false;
-
- if (mHashCode != other.mHashCode)
- return false;
-
- return true;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result +
- ((mHvDevice == null) ? 0 : mHvDevice.getDevice().getSerialNumber().hashCode());
- result = prime * result + mHashCode;
- return result;
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/CaptureDisplay.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/CaptureDisplay.java
deleted file mode 100644
index 7d4fdba..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/CaptureDisplay.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-import com.android.hierarchyviewerlib.models.ViewNode;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.ShellAdapter;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-public class CaptureDisplay {
- private static Shell sShell;
-
- private static Canvas sCanvas;
-
- private static Image sImage;
-
- private static ViewNode sViewNode;
-
- private static Composite sButtonBar;
-
- private static Button sOnWhite;
-
- private static Button sOnBlack;
-
- private static Button sShowExtras;
-
- public static void show(Shell parentShell, ViewNode viewNode, Image image) {
- if (sShell == null) {
- createShell();
- }
- if (sShell.isVisible() && CaptureDisplay.sViewNode != null) {
- CaptureDisplay.sViewNode.dereferenceImage();
- }
- CaptureDisplay.sImage = image;
- CaptureDisplay.sViewNode = viewNode;
- viewNode.referenceImage();
- sShell.setText(viewNode.name);
-
- boolean shellVisible = sShell.isVisible();
- if (!shellVisible) {
- sShell.setSize(0, 0);
- }
- Rectangle bounds =
- sShell.computeTrim(0, 0, Math.max(sButtonBar.getBounds().width,
- image.getBounds().width), sButtonBar.getBounds().height
- + image.getBounds().height + 5);
- sShell.setSize(bounds.width, bounds.height);
- if (!shellVisible) {
- sShell.setLocation(parentShell.getBounds().x
- + (parentShell.getBounds().width - bounds.width) / 2, parentShell.getBounds().y
- + (parentShell.getBounds().height - bounds.height) / 2);
- }
- sShell.open();
- if (shellVisible) {
- sCanvas.redraw();
- }
- }
-
- private static void createShell() {
- sShell = new Shell(Display.getDefault(), SWT.CLOSE | SWT.TITLE);
- GridLayout gridLayout = new GridLayout();
- gridLayout.marginWidth = 0;
- gridLayout.marginHeight = 0;
- sShell.setLayout(gridLayout);
-
- sButtonBar = new Composite(sShell, SWT.NONE);
- RowLayout rowLayout = new RowLayout(SWT.HORIZONTAL);
- rowLayout.pack = true;
- rowLayout.center = true;
- sButtonBar.setLayout(rowLayout);
- Composite buttons = new Composite(sButtonBar, SWT.NONE);
- buttons.setLayout(new FillLayout());
-
- sOnWhite = new Button(buttons, SWT.TOGGLE);
- sOnWhite.setText("On White");
- sOnBlack = new Button(buttons, SWT.TOGGLE);
- sOnBlack.setText("On Black");
- sOnBlack.setSelection(true);
- sOnWhite.addSelectionListener(sWhiteSelectionListener);
- sOnBlack.addSelectionListener(sBlackSelectionListener);
-
- sShowExtras = new Button(sButtonBar, SWT.CHECK);
- sShowExtras.setText("Show Extras");
- sShowExtras.addSelectionListener(sExtrasSelectionListener);
-
- sCanvas = new Canvas(sShell, SWT.NONE);
- sCanvas.setLayoutData(new GridData(GridData.FILL_BOTH));
- sCanvas.addPaintListener(sPaintListener);
-
- sShell.addShellListener(sShellListener);
-
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- Image image = imageLoader.loadImage("display.png", Display.getDefault()); //$NON-NLS-1$
- sShell.setImage(image);
- }
-
- private static PaintListener sPaintListener = new PaintListener() {
-
- @Override
- public void paintControl(PaintEvent e) {
- if (sOnWhite.getSelection()) {
- e.gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
- } else {
- e.gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
- }
- e.gc.fillRectangle(0, 0, sCanvas.getBounds().width, sCanvas.getBounds().height);
- if (sImage != null) {
- int width = sImage.getBounds().width;
- int height = sImage.getBounds().height;
- int x = (sCanvas.getBounds().width - width) / 2;
- int y = (sCanvas.getBounds().height - height) / 2;
- e.gc.drawImage(sImage, x, y);
- if (sShowExtras.getSelection()) {
- if ((sViewNode.paddingLeft | sViewNode.paddingRight | sViewNode.paddingTop | sViewNode.paddingBottom) != 0) {
- e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLUE));
- e.gc.drawRectangle(x + sViewNode.paddingLeft, y + sViewNode.paddingTop, width
- - sViewNode.paddingLeft - sViewNode.paddingRight - 1, height
- - sViewNode.paddingTop - sViewNode.paddingBottom - 1);
- }
- if (sViewNode.hasMargins) {
- e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_GREEN));
- e.gc.drawRectangle(x - sViewNode.marginLeft, y - sViewNode.marginTop, width
- + sViewNode.marginLeft + sViewNode.marginRight - 1, height
- + sViewNode.marginTop + sViewNode.marginBottom - 1);
- }
- if (sViewNode.baseline != -1) {
- e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
- e.gc.drawLine(x, y + sViewNode.baseline, x + width - 1, sViewNode.baseline);
- }
- }
- }
- }
- };
-
- private static ShellAdapter sShellListener = new ShellAdapter() {
- @Override
- public void shellClosed(ShellEvent e) {
- e.doit = false;
- sShell.setVisible(false);
- if (sViewNode != null) {
- sViewNode.dereferenceImage();
- }
- }
-
- };
-
- private static SelectionListener sWhiteSelectionListener = new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // pass
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- sOnWhite.setSelection(true);
- sOnBlack.setSelection(false);
- sCanvas.redraw();
- }
- };
-
- private static SelectionListener sBlackSelectionListener = new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // pass
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- sOnBlack.setSelection(true);
- sOnWhite.setSelection(false);
- sCanvas.redraw();
- }
- };
-
- private static SelectionListener sExtrasSelectionListener = new SelectionListener() {
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // pass
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- sCanvas.redraw();
- }
- };
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/DevicePropertyEditingSupport.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/DevicePropertyEditingSupport.java
deleted file mode 100644
index 1bbc97f..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/DevicePropertyEditingSupport.java
+++ /dev/null
@@ -1,302 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui;
-
-import com.android.SdkConstants;
-import com.android.hierarchyviewerlib.device.IHvDevice;
-import com.android.hierarchyviewerlib.models.ViewNode;
-import com.android.hierarchyviewerlib.models.ViewNode.Property;
-import com.android.utils.SdkUtils;
-import com.google.common.base.Splitter;
-import com.google.common.collect.ImmutableSet;
-
-import java.text.ParseException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-import java.util.Set;
-
-public class DevicePropertyEditingSupport {
- public enum PropertyType {
- INTEGER,
- INTEGER_OR_CONSTANT,
- ENUM,
- };
-
- private static final List<IDevicePropertyEditor> sDevicePropertyEditors = Arrays.asList(
- new LayoutPropertyEditor(),
- new PaddingPropertyEditor()
- );
-
- public boolean canEdit(Property p) {
- return getPropertyEditorFor(p) != null;
- }
-
- private IDevicePropertyEditor getPropertyEditorFor(Property p) {
- for (IDevicePropertyEditor pe: sDevicePropertyEditors) {
- if (pe.canEdit(p)) {
- return pe;
- }
- }
-
- return null;
- }
-
- public PropertyType getPropertyType(Property p) {
- return getPropertyEditorFor(p).getType(p);
- }
-
- public String[] getPropertyRange(Property p) {
- return getPropertyEditorFor(p).getPropertyRange(p);
- }
-
- public boolean setValue(Collection<Property> properties, Property p, Object newValue,
- ViewNode viewNode, IHvDevice device) {
- return getPropertyEditorFor(p).setValue(properties, p, newValue, viewNode, device);
- }
-
- private static String stripCategoryPrefix(String name) {
- return name.substring(name.indexOf(':') + 1);
- }
-
- private interface IDevicePropertyEditor {
- boolean canEdit(Property p);
- PropertyType getType(Property p);
- String[] getPropertyRange(Property p);
- boolean setValue(Collection<Property> properties, Property p, Object newValue,
- ViewNode viewNode, IHvDevice device);
- }
-
- private static class LayoutPropertyEditor implements IDevicePropertyEditor {
- private static final Set<String> sLayoutPropertiesWithStringValues =
- ImmutableSet.of(SdkConstants.ATTR_LAYOUT_WIDTH,
- SdkConstants.ATTR_LAYOUT_HEIGHT,
- SdkConstants.ATTR_LAYOUT_GRAVITY);
-
- private static final int MATCH_PARENT = -1;
- private static final int FILL_PARENT = -1;
- private static final int WRAP_CONTENT = -2;
-
- private enum LayoutGravity {
- top(0x30),
- bottom(0x50),
- left(0x03),
- right(0x05),
- center_vertical(0x10),
- fill_vertical(0x70),
- center_horizontal(0x01),
- fill_horizontal(0x07),
- center(0x11),
- fill(0x77),
- clip_vertical(0x80),
- clip_horizontal(0x08),
- start(0x00800003),
- end(0x00800005);
-
- private final int mValue;
-
- private LayoutGravity(int v) {
- mValue = v;
- }
- }
-
- /**
- * Returns true if this is a layout property with either a known string value, or an
- * integer value.
- */
- @Override
- public boolean canEdit(Property p) {
- String name = stripCategoryPrefix(p.name);
- if (!name.startsWith(SdkConstants.ATTR_LAYOUT_RESOURCE_PREFIX)) {
- return false;
- }
-
- if (sLayoutPropertiesWithStringValues.contains(name)) {
- return true;
- }
-
- try {
- SdkUtils.parseLocalizedInt(p.value);
- return true;
- } catch (ParseException e) {
- return false;
- }
- }
-
- @Override
- public PropertyType getType(Property p) {
- String name = stripCategoryPrefix(p.name);
- if (sLayoutPropertiesWithStringValues.contains(name)) {
- return PropertyType.INTEGER_OR_CONSTANT;
- } else {
- return PropertyType.INTEGER;
- }
- }
-
- @Override
- public String[] getPropertyRange(Property p) {
- return new String[0];
- }
-
- @Override
- public boolean setValue(Collection<Property> properties, Property p, Object newValue,
- ViewNode viewNode, IHvDevice device) {
- String name = stripCategoryPrefix(p.name);
-
- // nothing to do if same as current value
- if (p.value.equals(newValue)) {
- return false;
- }
-
- int value = -1;
- String textValue = null;
-
- if (SdkConstants.ATTR_LAYOUT_GRAVITY.equals(name)) {
- value = 0;
- StringBuilder sb = new StringBuilder(20);
- for (String attr: Splitter.on('|').split((String) newValue)) {
- LayoutGravity g;
- try {
- g = LayoutGravity.valueOf(attr);
- } catch (IllegalArgumentException e) {
- // ignore this gravity attribute
- continue;
- }
-
- value |= g.mValue;
-
- if (sb.length() > 0) {
- sb.append('|');
- }
- sb.append(g.name());
- }
- textValue = sb.toString();
- } else if (SdkConstants.ATTR_LAYOUT_HEIGHT.equals(name)
- || SdkConstants.ATTR_LAYOUT_WIDTH.equals(name)) {
- // newValue is of type string, but its contents may be a named constant or a integer
- String s = (String) newValue;
- if (s.equalsIgnoreCase(SdkConstants.VALUE_MATCH_PARENT)) {
- textValue = SdkConstants.VALUE_MATCH_PARENT;
- value = MATCH_PARENT;
- } else if (s.equalsIgnoreCase(SdkConstants.VALUE_FILL_PARENT)) {
- textValue = SdkConstants.VALUE_FILL_PARENT;
- value = FILL_PARENT;
- } else if (s.equalsIgnoreCase(SdkConstants.VALUE_WRAP_CONTENT)) {
- textValue = SdkConstants.VALUE_WRAP_CONTENT;
- value = WRAP_CONTENT;
- }
- }
-
- if (textValue == null) {
- try {
- value = Integer.parseInt((String) newValue);
- } catch (NumberFormatException e) {
- return false;
- }
- }
-
- // attempt to set the value on the device
- name = name.substring(SdkConstants.ATTR_LAYOUT_RESOURCE_PREFIX.length());
- if (device.setLayoutParameter(viewNode.window, viewNode, name, value)) {
- p.value = textValue != null ? textValue : (String) newValue;
- }
-
- return true;
- }
- }
-
- private static class PaddingPropertyEditor implements IDevicePropertyEditor {
- // These names should match the field names used for padding in the Framework's View class
- private static final String PADDING_LEFT = "mPaddingLeft"; //$NON-NLS-1$
- private static final String PADDING_RIGHT = "mPaddingRight"; //$NON-NLS-1$
- private static final String PADDING_TOP = "mPaddingTop"; //$NON-NLS-1$
- private static final String PADDING_BOTTOM = "mPaddingBottom"; //$NON-NLS-1$
-
- private static final Set<String> sPaddingProperties = ImmutableSet.of(
- PADDING_LEFT, PADDING_RIGHT, PADDING_TOP, PADDING_BOTTOM);
-
- @Override
- public boolean canEdit(Property p) {
- return sPaddingProperties.contains(stripCategoryPrefix(p.name));
- }
-
- @Override
- public PropertyType getType(Property p) {
- return PropertyType.INTEGER;
- }
-
- @Override
- public String[] getPropertyRange(Property p) {
- return new String[0];
- }
-
- /**
- * Set padding: Since the only view method is setPadding(l, t, r, b), we need access
- * to all 4 padding's to update any particular one.
- */
- @Override
- public boolean setValue(Collection<Property> properties, Property prop, Object newValue,
- ViewNode viewNode, IHvDevice device) {
- int v;
- try {
- v = Integer.parseInt((String) newValue);
- } catch (NumberFormatException e) {
- return false;
- }
-
- int pLeft = 0;
- int pRight = 0;
- int pTop = 0;
- int pBottom = 0;
-
- String propName = stripCategoryPrefix(prop.name);
- for (Property p: properties) {
- String name = stripCategoryPrefix(p.name);
- if (!sPaddingProperties.contains(name)) {
- continue;
- }
-
- if (name.equals(PADDING_LEFT)) {
- pLeft = propName.equals(PADDING_LEFT) ?
- v : SdkUtils.parseLocalizedInt(p.value, 0);
- } else if (name.equals(PADDING_RIGHT)) {
- pRight = propName.equals(PADDING_RIGHT) ?
- v : SdkUtils.parseLocalizedInt(p.value, 0);
- } else if (name.equals(PADDING_TOP)) {
- pTop = propName.equals(PADDING_TOP) ?
- v : SdkUtils.parseLocalizedInt(p.value, 0);
- } else if (name.equals(PADDING_BOTTOM)) {
- pBottom = propName.equals(PADDING_BOTTOM) ?
- v : SdkUtils.parseLocalizedInt(p.value, 0);
- }
- }
-
- // invoke setPadding() on the device
- device.invokeViewMethod(viewNode.window, viewNode, "setPadding", Arrays.asList(
- Integer.valueOf(pLeft),
- Integer.valueOf(pTop),
- Integer.valueOf(pRight),
- Integer.valueOf(pBottom)
- ));
-
- // update the value set in the property (to avoid reading all properties back from
- // the device)
- prop.value = Integer.toString(v);
- return true;
- }
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/DeviceSelector.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/DeviceSelector.java
deleted file mode 100644
index ae8ad26..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/DeviceSelector.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-import com.android.hierarchyviewerlib.device.IHvDevice;
-import com.android.hierarchyviewerlib.models.DeviceSelectionModel;
-import com.android.hierarchyviewerlib.models.DeviceSelectionModel.IWindowChangeListener;
-import com.android.hierarchyviewerlib.models.Window;
-
-import org.eclipse.jface.viewers.IFontProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
-
-public class DeviceSelector extends Composite implements IWindowChangeListener, SelectionListener {
- private TreeViewer mTreeViewer;
-
- private Tree mTree;
-
- private DeviceSelectionModel mModel;
-
- private Font mBoldFont;
-
- private Image mDeviceImage;
-
- private Image mEmulatorImage;
-
- private final static int ICON_WIDTH = 16;
-
- private boolean mDoTreeViewStuff;
-
- private boolean mDoPixelPerfectStuff;
-
- private class ContentProvider implements ITreeContentProvider, ILabelProvider, IFontProvider {
- @Override
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof IHvDevice && mDoTreeViewStuff) {
- Window[] list = mModel.getWindows((IHvDevice) parentElement);
- if (list != null) {
- return list;
- }
- }
- return new Object[0];
- }
-
- @Override
- public Object getParent(Object element) {
- if (element instanceof Window) {
- return ((Window) element).getDevice();
- }
- return null;
- }
-
- @Override
- public boolean hasChildren(Object element) {
- if (element instanceof IHvDevice && mDoTreeViewStuff) {
- Window[] list = mModel.getWindows((IHvDevice) element);
- if (list != null) {
- return list.length != 0;
- }
- }
- return false;
- }
-
- @Override
- public Object[] getElements(Object inputElement) {
- if (inputElement instanceof DeviceSelectionModel) {
- return mModel.getDevices();
- }
- return new Object[0];
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // pass
- }
-
- @Override
- public Image getImage(Object element) {
- if (element instanceof IHvDevice) {
- if (((IHvDevice) element).getDevice().isEmulator()) {
- return mEmulatorImage;
- }
- return mDeviceImage;
- }
- return null;
- }
-
- @Override
- public String getText(Object element) {
- if (element instanceof IHvDevice) {
- return ((IHvDevice) element).getDevice().getName();
- } else if (element instanceof Window) {
- return ((Window) element).getTitle();
- }
- return null;
- }
-
- @Override
- public Font getFont(Object element) {
- if (element instanceof Window) {
- int focusedWindow = mModel.getFocusedWindow(((Window) element).getHvDevice());
- if (focusedWindow == ((Window) element).getHashCode()) {
- return mBoldFont;
- }
- }
- return null;
- }
-
- @Override
- public void addListener(ILabelProviderListener listener) {
- // pass
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- // pass
- return false;
- }
-
- @Override
- public void removeListener(ILabelProviderListener listener) {
- // pass
- }
- }
-
- public DeviceSelector(Composite parent, boolean doTreeViewStuff, boolean doPixelPerfectStuff) {
- super(parent, SWT.NONE);
- this.mDoTreeViewStuff = doTreeViewStuff;
- this.mDoPixelPerfectStuff = doPixelPerfectStuff;
- setLayout(new FillLayout());
- mTreeViewer = new TreeViewer(this, SWT.SINGLE);
- mTreeViewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS);
-
- mTree = mTreeViewer.getTree();
- mTree.setLinesVisible(true);
- mTree.addSelectionListener(this);
-
- addDisposeListener(mDisposeListener);
-
- loadResources();
-
- mModel = DeviceSelectionModel.getModel();
- ContentProvider contentProvider = new ContentProvider();
- mTreeViewer.setContentProvider(contentProvider);
- mTreeViewer.setLabelProvider(contentProvider);
- mModel.addWindowChangeListener(this);
- mTreeViewer.setInput(mModel);
-
- addControlListener(mControlListener);
- }
-
- public void loadResources() {
- Display display = Display.getDefault();
- Font systemFont = display.getSystemFont();
- FontData[] fontData = systemFont.getFontData();
- FontData[] newFontData = new FontData[fontData.length];
- for (int i = 0; i < fontData.length; i++) {
- newFontData[i] =
- new FontData(fontData[i].getName(), fontData[i].getHeight(), fontData[i]
- .getStyle()
- | SWT.BOLD);
- }
- mBoldFont = new Font(Display.getDefault(), newFontData);
-
- ImageLoader loader = ImageLoader.getDdmUiLibLoader();
- mDeviceImage =
- loader.loadImage(display, "device.png", ICON_WIDTH, ICON_WIDTH, display //$NON-NLS-1$
- .getSystemColor(SWT.COLOR_RED));
-
- mEmulatorImage =
- loader.loadImage(display, "emulator.png", ICON_WIDTH, ICON_WIDTH, display //$NON-NLS-1$
- .getSystemColor(SWT.COLOR_BLUE));
- }
-
- private DisposeListener mDisposeListener = new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- mModel.removeWindowChangeListener(DeviceSelector.this);
- mBoldFont.dispose();
- }
- };
-
- // If the window gets too small, hide the data, otherwise SWT throws an
- // ERROR.
-
- private ControlListener mControlListener = new ControlAdapter() {
- private boolean noInput = false;
-
- @Override
- public void controlResized(ControlEvent e) {
- if (getBounds().height <= 38) {
- mTreeViewer.setInput(null);
- noInput = true;
- } else if (noInput) {
- mTreeViewer.setInput(mModel);
- noInput = false;
- }
- }
- };
-
- @Override
- public boolean setFocus() {
- return mTree.setFocus();
- }
-
- public void setMode(boolean doTreeViewStuff, boolean doPixelPerfectStuff) {
- if (this.mDoTreeViewStuff != doTreeViewStuff
- || this.mDoPixelPerfectStuff != doPixelPerfectStuff) {
- final boolean expandAll = !this.mDoTreeViewStuff && doTreeViewStuff;
- this.mDoTreeViewStuff = doTreeViewStuff;
- this.mDoPixelPerfectStuff = doPixelPerfectStuff;
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- mTreeViewer.refresh();
- if (expandAll) {
- mTreeViewer.expandAll();
- }
- }
- });
- }
- }
-
- @Override
- public void deviceConnected(final IHvDevice device) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- mTreeViewer.refresh();
- mTreeViewer.setExpandedState(device, true);
- }
- });
- }
-
- @Override
- public void deviceChanged(final IHvDevice device) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- TreeSelection selection = (TreeSelection) mTreeViewer.getSelection();
- mTreeViewer.refresh(device);
- if (selection.getFirstElement() instanceof Window
- && ((Window) selection.getFirstElement()).getDevice() == device) {
- mTreeViewer.setSelection(selection, true);
- }
- }
- });
- }
-
- @Override
- public void deviceDisconnected(final IHvDevice device) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- mTreeViewer.refresh();
- }
- });
- }
-
- @Override
- public void focusChanged(final IHvDevice device) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- TreeSelection selection = (TreeSelection) mTreeViewer.getSelection();
- mTreeViewer.refresh(device);
- if (selection.getFirstElement() instanceof Window
- && ((Window) selection.getFirstElement()).getDevice() == device) {
- mTreeViewer.setSelection(selection, true);
- }
- }
- });
- }
-
- @Override
- public void selectionChanged(IHvDevice device, Window window) {
- // pass
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- Object selection = ((TreeItem) e.item).getData();
- if (selection instanceof IHvDevice && mDoPixelPerfectStuff) {
- HierarchyViewerDirector.getDirector().loadPixelPerfectData((IHvDevice) selection);
- } else if (selection instanceof Window && mDoTreeViewStuff) {
- HierarchyViewerDirector.getDirector().loadViewTreeData((Window) selection);
- }
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- TreeItem item = (TreeItem) e.item;
- if (item == null) return;
- Object selection = item.getData();
- if (selection instanceof IHvDevice) {
- mModel.setSelection((IHvDevice) selection, null);
- } else if (selection instanceof Window) {
- mModel.setSelection(((Window) selection).getHvDevice(), (Window) selection);
- }
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/InvokeMethodPrompt.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/InvokeMethodPrompt.java
deleted file mode 100644
index 944a57a..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/InvokeMethodPrompt.java
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui;
-
-import com.android.ddmlib.Log;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-import com.android.hierarchyviewerlib.device.IHvDevice;
-import com.android.hierarchyviewerlib.models.TreeViewModel;
-import com.android.hierarchyviewerlib.models.TreeViewModel.ITreeChangeListener;
-import com.android.hierarchyviewerlib.models.ViewNode;
-import com.android.hierarchyviewerlib.ui.util.DrawableViewNode;
-import com.google.common.base.CharMatcher;
-import com.google.common.base.Splitter;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Text;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-public class InvokeMethodPrompt extends Composite implements ITreeChangeListener {
- private TreeViewModel mModel;
- private DrawableViewNode mSelectedNode;
- private Text mText;
- private static final Splitter CMD_SPLITTER = Splitter.on(CharMatcher.anyOf(", "))
- .trimResults().omitEmptyStrings();
-
- public InvokeMethodPrompt(Composite parent) {
- super(parent, SWT.NONE);
- setLayout(new FillLayout());
-
- mText = new Text(this, SWT.BORDER);
- mText.addKeyListener(new KeyListener() {
- @Override
- public void keyReleased(KeyEvent ke) {
- }
-
- @Override
- public void keyPressed(KeyEvent ke) {
- onKeyPress(ke);
- }
- });
-
- mModel = TreeViewModel.getModel();
- mModel.addTreeChangeListener(this);
- }
-
- private void onKeyPress(KeyEvent ke) {
- if (ke.keyCode == SWT.CR) {
- String cmd = mText.getText().trim();
- if (!cmd.isEmpty()) {
- invokeViewMethod(cmd);
- }
- mText.setText("");
- }
- }
-
- private void invokeViewMethod(String cmd) {
- Iterator<String> segmentIterator = CMD_SPLITTER.split(cmd).iterator();
-
- String method = null;
- if (segmentIterator.hasNext()) {
- method = segmentIterator.next();
- } else {
- return;
- }
-
- List<Object> args = new ArrayList<Object>(10);
- while (segmentIterator.hasNext()) {
- String arg = segmentIterator.next();
-
- // check for boolean
- if (arg.equalsIgnoreCase("true")) {
- args.add(Boolean.TRUE);
- continue;
- } else if (arg.equalsIgnoreCase("false")) {
- args.add(Boolean.FALSE);
- continue;
- }
-
- // see if last character gives a clue regarding the argument type
- char typeSpecifier = Character.toUpperCase(arg.charAt(arg.length() - 1));
- try {
- switch (typeSpecifier) {
- case 'L':
- args.add(Long.valueOf(arg.substring(0, arg.length())));
- break;
- case 'D':
- args.add(Double.valueOf(arg.substring(0, arg.length())));
- break;
- case 'F':
- args.add(Float.valueOf(arg.substring(0, arg.length())));
- break;
- case 'S':
- args.add(Short.valueOf(arg.substring(0, arg.length())));
- break;
- case 'B':
- args.add(Byte.valueOf(arg.substring(0, arg.length())));
- break;
- default: // default to integer
- args.add(Integer.valueOf(arg));
- break;
- }
- } catch (NumberFormatException e) {
- Log.e("hv", "Unable to parse method argument: " + arg);
- return;
- }
- }
-
- HierarchyViewerDirector.getDirector().invokeMethodOnSelectedView(method, args);
- }
-
- @Override
- public void selectionChanged() {
- mSelectedNode = mModel.getSelection();
- refresh();
- }
-
- private boolean isViewUpdateEnabled(ViewNode viewNode) {
- IHvDevice device = viewNode.window.getHvDevice();
- return device != null && device.isViewUpdateEnabled();
- }
-
- private void refresh() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- mText.setEnabled(mSelectedNode != null
- && isViewUpdateEnabled(mSelectedNode.viewNode));
- }
- });
- }
-
- @Override
- public void treeChanged() {
- selectionChanged();
- }
-
- @Override
- public void viewportChanged() {
- }
-
- @Override
- public void zoomChanged() {
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/LayoutViewer.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/LayoutViewer.java
deleted file mode 100644
index 95c7a29..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/LayoutViewer.java
+++ /dev/null
@@ -1,372 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui;
-
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-import com.android.hierarchyviewerlib.models.TreeViewModel;
-import com.android.hierarchyviewerlib.models.TreeViewModel.ITreeChangeListener;
-import com.android.hierarchyviewerlib.ui.util.DrawableViewNode;
-import com.android.hierarchyviewerlib.ui.util.DrawableViewNode.Point;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.graphics.Transform;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-
-import java.util.ArrayList;
-
-public class LayoutViewer extends Canvas implements ITreeChangeListener {
-
- private TreeViewModel mModel;
-
- private DrawableViewNode mTree;
-
- private DrawableViewNode mSelectedNode;
-
- private Transform mTransform;
-
- private Transform mInverse;
-
- private double mScale;
-
- private boolean mShowExtras = false;
-
- private boolean mOnBlack = true;
-
- public LayoutViewer(Composite parent) {
- super(parent, SWT.NONE);
- mModel = TreeViewModel.getModel();
- mModel.addTreeChangeListener(this);
-
- addDisposeListener(mDisposeListener);
- addPaintListener(mPaintListener);
- addListener(SWT.Resize, mResizeListener);
- addMouseListener(mMouseListener);
-
- mTransform = new Transform(Display.getDefault());
- mInverse = new Transform(Display.getDefault());
-
- treeChanged();
- }
-
- public void setShowExtras(boolean show) {
- mShowExtras = show;
- doRedraw();
- }
-
- public void setOnBlack(boolean value) {
- mOnBlack = value;
- doRedraw();
- }
-
- public boolean getOnBlack() {
- return mOnBlack;
- }
-
- private DisposeListener mDisposeListener = new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- mModel.removeTreeChangeListener(LayoutViewer.this);
- mTransform.dispose();
- mInverse.dispose();
- if (mSelectedNode != null) {
- mSelectedNode.viewNode.dereferenceImage();
- }
- }
- };
-
- private Listener mResizeListener = new Listener() {
- @Override
- public void handleEvent(Event e) {
- synchronized (this) {
- setTransform();
- }
- }
- };
-
- private MouseListener mMouseListener = new MouseListener() {
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- if (mSelectedNode != null) {
- HierarchyViewerDirector.getDirector()
- .showCapture(getShell(), mSelectedNode.viewNode);
- }
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- boolean selectionChanged = false;
- DrawableViewNode newSelection = null;
- synchronized (LayoutViewer.this) {
- if (mTree != null) {
- float[] pt = {
- e.x, e.y
- };
- mInverse.transform(pt);
- newSelection =
- updateSelection(mTree, pt[0], pt[1], 0, 0, 0, 0, mTree.viewNode.width,
- mTree.viewNode.height);
- if (mSelectedNode != newSelection) {
- selectionChanged = true;
- }
- }
- }
- if (selectionChanged) {
- mModel.setSelection(newSelection);
- }
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- // pass
- }
- };
-
- private DrawableViewNode updateSelection(DrawableViewNode node, float x, float y, int left,
- int top, int clipX, int clipY, int clipWidth, int clipHeight) {
- if (!node.treeDrawn) {
- return null;
- }
- // Update the clip
- int x1 = Math.max(left, clipX);
- int x2 = Math.min(left + node.viewNode.width, clipX + clipWidth);
- int y1 = Math.max(top, clipY);
- int y2 = Math.min(top + node.viewNode.height, clipY + clipHeight);
- clipX = x1;
- clipY = y1;
- clipWidth = x2 - x1;
- clipHeight = y2 - y1;
- if (x < clipX || x > clipX + clipWidth || y < clipY || y > clipY + clipHeight) {
- return null;
- }
- final int N = node.children.size();
- for (int i = N - 1; i >= 0; i--) {
- DrawableViewNode child = node.children.get(i);
- DrawableViewNode ret =
- updateSelection(child, x, y,
- left + child.viewNode.left - node.viewNode.scrollX, top
- + child.viewNode.top - node.viewNode.scrollY, clipX, clipY,
- clipWidth, clipHeight);
- if (ret != null) {
- return ret;
- }
- }
- return node;
- }
-
- private PaintListener mPaintListener = new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- synchronized (LayoutViewer.this) {
- if (mOnBlack) {
- e.gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
- } else {
- e.gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
- }
- e.gc.fillRectangle(0, 0, getBounds().width, getBounds().height);
- if (mTree != null) {
- e.gc.setLineWidth((int) Math.ceil(0.3 / mScale));
- e.gc.setTransform(mTransform);
- if (mOnBlack) {
- e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
- } else {
- e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
- }
- Rectangle parentClipping = e.gc.getClipping();
- e.gc.setClipping(0, 0, mTree.viewNode.width + (int) Math.ceil(0.3 / mScale),
- mTree.viewNode.height + (int) Math.ceil(0.3 / mScale));
- paintRecursive(e.gc, mTree, 0, 0, true);
-
- if (mSelectedNode != null) {
- e.gc.setClipping(parentClipping);
-
- // w00t, let's be nice and display the whole path in
- // light red and the selected node in dark red.
- ArrayList<Point> rightLeftDistances = new ArrayList<Point>();
- int left = 0;
- int top = 0;
- DrawableViewNode currentNode = mSelectedNode;
- while (currentNode != mTree) {
- left += currentNode.viewNode.left;
- top += currentNode.viewNode.top;
- currentNode = currentNode.parent;
- left -= currentNode.viewNode.scrollX;
- top -= currentNode.viewNode.scrollY;
- rightLeftDistances.add(new Point(left, top));
- }
- e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_DARK_RED));
- currentNode = mSelectedNode.parent;
- final int N = rightLeftDistances.size();
- for (int i = 0; i < N; i++) {
- e.gc.drawRectangle((int) (left - rightLeftDistances.get(i).x),
- (int) (top - rightLeftDistances.get(i).y),
- currentNode.viewNode.width, currentNode.viewNode.height);
- currentNode = currentNode.parent;
- }
-
- if (mShowExtras && mSelectedNode.viewNode.image != null) {
- e.gc.drawImage(mSelectedNode.viewNode.image, left, top);
- if (mOnBlack) {
- e.gc.setForeground(Display.getDefault().getSystemColor(
- SWT.COLOR_WHITE));
- } else {
- e.gc.setForeground(Display.getDefault().getSystemColor(
- SWT.COLOR_BLACK));
- }
- paintRecursive(e.gc, mSelectedNode, left, top, true);
-
- }
-
- e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
- e.gc.setLineWidth((int) Math.ceil(2 / mScale));
- e.gc.drawRectangle(left, top, mSelectedNode.viewNode.width,
- mSelectedNode.viewNode.height);
- }
- }
- }
- }
- };
-
- private void paintRecursive(GC gc, DrawableViewNode node, int left, int top, boolean root) {
- if (!node.treeDrawn) {
- return;
- }
- // Don't shift the root
- if (!root) {
- left += node.viewNode.left;
- top += node.viewNode.top;
- }
- Rectangle parentClipping = gc.getClipping();
- int x1 = Math.max(parentClipping.x, left);
- int x2 =
- Math.min(parentClipping.x + parentClipping.width, left + node.viewNode.width
- + (int) Math.ceil(0.3 / mScale));
- int y1 = Math.max(parentClipping.y, top);
- int y2 =
- Math.min(parentClipping.y + parentClipping.height, top + node.viewNode.height
- + (int) Math.ceil(0.3 / mScale));
-
- // Clipping is weird... You set it to -5 and it comes out 17 or
- // something.
- if (x2 <= x1 || y2 <= y1) {
- return;
- }
- gc.setClipping(x1, y1, x2 - x1, y2 - y1);
- final int N = node.children.size();
- for (int i = 0; i < N; i++) {
- paintRecursive(gc, node.children.get(i), left - node.viewNode.scrollX, top
- - node.viewNode.scrollY, false);
- }
- gc.setClipping(parentClipping);
- if (!node.viewNode.willNotDraw) {
- gc.drawRectangle(left, top, node.viewNode.width, node.viewNode.height);
- }
-
- }
-
- private void doRedraw() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- redraw();
- }
- });
- }
-
- private void setTransform() {
- if (mTree != null) {
- Rectangle bounds = getBounds();
- int leftRightPadding = bounds.width <= 30 ? 0 : 5;
- int topBottomPadding = bounds.height <= 30 ? 0 : 5;
- mScale =
- Math.min(1.0 * (bounds.width - leftRightPadding * 2) / mTree.viewNode.width, 1.0
- * (bounds.height - topBottomPadding * 2) / mTree.viewNode.height);
- int scaledWidth = (int) Math.ceil(mTree.viewNode.width * mScale);
- int scaledHeight = (int) Math.ceil(mTree.viewNode.height * mScale);
-
- mTransform.identity();
- mInverse.identity();
- mTransform.translate((bounds.width - scaledWidth) / 2.0f,
- (bounds.height - scaledHeight) / 2.0f);
- mInverse.translate((bounds.width - scaledWidth) / 2.0f,
- (bounds.height - scaledHeight) / 2.0f);
- mTransform.scale((float) mScale, (float) mScale);
- mInverse.scale((float) mScale, (float) mScale);
- if (bounds.width != 0 && bounds.height != 0) {
- mInverse.invert();
- }
- }
- }
-
- @Override
- public void selectionChanged() {
- synchronized (this) {
- if (mSelectedNode != null) {
- mSelectedNode.viewNode.dereferenceImage();
- }
- mSelectedNode = mModel.getSelection();
- if (mSelectedNode != null) {
- mSelectedNode.viewNode.referenceImage();
- }
- }
- doRedraw();
- }
-
- // Note the syncExec and then synchronized... It avoids deadlock
- @Override
- public void treeChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (this) {
- if (mSelectedNode != null) {
- mSelectedNode.viewNode.dereferenceImage();
- }
- mTree = mModel.getTree();
- mSelectedNode = mModel.getSelection();
- if (mSelectedNode != null) {
- mSelectedNode.viewNode.referenceImage();
- }
- setTransform();
- }
- }
- });
- doRedraw();
- }
-
- @Override
- public void viewportChanged() {
- // pass
- }
-
- @Override
- public void zoomChanged() {
- // pass
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfect.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfect.java
deleted file mode 100644
index 069fb61..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfect.java
+++ /dev/null
@@ -1,392 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui;
-
-import com.android.hierarchyviewerlib.models.PixelPerfectModel;
-import com.android.hierarchyviewerlib.models.ViewNode;
-import com.android.hierarchyviewerlib.models.PixelPerfectModel.IImageChangeListener;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-public class PixelPerfect extends ScrolledComposite implements IImageChangeListener {
- private Canvas mCanvas;
-
- private PixelPerfectModel mModel;
-
- private Image mImage;
-
- private Color mCrosshairColor;
-
- private Color mMarginColor;
-
- private Color mBorderColor;
-
- private Color mPaddingColor;
-
- private int mWidth;
-
- private int mHeight;
-
- private Point mCrosshairLocation;
-
- private ViewNode mSelectedNode;
-
- private Image mOverlayImage;
-
- private double mOverlayTransparency;
-
- public PixelPerfect(Composite parent) {
- super(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- mCanvas = new Canvas(this, SWT.NONE);
- setContent(mCanvas);
- setExpandHorizontal(true);
- setExpandVertical(true);
- mModel = PixelPerfectModel.getModel();
- mModel.addImageChangeListener(this);
-
- mCanvas.addPaintListener(mPaintListener);
- mCanvas.addMouseListener(mMouseListener);
- mCanvas.addMouseMoveListener(mMouseMoveListener);
- mCanvas.addKeyListener(mKeyListener);
-
- addDisposeListener(mDisposeListener);
-
- mCrosshairColor = new Color(Display.getDefault(), new RGB(0, 255, 255));
- mBorderColor = new Color(Display.getDefault(), new RGB(255, 0, 0));
- mMarginColor = new Color(Display.getDefault(), new RGB(0, 255, 0));
- mPaddingColor = new Color(Display.getDefault(), new RGB(0, 0, 255));
-
- imageLoaded();
- }
-
- private DisposeListener mDisposeListener = new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- mModel.removeImageChangeListener(PixelPerfect.this);
- mCrosshairColor.dispose();
- mBorderColor.dispose();
- mPaddingColor.dispose();
- }
- };
-
- @Override
- public boolean setFocus() {
- return mCanvas.setFocus();
- }
-
- private MouseListener mMouseListener = new MouseListener() {
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- // pass
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- handleMouseEvent(e);
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- handleMouseEvent(e);
- }
-
- };
-
- private MouseMoveListener mMouseMoveListener = new MouseMoveListener() {
- @Override
- public void mouseMove(MouseEvent e) {
- if (e.stateMask != 0) {
- handleMouseEvent(e);
- }
- }
- };
-
- private void handleMouseEvent(MouseEvent e) {
- synchronized (PixelPerfect.this) {
- if (mImage == null) {
- return;
- }
- int leftOffset = mCanvas.getSize().x / 2 - mWidth / 2;
- int topOffset = mCanvas.getSize().y / 2 - mHeight / 2;
- e.x -= leftOffset;
- e.y -= topOffset;
- e.x = Math.max(e.x, 0);
- e.x = Math.min(e.x, mWidth - 1);
- e.y = Math.max(e.y, 0);
- e.y = Math.min(e.y, mHeight - 1);
- }
- mModel.setCrosshairLocation(e.x, e.y);
- }
-
- private KeyListener mKeyListener = new KeyListener() {
-
- @Override
- public void keyPressed(KeyEvent e) {
- boolean crosshairMoved = false;
- synchronized (PixelPerfect.this) {
- if (mImage != null) {
- switch (e.keyCode) {
- case SWT.ARROW_UP:
- if (mCrosshairLocation.y != 0) {
- mCrosshairLocation.y--;
- crosshairMoved = true;
- }
- break;
- case SWT.ARROW_DOWN:
- if (mCrosshairLocation.y != mHeight - 1) {
- mCrosshairLocation.y++;
- crosshairMoved = true;
- }
- break;
- case SWT.ARROW_LEFT:
- if (mCrosshairLocation.x != 0) {
- mCrosshairLocation.x--;
- crosshairMoved = true;
- }
- break;
- case SWT.ARROW_RIGHT:
- if (mCrosshairLocation.x != mWidth - 1) {
- mCrosshairLocation.x++;
- crosshairMoved = true;
- }
- break;
- }
- }
- }
- if (crosshairMoved) {
- mModel.setCrosshairLocation(mCrosshairLocation.x, mCrosshairLocation.y);
- }
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
- // pass
- }
-
- };
-
- private PaintListener mPaintListener = new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- synchronized (PixelPerfect.this) {
- e.gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
- e.gc.fillRectangle(0, 0, mCanvas.getSize().x, mCanvas.getSize().y);
- if (mImage != null) {
- // Let's be cool and put it in the center...
- int leftOffset = mCanvas.getSize().x / 2 - mWidth / 2;
- int topOffset = mCanvas.getSize().y / 2 - mHeight / 2;
- e.gc.drawImage(mImage, leftOffset, topOffset);
- if (mOverlayImage != null) {
- e.gc.setAlpha((int) (mOverlayTransparency * 255));
- int overlayTopOffset =
- mCanvas.getSize().y / 2 + mHeight / 2
- - mOverlayImage.getBounds().height;
- e.gc.drawImage(mOverlayImage, leftOffset, overlayTopOffset);
- e.gc.setAlpha(255);
- }
-
- if (mSelectedNode != null) {
- // If the screen is in landscape mode, the
- // coordinates are backwards.
- int leftShift = 0;
- int topShift = 0;
- int nodeLeft = mSelectedNode.left;
- int nodeTop = mSelectedNode.top;
- int nodeWidth = mSelectedNode.width;
- int nodeHeight = mSelectedNode.height;
- int nodeMarginLeft = mSelectedNode.marginLeft;
- int nodeMarginTop = mSelectedNode.marginTop;
- int nodeMarginRight = mSelectedNode.marginRight;
- int nodeMarginBottom = mSelectedNode.marginBottom;
- int nodePadLeft = mSelectedNode.paddingLeft;
- int nodePadTop = mSelectedNode.paddingTop;
- int nodePadRight = mSelectedNode.paddingRight;
- int nodePadBottom = mSelectedNode.paddingBottom;
- ViewNode cur = mSelectedNode;
- while (cur.parent != null) {
- leftShift += cur.parent.left - cur.parent.scrollX;
- topShift += cur.parent.top - cur.parent.scrollY;
- cur = cur.parent;
- }
-
- // Everything is sideways.
- if (cur.width > cur.height) {
- e.gc.setForeground(mPaddingColor);
- e.gc.drawRectangle(leftOffset + mWidth - nodeTop - topShift - nodeHeight
- + nodePadBottom,
- topOffset + leftShift + nodeLeft + nodePadLeft, nodeHeight
- - nodePadBottom - nodePadTop, nodeWidth - nodePadRight
- - nodePadLeft);
- e.gc.setForeground(mMarginColor);
- e.gc.drawRectangle(leftOffset + mWidth - nodeTop - topShift - nodeHeight
- - nodeMarginBottom, topOffset + leftShift + nodeLeft
- - nodeMarginLeft,
- nodeHeight + nodeMarginBottom + nodeMarginTop, nodeWidth
- + nodeMarginRight + nodeMarginLeft);
- e.gc.setForeground(mBorderColor);
- e.gc.drawRectangle(
- leftOffset + mWidth - nodeTop - topShift - nodeHeight, topOffset
- + leftShift + nodeLeft, nodeHeight, nodeWidth);
- } else {
- e.gc.setForeground(mPaddingColor);
- e.gc.drawRectangle(leftOffset + leftShift + nodeLeft + nodePadLeft,
- topOffset + topShift + nodeTop + nodePadTop, nodeWidth
- - nodePadRight - nodePadLeft, nodeHeight
- - nodePadBottom - nodePadTop);
- e.gc.setForeground(mMarginColor);
- e.gc.drawRectangle(leftOffset + leftShift + nodeLeft - nodeMarginLeft,
- topOffset + topShift + nodeTop - nodeMarginTop, nodeWidth
- + nodeMarginRight + nodeMarginLeft, nodeHeight
- + nodeMarginBottom + nodeMarginTop);
- e.gc.setForeground(mBorderColor);
- e.gc.drawRectangle(leftOffset + leftShift + nodeLeft, topOffset
- + topShift + nodeTop, nodeWidth, nodeHeight);
- }
- }
- if (mCrosshairLocation != null) {
- e.gc.setForeground(mCrosshairColor);
- e.gc.drawLine(leftOffset, topOffset + mCrosshairLocation.y, leftOffset
- + mWidth - 1, topOffset + mCrosshairLocation.y);
- e.gc.drawLine(leftOffset + mCrosshairLocation.x, topOffset, leftOffset
- + mCrosshairLocation.x, topOffset + mHeight - 1);
- }
- }
- }
- }
- };
-
- private void doRedraw() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- mCanvas.redraw();
- }
- });
- }
-
- private void loadImage() {
- mImage = mModel.getImage();
- if (mImage != null) {
- mWidth = mImage.getBounds().width;
- mHeight = mImage.getBounds().height;
- } else {
- mWidth = 0;
- mHeight = 0;
- }
- setMinSize(mWidth, mHeight);
- }
-
- @Override
- public void imageLoaded() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (this) {
- loadImage();
- mCrosshairLocation = mModel.getCrosshairLocation();
- mSelectedNode = mModel.getSelected();
- mOverlayImage = mModel.getOverlayImage();
- mOverlayTransparency = mModel.getOverlayTransparency();
- }
- }
- });
- doRedraw();
- }
-
- @Override
- public void imageChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (this) {
- loadImage();
- }
- }
- });
- doRedraw();
- }
-
- @Override
- public void crosshairMoved() {
- synchronized (this) {
- mCrosshairLocation = mModel.getCrosshairLocation();
- }
- doRedraw();
- }
-
- @Override
- public void selectionChanged() {
- synchronized (this) {
- mSelectedNode = mModel.getSelected();
- }
- doRedraw();
- }
-
- // Note the syncExec and then synchronized... It avoids deadlock
- @Override
- public void treeChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (this) {
- mSelectedNode = mModel.getSelected();
- }
- }
- });
- doRedraw();
- }
-
- @Override
- public void zoomChanged() {
- // pass
- }
-
- @Override
- public void overlayChanged() {
- synchronized (this) {
- mOverlayImage = mModel.getOverlayImage();
- mOverlayTransparency = mModel.getOverlayTransparency();
- }
- doRedraw();
- }
-
- @Override
- public void overlayTransparencyChanged() {
- synchronized (this) {
- mOverlayTransparency = mModel.getOverlayTransparency();
- }
- doRedraw();
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectControls.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectControls.java
deleted file mode 100644
index 6054088..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectControls.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui;
-
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-import com.android.hierarchyviewerlib.models.PixelPerfectModel;
-import com.android.hierarchyviewerlib.models.PixelPerfectModel.IImageChangeListener;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FormAttachment;
-import org.eclipse.swt.layout.FormData;
-import org.eclipse.swt.layout.FormLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Slider;
-
-public class PixelPerfectControls extends Composite implements IImageChangeListener {
-
- private Slider mOverlaySlider;
-
- private Slider mZoomSlider;
-
- private Slider mAutoRefreshSlider;
-
- public PixelPerfectControls(Composite parent) {
- super(parent, SWT.NONE);
- setLayout(new FormLayout());
-
- Label overlayTransparencyRight = new Label(this, SWT.NONE);
- overlayTransparencyRight.setText("100%");
- FormData overlayTransparencyRightData = new FormData();
- overlayTransparencyRightData.right = new FormAttachment(100, -2);
- overlayTransparencyRightData.top = new FormAttachment(0, 2);
- overlayTransparencyRight.setLayoutData(overlayTransparencyRightData);
-
- Label refreshRight = new Label(this, SWT.NONE);
- refreshRight.setText("40s");
- FormData refreshRightData = new FormData();
- refreshRightData.right = new FormAttachment(100, -2);
- refreshRightData.top = new FormAttachment(overlayTransparencyRight, 2);
- refreshRightData.left = new FormAttachment(overlayTransparencyRight, 0, SWT.LEFT);
- refreshRight.setLayoutData(refreshRightData);
-
- Label zoomRight = new Label(this, SWT.NONE);
- zoomRight.setText("24x");
- FormData zoomRightData = new FormData();
- zoomRightData.right = new FormAttachment(100, -2);
- zoomRightData.top = new FormAttachment(refreshRight, 2);
- zoomRightData.left = new FormAttachment(overlayTransparencyRight, 0, SWT.LEFT);
- zoomRight.setLayoutData(zoomRightData);
-
- Label overlayTransparency = new Label(this, SWT.NONE);
- Label refresh = new Label(this, SWT.NONE);
-
- overlayTransparency.setText("Overlay:");
- FormData overlayTransparencyData = new FormData();
- overlayTransparencyData.left = new FormAttachment(0, 2);
- overlayTransparencyData.top = new FormAttachment(0, 2);
- overlayTransparencyData.right = new FormAttachment(refresh, 0, SWT.RIGHT);
- overlayTransparency.setLayoutData(overlayTransparencyData);
-
- refresh.setText("Refresh Rate:");
- FormData refreshData = new FormData();
- refreshData.top = new FormAttachment(overlayTransparency, 2);
- refreshData.left = new FormAttachment(0, 2);
- refresh.setLayoutData(refreshData);
-
- Label zoom = new Label(this, SWT.NONE);
- zoom.setText("Zoom:");
- FormData zoomData = new FormData();
- zoomData.right = new FormAttachment(refresh, 0, SWT.RIGHT);
- zoomData.top = new FormAttachment(refresh, 2);
- zoomData.left = new FormAttachment(0, 2);
- zoom.setLayoutData(zoomData);
-
- Label overlayTransparencyLeft = new Label(this, SWT.RIGHT);
- overlayTransparencyLeft.setText("0%");
- FormData overlayTransparencyLeftData = new FormData();
- overlayTransparencyLeftData.top = new FormAttachment(0, 2);
- overlayTransparencyLeftData.left = new FormAttachment(overlayTransparency, 2);
- overlayTransparencyLeft.setLayoutData(overlayTransparencyLeftData);
-
- Label refreshLeft = new Label(this, SWT.RIGHT);
- refreshLeft.setText("1s");
- FormData refreshLeftData = new FormData();
- refreshLeftData.top = new FormAttachment(overlayTransparencyLeft, 2);
- refreshLeftData.left = new FormAttachment(refresh, 2);
- refreshLeft.setLayoutData(refreshLeftData);
-
- Label zoomLeft = new Label(this, SWT.RIGHT);
- zoomLeft.setText("2x");
- FormData zoomLeftData = new FormData();
- zoomLeftData.top = new FormAttachment(refreshLeft, 2);
- zoomLeftData.left = new FormAttachment(zoom, 2);
- zoomLeft.setLayoutData(zoomLeftData);
-
- mOverlaySlider = new Slider(this, SWT.HORIZONTAL);
- mOverlaySlider.setMinimum(0);
- mOverlaySlider.setMaximum(101);
- mOverlaySlider.setThumb(1);
- mOverlaySlider.setSelection((int) Math.round(PixelPerfectModel.getModel()
- .getOverlayTransparency() * 100));
-
- Image overlayImage = PixelPerfectModel.getModel().getOverlayImage();
- mOverlaySlider.setEnabled(overlayImage != null);
- FormData overlaySliderData = new FormData();
- overlaySliderData.right = new FormAttachment(overlayTransparencyRight, -4);
- overlaySliderData.top = new FormAttachment(0, 2);
- overlaySliderData.left = new FormAttachment(overlayTransparencyLeft, 4);
- mOverlaySlider.setLayoutData(overlaySliderData);
-
- mOverlaySlider.addSelectionListener(overlaySliderSelectionListener);
-
- mAutoRefreshSlider = new Slider(this, SWT.HORIZONTAL);
- mAutoRefreshSlider.setMinimum(1);
- mAutoRefreshSlider.setMaximum(41);
- mAutoRefreshSlider.setThumb(1);
- mAutoRefreshSlider.setSelection(HierarchyViewerDirector.getDirector()
- .getPixelPerfectAutoRefreshInverval());
- FormData refreshSliderData = new FormData();
- refreshSliderData.right = new FormAttachment(overlayTransparencyRight, -4);
- refreshSliderData.top = new FormAttachment(overlayTransparencyRight, 2);
- refreshSliderData.left = new FormAttachment(mOverlaySlider, 0, SWT.LEFT);
- mAutoRefreshSlider.setLayoutData(refreshSliderData);
-
- mAutoRefreshSlider.addSelectionListener(mRefreshSliderSelectionListener);
-
- mZoomSlider = new Slider(this, SWT.HORIZONTAL);
- mZoomSlider.setMinimum(2);
- mZoomSlider.setMaximum(25);
- mZoomSlider.setThumb(1);
- mZoomSlider.setSelection(PixelPerfectModel.getModel().getZoom());
- FormData zoomSliderData = new FormData();
- zoomSliderData.right = new FormAttachment(overlayTransparencyRight, -4);
- zoomSliderData.top = new FormAttachment(refreshRight, 2);
- zoomSliderData.left = new FormAttachment(mOverlaySlider, 0, SWT.LEFT);
- mZoomSlider.setLayoutData(zoomSliderData);
-
- mZoomSlider.addSelectionListener(mZoomSliderSelectionListener);
-
- addDisposeListener(mDisposeListener);
-
- PixelPerfectModel.getModel().addImageChangeListener(this);
- }
-
- private DisposeListener mDisposeListener = new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- PixelPerfectModel.getModel().removeImageChangeListener(PixelPerfectControls.this);
- }
- };
-
- private SelectionListener overlaySliderSelectionListener = new SelectionListener() {
- private int oldValue;
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // pass
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- int newValue = mOverlaySlider.getSelection();
- if (oldValue != newValue) {
- PixelPerfectModel.getModel().removeImageChangeListener(PixelPerfectControls.this);
- PixelPerfectModel.getModel().setOverlayTransparency(newValue / 100.0);
- PixelPerfectModel.getModel().addImageChangeListener(PixelPerfectControls.this);
- oldValue = newValue;
- }
- }
- };
-
- private SelectionListener mRefreshSliderSelectionListener = new SelectionListener() {
- private int oldValue;
-
- @Override
- public void widgetDefaultSelected(final SelectionEvent e) {
- // pass
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- int newValue = mAutoRefreshSlider.getSelection();
- if (oldValue != newValue) {
- HierarchyViewerDirector.getDirector().setPixelPerfectAutoRefreshInterval(newValue);
- }
- }
- };
-
- private SelectionListener mZoomSliderSelectionListener = new SelectionListener() {
- private int oldValue;
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // pass
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- int newValue = mZoomSlider.getSelection();
- if (oldValue != newValue) {
- PixelPerfectModel.getModel().removeImageChangeListener(PixelPerfectControls.this);
- PixelPerfectModel.getModel().setZoom(newValue);
- PixelPerfectModel.getModel().addImageChangeListener(PixelPerfectControls.this);
- oldValue = newValue;
- }
- }
- };
-
- @Override
- public void crosshairMoved() {
- // pass
- }
-
- @Override
- public void treeChanged() {
- // pass
- }
-
- @Override
- public void imageChanged() {
- // pass
- }
-
- @Override
- public void imageLoaded() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- Image overlayImage = PixelPerfectModel.getModel().getOverlayImage();
- mOverlaySlider.setEnabled(overlayImage != null);
- if (PixelPerfectModel.getModel().getImage() == null) {
- } else {
- mZoomSlider.setSelection(PixelPerfectModel.getModel().getZoom());
- }
- }
- });
- }
-
- @Override
- public void overlayChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- Image overlayImage = PixelPerfectModel.getModel().getOverlayImage();
- mOverlaySlider.setEnabled(overlayImage != null);
- }
- });
- }
-
- @Override
- public void overlayTransparencyChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- mOverlaySlider.setSelection((int) (PixelPerfectModel.getModel()
- .getOverlayTransparency() * 100));
- }
- });
- }
-
- @Override
- public void selectionChanged() {
- // pass
- }
-
- @Override
- public void zoomChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- mZoomSlider.setSelection(PixelPerfectModel.getModel().getZoom());
- }
- });
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectLoupe.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectLoupe.java
deleted file mode 100644
index ac3d66e..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectLoupe.java
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui;
-
-import com.android.hierarchyviewerlib.models.PixelPerfectModel;
-import com.android.hierarchyviewerlib.models.PixelPerfectModel.IImageChangeListener;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseWheelListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.PaletteData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.graphics.Transform;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-public class PixelPerfectLoupe extends Canvas implements IImageChangeListener {
- private PixelPerfectModel mModel;
-
- private Image mImage;
-
- private Image mGrid;
-
- private Color mCrosshairColor;
-
- private int mWidth;
-
- private int mHeight;
-
- private Point mCrosshairLocation;
-
- private int mZoom;
-
- private Transform mTransform;
-
- private int mCanvasWidth;
-
- private int mCanvasHeight;
-
- private Image mOverlayImage;
-
- private double mOverlayTransparency;
-
- private boolean mShowOverlay = false;
-
- public PixelPerfectLoupe(Composite parent) {
- super(parent, SWT.NONE);
- mModel = PixelPerfectModel.getModel();
- mModel.addImageChangeListener(this);
-
- addPaintListener(mPaintListener);
- addMouseListener(mMouseListener);
- addMouseWheelListener(mMouseWheelListener);
- addDisposeListener(mDisposeListener);
- addKeyListener(mKeyListener);
-
- mCrosshairColor = new Color(Display.getDefault(), new RGB(255, 94, 254));
-
- mTransform = new Transform(Display.getDefault());
-
- imageLoaded();
- }
-
- public void setShowOverlay(boolean value) {
- synchronized (this) {
- mShowOverlay = value;
- }
- doRedraw();
- }
-
- private DisposeListener mDisposeListener = new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- mModel.removeImageChangeListener(PixelPerfectLoupe.this);
- mCrosshairColor.dispose();
- mTransform.dispose();
- if (mGrid != null) {
- mGrid.dispose();
- }
- }
- };
-
- private MouseListener mMouseListener = new MouseListener() {
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- // pass
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- handleMouseEvent(e);
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- //
- }
-
- };
-
- private MouseWheelListener mMouseWheelListener = new MouseWheelListener() {
- @Override
- public void mouseScrolled(MouseEvent e) {
- int newZoom = -1;
- synchronized (PixelPerfectLoupe.this) {
- if (mImage != null && mCrosshairLocation != null) {
- if (e.count > 0) {
- newZoom = mZoom + 1;
- } else {
- newZoom = mZoom - 1;
- }
- }
- }
- if (newZoom != -1) {
- mModel.setZoom(newZoom);
- }
- }
- };
-
- private void handleMouseEvent(MouseEvent e) {
- int newX = -1;
- int newY = -1;
- synchronized (PixelPerfectLoupe.this) {
- if (mImage == null) {
- return;
- }
- int zoomedX = -mCrosshairLocation.x * mZoom - mZoom / 2 + getBounds().width / 2;
- int zoomedY = -mCrosshairLocation.y * mZoom - mZoom / 2 + getBounds().height / 2;
- int x = (e.x - zoomedX) / mZoom;
- int y = (e.y - zoomedY) / mZoom;
- if (x >= 0 && x < mWidth && y >= 0 && y < mHeight) {
- newX = x;
- newY = y;
- }
- }
- if (newX != -1) {
- mModel.setCrosshairLocation(newX, newY);
- }
- }
-
- private KeyListener mKeyListener = new KeyListener() {
-
- @Override
- public void keyPressed(KeyEvent e) {
- boolean crosshairMoved = false;
- synchronized (PixelPerfectLoupe.this) {
- if (mImage != null) {
- switch (e.keyCode) {
- case SWT.ARROW_UP:
- if (mCrosshairLocation.y != 0) {
- mCrosshairLocation.y--;
- crosshairMoved = true;
- }
- break;
- case SWT.ARROW_DOWN:
- if (mCrosshairLocation.y != mHeight - 1) {
- mCrosshairLocation.y++;
- crosshairMoved = true;
- }
- break;
- case SWT.ARROW_LEFT:
- if (mCrosshairLocation.x != 0) {
- mCrosshairLocation.x--;
- crosshairMoved = true;
- }
- break;
- case SWT.ARROW_RIGHT:
- if (mCrosshairLocation.x != mWidth - 1) {
- mCrosshairLocation.x++;
- crosshairMoved = true;
- }
- break;
- }
- }
- }
- if (crosshairMoved) {
- mModel.setCrosshairLocation(mCrosshairLocation.x, mCrosshairLocation.y);
- }
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
- // pass
- }
-
- };
-
- private PaintListener mPaintListener = new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- synchronized (PixelPerfectLoupe.this) {
- e.gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
- e.gc.fillRectangle(0, 0, getSize().x, getSize().y);
- if (mImage != null && mCrosshairLocation != null) {
- int zoomedX = -mCrosshairLocation.x * mZoom - mZoom / 2 + getBounds().width / 2;
- int zoomedY = -mCrosshairLocation.y * mZoom - mZoom / 2 + getBounds().height / 2;
- mTransform.translate(zoomedX, zoomedY);
- mTransform.scale(mZoom, mZoom);
- e.gc.setInterpolation(SWT.NONE);
- e.gc.setTransform(mTransform);
- e.gc.drawImage(mImage, 0, 0);
- if (mShowOverlay && mOverlayImage != null) {
- e.gc.setAlpha((int) (mOverlayTransparency * 255));
- e.gc.drawImage(mOverlayImage, 0, mHeight - mOverlayImage.getBounds().height);
- e.gc.setAlpha(255);
- }
-
- mTransform.identity();
- e.gc.setTransform(mTransform);
-
- // If the size of the canvas has changed, we need to make
- // another grid.
- if (mGrid != null
- && (mCanvasWidth != getBounds().width || mCanvasHeight != getBounds().height)) {
- mGrid.dispose();
- mGrid = null;
- }
- mCanvasWidth = getBounds().width;
- mCanvasHeight = getBounds().height;
- if (mGrid == null) {
- // Make a transparent image;
- ImageData imageData =
- new ImageData(mCanvasWidth + mZoom + 1, mCanvasHeight + mZoom + 1, 1,
- new PaletteData(new RGB[] {
- new RGB(0, 0, 0)
- }));
- imageData.transparentPixel = 0;
-
- // Draw the grid.
- mGrid = new Image(Display.getDefault(), imageData);
- GC gc = new GC(mGrid);
- gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
- for (int x = 0; x <= mCanvasWidth + mZoom; x += mZoom) {
- gc.drawLine(x, 0, x, mCanvasHeight + mZoom);
- }
- for (int y = 0; y <= mCanvasHeight + mZoom; y += mZoom) {
- gc.drawLine(0, y, mCanvasWidth + mZoom, y);
- }
- gc.dispose();
- }
-
- e.gc.setClipping(new Rectangle(zoomedX, zoomedY, mWidth * mZoom + 1, mHeight
- * mZoom + 1));
- e.gc.setAlpha(76);
- e.gc.drawImage(mGrid, (mCanvasWidth / 2 - mZoom / 2) % mZoom - mZoom,
- (mCanvasHeight / 2 - mZoom / 2) % mZoom - mZoom);
- e.gc.setAlpha(255);
-
- e.gc.setForeground(mCrosshairColor);
- e.gc.drawLine(0, mCanvasHeight / 2, mCanvasWidth - 1, mCanvasHeight / 2);
- e.gc.drawLine(mCanvasWidth / 2, 0, mCanvasWidth / 2, mCanvasHeight - 1);
- }
- }
- }
- };
-
- private void doRedraw() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- redraw();
- }
- });
- }
-
- private void loadImage() {
- mImage = mModel.getImage();
- if (mImage != null) {
- mWidth = mImage.getBounds().width;
- mHeight = mImage.getBounds().height;
- } else {
- mWidth = 0;
- mHeight = 0;
- }
- }
-
- // Note the syncExec and then synchronized... It avoids deadlock
- @Override
- public void imageLoaded() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (this) {
- loadImage();
- mCrosshairLocation = mModel.getCrosshairLocation();
- mZoom = mModel.getZoom();
- mOverlayImage = mModel.getOverlayImage();
- mOverlayTransparency = mModel.getOverlayTransparency();
- }
- }
- });
- doRedraw();
- }
-
- @Override
- public void imageChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (this) {
- loadImage();
- }
- }
- });
- doRedraw();
- }
-
- @Override
- public void crosshairMoved() {
- synchronized (this) {
- mCrosshairLocation = mModel.getCrosshairLocation();
- }
- doRedraw();
- }
-
- @Override
- public void selectionChanged() {
- // pass
- }
-
- @Override
- public void treeChanged() {
- // pass
- }
-
- @Override
- public void zoomChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (this) {
- if (mGrid != null) {
- // To notify that the zoom level has changed, we get rid
- // of the
- // grid.
- mGrid.dispose();
- mGrid = null;
- }
- mZoom = mModel.getZoom();
- }
- }
- });
- doRedraw();
- }
-
- @Override
- public void overlayChanged() {
- synchronized (this) {
- mOverlayImage = mModel.getOverlayImage();
- mOverlayTransparency = mModel.getOverlayTransparency();
- }
- doRedraw();
- }
-
- @Override
- public void overlayTransparencyChanged() {
- synchronized (this) {
- mOverlayTransparency = mModel.getOverlayTransparency();
- }
- doRedraw();
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectPixelPanel.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectPixelPanel.java
deleted file mode 100644
index d1ff6d9..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectPixelPanel.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui;
-
-import com.android.hierarchyviewerlib.models.PixelPerfectModel;
-import com.android.hierarchyviewerlib.models.PixelPerfectModel.IImageChangeListener;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-public class PixelPerfectPixelPanel extends Canvas implements IImageChangeListener {
- private PixelPerfectModel mModel;
-
- private Image mImage;
-
- private Image mOverlayImage;
-
- private Point mCrosshairLocation;
-
- public static final int PREFERRED_WIDTH = 180;
-
- public static final int PREFERRED_HEIGHT = 52;
-
- public PixelPerfectPixelPanel(Composite parent) {
- super(parent, SWT.NONE);
- mModel = PixelPerfectModel.getModel();
- mModel.addImageChangeListener(this);
-
- addPaintListener(mPaintListener);
- addDisposeListener(mDisposeListener);
-
- imageLoaded();
- }
-
- @Override
- public Point computeSize(int wHint, int hHint, boolean changed) {
- int height = PREFERRED_HEIGHT;
- int width = (wHint == SWT.DEFAULT) ? PREFERRED_WIDTH : wHint;
- return new Point(width, height);
- }
-
- private DisposeListener mDisposeListener = new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- mModel.removeImageChangeListener(PixelPerfectPixelPanel.this);
- }
- };
-
- private PaintListener mPaintListener = new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- synchronized (PixelPerfectPixelPanel.this) {
- e.gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
- e.gc.fillRectangle(0, 0, getBounds().width, getBounds().height);
- if (mImage != null) {
- RGB pixel =
- mImage.getImageData().palette.getRGB(mImage.getImageData().getPixel(
- mCrosshairLocation.x, mCrosshairLocation.y));
- Color rgbColor = new Color(Display.getDefault(), pixel);
- e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
- e.gc.setBackground(rgbColor);
- e.gc.drawRectangle(4, 4, 60, 30);
- e.gc.fillRectangle(5, 5, 59, 29);
- rgbColor.dispose();
- e.gc.drawText("#"
- + Integer
- .toHexString(
- (1 << 24) + (pixel.red << 16) + (pixel.green << 8)
- + pixel.blue).substring(1), 4, 35, true);
- e.gc.drawText("R:", 80, 4, true);
- e.gc.drawText("G:", 80, 20, true);
- e.gc.drawText("B:", 80, 35, true);
- e.gc.drawText(Integer.toString(pixel.red), 97, 4, true);
- e.gc.drawText(Integer.toString(pixel.green), 97, 20, true);
- e.gc.drawText(Integer.toString(pixel.blue), 97, 35, true);
- e.gc.drawText("X:", 132, 4, true);
- e.gc.drawText("Y:", 132, 20, true);
- e.gc.drawText(Integer.toString(mCrosshairLocation.x) + " px", 149, 4, true);
- e.gc.drawText(Integer.toString(mCrosshairLocation.y) + " px", 149, 20, true);
-
- if (mOverlayImage != null) {
- int xInOverlay = mCrosshairLocation.x;
- int yInOverlay =
- mCrosshairLocation.y
- - (mImage.getBounds().height - mOverlayImage.getBounds().height);
- if (xInOverlay >= 0 && yInOverlay >= 0
- && xInOverlay < mOverlayImage.getBounds().width
- && yInOverlay < mOverlayImage.getBounds().height) {
- pixel =
- mOverlayImage.getImageData().palette.getRGB(mOverlayImage
- .getImageData().getPixel(xInOverlay, yInOverlay));
- rgbColor = new Color(Display.getDefault(), pixel);
- e.gc
- .setForeground(Display.getDefault().getSystemColor(
- SWT.COLOR_WHITE));
- e.gc.setBackground(rgbColor);
- e.gc.drawRectangle(204, 4, 60, 30);
- e.gc.fillRectangle(205, 5, 59, 29);
- rgbColor.dispose();
- e.gc.drawText("#"
- + Integer.toHexString(
- (1 << 24) + (pixel.red << 16) + (pixel.green << 8)
- + pixel.blue).substring(1), 204, 35, true);
- e.gc.drawText("R:", 280, 4, true);
- e.gc.drawText("G:", 280, 20, true);
- e.gc.drawText("B:", 280, 35, true);
- e.gc.drawText(Integer.toString(pixel.red), 297, 4, true);
- e.gc.drawText(Integer.toString(pixel.green), 297, 20, true);
- e.gc.drawText(Integer.toString(pixel.blue), 297, 35, true);
- }
- }
- }
- }
- }
- };
-
- private void doRedraw() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- redraw();
- }
- });
- }
-
- @Override
- public void crosshairMoved() {
- synchronized (this) {
- mCrosshairLocation = mModel.getCrosshairLocation();
- }
- doRedraw();
- }
-
- @Override
- public void imageChanged() {
- synchronized (this) {
- mImage = mModel.getImage();
- }
- doRedraw();
- }
-
- @Override
- public void imageLoaded() {
- synchronized (this) {
- mImage = mModel.getImage();
- mCrosshairLocation = mModel.getCrosshairLocation();
- mOverlayImage = mModel.getOverlayImage();
- }
- doRedraw();
- }
-
- @Override
- public void overlayChanged() {
- synchronized (this) {
- mOverlayImage = mModel.getOverlayImage();
- }
- doRedraw();
- }
-
- @Override
- public void overlayTransparencyChanged() {
- // pass
- }
-
- @Override
- public void selectionChanged() {
- // pass
- }
-
- @Override
- public void treeChanged() {
- // pass
- }
-
- @Override
- public void zoomChanged() {
- // pass
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectTree.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectTree.java
deleted file mode 100644
index f2b0189..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PixelPerfectTree.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.models.PixelPerfectModel;
-import com.android.hierarchyviewerlib.models.ViewNode;
-import com.android.hierarchyviewerlib.models.PixelPerfectModel.IImageChangeListener;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TreeSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Tree;
-
-import java.util.List;
-
-public class PixelPerfectTree extends Composite implements IImageChangeListener, SelectionListener {
-
- private TreeViewer mTreeViewer;
-
- private Tree mTree;
-
- private PixelPerfectModel mModel;
-
- private Image mFolderImage;
-
- private Image mFileImage;
-
- private class ContentProvider implements ITreeContentProvider, ILabelProvider {
- @Override
- public Object[] getChildren(Object element) {
- if (element instanceof ViewNode) {
- List<ViewNode> children = ((ViewNode) element).children;
- return children.toArray(new ViewNode[children.size()]);
- }
- return null;
- }
-
- @Override
- public Object getParent(Object element) {
- if (element instanceof ViewNode) {
- return ((ViewNode) element).parent;
- }
- return null;
- }
-
- @Override
- public boolean hasChildren(Object element) {
- if (element instanceof ViewNode) {
- return ((ViewNode) element).children.size() != 0;
- }
- return false;
- }
-
- @Override
- public Object[] getElements(Object element) {
- if (element instanceof PixelPerfectModel) {
- ViewNode viewNode = ((PixelPerfectModel) element).getViewNode();
- if (viewNode == null) {
- return new Object[0];
- }
- return new Object[] {
- viewNode
- };
- }
- return new Object[0];
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // pass
- }
-
- @Override
- public Image getImage(Object element) {
- if (element instanceof ViewNode) {
- if (hasChildren(element)) {
- return mFolderImage;
- }
- return mFileImage;
- }
- return null;
- }
-
- @Override
- public String getText(Object element) {
- if (element instanceof ViewNode) {
- return ((ViewNode) element).name;
- }
- return null;
- }
-
- @Override
- public void addListener(ILabelProviderListener listener) {
- // pass
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- // pass
- return false;
- }
-
- @Override
- public void removeListener(ILabelProviderListener listener) {
- // pass
- }
- }
-
- public PixelPerfectTree(Composite parent) {
- super(parent, SWT.NONE);
- setLayout(new FillLayout());
- mTreeViewer = new TreeViewer(this, SWT.SINGLE);
- mTreeViewer.setAutoExpandLevel(TreeViewer.ALL_LEVELS);
-
- mTree = mTreeViewer.getTree();
- mTree.addSelectionListener(this);
-
- loadResources();
-
- addDisposeListener(mDisposeListener);
-
- mModel = PixelPerfectModel.getModel();
- ContentProvider contentProvider = new ContentProvider();
- mTreeViewer.setContentProvider(contentProvider);
- mTreeViewer.setLabelProvider(contentProvider);
- mTreeViewer.setInput(mModel);
- mModel.addImageChangeListener(this);
-
- }
-
- private void loadResources() {
- ImageLoader loader = ImageLoader.getDdmUiLibLoader();
- mFileImage = loader.loadImage("file.png", Display.getDefault());
- mFolderImage = loader.loadImage("folder.png", Display.getDefault());
- }
-
- private DisposeListener mDisposeListener = new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- mModel.removeImageChangeListener(PixelPerfectTree.this);
- }
- };
-
- @Override
- public boolean setFocus() {
- return mTree.setFocus();
- }
-
- @Override
- public void imageLoaded() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- mTreeViewer.refresh();
- mTreeViewer.expandAll();
- }
- });
- }
-
- @Override
- public void imageChanged() {
- // pass
- }
-
- @Override
- public void crosshairMoved() {
- // pass
- }
-
- @Override
- public void selectionChanged() {
- // pass
- }
-
- @Override
- public void treeChanged() {
- imageLoaded();
- }
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // pass
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- // To combat phantom selection...
- if (((TreeSelection) mTreeViewer.getSelection()).isEmpty()) {
- mModel.setSelected(null);
- } else {
- mModel.setSelected((ViewNode) e.item.getData());
- }
- }
-
- @Override
- public void zoomChanged() {
- // pass
- }
-
- @Override
- public void overlayChanged() {
- // pass
- }
-
- @Override
- public void overlayTransparencyChanged() {
- // pass
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PropertyViewer.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PropertyViewer.java
deleted file mode 100644
index 9456a0a..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/PropertyViewer.java
+++ /dev/null
@@ -1,391 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-import com.android.hierarchyviewerlib.device.IHvDevice;
-import com.android.hierarchyviewerlib.models.TreeViewModel;
-import com.android.hierarchyviewerlib.models.TreeViewModel.ITreeChangeListener;
-import com.android.hierarchyviewerlib.models.ViewNode;
-import com.android.hierarchyviewerlib.models.ViewNode.Property;
-import com.android.hierarchyviewerlib.ui.DevicePropertyEditingSupport.PropertyType;
-import com.android.hierarchyviewerlib.ui.util.DrawableViewNode;
-import com.android.hierarchyviewerlib.ui.util.TreeColumnResizer;
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnViewer;
-import org.eclipse.jface.viewers.ComboBoxCellEditor;
-import org.eclipse.jface.viewers.EditingSupport;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.TreeViewerColumn;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ControlAdapter;
-import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.ControlListener;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-public class PropertyViewer extends Composite implements ITreeChangeListener {
- private TreeViewModel mModel;
-
- private TreeViewer mTreeViewer;
- private Tree mTree;
- private TreeViewerColumn mValueColumn;
- private PropertyValueEditingSupport mPropertyValueEditingSupport;
-
- private Image mImage;
-
- private DrawableViewNode mSelectedNode;
-
- private class ContentProvider implements ITreeContentProvider, ITableLabelProvider {
-
- @Override
- public Object[] getChildren(Object parentElement) {
- synchronized (PropertyViewer.this) {
- if (mSelectedNode != null && parentElement instanceof String) {
- String category = (String) parentElement;
- ArrayList<Property> returnValue = new ArrayList<Property>();
- for (Property property : mSelectedNode.viewNode.properties) {
- if (category.equals(ViewNode.MISCELLANIOUS)) {
- if (property.name.indexOf(':') == -1) {
- returnValue.add(property);
- }
- } else {
- if (property.name.startsWith(((String) parentElement) + ":")) {
- returnValue.add(property);
- }
- }
- }
- return returnValue.toArray(new Property[returnValue.size()]);
- }
- return new Object[0];
- }
- }
-
- @Override
- public Object getParent(Object element) {
- synchronized (PropertyViewer.this) {
- if (mSelectedNode != null && element instanceof Property) {
- if (mSelectedNode.viewNode.categories.size() == 0) {
- return null;
- }
- String name = ((Property) element).name;
- int index = name.indexOf(':');
- if (index == -1) {
- return ViewNode.MISCELLANIOUS;
- }
- return name.substring(0, index);
- }
- return null;
- }
- }
-
- @Override
- public boolean hasChildren(Object element) {
- synchronized (PropertyViewer.this) {
- if (mSelectedNode != null && element instanceof String) {
- String category = (String) element;
- for (String name : mSelectedNode.viewNode.namedProperties.keySet()) {
- if (category.equals(ViewNode.MISCELLANIOUS)) {
- if (name.indexOf(':') == -1) {
- return true;
- }
- } else {
- if (name.startsWith(((String) element) + ":")) {
- return true;
- }
- }
- }
- }
- return false;
- }
- }
-
- @Override
- public Object[] getElements(Object inputElement) {
- synchronized (PropertyViewer.this) {
- if (mSelectedNode != null && inputElement instanceof TreeViewModel) {
- if (mSelectedNode.viewNode.categories.size() == 0) {
- return mSelectedNode.viewNode.properties
- .toArray(new Property[mSelectedNode.viewNode.properties.size()]);
- } else {
- return mSelectedNode.viewNode.categories
- .toArray(new String[mSelectedNode.viewNode.categories.size()]);
- }
- }
- return new Object[0];
- }
- }
-
- @Override
- public void dispose() {
- // pass
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // pass
- }
-
- @Override
- public Image getColumnImage(Object element, int column) {
- if (mSelectedNode == null) {
- return null;
- }
- if (column == 1 && mPropertyValueEditingSupport.canEdit(element)) {
- return mImage;
- }
-
- return null;
- }
-
- @Override
- public String getColumnText(Object element, int column) {
- synchronized (PropertyViewer.this) {
- if (mSelectedNode != null) {
- if (element instanceof String && column == 0) {
- String category = (String) element;
- return Character.toUpperCase(category.charAt(0)) + category.substring(1);
- } else if (element instanceof Property) {
- if (column == 0) {
- String returnValue = ((Property) element).name;
- int index = returnValue.indexOf(':');
- if (index != -1) {
- return returnValue.substring(index + 1);
- }
- return returnValue;
- } else if (column == 1) {
- return ((Property) element).value;
- }
- }
- }
- return "";
- }
- }
-
- @Override
- public void addListener(ILabelProviderListener listener) {
- // pass
- }
-
- @Override
- public boolean isLabelProperty(Object element, String property) {
- // pass
- return false;
- }
-
- @Override
- public void removeListener(ILabelProviderListener listener) {
- // pass
- }
- }
-
- private class PropertyValueEditingSupport extends EditingSupport {
- private DevicePropertyEditingSupport mDevicePropertyEditingSupport =
- new DevicePropertyEditingSupport();
-
- public PropertyValueEditingSupport(ColumnViewer viewer) {
- super(viewer);
- }
-
- @Override
- protected boolean canEdit(Object element) {
- if (mSelectedNode == null) {
- return false;
- }
-
- return element instanceof Property
- && mSelectedNode.viewNode.window.getHvDevice().isViewUpdateEnabled()
- && mDevicePropertyEditingSupport.canEdit((Property) element);
- }
-
- @Override
- protected CellEditor getCellEditor(Object element) {
- Property p = (Property) element;
- PropertyType type = mDevicePropertyEditingSupport.getPropertyType(p);
- Composite parent = (Composite) getViewer().getControl();
-
- switch (type) {
- case INTEGER:
- case INTEGER_OR_CONSTANT:
- return new TextCellEditor(parent);
- case ENUM:
- String[] items = mDevicePropertyEditingSupport.getPropertyRange(p);
- return new ComboBoxCellEditor(parent, items, SWT.READ_ONLY);
- }
-
- return null;
- }
-
- @Override
- protected Object getValue(Object element) {
- Property p = (Property) element;
- PropertyType type = mDevicePropertyEditingSupport.getPropertyType(p);
-
- if (type == PropertyType.ENUM) {
- // for enums, return the index of the current value in the list of possible values
- String[] items = mDevicePropertyEditingSupport.getPropertyRange(p);
- return Integer.valueOf(indexOf(p.value, items));
- }
-
- return ((Property) element).value;
- }
-
- private int indexOf(String item, String[] items) {
- for (int i = 0; i < items.length; i++) {
- if (items[i].equals(item)) {
- return i;
- }
- }
-
- return -1;
- }
-
- @Override
- protected void setValue(Object element, Object newValue) {
- Property p = (Property) element;
- IHvDevice device = mSelectedNode.viewNode.window.getHvDevice();
- Collection<Property> properties = mSelectedNode.viewNode.namedProperties.values();
- if (mDevicePropertyEditingSupport.setValue(properties, p, newValue,
- mSelectedNode.viewNode, device)) {
- doRefresh();
- }
- }
- }
-
- public PropertyViewer(Composite parent) {
- super(parent, SWT.NONE);
- setLayout(new FillLayout());
- mTreeViewer = new TreeViewer(this, SWT.NONE);
-
- mTree = mTreeViewer.getTree();
- mTree.setLinesVisible(true);
- mTree.setHeaderVisible(true);
-
- TreeColumn propertyColumn = new TreeColumn(mTree, SWT.NONE);
- propertyColumn.setText("Property");
- TreeColumn valueColumn = new TreeColumn(mTree, SWT.NONE);
- valueColumn.setText("Value");
-
- mValueColumn = new TreeViewerColumn(mTreeViewer, valueColumn);
- mPropertyValueEditingSupport = new PropertyValueEditingSupport(mTreeViewer);
- mValueColumn.setEditingSupport(mPropertyValueEditingSupport);
-
- mModel = TreeViewModel.getModel();
- ContentProvider contentProvider = new ContentProvider();
- mTreeViewer.setContentProvider(contentProvider);
- mTreeViewer.setLabelProvider(contentProvider);
- mTreeViewer.setInput(mModel);
- mModel.addTreeChangeListener(this);
-
- addDisposeListener(mDisposeListener);
-
- @SuppressWarnings("unused")
- TreeColumnResizer resizer = new TreeColumnResizer(this, propertyColumn, valueColumn);
-
- addControlListener(mControlListener);
-
- ImageLoader imageLoader = ImageLoader.getLoader(HierarchyViewerDirector.class);
- mImage = imageLoader.loadImage("picker.png", Display.getDefault()); //$NON-NLS-1$
-
- treeChanged();
- }
-
- private DisposeListener mDisposeListener = new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- mModel.removeTreeChangeListener(PropertyViewer.this);
- }
- };
-
- // If the window gets too small, hide the data, otherwise SWT throws an
- // ERROR.
-
- private ControlListener mControlListener = new ControlAdapter() {
- private boolean noInput = false;
-
- private boolean noHeader = false;
-
- @Override
- public void controlResized(ControlEvent e) {
- if (getBounds().height <= 20) {
- mTree.setHeaderVisible(false);
- noHeader = true;
- } else if (noHeader) {
- mTree.setHeaderVisible(true);
- noHeader = false;
- }
- if (getBounds().height <= 38) {
- mTreeViewer.setInput(null);
- noInput = true;
- } else if (noInput) {
- mTreeViewer.setInput(mModel);
- noInput = false;
- }
- }
- };
-
- @Override
- public void selectionChanged() {
- synchronized (this) {
- mSelectedNode = mModel.getSelection();
- }
- doRefresh();
- }
-
- @Override
- public void treeChanged() {
- synchronized (this) {
- mSelectedNode = mModel.getSelection();
- }
- doRefresh();
- }
-
- @Override
- public void viewportChanged() {
- // pass
- }
-
- @Override
- public void zoomChanged() {
- // pass
- }
-
- private void doRefresh() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- mTreeViewer.refresh();
- }
- });
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/TreeView.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/TreeView.java
deleted file mode 100644
index 5617239..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/TreeView.java
+++ /dev/null
@@ -1,1086 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-import com.android.hierarchyviewerlib.models.TreeViewModel;
-import com.android.hierarchyviewerlib.models.TreeViewModel.ITreeChangeListener;
-import com.android.hierarchyviewerlib.models.ViewNode.ProfileRating;
-import com.android.hierarchyviewerlib.ui.util.DrawableViewNode;
-import com.android.hierarchyviewerlib.ui.util.DrawableViewNode.Point;
-import com.android.hierarchyviewerlib.ui.util.DrawableViewNode.Rectangle;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseWheelListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Path;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Transform;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-
-import java.text.DecimalFormat;
-
-public class TreeView extends Canvas implements ITreeChangeListener {
-
- private TreeViewModel mModel;
-
- private DrawableViewNode mTree;
-
- private DrawableViewNode mSelectedNode;
-
- private Rectangle mViewport;
-
- private Transform mTransform;
-
- private Transform mInverse;
-
- private double mZoom;
-
- private Point mLastPoint;
-
- private boolean mAlreadySelectedOnMouseDown;
-
- private boolean mDoubleClicked;
-
- private boolean mNodeMoved;
-
- private DrawableViewNode mDraggedNode;
-
- public static final int LINE_PADDING = 10;
-
- public static final float BEZIER_FRACTION = 0.35f;
-
- private static Image sRedImage;
-
- private static Image sYellowImage;
-
- private static Image sGreenImage;
-
- private static Image sNotSelectedImage;
-
- private static Image sSelectedImage;
-
- private static Image sFilteredImage;
-
- private static Image sFilteredSelectedImage;
-
- private static Font sSystemFont;
-
- private Color mBoxColor;
-
- private Color mTextBackgroundColor;
-
- private Rectangle mSelectedRectangleLocation;
-
- private Point mButtonCenter;
-
- private static final int BUTTON_SIZE = 13;
-
- private Image mScaledSelectedImage;
-
- private boolean mButtonClicked;
-
- private DrawableViewNode mLastDrawnSelectedViewNode;
-
- // The profile-image box needs to be moved to,
- // so add some dragging leeway.
- private static final int DRAG_LEEWAY = 220;
-
- // Profile-image box constants
- private static final int RECT_WIDTH = 190;
-
- private static final int RECT_HEIGHT = 224;
-
- private static final int BUTTON_RIGHT_OFFSET = 5;
-
- private static final int BUTTON_TOP_OFFSET = 5;
-
- private static final int IMAGE_WIDTH = 125;
-
- private static final int IMAGE_HEIGHT = 120;
-
- private static final int IMAGE_OFFSET = 6;
-
- private static final int IMAGE_ROUNDING = 8;
-
- private static final int RECTANGLE_SIZE = 5;
-
- private static final int TEXT_SIDE_OFFSET = 8;
-
- private static final int TEXT_TOP_OFFSET = 4;
-
- private static final int TEXT_SPACING = 2;
-
- private static final int TEXT_ROUNDING = 20;
-
- public TreeView(Composite parent) {
- super(parent, SWT.NONE);
-
- mModel = TreeViewModel.getModel();
- mModel.addTreeChangeListener(this);
-
- addPaintListener(mPaintListener);
- addMouseListener(mMouseListener);
- addMouseMoveListener(mMouseMoveListener);
- addMouseWheelListener(mMouseWheelListener);
- addListener(SWT.Resize, mResizeListener);
- addDisposeListener(mDisposeListener);
- addKeyListener(mKeyListener);
-
- loadResources();
-
- mTransform = new Transform(Display.getDefault());
- mInverse = new Transform(Display.getDefault());
-
- loadAllData();
- }
-
- private void loadResources() {
- ImageLoader loader = ImageLoader.getLoader(this.getClass());
- sRedImage = loader.loadImage("red.png", Display.getDefault()); //$NON-NLS-1$
- sYellowImage = loader.loadImage("yellow.png", Display.getDefault()); //$NON-NLS-1$
- sGreenImage = loader.loadImage("green.png", Display.getDefault()); //$NON-NLS-1$
- sNotSelectedImage = loader.loadImage("not-selected.png", Display.getDefault()); //$NON-NLS-1$
- sSelectedImage = loader.loadImage("selected.png", Display.getDefault()); //$NON-NLS-1$
- sFilteredImage = loader.loadImage("filtered.png", Display.getDefault()); //$NON-NLS-1$
- sFilteredSelectedImage = loader.loadImage("selected-filtered.png", Display.getDefault()); //$NON-NLS-1$
- mBoxColor = new Color(Display.getDefault(), new RGB(225, 225, 225));
- mTextBackgroundColor = new Color(Display.getDefault(), new RGB(82, 82, 82));
- if (mScaledSelectedImage != null) {
- mScaledSelectedImage.dispose();
- }
- sSystemFont = Display.getDefault().getSystemFont();
- }
-
- private DisposeListener mDisposeListener = new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- mModel.removeTreeChangeListener(TreeView.this);
- mTransform.dispose();
- mInverse.dispose();
- mBoxColor.dispose();
- mTextBackgroundColor.dispose();
- if (mTree != null) {
- mModel.setViewport(null);
- }
- }
- };
-
- private Listener mResizeListener = new Listener() {
- @Override
- public void handleEvent(Event e) {
- synchronized (TreeView.this) {
- if (mTree != null && mViewport != null) {
-
- // Keep the center in the same place.
- Point viewCenter =
- new Point(mViewport.x + mViewport.width / 2, mViewport.y + mViewport.height
- / 2);
- mViewport.width = getBounds().width / mZoom;
- mViewport.height = getBounds().height / mZoom;
- mViewport.x = viewCenter.x - mViewport.width / 2;
- mViewport.y = viewCenter.y - mViewport.height / 2;
- }
- }
- if (mViewport != null) {
- mModel.setViewport(mViewport);
- }
- }
- };
-
- private KeyListener mKeyListener = new KeyListener() {
-
- @Override
- public void keyPressed(KeyEvent e) {
- boolean selectionChanged = false;
- DrawableViewNode clickedNode = null;
- synchronized (TreeView.this) {
- if (mTree != null && mViewport != null && mSelectedNode != null) {
- switch (e.keyCode) {
- case SWT.ARROW_LEFT:
- if (mSelectedNode.parent != null) {
- mSelectedNode = mSelectedNode.parent;
- selectionChanged = true;
- }
- break;
- case SWT.ARROW_UP:
-
- // On up and down, it is cool to go up and down only
- // the leaf nodes.
- // It goes well with the layout viewer
- DrawableViewNode currentNode = mSelectedNode;
- while (currentNode.parent != null && currentNode.viewNode.index == 0) {
- currentNode = currentNode.parent;
- }
- if (currentNode.parent != null) {
- selectionChanged = true;
- currentNode =
- currentNode.parent.children
- .get(currentNode.viewNode.index - 1);
- while (currentNode.children.size() != 0) {
- currentNode =
- currentNode.children
- .get(currentNode.children.size() - 1);
- }
- }
- if (selectionChanged) {
- mSelectedNode = currentNode;
- }
- break;
- case SWT.ARROW_DOWN:
- currentNode = mSelectedNode;
- while (currentNode.parent != null
- && currentNode.viewNode.index + 1 == currentNode.parent.children
- .size()) {
- currentNode = currentNode.parent;
- }
- if (currentNode.parent != null) {
- selectionChanged = true;
- currentNode =
- currentNode.parent.children
- .get(currentNode.viewNode.index + 1);
- while (currentNode.children.size() != 0) {
- currentNode = currentNode.children.get(0);
- }
- }
- if (selectionChanged) {
- mSelectedNode = currentNode;
- }
- break;
- case SWT.ARROW_RIGHT:
- DrawableViewNode rightNode = null;
- double mostOverlap = 0;
- final int N = mSelectedNode.children.size();
-
- // We consider all the children and pick the one
- // who's tree overlaps the most.
- for (int i = 0; i < N; i++) {
- DrawableViewNode child = mSelectedNode.children.get(i);
- DrawableViewNode topMostChild = child;
- while (topMostChild.children.size() != 0) {
- topMostChild = topMostChild.children.get(0);
- }
- double overlap =
- Math.min(DrawableViewNode.NODE_HEIGHT, Math.min(
- mSelectedNode.top + DrawableViewNode.NODE_HEIGHT
- - topMostChild.top, topMostChild.top
- + child.treeHeight - mSelectedNode.top));
- if (overlap > mostOverlap) {
- mostOverlap = overlap;
- rightNode = child;
- }
- }
- if (rightNode != null) {
- mSelectedNode = rightNode;
- selectionChanged = true;
- }
- break;
- case SWT.CR:
- clickedNode = mSelectedNode;
- break;
- }
- }
- }
- if (selectionChanged) {
- mModel.setSelection(mSelectedNode);
- }
- if (clickedNode != null) {
- HierarchyViewerDirector.getDirector().showCapture(getShell(), clickedNode.viewNode);
- }
- }
-
- @Override
- public void keyReleased(KeyEvent e) {
- }
- };
-
- private MouseListener mMouseListener = new MouseListener() {
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- DrawableViewNode clickedNode = null;
- synchronized (TreeView.this) {
- if (mTree != null && mViewport != null) {
- Point pt = transformPoint(e.x, e.y);
- clickedNode = mTree.getSelected(pt.x, pt.y);
- }
- }
- if (clickedNode != null) {
- HierarchyViewerDirector.getDirector().showCapture(getShell(), clickedNode.viewNode);
- mDoubleClicked = true;
- }
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- boolean selectionChanged = false;
- synchronized (TreeView.this) {
- if (mTree != null && mViewport != null) {
- Point pt = transformPoint(e.x, e.y);
-
- // Ignore profiling rectangle, except for...
- if (mSelectedRectangleLocation != null
- && pt.x >= mSelectedRectangleLocation.x
- && pt.x < mSelectedRectangleLocation.x
- + mSelectedRectangleLocation.width
- && pt.y >= mSelectedRectangleLocation.y
- && pt.y < mSelectedRectangleLocation.y
- + mSelectedRectangleLocation.height) {
-
- // the small button!
- if ((pt.x - mButtonCenter.x) * (pt.x - mButtonCenter.x)
- + (pt.y - mButtonCenter.y) * (pt.y - mButtonCenter.y) <= (BUTTON_SIZE * BUTTON_SIZE) / 4) {
- mButtonClicked = true;
- doRedraw();
- }
- return;
- }
- mDraggedNode = mTree.getSelected(pt.x, pt.y);
-
- // Update the selection.
- if (mDraggedNode != null && mDraggedNode != mSelectedNode) {
- mSelectedNode = mDraggedNode;
- selectionChanged = true;
- mAlreadySelectedOnMouseDown = false;
- } else if (mDraggedNode != null) {
- mAlreadySelectedOnMouseDown = true;
- }
-
- // Can't drag the root.
- if (mDraggedNode == mTree) {
- mDraggedNode = null;
- }
-
- if (mDraggedNode != null) {
- mLastPoint = pt;
- } else {
- mLastPoint = new Point(e.x, e.y);
- }
- mNodeMoved = false;
- mDoubleClicked = false;
- }
- }
- if (selectionChanged) {
- mModel.setSelection(mSelectedNode);
- }
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- boolean redraw = false;
- boolean redrawButton = false;
- boolean viewportChanged = false;
- boolean selectionChanged = false;
- synchronized (TreeView.this) {
- if (mTree != null && mViewport != null && mLastPoint != null) {
- if (mDraggedNode == null) {
- // The viewport moves.
- handleMouseDrag(new Point(e.x, e.y));
- viewportChanged = true;
- } else {
- // The nodes move.
- handleMouseDrag(transformPoint(e.x, e.y));
- }
-
- // Deselect on the second click...
- // This is in the mouse up, because mouse up happens after a
- // double click event.
- // During a double click, we don't want to deselect.
- Point pt = transformPoint(e.x, e.y);
- DrawableViewNode mouseUpOn = mTree.getSelected(pt.x, pt.y);
- if (mouseUpOn != null && mouseUpOn == mSelectedNode
- && mAlreadySelectedOnMouseDown && !mNodeMoved && !mDoubleClicked) {
- mSelectedNode = null;
- selectionChanged = true;
- }
- mLastPoint = null;
- mDraggedNode = null;
- redraw = true;
- }
-
- // Just clicked the button here.
- if (mButtonClicked) {
- HierarchyViewerDirector.getDirector().showCapture(getShell(),
- mSelectedNode.viewNode);
- mButtonClicked = false;
- redrawButton = true;
- }
- }
-
- // Complicated.
- if (viewportChanged) {
- mModel.setViewport(mViewport);
- } else if (redraw) {
- mModel.removeTreeChangeListener(TreeView.this);
- mModel.notifyViewportChanged();
- if (selectionChanged) {
- mModel.setSelection(mSelectedNode);
- }
- mModel.addTreeChangeListener(TreeView.this);
- doRedraw();
- } else if (redrawButton) {
- doRedraw();
- }
- }
-
- };
-
- private MouseMoveListener mMouseMoveListener = new MouseMoveListener() {
- @Override
- public void mouseMove(MouseEvent e) {
- boolean redraw = false;
- boolean viewportChanged = false;
- synchronized (TreeView.this) {
- if (mTree != null && mViewport != null && mLastPoint != null) {
- if (mDraggedNode == null) {
- handleMouseDrag(new Point(e.x, e.y));
- viewportChanged = true;
- } else {
- handleMouseDrag(transformPoint(e.x, e.y));
- }
- redraw = true;
- }
- }
- if (viewportChanged) {
- mModel.setViewport(mViewport);
- } else if (redraw) {
- mModel.removeTreeChangeListener(TreeView.this);
- mModel.notifyViewportChanged();
- mModel.addTreeChangeListener(TreeView.this);
- doRedraw();
- }
- }
- };
-
- private void handleMouseDrag(Point pt) {
-
- // Case 1: a node is dragged. DrawableViewNode knows how to handle this.
- if (mDraggedNode != null) {
- if (mLastPoint.y - pt.y != 0) {
- mNodeMoved = true;
- }
- mDraggedNode.move(mLastPoint.y - pt.y);
- mLastPoint = pt;
- return;
- }
-
- // Case 2: the viewport is dragged. We have to make sure we respect the
- // bounds - don't let the user drag way out... + some leeway for the
- // profiling box.
- double xDif = (mLastPoint.x - pt.x) / mZoom;
- double yDif = (mLastPoint.y - pt.y) / mZoom;
-
- double treeX = mTree.bounds.x - DRAG_LEEWAY;
- double treeY = mTree.bounds.y - DRAG_LEEWAY;
- double treeWidth = mTree.bounds.width + 2 * DRAG_LEEWAY;
- double treeHeight = mTree.bounds.height + 2 * DRAG_LEEWAY;
-
- if (mViewport.width > treeWidth) {
- if (xDif < 0 && mViewport.x + mViewport.width > treeX + treeWidth) {
- mViewport.x = Math.max(mViewport.x + xDif, treeX + treeWidth - mViewport.width);
- } else if (xDif > 0 && mViewport.x < treeX) {
- mViewport.x = Math.min(mViewport.x + xDif, treeX);
- }
- } else {
- if (xDif < 0 && mViewport.x > treeX) {
- mViewport.x = Math.max(mViewport.x + xDif, treeX);
- } else if (xDif > 0 && mViewport.x + mViewport.width < treeX + treeWidth) {
- mViewport.x = Math.min(mViewport.x + xDif, treeX + treeWidth - mViewport.width);
- }
- }
- if (mViewport.height > treeHeight) {
- if (yDif < 0 && mViewport.y + mViewport.height > treeY + treeHeight) {
- mViewport.y = Math.max(mViewport.y + yDif, treeY + treeHeight - mViewport.height);
- } else if (yDif > 0 && mViewport.y < treeY) {
- mViewport.y = Math.min(mViewport.y + yDif, treeY);
- }
- } else {
- if (yDif < 0 && mViewport.y > treeY) {
- mViewport.y = Math.max(mViewport.y + yDif, treeY);
- } else if (yDif > 0 && mViewport.y + mViewport.height < treeY + treeHeight) {
- mViewport.y = Math.min(mViewport.y + yDif, treeY + treeHeight - mViewport.height);
- }
- }
- mLastPoint = pt;
- }
-
- private Point transformPoint(double x, double y) {
- float[] pt = {
- (float) x, (float) y
- };
- mInverse.transform(pt);
- return new Point(pt[0], pt[1]);
- }
-
- private MouseWheelListener mMouseWheelListener = new MouseWheelListener() {
- @Override
- public void mouseScrolled(MouseEvent e) {
- Point zoomPoint = null;
- synchronized (TreeView.this) {
- if (mTree != null && mViewport != null) {
- mZoom += Math.ceil(e.count / 3.0) * 0.1;
- zoomPoint = transformPoint(e.x, e.y);
- }
- }
- if (zoomPoint != null) {
- mModel.zoomOnPoint(mZoom, zoomPoint);
- }
- }
- };
-
- private PaintListener mPaintListener = new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- synchronized (TreeView.this) {
- e.gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
- e.gc.fillRectangle(0, 0, getBounds().width, getBounds().height);
- if (mTree != null && mViewport != null) {
-
- // Easy stuff!
- e.gc.setTransform(mTransform);
- e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
- Path connectionPath = new Path(Display.getDefault());
- paintRecursive(e.gc, mTransform, mTree, mSelectedNode, connectionPath);
- e.gc.drawPath(connectionPath);
- connectionPath.dispose();
-
- // Draw the profiling box.
- if (mSelectedNode != null) {
-
- e.gc.setAlpha(200);
-
- // Draw the little triangle
- int x = mSelectedNode.left + DrawableViewNode.NODE_WIDTH / 2;
- int y = (int) mSelectedNode.top + 4;
- e.gc.setBackground(mBoxColor);
- e.gc.fillPolygon(new int[] {
- x, y, x - 11, y - 11, x + 11, y - 11
- });
-
- // Draw the rectangle and update the location.
- y -= 10 + RECT_HEIGHT;
- e.gc.fillRoundRectangle(x - RECT_WIDTH / 2, y, RECT_WIDTH, RECT_HEIGHT, 30,
- 30);
- mSelectedRectangleLocation =
- new Rectangle(x - RECT_WIDTH / 2, y, RECT_WIDTH, RECT_HEIGHT);
-
- e.gc.setAlpha(255);
-
- // Draw the button
- mButtonCenter =
- new Point(x - BUTTON_RIGHT_OFFSET + (RECT_WIDTH - BUTTON_SIZE) / 2,
- y + BUTTON_TOP_OFFSET + BUTTON_SIZE / 2);
-
- if (mButtonClicked) {
- e.gc
- .setBackground(Display.getDefault().getSystemColor(
- SWT.COLOR_BLACK));
- } else {
- e.gc.setBackground(mTextBackgroundColor);
-
- }
- e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
-
- e.gc.fillOval(x + RECT_WIDTH / 2 - BUTTON_RIGHT_OFFSET - BUTTON_SIZE, y
- + BUTTON_TOP_OFFSET, BUTTON_SIZE, BUTTON_SIZE);
-
- e.gc.drawRectangle(x - BUTTON_RIGHT_OFFSET
- + (RECT_WIDTH - BUTTON_SIZE - RECTANGLE_SIZE) / 2 - 1, y
- + BUTTON_TOP_OFFSET + (BUTTON_SIZE - RECTANGLE_SIZE) / 2,
- RECTANGLE_SIZE + 1, RECTANGLE_SIZE);
-
- y += 15;
-
- // If there is an image, draw it.
- if (mSelectedNode.viewNode.image != null
- && mSelectedNode.viewNode.image.getBounds().height != 1
- && mSelectedNode.viewNode.image.getBounds().width != 1) {
-
- // Scaling the image to the right size takes lots of
- // time, so we want to do it only once.
-
- // If the selection changed, get rid of the old
- // image.
- if (mLastDrawnSelectedViewNode != mSelectedNode) {
- if (mScaledSelectedImage != null) {
- mScaledSelectedImage.dispose();
- mScaledSelectedImage = null;
- }
- mLastDrawnSelectedViewNode = mSelectedNode;
- }
-
- if (mScaledSelectedImage == null) {
- double ratio =
- 1.0 * mSelectedNode.viewNode.image.getBounds().width
- / mSelectedNode.viewNode.image.getBounds().height;
- int newWidth, newHeight;
- if (ratio > 1.0 * IMAGE_WIDTH / IMAGE_HEIGHT) {
- newWidth =
- Math.min(IMAGE_WIDTH, mSelectedNode.viewNode.image
- .getBounds().width);
- newHeight = (int) (newWidth / ratio);
- } else {
- newHeight =
- Math.min(IMAGE_HEIGHT, mSelectedNode.viewNode.image
- .getBounds().height);
- newWidth = (int) (newHeight * ratio);
- }
-
- // Interesting note... We make the image twice
- // the needed size so that there is better
- // resolution under zoom.
- newWidth = Math.max(newWidth * 2, 1);
- newHeight = Math.max(newHeight * 2, 1);
- mScaledSelectedImage =
- new Image(Display.getDefault(), newWidth, newHeight);
- GC gc = new GC(mScaledSelectedImage);
- gc.setBackground(mTextBackgroundColor);
- gc.fillRectangle(0, 0, newWidth, newHeight);
- gc.drawImage(mSelectedNode.viewNode.image, 0, 0,
- mSelectedNode.viewNode.image.getBounds().width,
- mSelectedNode.viewNode.image.getBounds().height, 0, 0,
- newWidth, newHeight);
- gc.dispose();
- }
-
- // Draw the background rectangle
- e.gc.setBackground(mTextBackgroundColor);
- e.gc.fillRoundRectangle(x - mScaledSelectedImage.getBounds().width / 4
- - IMAGE_OFFSET, y
- + (IMAGE_HEIGHT - mScaledSelectedImage.getBounds().height / 2)
- / 2 - IMAGE_OFFSET, mScaledSelectedImage.getBounds().width / 2
- + 2 * IMAGE_OFFSET, mScaledSelectedImage.getBounds().height / 2
- + 2 * IMAGE_OFFSET, IMAGE_ROUNDING, IMAGE_ROUNDING);
-
- // Under max zoom, we want the image to be
- // untransformed. So, get back to the identity
- // transform.
- int imageX = x - mScaledSelectedImage.getBounds().width / 4;
- int imageY =
- y
- + (IMAGE_HEIGHT - mScaledSelectedImage.getBounds().height / 2)
- / 2;
-
- Transform untransformedTransform = new Transform(Display.getDefault());
- e.gc.setTransform(untransformedTransform);
- float[] pt = new float[] {
- imageX, imageY
- };
- mTransform.transform(pt);
- e.gc.drawImage(mScaledSelectedImage, 0, 0, mScaledSelectedImage
- .getBounds().width, mScaledSelectedImage.getBounds().height,
- (int) pt[0], (int) pt[1], (int) (mScaledSelectedImage
- .getBounds().width
- * mZoom / 2),
- (int) (mScaledSelectedImage.getBounds().height * mZoom / 2));
- untransformedTransform.dispose();
- e.gc.setTransform(mTransform);
- }
-
- // Text stuff
-
- y += IMAGE_HEIGHT;
- y += 10;
- Font font = getFont(8, false);
- e.gc.setFont(font);
-
- String text =
- mSelectedNode.viewNode.viewCount + " view"
- + (mSelectedNode.viewNode.viewCount != 1 ? "s" : "");
- DecimalFormat formatter = new DecimalFormat("0.000");
-
- String measureText =
- "Measure: "
- + (mSelectedNode.viewNode.measureTime != -1 ? formatter
- .format(mSelectedNode.viewNode.measureTime)
- + " ms" : "n/a");
- String layoutText =
- "Layout: "
- + (mSelectedNode.viewNode.layoutTime != -1 ? formatter
- .format(mSelectedNode.viewNode.layoutTime)
- + " ms" : "n/a");
- String drawText =
- "Draw: "
- + (mSelectedNode.viewNode.drawTime != -1 ? formatter
- .format(mSelectedNode.viewNode.drawTime)
- + " ms" : "n/a");
-
- org.eclipse.swt.graphics.Point titleExtent = e.gc.stringExtent(text);
- org.eclipse.swt.graphics.Point measureExtent =
- e.gc.stringExtent(measureText);
- org.eclipse.swt.graphics.Point layoutExtent = e.gc.stringExtent(layoutText);
- org.eclipse.swt.graphics.Point drawExtent = e.gc.stringExtent(drawText);
- int boxWidth =
- Math.max(titleExtent.x, Math.max(measureExtent.x, Math.max(
- layoutExtent.x, drawExtent.x)))
- + 2 * TEXT_SIDE_OFFSET;
- int boxHeight =
- titleExtent.y + TEXT_SPACING + measureExtent.y + TEXT_SPACING
- + layoutExtent.y + TEXT_SPACING + drawExtent.y + 2
- * TEXT_TOP_OFFSET;
-
- e.gc.setBackground(mTextBackgroundColor);
- e.gc.fillRoundRectangle(x - boxWidth / 2, y, boxWidth, boxHeight,
- TEXT_ROUNDING, TEXT_ROUNDING);
-
- e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
-
- y += TEXT_TOP_OFFSET;
-
- e.gc.drawText(text, x - titleExtent.x / 2, y, true);
-
- x -= boxWidth / 2;
- x += TEXT_SIDE_OFFSET;
-
- y += titleExtent.y + TEXT_SPACING;
-
- e.gc.drawText(measureText, x, y, true);
-
- y += measureExtent.y + TEXT_SPACING;
-
- e.gc.drawText(layoutText, x, y, true);
-
- y += layoutExtent.y + TEXT_SPACING;
-
- e.gc.drawText(drawText, x, y, true);
-
- font.dispose();
- } else {
- mSelectedRectangleLocation = null;
- mButtonCenter = null;
- }
- }
- }
- }
- };
-
- private static void paintRecursive(GC gc, Transform transform, DrawableViewNode node,
- DrawableViewNode selectedNode, Path connectionPath) {
- if (selectedNode == node && node.viewNode.filtered) {
- gc.drawImage(sFilteredSelectedImage, node.left, (int) Math.round(node.top));
- } else if (selectedNode == node) {
- gc.drawImage(sSelectedImage, node.left, (int) Math.round(node.top));
- } else if (node.viewNode.filtered) {
- gc.drawImage(sFilteredImage, node.left, (int) Math.round(node.top));
- } else {
- gc.drawImage(sNotSelectedImage, node.left, (int) Math.round(node.top));
- }
-
- int fontHeight = gc.getFontMetrics().getHeight();
-
- // Draw the text...
- int contentWidth =
- DrawableViewNode.NODE_WIDTH - 2 * DrawableViewNode.CONTENT_LEFT_RIGHT_PADDING;
- String name = node.viewNode.name;
- int dotIndex = name.lastIndexOf('.');
- if (dotIndex != -1) {
- name = name.substring(dotIndex + 1);
- }
- double x = node.left + DrawableViewNode.CONTENT_LEFT_RIGHT_PADDING;
- double y = node.top + DrawableViewNode.CONTENT_TOP_BOTTOM_PADDING;
- drawTextInArea(gc, transform, name, x, y, contentWidth, fontHeight, 10, true);
-
- y += fontHeight + DrawableViewNode.CONTENT_INTER_PADDING;
-
- drawTextInArea(gc, transform, "@" + node.viewNode.hashCode, x, y, contentWidth, fontHeight,
- 8, false);
-
- y += fontHeight + DrawableViewNode.CONTENT_INTER_PADDING;
- if (!node.viewNode.id.equals("NO_ID")) {
- drawTextInArea(gc, transform, node.viewNode.id, x, y, contentWidth, fontHeight, 8,
- false);
- }
-
- if (node.viewNode.measureRating != ProfileRating.NONE) {
- y =
- node.top + DrawableViewNode.NODE_HEIGHT
- - DrawableViewNode.CONTENT_TOP_BOTTOM_PADDING
- - sRedImage.getBounds().height;
- x +=
- (contentWidth - (sRedImage.getBounds().width * 3 + 2 * DrawableViewNode.CONTENT_INTER_PADDING)) / 2;
- switch (node.viewNode.measureRating) {
- case GREEN:
- gc.drawImage(sGreenImage, (int) x, (int) y);
- break;
- case YELLOW:
- gc.drawImage(sYellowImage, (int) x, (int) y);
- break;
- case RED:
- gc.drawImage(sRedImage, (int) x, (int) y);
- break;
- }
-
- x += sRedImage.getBounds().width + DrawableViewNode.CONTENT_INTER_PADDING;
- switch (node.viewNode.layoutRating) {
- case GREEN:
- gc.drawImage(sGreenImage, (int) x, (int) y);
- break;
- case YELLOW:
- gc.drawImage(sYellowImage, (int) x, (int) y);
- break;
- case RED:
- gc.drawImage(sRedImage, (int) x, (int) y);
- break;
- }
-
- x += sRedImage.getBounds().width + DrawableViewNode.CONTENT_INTER_PADDING;
- switch (node.viewNode.drawRating) {
- case GREEN:
- gc.drawImage(sGreenImage, (int) x, (int) y);
- break;
- case YELLOW:
- gc.drawImage(sYellowImage, (int) x, (int) y);
- break;
- case RED:
- gc.drawImage(sRedImage, (int) x, (int) y);
- break;
- }
- }
-
- org.eclipse.swt.graphics.Point indexExtent =
- gc.stringExtent(Integer.toString(node.viewNode.index));
- x =
- node.left + DrawableViewNode.NODE_WIDTH - DrawableViewNode.INDEX_PADDING
- - indexExtent.x;
- y =
- node.top + DrawableViewNode.NODE_HEIGHT - DrawableViewNode.INDEX_PADDING
- - indexExtent.y;
- gc.drawText(Integer.toString(node.viewNode.index), (int) x, (int) y, SWT.DRAW_TRANSPARENT);
-
- int N = node.children.size();
- if (N == 0) {
- return;
- }
- float childSpacing = (1.0f * (DrawableViewNode.NODE_HEIGHT - 2 * LINE_PADDING)) / N;
- for (int i = 0; i < N; i++) {
- DrawableViewNode child = node.children.get(i);
- paintRecursive(gc, transform, child, selectedNode, connectionPath);
- float x1 = node.left + DrawableViewNode.NODE_WIDTH;
- float y1 = (float) node.top + LINE_PADDING + childSpacing * i + childSpacing / 2;
- float x2 = child.left;
- float y2 = (float) child.top + DrawableViewNode.NODE_HEIGHT / 2.0f;
- float cx1 = x1 + BEZIER_FRACTION * DrawableViewNode.PARENT_CHILD_SPACING;
- float cy1 = y1;
- float cx2 = x2 - BEZIER_FRACTION * DrawableViewNode.PARENT_CHILD_SPACING;
- float cy2 = y2;
- connectionPath.moveTo(x1, y1);
- connectionPath.cubicTo(cx1, cy1, cx2, cy2, x2, y2);
- }
- }
-
- private static void drawTextInArea(GC gc, Transform transform, String text, double x, double y,
- double width, double height, int fontSize, boolean bold) {
-
- Font oldFont = gc.getFont();
-
- Font newFont = getFont(fontSize, bold);
- gc.setFont(newFont);
-
- org.eclipse.swt.graphics.Point extent = gc.stringExtent(text);
-
- if (extent.x > width) {
- // Oh no... we need to scale it.
- double scale = width / extent.x;
- float[] transformElements = new float[6];
- transform.getElements(transformElements);
- transform.scale((float) scale, (float) scale);
- gc.setTransform(transform);
-
- x /= scale;
- y /= scale;
- y += (extent.y / scale - extent.y) / 2;
-
- gc.drawText(text, (int) x, (int) y, SWT.DRAW_TRANSPARENT);
-
- transform.setElements(transformElements[0], transformElements[1], transformElements[2],
- transformElements[3], transformElements[4], transformElements[5]);
- gc.setTransform(transform);
- } else {
- gc.drawText(text, (int) (x + (width - extent.x) / 2),
- (int) (y + (height - extent.y) / 2), SWT.DRAW_TRANSPARENT);
- }
- gc.setFont(oldFont);
- newFont.dispose();
-
- }
-
- public static Image paintToImage(DrawableViewNode tree) {
- Image image =
- new Image(Display.getDefault(), (int) Math.ceil(tree.bounds.width), (int) Math
- .ceil(tree.bounds.height));
-
- Transform transform = new Transform(Display.getDefault());
- transform.identity();
- transform.translate((float) -tree.bounds.x, (float) -tree.bounds.y);
- Path connectionPath = new Path(Display.getDefault());
- GC gc = new GC(image);
-
- // Can't use Display.getDefault().getSystemColor in a non-UI thread.
- Color white = new Color(Display.getDefault(), 255, 255, 255);
- Color black = new Color(Display.getDefault(), 0, 0, 0);
- gc.setForeground(white);
- gc.setBackground(black);
- gc.fillRectangle(0, 0, image.getBounds().width, image.getBounds().height);
- gc.setTransform(transform);
- paintRecursive(gc, transform, tree, null, connectionPath);
- gc.drawPath(connectionPath);
- gc.dispose();
- connectionPath.dispose();
- white.dispose();
- black.dispose();
- return image;
- }
-
- private static Font getFont(int size, boolean bold) {
- FontData[] fontData = sSystemFont.getFontData();
- for (int i = 0; i < fontData.length; i++) {
- fontData[i].setHeight(size);
- if (bold) {
- fontData[i].setStyle(SWT.BOLD);
- }
- }
- return new Font(Display.getDefault(), fontData);
- }
-
- private void doRedraw() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- redraw();
- }
- });
- }
-
- public void loadAllData() {
- boolean newViewport = mViewport == null;
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (this) {
- mTree = mModel.getTree();
- mSelectedNode = mModel.getSelection();
- mViewport = mModel.getViewport();
- mZoom = mModel.getZoom();
- if (mTree != null && mViewport == null) {
- mViewport =
- new Rectangle(0, mTree.top + DrawableViewNode.NODE_HEIGHT / 2
- - getBounds().height / 2, getBounds().width,
- getBounds().height);
- } else {
- setTransform();
- }
- }
- }
- });
- if (newViewport) {
- mModel.setViewport(mViewport);
- }
- }
-
- // Fickle behaviour... When a new tree is loaded, the model doesn't know
- // about the viewport until it passes through here.
- @Override
- public void treeChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (this) {
- mTree = mModel.getTree();
- mSelectedNode = mModel.getSelection();
- if (mTree == null) {
- mViewport = null;
- } else {
- mViewport =
- new Rectangle(0, mTree.top + DrawableViewNode.NODE_HEIGHT / 2
- - getBounds().height / 2, getBounds().width,
- getBounds().height);
- }
- }
- }
- });
- if (mViewport != null) {
- mModel.setViewport(mViewport);
- } else {
- doRedraw();
- }
- }
-
- private void setTransform() {
- if (mViewport != null && mTree != null) {
- // Set the transform.
- mTransform.identity();
- mInverse.identity();
-
- mTransform.scale((float) mZoom, (float) mZoom);
- mInverse.scale((float) mZoom, (float) mZoom);
- mTransform.translate((float) -mViewport.x, (float) -mViewport.y);
- mInverse.translate((float) -mViewport.x, (float) -mViewport.y);
- mInverse.invert();
- }
- }
-
- // Note the syncExec and then synchronized... It avoids deadlock
- @Override
- public void viewportChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (this) {
- mViewport = mModel.getViewport();
- mZoom = mModel.getZoom();
- setTransform();
- }
- }
- });
- doRedraw();
- }
-
- @Override
- public void zoomChanged() {
- viewportChanged();
- }
-
- @Override
- public void selectionChanged() {
- synchronized (this) {
- mSelectedNode = mModel.getSelection();
- if (mSelectedNode != null && mSelectedNode.viewNode.image == null) {
- HierarchyViewerDirector.getDirector()
- .loadCaptureInBackground(mSelectedNode.viewNode);
- }
- }
- doRedraw();
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/TreeViewControls.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/TreeViewControls.java
deleted file mode 100644
index fc03f13..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/TreeViewControls.java
+++ /dev/null
@@ -1,153 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui;
-
-import com.android.hierarchyviewerlib.HierarchyViewerDirector;
-import com.android.hierarchyviewerlib.models.TreeViewModel;
-import com.android.hierarchyviewerlib.models.TreeViewModel.ITreeChangeListener;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Slider;
-import org.eclipse.swt.widgets.Text;
-
-public class TreeViewControls extends Composite implements ITreeChangeListener {
-
- private Text mFilterText;
-
- private Slider mZoomSlider;
-
- public TreeViewControls(Composite parent) {
- super(parent, SWT.NONE);
- GridLayout layout = new GridLayout(5, false);
- layout.marginWidth = layout.marginHeight = 2;
- layout.verticalSpacing = layout.horizontalSpacing = 4;
- setLayout(layout);
-
- Label filterLabel = new Label(this, SWT.NONE);
- filterLabel.setText("Filter by class or id:");
- filterLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, true));
-
- mFilterText = new Text(this, SWT.LEFT | SWT.SINGLE);
- mFilterText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- mFilterText.addModifyListener(mFilterTextModifyListener);
- mFilterText.setText(HierarchyViewerDirector.getDirector().getFilterText());
-
- Label smallZoomLabel = new Label(this, SWT.NONE);
- smallZoomLabel.setText(" 20%");
- smallZoomLabel
- .setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, true));
-
- mZoomSlider = new Slider(this, SWT.HORIZONTAL);
- GridData zoomSliderGridData = new GridData(GridData.CENTER, GridData.CENTER, false, false);
- zoomSliderGridData.widthHint = 190;
- mZoomSlider.setLayoutData(zoomSliderGridData);
- mZoomSlider.setMinimum((int) (TreeViewModel.MIN_ZOOM * 10));
- mZoomSlider.setMaximum((int) (TreeViewModel.MAX_ZOOM * 10 + 1));
- mZoomSlider.setThumb(1);
- mZoomSlider.setSelection((int) Math.round(TreeViewModel.getModel().getZoom() * 10));
-
- mZoomSlider.addSelectionListener(mZoomSliderSelectionListener);
-
- Label largeZoomLabel = new Label(this, SWT.NONE);
- largeZoomLabel
- .setLayoutData(new GridData(GridData.BEGINNING, GridData.CENTER, false, true));
- largeZoomLabel.setText("200%");
-
- addDisposeListener(mDisposeListener);
-
- TreeViewModel.getModel().addTreeChangeListener(this);
- }
-
- private DisposeListener mDisposeListener = new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- TreeViewModel.getModel().removeTreeChangeListener(TreeViewControls.this);
- }
- };
-
- private SelectionListener mZoomSliderSelectionListener = new SelectionListener() {
- private int oldValue;
-
- @Override
- public void widgetDefaultSelected(SelectionEvent e) {
- // pass
- }
-
- @Override
- public void widgetSelected(SelectionEvent e) {
- int newValue = mZoomSlider.getSelection();
- if (oldValue != newValue) {
- TreeViewModel.getModel().removeTreeChangeListener(TreeViewControls.this);
- TreeViewModel.getModel().setZoom(newValue / 10.0);
- TreeViewModel.getModel().addTreeChangeListener(TreeViewControls.this);
- oldValue = newValue;
- }
- }
- };
-
- private ModifyListener mFilterTextModifyListener = new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- HierarchyViewerDirector.getDirector().filterNodes(mFilterText.getText());
- }
- };
-
- @Override
- public void selectionChanged() {
- // pass
- }
-
- @Override
- public void treeChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- if (TreeViewModel.getModel().getTree() != null) {
- mZoomSlider.setSelection((int) Math
- .round(TreeViewModel.getModel().getZoom() * 10));
- }
- mFilterText.setText(""); //$NON-NLS-1$
- }
- });
- }
-
- @Override
- public void viewportChanged() {
- // pass
- }
-
- @Override
- public void zoomChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- mZoomSlider.setSelection((int) Math.round(TreeViewModel.getModel().getZoom() * 10));
- }
- });
- };
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/TreeViewOverview.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/TreeViewOverview.java
deleted file mode 100644
index 3352df0..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/TreeViewOverview.java
+++ /dev/null
@@ -1,396 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui;
-
-import com.android.ddmuilib.ImageLoader;
-import com.android.hierarchyviewerlib.models.TreeViewModel;
-import com.android.hierarchyviewerlib.models.TreeViewModel.ITreeChangeListener;
-import com.android.hierarchyviewerlib.ui.util.DrawableViewNode;
-import com.android.hierarchyviewerlib.ui.util.DrawableViewNode.Point;
-import com.android.hierarchyviewerlib.ui.util.DrawableViewNode.Rectangle;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Path;
-import org.eclipse.swt.graphics.Transform;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-
-public class TreeViewOverview extends Canvas implements ITreeChangeListener {
-
- private TreeViewModel mModel;
-
- private DrawableViewNode mTree;
-
- private Rectangle mViewport;
-
- private Transform mTransform;
-
- private Transform mInverse;
-
- private Rectangle mBounds = new Rectangle();
-
- private double mScale;
-
- private boolean mDragging = false;
-
- private DrawableViewNode mSelectedNode;
-
- private static Image sNotSelectedImage;
-
- private static Image sSelectedImage;
-
- private static Image sFilteredImage;
-
- private static Image sFilteredSelectedImage;
-
- public TreeViewOverview(Composite parent) {
- super(parent, SWT.NONE);
-
- mModel = TreeViewModel.getModel();
- mModel.addTreeChangeListener(this);
-
- loadResources();
-
- addPaintListener(mPaintListener);
- addMouseListener(mMouseListener);
- addMouseMoveListener(mMouseMoveListener);
- addListener(SWT.Resize, mResizeListener);
- addDisposeListener(mDisposeListener);
-
- mTransform = new Transform(Display.getDefault());
- mInverse = new Transform(Display.getDefault());
-
- loadAllData();
- }
-
- private void loadResources() {
- ImageLoader loader = ImageLoader.getLoader(this.getClass());
- sNotSelectedImage = loader.loadImage("not-selected.png", Display.getDefault()); //$NON-NLS-1$
- sSelectedImage = loader.loadImage("selected-small.png", Display.getDefault()); //$NON-NLS-1$
- sFilteredImage = loader.loadImage("filtered.png", Display.getDefault()); //$NON-NLS-1$
- sFilteredSelectedImage =
- loader.loadImage("selected-filtered-small.png", Display.getDefault()); //$NON-NLS-1$
- }
-
- private DisposeListener mDisposeListener = new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- mModel.removeTreeChangeListener(TreeViewOverview.this);
- mTransform.dispose();
- mInverse.dispose();
- }
- };
-
- private MouseListener mMouseListener = new MouseListener() {
-
- @Override
- public void mouseDoubleClick(MouseEvent e) {
- // pass
- }
-
- @Override
- public void mouseDown(MouseEvent e) {
- boolean redraw = false;
- synchronized (TreeViewOverview.this) {
- if (mTree != null && mViewport != null) {
- mDragging = true;
- redraw = true;
- handleMouseEvent(transformPoint(e.x, e.y));
- }
- }
- if (redraw) {
- mModel.removeTreeChangeListener(TreeViewOverview.this);
- mModel.setViewport(mViewport);
- mModel.addTreeChangeListener(TreeViewOverview.this);
- doRedraw();
- }
- }
-
- @Override
- public void mouseUp(MouseEvent e) {
- boolean redraw = false;
- synchronized (TreeViewOverview.this) {
- if (mTree != null && mViewport != null) {
- mDragging = false;
- redraw = true;
- handleMouseEvent(transformPoint(e.x, e.y));
-
- // Update bounds and transform only on mouse up. That way,
- // you don't get confusing behaviour during mouse drag and
- // it snaps neatly at the end
- setBounds();
- setTransform();
- }
- }
- if (redraw) {
- mModel.removeTreeChangeListener(TreeViewOverview.this);
- mModel.setViewport(mViewport);
- mModel.addTreeChangeListener(TreeViewOverview.this);
- doRedraw();
- }
- }
-
- };
-
- private MouseMoveListener mMouseMoveListener = new MouseMoveListener() {
- @Override
- public void mouseMove(MouseEvent e) {
- boolean moved = false;
- synchronized (TreeViewOverview.this) {
- if (mDragging) {
- moved = true;
- handleMouseEvent(transformPoint(e.x, e.y));
- }
- }
- if (moved) {
- mModel.removeTreeChangeListener(TreeViewOverview.this);
- mModel.setViewport(mViewport);
- mModel.addTreeChangeListener(TreeViewOverview.this);
- doRedraw();
- }
- }
- };
-
- private void handleMouseEvent(Point pt) {
- mViewport.x = pt.x - mViewport.width / 2;
- mViewport.y = pt.y - mViewport.height / 2;
- if (mViewport.x < mBounds.x) {
- mViewport.x = mBounds.x;
- }
- if (mViewport.y < mBounds.y) {
- mViewport.y = mBounds.y;
- }
- if (mViewport.x + mViewport.width > mBounds.x + mBounds.width) {
- mViewport.x = mBounds.x + mBounds.width - mViewport.width;
- }
- if (mViewport.y + mViewport.height > mBounds.y + mBounds.height) {
- mViewport.y = mBounds.y + mBounds.height - mViewport.height;
- }
- }
-
- private Point transformPoint(double x, double y) {
- float[] pt = {
- (float) x, (float) y
- };
- mInverse.transform(pt);
- return new Point(pt[0], pt[1]);
- }
-
- private Listener mResizeListener = new Listener() {
- @Override
- public void handleEvent(Event arg0) {
- synchronized (TreeViewOverview.this) {
- setTransform();
- }
- doRedraw();
- }
- };
-
- private PaintListener mPaintListener = new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- synchronized (TreeViewOverview.this) {
- if (mTree != null) {
- e.gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
- e.gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
- e.gc.fillRectangle(0, 0, getBounds().width, getBounds().height);
- e.gc.setTransform(mTransform);
- e.gc.setLineWidth((int) Math.ceil(0.7 / mScale));
- Path connectionPath = new Path(Display.getDefault());
- paintRecursive(e.gc, mTree, connectionPath);
- e.gc.drawPath(connectionPath);
- connectionPath.dispose();
-
- if (mViewport != null) {
- e.gc.setAlpha(50);
- e.gc.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
- e.gc.fillRectangle((int) mViewport.x, (int) mViewport.y, (int) Math
- .ceil(mViewport.width), (int) Math.ceil(mViewport.height));
-
- e.gc.setAlpha(255);
- e.gc.setForeground(Display.getDefault().getSystemColor(
- SWT.COLOR_DARK_GRAY));
- e.gc.setLineWidth((int) Math.ceil(2 / mScale));
- e.gc.drawRectangle((int) mViewport.x, (int) mViewport.y, (int) Math
- .ceil(mViewport.width), (int) Math.ceil(mViewport.height));
- }
- }
- }
- }
- };
-
- private void paintRecursive(GC gc, DrawableViewNode node, Path connectionPath) {
- if (mSelectedNode == node && node.viewNode.filtered) {
- gc.drawImage(sFilteredSelectedImage, node.left, (int) Math.round(node.top));
- } else if (mSelectedNode == node) {
- gc.drawImage(sSelectedImage, node.left, (int) Math.round(node.top));
- } else if (node.viewNode.filtered) {
- gc.drawImage(sFilteredImage, node.left, (int) Math.round(node.top));
- } else {
- gc.drawImage(sNotSelectedImage, node.left, (int) Math.round(node.top));
- }
- int N = node.children.size();
- if (N == 0) {
- return;
- }
- float childSpacing =
- (1.0f * (DrawableViewNode.NODE_HEIGHT - 2 * TreeView.LINE_PADDING)) / N;
- for (int i = 0; i < N; i++) {
- DrawableViewNode child = node.children.get(i);
- paintRecursive(gc, child, connectionPath);
- float x1 = node.left + DrawableViewNode.NODE_WIDTH;
- float y1 =
- (float) node.top + TreeView.LINE_PADDING + childSpacing * i + childSpacing / 2;
- float x2 = child.left;
- float y2 = (float) child.top + DrawableViewNode.NODE_HEIGHT / 2.0f;
- float cx1 = x1 + TreeView.BEZIER_FRACTION * DrawableViewNode.PARENT_CHILD_SPACING;
- float cy1 = y1;
- float cx2 = x2 - TreeView.BEZIER_FRACTION * DrawableViewNode.PARENT_CHILD_SPACING;
- float cy2 = y2;
- connectionPath.moveTo(x1, y1);
- connectionPath.cubicTo(cx1, cy1, cx2, cy2, x2, y2);
- }
- }
-
- private void doRedraw() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- redraw();
- }
- });
- }
-
- public void loadAllData() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (this) {
- mTree = mModel.getTree();
- mSelectedNode = mModel.getSelection();
- mViewport = mModel.getViewport();
- setBounds();
- setTransform();
- }
- }
- });
- }
-
- // Note the syncExec and then synchronized... It avoids deadlock
- @Override
- public void treeChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (this) {
- mTree = mModel.getTree();
- mSelectedNode = mModel.getSelection();
- mViewport = mModel.getViewport();
- setBounds();
- setTransform();
- }
- }
- });
- doRedraw();
- }
-
- private void setBounds() {
- if (mViewport != null && mTree != null) {
- mBounds.x = Math.min(mViewport.x, mTree.bounds.x);
- mBounds.y = Math.min(mViewport.y, mTree.bounds.y);
- mBounds.width =
- Math.max(mViewport.x + mViewport.width, mTree.bounds.x + mTree.bounds.width)
- - mBounds.x;
- mBounds.height =
- Math.max(mViewport.y + mViewport.height, mTree.bounds.y + mTree.bounds.height)
- - mBounds.y;
- } else if (mTree != null) {
- mBounds.x = mTree.bounds.x;
- mBounds.y = mTree.bounds.y;
- mBounds.width = mTree.bounds.x + mTree.bounds.width - mBounds.x;
- mBounds.height = mTree.bounds.y + mTree.bounds.height - mBounds.y;
- }
- }
-
- private void setTransform() {
- if (mTree != null) {
-
- mTransform.identity();
- mInverse.identity();
- final Point size = new Point();
- size.x = getBounds().width;
- size.y = getBounds().height;
- if (mBounds.width == 0 || mBounds.height == 0 || size.x == 0 || size.y == 0) {
- mScale = 1;
- } else {
- mScale = Math.min(size.x / mBounds.width, size.y / mBounds.height);
- }
- mTransform.scale((float) mScale, (float) mScale);
- mInverse.scale((float) mScale, (float) mScale);
- mTransform.translate((float) -mBounds.x, (float) -mBounds.y);
- mInverse.translate((float) -mBounds.x, (float) -mBounds.y);
- if (size.x / mBounds.width < size.y / mBounds.height) {
- mTransform.translate(0, (float) (size.y / mScale - mBounds.height) / 2);
- mInverse.translate(0, (float) (size.y / mScale - mBounds.height) / 2);
- } else {
- mTransform.translate((float) (size.x / mScale - mBounds.width) / 2, 0);
- mInverse.translate((float) (size.x / mScale - mBounds.width) / 2, 0);
- }
- mInverse.invert();
- }
- }
-
- @Override
- public void viewportChanged() {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- synchronized (this) {
- mViewport = mModel.getViewport();
- setBounds();
- setTransform();
- }
- }
- });
- doRedraw();
- }
-
- @Override
- public void zoomChanged() {
- viewportChanged();
- }
-
- @Override
- public void selectionChanged() {
- synchronized (this) {
- mSelectedNode = mModel.getSelection();
- }
- doRedraw();
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/util/DrawableViewNode.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/util/DrawableViewNode.java
deleted file mode 100644
index 3c3b718..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/util/DrawableViewNode.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui.util;
-
-import com.android.hierarchyviewerlib.models.ViewNode;
-
-import java.util.ArrayList;
-
-public class DrawableViewNode {
- public ViewNode viewNode;
-
- public final ArrayList<DrawableViewNode> children = new ArrayList<DrawableViewNode>();
-
- public final static int NODE_HEIGHT = 100;
-
- public final static int NODE_WIDTH = 180;
-
- public final static int CONTENT_LEFT_RIGHT_PADDING = 9;
-
- public final static int CONTENT_TOP_BOTTOM_PADDING = 8;
-
- public final static int CONTENT_INTER_PADDING = 3;
-
- public final static int INDEX_PADDING = 7;
-
- public final static int LEAF_NODE_SPACING = 9;
-
- public final static int NON_LEAF_NODE_SPACING = 15;
-
- public final static int PARENT_CHILD_SPACING = 50;
-
- public final static int PADDING = 30;
-
- public int treeHeight;
-
- public int treeWidth;
-
- public boolean leaf;
-
- public DrawableViewNode parent;
-
- public int left;
-
- public double top;
-
- public int topSpacing;
-
- public int bottomSpacing;
-
- public boolean treeDrawn;
-
- public static class Rectangle {
- public double x, y, width, height;
-
- public Rectangle() {
-
- }
-
- public Rectangle(Rectangle other) {
- this.x = other.x;
- this.y = other.y;
- this.width = other.width;
- this.height = other.height;
- }
-
- public Rectangle(double x, double y, double width, double height) {
- this.x = x;
- this.y = y;
- this.width = width;
- this.height = height;
- }
-
- @Override
- public String toString() {
- return "{" + x + ", " + y + ", " + width + ", " + height + "}"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- }
-
- }
-
- public static class Point {
- public double x, y;
-
- public Point() {
- }
-
- public Point(double x, double y) {
- this.x = x;
- this.y = y;
- }
-
- @Override
- public String toString() {
- return "(" + x + ", " + y + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
-
- public Rectangle bounds = new Rectangle();
-
- public DrawableViewNode(ViewNode viewNode) {
- this.viewNode = viewNode;
- treeDrawn = !viewNode.willNotDraw;
- if (viewNode.children.size() == 0) {
- treeHeight = NODE_HEIGHT;
- treeWidth = NODE_WIDTH;
- leaf = true;
- } else {
- leaf = false;
- int N = viewNode.children.size();
- treeHeight = 0;
- treeWidth = 0;
- for (int i = 0; i < N; i++) {
- DrawableViewNode child = new DrawableViewNode(viewNode.children.get(i));
- children.add(child);
- child.parent = this;
- treeHeight += child.treeHeight;
- treeWidth = Math.max(treeWidth, child.treeWidth);
- if (i != 0) {
- DrawableViewNode prevChild = children.get(i - 1);
- if (prevChild.leaf && child.leaf) {
- treeHeight += LEAF_NODE_SPACING;
- prevChild.bottomSpacing = LEAF_NODE_SPACING;
- child.topSpacing = LEAF_NODE_SPACING;
- } else {
- treeHeight += NON_LEAF_NODE_SPACING;
- prevChild.bottomSpacing = NON_LEAF_NODE_SPACING;
- child.topSpacing = NON_LEAF_NODE_SPACING;
- }
- }
- treeDrawn |= child.treeDrawn;
- }
- treeWidth += NODE_WIDTH + PARENT_CHILD_SPACING;
- }
- }
-
- public void setLeft() {
- if (parent == null) {
- left = PADDING;
- bounds.x = 0;
- bounds.width = treeWidth + 2 * PADDING;
- } else {
- left = parent.left + NODE_WIDTH + PARENT_CHILD_SPACING;
- }
- int N = children.size();
- for (int i = 0; i < N; i++) {
- children.get(i).setLeft();
- }
- }
-
- public void placeRoot() {
- top = PADDING + (treeHeight - NODE_HEIGHT) / 2.0;
- double currentTop = PADDING;
- int N = children.size();
- for (int i = 0; i < N; i++) {
- DrawableViewNode child = children.get(i);
- child.place(currentTop, top - currentTop);
- currentTop += child.treeHeight + child.bottomSpacing;
- }
- bounds.y = 0;
- bounds.height = treeHeight + 2 * PADDING;
- }
-
- private void place(double treeTop, double rootDistance) {
- if (treeHeight <= rootDistance) {
- top = treeTop + treeHeight - NODE_HEIGHT;
- } else if (rootDistance <= -NODE_HEIGHT) {
- top = treeTop;
- } else {
- if (children.size() == 0) {
- top = treeTop;
- } else {
- top =
- rootDistance + treeTop - NODE_HEIGHT + (2.0 * NODE_HEIGHT)
- / (treeHeight + NODE_HEIGHT) * (treeHeight - rootDistance);
- }
- }
- int N = children.size();
- double currentTop = treeTop;
- for (int i = 0; i < N; i++) {
- DrawableViewNode child = children.get(i);
- child.place(currentTop, rootDistance);
- currentTop += child.treeHeight + child.bottomSpacing;
- rootDistance -= child.treeHeight + child.bottomSpacing;
- }
- }
-
- public DrawableViewNode getSelected(double x, double y) {
- if (x >= left && x < left + NODE_WIDTH && y >= top && y <= top + NODE_HEIGHT) {
- return this;
- }
- int N = children.size();
- for (int i = 0; i < N; i++) {
- DrawableViewNode selected = children.get(i).getSelected(x, y);
- if (selected != null) {
- return selected;
- }
- }
- return null;
- }
-
- /*
- * Moves the node the specified distance up.
- */
- public void move(double distance) {
- top -= distance;
-
- // Get the root
- DrawableViewNode root = this;
- while (root.parent != null) {
- root = root.parent;
- }
-
- // Figure out the new tree top.
- double treeTop;
- if (top + NODE_HEIGHT <= root.top) {
- treeTop = top + NODE_HEIGHT - treeHeight;
- } else if (top >= root.top + NODE_HEIGHT) {
- treeTop = top;
- } else {
- if (leaf) {
- treeTop = top;
- } else {
- double distanceRatio = 1 - (root.top + NODE_HEIGHT - top) / (2.0 * NODE_HEIGHT);
- treeTop = root.top - treeHeight + distanceRatio * (treeHeight + NODE_HEIGHT);
- }
- }
- // Go up the tree and figure out the tree top.
- DrawableViewNode node = this;
- while (node.parent != null) {
- int index = node.viewNode.index;
- for (int i = 0; i < index; i++) {
- DrawableViewNode sibling = node.parent.children.get(i);
- treeTop -= sibling.treeHeight + sibling.bottomSpacing;
- }
- node = node.parent;
- }
-
- // Update the bounds.
- root.bounds.y = Math.min(root.top - PADDING, treeTop - PADDING);
- root.bounds.height =
- Math.max(treeTop + root.treeHeight + PADDING, root.top + NODE_HEIGHT + PADDING)
- - root.bounds.y;
- // Place all the children of the root
- double currentTop = treeTop;
- int N = root.children.size();
- for (int i = 0; i < N; i++) {
- DrawableViewNode child = root.children.get(i);
- child.place(currentTop, root.top - currentTop);
- currentTop += child.treeHeight + child.bottomSpacing;
- }
-
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/util/PsdFile.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/util/PsdFile.java
deleted file mode 100644
index 2c1154b..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/util/PsdFile.java
+++ /dev/null
@@ -1,508 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui.util;
-
-import java.awt.Graphics2D;
-import java.awt.Point;
-import java.awt.image.BufferedImage;
-import java.io.BufferedOutputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * Writes PSD file. Supports only 8 bits, RGB images with 4 channels.
- */
-public class PsdFile {
- private final Header mHeader;
-
- private final ColorMode mColorMode;
-
- private final ImageResources mImageResources;
-
- private final LayersMasksInfo mLayersMasksInfo;
-
- private final LayersInfo mLayersInfo;
-
- private final BufferedImage mMergedImage;
-
- private final Graphics2D mGraphics;
-
- public PsdFile(int width, int height) {
- mHeader = new Header(width, height);
- mColorMode = new ColorMode();
- mImageResources = new ImageResources();
- mLayersMasksInfo = new LayersMasksInfo();
- mLayersInfo = new LayersInfo();
-
- mMergedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
- mGraphics = mMergedImage.createGraphics();
- }
-
- public void addLayer(String name, BufferedImage image, Point offset) {
- addLayer(name, image, offset, true);
- }
-
- public void addLayer(String name, BufferedImage image, Point offset, boolean visible) {
- mLayersInfo.addLayer(name, image, offset, visible);
- if (visible)
- mGraphics.drawImage(image, null, offset.x, offset.y);
- }
-
- public void write(OutputStream stream) {
- mLayersMasksInfo.setLayersInfo(mLayersInfo);
-
- DataOutputStream out = new DataOutputStream(new BufferedOutputStream(stream));
- try {
- mHeader.write(out);
- out.flush();
-
- mColorMode.write(out);
- mImageResources.write(out);
- mLayersMasksInfo.write(out);
- mLayersInfo.write(out);
- out.flush();
-
- mLayersInfo.writeImageData(out);
- out.flush();
-
- writeImage(mMergedImage, out, false);
- out.flush();
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- out.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }
-
- private static void writeImage(BufferedImage image, DataOutputStream out, boolean split)
- throws IOException {
-
- if (!split)
- out.writeShort(0);
-
- int width = image.getWidth();
- int height = image.getHeight();
-
- final int length = width * height;
- int[] pixels = new int[length];
-
- image.getData().getDataElements(0, 0, width, height, pixels);
-
- byte[] a = new byte[length];
- byte[] r = new byte[length];
- byte[] g = new byte[length];
- byte[] b = new byte[length];
-
- for (int i = 0; i < length; i++) {
- final int pixel = pixels[i];
- a[i] = (byte) ((pixel >> 24) & 0xFF);
- r[i] = (byte) ((pixel >> 16) & 0xFF);
- g[i] = (byte) ((pixel >> 8) & 0xFF);
- b[i] = (byte) (pixel & 0xFF);
- }
-
- if (split)
- out.writeShort(0);
- if (split)
- out.write(a);
- if (split)
- out.writeShort(0);
- out.write(r);
- if (split)
- out.writeShort(0);
- out.write(g);
- if (split)
- out.writeShort(0);
- out.write(b);
- if (!split)
- out.write(a);
- }
-
- @SuppressWarnings( {
- "UnusedDeclaration"
- })
- static class Header {
- static final short MODE_BITMAP = 0;
-
- static final short MODE_GRAYSCALE = 1;
-
- static final short MODE_INDEXED = 2;
-
- static final short MODE_RGB = 3;
-
- static final short MODE_CMYK = 4;
-
- static final short MODE_MULTI_CHANNEL = 7;
-
- static final short MODE_DUOTONE = 8;
-
- static final short MODE_LAB = 9;
-
- final byte[] mSignature = "8BPS".getBytes(); //$NON-NLS-1$
-
- final short mVersion = 1;
-
- final byte[] mReserved = new byte[6];
-
- final short mChannelCount = 4;
-
- final int mHeight;
-
- final int mWidth;
-
- final short mDepth = 8;
-
- final short mMode = MODE_RGB;
-
- Header(int width, int height) {
- mWidth = width;
- mHeight = height;
- }
-
- void write(DataOutputStream out) throws IOException {
- out.write(mSignature);
- out.writeShort(mVersion);
- out.write(mReserved);
- out.writeShort(mChannelCount);
- out.writeInt(mHeight);
- out.writeInt(mWidth);
- out.writeShort(mDepth);
- out.writeShort(mMode);
- }
- }
-
- // Unused at the moment
- @SuppressWarnings( {
- "UnusedDeclaration"
- })
- static class ColorMode {
- final int mLength = 0;
-
- void write(DataOutputStream out) throws IOException {
- out.writeInt(mLength);
- }
- }
-
- // Unused at the moment
- @SuppressWarnings( {
- "UnusedDeclaration"
- })
- static class ImageResources {
- static final short RESOURCE_RESOLUTION_INFO = 0x03ED;
-
- int mLength = 0;
-
- final byte[] mSignature = "8BIM".getBytes(); //$NON-NLS-1$
-
- final short mResourceId = RESOURCE_RESOLUTION_INFO;
-
- final short mPad = 0;
-
- final int mDataLength = 16;
-
- final short mHorizontalDisplayUnit = 0x48; // 72 dpi
-
- final int mHorizontalResolution = 1;
-
- final short mWidthDisplayUnit = 1;
-
- final short mVerticalDisplayUnit = 0x48; // 72 dpi
-
- final int mVerticalResolution = 1;
-
- final short mHeightDisplayUnit = 1;
-
- ImageResources() {
- mLength = mSignature.length;
- mLength += 2;
- mLength += 2;
- mLength += 4;
- mLength += 8;
- mLength += 8;
- }
-
- void write(DataOutputStream out) throws IOException {
- out.writeInt(mLength);
- out.write(mSignature);
- out.writeShort(mResourceId);
- out.writeShort(mPad);
- out.writeInt(mDataLength);
- out.writeShort(mHorizontalDisplayUnit);
- out.writeInt(mHorizontalResolution);
- out.writeShort(mWidthDisplayUnit);
- out.writeShort(mVerticalDisplayUnit);
- out.writeInt(mVerticalResolution);
- out.writeShort(mHeightDisplayUnit);
- }
- }
-
- @SuppressWarnings( {
- "UnusedDeclaration"
- })
- static class LayersMasksInfo {
- int mMiscLength;
-
- int mLayerInfoLength;
-
- void setLayersInfo(LayersInfo layersInfo) {
- mLayerInfoLength = layersInfo.getLength();
- // Round to the next multiple of 2
- if ((mLayerInfoLength & 0x1) == 0x1)
- mLayerInfoLength++;
- mMiscLength = mLayerInfoLength + 8;
- }
-
- void write(DataOutputStream out) throws IOException {
- out.writeInt(mMiscLength);
- out.writeInt(mLayerInfoLength);
- }
- }
-
- @SuppressWarnings( {
- "UnusedDeclaration"
- })
- static class LayersInfo {
- final List<Layer> mLayers = new ArrayList<Layer>();
-
- void addLayer(String name, BufferedImage image, Point offset, boolean visible) {
- mLayers.add(new Layer(name, image, offset, visible));
- }
-
- int getLength() {
- int length = 2;
- for (Layer layer : mLayers) {
- length += layer.getLength();
- }
- return length;
- }
-
- void write(DataOutputStream out) throws IOException {
- out.writeShort((short) -mLayers.size());
- for (Layer layer : mLayers) {
- layer.write(out);
- }
- }
-
- void writeImageData(DataOutputStream out) throws IOException {
- for (Layer layer : mLayers) {
- layer.writeImageData(out);
- }
- // Global layer mask info length
- out.writeInt(0);
- }
- }
-
- @SuppressWarnings( {
- "UnusedDeclaration"
- })
- static class Layer {
- static final byte OPACITY_TRANSPARENT = 0x0;
-
- static final byte OPACITY_OPAQUE = (byte) 0xFF;
-
- static final byte CLIPPING_BASE = 0x0;
-
- static final byte CLIPPING_NON_BASE = 0x1;
-
- static final byte FLAG_TRANSPARENCY_PROTECTED = 0x1;
-
- static final byte FLAG_INVISIBLE = 0x2;
-
- final int mTop;
-
- final int mLeft;
-
- final int mBottom;
-
- final int mRight;
-
- final short mChannelCount = 4;
-
- final Channel[] mChannelInfo = new Channel[mChannelCount];
-
- final byte[] mBlendSignature = "8BIM".getBytes(); //$NON-NLS-1$
-
- final byte[] mBlendMode = "norm".getBytes(); //$NON-NLS-1$
-
- final byte mOpacity = OPACITY_OPAQUE;
-
- final byte mClipping = CLIPPING_BASE;
-
- byte mFlags = 0x0;
-
- final byte mFiller = 0x0;
-
- int mExtraSize = 4 + 4;
-
- final int mMaskDataLength = 0;
-
- final int mBlendRangeDataLength = 0;
-
- final byte[] mName;
-
- final byte[] mLayerExtraSignature = "8BIM".getBytes(); //$NON-NLS-1$
-
- final byte[] mLayerExtraKey = "luni".getBytes(); //$NON-NLS-1$
-
- int mLayerExtraLength;
-
- final String mOriginalName;
-
- private BufferedImage mImage;
-
- Layer(String name, BufferedImage image, Point offset, boolean visible) {
- final int height = image.getHeight();
- final int width = image.getWidth();
- final int length = width * height;
-
- mChannelInfo[0] = new Channel(Channel.ID_ALPHA, length);
- mChannelInfo[1] = new Channel(Channel.ID_RED, length);
- mChannelInfo[2] = new Channel(Channel.ID_GREEN, length);
- mChannelInfo[3] = new Channel(Channel.ID_BLUE, length);
-
- mTop = offset.y;
- mLeft = offset.x;
- mBottom = offset.y + height;
- mRight = offset.x + width;
-
- mOriginalName = name;
- byte[] data = name.getBytes();
-
- try {
- mLayerExtraLength = 4 + mOriginalName.getBytes("UTF-16").length; //$NON-NLS-1$
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
-
- final byte[] nameData = new byte[data.length + 1];
- nameData[0] = (byte) (data.length & 0xFF);
- System.arraycopy(data, 0, nameData, 1, data.length);
-
- // This could be done in the same pass as above
- if (nameData.length % 4 != 0) {
- data = new byte[nameData.length + 4 - (nameData.length % 4)];
- System.arraycopy(nameData, 0, data, 0, nameData.length);
- mName = data;
- } else {
- mName = nameData;
- }
- mExtraSize += mName.length;
- mExtraSize +=
- mLayerExtraLength + 4 + mLayerExtraKey.length + mLayerExtraSignature.length;
-
- mImage = image;
-
- if (!visible) {
- mFlags |= FLAG_INVISIBLE;
- }
- }
-
- int getLength() {
- int length = 4 * 4 + 2;
-
- for (Channel channel : mChannelInfo) {
- length += channel.getLength();
- }
-
- length += mBlendSignature.length;
- length += mBlendMode.length;
- length += 4;
- length += 4;
- length += mExtraSize;
-
- return length;
- }
-
- void write(DataOutputStream out) throws IOException {
- out.writeInt(mTop);
- out.writeInt(mLeft);
- out.writeInt(mBottom);
- out.writeInt(mRight);
-
- out.writeShort(mChannelCount);
- for (Channel channel : mChannelInfo) {
- channel.write(out);
- }
-
- out.write(mBlendSignature);
- out.write(mBlendMode);
-
- out.write(mOpacity);
- out.write(mClipping);
- out.write(mFlags);
- out.write(mFiller);
-
- out.writeInt(mExtraSize);
- out.writeInt(mMaskDataLength);
-
- out.writeInt(mBlendRangeDataLength);
-
- out.write(mName);
-
- out.write(mLayerExtraSignature);
- out.write(mLayerExtraKey);
- out.writeInt(mLayerExtraLength);
- out.writeInt(mOriginalName.length() + 1);
- out.write(mOriginalName.getBytes("UTF-16")); //$NON-NLS-1$
- }
-
- void writeImageData(DataOutputStream out) throws IOException {
- writeImage(mImage, out, true);
- }
- }
-
- @SuppressWarnings( {
- "UnusedDeclaration"
- })
- static class Channel {
- static final short ID_RED = 0;
-
- static final short ID_GREEN = 1;
-
- static final short ID_BLUE = 2;
-
- static final short ID_ALPHA = -1;
-
- static final short ID_LAYER_MASK = -2;
-
- final short mId;
-
- final int mDataLength;
-
- Channel(short id, int dataLength) {
- mId = id;
- mDataLength = dataLength + 2;
- }
-
- int getLength() {
- return 2 + 4 + mDataLength;
- }
-
- void write(DataOutputStream out) throws IOException {
- out.writeShort(mId);
- out.writeInt(mDataLength);
- }
- }
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/util/TreeColumnResizer.java b/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/util/TreeColumnResizer.java
deleted file mode 100644
index 1213620..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/com/android/hierarchyviewerlib/ui/util/TreeColumnResizer.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.hierarchyviewerlib.ui.util;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.TreeColumn;
-
-public class TreeColumnResizer {
-
- private TreeColumn mColumn1;
-
- private TreeColumn mColumn2;
-
- private Composite mControl;
-
- private int mColumn1Width;
-
- private int mColumn2Width;
-
- private final static int MIN_COLUMN1_WIDTH = 18;
-
- private final static int MIN_COLUMN2_WIDTH = 3;
-
- public TreeColumnResizer(Composite control, TreeColumn column1, TreeColumn column2) {
- this.mControl = control;
- this.mColumn1 = column1;
- this.mColumn2 = column2;
- control.addListener(SWT.Resize, resizeListener);
- column1.addListener(SWT.Resize, column1ResizeListener);
- column2.setResizable(false);
- }
-
- private Listener resizeListener = new Listener() {
- @Override
- public void handleEvent(Event e) {
- if (mColumn1Width == 0 && mColumn2Width == 0) {
- mColumn1Width = (mControl.getBounds().width - 18) / 2;
- mColumn2Width = (mControl.getBounds().width - 18) / 2;
- } else {
- int dif = mControl.getBounds().width - 18 - (mColumn1Width + mColumn2Width);
- int columnDif = Math.abs(mColumn1Width - mColumn2Width);
- int mainColumnChange = Math.min(Math.abs(dif), columnDif);
- int left = Math.max(0, Math.abs(dif) - columnDif);
- if (dif < 0) {
- if (mColumn1Width > mColumn2Width) {
- mColumn1Width -= mainColumnChange;
- } else {
- mColumn2Width -= mainColumnChange;
- }
- mColumn1Width -= left / 2;
- mColumn2Width -= left - left / 2;
- } else {
- if (mColumn1Width > mColumn2Width) {
- mColumn2Width += mainColumnChange;
- } else {
- mColumn1Width += mainColumnChange;
- }
- mColumn1Width += left / 2;
- mColumn2Width += left - left / 2;
- }
- }
- mColumn1.removeListener(SWT.Resize, column1ResizeListener);
- mColumn1.setWidth(mColumn1Width);
- mColumn2.setWidth(mColumn2Width);
- mColumn1.addListener(SWT.Resize, column1ResizeListener);
- }
- };
-
- private Listener column1ResizeListener = new Listener() {
- @Override
- public void handleEvent(Event e) {
- int widthDif = mColumn1Width - mColumn1.getWidth();
- mColumn1Width -= widthDif;
- mColumn2Width += widthDif;
- boolean column1Changed = false;
-
- // Strange, but these constants make the columns look the same.
-
- if (mColumn1Width < MIN_COLUMN1_WIDTH) {
- mColumn2Width -= MIN_COLUMN1_WIDTH - mColumn1Width;
- mColumn1Width += MIN_COLUMN1_WIDTH - mColumn1Width;
- column1Changed = true;
- }
- if (mColumn2Width < MIN_COLUMN2_WIDTH) {
- mColumn1Width += mColumn2Width - MIN_COLUMN2_WIDTH;
- mColumn2Width = MIN_COLUMN2_WIDTH;
- column1Changed = true;
- }
- if (column1Changed) {
- mColumn1.removeListener(SWT.Resize, this);
- mColumn1.setWidth(mColumn1Width);
- mColumn1.addListener(SWT.Resize, this);
- }
- mColumn2.setWidth(mColumn2Width);
- }
- };
-}
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/auto-refresh.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/auto-refresh.png
deleted file mode 100644
index 240862f..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/auto-refresh.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/capture-psd.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/capture-psd.png
deleted file mode 100644
index 0f25426..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/capture-psd.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/device-view-selected.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/device-view-selected.png
deleted file mode 100644
index fd107ed..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/device-view-selected.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/device-view.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/device-view.png
deleted file mode 100644
index 9a7eed4..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/device-view.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/display.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/display.png
deleted file mode 100644
index a9de0ec..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/display.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/filtered.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/filtered.png
deleted file mode 100644
index 4fcab3f..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/filtered.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/green.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/green.png
deleted file mode 100644
index 800000d..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/green.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/inspect-screenshot.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/inspect-screenshot.png
deleted file mode 100644
index 6e51701..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/inspect-screenshot.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/invalidate.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/invalidate.png
deleted file mode 100644
index ee75f69..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/invalidate.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/load-all-views.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/load-all-views.png
deleted file mode 100644
index 3329ec9..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/load-all-views.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/load-overlay.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/load-overlay.png
deleted file mode 100644
index 4817252..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/load-overlay.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/load-view-hierarchy.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/load-view-hierarchy.png
deleted file mode 100644
index 8f01dda..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/load-view-hierarchy.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/not-selected.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/not-selected.png
deleted file mode 100644
index db6f13b..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/not-selected.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/on-black.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/on-black.png
deleted file mode 100644
index cd88803..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/on-black.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/on-white.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/on-white.png
deleted file mode 100644
index 5f05662..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/on-white.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/picker.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/picker.png
deleted file mode 100644
index 8ea2bed..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/picker.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/pixel-perfect-view-selected.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/pixel-perfect-view-selected.png
deleted file mode 100644
index 1e44000..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/pixel-perfect-view-selected.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/pixel-perfect-view.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/pixel-perfect-view.png
deleted file mode 100644
index ec51cec..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/pixel-perfect-view.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/profile.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/profile.png
deleted file mode 100644
index 1e9fb5a..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/profile.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/red.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/red.png
deleted file mode 100644
index a2ab855..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/red.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/refresh-windows.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/refresh-windows.png
deleted file mode 100644
index 8fddcae..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/refresh-windows.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/request-layout.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/request-layout.png
deleted file mode 100644
index 92a78c8..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/request-layout.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/save.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/save.png
deleted file mode 100644
index 2c0bab1..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/save.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/sdk-hierarchyviewer-128.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/sdk-hierarchyviewer-128.png
deleted file mode 100644
index 4535f22..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/sdk-hierarchyviewer-128.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/sdk-hierarchyviewer-16.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/sdk-hierarchyviewer-16.png
deleted file mode 100755
index 8c3c23d..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/sdk-hierarchyviewer-16.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected-filtered-small.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected-filtered-small.png
deleted file mode 100644
index 9ef6b34..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected-filtered-small.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected-filtered.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected-filtered.png
deleted file mode 100644
index 1f59685..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected-filtered.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected-small.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected-small.png
deleted file mode 100644
index 538e385..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected-small.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected.png
deleted file mode 100644
index 5cd5c3f..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/selected.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/show-extras.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/show-extras.png
deleted file mode 100644
index ba9c305..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/show-extras.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/show-overlay.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/show-overlay.png
deleted file mode 100644
index e39e90a..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/show-overlay.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/tree-view-selected.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/tree-view-selected.png
deleted file mode 100644
index 175ad1f..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/tree-view-selected.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/tree-view.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/tree-view.png
deleted file mode 100644
index 23aa424..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/tree-view.png
+++ /dev/null
Binary files differ
diff --git a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/yellow.png b/hierarchyviewer2/libs/hierarchyviewerlib/src/images/yellow.png
deleted file mode 100644
index e9b5781..0000000
--- a/hierarchyviewer2/libs/hierarchyviewerlib/src/images/yellow.png
+++ /dev/null
Binary files differ
diff --git a/jobb/Android.mk b/jobb/Android.mk
deleted file mode 100644
index 2750830..0000000
--- a/jobb/Android.mk
+++ /dev/null
@@ -1,29 +0,0 @@
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# The jobb code has moved to tools/base/jobb.
-# The rule below uses the prebuilt jobb.jar if found.
-
-LOCAL_MODULE := jobb
-LOCAL_MODULE_TAGS := debug
-LOCAL_JAVA_LIBRARIES := fat32lib
-
-LOCAL_PREBUILT_JAVA_LIBRARIES := \
- ../../prebuilts/devtools/tools/lib/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/jobb/NOTICE b/jobb/NOTICE
deleted file mode 100644
index 93baeb5..0000000
--- a/jobb/NOTICE
+++ /dev/null
@@ -1,50 +0,0 @@
-Portions of this code:
--------------------------------------------------------------------------------
-Copyright (c) 2000 The Legion Of The Bouncy Castle
-(http://www.bouncycastle.org)
-
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the "Software")
-to deal in the Software without restriction, including without limitation
-the rights to use, copy, modify, merge, publish, distribute, sublicense
-and/or sell copies of the Software, and to permit persons to whom the Software
-is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
--------------------------------------------------------------------------------
-Twofish is uncopyrighted and license-free, and was created and analyzed by:
-Bruce Schneier - John Kelsey - Doug Whiting
-David Wagner - Chris Hall - Niels Ferguson
--------------------------------------------------------------------------------
-Cryptix General License
-
-Copyright (c) 1995-2005 The Cryptix Foundation Limited.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
- 1. Redistributions of source code must retain the copyright notice,
- this list of conditions and the following disclaimer.
- 2. Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
--------------------------------------------------------------------------------
-All other code is:
-
-Copyright (C) 2012 The Android Open Source Project
-
-Licensed under the Apache License, Version 2.0 (the "License");
-you may not use this file except in compliance with the License.
-You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
-Unless required by applicable law or agreed to in writing, software
-distributed under the License is distributed on an "AS IS" BASIS,
-WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-See the License for the specific language governing permissions and
-limitations under the License.
-
diff --git a/layoutlib_api/.classpath b/layoutlib_api/.classpath
deleted file mode 100644
index d7c9d12..0000000
--- a/layoutlib_api/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/misc/common/kxml2/kxml2-2.3.0.jar" sourcepath="/ANDROID_SRC/dalvik/libcore/xml/src/main/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/layoutlib_api/.gitignore b/layoutlib_api/.gitignore
deleted file mode 100644
index 4ff597c..0000000
--- a/layoutlib_api/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-bin
-build
-
diff --git a/layoutlib_api/.project b/layoutlib_api/.project
deleted file mode 100644
index 4e4ca3b..0000000
--- a/layoutlib_api/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>layoutlib_api</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/layoutlib_api/.settings/org.eclipse.jdt.core.prefs b/layoutlib_api/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/layoutlib_api/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/layoutlib_api/Android.mk b/layoutlib_api/Android.mk
deleted file mode 100644
index e03b7dc..0000000
--- a/layoutlib_api/Android.mk
+++ /dev/null
@@ -1,35 +0,0 @@
-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# The layoutlib_api code has moved to tools/base/layoutlib_api.
-# The rule below uses the prebuilt layoutlib_api.jar.
-#
-# If you want to run the tests, cd to tools/base/layoutlib_api
-# and run ./gradlew :layoutlib_api:test
-
-LOCAL_JAVA_LIBRARIES := \
- common \
- kxml2-2.3.0
-
-LOCAL_MODULE := layoutlib_api
-
-LOCAL_PREBUILT_JAVA_LIBRARIES := \
- ../../prebuilts/devtools/tools/lib/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/layoutlib_api/NOTICE b/layoutlib_api/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/layoutlib_api/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/layoutlib_api/README.txt b/layoutlib_api/README.txt
deleted file mode 100644
index 487a1a2..0000000
--- a/layoutlib_api/README.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-LayoutLib API is a jar describing the API used to load and interact with layoutlib.jar
-It is to be packaged with clients accessing layoutlib.jar
-
-Layoutlib.jar is built from frameworks/base.git and therefore is versioned with the platform.
-
-IMPORTANT NOTE REGARDING CHANGES IN LAYOUTLIB_API:
-
-- The API must stay compatible. This is because while layoutlib.jar compiles against it,
- the client provides the implementation and must be able to load earlier versions of layoutlib.jar.
- This is true for all the classes under com.android.ide.common.rendering.api and
- com.android.layoutlib.api although the latter is obsolete and should not be changed at all.
-
-- Updated version of layoutlib_api should be copied to the current in-dev branch of
- prebuilt/common/layoutlib_api/layoutlib_api-prebuilt.jar
- The PREBUILT file in the same folder must be updated as well to reflect how to rebuild this
- prebuilt jar file. \ No newline at end of file
diff --git a/layoutlib_api/sample/.classpath b/layoutlib_api/sample/.classpath
deleted file mode 100644
index 0f75c98..0000000
--- a/layoutlib_api/sample/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/misc/common/kxml2/kxml2-2.3.0.jar" sourcepath="/ANDROID_SRC/dalvik/libcore/xml/src/main/java"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry combineaccessrules="false" kind="src" path="/sdk_common"/>
- <classpathentry combineaccessrules="false" kind="src" path="/layoutlib_api"/>
- <classpathentry combineaccessrules="false" kind="src" path="/SdkLib"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/layoutlib_api/sample/.project b/layoutlib_api/sample/.project
deleted file mode 100644
index 1cc19f5..0000000
--- a/layoutlib_api/sample/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>layoutlib_sample</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/layoutlib_api/sample/README.txt b/layoutlib_api/sample/README.txt
deleted file mode 100644
index 84570a3..0000000
--- a/layoutlib_api/sample/README.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-Sample code to use the layout rendering library.
-
-This is very basic sample code showing how to render
-a layout.
-
-This explains how to load the resources, create Folderconfig,
-ResourceResolver, and how to call the LayoutLibrary to do an
-actual render.
-
-There are some big limitations:
-- can't render custom views because there's nothing
-compiling them and generating the compiled R.class
-file.
-- not all features of ADT are present because there
-are things that don't make sense outside of an editor
-(render in context, expand empty layouts, etc...) \ No newline at end of file
diff --git a/layoutlib_api/sample/src/com/example/android/render/Main.java b/layoutlib_api/sample/src/com/example/android/render/Main.java
deleted file mode 100644
index d33ab03..0000000
--- a/layoutlib_api/sample/src/com/example/android/render/Main.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.render;
-
-import com.android.ide.common.rendering.api.RenderSession;
-import com.android.ide.common.rendering.api.Result;
-import com.android.ide.common.rendering.api.ViewInfo;
-import com.android.ide.common.resources.ResourceItem;
-import com.android.ide.common.resources.ResourceRepository;
-import com.android.ide.common.resources.ResourceResolver;
-import com.android.ide.common.resources.configuration.FolderConfiguration;
-import com.android.io.FolderWrapper;
-import com.android.resources.Density;
-import com.android.resources.Keyboard;
-import com.android.resources.KeyboardState;
-import com.android.resources.Navigation;
-import com.android.resources.NavigationState;
-import com.android.resources.ScreenOrientation;
-import com.android.resources.ScreenRatio;
-import com.android.resources.ScreenSize;
-import com.android.resources.TouchScreen;
-
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.List;
-
-import javax.imageio.ImageIO;
-
-/**
- * Sample code showing how to use the different API used to achieve a layout rendering.
- * This requires the following jar: layoutlib_api.jar, common.jar, sdk_common.jar, sdklib.jar (altho
- * we should get rid of this one) and a full SDK (or at leas the platform component).
- *
- */
-public class Main {
-
- // path to the SDK and the project to render
- private final static String SDK = "...<insert>...";
- private final static String PROJECT = "...<insert>...";
-
- /**
- * @param args
- */
- public static void main(String[] args) {
- // load the factory for a given platform
- File f = new File(SDK + "/platforms/android-3.1");
- RenderServiceFactory factory = RenderServiceFactory.create(f);
-
- if (factory == null) {
- System.err.println("Failed to load platform rendering library");
- System.exit(1);
- }
-
- // load the project resources
- ResourceRepository projectRes = new ResourceRepository(false /*isFramework*/) {
-
- @Override
- protected ResourceItem createResourceItem(String name) {
- return new ResourceItem(name);
- }
- };
- try {
- projectRes.loadResources(new FolderWrapper(PROJECT + "/res"));
- } catch (IOException e) {
- e.printStackTrace();
- System.exit(1);
- }
-
- // create the rendering config
- FolderConfiguration config = RenderServiceFactory.createConfig(
- 1280, 800, // size 1 and 2. order doesn't matter.
- // Orientation will drive which is w and h
- ScreenSize.XLARGE,
- ScreenRatio.LONG,
- ScreenOrientation.LANDSCAPE,
- Density.MEDIUM,
- TouchScreen.FINGER,
- KeyboardState.SOFT,
- Keyboard.QWERTY,
- NavigationState.EXPOSED,
- Navigation.NONAV,
- 12); // api level
-
- // create the resource resolver once for the given config.
- ResourceResolver resources = factory.createResourceResolver(
- config, projectRes,
- "Theme", false /*isProjectTheme*/);
-
- // create the render service
- RenderService renderService = factory.createService(
- resources, config, new ProjectCallback());
-
- try {
- RenderSession session = renderService
- .setLog(new StdOutLogger())
- .setAppInfo("foo", "icon") // optional
- .createRenderSession("main" /*layoutName*/);
-
- // get the status of the render
- Result result = session.getResult();
- if (result.isSuccess() == false) {
- System.err.println(result.getErrorMessage());
- System.exit(1);
- }
-
- // get the image and save it somewhere.
- BufferedImage image = session.getImage();
- ImageIO.write(image, "png", new File("/path/to/test.png"));
-
- // read the views
- displayViewObjects(session.getRootViews());
-
- return;
- } catch (FileNotFoundException e) {
- e.printStackTrace();
- } catch (XmlPullParserException e) {
- e.printStackTrace();
- } catch (IOException e) {
- e.printStackTrace();
- }
-
- System.exit(1);
- }
-
- private static void displayViewObjects(List<ViewInfo> rootViews) {
- for (ViewInfo info : rootViews) {
- displayView(info, "");
- }
- }
-
- private static void displayView(ViewInfo info, String indent) {
- // display info data
- System.out.println(indent + info.getClassName() +
- " [" + info.getLeft() + ", " + info.getTop() + ", " +
- info.getRight() + ", " + info.getBottom() + "]");
-
- // display the children
- List<ViewInfo> children = info.getChildren();
- if (children != null) {
- indent += "\t";
- for (ViewInfo child : children) {
- displayView(child, indent);
- }
- }
- }
-}
diff --git a/layoutlib_api/sample/src/com/example/android/render/ProjectCallback.java b/layoutlib_api/sample/src/com/example/android/render/ProjectCallback.java
deleted file mode 100644
index 2e20f7c..0000000
--- a/layoutlib_api/sample/src/com/example/android/render/ProjectCallback.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.render;
-
-import com.android.ide.common.rendering.api.AdapterBinding;
-import com.android.ide.common.rendering.api.ILayoutPullParser;
-import com.android.ide.common.rendering.api.IProjectCallback;
-import com.android.ide.common.rendering.api.ResourceReference;
-import com.android.ide.common.rendering.api.ResourceValue;
-import com.android.resources.ResourceType;
-import com.android.util.Pair;
-
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * Simple implementation of {@link IProjectCallback}. This is a very basic implementation that
- * cannot support custom classes. Look for the one in ADT for custom class support.
- *
- * Because there's no custom view support, the int to resource name is all dynamic instad of
- * looking up in the R.java class that was compiled.
- *
- */
-public class ProjectCallback implements IProjectCallback {
-
- private Map<ResourceType, Map<String, Integer>> mIdMap =
- new HashMap<ResourceType, Map<String, Integer>>();
- private Map<Integer, Pair<ResourceType, String>> mReverseIdMap =
- new HashMap<Integer, Pair<ResourceType,String>>();
-
- public ProjectCallback() {
-
- }
-
- public AdapterBinding getAdapterBinding(ResourceReference adapterViewRef, Object adapterCookie,
- Object viewObject) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public Object getAdapterItemValue(ResourceReference adapterView, Object adapterCookie,
- ResourceReference itemRef, int fullPosition, int positionPerType,
- int fullParentPosition, int parentPositionPerType, ResourceReference viewRef,
- ViewAttribute viewAttribute, Object defaultValue) {
- // TODO Auto-generated method stub
- return null;
- }
-
- public String getNamespace() {
- // no custom class == no custom attribute, this is not needed.
- return null;
- }
-
- public ILayoutPullParser getParser(String layoutName) {
- // don't support custom parser for included files.
- return null;
- }
-
- public ILayoutPullParser getParser(ResourceValue layoutResource) {
- // don't support custom parser for included files.
- return null;
- }
-
- public Integer getResourceId(ResourceType type, String name) {
- // since we don't have access to compiled id, generate one on the fly.
- Map<String, Integer> typeMap = mIdMap.get(type);
- if (typeMap == null) {
- typeMap = new HashMap<String, Integer>();
- mIdMap.put(type, typeMap);
- }
-
- Integer value = typeMap.get(name);
- if (value == null) {
- value = typeMap.size() + 1;
- typeMap.put(name, value);
- mReverseIdMap.put(value, Pair.of(type, name));
- }
-
- return value;
- }
-
- @SuppressWarnings("unchecked")
- public Object loadView(String name, Class[] constructorSignature, Object[] constructorArgs)
- throws ClassNotFoundException, Exception {
- // don't support custom views.
- return null;
- }
-
- public Pair<ResourceType, String> resolveResourceId(int id) {
- return mReverseIdMap.get(id);
- }
-
- public String resolveResourceId(int[] id) {
- // this is needed only when custom views have custom styleable
- return null;
- }
-
-}
diff --git a/layoutlib_api/sample/src/com/example/android/render/RenderService.java b/layoutlib_api/sample/src/com/example/android/render/RenderService.java
deleted file mode 100644
index 33ed35f..0000000
--- a/layoutlib_api/sample/src/com/example/android/render/RenderService.java
+++ /dev/null
@@ -1,313 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.render;
-
-import com.android.ide.common.rendering.LayoutLibrary;
-import com.android.ide.common.rendering.api.DrawableParams;
-import com.android.ide.common.rendering.api.IImageFactory;
-import com.android.ide.common.rendering.api.ILayoutPullParser;
-import com.android.ide.common.rendering.api.IProjectCallback;
-import com.android.ide.common.rendering.api.LayoutLog;
-import com.android.ide.common.rendering.api.RenderSession;
-import com.android.ide.common.rendering.api.ResourceValue;
-import com.android.ide.common.rendering.api.Result;
-import com.android.ide.common.rendering.api.SessionParams;
-import com.android.ide.common.rendering.api.SessionParams.RenderingMode;
-import com.android.ide.common.resources.ResourceResolver;
-import com.android.ide.common.resources.configuration.FolderConfiguration;
-import com.android.resources.ResourceType;
-import com.android.resources.ScreenOrientation;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-
-
-/**
- * The {@link RenderService} provides rendering service and easy config.
- */
-public class RenderService {
-
- // The following fields are set through the constructor and are required.
-
- private final IProjectCallback mProjectCallback;
- private final ResourceResolver mResourceResolver;
- private final LayoutLibrary mLayoutLib;
- private final FolderConfiguration mConfig;
-
- // The following fields are optional or configurable using the various chained
- // setters:
-
- private int mWidth;
- private int mHeight;
- private int mMinSdkVersion = -1;
- private int mTargetSdkVersion = -1;
- private float mXdpi = -1;
- private float mYdpi = -1;
- private RenderingMode mRenderingMode = RenderingMode.NORMAL;
- private LayoutLog mLogger;
- private Integer mOverrideBgColor;
- private boolean mShowDecorations = true;
- private String mAppLabel;
- private String mAppIconName;
- private IImageFactory mImageFactory;
-
- /** Use the {@link RenderServiceFactory#create} factory instead */
- RenderService(LayoutLibrary layoutLibrary,
- ResourceResolver resources,
- FolderConfiguration config,
- IProjectCallback projectCallback) {
- mLayoutLib = layoutLibrary;
- mResourceResolver = resources;
- mConfig = config;
- mProjectCallback = projectCallback;
- }
-
- /**
- * Sets the {@link LayoutLog} to be used during rendering. If none is specified, a
- * silent logger will be used.
- *
- * @param logger the log to be used
- * @return this (such that chains of setters can be stringed together)
- */
- public RenderService setLog(LayoutLog logger) {
- mLogger = logger;
- return this;
- }
-
- /**
- * Sets the {@link RenderingMode} to be used during rendering. If none is specified,
- * the default is {@link RenderingMode#NORMAL}.
- *
- * @param renderingMode the rendering mode to be used
- * @return this (such that chains of setters can be stringed together)
- */
- public RenderService setRenderingMode(RenderingMode renderingMode) {
- mRenderingMode = renderingMode;
- return this;
- }
-
- /**
- * Sets the overriding background color to be used, if any. The color should be a
- * bitmask of AARRGGBB. The default is null.
- *
- * @param overrideBgColor the overriding background color to be used in the rendering,
- * in the form of a AARRGGBB bitmask, or null to use no custom background.
- * @return this (such that chains of setters can be stringed together)
- */
- public RenderService setOverrideBgColor(Integer overrideBgColor) {
- mOverrideBgColor = overrideBgColor;
- return this;
- }
-
- /**
- * Sets whether the rendering should include decorations such as a system bar, an
- * application bar etc depending on the SDK target and theme. The default is true.
- *
- * @param showDecorations true if the rendering should include system bars etc.
- * @return this (such that chains of setters can be stringed together)
- */
- public RenderService setDecorations(boolean showDecorations) {
- mShowDecorations = showDecorations;
- return this;
- }
-
- public RenderService setAppInfo(String label, String icon) {
- mAppLabel = label;
- mAppIconName = icon;
- return this;
- }
-
- public RenderService setMinSdkVersion(int minSdkVersion) {
- mMinSdkVersion = minSdkVersion;
- return this;
- }
-
- public RenderService setTargetSdkVersion(int targetSdkVersion) {
- mTargetSdkVersion = targetSdkVersion;
- return this;
- }
-
- public RenderService setExactDeviceDpi(float xdpi, float ydpi) {
- mXdpi = xdpi;
- mYdpi = ydpi;
- return this;
- }
-
- public RenderService setImageFactory(IImageFactory imageFactory) {
- mImageFactory = imageFactory;
- return this;
- }
-
- /** Initializes any remaining optional fields after all setters have been called */
- private void finishConfiguration() {
- if (mLogger == null) {
- // Silent logging
- mLogger = new LayoutLog();
- }
- }
-
- /**
- * Renders the model and returns the result as a {@link RenderSession}.
- * @return the {@link RenderSession} resulting from rendering the current model
- * @throws XmlPullParserException
- * @throws FileNotFoundException
- */
- public RenderSession createRenderSession(String layoutName) throws FileNotFoundException,
- XmlPullParserException {
- finishConfiguration();
-
- if (mResourceResolver == null) {
- // Abort the rendering if the resources are not found.
- return null;
- }
-
- // find the layout to run
- ResourceValue value = mResourceResolver.getProjectResource(ResourceType.LAYOUT, layoutName);
- if (value == null || value.getValue() == null) {
- throw new IllegalArgumentException("layout does not exist");
- }
-
- File layoutFile = new File(value.getValue());
-
- ILayoutPullParser parser = null;
- parser = new XmlParser();
- parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true);
- parser.setInput(new FileInputStream(layoutFile), "UTF-8"); //$NON-NLS-1$
-
- figureSomeValuesOut();
-
- SessionParams params = new SessionParams(
- parser,
- mRenderingMode,
- this /* projectKey */,
- mWidth, mHeight,
- mConfig.getDensityQualifier().getValue(),
- mXdpi, mYdpi,
- mResourceResolver,
- mProjectCallback,
- mMinSdkVersion,
- mTargetSdkVersion,
- mLogger);
-
- // Request margin and baseline information.
- // TODO: Be smarter about setting this; start without it, and on the first request
- // for an extended view info, re-render in the same session, and then set a flag
- // which will cause this to create extended view info each time from then on in the
- // same session
- params.setExtendedViewInfoMode(true);
-
- if (!mShowDecorations) {
- params.setForceNoDecor();
- } else {
- if (mAppLabel == null) {
- mAppLabel = "Random App";
- }
-
- params.setAppLabel(mAppLabel);
- params.setAppIcon(mAppIconName); // ok to be null
- }
-
- params.setConfigScreenSize(mConfig.getScreenSizeQualifier().getValue());
-
- if (mOverrideBgColor != null) {
- params.setOverrideBgColor(mOverrideBgColor.intValue());
- }
-
- // set the Image Overlay as the image factory.
- params.setImageFactory(mImageFactory);
-
- try {
- return mLayoutLib.createSession(params);
- } catch (RuntimeException t) {
- // Exceptions from the bridge
- mLogger.error(null, t.getLocalizedMessage(), t, null);
- throw t;
- }
- }
-
- private void figureSomeValuesOut() {
- int size1 = mConfig.getScreenDimensionQualifier().getValue1();
- int size2 = mConfig.getScreenDimensionQualifier().getValue2();
- ScreenOrientation orientation = mConfig.getScreenOrientationQualifier().getValue();
- switch (orientation) {
- case LANDSCAPE:
- mWidth = size1 < size2 ? size2 : size1;
- mHeight = size1 < size2 ? size1 : size2;
- break;
- case PORTRAIT:
- mWidth = size1 < size2 ? size1 : size2;
- mHeight = size1 < size2 ? size2 : size1;
- break;
- case SQUARE:
- mWidth = mHeight = size1;
- break;
- }
-
- if (mMinSdkVersion == -1) {
- mMinSdkVersion = mConfig.getVersionQualifier().getVersion();
- }
-
- if (mTargetSdkVersion == -1) {
- mTargetSdkVersion = mConfig.getVersionQualifier().getVersion();
- }
-
- if (mXdpi == -1) {
- mXdpi = mConfig.getDensityQualifier().getValue().getDpiValue();
- }
-
- if (mYdpi == -1) {
- mYdpi = mConfig.getDensityQualifier().getValue().getDpiValue();
- }
- }
-
- /**
- * Renders the given resource value (which should refer to a drawable) and returns it
- * as an image
- *
- * @param drawableResourceValue the drawable resource value to be rendered, or null
- * @return the image, or null if something went wrong
- */
- public BufferedImage renderDrawable(ResourceValue drawableResourceValue) {
- if (drawableResourceValue == null) {
- return null;
- }
-
- finishConfiguration();
-
- figureSomeValuesOut();
-
- DrawableParams params = new DrawableParams(drawableResourceValue, this, mWidth, mHeight,
- mConfig.getDensityQualifier().getValue(),
- mXdpi, mYdpi, mResourceResolver, mProjectCallback, mMinSdkVersion,
- mTargetSdkVersion, mLogger);
- params.setForceNoDecor();
- Result result = mLayoutLib.renderDrawable(params);
- if (result != null && result.isSuccess()) {
- Object data = result.getData();
- if (data instanceof BufferedImage) {
- return (BufferedImage) data;
- }
- }
-
- return null;
- }
-}
diff --git a/layoutlib_api/sample/src/com/example/android/render/RenderServiceFactory.java b/layoutlib_api/sample/src/com/example/android/render/RenderServiceFactory.java
deleted file mode 100644
index 0633b7d..0000000
--- a/layoutlib_api/sample/src/com/example/android/render/RenderServiceFactory.java
+++ /dev/null
@@ -1,337 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.render;
-
-import com.android.ide.common.log.ILogger;
-import com.android.ide.common.rendering.LayoutLibrary;
-import com.android.ide.common.rendering.api.AttrResourceValue;
-import com.android.ide.common.rendering.api.DeclareStyleableResourceValue;
-import com.android.ide.common.rendering.api.IProjectCallback;
-import com.android.ide.common.rendering.api.ResourceValue;
-import com.android.ide.common.resources.FrameworkResources;
-import com.android.ide.common.resources.ResourceRepository;
-import com.android.ide.common.resources.ResourceResolver;
-import com.android.ide.common.resources.configuration.DensityQualifier;
-import com.android.ide.common.resources.configuration.FolderConfiguration;
-import com.android.ide.common.resources.configuration.KeyboardStateQualifier;
-import com.android.ide.common.resources.configuration.NavigationMethodQualifier;
-import com.android.ide.common.resources.configuration.NavigationStateQualifier;
-import com.android.ide.common.resources.configuration.ScreenDimensionQualifier;
-import com.android.ide.common.resources.configuration.ScreenHeightQualifier;
-import com.android.ide.common.resources.configuration.ScreenOrientationQualifier;
-import com.android.ide.common.resources.configuration.ScreenRatioQualifier;
-import com.android.ide.common.resources.configuration.ScreenSizeQualifier;
-import com.android.ide.common.resources.configuration.ScreenWidthQualifier;
-import com.android.ide.common.resources.configuration.SmallestScreenWidthQualifier;
-import com.android.ide.common.resources.configuration.TextInputMethodQualifier;
-import com.android.ide.common.resources.configuration.TouchScreenQualifier;
-import com.android.ide.common.resources.configuration.VersionQualifier;
-import com.android.ide.common.sdk.LoadStatus;
-import com.android.io.FileWrapper;
-import com.android.io.FolderWrapper;
-import com.android.resources.Density;
-import com.android.resources.Keyboard;
-import com.android.resources.KeyboardState;
-import com.android.resources.Navigation;
-import com.android.resources.NavigationState;
-import com.android.resources.ResourceType;
-import com.android.resources.ScreenOrientation;
-import com.android.resources.ScreenRatio;
-import com.android.resources.ScreenSize;
-import com.android.resources.TouchScreen;
-import com.android.sdklib.SdkConstants;
-import com.android.sdklib.internal.project.ProjectProperties;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * RenderService Factory. This is initialized for a given platform from the SDK.
- *
- * Also contains some utility method to create {@link FolderConfiguration} and
- * {@link ResourceResolver}
- *
- */
-public class RenderServiceFactory {
-
- private LayoutLibrary mLibrary;
- private FrameworkResources mResources;
-
- public static RenderServiceFactory create(File platformFolder) {
-
- // create the factory
- RenderServiceFactory factory = new RenderServiceFactory();
- if (factory.loadLibrary(platformFolder)) {
- return factory;
- }
-
- return null;
- }
-
- /**
- * Creates a config. This must be a valid config like a device would return. This is to
- * prevent issues where some resources don't exist in all cases and not in the default
- * (for instance only available in hdpi and mdpi but not in default).
- *
- * @param size1
- * @param size2
- * @param screenSize
- * @param screenRatio
- * @param orientation
- * @param density
- * @param touchScreen
- * @param keyboardState
- * @param keyboard
- * @param navigationState
- * @param navigation
- * @param apiLevel
- * @return
- */
- public static FolderConfiguration createConfig(
- int size1,
- int size2,
- ScreenSize screenSize,
- ScreenRatio screenRatio,
- ScreenOrientation orientation,
- Density density,
- TouchScreen touchScreen,
- KeyboardState keyboardState,
- Keyboard keyboard,
- NavigationState navigationState,
- Navigation navigation,
- int apiLevel) {
- FolderConfiguration config = new FolderConfiguration();
-
- int width = size1, height = size2;
- switch (orientation) {
- case LANDSCAPE:
- width = size1 < size2 ? size2 : size1;
- height = size1 < size2 ? size1 : size2;
- break;
- case PORTRAIT:
- width = size1 < size2 ? size1 : size2;
- height = size1 < size2 ? size2 : size1;
- break;
- case SQUARE:
- width = height = size1;
- break;
- }
-
- int wdp = (width * Density.DEFAULT_DENSITY) / density.getDpiValue();
- int hdp = (height * Density.DEFAULT_DENSITY) / density.getDpiValue();
-
- config.addQualifier(new SmallestScreenWidthQualifier(wdp < hdp ? wdp : hdp));
- config.addQualifier(new ScreenWidthQualifier(wdp));
- config.addQualifier(new ScreenHeightQualifier(hdp));
-
- config.addQualifier(new ScreenSizeQualifier(screenSize));
- config.addQualifier(new ScreenRatioQualifier(screenRatio));
- config.addQualifier(new ScreenOrientationQualifier(orientation));
- config.addQualifier(new DensityQualifier(density));
- config.addQualifier(new TouchScreenQualifier(touchScreen));
- config.addQualifier(new KeyboardStateQualifier(keyboardState));
- config.addQualifier(new TextInputMethodQualifier(keyboard));
- config.addQualifier(new NavigationStateQualifier(navigationState));
- config.addQualifier(new NavigationMethodQualifier(navigation));
- config.addQualifier(width > height ? new ScreenDimensionQualifier(width, height) :
- new ScreenDimensionQualifier(height, width));
- config.addQualifier(new VersionQualifier(apiLevel));
-
- config.updateScreenWidthAndHeight();
-
- return config;
- }
-
- /**
- * Returns a {@link ResourceResolver} for a given config and project resource.
- *
- * @param config
- * @param projectResources
- * @param themeName
- * @param isProjectTheme
- * @return
- */
- public ResourceResolver createResourceResolver(
- FolderConfiguration config,
- ResourceRepository projectResources,
- String themeName,
- boolean isProjectTheme) {
-
- Map<ResourceType, Map<String, ResourceValue>> configedProjectRes =
- projectResources.getConfiguredResources(config);
-
- Map<ResourceType, Map<String, ResourceValue>> configedFrameworkRes =
- mResources.getConfiguredResources(config);
-
- return ResourceResolver.create(configedProjectRes, configedFrameworkRes,
- themeName, isProjectTheme);
- }
-
- /**
- * Creates a RenderService
- *
- * @param resources
- * @param config
- * @param projectCallback
- * @return
- */
- public RenderService createService(
- ResourceResolver resources,
- FolderConfiguration config,
- IProjectCallback projectCallback) {
- RenderService renderService = new RenderService(
- mLibrary, resources, config, projectCallback);
-
- return renderService;
-
- }
-
- /**
- * Creates a RenderService. This is less efficient than
- * {@link #createService(ResourceResolver, FolderConfiguration, IProjectCallback)} since the
- * {@link ResourceResolver} object is not cached by the caller.
- *
- * @param projectResources
- * @param themeName
- * @param isProjectTheme
- * @param config
- * @param projectCallback
- * @return
- */
- public RenderService createService(
- ResourceRepository projectResources,
- String themeName,
- boolean isProjectTheme,
- FolderConfiguration config,
- IProjectCallback projectCallback) {
- ResourceResolver resources = createResourceResolver(
- config, projectResources, themeName, isProjectTheme);
-
- RenderService renderService = new RenderService(
- mLibrary, resources, config, projectCallback);
-
- return renderService;
- }
-
- private RenderServiceFactory() {
-
- }
-
- private boolean loadLibrary(File platformFolder) {
- if (platformFolder.isDirectory() == false) {
- throw new IllegalArgumentException("platform folder does not exist.");
- }
-
- File dataFolder = new File(platformFolder, "data");
- if (dataFolder.isDirectory() == false) {
- throw new IllegalArgumentException("platform data folder does not exist.");
- }
-
- File layoutLibJar = new File(dataFolder, "layoutlib.jar");
- if (layoutLibJar.isFile() == false) {
- throw new IllegalArgumentException("platform layoutlib.jar does not exist.");
- }
-
- File resFolder = new File(dataFolder, "res");
- if (resFolder.isDirectory() == false) {
- throw new IllegalArgumentException("platform res folder does not exist.");
- }
-
- File fontFolder = new File(dataFolder, "fonts");
- if (fontFolder.isDirectory() == false) {
- throw new IllegalArgumentException("platform font folder does not exist.");
- }
-
- FileWrapper buildProp = new FileWrapper(platformFolder, SdkConstants.FN_BUILD_PROP);
- if (buildProp.isFile() == false) {
- throw new IllegalArgumentException("platform build.prop does not exist.");
- }
-
- StdOutLogger log = new StdOutLogger();
-
- mLibrary = LayoutLibrary.load(layoutLibJar.getAbsolutePath(), log,
- "LayoutLibRenderer");
- if (mLibrary.getStatus() != LoadStatus.LOADED) {
- throw new IllegalArgumentException(mLibrary.getLoadMessage());
- }
-
- // load the framework resources
- mResources = loadResources(resFolder, log);
-
- // get all the attr values.
- HashMap<String, Map<String, Integer>> enumMap = new HashMap<String, Map<String, Integer>>();
-
- FolderConfiguration config = new FolderConfiguration();
- Map<ResourceType, Map<String, ResourceValue>> res =
- mResources.getConfiguredResources(config);
-
- // get the ATTR values
- Map<String, ResourceValue> attrItems = res.get(ResourceType.ATTR);
- for (ResourceValue value : attrItems.values()) {
- if (value instanceof AttrResourceValue) {
- AttrResourceValue attr = (AttrResourceValue) value;
- Map<String, Integer> values = attr.getAttributeValues();
- if (values != null) {
- enumMap.put(attr.getName(), values);
- }
- }
- }
-
- // get the declare-styleable values
- Map<String, ResourceValue> styleableItems = res.get(ResourceType.DECLARE_STYLEABLE);
-
- // get the attr from the styleable
- for (ResourceValue value : styleableItems.values()) {
- if (value instanceof DeclareStyleableResourceValue) {
- DeclareStyleableResourceValue dsrc = (DeclareStyleableResourceValue) value;
- Map<String, AttrResourceValue> attrs = dsrc.getAllAttributes();
- if (attrs != null && attrs.size() > 0) {
- for (AttrResourceValue attr : attrs.values()) {
- Map<String, Integer> values = attr.getAttributeValues();
- if (values != null) {
- enumMap.put(attr.getName(), values);
- }
- }
- }
- }
- }
-
- // we need to parse the build.prop for this
- Map<String, String> buildPropMap = ProjectProperties.parsePropertyFile(buildProp, log);
-
- return mLibrary.init(buildPropMap, fontFolder, enumMap, log);
- }
-
- private FrameworkResources loadResources(File resFolder, ILogger log) {
- FrameworkResources resources = new FrameworkResources();
-
- try {
- FolderWrapper path = new FolderWrapper(resFolder);
- resources.loadResources(path);
- resources.loadPublicResources(path, log);
- return resources;
- } catch (IOException e) {
- // since we test that folders are folders, and files are files, this shouldn't
- // happen. We can ignore it.
- }
-
- return null;
- }
-
-}
diff --git a/layoutlib_api/sample/src/com/example/android/render/StdOutLogger.java b/layoutlib_api/sample/src/com/example/android/render/StdOutLogger.java
deleted file mode 100644
index e934a2f..0000000
--- a/layoutlib_api/sample/src/com/example/android/render/StdOutLogger.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.render;
-
-import com.android.ide.common.log.ILogger;
-import com.android.ide.common.rendering.api.LayoutLog;
-import com.android.sdklib.ISdkLog;
-
-/**
- * Class implementing the 3 different log interface we use!
- *
- * At least ILogger and ISdkLog are identical...
- *
- */
-public class StdOutLogger extends LayoutLog implements ILogger, ISdkLog {
-
- // LayoutLog
-
- @Override
- public void error(String tag, String message, Object data) {
- if (tag != null) {
- System.err.println("ERROR: [" + tag + "] " + message);
- } else {
- System.err.println("ERROR: " + message);
- }
- }
-
- @Override
- public void error(String tag, String message, Throwable throwable, Object data) {
- error(tag, message, data);
- throwable.printStackTrace();
- }
-
- @Override
- public void fidelityWarning(String tag, String message, Throwable throwable, Object data) {
- if (tag != null) {
- System.out.println("warning: [" + tag + "] " + message);
- } else {
- System.out.println("warning: " + message);
- }
- if (throwable != null) {
- throwable.printStackTrace();
- }
- }
-
- @Override
- public void warning(String tag, String message, Object data) {
- fidelityWarning(tag, message, null /*throwable*/, data);
- }
-
- // ILogger / ISdkLog
-
- public void error(Throwable t, String errorFormat, Object... args) {
- error(null /*tag*/, String.format(errorFormat, args), t, null /*data*/);
- }
-
- public void printf(String msgFormat, Object... args) {
- System.out.println(String.format(msgFormat, args));
- }
-
- public void warning(String warningFormat, Object... args) {
- warning(null /*tag*/, String.format(warningFormat, args), null /*data*/);
- }
-}
diff --git a/layoutlib_api/sample/src/com/example/android/render/XmlParser.java b/layoutlib_api/sample/src/com/example/android/render/XmlParser.java
deleted file mode 100644
index 6c1f67c..0000000
--- a/layoutlib_api/sample/src/com/example/android/render/XmlParser.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.render;
-
-import com.android.ide.common.rendering.api.ILayoutPullParser;
-import com.android.ide.common.rendering.api.IProjectCallback;
-
-import org.kxml2.io.KXmlParser;
-
-/**
- * KXml-based parser that implements {@link ILayoutPullParser}.
- *
- */
-public class XmlParser extends KXmlParser implements ILayoutPullParser {
-
- /**
- * @deprecated {@link IProjectCallback} replaces this.
- */
- @Deprecated
- public ILayoutPullParser getParser(String layoutName) {
- return null;
- }
-
- public Object getViewCookie() {
- return null;
- }
-}
diff --git a/layoutlib_api/sample/testproject/AndroidManifest.xml b/layoutlib_api/sample/testproject/AndroidManifest.xml
deleted file mode 100644
index e584b3c..0000000
--- a/layoutlib_api/sample/testproject/AndroidManifest.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.layoutlib.testproject"
- android:versionCode="1"
- android:versionName="1.0">
- <application android:label="@string/app_name" android:icon="@drawable/icon">
- <activity android:name="Main"
- android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-</manifest>
diff --git a/layoutlib_api/sample/testproject/build.properties b/layoutlib_api/sample/testproject/build.properties
deleted file mode 100644
index ee52d86..0000000
--- a/layoutlib_api/sample/testproject/build.properties
+++ /dev/null
@@ -1,17 +0,0 @@
-# This file is used to override default values used by the Ant build system.
-#
-# This file must be checked in Version Control Systems, as it is
-# integral to the build system of your project.
-
-# This file is only used by the Ant script.
-
-# You can use this to override default values such as
-# 'source.dir' for the location of your java source folder and
-# 'out.dir' for the location of your output folder.
-
-# You can also use it define how the release builds are signed by declaring
-# the following properties:
-# 'key.store' for the location of your keystore and
-# 'key.alias' for the name of the key to use.
-# The password will be asked during the build when you use the 'release' target.
-
diff --git a/layoutlib_api/sample/testproject/build.xml b/layoutlib_api/sample/testproject/build.xml
deleted file mode 100644
index ed79018..0000000
--- a/layoutlib_api/sample/testproject/build.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project name="testproject" default="help">
-
-<!-- The local.properties file is created and updated by the 'android'
- tool.
- It contains the path to the SDK. It should *NOT* be checked into
- Version Control Systems. -->
- <property file="local.properties" />
-
- <!-- The build.properties file can be created by you and is never touched
- by the 'android' tool. This is the place to change some of the
- default property values used by the Ant rules.
- Here are some properties you may want to change/update:
-
- source.dir
- The name of the source directory. Default is 'src'.
- out.dir
- The name of the output directory. Default is 'bin'.
-
- Properties related to the SDK location or the project target should
- be updated using the 'android' tool with the 'update' action.
-
- This file is an integral part of the build system for your
- application and should be checked into Version Control Systems.
-
- -->
- <property file="build.properties" />
-
- <!-- The default.properties file is created and updated by the 'android'
- tool, as well as ADT.
- This file is an integral part of the build system for your
- application and should be checked into Version Control Systems. -->
- <property file="default.properties" />
-
-
- <!-- Required pre-setup import -->
- <import file="${sdk.dir}/tools/ant/pre_setup.xml" />
-
-
-<!-- extension targets. Uncomment the ones where you want to do custom work
- in between standard targets -->
-<!--
- <target name="-pre-build">
- </target>
- <target name="-pre-compile">
- </target>
-
- [This is typically used for code obfuscation.
- Compiled code location: ${out.classes.absolute.dir}
- If this is not done in place, override ${out.dex.input.absolute.dir}]
- <target name="-post-compile">
- </target>
--->
-
- <!-- Execute the Android Setup task that will setup some properties
- specific to the target, and import the build rules files.
-
- The rules file is imported from
- <SDK>/tools/ant/
- Depending on the project type it can be either:
- - main_rules.xml
- - lib_rules.xml
- - test_rules.xml
-
- To customize existing targets, there are two options:
- - Customize only one target:
- - copy/paste the target into this file, *before* the
- <setup> task.
- - customize it to your needs.
- - Customize the whole script.
- - copy/paste the content of the rules files (minus the top node)
- into this file, *after* the <setup> task
- - disable the import of the rules by changing the setup task
- below to <setup import="false" />.
- - customize to your needs.
- -->
- <setup />
-
-</project>
diff --git a/layoutlib_api/sample/testproject/default.properties b/layoutlib_api/sample/testproject/default.properties
deleted file mode 100644
index 8ee25b8..0000000
--- a/layoutlib_api/sample/testproject/default.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "build.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-AOSP
diff --git a/layoutlib_api/sample/testproject/proguard.cfg b/layoutlib_api/sample/testproject/proguard.cfg
deleted file mode 100644
index b1cdf17..0000000
--- a/layoutlib_api/sample/testproject/proguard.cfg
+++ /dev/null
@@ -1,40 +0,0 @@
--optimizationpasses 5
--dontusemixedcaseclassnames
--dontskipnonpubliclibraryclasses
--dontpreverify
--verbose
--optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-
--keep public class * extends android.app.Activity
--keep public class * extends android.app.Application
--keep public class * extends android.app.Service
--keep public class * extends android.content.BroadcastReceiver
--keep public class * extends android.content.ContentProvider
--keep public class * extends android.app.backup.BackupAgentHelper
--keep public class * extends android.preference.Preference
--keep public class com.android.vending.licensing.ILicensingService
-
--keepclasseswithmembernames class * {
- native <methods>;
-}
-
--keepclasseswithmembers class * {
- public <init>(android.content.Context, android.util.AttributeSet);
-}
-
--keepclasseswithmembers class * {
- public <init>(android.content.Context, android.util.AttributeSet, int);
-}
-
--keepclassmembers class * extends android.app.Activity {
- public void *(android.view.View);
-}
-
--keepclassmembers enum * {
- public static **[] values();
- public static ** valueOf(java.lang.String);
-}
-
--keep class * implements android.os.Parcelable {
- public static final android.os.Parcelable$Creator *;
-}
diff --git a/layoutlib_api/sample/testproject/res/drawable-hdpi/icon.png b/layoutlib_api/sample/testproject/res/drawable-hdpi/icon.png
deleted file mode 100644
index 8074c4c..0000000
--- a/layoutlib_api/sample/testproject/res/drawable-hdpi/icon.png
+++ /dev/null
Binary files differ
diff --git a/layoutlib_api/sample/testproject/res/drawable-ldpi/icon.png b/layoutlib_api/sample/testproject/res/drawable-ldpi/icon.png
deleted file mode 100644
index 1095584..0000000
--- a/layoutlib_api/sample/testproject/res/drawable-ldpi/icon.png
+++ /dev/null
Binary files differ
diff --git a/layoutlib_api/sample/testproject/res/drawable-mdpi/icon.png b/layoutlib_api/sample/testproject/res/drawable-mdpi/icon.png
deleted file mode 100644
index a07c69f..0000000
--- a/layoutlib_api/sample/testproject/res/drawable-mdpi/icon.png
+++ /dev/null
Binary files differ
diff --git a/layoutlib_api/sample/testproject/res/layout/main.xml b/layoutlib_api/sample/testproject/res/layout/main.xml
deleted file mode 100644
index c1d0043..0000000
--- a/layoutlib_api/sample/testproject/res/layout/main.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- >
-<TextView
- android:text="Hello World, Main"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="right"
- />
-</LinearLayout>
-
diff --git a/layoutlib_api/sample/testproject/res/values/strings.xml b/layoutlib_api/sample/testproject/res/values/strings.xml
deleted file mode 100644
index 549e4ea..0000000
--- a/layoutlib_api/sample/testproject/res/values/strings.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="app_name">Main</string>
-</resources>
diff --git a/layoutlib_api/sample/testproject/src/com/example/layoutlib/testproject/Main.java b/layoutlib_api/sample/testproject/src/com/example/layoutlib/testproject/Main.java
deleted file mode 100644
index 90ec357..0000000
--- a/layoutlib_api/sample/testproject/src/com/example/layoutlib/testproject/Main.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.example.layoutlib.testproject;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class Main extends Activity
-{
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState)
- {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- }
-}
diff --git a/lint/.gitignore b/lint/.gitignore
deleted file mode 100644
index efaf427..0000000
--- a/lint/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-cli/bin
-cli/build
-cli/src/test/bin
-libs/lint_api/bin
-libs/lint_api/build
-libs/lint_checks/bin
-libs/lint_checks/build
diff --git a/lint/Android.mk b/lint/Android.mk
deleted file mode 100644
index 8a99bd7..0000000
--- a/lint/Android.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2011 The Android Open Source Project
-#
-LINT_LOCAL_DIR := $(call my-dir)
-include $(LINT_LOCAL_DIR)/libs/Android.mk
-include $(LINT_LOCAL_DIR)/cli/Android.mk
diff --git a/lint/MODULE_LICENSE_APACHE2 b/lint/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/lint/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/lint/cli/.classpath b/lint/cli/.classpath
deleted file mode 100644
index f698d34..0000000
--- a/lint/cli/.classpath
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry combineaccessrules="false" kind="src" path="/lint-api"/>
- <classpathentry combineaccessrules="false" kind="src" path="/lint-checks"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src-4.0.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-tree-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src-4.0.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-analysis-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src-4.0.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src-4.0.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/lombok-ast/lombok-ast-0.2.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/lombok-ast/src-4.0.zip"/>
- <classpathentry combineaccessrules="false" kind="src" path="/sdklib"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/lint/cli/.project b/lint/cli/.project
deleted file mode 100644
index 2809612..0000000
--- a/lint/cli/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>lint-cli</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/lint/cli/.settings/org.eclipse.jdt.core.prefs b/lint/cli/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/lint/cli/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/lint/cli/Android.mk b/lint/cli/Android.mk
deleted file mode 100644
index 0f29dae..0000000
--- a/lint/cli/Android.mk
+++ /dev/null
@@ -1,42 +0,0 @@
-# Copyright 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# The lint code has moved to tools/base/lint.
-# The rule below uses the prebuilt lint.jar.
-#
-# If you want to run the tests, cd to tools/base/lint
-# and run ./gradlew :lint:test
-
-LOCAL_JAVA_LIBRARIES := \
- common \
- sdklib \
- lint_api \
- lint_checks \
- lombok-ast-0.2 \
- asm-tools \
- asm-tree-tools \
- asm-analysis-tools \
- guava-tools
-
-LOCAL_MODULE := lint
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PREBUILT_JAVA_LIBRARIES := \
- ../../../prebuilts/devtools/tools/lib/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/lint/cli/NOTICE b/lint/cli/NOTICE
deleted file mode 100644
index becc120..0000000
--- a/lint/cli/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2011, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/lint/cli/etc/Android.mk b/lint/cli/etc/Android.mk
deleted file mode 100644
index 987b452..0000000
--- a/lint/cli/etc/Android.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-# Copyright 2011 The Android Open Source Project
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_PREBUILT_EXECUTABLES := lint
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/lint/cli/etc/lint b/lint/cli/etc/lint
deleted file mode 100755
index 6a75288..0000000
--- a/lint/cli/etc/lint
+++ /dev/null
@@ -1,72 +0,0 @@
-#!/bin/bash
-# Copyright 2011, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
- newProg=`/bin/ls -ld "${prog}"`
- newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
- if expr "x${newProg}" : 'x/' >/dev/null; then
- prog="${newProg}"
- else
- progdir=`dirname "${prog}"`
- prog="${progdir}/${newProg}"
- fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/`basename "${prog}"`
-cd "${oldwd}"
-
-jarfile=lint.jar
-frameworkdir="$progdir"
-libdir="$progdir"
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/tools/lib
- libdir=`dirname "$progdir"`/tools/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/framework
- libdir=`dirname "$progdir"`/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- echo `basename "$prog"`": can't find $jarfile"
- exit 1
-fi
-
-# Check args.
-if [ debug = "$1" ]; then
- # add this in for debugging
- java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
- shift 1
-else
- java_debug=
-fi
-
-javaCmd="java"
-
-jarpath="$frameworkdir/$jarfile"
-
-exec "$javaCmd" \
- -Xmx512m $os_opts $java_debug \
- -Dcom.android.tools.lint.bindir="$progdir" \
- -classpath "$jarpath" \
- com.android.tools.lint.Main "$@"
diff --git a/lint/cli/etc/lint.bat b/lint/cli/etc/lint.bat
deleted file mode 100755
index 08ae1c3..0000000
--- a/lint/cli/etc/lint.bat
+++ /dev/null
@@ -1,58 +0,0 @@
-@echo off
-rem Copyright (C) 2011 The Android Open Source Project
-rem
-rem Licensed under the Apache License, Version 2.0 (the "License");
-rem you may not use this file except in compliance with the License.
-rem You may obtain a copy of the License at
-rem
-rem http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-
-rem don't modify the caller's environment
-setlocal
-
-rem Set up prog to be the path of this script, including following symlinks,
-rem and set up progdir to be the fully-qualified pathname of its directory.
-set prog=%~f0
-
-rem Grab current directory before we change it
-set work_dir="%cd%"
-
-rem Change current directory and drive to where the script is, to avoid
-rem issues with directories containing whitespaces.
-cd /d %~dp0
-
-rem Get the CWD as a full path with short names only (without spaces)
-for %%i in ("%cd%") do set prog_dir=%%~fsi
-
-rem Check we have a valid Java.exe in the path.
-set java_exe=
-call lib\find_java.bat
-if not defined java_exe goto :EOF
-
-set jarfile=lint.jar
-set frameworkdir=
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=lib\
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=..\framework\
-
-:JarFileOk
-
-if debug NEQ "%1" goto NoDebug
- set java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
- shift 1
-:NoDebug
-
-set jarpath=%frameworkdir%%jarfile%
-set javaextdirs=%frameworkdir%
-
-call %java_exe% %java_debug% -Xmx512m -Dcom.android.tools.lint.bindir=%prog_dir% -Dcom.android.tools.lint.workdir=%work_dir% -classpath "%jarpath%" com.android.tools.lint.Main %*
-
diff --git a/lint/cli/etc/manifest.txt b/lint/cli/etc/manifest.txt
deleted file mode 100644
index ff04772..0000000
--- a/lint/cli/etc/manifest.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Main-Class: com.android.tools.lint.Main
-Class-Path: common.jar layout_lib.jar lint_api.jar lint_checks.jar asm-4.0.jar asm-tree-4.0.jar asm-analysis-4.0.jar guava-13.0.1.jar lombok-ast-0.2.jar sdklib.jar
diff --git a/lint/cli/src/main/java/com/android/tools/lint/HtmlReporter.java b/lint/cli/src/main/java/com/android/tools/lint/HtmlReporter.java
deleted file mode 100644
index 83cd76d..0000000
--- a/lint/cli/src/main/java/com/android/tools/lint/HtmlReporter.java
+++ /dev/null
@@ -1,773 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint;
-
-import static com.android.SdkConstants.DOT_JPG;
-import static com.android.SdkConstants.DOT_PNG;
-import static com.android.tools.lint.detector.api.LintUtils.endsWith;
-
-import com.android.tools.lint.checks.BuiltinIssueRegistry;
-import com.android.tools.lint.client.api.Configuration;
-import com.android.tools.lint.detector.api.Category;
-import com.android.tools.lint.detector.api.Issue;
-import com.android.tools.lint.detector.api.Location;
-import com.android.tools.lint.detector.api.Position;
-import com.android.tools.lint.detector.api.Project;
-import com.android.tools.lint.detector.api.Severity;
-import com.google.common.annotations.Beta;
-import com.google.common.base.Charsets;
-import com.google.common.collect.Maps;
-import com.google.common.io.ByteStreams;
-import com.google.common.io.Closeables;
-import com.google.common.io.Files;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Writer;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * A reporter which emits lint results into an HTML report.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- */
-@Beta
-public class HtmlReporter extends Reporter {
- private static final boolean USE_HOLO_STYLE = true;
- private static final String CSS = USE_HOLO_STYLE
- ? "hololike.css" : "default.css"; //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * Maximum number of warnings allowed for a single issue type before we
- * split up and hide all but the first {@link #SHOWN_COUNT} items.
- */
- private static final int SPLIT_LIMIT = 8;
- /**
- * When a warning has at least {@link #SPLIT_LIMIT} items, then we show the
- * following number of items before the "Show more" button/link.
- */
- private static final int SHOWN_COUNT = SPLIT_LIMIT - 3;
-
- protected final Writer mWriter;
- private String mStripPrefix;
- private String mFixUrl;
-
- /**
- * Creates a new {@link HtmlReporter}
- *
- * @param client the associated client
- * @param output the output file
- * @throws IOException if an error occurs
- */
- public HtmlReporter(Main client, File output) throws IOException {
- super(client, output);
- mWriter = new BufferedWriter(Files.newWriter(output, Charsets.UTF_8));
- }
-
- @Override
- public void write(int errorCount, int warningCount, List<Warning> issues) throws IOException {
- Map<Issue, String> missing = computeMissingIssues(issues);
-
- mWriter.write(
- "<html>\n" + //$NON-NLS-1$
- "<head>\n" + //$NON-NLS-1$
- "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>" + //$NON-NLS-1$
- "<title>" + mTitle + "</title>\n"); //$NON-NLS-1$//$NON-NLS-2$
-
- writeStyleSheet();
-
- if (!mSimpleFormat) {
- // JavaScript for collapsing/expanding long lists
- mWriter.write(
- "<script language=\"javascript\"> \n" + //$NON-NLS-1$
- "<!--\n" + //$NON-NLS-1$
- "function reveal(id) {\n" + //$NON-NLS-1$
- "if (document.getElementById) {\n" + //$NON-NLS-1$
- "document.getElementById(id).style.display = 'block';\n" + //$NON-NLS-1$
- "document.getElementById(id+'Link').style.display = 'none';\n" + //$NON-NLS-1$
- "}\n" + //$NON-NLS-1$
- "}\n" + //$NON-NLS-1$
- "//--> \n" + //$NON-NLS-1$
- "</script>\n"); //$NON-NLS-1$
- }
-
- mWriter.write(
- "</head>\n" + //$NON-NLS-1$
- "<body>\n" + //$NON-NLS-1$
- "<h1>" + //$NON-NLS-1$
- mTitle +
- "<div class=\"titleSeparator\"></div>\n" + //$NON-NLS-1$
- "</h1>\n"); //$NON-NLS-1$
-
- mWriter.write(String.format("Check performed at %1$s.",
- new Date().toString()));
- mWriter.write("<br/>"); //$NON-NLS-1$
- mWriter.write(String.format("%1$d errors and %2$d warnings found:",
- errorCount, warningCount));
- mWriter.write("<br/><br/>"); //$NON-NLS-1$
-
- Issue previousIssue = null;
- if (!issues.isEmpty()) {
- List<List<Warning>> related = new ArrayList<List<Warning>>();
- List<Warning> currentList = null;
- for (Warning warning : issues) {
- if (warning.issue != previousIssue) {
- previousIssue = warning.issue;
- currentList = new ArrayList<Warning>();
- related.add(currentList);
- }
- assert currentList != null;
- currentList.add(warning);
- }
-
- writeOverview(related, missing.size());
-
- Category previousCategory = null;
- for (List<Warning> warnings : related) {
- Warning first = warnings.get(0);
- Issue issue = first.issue;
-
- if (issue.getCategory() != previousCategory) {
- previousCategory = issue.getCategory();
- mWriter.write("\n<a name=\""); //$NON-NLS-1$
- mWriter.write(issue.getCategory().getFullName());
- mWriter.write("\"></a>\n"); //$NON-NLS-1$
- mWriter.write("<div class=\"category\"><a href=\"#\" title=\"Return to top\">"); //$NON-NLS-1$
- mWriter.write(issue.getCategory().getFullName());
- mWriter.write("</a><div class=\"categorySeparator\"></div>\n");//$NON-NLS-1$
- mWriter.write("</div>\n"); //$NON-NLS-1$
- }
-
- mWriter.write("<a name=\"" + issue.getId() + "\"></a>\n"); //$NON-NLS-1$ //$NON-NLS-2$
- mWriter.write("<div class=\"issue\">\n"); //$NON-NLS-1$
-
- // Explain this issue
- mWriter.write("<div class=\"id\"><a href=\"#\" title=\"Return to top\">"); //$NON-NLS-1$
- mWriter.write(issue.getId());
- mWriter.write("</a><div class=\"issueSeparator\"></div>\n"); //$NON-NLS-1$
- mWriter.write("</div>\n"); //$NON-NLS-1$
-
- mWriter.write("<div class=\"warningslist\">\n"); //$NON-NLS-1$
- boolean partialHide = !mSimpleFormat && warnings.size() > SPLIT_LIMIT;
-
- int count = 0;
- for (Warning warning : warnings) {
- if (partialHide && count == SHOWN_COUNT) {
- String id = warning.issue.getId() + "Div"; //$NON-NLS-1$
- mWriter.write("<button id=\""); //$NON-NLS-1$
- mWriter.write(id);
- mWriter.write("Link\" onclick=\"reveal('"); //$NON-NLS-1$
- mWriter.write(id);
- mWriter.write("');\" />"); //$NON-NLS-1$
- mWriter.write(String.format("+ %1$d More Occurrences...",
- warnings.size() - SHOWN_COUNT));
- mWriter.write("</button>\n"); //$NON-NLS-1$
- mWriter.write("<div id=\""); //$NON-NLS-1$
- mWriter.write(id);
- mWriter.write("\" style=\"display: none\">\n"); //$NON-NLS-1$
- }
- count++;
- String url = null;
- if (warning.path != null) {
- url = writeLocation(warning.file, warning.path, warning.line);
- mWriter.write(':');
- mWriter.write(' ');
- }
-
- // Is the URL for a single image? If so, place it here near the top
- // of the error floating on the right. If there are multiple images,
- // they will instead be placed in a horizontal box below the error
- boolean addedImage = false;
- if (url != null && warning.location != null
- && warning.location.getSecondary() == null) {
- addedImage = addImage(url, warning.location);
- }
- mWriter.write("<span class=\"message\">"); //$NON-NLS-1$
- appendEscapedText(warning.message);
- mWriter.write("</span>"); //$NON-NLS-1$
- if (addedImage) {
- mWriter.write("<br clear=\"right\"/>"); //$NON-NLS-1$
- } else {
- mWriter.write("<br />"); //$NON-NLS-1$
- }
-
- // Insert surrounding code block window
- if (warning.line >= 0 && warning.fileContents != null) {
- mWriter.write("<pre class=\"errorlines\">\n"); //$NON-NLS-1$
- appendCodeBlock(warning.fileContents, warning.line, warning.offset);
- mWriter.write("\n</pre>"); //$NON-NLS-1$
- }
- mWriter.write('\n');
- if (warning.location != null && warning.location.getSecondary() != null) {
- mWriter.write("<ul>");
- Location l = warning.location.getSecondary();
- int otherLocations = 0;
- while (l != null) {
- String message = l.getMessage();
- if (message != null && !message.isEmpty()) {
- Position start = l.getStart();
- int line = start != null ? start.getLine() : -1;
- String path = mClient.getDisplayPath(warning.project, l.getFile());
- writeLocation(l.getFile(), path, line);
- mWriter.write(':');
- mWriter.write(' ');
- mWriter.write("<span class=\"message\">"); //$NON-NLS-1$
- appendEscapedText(message);
- mWriter.write("</span>"); //$NON-NLS-1$
- mWriter.write("<br />"); //$NON-NLS-1$
-
- String name = l.getFile().getName();
- if (!(endsWith(name, DOT_PNG) || endsWith(name, DOT_JPG))) {
- String s = mClient.readFile(l.getFile());
- if (s != null && !s.isEmpty()) {
- mWriter.write("<pre class=\"errorlines\">\n"); //$NON-NLS-1$
- int offset = start != null ? start.getOffset() : -1;
- appendCodeBlock(s, line, offset);
- mWriter.write("\n</pre>"); //$NON-NLS-1$
- }
- }
- } else {
- otherLocations++;
- }
-
- l = l.getSecondary();
- }
- mWriter.write("</ul>");
- if (otherLocations > 0) {
-
- String id = "Location" + count + "Div"; //$NON-NLS-1$
- mWriter.write("<button id=\""); //$NON-NLS-1$
- mWriter.write(id);
- mWriter.write("Link\" onclick=\"reveal('"); //$NON-NLS-1$
- mWriter.write(id);
- mWriter.write("');\" />"); //$NON-NLS-1$
- mWriter.write(String.format("+ %1$d Additional Locations...",
- otherLocations));
- mWriter.write("</button>\n"); //$NON-NLS-1$
- mWriter.write("<div id=\""); //$NON-NLS-1$
- mWriter.write(id);
- mWriter.write("\" style=\"display: none\">\n"); //$NON-NLS-1$
-
- mWriter.write("Additional locations: ");
- mWriter.write("<ul>\n"); //$NON-NLS-1$
- l = warning.location.getSecondary();
- while (l != null) {
- Position start = l.getStart();
- int line = start != null ? start.getLine() : -1;
- String path = mClient.getDisplayPath(warning.project, l.getFile());
- mWriter.write("<li> "); //$NON-NLS-1$
- writeLocation(l.getFile(), path, line);
- mWriter.write("\n"); //$NON-NLS-1$
- l = l.getSecondary();
- }
- mWriter.write("</ul>\n"); //$NON-NLS-1$
-
- mWriter.write("</div><br/><br/>\n"); //$NON-NLS-1$
- }
- }
-
- // Place a block of images?
- if (!addedImage && url != null && warning.location != null
- && warning.location.getSecondary() != null) {
- addImage(url, warning.location);
- }
- }
- if (partialHide) { // Close up the extra div
- mWriter.write("</div>\n"); //$NON-NLS-1$
- }
-
- mWriter.write("</div>\n"); //$NON-NLS-1$
- writeIssueMetadata(issue, first.severity, null);
- }
-
- if (!mClient.isCheckingSpecificIssues()) {
- writeMissingIssues(missing);
- }
-
- writeSuppressInfo();
- } else {
- mWriter.write("Congratulations!");
- }
- mWriter.write("\n</body>\n</html>"); //$NON-NLS-1$
- mWriter.close();
-
- String path = mOutput.getAbsolutePath();
- System.out.println(String.format("Wrote HTML report to %1$s", path));
- }
-
- private void writeIssueMetadata(Issue issue, Severity severity, String disabledBy)
- throws IOException {
- mWriter.write("<div class=\"metadata\">"); //$NON-NLS-1$
-
- if (mClient.getRegistry() instanceof BuiltinIssueRegistry &&
- ((BuiltinIssueRegistry) mClient.getRegistry()).hasAutoFix("adt", issue)) { //$NON-NLS-1$
- mWriter.write("Note: This issue has an associated quickfix operation in Eclipse/ADT");
- if (mFixUrl != null) {
- mWriter.write("&nbsp;<img border=\"0\" align=\"top\" src=\""); //$NON-NLS-1$
- mWriter.write(mFixUrl);
- mWriter.write("\" />\n"); //$NON-NLS-1$
- }
-
- mWriter.write("<br>\n");
- }
-
- if (disabledBy != null) {
- mWriter.write(String.format("Disabled By: %1$s<br/>\n", disabledBy));
- }
-
- mWriter.write("Priority: ");
- mWriter.write(String.format("%1$d / 10", issue.getPriority()));
- mWriter.write("<br/>\n"); //$NON-NLS-1$
- mWriter.write("Category: ");
- mWriter.write(issue.getCategory().getFullName());
- mWriter.write("</div>\n"); //$NON-NLS-1$
-
- mWriter.write("Severity: ");
- if (severity == Severity.ERROR || severity == Severity.FATAL) {
- mWriter.write("<span class=\"error\">"); //$NON-NLS-1$
- } else if (severity == Severity.WARNING) {
- mWriter.write("<span class=\"warning\">"); //$NON-NLS-1$
- } else {
- mWriter.write("<span>"); //$NON-NLS-1$
- }
- appendEscapedText(severity.getDescription());
- mWriter.write("</span>"); //$NON-NLS-1$
-
- mWriter.write("<div class=\"summary\">\n"); //$NON-NLS-1$
- mWriter.write("Explanation: ");
- String description = issue.getDescription();
- mWriter.write(description);
- if (!description.isEmpty()
- && Character.isLetter(description.charAt(description.length() - 1))) {
- mWriter.write('.');
- }
- mWriter.write("</div>\n"); //$NON-NLS-1$
- mWriter.write("<div class=\"explanation\">\n"); //$NON-NLS-1$
- String explanationHtml = issue.getExplanationAsHtml();
- mWriter.write(explanationHtml);
- mWriter.write("\n</div>\n"); //$NON-NLS-1$;
- if (issue.getMoreInfo() != null) {
- mWriter.write("<br/>"); //$NON-NLS-1$
- mWriter.write("<div class=\"moreinfo\">"); //$NON-NLS-1$
- mWriter.write("More info: ");
- mWriter.write("<a href=\""); //$NON-NLS-1$
- mWriter.write(issue.getMoreInfo());
- mWriter.write("\">"); //$NON-NLS-1$
- mWriter.write(issue.getMoreInfo());
- mWriter.write("</a></div>\n"); //$NON-NLS-1$
- }
-
- mWriter.write("<br/>"); //$NON-NLS-1$
- mWriter.write(String.format(
- "To suppress this error, use the issue id \"%1$s\" as explained in the " +
- "%2$sSuppressing Warnings and Errors%3$s section.",
- issue.getId(),
- "<a href=\"#SuppressInfo\">", "</a>")); //$NON-NLS-1$ //$NON-NLS-2$
- mWriter.write("<br/>\n");
-
- mWriter.write("</div>"); //$NON-NLS-1$
- }
-
- private void writeSuppressInfo() throws IOException {
- //getSuppressHelp
- mWriter.write("\n<a name=\"SuppressInfo\"></a>\n"); //$NON-NLS-1$
- mWriter.write("<div class=\"category\">"); //$NON-NLS-1$
- mWriter.write("Suppressing Warnings and Errors");
- mWriter.write("<div class=\"categorySeparator\"></div>\n");//$NON-NLS-1$
- mWriter.write("</div>\n"); //$NON-NLS-1$
- appendEscapedText(Main.getSuppressHelp());
- mWriter.write('\n');
- }
-
- protected Map<Issue, String> computeMissingIssues(List<Warning> warnings) {
- Set<Project> projects = new HashSet<Project>();
- Set<Issue> seen = new HashSet<Issue>();
- for (Warning warning : warnings) {
- projects.add(warning.project);
- seen.add(warning.issue);
- }
- Configuration cliConfiguration = mClient.getConfiguration();
- Map<Issue, String> map = Maps.newHashMap();
- for (Issue issue : mClient.getRegistry().getIssues()) {
- if (!seen.contains(issue)) {
- if (mClient.isSuppressed(issue)) {
- map.put(issue, "Command line flag");
- continue;
- }
-
- if (!issue.isEnabledByDefault() && !mClient.isAllEnabled()) {
- map.put(issue, "Default");
- continue;
- }
-
- if (cliConfiguration != null && !cliConfiguration.isEnabled(issue)) {
- map.put(issue, "Command line supplied --config lint.xml file");
- continue;
- }
-
- // See if any projects disable this warning
- for (Project project : projects) {
- if (!project.getConfiguration().isEnabled(issue)) {
- map.put(issue, "Project lint.xml file");
- break;
- }
- }
- }
- }
-
- return map;
- }
-
- private void writeMissingIssues(Map<Issue, String> missing) throws IOException {
- mWriter.write("\n<a name=\"MissingIssues\"></a>\n"); //$NON-NLS-1$
- mWriter.write("<div class=\"category\">"); //$NON-NLS-1$
- mWriter.write("Disabled Checks");
- mWriter.write("<div class=\"categorySeparator\"></div>\n");//$NON-NLS-1$
- mWriter.write("</div>\n");//$NON-NLS-1$
-
- mWriter.write(
- "The following issues were not run by lint, either " +
- "because the check is not enabled by default, or because " +
- "it was disabled with a command line flag or via one or " +
- "more lint.xml configuration files in the project directories.");
- mWriter.write("\n<br/><br/>\n"); //$NON-NLS-1$
-
- List<Issue> list = new ArrayList<Issue>(missing.keySet());
- Collections.sort(list);
-
-
- for (Issue issue : list) {
- mWriter.write("<a name=\"" + issue.getId() + "\"></a>\n"); //$NON-NLS-1$ //$NON-NLS-2$
- mWriter.write("<div class=\"issue\">\n"); //$NON-NLS-1$
-
- // Explain this issue
- mWriter.write("<div class=\"id\">"); //$NON-NLS-1$
- mWriter.write(issue.getId());
- mWriter.write("<div class=\"issueSeparator\"></div>\n"); //$NON-NLS-1$
- mWriter.write("</div>\n"); //$NON-NLS-1$
- String disabledBy = missing.get(issue);
- writeIssueMetadata(issue, issue.getDefaultSeverity(), disabledBy);
- }
- }
-
- protected void writeStyleSheet() throws IOException {
- if (USE_HOLO_STYLE) {
- mWriter.write(
- "<link rel=\"stylesheet\" type=\"text/css\" " + //$NON-NLS-1$
- "href=\"http://fonts.googleapis.com/css?family=Roboto\">" );//$NON-NLS-1$
- }
-
- URL cssUrl = HtmlReporter.class.getResource(CSS);
- if (mSimpleFormat) {
- // Inline the CSS
- mWriter.write("<style>\n"); //$NON-NLS-1$
- @SuppressWarnings("resource") // Eclipse doesn't know about Closeables.closeQuietly
- InputStream input = cssUrl.openStream();
- byte[] bytes = ByteStreams.toByteArray(input);
- Closeables.closeQuietly(input);
- String css = new String(bytes, Charsets.UTF_8);
- mWriter.write(css);
- mWriter.write("</style>\n"); //$NON-NLS-1$
- } else {
- String ref = addLocalResources(cssUrl);
- if (ref != null) {
- mWriter.write(
- "<link rel=\"stylesheet\" type=\"text/css\" href=\"" //$NON-NLS-1$
- + ref + "\">\n"); //$NON-NLS-1$
- }
- }
- }
-
- private void writeOverview(List<List<Warning>> related, int missingCount)
- throws IOException {
- // Write issue id summary
- mWriter.write("<table class=\"overview\">\n"); //$NON-NLS-1$
-
- String errorUrl = null;
- String warningUrl = null;
- if (!mSimpleFormat) {
- errorUrl = addLocalResources(getErrorIconUrl());
- warningUrl = addLocalResources(getWarningIconUrl());
- mFixUrl = addLocalResources(HtmlReporter.class.getResource("lint-run.png")); //$NON-NLS-1$)
- }
-
- Category previousCategory = null;
- for (List<Warning> warnings : related) {
- Issue issue = warnings.get(0).issue;
-
- boolean isError = false;
- for (Warning warning : warnings) {
- if (warning.severity == Severity.ERROR || warning.severity == Severity.FATAL) {
- isError = true;
- break;
- }
- }
-
- if (issue.getCategory() != previousCategory) {
- mWriter.write("<tr><td></td><td class=\"categoryColumn\">");
- previousCategory = issue.getCategory();
- String categoryName = issue.getCategory().getFullName();
- mWriter.write("<a href=\"#"); //$NON-NLS-1$
- mWriter.write(categoryName);
- mWriter.write("\">"); //$NON-NLS-1$
- mWriter.write(categoryName);
- mWriter.write("</a>\n"); //$NON-NLS-1$
- mWriter.write("</td></tr>"); //$NON-NLS-1$
- mWriter.write("\n"); //$NON-NLS-1$
- }
- mWriter.write("<tr>\n"); //$NON-NLS-1$
-
- // Count column
- mWriter.write("<td class=\"countColumn\">"); //$NON-NLS-1$
- mWriter.write(Integer.toString(warnings.size()));
- mWriter.write("</td>"); //$NON-NLS-1$
-
- mWriter.write("<td class=\"issueColumn\">"); //$NON-NLS-1$
-
- String imageUrl = isError ? errorUrl : warningUrl;
- if (imageUrl != null) {
- mWriter.write("<img border=\"0\" align=\"top\" src=\""); //$NON-NLS-1$
- mWriter.write(imageUrl);
- mWriter.write("\" />\n"); //$NON-NLS-1$
- }
-
- mWriter.write("<a href=\"#"); //$NON-NLS-1$
- mWriter.write(issue.getId());
- mWriter.write("\">"); //$NON-NLS-1$
- mWriter.write(issue.getId());
- mWriter.write("</a>\n"); //$NON-NLS-1$
-
- mWriter.write("</td></tr>\n");
- }
-
- if (missingCount > 0 && !mClient.isCheckingSpecificIssues()) {
- mWriter.write("<tr><td></td>"); //$NON-NLS-1$
- mWriter.write("<td class=\"categoryColumn\">"); //$NON-NLS-1$
- mWriter.write("<a href=\"#MissingIssues\">"); //$NON-NLS-1$
- mWriter.write(String.format("Disabled Checks (%1$d)",
- missingCount));
-
- mWriter.write("</a>\n"); //$NON-NLS-1$
- mWriter.write("</td></tr>"); //$NON-NLS-1$
- }
-
- mWriter.write("</table>\n"); //$NON-NLS-1$
- mWriter.write("<br/>"); //$NON-NLS-1$
- }
-
- private String writeLocation(File file, String path, int line) throws IOException {
- String url;
- mWriter.write("<span class=\"location\">"); //$NON-NLS-1$
-
- url = getUrl(file);
- if (url != null) {
- mWriter.write("<a href=\""); //$NON-NLS-1$
- mWriter.write(url);
- mWriter.write("\">"); //$NON-NLS-1$
- }
- mWriter.write(stripPath(path));
- if (url != null) {
- mWriter.write("</a>"); //$NON-NLS-1$
- }
- if (line >= 0) {
- // 0-based line numbers, but display 1-based
- mWriter.write(':');
- mWriter.write(Integer.toString(line + 1));
- }
- mWriter.write("</span>"); //$NON-NLS-1$
- return url;
- }
-
- private boolean addImage(String url, Location location) throws IOException {
- if (url != null && endsWith(url, DOT_PNG)) {
- if (location.getSecondary() != null) {
- // Emit many images
- // Add in linked images as well
- List<String> urls = new ArrayList<String>();
- while (location != null && location.getFile() != null) {
- String imageUrl = getUrl(location.getFile());
- if (imageUrl != null
- && endsWith(imageUrl, DOT_PNG)) {
- urls.add(imageUrl);
- }
- location = location.getSecondary();
- }
- if (!urls.isEmpty()) {
- // Sort in order
- Collections.sort(urls, new Comparator<String>() {
- @Override
- public int compare(String s1, String s2) {
- return getDpiRank(s1) - getDpiRank(s2);
- }
- });
- mWriter.write("<table>"); //$NON-NLS-1$
- mWriter.write("<tr>"); //$NON-NLS-1$
- for (String linkedUrl : urls) {
- // Image series: align top
- mWriter.write("<td>"); //$NON-NLS-1$
- mWriter.write("<a href=\""); //$NON-NLS-1$
- mWriter.write(linkedUrl);
- mWriter.write("\">"); //$NON-NLS-1$
- mWriter.write("<img border=\"0\" align=\"top\" src=\""); //$NON-NLS-1$
- mWriter.write(linkedUrl);
- mWriter.write("\" /></a>\n"); //$NON-NLS-1$
- mWriter.write("</td>"); //$NON-NLS-1$
- }
- mWriter.write("</tr>"); //$NON-NLS-1$
-
- mWriter.write("<tr>"); //$NON-NLS-1$
- for (String linkedUrl : urls) {
- mWriter.write("<th>"); //$NON-NLS-1$
- int index = linkedUrl.lastIndexOf("drawable-"); //$NON-NLS-1$
- if (index != -1) {
- index += "drawable-".length(); //$NON-NLS-1$
- int end = linkedUrl.indexOf('/', index);
- if (end != -1) {
- mWriter.write(linkedUrl.substring(index, end));
- }
- }
- mWriter.write("</th>"); //$NON-NLS-1$
- }
- mWriter.write("</tr>\n"); //$NON-NLS-1$
-
- mWriter.write("</table>\n"); //$NON-NLS-1$
- }
- } else {
- // Just this image: float to the right
- mWriter.write("<img class=\"embedimage\" align=\"right\" src=\""); //$NON-NLS-1$
- mWriter.write(url);
- mWriter.write("\" />"); //$NON-NLS-1$
- }
-
- return true;
- }
-
- return false;
- }
-
- /** Provide a sorting rank for a url */
- private static int getDpiRank(String url) {
- if (url.contains("-xhdpi")) { //$NON-NLS-1$
- return 0;
- } else if (url.contains("-hdpi")) { //$NON-NLS-1$
- return 1;
- } else if (url.contains("-mdpi")) { //$NON-NLS-1$
- return 2;
- } else if (url.contains("-ldpi")) { //$NON-NLS-1$
- return 3;
- } else {
- return 4;
- }
- }
-
- private void appendCodeBlock(String contents, int lineno, int offset)
- throws IOException {
- int max = lineno + 3;
- int min = lineno - 3;
- for (int l = min; l < max; l++) {
- if (l >= 0) {
- int lineOffset = Main.getLineOffset(contents, l);
- if (lineOffset == -1) {
- break;
- }
-
- mWriter.write(String.format("<span class=\"lineno\">%1$4d</span> ", (l + 1))); //$NON-NLS-1$
-
- String line = Main.getLineOfOffset(contents, lineOffset);
- if (offset != -1 && lineOffset <= offset && lineOffset+line.length() >= offset) {
- // Text nodes do not always have correct lines/offsets
- //assert l == lineno;
-
- // This line contains the beginning of the offset
- // First print everything before
- int delta = offset - lineOffset;
- appendEscapedText(line.substring(0, delta));
- mWriter.write("<span class=\"errorspan\">"); //$NON-NLS-1$
- appendEscapedText(line.substring(delta));
- mWriter.write("</span>"); //$NON-NLS-1$
- } else if (offset == -1 && l == lineno) {
- mWriter.write("<span class=\"errorline\">"); //$NON-NLS-1$
- appendEscapedText(line);
- mWriter.write("</span>"); //$NON-NLS-1$
- } else {
- appendEscapedText(line);
- }
- if (l < max - 1) {
- mWriter.write("\n"); //$NON-NLS-1$
- }
- }
- }
- }
-
- private void appendEscapedText(String textValue) throws IOException {
- for (int i = 0, n = textValue.length(); i < n; i++) {
- char c = textValue.charAt(i);
- if (c == '<') {
- mWriter.write("&lt;"); //$NON-NLS-1$
- } else if (c == '&') {
- mWriter.write("&amp;"); //$NON-NLS-1$
- } else if (c == '\n') {
- mWriter.write("<br/>");
- } else {
- if (c > 255) {
- mWriter.write("&#"); //$NON-NLS-1$
- mWriter.write(Integer.toString(c));
- mWriter.write(';');
- } else {
- mWriter.write(c);
- }
- }
- }
- }
-
- private String stripPath(String path) {
- if (mStripPrefix != null && path.startsWith(mStripPrefix)
- && path.length() > mStripPrefix.length()) {
- int index = mStripPrefix.length();
- if (path.charAt(index) == File.separatorChar) {
- index++;
- }
- return path.substring(index);
- }
-
- return path;
- }
-
- /** Sets path prefix to strip from displayed file names */
- void setStripPrefix(String prefix) {
- mStripPrefix = prefix;
- }
-
- static URL getWarningIconUrl() {
- return HtmlReporter.class.getResource("lint-warning.png"); //$NON-NLS-1$
- }
-
- static URL getErrorIconUrl() {
- return HtmlReporter.class.getResource("lint-error.png"); //$NON-NLS-1$
- }
-}
diff --git a/lint/cli/src/main/java/com/android/tools/lint/LintCliXmlParser.java b/lint/cli/src/main/java/com/android/tools/lint/LintCliXmlParser.java
deleted file mode 100644
index bfbe7cb..0000000
--- a/lint/cli/src/main/java/com/android/tools/lint/LintCliXmlParser.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.android.tools.lint.client.api.IDomParser;
-import com.android.tools.lint.client.api.IssueRegistry;
-import com.android.tools.lint.detector.api.Location;
-import com.android.tools.lint.detector.api.Location.Handle;
-import com.android.tools.lint.detector.api.XmlContext;
-import com.android.utils.PositionXmlParser;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.xml.sax.SAXException;
-
-import java.io.File;
-import java.io.UnsupportedEncodingException;
-
-/**
- * A customization of the {@link PositionXmlParser} which creates position
- * objects that directly extend the lint
- * {@link com.android.tools.lint.detector.api.Position} class.
- * <p>
- * It also catches and reports parser errors as lint errors.
- */
-public class LintCliXmlParser extends PositionXmlParser implements IDomParser {
- @Override
- public Document parseXml(@NonNull XmlContext context) {
- String xml = null;
- try {
- // Do we need to provide an input stream for encoding?
- xml = context.getContents();
- if (xml != null) {
- return super.parse(xml);
- }
- } catch (UnsupportedEncodingException e) {
- context.report(
- // Must provide an issue since API guarantees that the issue parameter
- // is valid
- IssueRegistry.PARSER_ERROR, Location.create(context.file),
- e.getCause() != null ? e.getCause().getLocalizedMessage() :
- e.getLocalizedMessage(),
- null);
- } catch (SAXException e) {
- Location location = Location.create(context.file);
- String message = e.getCause() != null ? e.getCause().getLocalizedMessage() :
- e.getLocalizedMessage();
- if (message.startsWith("The processing instruction target matching "
- + "\"[xX][mM][lL]\" is not allowed.")) {
- int prologue = xml.indexOf("<?xml ");
- int comment = xml.indexOf("<!--");
- if (prologue != -1 && comment != -1 && comment < prologue) {
- message = "The XML prologue should appear before, not after, the first XML "
- + "header/copyright comment. " + message;
- }
- }
- context.report(
- // Must provide an issue since API guarantees that the issue parameter
- // is valid
- IssueRegistry.PARSER_ERROR, location,
- message,
- null);
- } catch (Throwable t) {
- context.log(t, null);
- }
- return null;
- }
-
- @NonNull
- @Override
- public Location getLocation(@NonNull XmlContext context, @NonNull Node node) {
- OffsetPosition pos = (OffsetPosition) getPosition(node, -1, -1);
- if (pos != null) {
- return Location.create(context.file, pos, (OffsetPosition) pos.getEnd());
- }
-
- return Location.create(context.file);
- }
-
- @NonNull
- @Override
- public Location getLocation(@NonNull XmlContext context, @NonNull Node node,
- int start, int end) {
- OffsetPosition pos = (OffsetPosition) getPosition(node, start, end);
- if (pos != null) {
- return Location.create(context.file, pos, (OffsetPosition) pos.getEnd());
- }
-
- return Location.create(context.file);
- }
-
- @NonNull
- @Override
- public Handle createLocationHandle(@NonNull XmlContext context, @NonNull Node node) {
- return new LocationHandle(context.file, node);
- }
-
- @NonNull
- @Override
- protected OffsetPosition createPosition(int line, int column, int offset) {
- return new OffsetPosition(line, column, offset);
- }
-
- private static class OffsetPosition extends com.android.tools.lint.detector.api.Position
- implements PositionXmlParser.Position {
- /** The line number (0-based where the first line is line 0) */
- private final int mLine;
-
- /**
- * The column number (where the first character on the line is 0), or -1 if
- * unknown
- */
- private final int mColumn;
-
- /** The character offset */
- private final int mOffset;
-
- /**
- * Linked position: for a begin offset this will point to the end
- * offset, and for an end offset this will be null
- */
- private PositionXmlParser.Position mEnd;
-
- /**
- * Creates a new {@link OffsetPosition}
- *
- * @param line the 0-based line number, or -1 if unknown
- * @param column the 0-based column number, or -1 if unknown
- * @param offset the offset, or -1 if unknown
- */
- public OffsetPosition(int line, int column, int offset) {
- mLine = line;
- mColumn = column;
- mOffset = offset;
- }
-
- @Override
- public int getLine() {
- return mLine;
- }
-
- @Override
- public int getOffset() {
- return mOffset;
- }
-
- @Override
- public int getColumn() {
- return mColumn;
- }
-
- @Override
- public PositionXmlParser.Position getEnd() {
- return mEnd;
- }
-
- @Override
- public void setEnd(@NonNull PositionXmlParser.Position end) {
- mEnd = end;
- }
-
- @Override
- public String toString() {
- return "OffsetPosition [line=" + mLine + ", column=" + mColumn + ", offset="
- + mOffset + ", end=" + mEnd + ']';
- }
- }
-
- @Override
- public void dispose(@NonNull XmlContext context, @NonNull Document document) {
- }
-
- /* Handle for creating DOM positions cheaply and returning full fledged locations later */
- private class LocationHandle implements Handle {
- private final File mFile;
- private final Node mNode;
- private Object mClientData;
-
- public LocationHandle(File file, Node node) {
- mFile = file;
- mNode = node;
- }
-
- @NonNull
- @Override
- public Location resolve() {
- OffsetPosition pos = (OffsetPosition) getPosition(mNode);
- if (pos != null) {
- return Location.create(mFile, pos, (OffsetPosition) pos.getEnd());
- }
-
- return Location.create(mFile);
- }
-
- @Override
- public void setClientData(@Nullable Object clientData) {
- mClientData = clientData;
- }
-
- @Override
- @Nullable
- public Object getClientData() {
- return mClientData;
- }
- }
-}
diff --git a/lint/cli/src/main/java/com/android/tools/lint/LombokParser.java b/lint/cli/src/main/java/com/android/tools/lint/LombokParser.java
deleted file mode 100644
index 26845a9..0000000
--- a/lint/cli/src/main/java/com/android/tools/lint/LombokParser.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.android.tools.lint.client.api.IJavaParser;
-import com.android.tools.lint.detector.api.JavaContext;
-import com.android.tools.lint.detector.api.Location;
-import com.android.tools.lint.detector.api.Location.Handle;
-
-import java.io.File;
-import java.util.List;
-
-import lombok.ast.CompilationUnit;
-import lombok.ast.Node;
-import lombok.ast.Position;
-import lombok.ast.grammar.ParseProblem;
-import lombok.ast.grammar.Source;
-
-/**
- * Java parser which uses the Lombok parser directly. This is a pretty slow parser
- * (2.5 times slower than javac, which in turn is about 3 times slower than EJC for
- * some benchmarks).
- */
-public class LombokParser implements IJavaParser {
-
- @Override
- public Node parseJava(@NonNull JavaContext context) {
- try {
- Source source = new Source(context.getContents(), context.file.getName());
- List<Node> nodes = source.getNodes();
-
- // Don't analyze files containing errors
- List<ParseProblem> problems = source.getProblems();
- if (problems != null && !problems.isEmpty()) {
- context.getDriver().setHasParserErrors(true);
-
- /* Silently ignore the errors. There are still some bugs in Lombok/Parboiled
- * (triggered if you run lint on the AOSP framework directory for example),
- * and having these show up as fatal errors when it's really a tool bug
- * is bad. To make matters worse, the error messages aren't clear:
- * http://code.google.com/p/projectlombok/issues/detail?id=313
- for (ParseProblem problem : problems) {
- Position position = problem.getPosition();
- Location location = Location.create(context.file,
- context.getContents(), position.getStart(), position.getEnd());
- // Sanitize the message?
- // See http://code.google.com/p/projectlombok/issues/detail?id=313
- String message = problem.getMessage();
- context.report(
- com.android.tools.lint.client.api.IssueRegistry.PARSER_ERROR, location,
- message,
- null);
-
- }
- */
- return null;
- }
-
- // There could be more than one node when there are errors; pick out the
- // compilation unit node
- for (Node node : nodes) {
- if (node instanceof CompilationUnit) {
- return node;
- }
- }
- return null;
- } catch (Throwable e) {
- /* Silently ignore the errors. There are still some bugs in Lombok/Parboiled
- * (triggered if you run lint on the AOSP framework directory for example),
- * and having these show up as fatal errors when it's really a tool bug
- * is bad. To make matters worse, the error messages aren't clear:
- * http://code.google.com/p/projectlombok/issues/detail?id=313
- context.report(
- IssueRegistry.PARSER_ERROR, Location.create(context.file),
- e.getCause() != null ? e.getCause().getLocalizedMessage() :
- e.getLocalizedMessage(),
- null);
- */
-
- return null;
- }
- }
-
- @NonNull
- @Override
- public Location getLocation(
- @NonNull JavaContext context,
- @NonNull Node node) {
- Position position = node.getPosition();
- return Location.create(context.file, context.getContents(),
- position.getStart(), position.getEnd());
- }
-
- @NonNull
- @Override
- public Handle createLocationHandle(@NonNull JavaContext context, @NonNull Node node) {
- return new LocationHandle(context.file, node);
- }
-
- @Override
- public void dispose(@NonNull JavaContext context, @NonNull Node compilationUnit) {
- }
-
- /* Handle for creating positions cheaply and returning full fledged locations later */
- private static class LocationHandle implements Handle {
- private final File mFile;
- private final Node mNode;
- private Object mClientData;
-
- public LocationHandle(File file, Node node) {
- mFile = file;
- mNode = node;
- }
-
- @NonNull
- @Override
- public Location resolve() {
- Position pos = mNode.getPosition();
- return Location.create(mFile, null /*contents*/, pos.getStart(), pos.getEnd());
- }
-
-
- @Override
- public void setClientData(@Nullable Object clientData) {
- mClientData = clientData;
- }
-
- @Override
- @Nullable
- public Object getClientData() {
- return mClientData;
- }
- }
-}
diff --git a/lint/cli/src/main/java/com/android/tools/lint/Main.java b/lint/cli/src/main/java/com/android/tools/lint/Main.java
deleted file mode 100644
index c53469e..0000000
--- a/lint/cli/src/main/java/com/android/tools/lint/Main.java
+++ /dev/null
@@ -1,1459 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint;
-
-import static com.android.SdkConstants.DOT_XML;
-import static com.android.tools.lint.client.api.IssueRegistry.LINT_ERROR;
-import static com.android.tools.lint.client.api.IssueRegistry.PARSER_ERROR;
-import static com.android.tools.lint.detector.api.LintUtils.endsWith;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.android.annotations.VisibleForTesting;
-import com.android.tools.lint.checks.BuiltinIssueRegistry;
-import com.android.tools.lint.client.api.Configuration;
-import com.android.tools.lint.client.api.DefaultConfiguration;
-import com.android.tools.lint.client.api.IDomParser;
-import com.android.tools.lint.client.api.IJavaParser;
-import com.android.tools.lint.client.api.IssueRegistry;
-import com.android.tools.lint.client.api.LintClient;
-import com.android.tools.lint.client.api.LintDriver;
-import com.android.tools.lint.client.api.LintListener;
-import com.android.tools.lint.detector.api.Category;
-import com.android.tools.lint.detector.api.Context;
-import com.android.tools.lint.detector.api.Issue;
-import com.android.tools.lint.detector.api.LintUtils;
-import com.android.tools.lint.detector.api.Location;
-import com.android.tools.lint.detector.api.Position;
-import com.android.tools.lint.detector.api.Project;
-import com.android.tools.lint.detector.api.Severity;
-import com.android.utils.SdkUtils;
-import com.google.common.base.Splitter;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.io.Closeables;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintStream;
-import java.io.PrintWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-/**
- * Command line driver for the lint framework
- */
-public class Main extends LintClient {
- static final int MAX_LINE_WIDTH = 78;
- private static final String ARG_ENABLE = "--enable"; //$NON-NLS-1$
- private static final String ARG_DISABLE = "--disable"; //$NON-NLS-1$
- private static final String ARG_CHECK = "--check"; //$NON-NLS-1$
- private static final String ARG_IGNORE = "--ignore"; //$NON-NLS-1$
- private static final String ARG_LISTIDS = "--list"; //$NON-NLS-1$
- private static final String ARG_SHOW = "--show"; //$NON-NLS-1$
- private static final String ARG_QUIET = "--quiet"; //$NON-NLS-1$
- private static final String ARG_FULLPATH = "--fullpath"; //$NON-NLS-1$
- private static final String ARG_SHOWALL = "--showall"; //$NON-NLS-1$
- private static final String ARG_HELP = "--help"; //$NON-NLS-1$
- private static final String ARG_NOLINES = "--nolines"; //$NON-NLS-1$
- private static final String ARG_HTML = "--html"; //$NON-NLS-1$
- private static final String ARG_SIMPLEHTML = "--simplehtml"; //$NON-NLS-1$
- private static final String ARG_XML = "--xml"; //$NON-NLS-1$
- private static final String ARG_TEXT = "--text"; //$NON-NLS-1$
- private static final String ARG_CONFIG = "--config"; //$NON-NLS-1$
- private static final String ARG_URL = "--url"; //$NON-NLS-1$
- private static final String ARG_VERSION = "--version"; //$NON-NLS-1$
- private static final String ARG_EXITCODE = "--exitcode"; //$NON-NLS-1$
- private static final String ARG_CLASSES = "--classpath"; //$NON-NLS-1$
- private static final String ARG_SOURCES = "--sources"; //$NON-NLS-1$
- private static final String ARG_RESOURCES = "--resources"; //$NON-NLS-1$
- private static final String ARG_LIBRARIES = "--libraries"; //$NON-NLS-1$
-
- private static final String ARG_NOWARN2 = "--nowarn"; //$NON-NLS-1$
- // GCC style flag names for options
- private static final String ARG_NOWARN1 = "-w"; //$NON-NLS-1$
- private static final String ARG_WARNALL = "-Wall"; //$NON-NLS-1$
- private static final String ARG_ALLERROR = "-Werror"; //$NON-NLS-1$
-
- private static final String VALUE_NONE = "none"; //$NON-NLS-1$
-
- private static final String PROP_WORK_DIR = "com.android.tools.lint.workdir"; //$NON-NLS-1$
-
- private static final int ERRNO_ERRORS = 1;
- private static final int ERRNO_USAGE = 2;
- private static final int ERRNO_EXISTS = 3;
- private static final int ERRNO_HELP = 4;
- private static final int ERRNO_INVALIDARGS = 5;
-
- protected final List<Warning> mWarnings = new ArrayList<Warning>();
- protected final Set<String> mSuppress = new HashSet<String>();
- protected final Set<String> mEnabled = new HashSet<String>();
- /** If non-null, only run the specified checks (possibly modified by enable/disables) */
- protected Set<String> mCheck = null;
- protected boolean mHasErrors;
- protected boolean mSetExitCode;
- protected boolean mFullPath;
- protected int mErrorCount;
- protected int mWarningCount;
- protected boolean mShowLines = true;
- protected final List<Reporter> mReporters = Lists.newArrayList();
- protected boolean mQuiet;
- protected boolean mWarnAll;
- protected boolean mNoWarnings;
- protected boolean mAllErrors;
- protected List<File> mSources;
- protected List<File> mClasses;
- protected List<File> mLibraries;
- protected List<File> mResources;
-
- protected Configuration mDefaultConfiguration;
- protected IssueRegistry mRegistry;
- protected LintDriver mDriver;
- protected boolean mShowAll;
-
- /** Creates a CLI driver */
- public Main() {
- }
-
- /**
- * Runs the static analysis command line driver
- *
- * @param args program arguments
- */
- public static void main(String[] args) {
- new Main().run(args);
- }
-
- /**
- * Runs the static analysis command line driver
- *
- * @param args program arguments
- */
- public void run(String[] args) {
- if (args.length < 1) {
- printUsage(System.err);
- System.exit(ERRNO_USAGE);
- }
-
- IssueRegistry registry = mRegistry = new BuiltinIssueRegistry();
-
- // Mapping from file path prefix to URL. Applies only to HTML reports
- String urlMap = null;
-
- List<File> files = new ArrayList<File>();
- for (int index = 0; index < args.length; index++) {
- String arg = args[index];
-
- if (arg.equals(ARG_HELP)
- || arg.equals("-h") || arg.equals("-?")) { //$NON-NLS-1$ //$NON-NLS-2$
- if (index < args.length - 1) {
- String topic = args[index + 1];
- if (topic.equals("suppress") || topic.equals("ignore")) {
- printHelpTopicSuppress();
- System.exit(ERRNO_HELP);
- } else {
- System.err.println(String.format("Unknown help topic \"%1$s\"", topic));
- System.exit(ERRNO_INVALIDARGS);
- }
- }
- printUsage(System.out);
- System.exit(ERRNO_HELP);
- } else if (arg.equals(ARG_LISTIDS)) {
- // Did the user provide a category list?
- if (index < args.length - 1 && !args[index + 1].startsWith("-")) { //$NON-NLS-1$
- String[] ids = args[++index].split(",");
- for (String id : ids) {
- if (registry.isCategoryName(id)) {
- // List all issues with the given category
- String category = id;
- for (Issue issue : registry.getIssues()) {
- // Check prefix such that filtering on the "Usability" category
- // will match issue category "Usability:Icons" etc.
- if (issue.getCategory().getName().startsWith(category) ||
- issue.getCategory().getFullName().startsWith(category)) {
- listIssue(System.out, issue);
- }
- }
- } else {
- System.err.println("Invalid category \"" + id + "\".\n");
- displayValidIds(registry, System.err);
- System.exit(ERRNO_INVALIDARGS);
- }
- }
- } else {
- displayValidIds(registry, System.out);
- }
- System.exit(0);
- } else if (arg.equals(ARG_SHOW)) {
- // Show specific issues?
- if (index < args.length - 1 && !args[index + 1].startsWith("-")) { //$NON-NLS-1$
- String[] ids = args[++index].split(",");
- for (String id : ids) {
- if (registry.isCategoryName(id)) {
- // Show all issues in the given category
- String category = id;
- for (Issue issue : registry.getIssues()) {
- // Check prefix such that filtering on the "Usability" category
- // will match issue category "Usability:Icons" etc.
- if (issue.getCategory().getName().startsWith(category) ||
- issue.getCategory().getFullName().startsWith(category)) {
- describeIssue(issue);
- System.out.println();
- }
- }
- } else if (registry.isIssueId(id)) {
- describeIssue(registry.getIssue(id));
- System.out.println();
- } else {
- System.err.println("Invalid id or category \"" + id + "\".\n");
- displayValidIds(registry, System.err);
- System.exit(ERRNO_INVALIDARGS);
- }
- }
- } else {
- showIssues(registry);
- }
- System.exit(0);
- } else if (arg.equals(ARG_FULLPATH)
- || arg.equals(ARG_FULLPATH + "s")) { // allow "--fullpaths" too
- mFullPath = true;
- } else if (arg.equals(ARG_SHOWALL)) {
- mShowAll = true;
- } else if (arg.equals(ARG_QUIET) || arg.equals("-q")) {
- mQuiet = true;
- } else if (arg.equals(ARG_NOLINES)) {
- mShowLines = false;
- } else if (arg.equals(ARG_EXITCODE)) {
- mSetExitCode = true;
- } else if (arg.equals(ARG_VERSION)) {
- printVersion();
- System.exit(0);
- } else if (arg.equals(ARG_URL)) {
- if (index == args.length - 1) {
- System.err.println("Missing URL mapping string");
- System.exit(ERRNO_INVALIDARGS);
- }
- String map = args[++index];
- // Allow repeated usage of the argument instead of just comma list
- if (urlMap != null) {
- urlMap = urlMap + ',' + map;
- } else {
- urlMap = map;
- }
- } else if (arg.equals(ARG_CONFIG)) {
- if (index == args.length - 1 || !endsWith(args[index + 1], DOT_XML)) {
- System.err.println("Missing XML configuration file argument");
- System.exit(ERRNO_INVALIDARGS);
- }
- File file = getInArgumentPath(args[++index]);
- if (!file.exists()) {
- System.err.println(file.getAbsolutePath() + " does not exist");
- System.exit(ERRNO_INVALIDARGS);
- }
- mDefaultConfiguration = new CliConfiguration(file);
- } else if (arg.equals(ARG_HTML) || arg.equals(ARG_SIMPLEHTML)) {
- if (index == args.length - 1) {
- System.err.println("Missing HTML output file name");
- System.exit(ERRNO_INVALIDARGS);
- }
- File output = getOutArgumentPath(args[++index]);
- // Get an absolute path such that we can ask its parent directory for
- // write permission etc.
- output = output.getAbsoluteFile();
- if (output.isDirectory() ||
- (!output.exists() && output.getName().indexOf('.') == -1)) {
- if (!output.exists()) {
- boolean mkdirs = output.mkdirs();
- if (!mkdirs) {
- log(null, "Could not create output directory %1$s", output);
- System.exit(ERRNO_EXISTS);
- }
- }
- try {
- MultiProjectHtmlReporter reporter =
- new MultiProjectHtmlReporter(this, output);
- if (arg.equals(ARG_SIMPLEHTML)) {
- reporter.setSimpleFormat(true);
- }
- mReporters.add(reporter);
- } catch (IOException e) {
- log(e, null);
- System.exit(ERRNO_INVALIDARGS);
- }
- continue;
- }
- if (output.exists()) {
- boolean delete = output.delete();
- if (!delete) {
- System.err.println("Could not delete old " + output);
- System.exit(ERRNO_EXISTS);
- }
- }
- if (output.getParentFile() != null && !output.getParentFile().canWrite()) {
- System.err.println("Cannot write HTML output file " + output);
- System.exit(ERRNO_EXISTS);
- }
- try {
- HtmlReporter htmlReporter = new HtmlReporter(this, output);
- if (arg.equals(ARG_SIMPLEHTML)) {
- htmlReporter.setSimpleFormat(true);
- }
- mReporters.add(htmlReporter);
- } catch (IOException e) {
- log(e, null);
- System.exit(ERRNO_INVALIDARGS);
- }
- } else if (arg.equals(ARG_XML)) {
- if (index == args.length - 1) {
- System.err.println("Missing XML output file name");
- System.exit(ERRNO_INVALIDARGS);
- }
- File output = getOutArgumentPath(args[++index]);
- if (output.exists()) {
- boolean delete = output.delete();
- if (!delete) {
- System.err.println("Could not delete old " + output);
- System.exit(ERRNO_EXISTS);
- }
- }
- if (output.canWrite()) {
- System.err.println("Cannot write XML output file " + output);
- System.exit(ERRNO_EXISTS);
- }
- try {
- mReporters.add(new XmlReporter(this, output));
- } catch (IOException e) {
- log(e, null);
- System.exit(ERRNO_INVALIDARGS);
- }
- } else if (arg.equals(ARG_TEXT)) {
- if (index == args.length - 1) {
- System.err.println("Missing XML output file name");
- System.exit(ERRNO_INVALIDARGS);
- }
-
- Writer writer = null;
- boolean closeWriter;
- String outputName = args[++index];
- if (outputName.equals("stdout")) { //$NON-NLS-1$
- writer = new PrintWriter(System.out, true);
- closeWriter = false;
- } else {
- File output = getOutArgumentPath(outputName);
- if (output.exists()) {
- boolean delete = output.delete();
- if (!delete) {
- System.err.println("Could not delete old " + output);
- System.exit(ERRNO_EXISTS);
- }
- }
- if (output.canWrite()) {
- System.err.println("Cannot write XML output file " + output);
- System.exit(ERRNO_EXISTS);
- }
- try {
- writer = new BufferedWriter(new FileWriter(output));
- } catch (IOException e) {
- log(e, null);
- System.exit(ERRNO_INVALIDARGS);
- }
- closeWriter = true;
- }
- mReporters.add(new TextReporter(this, writer, closeWriter));
- } else if (arg.equals(ARG_DISABLE) || arg.equals(ARG_IGNORE)) {
- if (index == args.length - 1) {
- System.err.println("Missing categories or id's to disable");
- System.exit(ERRNO_INVALIDARGS);
- }
- String[] ids = args[++index].split(",");
- for (String id : ids) {
- if (registry.isCategoryName(id)) {
- // Suppress all issues with the given category
- String category = id;
- for (Issue issue : registry.getIssues()) {
- // Check prefix such that filtering on the "Usability" category
- // will match issue category "Usability:Icons" etc.
- if (issue.getCategory().getName().startsWith(category) ||
- issue.getCategory().getFullName().startsWith(category)) {
- mSuppress.add(issue.getId());
- }
- }
- } else if (!registry.isIssueId(id)) {
- System.err.println("Invalid id or category \"" + id + "\".\n");
- displayValidIds(registry, System.err);
- System.exit(ERRNO_INVALIDARGS);
- } else {
- mSuppress.add(id);
- }
- }
- } else if (arg.equals(ARG_ENABLE)) {
- if (index == args.length - 1) {
- System.err.println("Missing categories or id's to enable");
- System.exit(ERRNO_INVALIDARGS);
- }
- String[] ids = args[++index].split(",");
- for (String id : ids) {
- if (registry.isCategoryName(id)) {
- // Enable all issues with the given category
- String category = id;
- for (Issue issue : registry.getIssues()) {
- if (issue.getCategory().getName().startsWith(category) ||
- issue.getCategory().getFullName().startsWith(category)) {
- mEnabled.add(issue.getId());
- }
- }
- } else if (!registry.isIssueId(id)) {
- System.err.println("Invalid id or category \"" + id + "\".\n");
- displayValidIds(registry, System.err);
- System.exit(ERRNO_INVALIDARGS);
- } else {
- mEnabled.add(id);
- }
- }
- } else if (arg.equals(ARG_CHECK)) {
- if (index == args.length - 1) {
- System.err.println("Missing categories or id's to check");
- System.exit(ERRNO_INVALIDARGS);
- }
- mCheck = new HashSet<String>();
- String[] ids = args[++index].split(",");
- for (String id : ids) {
- if (registry.isCategoryName(id)) {
- // Check all issues with the given category
- String category = id;
- for (Issue issue : registry.getIssues()) {
- // Check prefix such that filtering on the "Usability" category
- // will match issue category "Usability:Icons" etc.
- if (issue.getCategory().getName().startsWith(category) ||
- issue.getCategory().getFullName().startsWith(category)) {
- mCheck.add(issue.getId());
- }
- }
- } else if (!registry.isIssueId(id)) {
- System.err.println("Invalid id or category \"" + id + "\".\n");
- displayValidIds(registry, System.err);
- System.exit(ERRNO_INVALIDARGS);
- } else {
- mCheck.add(id);
- }
- }
- } else if (arg.equals(ARG_NOWARN1) || arg.equals(ARG_NOWARN2)) {
- mNoWarnings = true;
- } else if (arg.equals(ARG_WARNALL)) {
- mWarnAll = true;
- } else if (arg.equals(ARG_ALLERROR)) {
- mAllErrors = true;
- } else if (arg.equals(ARG_CLASSES)) {
- if (index == args.length - 1) {
- System.err.println("Missing class folder name");
- System.exit(ERRNO_INVALIDARGS);
- }
- String paths = args[++index];
- for (String path : LintUtils.splitPath(paths)) {
- File input = getInArgumentPath(path);
- if (!input.exists()) {
- System.err.println("Class path entry " + input + " does not exist.");
- System.exit(ERRNO_INVALIDARGS);
- }
- if (mClasses == null) {
- mClasses = new ArrayList<File>();
- }
- mClasses.add(input);
- }
- } else if (arg.equals(ARG_SOURCES)) {
- if (index == args.length - 1) {
- System.err.println("Missing source folder name");
- System.exit(ERRNO_INVALIDARGS);
- }
- String paths = args[++index];
- for (String path : LintUtils.splitPath(paths)) {
- File input = getInArgumentPath(path);
- if (!input.exists()) {
- System.err.println("Source folder " + input + " does not exist.");
- System.exit(ERRNO_INVALIDARGS);
- }
- if (mSources == null) {
- mSources = new ArrayList<File>();
- }
- mSources.add(input);
- }
- } else if (arg.equals(ARG_RESOURCES)) {
- if (index == args.length - 1) {
- System.err.println("Missing resource folder name");
- System.exit(ERRNO_INVALIDARGS);
- }
- String paths = args[++index];
- for (String path : LintUtils.splitPath(paths)) {
- File input = getInArgumentPath(path);
- if (!input.exists()) {
- System.err.println("Resource folder " + input + " does not exist.");
- System.exit(ERRNO_INVALIDARGS);
- }
- if (mResources == null) {
- mResources = new ArrayList<File>();
- }
- mResources.add(input);
- }
- } else if (arg.equals(ARG_LIBRARIES)) {
- if (index == args.length - 1) {
- System.err.println("Missing library folder name");
- System.exit(ERRNO_INVALIDARGS);
- }
- String paths = args[++index];
- for (String path : LintUtils.splitPath(paths)) {
- File input = getInArgumentPath(path);
- if (!input.exists()) {
- System.err.println("Library " + input + " does not exist.");
- System.exit(ERRNO_INVALIDARGS);
- }
- if (mLibraries == null) {
- mLibraries = new ArrayList<File>();
- }
- mLibraries.add(input);
- }
- } else if (arg.startsWith("--")) {
- System.err.println("Invalid argument " + arg + "\n");
- printUsage(System.err);
- System.exit(ERRNO_INVALIDARGS);
- } else {
- String filename = arg;
- File file = getInArgumentPath(filename);
-
- if (!file.exists()) {
- System.err.println(String.format("%1$s does not exist.", filename));
- System.exit(ERRNO_EXISTS);
- }
- files.add(file);
- }
- }
-
- if (files.isEmpty()) {
- System.err.println("No files to analyze.");
- System.exit(ERRNO_INVALIDARGS);
- } else if (files.size() > 1
- && (mClasses != null || mSources != null || mLibraries != null
- || mResources != null)) {
- System.err.println(String.format(
- "The %1$s, %2$s, %3$s and %4$s arguments can only be used with a single project",
- ARG_SOURCES, ARG_CLASSES, ARG_LIBRARIES, ARG_RESOURCES));
- System.exit(ERRNO_INVALIDARGS);
- }
-
- if (mReporters.isEmpty()) {
- if (urlMap != null) {
- System.err.println(String.format(
- "Warning: The %1$s option only applies to HTML reports (%2$s)",
- ARG_URL, ARG_HTML));
- }
-
- mReporters.add(new TextReporter(this, new PrintWriter(System.out, true), false));
- } else {
- if (urlMap == null) {
- // By default just map from /foo to file:///foo
- // TODO: Find out if we need file:// on Windows.
- urlMap = "=file://"; //$NON-NLS-1$
- } else {
- for (Reporter reporter : mReporters) {
- if (!reporter.isSimpleFormat()) {
- reporter.setBundleResources(true);
- }
- }
- }
-
- if (!urlMap.equals(VALUE_NONE)) {
- Map<String, String> map = new HashMap<String, String>();
- String[] replace = urlMap.split(","); //$NON-NLS-1$
- for (String s : replace) {
- // Allow ='s in the suffix part
- int index = s.indexOf('=');
- if (index == -1) {
- System.err.println(
- "The URL map argument must be of the form 'path_prefix=url_prefix'");
- System.exit(ERRNO_INVALIDARGS);
- }
- String key = s.substring(0, index);
- String value = s.substring(index + 1);
- map.put(key, value);
- }
- for (Reporter reporter : mReporters) {
- reporter.setUrlMap(map);
- }
- }
- }
-
- mDriver = new LintDriver(registry, this);
-
- mDriver.setAbbreviating(!mShowAll);
- if (!mQuiet) {
- mDriver.addLintListener(new ProgressPrinter());
- }
-
- mDriver.analyze(files, null /* scope */);
-
- Collections.sort(mWarnings);
-
- for (Reporter reporter : mReporters) {
- try {
- reporter.write(mErrorCount, mWarningCount, mWarnings);
- } catch (IOException e) {
- log(e, null);
- System.exit(ERRNO_INVALIDARGS);
- }
- }
-
- System.exit(mSetExitCode ? (mHasErrors ? ERRNO_ERRORS : 0) : 0);
- }
-
- /**
- * Converts a relative or absolute command-line argument into an input file.
- *
- * @param filename The filename given as a command-line argument.
- * @return A File matching filename, either absolute or relative to lint.workdir if defined.
- */
- private static File getInArgumentPath(String filename) {
- File file = new File(filename);
-
- if (!file.isAbsolute()) {
- File workDir = getLintWorkDir();
- if (workDir != null) {
- File file2 = new File(workDir, filename);
- if (file2.exists()) {
- try {
- file = file2.getCanonicalFile();
- } catch (IOException e) {
- file = file2;
- }
- }
- }
- }
- return file;
- }
-
- /**
- * Converts a relative or absolute command-line argument into an output file.
- * <p/>
- * The difference with {@code getInArgumentPath} is that we can't check whether the
- * a relative path turned into an absolute compared to lint.workdir actually exists.
- *
- * @param filename The filename given as a command-line argument.
- * @return A File matching filename, either absolute or relative to lint.workdir if defined.
- */
- private static File getOutArgumentPath(String filename) {
- File file = new File(filename);
-
- if (!file.isAbsolute()) {
- File workDir = getLintWorkDir();
- if (workDir != null) {
- File file2 = new File(workDir, filename);
- try {
- file = file2.getCanonicalFile();
- } catch (IOException e) {
- file = file2;
- }
- }
- }
- return file;
- }
-
-
- /**
- * Returns the File corresponding to the system property or the environment variable
- * for {@link #PROP_WORK_DIR}.
- * This property is typically set by the SDK/tools/lint[.bat] wrapper.
- * It denotes the path where the command-line client was originally invoked from
- * and can be used to convert relative input/output paths.
- *
- * @return A new File corresponding to {@link #PROP_WORK_DIR} or null.
- */
- @Nullable
- private static File getLintWorkDir() {
- // First check the Java properties (e.g. set using "java -jar ... -Dname=value")
- String path = System.getProperty(PROP_WORK_DIR);
- if (path == null || path.isEmpty()) {
- // If not found, check environment variables.
- path = System.getenv(PROP_WORK_DIR);
- }
- if (path != null && !path.isEmpty()) {
- return new File(path);
- }
- return null;
- }
-
- private static void printHelpTopicSuppress() {
- System.out.println(wrap(getSuppressHelp()));
- }
-
- static String getSuppressHelp() {
- return
- "Lint errors can be suppressed in a variety of ways:\n" +
- "\n" +
- "1. With a @SuppressLint annotation in the Java code\n" +
- "2. With a tools:ignore attribute in the XML file\n" +
- "3. With a lint.xml configuration file in the project\n" +
- "4. With a lint.xml configuration file passed to lint " +
- "via the " + ARG_CONFIG + " flag\n" +
- "5. With the " + ARG_IGNORE + " flag passed to lint.\n" +
- "\n" +
- "To suppress a lint warning with an annotation, add " +
- "a @SuppressLint(\"id\") annotation on the class, method " +
- "or variable declaration closest to the warning instance " +
- "you want to disable. The id can be one or more issue " +
- "id's, such as \"UnusedResources\" or {\"UnusedResources\"," +
- "\"UnusedIds\"}, or it can be \"all\" to suppress all lint " +
- "warnings in the given scope.\n" +
- "\n" +
- "To suppress a lint warning in an XML file, add a " +
- "tools:ignore=\"id\" attribute on the element containing " +
- "the error, or one of its surrounding elements. You also " +
- "need to define the namespace for the tools prefix on the " +
- "root element in your document, next to the xmlns:android " +
- "declaration:\n" +
- "* xmlns:tools=\"http://schemas.android.com/tools\"\n" +
- "\n" +
- "To suppress lint warnings with a configuration XML file, " +
- "create a file named lint.xml and place it at the root " +
- "directory of the project in which it applies. (If you " +
- "use the Eclipse plugin's Lint view, you can suppress " +
- "errors there via the toolbar and Eclipse will create the " +
- "lint.xml file for you.).\n" +
- "\n" +
- "The format of the lint.xml file is something like the " +
- "following:\n" +
- "\n" +
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<lint>\n" +
- " <!-- Disable this given check in this project -->\n" +
- " <issue id=\"IconMissingDensityFolder\" severity=\"ignore\" />\n" +
- "\n" +
- " <!-- Ignore the ObsoleteLayoutParam issue in the given files -->\n" +
- " <issue id=\"ObsoleteLayoutParam\">\n" +
- " <ignore path=\"res/layout/activation.xml\" />\n" +
- " <ignore path=\"res/layout-xlarge/activation.xml\" />\n" +
- " </issue>\n" +
- "\n" +
- " <!-- Ignore the UselessLeaf issue in the given file -->\n" +
- " <issue id=\"UselessLeaf\">\n" +
- " <ignore path=\"res/layout/main.xml\" />\n" +
- " </issue>\n" +
- "\n" +
- " <!-- Change the severity of hardcoded strings to \"error\" -->\n" +
- " <issue id=\"HardcodedText\" severity=\"error\" />\n" +
- "</lint>\n" +
- "\n" +
- "To suppress lint checks from the command line, pass the " + ARG_IGNORE + " " +
- "flag with a comma separated list of ids to be suppressed, such as:\n" +
- "\"lint --ignore UnusedResources,UselessLeaf /my/project/path\"\n";
- }
-
- private void printVersion() {
- String revision = getRevision();
- if (revision != null) {
- System.out.println(String.format("lint: version %1$s", revision));
- } else {
- System.out.println("lint: unknown version");
- }
- }
-
- @SuppressWarnings("resource") // Eclipse doesn't know about Closeables.closeQuietly
- @Nullable
- String getRevision() {
- File file = findResource("tools" + File.separator + //$NON-NLS-1$
- "source.properties"); //$NON-NLS-1$
- if (file != null && file.exists()) {
- FileInputStream input = null;
- try {
- input = new FileInputStream(file);
- Properties properties = new Properties();
- properties.load(input);
-
- String revision = properties.getProperty("Pkg.Revision"); //$NON-NLS-1$
- if (revision != null && !revision.isEmpty()) {
- return revision;
- }
- } catch (IOException e) {
- // Couldn't find or read the version info: just print out unknown below
- } finally {
- Closeables.closeQuietly(input);
- }
- }
-
- return null;
- }
-
- private static void displayValidIds(IssueRegistry registry, PrintStream out) {
- List<Category> categories = registry.getCategories();
- out.println("Valid issue categories:");
- for (Category category : categories) {
- out.println(" " + category.getFullName());
- }
- out.println();
- List<Issue> issues = registry.getIssues();
- out.println("Valid issue id's:");
- for (Issue issue : issues) {
- listIssue(out, issue);
- }
- }
-
- private static void listIssue(PrintStream out, Issue issue) {
- out.print(wrapArg("\"" + issue.getId() + "\": " + issue.getDescription()));
- }
-
- private static void showIssues(IssueRegistry registry) {
- List<Issue> issues = registry.getIssues();
- List<Issue> sorted = new ArrayList<Issue>(issues);
- Collections.sort(sorted, new Comparator<Issue>() {
- @Override
- public int compare(Issue issue1, Issue issue2) {
- int d = issue1.getCategory().compareTo(issue2.getCategory());
- if (d != 0) {
- return d;
- }
- d = issue2.getPriority() - issue1.getPriority();
- if (d != 0) {
- return d;
- }
-
- return issue1.getId().compareTo(issue2.getId());
- }
- });
-
- System.out.println("Available issues:\n");
- Category previousCategory = null;
- for (Issue issue : sorted) {
- Category category = issue.getCategory();
- if (!category.equals(previousCategory)) {
- String name = category.getFullName();
- System.out.println(name);
- for (int i = 0, n = name.length(); i < n; i++) {
- System.out.print('=');
- }
- System.out.println('\n');
- previousCategory = category;
- }
-
- describeIssue(issue);
- System.out.println();
- }
- }
-
- private static void describeIssue(Issue issue) {
- System.out.println(issue.getId());
- for (int i = 0; i < issue.getId().length(); i++) {
- System.out.print('-');
- }
- System.out.println();
- System.out.println(wrap("Summary: " + issue.getDescription()));
- System.out.println("Priority: " + issue.getPriority() + " / 10");
- System.out.println("Severity: " + issue.getDefaultSeverity().getDescription());
- System.out.println("Category: " + issue.getCategory().getFullName());
-
- if (!issue.isEnabledByDefault()) {
- System.out.println("NOTE: This issue is disabled by default!");
- System.out.println(String.format("You can enable it by adding %1$s %2$s", ARG_ENABLE,
- issue.getId()));
- }
-
- if (issue.getExplanation() != null) {
- System.out.println();
- System.out.println(wrap(issue.getExplanationAsSimpleText()));
- }
- if (issue.getMoreInfo() != null) {
- System.out.println("More information: " + issue.getMoreInfo());
- }
- }
-
- static String wrapArg(String explanation) {
- // Wrap arguments such that the wrapped lines are not showing up in the left column
- return wrap(explanation, MAX_LINE_WIDTH, " ");
- }
-
- static String wrap(String explanation) {
- return wrap(explanation, MAX_LINE_WIDTH, "");
- }
-
- static String wrap(String explanation, int lineWidth, String hangingIndent) {
- return SdkUtils.wrap(explanation, lineWidth, hangingIndent);
- }
-
- private static void printUsage(PrintStream out) {
- // TODO: Look up launcher script name!
- String command = "lint"; //$NON-NLS-1$
-
- out.println("Usage: " + command + " [flags] <project directories>\n");
- out.println("Flags:\n");
-
- printUsage(out, new String[] {
- ARG_HELP, "This message.",
- ARG_HELP + " <topic>", "Help on the given topic, such as \"suppress\".",
- ARG_LISTIDS, "List the available issue id's and exit.",
- ARG_VERSION, "Output version information and exit.",
- ARG_EXITCODE, "Set the exit code to " + ERRNO_ERRORS + " if errors are found.",
- ARG_SHOW, "List available issues along with full explanations.",
- ARG_SHOW + " <ids>", "Show full explanations for the given list of issue id's.",
-
- "", "\nEnabled Checks:",
- ARG_DISABLE + " <list>", "Disable the list of categories or " +
- "specific issue id's. The list should be a comma-separated list of issue " +
- "id's or categories.",
- ARG_ENABLE + " <list>", "Enable the specific list of issues. " +
- "This checks all the default issues plus the specifically enabled issues. The " +
- "list should be a comma-separated list of issue id's or categories.",
- ARG_CHECK + " <list>", "Only check the specific list of issues. " +
- "This will disable everything and re-enable the given list of issues. " +
- "The list should be a comma-separated list of issue id's or categories.",
- ARG_NOWARN1 + ", " + ARG_NOWARN2, "Only check for errors (ignore warnings)",
- ARG_WARNALL, "Check all warnings, including those off by default",
- ARG_ALLERROR, "Treat all warnings as errors",
- ARG_CONFIG + " <filename>", "Use the given configuration file to " +
- "determine whether issues are enabled or disabled. If a project contains " +
- "a lint.xml file, then this config file will be used as a fallback.",
-
-
- "", "\nOutput Options:",
- ARG_QUIET, "Don't show progress.",
- ARG_FULLPATH, "Use full paths in the error output.",
- ARG_SHOWALL, "Do not truncate long messages, lists of alternate locations, etc.",
- ARG_NOLINES, "Do not include the source file lines with errors " +
- "in the output. By default, the error output includes snippets of source code " +
- "on the line containing the error, but this flag turns it off.",
- ARG_HTML + " <filename>", "Create an HTML report instead. If the filename is a " +
- "directory (or a new filename without an extension), lint will create a " +
- "separate report for each scanned project.",
- ARG_URL + " filepath=url", "Add links to HTML report, replacing local " +
- "path prefixes with url prefix. The mapping can be a comma-separated list of " +
- "path prefixes to corresponding URL prefixes, such as " +
- "C:\\temp\\Proj1=http://buildserver/sources/temp/Proj1. To turn off linking " +
- "to files, use " + ARG_URL + " " + VALUE_NONE,
- ARG_SIMPLEHTML + " <filename>", "Create a simple HTML report",
- ARG_XML + " <filename>", "Create an XML report instead.",
-
- "", "\nProject Options:",
- ARG_RESOURCES + " <dir>", "Add the given folder (or path) as a resource directory " +
- "for the project. Only valid when running lint on a single project.",
- ARG_SOURCES + " <dir>", "Add the given folder (or path) as a source directory for " +
- "the project. Only valid when running lint on a single project.",
- ARG_CLASSES + " <dir>", "Add the given folder (or jar file, or path) as a class " +
- "directory for the project. Only valid when running lint on a single project.",
- ARG_LIBRARIES + " <dir>", "Add the given folder (or jar file, or path) as a class " +
- "library for the project. Only valid when running lint on a single project.",
-
- "", "\nExit Status:",
- "0", "Success.",
- Integer.toString(ERRNO_ERRORS), "Lint errors detected.",
- Integer.toString(ERRNO_USAGE), "Lint usage.",
- Integer.toString(ERRNO_EXISTS), "Cannot clobber existing file.",
- Integer.toString(ERRNO_HELP), "Lint help.",
- Integer.toString(ERRNO_INVALIDARGS), "Invalid command-line argument.",
- });
- }
-
- private static void printUsage(PrintStream out, String[] args) {
- int argWidth = 0;
- for (int i = 0; i < args.length; i += 2) {
- String arg = args[i];
- argWidth = Math.max(argWidth, arg.length());
- }
- argWidth += 2;
- StringBuilder sb = new StringBuilder(20);
- for (int i = 0; i < argWidth; i++) {
- sb.append(' ');
- }
- String indent = sb.toString();
- String formatString = "%1$-" + argWidth + "s%2$s"; //$NON-NLS-1$
-
- for (int i = 0; i < args.length; i += 2) {
- String arg = args[i];
- String description = args[i + 1];
- if (arg.isEmpty()) {
- out.println(description);
- } else {
- out.print(wrap(String.format(formatString, arg, description),
- MAX_LINE_WIDTH, indent));
- }
- }
- }
-
- @Override
- public void log(
- @NonNull Severity severity,
- @Nullable Throwable exception,
- @Nullable String format,
- @Nullable Object... args) {
- System.out.flush();
- if (!mQuiet) {
- // Place the error message on a line of its own since we're printing '.' etc
- // with newlines during analysis
- System.err.println();
- }
- if (format != null) {
- System.err.println(String.format(format, args));
- }
- if (exception != null) {
- exception.printStackTrace();
- }
- }
-
- @Override
- public IDomParser getDomParser() {
- return new LintCliXmlParser();
- }
-
- @Override
- public Configuration getConfiguration(@NonNull Project project) {
- return new CliConfiguration(mDefaultConfiguration, project);
- }
-
- /** File content cache */
- private final Map<File, String> mFileContents = new HashMap<File, String>(100);
-
- /** Read the contents of the given file, possibly cached */
- private String getContents(File file) {
- String s = mFileContents.get(file);
- if (s == null) {
- s = readFile(file);
- mFileContents.put(file, s);
- }
-
- return s;
- }
-
- @Override
- public IJavaParser getJavaParser() {
- return new LombokParser();
- }
-
- @Override
- public void report(
- @NonNull Context context,
- @NonNull Issue issue,
- @NonNull Severity severity,
- @Nullable Location location,
- @NonNull String message,
- @Nullable Object data) {
- assert context.isEnabled(issue);
-
- if (severity == Severity.IGNORE) {
- return;
- }
-
- if (severity == Severity.ERROR || severity == Severity.FATAL) {
- mHasErrors = true;
- mErrorCount++;
- } else {
- mWarningCount++;
- }
-
- Warning warning = new Warning(issue, message, severity, context.getProject(), data);
- mWarnings.add(warning);
-
- if (location != null) {
- warning.location = location;
- File file = location.getFile();
- if (file != null) {
- warning.file = file;
- warning.path = getDisplayPath(context.getProject(), file);
- }
-
- Position startPosition = location.getStart();
- if (startPosition != null) {
- int line = startPosition.getLine();
- warning.line = line;
- warning.offset = startPosition.getOffset();
- if (line >= 0) {
- if (context.file == location.getFile()) {
- warning.fileContents = context.getContents();
- }
- if (warning.fileContents == null) {
- warning.fileContents = getContents(location.getFile());
- }
-
- if (mShowLines) {
- // Compute error line contents
- warning.errorLine = getLine(warning.fileContents, line);
- if (warning.errorLine != null) {
- // Replace tabs with spaces such that the column
- // marker (^) lines up properly:
- warning.errorLine = warning.errorLine.replace('\t', ' ');
- int column = startPosition.getColumn();
- if (column < 0) {
- column = 0;
- for (int i = 0; i < warning.errorLine.length(); i++, column++) {
- if (!Character.isWhitespace(warning.errorLine.charAt(i))) {
- break;
- }
- }
- }
- StringBuilder sb = new StringBuilder(100);
- sb.append(warning.errorLine);
- sb.append('\n');
- for (int i = 0; i < column; i++) {
- sb.append(' ');
- }
-
- boolean displayCaret = true;
- Position endPosition = location.getEnd();
- if (endPosition != null) {
- int endLine = endPosition.getLine();
- int endColumn = endPosition.getColumn();
- if (endLine == line && endColumn > column) {
- for (int i = column; i < endColumn; i++) {
- sb.append('~');
- }
- displayCaret = false;
- }
- }
-
- if (displayCaret) {
- sb.append('^');
- }
- sb.append('\n');
- warning.errorLine = sb.toString();
- }
- }
- }
- }
- }
- }
-
- /** Look up the contents of the given line */
- static String getLine(String contents, int line) {
- int index = getLineOffset(contents, line);
- if (index != -1) {
- return getLineOfOffset(contents, index);
- } else {
- return null;
- }
- }
-
- static String getLineOfOffset(String contents, int offset) {
- int end = contents.indexOf('\n', offset);
- if (end == -1) {
- end = contents.indexOf('\r', offset);
- }
- return contents.substring(offset, end != -1 ? end : contents.length());
- }
-
-
- /** Look up the contents of the given line */
- static int getLineOffset(String contents, int line) {
- int index = 0;
- for (int i = 0; i < line; i++) {
- index = contents.indexOf('\n', index);
- if (index == -1) {
- return -1;
- }
- index++;
- }
-
- return index;
- }
-
- @NonNull
- @Override
- public String readFile(@NonNull File file) {
- try {
- return LintUtils.getEncodedString(this, file);
- } catch (IOException e) {
- return ""; //$NON-NLS-1$
- }
- }
-
- boolean isCheckingSpecificIssues() {
- return mCheck != null;
- }
-
- private Map<Project, ClassPathInfo> mProjectInfo;
-
- @Override
- @NonNull
- protected ClassPathInfo getClassPath(@NonNull Project project) {
- ClassPathInfo classPath = super.getClassPath(project);
-
- if (mClasses == null && mSources == null && mLibraries == null) {
- return classPath;
- }
-
- ClassPathInfo info;
- if (mProjectInfo == null) {
- mProjectInfo = Maps.newHashMap();
- info = null;
- } else {
- info = mProjectInfo.get(project);
- }
-
- if (info == null) {
- List<File> sources;
- if (mSources != null) {
- sources = mSources;
- } else {
- sources = classPath.getSourceFolders();
- }
- List<File> classes;
- if (mClasses != null) {
- classes = mClasses;
- } else {
- classes = classPath.getClassFolders();
- }
- List<File> libraries;
- if (mLibraries != null) {
- libraries = mLibraries;
- } else {
- libraries = classPath.getLibraries();
- }
-
- info = new ClassPathInfo(sources, classes, libraries);
- mProjectInfo.put(project, info);
- }
-
- return info;
- }
-
- @NonNull
- @Override
- public List<File> getResourceFolders(@NonNull Project project) {
- if (mResources == null) {
- return super.getResourceFolders(project);
- }
-
- return mResources;
- }
-
- /**
- * Consult the lint.xml file, but override with the --enable and --disable
- * flags supplied on the command line
- */
- class CliConfiguration extends DefaultConfiguration {
- CliConfiguration(@NonNull Configuration parent, @NonNull Project project) {
- super(Main.this, project, parent);
- }
-
- CliConfiguration(File lintFile) {
- super(Main.this, null /*project*/, null /*parent*/, lintFile);
- }
-
- @NonNull
- @Override
- public Severity getSeverity(@NonNull Issue issue) {
- Severity severity = computeSeverity(issue);
-
- if (mAllErrors && severity != Severity.IGNORE) {
- severity = Severity.ERROR;
- }
-
- if (mNoWarnings && severity == Severity.WARNING) {
- severity = Severity.IGNORE;
- }
-
- return severity;
- }
-
- @NonNull
- @Override
- protected Severity getDefaultSeverity(@NonNull Issue issue) {
- if (mWarnAll) {
- return issue.getDefaultSeverity();
- }
-
- return super.getDefaultSeverity(issue);
- }
-
- private Severity computeSeverity(@NonNull Issue issue) {
- Severity severity = super.getSeverity(issue);
-
- String id = issue.getId();
- if (mSuppress.contains(id)) {
- return Severity.IGNORE;
- }
-
- if (mEnabled.contains(id) || (mCheck != null && mCheck.contains(id))) {
- // Overriding default
- // Detectors shouldn't be returning ignore as a default severity,
- // but in case they do, force it up to warning here to ensure that
- // it's run
- if (severity == Severity.IGNORE) {
- severity = issue.getDefaultSeverity();
- if (severity == Severity.IGNORE) {
- severity = Severity.WARNING;
- }
- }
-
- return severity;
- }
-
- if (mCheck != null && issue != LINT_ERROR && issue != PARSER_ERROR) {
- return Severity.IGNORE;
- }
-
- return severity;
- }
- }
-
- private static class ProgressPrinter implements LintListener {
- @Override
- public void update(
- @NonNull LintDriver lint,
- @NonNull EventType type,
- @Nullable Context context) {
- switch (type) {
- case SCANNING_PROJECT: {
- String name = context != null ? context.getProject().getName() : "?";
- if (lint.getPhase() > 1) {
- System.out.print(String.format(
- "\nScanning %1$s (Phase %2$d): ",
- name,
- lint.getPhase()));
- } else {
- System.out.print(String.format(
- "\nScanning %1$s: ",
- name));
- }
- break;
- }
- case SCANNING_LIBRARY_PROJECT: {
- String name = context != null ? context.getProject().getName() : "?";
- System.out.print(String.format(
- "\n - %1$s: ",
- name));
- break;
- }
- case SCANNING_FILE:
- System.out.print('.');
- break;
- case NEW_PHASE:
- // Ignored for now: printing status as part of next project's status
- break;
- case CANCELED:
- case COMPLETED:
- System.out.println();
- break;
- case STARTING:
- // Ignored for now
- break;
- }
- }
- }
-
- /**
- * Given a file, it produces a cleaned up path from the file.
- * This will clean up the path such that
- * <ul>
- * <li> {@code foo/./bar} becomes {@code foo/bar}
- * <li> {@code foo/bar/../baz} becomes {@code foo/baz}
- * </ul>
- *
- * Unlike {@link File#getCanonicalPath()} however, it will <b>not</b> attempt
- * to make the file canonical, such as expanding symlinks and network mounts.
- *
- * @param file the file to compute a clean path for
- * @return the cleaned up path
- */
- @VisibleForTesting
- @NonNull
- static String getCleanPath(@NonNull File file) {
- String path = file.getPath();
- StringBuilder sb = new StringBuilder(path.length());
-
- if (path.startsWith(File.separator)) {
- sb.append(File.separator);
- }
- elementLoop:
- for (String element : Splitter.on(File.separatorChar).omitEmptyStrings().split(path)) {
- if (element.equals(".")) { //$NON-NLS-1$
- continue;
- } else if (element.equals("..")) { //$NON-NLS-1$
- if (sb.length() > 0) {
- for (int i = sb.length() - 1; i >= 0; i--) {
- char c = sb.charAt(i);
- if (c == File.separatorChar) {
- sb.setLength(i == 0 ? 1 : i);
- continue elementLoop;
- }
- }
- sb.setLength(0);
- continue;
- }
- }
-
- if (sb.length() > 1) {
- sb.append(File.separatorChar);
- } else if (sb.length() > 0 && sb.charAt(0) != File.separatorChar) {
- sb.append(File.separatorChar);
- }
- sb.append(element);
- }
- if (path.endsWith(File.separator) && sb.length() > 0
- && sb.charAt(sb.length() - 1) != File.separatorChar) {
- sb.append(File.separator);
- }
-
- return sb.toString();
- }
-
- String getDisplayPath(Project project, File file) {
- String path = file.getPath();
- if (!mFullPath && path.startsWith(project.getReferenceDir().getPath())) {
- int chop = project.getReferenceDir().getPath().length();
- if (path.length() > chop && path.charAt(chop) == File.separatorChar) {
- chop++;
- }
- path = path.substring(chop);
- if (path.isEmpty()) {
- path = file.getName();
- }
- } else if (mFullPath) {
- path = getCleanPath(file.getAbsoluteFile());
- }
-
- return path;
- }
-
- /** Returns whether all warnings are enabled, including those disabled by default */
- boolean isAllEnabled() {
- return mWarnAll;
- }
-
- /** Returns the issue registry used by this client */
- IssueRegistry getRegistry() {
- return mRegistry;
- }
-
- /** Returns the driver running the lint checks */
- LintDriver getDriver() {
- return mDriver;
- }
-
- /** Returns the configuration used by this client */
- Configuration getConfiguration() {
- return mDefaultConfiguration;
- }
-
- /** Returns true if the given issue has been explicitly disabled */
- boolean isSuppressed(Issue issue) {
- return mSuppress.contains(issue.getId());
- }
-}
diff --git a/lint/cli/src/main/java/com/android/tools/lint/MultiProjectHtmlReporter.java b/lint/cli/src/main/java/com/android/tools/lint/MultiProjectHtmlReporter.java
deleted file mode 100644
index 6035c29..0000000
--- a/lint/cli/src/main/java/com/android/tools/lint/MultiProjectHtmlReporter.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint;
-
-import com.android.tools.lint.detector.api.Project;
-import com.android.tools.lint.detector.api.Severity;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.google.common.io.Closeables;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * "Multiplexing" reporter which allows output to be split up into a separate
- * report for each separate project. It also adds an overview index.
- */
-public class MultiProjectHtmlReporter extends HtmlReporter {
- private static final String INDEX_NAME = "index.html"; //$NON-NLS-1$
- private final File mDir;
-
- public MultiProjectHtmlReporter(Main client, File dir) throws IOException {
- super(client, new File(dir, INDEX_NAME));
- mDir = dir;
- }
-
- @Override
- public void write(int errorCount, int warningCount, List<Warning> allIssues) throws IOException {
- Map<Project, List<Warning>> projectToWarnings = new HashMap<Project, List<Warning>>();
- for (Warning warning : allIssues) {
- List<Warning> list = projectToWarnings.get(warning.project);
- if (list == null) {
- list = new ArrayList<Warning>();
- projectToWarnings.put(warning.project, list);
- }
- list.add(warning);
- }
-
-
- // Set of unique file names: lowercase names to avoid case conflicts in web environment
- Set<String> unique = Sets.newHashSet();
- unique.add(INDEX_NAME.toLowerCase(Locale.US));
- List<ProjectEntry> projects = Lists.newArrayList();
-
- for (Project project : projectToWarnings.keySet()) {
- // TODO: Can I get the project name from the Android manifest file instead?
- String projectName = project.getName();
-
- // Produce file names of the form Project.html, Project1.html, Project2.html, etc
- int number = 1;
- String fileName;
- while (true) {
- String numberString = number > 1 ? Integer.toString(number) : "";
- fileName = String.format("%1$s%2$s.html", projectName, numberString); //$NON-NLS-1$
- String lowercase = fileName.toLowerCase(Locale.US);
- if (!unique.contains(lowercase)) {
- unique.add(lowercase);
- break;
- }
- number++;
- }
-
- File output = new File(mDir, fileName);
- if (output.exists()) {
- boolean deleted = output.delete();
- if (!deleted) {
- mClient.log(null, "Could not delete old file %1$s", output);
- continue;
- }
- }
- if (!output.getParentFile().canWrite()) {
- mClient.log(null, "Cannot write output file %1$s", output);
- continue;
- }
- HtmlReporter reporter = new HtmlReporter(mClient, output);
- reporter.setBundleResources(mBundleResources);
- reporter.setSimpleFormat(mSimpleFormat);
- reporter.setUrlMap(mUrlMap);
-
- List<Warning> issues = projectToWarnings.get(project);
- int projectErrorCount = 0;
- int projectWarningCount = 0;
- for (Warning warning: issues) {
- if (warning.severity == Severity.ERROR || warning.severity == Severity.FATAL) {
- projectErrorCount++;
- } else if (warning.severity == Severity.WARNING) {
- projectWarningCount++;
- }
- }
-
- String prefix = project.getReferenceDir().getPath();
- String path = project.getDir().getPath();
- String relative;
- if (path.startsWith(prefix) && path.length() > prefix.length()) {
- int i = prefix.length();
- if (path.charAt(i) == File.separatorChar) {
- i++;
- }
- relative = path.substring(i);
- } else {
- relative = projectName;
- }
- reporter.setTitle(String.format("Lint Report for %1$s", relative));
- reporter.setStripPrefix(relative);
- reporter.write(projectErrorCount, projectWarningCount, issues);
-
- projects.add(new ProjectEntry(fileName, projectErrorCount, projectWarningCount,
- relative));
- }
-
- // Write overview index?
- writeOverview(errorCount, warningCount, projects);
- Closeables.closeQuietly(mWriter);
-
- File index = new File(mDir, INDEX_NAME);
- System.out.println();
- System.out.println(String.format("Wrote overview index to %1$s", index));
- }
-
- private void writeOverview(int errorCount, int warningCount, List<ProjectEntry> projects)
- throws IOException {
- mWriter.write(
- "<html>\n" + //$NON-NLS-1$
- "<head>\n" + //$NON-NLS-1$
- "<title>" + mTitle + "</title>\n"); //$NON-NLS-1$//$NON-NLS-2$
- writeStyleSheet();
- mWriter.write(
- "</head>\n" + //$NON-NLS-1$
- "<body>\n" + //$NON-NLS-1$
- "<h1>" + //$NON-NLS-1$
- mTitle +
- "<div class=\"titleSeparator\"></div>\n" + //$NON-NLS-1$
- "</h1>"); //$NON-NLS-1$
-
-
- // Sort project list in decreasing order of errors, warnings and names
- Collections.sort(projects);
-
- mWriter.write(String.format("Check performed at %1$s.",
- new Date().toString()));
- mWriter.write("<br/>"); //$NON-NLS-1$
- mWriter.write(String.format("%1$d errors and %2$d warnings found:\n",
- errorCount, warningCount));
-
- mWriter.write("<br/><br/>"); //$NON-NLS-1$
-
- if (errorCount == 0 && warningCount == 0) {
- mWriter.write("Congratulations!");
- return;
- }
-
- String errorUrl = null;
- String warningUrl = null;
- if (!mSimpleFormat) {
- errorUrl = addLocalResources(HtmlReporter.getErrorIconUrl());
- warningUrl = addLocalResources(HtmlReporter.getWarningIconUrl());
- }
-
- mWriter.write("<table class=\"overview\">\n"); //$NON-NLS-1$
- mWriter.write("<tr><th>"); //$NON-NLS-1$
- mWriter.write("Project");
- mWriter.write("</th><th class=\"countColumn\">"); //$NON-NLS-1$
-
- if (errorUrl != null) {
- mWriter.write("<img border=\"0\" align=\"top\" src=\""); //$NON-NLS-1$
- mWriter.write(errorUrl);
- mWriter.write("\" />\n"); //$NON-NLS-1$
- }
- mWriter.write("Errors");
- mWriter.write("</th><th class=\"countColumn\">"); //$NON-NLS-1$
-
- if (warningUrl != null) {
- mWriter.write("<img border=\"0\" align=\"top\" src=\""); //$NON-NLS-1$
- mWriter.write(warningUrl);
- mWriter.write("\" />\n"); //$NON-NLS-1$
- }
- mWriter.write("Warnings");
- mWriter.write("</th></tr>\n"); //$NON-NLS-1$
-
- for (ProjectEntry entry : projects) {
- mWriter.write("<tr><td>"); //$NON-NLS-1$
- mWriter.write("<a href=\"");
- mWriter.write(entry.fileName); // TODO: Escape?
- mWriter.write("\">"); //$NON-NLS-1$
- mWriter.write(entry.path);
- mWriter.write("</a></td><td class=\"countColumn\">"); //$NON-NLS-1$
- mWriter.write(Integer.toString(entry.errorCount));
- mWriter.write("</td><td class=\"countColumn\">"); //$NON-NLS-1$
- mWriter.write(Integer.toString(entry.warningCount));
- mWriter.write("</td></tr>\n"); //$NON-NLS-1$
- }
- mWriter.write("</table>\n"); //$NON-NLS-1$
- }
-
- private static class ProjectEntry implements Comparable<ProjectEntry> {
- public final int errorCount;
- public final int warningCount;
- public final String fileName;
- public final String path;
-
-
- public ProjectEntry(String fileName, int errorCount, int warningCount, String path) {
- this.fileName = fileName;
- this.errorCount = errorCount;
- this.warningCount = warningCount;
- this.path = path;
- }
-
- @Override
- public int compareTo(ProjectEntry other) {
- int delta = other.errorCount - errorCount;
- if (delta != 0) {
- return delta;
- }
-
- delta = other.warningCount - warningCount;
- if (delta != 0) {
- return delta;
- }
-
- return path.compareTo(other.path);
- }
- }
-}
diff --git a/lint/cli/src/main/java/com/android/tools/lint/Reporter.java b/lint/cli/src/main/java/com/android/tools/lint/Reporter.java
deleted file mode 100644
index 3086a7c..0000000
--- a/lint/cli/src/main/java/com/android/tools/lint/Reporter.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint;
-
-import static com.android.SdkConstants.DOT_9PNG;
-import static com.android.SdkConstants.DOT_PNG;
-import static com.android.tools.lint.detector.api.LintUtils.endsWith;
-
-import com.google.common.annotations.Beta;
-import com.google.common.io.ByteStreams;
-import com.google.common.io.Closeables;
-import com.google.common.io.Files;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-/** A reporter is an output generator for lint warnings
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- */
-@Beta
-public abstract class Reporter {
- protected final Main mClient;
- protected final File mOutput;
- protected String mTitle = "Lint Report";
- protected boolean mSimpleFormat;
- protected boolean mBundleResources;
- protected Map<String, String> mUrlMap;
- protected File mResources;
- protected final Map<File, String> mResourceUrl = new HashMap<File, String>();
- protected final Map<String, File> mNameToFile = new HashMap<String, File>();
-
- /**
- * Write the given warnings into the report
- *
- * @param errorCount the number of errors
- * @param warningCount the number of warnings
- * @param issues the issues to be reported
- * @throws IOException if an error occurs
- */
- public abstract void write(int errorCount, int warningCount, List<Warning> issues)
- throws IOException;
-
- protected Reporter(Main client, File output) {
- mClient = client;
- mOutput = output;
- }
-
- /**
- * Sets the report title
- *
- * @param title the title of the report
- */
- public void setTitle(String title) {
- mTitle = title;
- }
-
- /** @return the title of the report */
- public String getTitle() {
- return mTitle;
- }
-
- /**
- * Sets whether the report should bundle up resources along with the HTML report.
- * This implies a non-simple format (see {@link #setSimpleFormat(boolean)}).
- *
- * @param bundleResources if true, copy images into a directory relative to
- * the report
- */
- public void setBundleResources(boolean bundleResources) {
- mBundleResources = bundleResources;
- mSimpleFormat = false;
- }
-
- /**
- * Sets whether the report should use simple formatting (meaning no JavaScript,
- * embedded images, etc).
- *
- * @param simpleFormat whether the formatting should be simple
- */
- public void setSimpleFormat(boolean simpleFormat) {
- mSimpleFormat = simpleFormat;
- }
-
- /**
- * Returns whether the report should use simple formatting (meaning no JavaScript,
- * embedded images, etc).
- *
- * @return whether the report should use simple formatting
- */
- public boolean isSimpleFormat() {
- return mSimpleFormat;
- }
-
-
- String getUrl(File file) {
- if (mBundleResources && !mSimpleFormat) {
- String url = getRelativeResourceUrl(file);
- if (url != null) {
- return url;
- }
- }
-
- if (mUrlMap != null) {
- String path = file.getAbsolutePath();
- try {
- // Perform the comparison using URLs such that we properly escape spaces etc.
- String pathUrl = URLEncoder.encode(path, "UTF-8"); //$NON-NLS-1$
- for (Map.Entry<String, String> entry : mUrlMap.entrySet()) {
- String prefix = entry.getKey();
- String prefixUrl = URLEncoder.encode(prefix, "UTF-8"); //$NON-NLS-1$
- if (pathUrl.startsWith(prefixUrl)) {
- String relative = pathUrl.substring(prefixUrl.length());
- return entry.getValue()
- + relative.replace("%2F", "/"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- } catch (UnsupportedEncodingException e) {
- // This shouldn't happen for UTF-8
- System.err.println("Invalid URL map specification - " + e.getLocalizedMessage());
- }
- }
-
- return null;
- }
-
- /** Encodes the given String as a safe URL substring, escaping spaces etc */
- static String encodeUrl(String url) {
- try {
- return URLEncoder.encode(url, "UTF-8"); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e) {
- // This shouldn't happen for UTF-8
- System.err.println("Invalid string " + e.getLocalizedMessage());
- return url;
- }
- }
-
- /** Set mapping of path prefixes to corresponding URLs in the HTML report */
- void setUrlMap(Map<String, String> urlMap) {
- mUrlMap = urlMap;
- }
-
- /** Gets a pointer to the local resource directory, if any */
- File getResourceDir() {
- if (mResources == null && mBundleResources) {
- mResources = computeResourceDir();
- if (mResources == null) {
- mBundleResources = false;
- }
- }
-
- return mResources;
- }
-
- /** Finds/creates the local resource directory, if possible */
- File computeResourceDir() {
- String fileName = mOutput.getName();
- int dot = fileName.indexOf('.');
- if (dot != -1) {
- fileName = fileName.substring(0, dot);
- }
-
- File resources = new File(mOutput.getParentFile(), fileName + "_files"); //$NON-NLS-1$
- if (!resources.exists() && !resources.mkdir()) {
- resources = null;
- }
-
- return resources;
- }
-
- /** Returns a URL to a local copy of the given file, or null */
- protected String getRelativeResourceUrl(File file) {
- String resource = mResourceUrl.get(file);
- if (resource != null) {
- return resource;
- }
-
- String name = file.getName();
- if (!endsWith(name, DOT_PNG) || endsWith(name, DOT_9PNG)) {
- return null;
- }
-
- // Attempt to make local copy
- File resourceDir = getResourceDir();
- if (resourceDir != null) {
- String base = file.getName();
-
- File path = mNameToFile.get(base);
- if (path != null && !path.equals(file)) {
- // That filename already exists and is associated with a different path:
- // make a new unique version
- for (int i = 0; i < 100; i++) {
- base = '_' + base;
- path = mNameToFile.get(base);
- if (path == null || path.equals(file)) {
- break;
- }
- }
- }
-
- File target = new File(resourceDir, base);
- try {
- Files.copy(file, target);
- } catch (IOException e) {
- return null;
- }
- return resourceDir.getName() + '/' + encodeUrl(base);
- }
- return null;
- }
-
- /** Returns a URL to a local copy of the given resource, or null. There is
- * no filename conflict resolution. */
- protected String addLocalResources(URL url) {
- // Attempt to make local copy
- File resourceDir = computeResourceDir();
- if (resourceDir != null) {
- String base = url.getFile();
- base = base.substring(base.lastIndexOf('/') + 1);
- mNameToFile.put(base, new File(url.toExternalForm()));
-
- File target = new File(resourceDir, base);
- try {
- FileOutputStream output = new FileOutputStream(target);
- InputStream input = url.openStream();
- ByteStreams.copy(input, output);
- Closeables.closeQuietly(output);
- Closeables.closeQuietly(input);
- } catch (IOException e) {
- return null;
- }
- return resourceDir.getName() + '/' + encodeUrl(base);
- }
- return null;
- }
-}
diff --git a/lint/cli/src/main/java/com/android/tools/lint/TextReporter.java b/lint/cli/src/main/java/com/android/tools/lint/TextReporter.java
deleted file mode 100644
index 8e9f776..0000000
--- a/lint/cli/src/main/java/com/android/tools/lint/TextReporter.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint;
-
-import com.android.tools.lint.detector.api.Location;
-import com.android.tools.lint.detector.api.Position;
-import com.android.tools.lint.detector.api.Severity;
-import com.google.common.annotations.Beta;
-
-import java.io.IOException;
-import java.io.Writer;
-import java.util.List;
-
-/**
- * A reporter which emits lint warnings as plain text strings
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- */
-@Beta
-public class TextReporter extends Reporter {
- private final Writer mWriter;
- private final boolean mClose;
-
- /**
- * Constructs a new {@link TextReporter}
- *
- * @param client the client
- * @param writer the writer to write into
- * @param close whether the writer should be closed when done
- */
- public TextReporter(Main client, Writer writer, boolean close) {
- super(client, null);
- mWriter = writer;
- mClose = close;
- }
-
- @Override
- public void write(int errorCount, int warningCount, List<Warning> issues) throws IOException {
- boolean abbreviate = mClient.getDriver().isAbbreviating();
-
- StringBuilder output = new StringBuilder(issues.size() * 200);
- if (issues.isEmpty()) {
- mWriter.write('\n');
- mWriter.write("No issues found.");
- mWriter.write('\n');
- mWriter.flush();
- } else {
- for (Warning warning : issues) {
- int startLength = output.length();
-
- if (warning.path != null) {
- output.append(warning.path);
- output.append(':');
-
- if (warning.line >= 0) {
- output.append(Integer.toString(warning.line + 1));
- output.append(':');
- }
- if (startLength < output.length()) {
- output.append(' ');
- }
- }
-
- Severity severity = warning.severity;
- if (severity == Severity.FATAL) {
- // Treat the fatal error as an error such that we don't display
- // both "Fatal:" and "Error:" etc in the error output.
- severity = Severity.ERROR;
- }
- output.append(severity.getDescription());
- output.append(':');
- output.append(' ');
-
- output.append(warning.message);
- if (warning.issue != null) {
- output.append(' ').append('[');
- output.append(warning.issue.getId());
- output.append(']');
- }
-
- output.append('\n');
-
- if (warning.errorLine != null && !warning.errorLine.isEmpty()) {
- output.append(warning.errorLine);
- }
-
- if (warning.location != null && warning.location.getSecondary() != null) {
- Location location = warning.location.getSecondary();
- while (location != null) {
- if (location.getMessage() != null
- && !location.getMessage().isEmpty()) {
- output.append(" "); //$NON-NLS-1$
- String path = mClient.getDisplayPath(warning.project,
- location.getFile());
- output.append(path);
-
- Position start = location.getStart();
- if (start != null) {
- int line = start.getLine();
- if (line >= 0) {
- output.append(':');
- output.append(Integer.toString(line + 1));
- }
- }
-
- if (location.getMessage() != null
- && !location.getMessage().isEmpty()) {
- output.append(':');
- output.append(' ');
- output.append(location.getMessage());
- }
-
- output.append('\n');
- }
-
- location = location.getSecondary();
- }
-
- if (!abbreviate) {
- location = warning.location.getSecondary();
- StringBuilder sb = new StringBuilder(100);
- sb.append("Also affects: ");
- int begin = sb.length();
- while (location != null) {
- if (location.getMessage() == null
- || !location.getMessage().isEmpty()) {
- if (sb.length() > begin) {
- sb.append(", ");
- }
-
- String path = mClient.getDisplayPath(warning.project,
- location.getFile());
- sb.append(path);
-
- Position start = location.getStart();
- if (start != null) {
- int line = start.getLine();
- if (line >= 0) {
- sb.append(':');
- sb.append(Integer.toString(line + 1));
- }
- }
- }
-
- location = location.getSecondary();
- }
- String wrapped = Main.wrap(sb.toString(), Main.MAX_LINE_WIDTH, " "); //$NON-NLS-1$
- output.append(wrapped);
- }
- }
- }
-
- mWriter.write(output.toString());
-
- mWriter.write(String.format("%1$d errors, %2$d warnings",
- errorCount, warningCount));
- mWriter.write('\n');
- mWriter.flush();
- if (mClose) {
- mWriter.close();
- }
- }
- }
-} \ No newline at end of file
diff --git a/lint/cli/src/main/java/com/android/tools/lint/Warning.java b/lint/cli/src/main/java/com/android/tools/lint/Warning.java
deleted file mode 100644
index b6f413b..0000000
--- a/lint/cli/src/main/java/com/android/tools/lint/Warning.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint;
-
-import com.android.tools.lint.client.api.LintClient;
-import com.android.tools.lint.detector.api.Issue;
-import com.android.tools.lint.detector.api.Location;
-import com.android.tools.lint.detector.api.Project;
-import com.android.tools.lint.detector.api.Severity;
-
-import java.io.File;
-
-/**
- * A {@link Warning} represents a specific warning that a {@link LintClient}
- * has been told about. The context stores these as they are reported into a
- * list of warnings such that it can sort them all before presenting them all at
- * the end.
- */
-class Warning implements Comparable<Warning> {
- public final Issue issue;
- public final String message;
- public final Severity severity;
- public final Object data;
- public final Project project;
- public Location location;
- public File file;
- public String path;
- public int line = -1;
- public int offset = -1;
- public String errorLine;
- public String fileContents;
-
- public Warning(Issue issue, String message, Severity severity, Project project, Object data) {
- this.issue = issue;
- this.message = message;
- this.severity = severity;
- this.project = project;
- this.data = data;
- }
-
- // ---- Implements Comparable<Warning> ----
- @Override
- public int compareTo(Warning other) {
- // Sort by category, then by priority, then by id,
- // then by file, then by line
- int categoryDelta = issue.getCategory().compareTo(other.issue.getCategory());
- if (categoryDelta != 0) {
- return categoryDelta;
- }
- // DECREASING priority order
- int priorityDelta = other.issue.getPriority() - issue.getPriority();
- if (priorityDelta != 0) {
- return priorityDelta;
- }
- String id1 = issue.getId();
- String id2 = other.issue.getId();
- if (id1 == null || id2 == null) {
- return file.getName().compareTo(other.file.getName());
- }
- int idDelta = id1.compareTo(id2);
- if (idDelta != 0) {
- return idDelta;
- }
- if (file != null && other.file != null) {
- int fileDelta = file.getName().compareTo(
- other.file.getName());
- if (fileDelta != 0) {
- return fileDelta;
- }
- }
- if (line != other.line) {
- return line - other.line;
- }
-
- return message.compareTo(other.message);
- }
-}
diff --git a/lint/cli/src/main/java/com/android/tools/lint/XmlReporter.java b/lint/cli/src/main/java/com/android/tools/lint/XmlReporter.java
deleted file mode 100644
index c0dca75..0000000
--- a/lint/cli/src/main/java/com/android/tools/lint/XmlReporter.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint;
-
-import com.android.tools.lint.checks.BuiltinIssueRegistry;
-import com.android.tools.lint.detector.api.Issue;
-import com.android.tools.lint.detector.api.Location;
-import com.android.tools.lint.detector.api.Position;
-import com.google.common.annotations.Beta;
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.IOException;
-import java.io.Writer;
-import java.util.List;
-
-/**
- * A reporter which emits lint results into an XML report.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- */
-@Beta
-public class XmlReporter extends Reporter {
- private final Writer mWriter;
-
- /**
- * Constructs a new {@link XmlReporter}
- *
- * @param client the client
- * @param output the output file
- * @throws IOException if an error occurs
- */
- public XmlReporter(Main client, File output) throws IOException {
- super(client, output);
- mWriter = new BufferedWriter(Files.newWriter(output, Charsets.UTF_8));
- }
-
- @Override
- public void write(int errorCount, int warningCount, List<Warning> issues) throws IOException {
- mWriter.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); //$NON-NLS-1$
- mWriter.write("<issues format=\"3\""); //$NON-NLS-1$
- String revision = mClient.getRevision();
- if (revision != null) {
- mWriter.write(String.format(" by=\"lint %1$s\"", revision)); //$NON-NLS-1$
- }
- mWriter.write(">\n"); //$NON-NLS-1$
-
- if (!issues.isEmpty()) {
- for (Warning warning : issues) {
- mWriter.write('\n');
- indent(mWriter, 1);
- mWriter.write("<issue"); //$NON-NLS-1$
- Issue issue = warning.issue;
- writeAttribute(mWriter, 2, "id", issue.getId()); //$NON-NLS-1$
- writeAttribute(mWriter, 2, "severity",
- warning.severity.getDescription());
- writeAttribute(mWriter, 2, "message", warning.message); //$NON-NLS-1$
-
- writeAttribute(mWriter, 2, "category", //$NON-NLS-1$
- issue.getCategory().getFullName());
- writeAttribute(mWriter, 2, "priority", //$NON-NLS-1$
- Integer.toString(issue.getPriority()));
- writeAttribute(mWriter, 2, "summary", issue.getDescription()); //$NON-NLS-1$
- writeAttribute(mWriter, 2, "explanation", issue.getExplanation()); //$NON-NLS-1$
- if (issue.getMoreInfo() != null) {
- writeAttribute(mWriter, 2, "url", issue.getMoreInfo()); //$NON-NLS-1$
- }
- if (warning.errorLine != null && !warning.errorLine.isEmpty()) {
- String line = warning.errorLine;
- int index1 = line.indexOf('\n');
- if (index1 != -1) {
- int index2 = line.indexOf('\n', index1 + 1);
- if (index2 != -1) {
- String line1 = line.substring(0, index1);
- String line2 = line.substring(index1 + 1, index2);
- writeAttribute(mWriter, 2, "errorLine1", line1); //$NON-NLS-1$
- writeAttribute(mWriter, 2, "errorLine2", line2); //$NON-NLS-1$
- }
- }
- }
- if (mClient.getRegistry() instanceof BuiltinIssueRegistry &&
- ((BuiltinIssueRegistry) mClient.getRegistry()).hasAutoFix(
- "adt", issue)) { //$NON-NLS-1$
- writeAttribute(mWriter, 2, "quickfix", "adt"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- assert (warning.file != null) == (warning.location != null);
-
- if (warning.file != null) {
- assert warning.location.getFile() == warning.file;
- }
-
- Location location = warning.location;
- if (location != null) {
- mWriter.write(">\n"); //$NON-NLS-1$
- while (location != null) {
- indent(mWriter, 2);
- mWriter.write("<location"); //$NON-NLS-1$
- String path = mClient.getDisplayPath(warning.project, location.getFile());
- writeAttribute(mWriter, 3, "file", path); //$NON-NLS-1$
- Position start = location.getStart();
- if (start != null) {
- int line = start.getLine();
- int column = start.getColumn();
- if (line >= 0) {
- // +1: Line numbers internally are 0-based, report should be
- // 1-based.
- writeAttribute(mWriter, 3, "line", //$NON-NLS-1$
- Integer.toString(line + 1));
- if (column >= 0) {
- writeAttribute(mWriter, 3, "column", //$NON-NLS-1$
- Integer.toString(column + 1));
- }
- }
- }
-
- mWriter.write("/>\n"); //$NON-NLS-1$
- location = location.getSecondary();
- }
- indent(mWriter, 1);
- mWriter.write("</issue>\n"); //$NON-NLS-1$
- } else {
- mWriter.write('\n');
- indent(mWriter, 1);
- mWriter.write("/>\n"); //$NON-NLS-1$
- }
- }
- }
-
- mWriter.write("\n</issues>\n"); //$NON-NLS-1$
- mWriter.close();
-
- String path = mOutput.getAbsolutePath();
- System.out.println(String.format("Wrote XML report to %1$s", path));
- }
-
- private static void writeAttribute(Writer writer, int indent, String name, String value)
- throws IOException {
- writer.write('\n');
- indent(writer, indent);
- writer.write(name);
- writer.write('=');
- writer.write('"');
- for (int i = 0, n = value.length(); i < n; i++) {
- char c = value.charAt(i);
- switch (c) {
- case '"':
- writer.write("&quot;"); //$NON-NLS-1$
- break;
- case '\'':
- writer.write("&apos;"); //$NON-NLS-1$
- break;
- case '&':
- writer.write("&amp;"); //$NON-NLS-1$
- break;
- case '<':
- writer.write("&lt;"); //$NON-NLS-1$
- break;
- default:
- writer.write(c);
- break;
- }
- }
- writer.write('"');
- }
-
- private static void indent(Writer writer, int indent) throws IOException {
- for (int level = 0; level < indent; level++) {
- writer.write(" "); //$NON-NLS-1$
- }
- }
-} \ No newline at end of file
diff --git a/lint/cli/src/main/java/com/android/tools/lint/default.css b/lint/cli/src/main/java/com/android/tools/lint/default.css
deleted file mode 100644
index a7cfc24..0000000
--- a/lint/cli/src/main/java/com/android/tools/lint/default.css
+++ /dev/null
@@ -1,72 +0,0 @@
-body {
- max-width: 800px;
-}
-.issue {
- border: solid 1px #cccccc;
- margin-top: 10px;
- margin-bottom: 10px;
- padding: 5px;
- background-color: #eeeeee;
-}
-.id {
- font-size: 14pt;
- font-weight: bold;
- margin: 5px 0px 5px 0px;
-}
-.category {
- font-size: 18pt;
- font-weight: bold;
- margin: 10px 0px 5px 0px;
-}
-.explanation {
- margin-top: 10px;
-}
-pre {
- border: solid 1px #cccccc;
- background-color: #dddddd;
- margin: 10pt;
- overflow: auto;
-}
-.lineno {
- color: #4f4f4f;
-}
-.moreinfo {
-}
-.embedimage {
- max-width: 200px;
- max-height: 200px;
-}
-th { font-weight: normal; }
-table { border: none; }
-.metadata { }
-.message { font-weight:bold; }
-.errorlines { font-family: monospace; }
-.errorspan { font-weight: bold; }
-.errorline { font-weight: bold; }
-.warningslist { margin-bottom: 20px; }
-.overview {
- padding: 10pt;
- width: 100%;
- border: solid 1px #cccccc;
- background-color: #eeeeee;
- overflow: auto;
-}
-.countColumn {
- text-align: right;
- padding-right: 20px;
-}
-.issueColumn {
- padding-left: 50px;
-}
-.titleSeparator {
- background-color: #000000;
- height: 2px;
-}
-.categorySeparator {
- background-color: #444444;
- height: 2px;
-}
-.issueSeparator {
- background-color: #444444;
- height: 1px;
-}
diff --git a/lint/cli/src/main/java/com/android/tools/lint/hololike.css b/lint/cli/src/main/java/com/android/tools/lint/hololike.css
deleted file mode 100644
index b12611f..0000000
--- a/lint/cli/src/main/java/com/android/tools/lint/hololike.css
+++ /dev/null
@@ -1,175 +0,0 @@
-body {
- max-width: 800px;
- background-color: #000000;
- background: -webkit-gradient(linear, left top, left bottom, from(#000000), to(#272d33));
- background: -moz-linear-gradient(top, #000000, #272d33);
- color: #f3f3f3;
- font-family: 'Roboto', Sans-Serif;
-}
-.issue {
- margin-top: 10px;
- margin-bottom: 10px;
- padding: 5px 0px 5px 5px;
-}
-.id {
- font-size: 14pt;
- color: #bebebe;
- margin: 5px 0px 5px 0px;
-}
-.category {
- font-size: 18pt;
- color: #bebebe;
- margin: 10px 0px 5px 0px;
-}
-.explanation {
- margin-top: 10px;
-}
-.explanation b {
- color: #ffbbbb;
-}
-.explanation code {
- color: #bebebe;
- font-family: 'Roboto', Sans-Serif;
-}
-pre {
- background-color: #282828;
- margin: 5px 0px 5px 5px;
- padding: 5px 5px 5px 0px;
- overflow: hidden;
-}
-.lineno {
- color: #4f4f4f;
-}
-.embedimage {
- max-width: 200px;
- max-height: 200px;
-}
-th { font-weight: normal; }
-table { border: none; }
-.metadata {
-}
-.location {
- color: #bebebe;
-}
-.message { }
-.errorspan { color: #33b5e5; }
-.errorline { color: #33b5e5; }
-.warningslist { margin-bottom: 20px; }
-.overview {
- padding: 10pt;
- width: 100%;
- overflow: auto;
- border-collapse:collapse;
-}
-.overview tr {
- border-top: solid 1px #39393a;
- border-bottom: solid 1px #39393a;
-}
-.countColumn {
- text-align: right;
- padding-right: 20px;
-}
-.issueColumn {
- padding-left: 16px;
-}
-.categoryColumn {
- position: relative;
- left: -50px;
- padding-top: 20px;
- padding-bottom: 5px;
-}
-.titleSeparator {
- background-color: #33b5e5;
- height: 3px;
- margin-bottom: 10px;
-}
-.categorySeparator {
- background-color: #33b5e5;
- height: 3px;
- margin-bottom: 10px;
-}
-.issueSeparator {
- background-color: #39393a;
- height: 2px;
- margin-bottom: 10px;
-}
-.location a:link {
- text-decoration: none;
- color: #bebebe;
-}
-.location a:hover {
- text-decoration: underline;
- color: #f3f3f3;
-}
-a:link {
- text-decoration: none;
- color: #f3f3f3;
-}
-a:visited {
- text-decoration: none;
- color: #bebebe;
-}
-a:hover {
- text-decoration: underline;
- color: #f3f3f3;
-}
-a:active {
- text-decoration: underline;
- color: #f3f3f3;
-}
-.moreinfo a:link {
- text-decoration: underline;
- color: #33b5e5;
-}
-.moreinfo a:visited {
- text-decoration: underline;
- color: #33b5e5;
-}
-.issue a:link {
- text-decoration: underline;
-}
-.issue a:visited {
- text-decoration: underline;
-}
-.id a:link {
- text-decoration: none;
- color: #bebebe;
-}
-.id a:visited {
- text-decoration: none;
- color: #bebebe;
-}
-.id a:hover {
- text-decoration: underline;
- color: #f3f3f3;
-}
-.id a:active {
- text-decoration: underline;
- color: #bebebe;
-}
-.category a:link {
- text-decoration: none;
- color: #bebebe;
-}
-.category a:visited {
- text-decoration: none;
- color: #bebebe;
-}
-.category a:hover {
- text-decoration: underline;
- color: #f3f3f3;
-}
-.category a:active {
- text-decoration: underline;
- color: #bebebe;
-}
-button {
- color: #ffffff;
- background-color: #353535;
- border-left: none;
- border-right: none;
- border-bottom: none;
- border-top: solid 1px #5b5b5b;
- font-family: 'Roboto', Sans-Serif;
- font-size: 12pt;
-}
diff --git a/lint/cli/src/main/java/com/android/tools/lint/lint-error.png b/lint/cli/src/main/java/com/android/tools/lint/lint-error.png
deleted file mode 100644
index fb4c982..0000000
--- a/lint/cli/src/main/java/com/android/tools/lint/lint-error.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/main/java/com/android/tools/lint/lint-run.png b/lint/cli/src/main/java/com/android/tools/lint/lint-run.png
deleted file mode 100644
index d1a074b..0000000
--- a/lint/cli/src/main/java/com/android/tools/lint/lint-run.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/main/java/com/android/tools/lint/lint-warning.png b/lint/cli/src/main/java/com/android/tools/lint/lint-warning.png
deleted file mode 100644
index 3960cdd..0000000
--- a/lint/cli/src/main/java/com/android/tools/lint/lint-warning.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/.classpath b/lint/cli/src/test/.classpath
deleted file mode 100644
index e79b65f..0000000
--- a/lint/cli/src/test/.classpath
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/easymock.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/lint-api"/>
- <classpathentry combineaccessrules="false" kind="src" path="/lint-checks"/>
- <classpathentry combineaccessrules="false" kind="src" path="/lint-cli"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src-4.0.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-tree-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src-4.0.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src-4.0.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/lombok-ast/lombok-ast-0.2.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/lombok-ast/src-4.0.zip"/>
- <classpathentry combineaccessrules="false" kind="src" path="/layoutlib_api"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry combineaccessrules="false" kind="src" path="/testutils"/>
- <classpathentry combineaccessrules="false" kind="src" path="/SdkLib"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/lint/cli/src/test/.project b/lint/cli/src/test/.project
deleted file mode 100644
index 5713c07..0000000
--- a/lint/cli/src/test/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>lint_check-tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/lint/cli/src/test/.settings/org.eclipse.core.resources.prefs b/lint/cli/src/test/.settings/org.eclipse.core.resources.prefs
deleted file mode 100644
index 609db57..0000000
--- a/lint/cli/src/test/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,5 +0,0 @@
-eclipse.preferences.version=1
-encoding//java/com/android/tools/lint/checks/TypoDetectorTest.java=UTF-8
-encoding//java/com/android/tools/lint/checks/TypoLookupTest.java=UTF-8
-encoding//java/com/android/tools/lint/checks/TypographyDetectorTest.java=UTF-8
-encoding//java/com/android/tools/lint/checks/data/res/values-nb/typos.xml=UTF-8
diff --git a/lint/cli/src/test/.settings/org.moreunit.prefs b/lint/cli/src/test/.settings/org.moreunit.prefs
deleted file mode 100644
index 4bc8717..0000000
--- a/lint/cli/src/test/.settings/org.moreunit.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-eclipse.preferences.version=1
-org.moreunit.prefixes=
-org.moreunit.unitsourcefolder=lint_check-tests\:java\:lint-api\:src/main/java\#lint_check-tests\:java\:lint-checks\:src/main/java\#lint_check-tests\:java\:lint-cli\:src/main/java
-org.moreunit.useprojectsettings=true
diff --git a/lint/cli/src/test/java/com/android/tools/lint/LintCliXmlParserTest.java b/lint/cli/src/test/java/com/android/tools/lint/LintCliXmlParserTest.java
deleted file mode 100644
index 9fa310f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/LintCliXmlParserTest.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.android.tools.lint.checks.BuiltinIssueRegistry;
-import com.android.tools.lint.client.api.LintClient;
-import com.android.tools.lint.client.api.LintDriver;
-import com.android.tools.lint.detector.api.Context;
-import com.android.tools.lint.detector.api.Issue;
-import com.android.tools.lint.detector.api.Location;
-import com.android.tools.lint.detector.api.Location.Handle;
-import com.android.tools.lint.detector.api.Position;
-import com.android.tools.lint.detector.api.Project;
-import com.android.tools.lint.detector.api.Severity;
-import com.android.tools.lint.detector.api.XmlContext;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.Writer;
-
-import junit.framework.TestCase;
-
-@SuppressWarnings("javadoc")
-public class LintCliXmlParserTest extends TestCase {
- public void test() throws Exception {
- String xml =
- "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
- "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
- " android:layout_width=\"match_parent\"\n" +
- " android:layout_height=\"wrap_content\"\n" +
- " android:orientation=\"vertical\" >\n" +
- "\n" +
- " <Button\n" +
- " android:id=\"@+id/button1\"\n" +
- " android:layout_width=\"wrap_content\"\n" +
- " android:layout_height=\"wrap_content\"\n" +
- " android:text=\"Button\" />\n" +
- "\n" +
- " <Button\n" +
- " android:id=\"@+id/button2\"\n" +
- " android:layout_width=\"wrap_content\"\n" +
- " android:layout_height=\"wrap_content\"\n" +
- " android:text=\"Button\" />\n" +
- "\n" +
- "</LinearLayout>\n";
- LintCliXmlParser parser = new LintCliXmlParser();
- File file = File.createTempFile("parsertest", ".xml");
- Writer fw = new BufferedWriter(new FileWriter(file));
- fw.write(xml);
- fw.close();
- LintClient client = new TestClient();
- LintDriver driver = new LintDriver(new BuiltinIssueRegistry(), client);
- Project project = Project.create(client, file.getParentFile(), file.getParentFile());
- XmlContext context = new XmlContext(driver, project, null, file, null);
- Document document = parser.parseXml(context);
- assertNotNull(document);
-
- // Basic parsing heart beat tests
- Element linearLayout = (Element) document.getElementsByTagName("LinearLayout").item(0);
- assertNotNull(linearLayout);
- NodeList buttons = document.getElementsByTagName("Button");
- assertEquals(2, buttons.getLength());
- final String ANDROID_URI = "http://schemas.android.com/apk/res/android";
- assertEquals("wrap_content",
- linearLayout.getAttributeNS(ANDROID_URI, "layout_height"));
-
- // Check attribute positions
- Attr attr = linearLayout.getAttributeNodeNS(ANDROID_URI, "layout_width");
- assertNotNull(attr);
- Location location = parser.getLocation(context, attr);
- Position start = location.getStart();
- Position end = location.getEnd();
- assertEquals(2, start.getLine());
- assertEquals(xml.indexOf("android:layout_width"), start.getOffset());
- assertEquals(2, end.getLine());
- String target = "android:layout_width=\"match_parent\"";
- assertEquals(xml.indexOf(target) + target.length(), end.getOffset());
-
- // Check element positions
- Element button = (Element) buttons.item(0);
- location = parser.getLocation(context, button);
- start = location.getStart();
- end = location.getEnd();
- assertEquals(6, start.getLine());
- assertEquals(xml.indexOf("<Button"), start.getOffset());
- assertEquals(xml.indexOf("/>") + 2, end.getOffset());
- assertEquals(10, end.getLine());
- int button1End = end.getOffset();
-
- Handle handle = parser.createLocationHandle(context, button);
- Location location2 = handle.resolve();
- assertSame(location.getFile(), location.getFile());
- assertNotNull(location2.getStart());
- assertNotNull(location2.getEnd());
- assertEquals(6, location2.getStart().getLine());
- assertEquals(10, location2.getEnd().getLine());
-
- Element button2 = (Element) buttons.item(1);
- location = parser.getLocation(context, button2);
- start = location.getStart();
- end = location.getEnd();
- assertEquals(12, start.getLine());
- assertEquals(xml.indexOf("<Button", button1End), start.getOffset());
- assertEquals(xml.indexOf("/>", start.getOffset()) + 2, end.getOffset());
- assertEquals(16, end.getLine());
-
- parser.dispose(context, document);
-
- file.delete();
- }
-
- public void testLineEndings() throws Exception {
- // Test for http://code.google.com/p/android/issues/detail?id=22925
- String xml =
- "<?xml version=\"1.0\" encoding=\"utf-8\"?>\r\n" +
- "<LinearLayout>\r\n" +
- "\r" +
- "<LinearLayout></LinearLayout>\r\n" +
- "</LinearLayout>\r\n";
- LintCliXmlParser parser = new LintCliXmlParser();
- File file = File.createTempFile("parsertest2", ".xml");
- Writer fw = new BufferedWriter(new FileWriter(file));
- fw.write(xml);
- fw.close();
- LintClient client = new TestClient();
- LintDriver driver = new LintDriver(new BuiltinIssueRegistry(), client);
- Project project = Project.create(client, file.getParentFile(), file.getParentFile());
- XmlContext context = new XmlContext(driver, project, null, file, null);
- Document document = parser.parseXml(context);
- assertNotNull(document);
-
- file.delete();
- }
-
- private static class TestClient extends Main {
- @Override
- public void report(
- @NonNull Context context,
- @NonNull Issue issue,
- @NonNull Severity severity,
- @Nullable Location location,
- @NonNull String message,
- @Nullable Object data) {
- System.out.println(location + ":" + message);
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/MainTest.java b/lint/cli/src/test/java/com/android/tools/lint/MainTest.java
deleted file mode 100644
index 68a1ea3..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/MainTest.java
+++ /dev/null
@@ -1,382 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint;
-
-import com.android.tools.lint.checks.AbstractCheckTest;
-import com.android.tools.lint.checks.AccessibilityDetector;
-import com.android.tools.lint.detector.api.Detector;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.PrintStream;
-import java.security.Permission;
-import java.util.List;
-
-@SuppressWarnings("javadoc")
-public class MainTest extends AbstractCheckTest {
- protected String checkLint(String[] args, List<File> files) throws Exception {
- PrintStream previousOut = System.out;
- try {
- final ByteArrayOutputStream output = new ByteArrayOutputStream();
- System.setOut(new PrintStream(output));
-
- Main.main(args);
-
- return output.toString();
- } finally {
- System.setOut(previousOut);
- }
- }
-
- private void checkDriver(String expectedOutput, String expectedError, String[] args)
- throws Exception {
- PrintStream previousOut = System.out;
- PrintStream previousErr = System.err;
- try {
- // Trap System.exit calls:
- System.setSecurityManager(new SecurityManager() {
- @Override
- public void checkPermission(Permission perm)
- {
- // allow anything.
- }
- @Override
- public void checkPermission(Permission perm, Object context)
- {
- // allow anything.
- }
- @Override
- public void checkExit(int status) {
- throw new ExitException();
- }
- });
-
- final ByteArrayOutputStream output = new ByteArrayOutputStream();
- System.setOut(new PrintStream(output));
- final ByteArrayOutputStream error = new ByteArrayOutputStream();
- System.setErr(new PrintStream(error));
-
- try {
- Main.main(args);
- } catch (ExitException e) {
- // Allow
- }
-
- assertEquals(expectedError, cleanup(error.toString()));
- assertEquals(expectedOutput, cleanup(output.toString()));
- } finally {
- // Re-enable system exit for unit test
- System.setSecurityManager(null);
-
- System.setOut(previousOut);
- System.setErr(previousErr);
- }
- }
-
- public void testArguments() throws Exception {
- checkDriver(
- // Expected output
- "\n" +
- "Scanning MainTest_testArguments: .\n" +
- "res/layout/accessibility.xml:4: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" +
- " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/accessibility.xml:5: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" +
- " <ImageButton android:importantForAccessibility=\"yes\" android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 2 warnings\n",
-
- // Expected error
- "",
-
- // Args
- new String[] {
- "--check",
- "ContentDescription",
- "--disable",
- "LintError",
- getProjectDir(null, "res/layout/accessibility.xml").getPath()
-
- });
- }
-
- public void testShowDescription() throws Exception {
- checkDriver(
- // Expected output
- "NewApi\n" +
- "------\n" +
- "Summary: Finds API accesses to APIs that are not supported in all targeted API\n" +
- "versions\n" +
- "\n" +
- "Priority: 6 / 10\n" +
- "Severity: Error\n" +
- "Category: Correctness\n" +
- "\n" +
- "This check scans through all the Android API calls in the application and\n" +
- "warns about any calls that are not available on all versions targeted by this\n" +
- "application (according to its minimum SDK attribute in the manifest).\n" +
- "\n" +
- "If you really want to use this API and don't need to support older devices\n" +
- "just set the minSdkVersion in your AndroidManifest.xml file.\n" +
- "If your code is deliberately accessing newer APIs, and you have ensured (e.g.\n" +
- "with conditional execution) that this code will only ever be called on a\n" +
- "supported platform, then you can annotate your class or method with the\n" +
- "@TargetApi annotation specifying the local minimum SDK to apply, such as\n" +
- "@TargetApi(11), such that this check considers 11 rather than your manifest\n" +
- "file's minimum SDK as the required API level.\n" +
- "\n" +
- "If you are deliberately setting android: attributes in style definitions, make\n" +
- "sure you place this in a values-v11 folder in order to avoid running into\n" +
- "runtime conflicts on certain devices where manufacturers have added custom\n" +
- "attributes whose ids conflict with the new ones on later platforms.\n" +
- "\n" +
- "Similarly, you can use tools:targetApi=\"11\" in an XML file to indicate that\n" +
- "the element will only be inflated in an adequate context.\n" +
- "\n" +
- "\n",
-
- // Expected error
- "",
-
- // Args
- new String[] {
- "--show",
- "NewApi"
- });
- }
-
- public void testNonexistentLibrary() throws Exception {
- checkDriver(
- "",
- "Library foo.jar does not exist.\n",
-
- // Args
- new String[] {
- "--libraries",
- "foo.jar",
- "prj"
-
- });
- }
-
- public void testMultipleProjects() throws Exception {
- File project = getProjectDir(null, "bytecode/classes.jar=>libs/classes.jar");
- checkDriver(
- "",
- "The --sources, --classpath, --libraries and --resources arguments can only be used with a single project\n",
-
- // Args
- new String[] {
- "--libraries",
- new File(project, "libs/classes.jar").getPath(),
- "--disable",
- "LintError",
- project.getPath(),
- project.getPath()
-
- });
- }
-
- public void testCustomResourceDirs() throws Exception {
- File project = getProjectDir(null,
- "res/layout/accessibility.xml=>myres1/layout/accessibility1.xml",
- "res/layout/accessibility.xml=>myres2/layout/accessibility1.xml"
- );
-
- checkDriver(
- "\n"
- + "Scanning MainTest_testCustomResourceDirs: ..\n"
- + "myres1/layout/accessibility1.xml:4: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n"
- + " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "myres2/layout/accessibility1.xml:4: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n"
- + " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "myres1/layout/accessibility1.xml:5: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n"
- + " <ImageButton android:importantForAccessibility=\"yes\" android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "myres2/layout/accessibility1.xml:5: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n"
- + " <ImageButton android:importantForAccessibility=\"yes\" android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "0 errors, 4 warnings\n", // Expected output
- "",
-
- // Args
- new String[] {
- "--check",
- "ContentDescription",
- "--disable",
- "LintError",
- "--resources",
- new File(project, "myres1").getPath(),
- "--resources",
- new File(project, "myres2").getPath(),
- project.getPath(),
- });
- }
-
- public void testPathList() throws Exception {
- File project = getProjectDir(null,
- "res/layout/accessibility.xml=>myres1/layout/accessibility1.xml",
- "res/layout/accessibility.xml=>myres2/layout/accessibility1.xml"
- );
-
- checkDriver(
- "\n"
- + "Scanning MainTest_testPathList: ..\n"
- + "myres1/layout/accessibility1.xml:4: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n"
- + " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "myres2/layout/accessibility1.xml:4: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n"
- + " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "myres1/layout/accessibility1.xml:5: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n"
- + " <ImageButton android:importantForAccessibility=\"yes\" android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "myres2/layout/accessibility1.xml:5: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n"
- + " <ImageButton android:importantForAccessibility=\"yes\" android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "0 errors, 4 warnings\n", // Expected output
- "",
-
- // Args
- new String[] {
- "--check",
- "ContentDescription",
- "--disable",
- "LintError",
- "--resources",
- // Combine two paths with a single separator here
- new File(project, "myres1").getPath()
- + ':' + new File(project, "myres2").getPath(),
- project.getPath(),
- });
- }
-
- public void testClassPath() throws Exception {
- File project = getProjectDir(null,
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "bytecode/GetterTest.java.txt=>src/test/bytecode/GetterTest.java",
- "bytecode/GetterTest.jar.data=>bin/classes.jar"
- );
- checkDriver(
- "\n" +
- "Scanning MainTest_testClassPath: \n" +
- "src/test/bytecode/GetterTest.java:47: Warning: Calling getter method getFoo1() on self is slower than field access (mFoo1) [FieldGetter]\n" +
- " getFoo1();\n" +
- " ~~~~~~~\n" +
- "src/test/bytecode/GetterTest.java:48: Warning: Calling getter method getFoo2() on self is slower than field access (mFoo2) [FieldGetter]\n" +
- " getFoo2();\n" +
- " ~~~~~~~\n" +
- "src/test/bytecode/GetterTest.java:52: Warning: Calling getter method isBar1() on self is slower than field access (mBar1) [FieldGetter]\n" +
- " isBar1();\n" +
- " ~~~~~~\n" +
- "src/test/bytecode/GetterTest.java:54: Warning: Calling getter method getFoo1() on self is slower than field access (mFoo1) [FieldGetter]\n" +
- " this.getFoo1();\n" +
- " ~~~~~~~\n" +
- "src/test/bytecode/GetterTest.java:55: Warning: Calling getter method getFoo2() on self is slower than field access (mFoo2) [FieldGetter]\n" +
- " this.getFoo2();\n" +
- " ~~~~~~~\n" +
- "0 errors, 5 warnings\n",
- "",
-
- // Args
- new String[] {
- "--check",
- "FieldGetter",
- "--classpath",
- new File(project, "bin/classes.jar").getPath(),
- "--disable",
- "LintError",
- project.getPath()
- });
- }
-
- public void testLibraries() throws Exception {
- File project = getProjectDir(null,
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "bytecode/GetterTest.java.txt=>src/test/bytecode/GetterTest.java",
- "bytecode/GetterTest.jar.data=>bin/classes.jar"
- );
- checkDriver(
- "\n" +
- "Scanning MainTest_testLibraries: \n" +
- "\n" +
- "No issues found.\n",
- "",
-
- // Args
- new String[] {
- "--check",
- "FieldGetter",
- "--libraries",
- new File(project, "bin/classes.jar").getPath(),
- "--disable",
- "LintError",
- project.getPath()
- });
- }
-
- @Override
- protected Detector getDetector() {
- // Sample issue to check by the main driver
- return new AccessibilityDetector();
- }
-
- private static class ExitException extends SecurityException {
- private static final long serialVersionUID = 1L;
-
- private ExitException() {
- super("Unit test");
- }
- }
-
- public void test_getCleanPath() throws Exception {
- assertEquals("foo", Main.getCleanPath(new File("foo")));
- String sep = File.separator;
- assertEquals("foo" + sep + "bar",
- Main.getCleanPath(new File("foo" + sep + "bar")));
- assertEquals(sep,
- Main.getCleanPath(new File(sep)));
- assertEquals("foo" + sep + "bar",
- Main.getCleanPath(new File("foo" + sep + "." + sep + "bar")));
- assertEquals("bar",
- Main.getCleanPath(new File("foo" + sep + ".." + sep + "bar")));
- assertEquals("",
- Main.getCleanPath(new File("foo" + sep + "..")));
- assertEquals("foo",
- Main.getCleanPath(new File("foo" + sep + "bar" + sep + "..")));
- assertEquals("foo" + sep + ".foo" + sep + "bar",
- Main.getCleanPath(new File("foo" + sep + ".foo" + sep + "bar")));
- assertEquals("foo" + sep + "bar",
- Main.getCleanPath(new File("foo" + sep + "bar" + sep + ".")));
- assertEquals("foo" + sep + "...",
- Main.getCleanPath(new File("foo" + sep + "...")));
- assertEquals(".." + sep + "foo",
- Main.getCleanPath(new File(".." + sep + "foo")));
- assertEquals(sep + "foo",
- Main.getCleanPath(new File(sep + "foo")));
- assertEquals(sep,
- Main.getCleanPath(new File(sep + "foo" + sep + "..")));
- assertEquals(sep + "foo",
- Main.getCleanPath(new File(sep + "foo" + sep + "bar " + sep + "..")));
- assertEquals(sep + "c:",
- Main.getCleanPath(new File(sep + "c:")));
- assertEquals(sep + "c:" + sep + "foo",
- Main.getCleanPath(new File(sep + "c:" + sep + "foo")));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/XmlReporterTest.java b/lint/cli/src/test/java/com/android/tools/lint/XmlReporterTest.java
deleted file mode 100644
index 9ada70f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/XmlReporterTest.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint;
-
-import com.android.tools.lint.checks.AbstractCheckTest;
-import com.android.tools.lint.checks.HardcodedValuesDetector;
-import com.android.tools.lint.checks.ManifestOrderDetector;
-import com.android.tools.lint.detector.api.DefaultPosition;
-import com.android.tools.lint.detector.api.Detector;
-import com.android.tools.lint.detector.api.Location;
-import com.android.tools.lint.detector.api.Project;
-import com.android.tools.lint.detector.api.Severity;
-import com.android.utils.PositionXmlParser;
-import com.google.common.base.Charsets;
-import com.google.common.io.Files;
-
-import org.w3c.dom.Document;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-@SuppressWarnings("javadoc")
-public class XmlReporterTest extends AbstractCheckTest {
- public void test() throws Exception {
- File file = new File(getTargetDir(), "report");
- try {
- Main client = new Main() {
- @Override
- String getRevision() {
- return "unittest"; // Hardcode version to keep unit test output stable
- }
- };
- file.getParentFile().mkdirs();
- XmlReporter reporter = new XmlReporter(client, file);
- Project project = Project.create(client, new File("/foo/bar/Foo"),
- new File("/foo/bar/Foo"));
-
- Warning warning1 = new Warning(ManifestOrderDetector.USES_SDK,
- "<uses-sdk> tag should specify a target API level (the highest verified " +
- "version; when running on later versions, compatibility behaviors may " +
- "be enabled) with android:targetSdkVersion=\"?\"",
- Severity.WARNING, project, null);
- warning1.line = 6;
- warning1.file = new File("/foo/bar/Foo/AndroidManifest.xml");
- warning1.errorLine = " <uses-sdk android:minSdkVersion=\"8\" />\n ^\n";
- warning1.path = "AndroidManifest.xml";
- warning1.location = Location.create(warning1.file,
- new DefaultPosition(6, 4, 198), new DefaultPosition(6, 42, 236));
-
- Warning warning2 = new Warning(HardcodedValuesDetector.ISSUE,
- "[I18N] Hardcoded string \"Fooo\", should use @string resource",
- Severity.WARNING, project, null);
- warning2.line = 11;
- warning2.file = new File("/foo/bar/Foo/res/layout/main.xml");
- warning2.errorLine = " (java.lang.String) android:text=\"Fooo\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~\n";
- warning2.path = "res/layout/main.xml";
- warning2.location = Location.create(warning2.file,
- new DefaultPosition(11, 8, 377), new DefaultPosition(11, 27, 396));
-
- List<Warning> warnings = new ArrayList<Warning>();
- warnings.add(warning1);
- warnings.add(warning2);
-
- reporter.write(0, 2, warnings);
-
- String report = Files.toString(file, Charsets.UTF_8);
- assertEquals(
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<issues format=\"3\" by=\"lint unittest\">\n" +
- "\n" +
- " <issue\n" +
- " id=\"UsesMinSdkAttributes\"\n" +
- " severity=\"Warning\"\n" +
- " message=\"&lt;uses-sdk> tag should specify a target API level (the highest verified version; when running on later versions, compatibility behaviors may be enabled) with android:targetSdkVersion=&quot;?&quot;\"\n" +
- " category=\"Correctness\"\n" +
- " priority=\"9\"\n" +
- " summary=\"Checks that the minimum SDK and target SDK attributes are defined\"\n" +
- " explanation=\"The manifest should contain a `&lt;uses-sdk>` element which defines the minimum API Level required for the application to run, as well as the target version (the highest API level you have tested the version for.)\"\n" +
- " url=\"http://developer.android.com/guide/topics/manifest/uses-sdk-element.html\"\n" +
- " errorLine1=\" &lt;uses-sdk android:minSdkVersion=&quot;8&quot; />\"\n" +
- " errorLine2=\" ^\">\n" +
- " <location\n" +
- " file=\"AndroidManifest.xml\"\n" +
- " line=\"7\"\n" +
- " column=\"5\"/>\n" +
- " </issue>\n" +
- "\n" +
- " <issue\n" +
- " id=\"HardcodedText\"\n" +
- " severity=\"Warning\"\n" +
- " message=\"[I18N] Hardcoded string &quot;Fooo&quot;, should use @string resource\"\n" +
- " category=\"Internationalization\"\n" +
- " priority=\"5\"\n" +
- " summary=\"Looks for hardcoded text attributes which should be converted to resource lookup\"\n" +
- " explanation=\"Hardcoding text attributes directly in layout files is bad for several reasons:\n" +
- "\n" +
- "* When creating configuration variations (for example for landscape or portrait)you have to repeat the actual text (and keep it up to date when making changes)\n" +
- "\n" +
- "* The application cannot be translated to other languages by just adding new translations for existing string resources.\n" +
- "\n" +
- "In Eclipse there is a quickfix to automatically extract this hardcoded string into a resource lookup.\"\n" +
- " errorLine1=\" (java.lang.String) android:text=&quot;Fooo&quot; />\"\n" +
- " errorLine2=\" ~~~~~~~~~~~~~~~~~~~\">\n" +
- " <location\n" +
- " file=\"res/layout/main.xml\"\n" +
- " line=\"12\"\n" +
- " column=\"9\"/>\n" +
- " </issue>\n" +
- "\n" +
- "</issues>\n",
- report);
-
- // Make sure the XML is valid
- Document document = new PositionXmlParser().parse(report);
- assertNotNull(document);
- assertEquals(2, document.getElementsByTagName("issue").getLength());
- } finally {
- file.delete();
- }
- }
-
- public void testFullPaths() throws Exception {
- File file = new File(getTargetDir(), "report");
- try {
- Main client = new Main() {
- @Override
- String getRevision() {
- return "unittest"; // Hardcode version to keep unit test output stable
- }
- };
- client.mFullPath = true;
-
- file.getParentFile().mkdirs();
- XmlReporter reporter = new XmlReporter(client, file);
- Project project = Project.create(client, new File("/foo/bar/Foo"),
- new File("/foo/bar/Foo"));
-
- Warning warning1 = new Warning(ManifestOrderDetector.USES_SDK,
- "<uses-sdk> tag should specify a target API level (the highest verified " +
- "version; when running on later versions, compatibility behaviors may " +
- "be enabled) with android:targetSdkVersion=\"?\"",
- Severity.WARNING, project, null);
- warning1.line = 6;
- warning1.file = new File("/foo/bar/../Foo/AndroidManifest.xml");
- warning1.errorLine = " <uses-sdk android:minSdkVersion=\"8\" />\n ^\n";
- warning1.path = "AndroidManifest.xml";
- warning1.location = Location.create(warning1.file,
- new DefaultPosition(6, 4, 198), new DefaultPosition(6, 42, 236));
-
- Warning warning2 = new Warning(HardcodedValuesDetector.ISSUE,
- "[I18N] Hardcoded string \"Fooo\", should use @string resource",
- Severity.WARNING, project, null);
- warning2.line = 11;
- warning2.file = new File("/foo/bar/Foo/res/layout/main.xml");
- warning2.errorLine = " (java.lang.String) android:text=\"Fooo\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~\n";
- warning2.path = "res/layout/main.xml";
- warning2.location = Location.create(warning2.file,
- new DefaultPosition(11, 8, 377), new DefaultPosition(11, 27, 396));
-
- List<Warning> warnings = new ArrayList<Warning>();
- warnings.add(warning1);
- warnings.add(warning2);
-
- reporter.write(0, 2, warnings);
-
- String report = Files.toString(file, Charsets.UTF_8);
- assertEquals(
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
- "<issues format=\"3\" by=\"lint unittest\">\n" +
- "\n" +
- " <issue\n" +
- " id=\"UsesMinSdkAttributes\"\n" +
- " severity=\"Warning\"\n" +
- " message=\"&lt;uses-sdk> tag should specify a target API level (the highest verified version; when running on later versions, compatibility behaviors may be enabled) with android:targetSdkVersion=&quot;?&quot;\"\n" +
- " category=\"Correctness\"\n" +
- " priority=\"9\"\n" +
- " summary=\"Checks that the minimum SDK and target SDK attributes are defined\"\n" +
- " explanation=\"The manifest should contain a `&lt;uses-sdk>` element which defines the minimum API Level required for the application to run, as well as the target version (the highest API level you have tested the version for.)\"\n" +
- " url=\"http://developer.android.com/guide/topics/manifest/uses-sdk-element.html\"\n" +
- " errorLine1=\" &lt;uses-sdk android:minSdkVersion=&quot;8&quot; />\"\n" +
- " errorLine2=\" ^\">\n" +
- " <location\n" +
- " file=\"/foo/Foo/AndroidManifest.xml\"\n" +
- " line=\"7\"\n" +
- " column=\"5\"/>\n" +
- " </issue>\n" +
- "\n" +
- " <issue\n" +
- " id=\"HardcodedText\"\n" +
- " severity=\"Warning\"\n" +
- " message=\"[I18N] Hardcoded string &quot;Fooo&quot;, should use @string resource\"\n" +
- " category=\"Internationalization\"\n" +
- " priority=\"5\"\n" +
- " summary=\"Looks for hardcoded text attributes which should be converted to resource lookup\"\n" +
- " explanation=\"Hardcoding text attributes directly in layout files is bad for several reasons:\n" +
- "\n" +
- "* When creating configuration variations (for example for landscape or portrait)you have to repeat the actual text (and keep it up to date when making changes)\n" +
- "\n" +
- "* The application cannot be translated to other languages by just adding new translations for existing string resources.\n" +
- "\n" +
- "In Eclipse there is a quickfix to automatically extract this hardcoded string into a resource lookup.\"\n" +
- " errorLine1=\" (java.lang.String) android:text=&quot;Fooo&quot; />\"\n" +
- " errorLine2=\" ~~~~~~~~~~~~~~~~~~~\">\n" +
- " <location\n" +
- " file=\"/foo/bar/Foo/res/layout/main.xml\"\n" +
- " line=\"12\"\n" +
- " column=\"9\"/>\n" +
- " </issue>\n" +
- "\n" +
- "</issues>\n",
- report);
-
- // Make sure the XML is valid
- Document document = new PositionXmlParser().parse(report);
- assertNotNull(document);
- assertEquals(2, document.getElementsByTagName("issue").getLength());
- } finally {
- file.delete();
- }
- }
-
- @Override
- protected Detector getDetector() {
- fail("Not used in this test");
- return null;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/AbstractCheckTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/AbstractCheckTest.java
deleted file mode 100644
index b73db8c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/AbstractCheckTest.java
+++ /dev/null
@@ -1,452 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.android.testutils.SdkTestCase;
-import com.android.tools.lint.LintCliXmlParser;
-import com.android.tools.lint.LombokParser;
-import com.android.tools.lint.Main;
-import com.android.tools.lint.Reporter;
-import com.android.tools.lint.TextReporter;
-import com.android.tools.lint.client.api.Configuration;
-import com.android.tools.lint.client.api.DefaultConfiguration;
-import com.android.tools.lint.client.api.IDomParser;
-import com.android.tools.lint.client.api.IJavaParser;
-import com.android.tools.lint.client.api.IssueRegistry;
-import com.android.tools.lint.client.api.LintClient;
-import com.android.tools.lint.client.api.LintDriver;
-import com.android.tools.lint.detector.api.Context;
-import com.android.tools.lint.detector.api.Detector;
-import com.android.tools.lint.detector.api.Issue;
-import com.android.tools.lint.detector.api.Location;
-import com.android.tools.lint.detector.api.Project;
-import com.android.tools.lint.detector.api.Scope;
-import com.android.tools.lint.detector.api.Severity;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.StringWriter;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.security.CodeSource;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.EnumSet;
-import java.util.List;
-
-/** Common utility methods for the various lint check tests */
-@SuppressWarnings("javadoc")
-public abstract class AbstractCheckTest extends SdkTestCase {
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- BuiltinIssueRegistry.reset();
- }
-
- protected abstract Detector getDetector();
-
- private Detector mDetector;
-
- private Detector getDetectorInstance() {
- if (mDetector == null) {
- mDetector = getDetector();
- }
-
- return mDetector;
- }
-
- protected List<Issue> getIssues() {
- List<Issue> issues = new ArrayList<Issue>();
- Class<? extends Detector> detectorClass = getDetectorInstance().getClass();
- // Get the list of issues from the registry and filter out others, to make sure
- // issues are properly registered
- List<Issue> candidates = new BuiltinIssueRegistry().getIssues();
- for (Issue issue : candidates) {
- if (issue.getDetectorClass() == detectorClass) {
- issues.add(issue);
- }
- }
-
- return issues;
- }
-
- private class CustomIssueRegistry extends IssueRegistry {
- @Override
- public List<Issue> getIssues() {
- return AbstractCheckTest.this.getIssues();
- }
- }
-
- protected String lintFiles(String... relativePaths) throws Exception {
- List<File> files = new ArrayList<File>();
- File targetDir = getTargetDir();
- for (String relativePath : relativePaths) {
- File file = getTestfile(targetDir, relativePath);
- assertNotNull(file);
- files.add(file);
- }
-
- addManifestFile(targetDir);
-
- return checkLint(files);
- }
-
- protected String checkLint(List<File> files) throws Exception {
- mOutput = new StringBuilder();
- TestLintClient lintClient = createClient();
- String result = lintClient.analyze(files);
-
- // The output typically contains a few directory/filenames.
- // On Windows we need to change the separators to the unix-style
- // forward slash to make the test as OS-agnostic as possible.
- if (File.separatorChar != '/') {
- result = result.replace(File.separatorChar, '/');
- }
-
- for (File f : files) {
- deleteFile(f);
- }
-
- return result;
- }
-
- protected TestLintClient createClient() {
- return new TestLintClient();
- }
-
- protected TestConfiguration getConfiguration(LintClient client, Project project) {
- return new TestConfiguration(client, project, null);
- }
-
- protected void configureDriver(LintDriver driver) {
- }
-
- /**
- * Run lint on the given files when constructed as a separate project
- * @return The output of the lint check. On Windows, this transforms all directory
- * separators to the unix-style forward slash.
- */
- protected String lintProject(String... relativePaths) throws Exception {
- File projectDir = getProjectDir(null, relativePaths);
- return checkLint(Collections.singletonList(projectDir));
- }
-
- @Override
- protected File getTargetDir() {
- File targetDir = new File(getTempDir(), getClass().getSimpleName() + "_" + getName());
- addCleanupDir(targetDir);
- return targetDir;
- }
-
- /** Creates a project directory structure from the given files */
- protected File getProjectDir(String name, String ...relativePaths) throws Exception {
- assertFalse("getTargetDir must be overridden to make a unique directory",
- getTargetDir().equals(getTempDir()));
-
- File projectDir = getTargetDir();
- if (name != null) {
- projectDir = new File(projectDir, name);
- }
- if (!projectDir.exists()) {
- assertTrue(projectDir.getPath(), projectDir.mkdirs());
- }
-
- List<File> files = new ArrayList<File>();
- for (String relativePath : relativePaths) {
- File file = getTestfile(projectDir, relativePath);
- assertNotNull(file);
- files.add(file);
- }
-
- addManifestFile(projectDir);
- return projectDir;
- }
-
- private void addManifestFile(File projectDir) throws IOException {
- // Ensure that there is at least a manifest file there to make it a valid project
- // as far as Lint is concerned:
- if (!new File(projectDir, "AndroidManifest.xml").exists()) {
- File manifest = new File(projectDir, "AndroidManifest.xml");
- FileWriter fw = new FileWriter(manifest);
- fw.write("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
- "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
- " package=\"foo.bar2\"\n" +
- " android:versionCode=\"1\"\n" +
- " android:versionName=\"1.0\" >\n" +
- "</manifest>\n");
- fw.close();
- }
- }
-
- private StringBuilder mOutput = null;
-
- @Override
- protected InputStream getTestResource(String relativePath, boolean expectExists) {
- String path = "data" + File.separator + relativePath; //$NON-NLS-1$
- InputStream stream =
- AbstractCheckTest.class.getResourceAsStream(path);
- if (!expectExists && stream == null) {
- return null;
- }
- return stream;
- }
-
- protected boolean isEnabled(Issue issue) {
- Class<? extends Detector> detectorClass = getDetectorInstance().getClass();
- if (issue.getDetectorClass() == detectorClass) {
- return true;
- }
-
- if (issue == IssueRegistry.LINT_ERROR || issue == IssueRegistry.PARSER_ERROR) {
- return !ignoreSystemErrors();
- }
-
- return false;
- }
-
- protected boolean includeParentPath() {
- return false;
- }
-
- protected EnumSet<Scope> getLintScope(List<File> file) {
- return null;
- }
-
- public String getSuperClass(Project project, String name) {
- return null;
- }
-
- protected boolean ignoreSystemErrors() {
- return true;
- }
-
- public class TestLintClient extends Main {
- private StringWriter mWriter = new StringWriter();
-
- public TestLintClient() {
- mReporters.add(new TextReporter(this, mWriter, false));
- }
-
- @Override
- public String getSuperClass(Project project, String name) {
- String superClass = AbstractCheckTest.this.getSuperClass(project, name);
- if (superClass != null) {
- return superClass;
- }
-
- return super.getSuperClass(project, name);
- }
-
- public String analyze(List<File> files) throws Exception {
- mDriver = new LintDriver(new CustomIssueRegistry(), this);
- configureDriver(mDriver);
- mDriver.analyze(files, getLintScope(files));
-
- Collections.sort(mWarnings);
-
- for (Reporter reporter : mReporters) {
- reporter.write(mErrorCount, mWarningCount, mWarnings);
- }
-
- mOutput.append(mWriter.toString());
-
- if (mOutput.length() == 0) {
- mOutput.append("No warnings.");
- }
-
- String result = mOutput.toString();
- if (result.equals("\nNo issues found.\n")) {
- result = "No warnings.";
- }
-
- result = cleanup(result);
-
- return result;
- }
-
- public String getErrors() throws Exception {
- return mWriter.toString();
- }
-
- @Override
- public void report(
- @NonNull Context context,
- @NonNull Issue issue,
- @NonNull Severity severity,
- @Nullable Location location,
- @NonNull String message,
- @Nullable Object data) {
- if (ignoreSystemErrors() && (issue == IssueRegistry.LINT_ERROR)) {
- return;
- }
-
- if (severity == Severity.FATAL) {
- // Treat fatal errors like errors in the golden files.
- severity = Severity.ERROR;
- }
-
- // For messages into all secondary locations to ensure they get
- // specifically included in the text report
- if (location != null && location.getSecondary() != null) {
- Location l = location.getSecondary();
- while (l != null) {
- if (l.getMessage() == null) {
- l.setMessage("<No location-specific message");
- }
- l = l.getSecondary();
- }
- }
-
- super.report(context, issue, severity, location, message, data);
- }
-
- @Override
- public void log(Throwable exception, String format, Object... args) {
- if (exception != null) {
- exception.printStackTrace();
- }
- StringBuilder sb = new StringBuilder();
- if (format != null) {
- sb.append(String.format(format, args));
- }
- if (exception != null) {
- sb.append(exception.toString());
- }
- System.err.println(sb);
-
- if (exception != null) {
- fail(exception.toString());
- }
- }
-
- @Override
- public IDomParser getDomParser() {
- return new LintCliXmlParser();
- }
-
- @Override
- public IJavaParser getJavaParser() {
- return new LombokParser();
- }
-
- @Override
- public Configuration getConfiguration(@NonNull Project project) {
- return AbstractCheckTest.this.getConfiguration(this, project);
- }
-
- @Override
- public File findResource(String relativePath) {
- if (relativePath.equals("platform-tools/api/api-versions.xml")) {
- File rootDir = getRootDir();
- if (rootDir != null) {
- File file = new File(rootDir, "development" + File.separator + "sdk"
- + File.separator + "api-versions.xml");
- return file;
- }
- } else if (relativePath.startsWith("tools/support/")) {
- String base = relativePath.substring("tools/support/".length());
- File rootDir = getRootDir();
- if (rootDir != null) {
- File file = new File(rootDir, "sdk" + File.separator + "files"
- + File.separator + "typos"
- + File.separator + base);
- return file;
- }
- } else {
- fail("Unit tests don't support arbitrary resource lookup yet.");
- }
-
- return super.findResource(relativePath);
- }
- }
-
- /**
- * Returns the Android source tree root dir.
- * @return the root dir or null if it couldn't be computed.
- */
- private File getRootDir() {
- CodeSource source = getClass().getProtectionDomain().getCodeSource();
- if (source != null) {
- URL location = source.getLocation();
- try {
- File dir = new File(location.toURI());
- assertTrue(dir.getPath(), dir.exists());
- while (dir != null) {
- File settingsGradle = new File(dir, "settings.gradle"); //$NON-NLS-1$
- if (settingsGradle.exists()) {
- return dir.getParentFile();
- }
- dir = dir.getParentFile();
- }
-
- return null;
- } catch (URISyntaxException e) {
- fail(e.getLocalizedMessage());
- }
- }
-
- return null;
- }
-
- public class TestConfiguration extends DefaultConfiguration {
- protected TestConfiguration(
- @NonNull LintClient client,
- @NonNull Project project,
- @Nullable Configuration parent) {
- super(client, project, parent);
- }
-
- public TestConfiguration(
- @NonNull LintClient client,
- @Nullable Project project,
- @Nullable Configuration parent,
- @NonNull File configFile) {
- super(client, project, parent, configFile);
- }
-
- @Override
- @NonNull
- protected Severity getDefaultSeverity(@NonNull Issue issue) {
- // In unit tests, include issues that are ignored by default
- Severity severity = super.getDefaultSeverity(issue);
- if (severity == Severity.IGNORE) {
- return Severity.WARNING;
- }
- return severity;
- }
-
- @Override
- public boolean isEnabled(@NonNull Issue issue) {
- return AbstractCheckTest.this.isEnabled(issue);
- }
-
- @Override
- public void ignore(@NonNull Context context, @NonNull Issue issue,
- @Nullable Location location, @NonNull String message, @Nullable Object data) {
- fail("Not supported in tests.");
- }
-
- @Override
- public void setSeverity(@NonNull Issue issue, @Nullable Severity severity) {
- fail("Not supported in tests.");
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/AccessibilityDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/AccessibilityDetectorTest.java
deleted file mode 100644
index fe24446..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/AccessibilityDetectorTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class AccessibilityDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new AccessibilityDetector();
- }
-
- public void testAccessibility() throws Exception {
- assertEquals(
- "res/layout/accessibility.xml:4: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" +
- " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/accessibility.xml:5: Warning: [Accessibility] Missing contentDescription attribute on image [ContentDescription]\n" +
- " <ImageButton android:importantForAccessibility=\"yes\" android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/accessibility.xml:9: Warning: Do not set both contentDescription and hint: the contentDescription will mask the hint [ContentDescription]\n" +
- " <EditText android:hint=\"@string/label\" android:id=\"@+android:id/summary\" android:contentDescription=\"@string/label\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 3 warnings\n",
-
- lintProject("res/layout/accessibility2.xml=>res/layout/accessibility.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/AlwaysShowActionDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/AlwaysShowActionDetectorTest.java
deleted file mode 100644
index f7879bb..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/AlwaysShowActionDetectorTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class AlwaysShowActionDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new AlwaysShowActionDetector();
- }
-
- public void testXmlMenus() throws Exception {
- assertEquals(
- "res/menu-land/actions.xml:6: Warning: Prefer \"ifRoom\" instead of \"always\" [AlwaysShowAction]\n" +
- " android:showAsAction=\"always|collapseActionView\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/menu-land/actions.xml:13: <No location-specific message\n" +
- " res/menu-land/actions.xml:18: <No location-specific message\n" +
- " res/menu-land/actions.xml:54: <No location-specific message\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject("res/menu-land/actions.xml"));
- }
-
- public void testXmlMenusWithFlags() throws Exception {
- assertEquals(
- "res/menu-land/actions2.xml:6: Warning: Prefer \"ifRoom\" instead of \"always\" [AlwaysShowAction]\n" +
- " android:showAsAction=\"always|collapseActionView\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/menu-land/actions2.xml:13: <No location-specific message\n" +
- " res/menu-land/actions2.xml:18: <No location-specific message\n" +
- " res/menu-land/actions2.xml:54: <No location-specific message\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject("res/menu-land/actions2.xml"));
- }
-
- public void testJavaFail() throws Exception {
- assertEquals(
- "src/test/pkg/ActionTest1.java:7: Warning: Prefer \"SHOW_AS_ACTION_IF_ROOM\" instead of \"SHOW_AS_ACTION_ALWAYS\" [AlwaysShowAction]\n" +
- " System.out.println(MenuItem.SHOW_AS_ACTION_ALWAYS);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- // Only references to ALWAYS
- lintProject("src/test/pkg/ActionTest1.java.txt=>src/test/pkg/ActionTest1.java"));
- }
- public void testJavaPass() throws Exception {
- assertEquals(
- "No warnings.",
-
- // Both references to ALWAYS and IF_ROOM
- lintProject(
- "src/test/pkg/ActionTest1.java.txt=>src/test/pkg/ActionTest1.java",
- "src/test/pkg/ActionTest2.java.txt=>src/test/pkg/ActionTest2.java"));
- }
-
- public void testSuppress() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/menu-land/actions2_ignore.xml",
- "src/test/pkg/ActionTest1_ignore.java.txt=>src/test/pkg/ActionTest1.java"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/AnnotationDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/AnnotationDetectorTest.java
deleted file mode 100644
index 7da1444..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/AnnotationDetectorTest.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-import com.android.tools.lint.detector.api.Issue;
-
-import java.util.List;
-
-@SuppressWarnings("javadoc")
-public class AnnotationDetectorTest extends AbstractCheckTest {
- public void test() throws Exception {
- assertEquals(
- "src/test/pkg/WrongAnnotation.java:9: Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress]\n" +
- " public static void foobar(View view, @SuppressLint(\"NewApi\") int foo) { // Invalid: class-file check\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/WrongAnnotation.java:10: Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress]\n" +
- " @SuppressLint(\"NewApi\") // Invalid\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/WrongAnnotation.java:12: Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress]\n" +
- " @SuppressLint({\"SdCardPath\", \"NewApi\"}) // Invalid: class-file based check on local variable\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/WrongAnnotation.java:14: Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress]\n" +
- " @android.annotation.SuppressLint({\"SdCardPath\", \"NewApi\"}) // Invalid (FQN)\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/WrongAnnotation.java:28: Error: The @SuppressLint annotation cannot be used on a local variable with the lint check 'NewApi': move out to the surrounding method [LocalSuppress]\n" +
- " @SuppressLint(\"NewApi\")\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "5 errors, 0 warnings\n",
-
- lintProject(
- "src/test/pkg/WrongAnnotation.java.txt=>src/test/pkg/WrongAnnotation.java"
- ));
- }
-
- @Override
- protected Detector getDetector() {
- return new AnnotationDetector();
- }
-
- @Override
- protected List<Issue> getIssues() {
- List<Issue> issues = super.getIssues();
-
- // Need these issues on to be found by the registry as well to look up scope
- // in id references (these ids are referenced in the unit test java file below)
- issues.add(ApiDetector.UNSUPPORTED);
- issues.add(SdCardDetector.ISSUE);
-
- return issues;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ApiDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ApiDetectorTest.java
deleted file mode 100644
index 947d27b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ApiDetectorTest.java
+++ /dev/null
@@ -1,900 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-import com.android.tools.lint.detector.api.Project;
-
-@SuppressWarnings("javadoc")
-public class ApiDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new ApiDetector();
- }
-
- public void testXmlApi1() throws Exception {
- assertEquals(
- "res/color/colors.xml:9: Error: @android:color/holo_red_light requires API level 14 (current min is 1) [NewApi]\n" +
- " <item name=\"android:windowBackground\"> @android:color/holo_red_light </item>\n" +
- " ^\n" +
- "res/layout/layout.xml:9: Error: View requires API level 5 (current min is 1): <QuickContactBadge> [NewApi]\n" +
- " <QuickContactBadge\n" +
- " ^\n" +
- "res/layout/layout.xml:15: Error: View requires API level 11 (current min is 1): <CalendarView> [NewApi]\n" +
- " <CalendarView\n" +
- " ^\n" +
- "res/layout/layout.xml:21: Error: View requires API level 14 (current min is 1): <GridLayout> [NewApi]\n" +
- " <GridLayout\n" +
- " ^\n" +
- "res/layout/layout.xml:22: Error: @android:attr/actionBarSplitStyle requires API level 14 (current min is 1) [NewApi]\n" +
- " foo=\"@android:attr/actionBarSplitStyle\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/layout.xml:23: Error: @android:color/holo_red_light requires API level 14 (current min is 1) [NewApi]\n" +
- " bar=\"@android:color/holo_red_light\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/values/themes.xml:9: Error: @android:color/holo_red_light requires API level 14 (current min is 1) [NewApi]\n" +
- " <item name=\"android:windowBackground\"> @android:color/holo_red_light </item>\n" +
- " ^\n" +
- "7 errors, 0 warnings\n" +
- "",
-
- lintProject(
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "apicheck/layout.xml=>res/layout/layout.xml",
- "apicheck/themes.xml=>res/values/themes.xml",
- "apicheck/themes.xml=>res/color/colors.xml"
- ));
- }
-
- public void testAttrWithoutSlash() throws Exception {
- assertEquals(""
- + "res/layout/divider.xml:7: Error: ?android:dividerHorizontal requires API level 11 (current min is 1) [NewApi]\n"
- + " android:divider=\"?android:dividerHorizontal\"\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "1 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "apicheck/divider.xml=>res/layout/divider.xml"
- ));
- }
-
- public void testXmlApi14() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "apicheck/layout.xml=>res/layout/layout.xml",
- "apicheck/themes.xml=>res/values/themes.xml",
- "apicheck/themes.xml=>res/color/colors.xml"
- ));
- }
-
- public void testXmlApi1TargetApi() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "apicheck/layout_targetapi.xml=>res/layout/layout.xml"
- ));
- }
-
- public void testXmlApiFolderVersion11() throws Exception {
- assertEquals(
- "res/color-v11/colors.xml:9: Error: @android:color/holo_red_light requires API level 14 (current min is 1) [NewApi]\n" +
- " <item name=\"android:windowBackground\"> @android:color/holo_red_light </item>\n" +
- " ^\n" +
- "res/layout-v11/layout.xml:21: Error: View requires API level 14 (current min is 1): <GridLayout> [NewApi]\n" +
- " <GridLayout\n" +
- " ^\n" +
- "res/layout-v11/layout.xml:22: Error: @android:attr/actionBarSplitStyle requires API level 14 (current min is 1) [NewApi]\n" +
- " foo=\"@android:attr/actionBarSplitStyle\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout-v11/layout.xml:23: Error: @android:color/holo_red_light requires API level 14 (current min is 1) [NewApi]\n" +
- " bar=\"@android:color/holo_red_light\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/values-v11/themes.xml:9: Error: @android:color/holo_red_light requires API level 14 (current min is 1) [NewApi]\n" +
- " <item name=\"android:windowBackground\"> @android:color/holo_red_light </item>\n" +
- " ^\n" +
- "5 errors, 0 warnings\n" +
- "",
-
- lintProject(
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "apicheck/layout.xml=>res/layout-v11/layout.xml",
- "apicheck/themes.xml=>res/values-v11/themes.xml",
- "apicheck/themes.xml=>res/color-v11/colors.xml"
- ));
- }
-
- public void testXmlApiFolderVersion14() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "apicheck/layout.xml=>res/layout-v14/layout.xml",
- "apicheck/themes.xml=>res/values-v14/themes.xml",
- "apicheck/themes.xml=>res/color-v14/colors.xml"
- ));
- }
-
- public void testApi1() throws Exception {
- assertEquals(
- "src/foo/bar/ApiCallTest.java:20: Error: Call requires API level 11 (current min is 1): android.app.Activity#getActionBar [NewApi]\n" +
- " getActionBar(); // API 11\n" +
- " ~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:24: Error: Class requires API level 8 (current min is 1): org.w3c.dom.DOMErrorHandler [NewApi]\n" +
- " Class<?> clz = DOMErrorHandler.class; // API 8\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:27: Error: Call requires API level 3 (current min is 1): android.widget.Chronometer#getOnChronometerTickListener [NewApi]\n" +
- " chronometer.getOnChronometerTickListener(); // API 3 \n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:30: Error: Call requires API level 11 (current min is 1): android.widget.Chronometer#setTextIsSelectable [NewApi]\n" +
- " chronometer.setTextIsSelectable(true); // API 11\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:33: Error: Field requires API level 11 (current min is 1): dalvik.bytecode.OpcodeInfo#MAXIMUM_VALUE [NewApi]\n" +
- " int field = OpcodeInfo.MAXIMUM_VALUE; // API 11\n" +
- " ~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:38: Error: Field requires API level 14 (current min is 1): android.app.ApplicationErrorReport#batteryInfo [NewApi]\n" +
- " BatteryInfo batteryInfo = getReport().batteryInfo;\n" +
- " ~~~~~~~~~~~\n" +
- // Note: the above error range is wrong; should be pointing to the second
- "src/foo/bar/ApiCallTest.java:41: Error: Field requires API level 11 (current min is 1): android.graphics.PorterDuff.Mode#OVERLAY [NewApi]\n" +
- " Mode mode = PorterDuff.Mode.OVERLAY; // API 11\n" +
- " ~~~~~~~\n" +
- "7 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "apicheck/ApiCallTest.java.txt=>src/foo/bar/ApiCallTest.java",
- "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class"
- ));
- }
-
- public void testApi2() throws Exception {
- assertEquals(
- "src/foo/bar/ApiCallTest.java:20: Error: Call requires API level 11 (current min is 2): android.app.Activity#getActionBar [NewApi]\n" +
- " getActionBar(); // API 11\n" +
- " ~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:24: Error: Class requires API level 8 (current min is 2): org.w3c.dom.DOMErrorHandler [NewApi]\n" +
- " Class<?> clz = DOMErrorHandler.class; // API 8\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:27: Error: Call requires API level 3 (current min is 2): android.widget.Chronometer#getOnChronometerTickListener [NewApi]\n" +
- " chronometer.getOnChronometerTickListener(); // API 3 \n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:30: Error: Call requires API level 11 (current min is 2): android.widget.Chronometer#setTextIsSelectable [NewApi]\n" +
- " chronometer.setTextIsSelectable(true); // API 11\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:33: Error: Field requires API level 11 (current min is 2): dalvik.bytecode.OpcodeInfo#MAXIMUM_VALUE [NewApi]\n" +
- " int field = OpcodeInfo.MAXIMUM_VALUE; // API 11\n" +
- " ~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:38: Error: Field requires API level 14 (current min is 2): android.app.ApplicationErrorReport#batteryInfo [NewApi]\n" +
- " BatteryInfo batteryInfo = getReport().batteryInfo;\n" +
- " ~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:41: Error: Field requires API level 11 (current min is 2): android.graphics.PorterDuff.Mode#OVERLAY [NewApi]\n" +
- " Mode mode = PorterDuff.Mode.OVERLAY; // API 11\n" +
- " ~~~~~~~\n" +
- "7 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk2.xml=>AndroidManifest.xml",
- "apicheck/ApiCallTest.java.txt=>src/foo/bar/ApiCallTest.java",
- "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class"
- ));
- }
-
- public void testApi4() throws Exception {
- assertEquals(
- "src/foo/bar/ApiCallTest.java:20: Error: Call requires API level 11 (current min is 4): android.app.Activity#getActionBar [NewApi]\n" +
- " getActionBar(); // API 11\n" +
- " ~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:24: Error: Class requires API level 8 (current min is 4): org.w3c.dom.DOMErrorHandler [NewApi]\n" +
- " Class<?> clz = DOMErrorHandler.class; // API 8\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:30: Error: Call requires API level 11 (current min is 4): android.widget.Chronometer#setTextIsSelectable [NewApi]\n" +
- " chronometer.setTextIsSelectable(true); // API 11\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:33: Error: Field requires API level 11 (current min is 4): dalvik.bytecode.OpcodeInfo#MAXIMUM_VALUE [NewApi]\n" +
- " int field = OpcodeInfo.MAXIMUM_VALUE; // API 11\n" +
- " ~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:38: Error: Field requires API level 14 (current min is 4): android.app.ApplicationErrorReport#batteryInfo [NewApi]\n" +
- " BatteryInfo batteryInfo = getReport().batteryInfo;\n" +
- " ~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:41: Error: Field requires API level 11 (current min is 4): android.graphics.PorterDuff.Mode#OVERLAY [NewApi]\n" +
- " Mode mode = PorterDuff.Mode.OVERLAY; // API 11\n" +
- " ~~~~~~~\n" +
- "6 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "apicheck/ApiCallTest.java.txt=>src/foo/bar/ApiCallTest.java",
- "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class"
- ));
- }
-
- public void testApi10() throws Exception {
- assertEquals(
- "src/foo/bar/ApiCallTest.java:20: Error: Call requires API level 11 (current min is 10): android.app.Activity#getActionBar [NewApi]\n" +
- " getActionBar(); // API 11\n" +
- " ~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:30: Error: Call requires API level 11 (current min is 10): android.widget.Chronometer#setTextIsSelectable [NewApi]\n" +
- " chronometer.setTextIsSelectable(true); // API 11\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:33: Error: Field requires API level 11 (current min is 10): dalvik.bytecode.OpcodeInfo#MAXIMUM_VALUE [NewApi]\n" +
- " int field = OpcodeInfo.MAXIMUM_VALUE; // API 11\n" +
- " ~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:38: Error: Field requires API level 14 (current min is 10): android.app.ApplicationErrorReport#batteryInfo [NewApi]\n" +
- " BatteryInfo batteryInfo = getReport().batteryInfo;\n" +
- " ~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest.java:41: Error: Field requires API level 11 (current min is 10): android.graphics.PorterDuff.Mode#OVERLAY [NewApi]\n" +
- " Mode mode = PorterDuff.Mode.OVERLAY; // API 11\n" +
- " ~~~~~~~\n" +
- "5 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk10.xml=>AndroidManifest.xml",
- "apicheck/ApiCallTest.java.txt=>src/foo/bar/ApiCallTest.java",
- "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class"
- ));
- }
-
- public void testApi14() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "apicheck/ApiCallTest.java.txt=>src/foo/bar/ApiCallTest.java",
- "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class"
- ));
- }
-
- public void testInheritStatic() throws Exception {
- assertEquals(
- "src/foo/bar/ApiCallTest5.java:16: Error: Call requires API level 11 (current min is 2): android.view.View#resolveSizeAndState [NewApi]\n" +
- " int measuredWidth = View.resolveSizeAndState(widthMeasureSpec,\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest5.java:18: Error: Call requires API level 11 (current min is 2): android.view.View#resolveSizeAndState [NewApi]\n" +
- " int measuredHeight = resolveSizeAndState(heightMeasureSpec,\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest5.java:20: Error: Call requires API level 11 (current min is 2): android.view.View#combineMeasuredStates [NewApi]\n" +
- " View.combineMeasuredStates(0, 0);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiCallTest5.java:21: Error: Call requires API level 11 (current min is 2): android.view.View#combineMeasuredStates [NewApi]\n" +
- " ApiCallTest5.combineMeasuredStates(0, 0);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~\n" +
- "4 errors, 0 warnings\n" +
- "",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk2.xml=>AndroidManifest.xml",
- "apicheck/ApiCallTest5.java.txt=>src/foo/bar/ApiCallTest5.java",
- "apicheck/ApiCallTest5.class.data=>bin/classes/foo/bar/ApiCallTest5.class"
- ));
- }
-
- public void testInheritLocal() throws Exception {
- // Test virtual dispatch in a local class which extends some other local class (which
- // in turn extends an Android API)
- assertEquals(
- "src/test/pkg/ApiCallTest3.java:10: Error: Call requires API level 11 (current min is 1): android.app.Activity#getActionBar [NewApi]\n" +
- " getActionBar(); // API 11\n" +
- " ~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n" +
- "",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "apicheck/Intermediate.java.txt=>src/test/pkg/Intermediate.java",
- "apicheck/ApiCallTest3.java.txt=>src/test/pkg/ApiCallTest3.java",
- "apicheck/ApiCallTest3.class.data=>bin/classes/test/pkg/ApiCallTest3.class",
- "apicheck/Intermediate.class.data=>bin/classes/test/pkg/Intermediate.class"
- ));
- }
-
- public void testViewClassLayoutReference() throws Exception {
- assertEquals(
- "res/layout/view.xml:9: Error: View requires API level 5 (current min is 1): <QuickContactBadge> [NewApi]\n" +
- " <view\n" +
- " ^\n" +
- "res/layout/view.xml:16: Error: View requires API level 11 (current min is 1): <CalendarView> [NewApi]\n" +
- " <view\n" +
- " ^\n" +
- "res/layout/view.xml:24: Error: ?android:attr/dividerHorizontal requires API level 11 (current min is 1) [NewApi]\n" +
- " unknown=\"?android:attr/dividerHorizontal\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/view.xml:25: Error: ?android:attr/textColorLinkInverse requires API level 11 (current min is 1) [NewApi]\n" +
- " android:textColor=\"?android:attr/textColorLinkInverse\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "4 errors, 0 warnings\n" +
- "",
-
- lintProject(
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "apicheck/view.xml=>res/layout/view.xml"
- ));
- }
-
- public void testIOException() throws Exception {
- // See http://code.google.com/p/android/issues/detail?id=35190
- assertEquals(
- "src/test/pkg/ApiCallTest6.java:8: Error: Call requires API level 9 (current min is 1): new java.io.IOException [NewApi]\n" +
- " IOException ioException = new IOException(throwable);\n" +
- " ~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "apicheck/Intermediate.java.txt=>src/test/pkg/Intermediate.java",
- "apicheck/ApiCallTest6.java.txt=>src/test/pkg/ApiCallTest6.java",
- "apicheck/ApiCallTest6.class.data=>bin/classes/test/pkg/ApiCallTest6.class"
- ));
- }
-
-
- // Test suppressing errors -- on classes, methods etc.
-
- public void testSuppress() throws Exception {
- assertEquals(
- // These errors are correctly -not- suppressed because they
- // appear in method3 (line 74-98) which is annotated with a
- // @SuppressLint annotation specifying only an unrelated issue id
-
- "src/foo/bar/SuppressTest1.java:76: Error: Call requires API level 11 (current min is 1): android.app.Activity#getActionBar [NewApi]\n" +
- " getActionBar(); // API 11\n" +
- " ~~~~~~~~~~~~\n" +
- "src/foo/bar/SuppressTest1.java:80: Error: Class requires API level 8 (current min is 1): org.w3c.dom.DOMErrorHandler [NewApi]\n" +
- " Class<?> clz = DOMErrorHandler.class; // API 8\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/SuppressTest1.java:83: Error: Call requires API level 3 (current min is 1): android.widget.Chronometer#getOnChronometerTickListener [NewApi]\n" +
- " chronometer.getOnChronometerTickListener(); // API 3\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/SuppressTest1.java:86: Error: Call requires API level 11 (current min is 1): android.widget.Chronometer#setTextIsSelectable [NewApi]\n" +
- " chronometer.setTextIsSelectable(true); // API 11\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/SuppressTest1.java:89: Error: Field requires API level 11 (current min is 1): dalvik.bytecode.OpcodeInfo#MAXIMUM_VALUE [NewApi]\n" +
- " int field = OpcodeInfo.MAXIMUM_VALUE; // API 11\n" +
- " ~~~~~~~~~~~~~\n" +
- "src/foo/bar/SuppressTest1.java:94: Error: Field requires API level 14 (current min is 1): android.app.ApplicationErrorReport#batteryInfo [NewApi]\n" +
- " BatteryInfo batteryInfo = getReport().batteryInfo;\n" +
- " ~~~~~~~~~~~\n" +
- "src/foo/bar/SuppressTest1.java:97: Error: Field requires API level 11 (current min is 1): android.graphics.PorterDuff.Mode#OVERLAY [NewApi]\n" +
- " Mode mode = PorterDuff.Mode.OVERLAY; // API 11\n" +
- " ~~~~~~~\n" +
-
- // Note: These annotations are within the methods, not ON the methods, so they have
- // no effect (because they don't end up in the bytecode)
-
-
- "src/foo/bar/SuppressTest4.java:19: Error: Field requires API level 14 (current min is 1): android.app.ApplicationErrorReport#batteryInfo [NewApi]\n" +
- " BatteryInfo batteryInfo = report.batteryInfo;\n" +
- " ~~~~~~~~~~~\n" +
- "8 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "apicheck/SuppressTest1.java.txt=>src/foo/bar/SuppressTest1.java",
- "apicheck/SuppressTest1.class.data=>bin/classes/foo/bar/SuppressTest1.class",
- "apicheck/SuppressTest2.java.txt=>src/foo/bar/SuppressTest2.java",
- "apicheck/SuppressTest2.class.data=>bin/classes/foo/bar/SuppressTest2.class",
- "apicheck/SuppressTest3.java.txt=>src/foo/bar/SuppressTest3.java",
- "apicheck/SuppressTest3.class.data=>bin/classes/foo/bar/SuppressTest3.class",
- "apicheck/SuppressTest4.java.txt=>src/foo/bar/SuppressTest4.java",
- "apicheck/SuppressTest4.class.data=>bin/classes/foo/bar/SuppressTest4.class"
- ));
- }
-
- public void testSuppressInnerClasses() throws Exception {
- assertEquals(
- // These errors are correctly -not- suppressed because they
- // appear outside the middle inner class suppressing its own errors
- // and its child's errors
- "src/test/pkg/ApiCallTest4.java:9: Error: Call requires API level 14 (current min is 1): new android.widget.GridLayout [NewApi]\n" +
- " new GridLayout(null, null, 0);\n" +
- " ~~~~~~~~~~\n" +
- "src/test/pkg/ApiCallTest4.java:38: Error: Call requires API level 14 (current min is 1): new android.widget.GridLayout [NewApi]\n" +
- " new GridLayout(null, null, 0);\n" +
- " ~~~~~~~~~~\n" +
- "2 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "apicheck/ApiCallTest4.java.txt=>src/test/pkg/ApiCallTest4.java",
- "apicheck/ApiCallTest4.class.data=>bin/classes/test/pkg/ApiCallTest4.class",
- "apicheck/ApiCallTest4$1.class.data=>bin/classes/test/pkg/ApiCallTest4$1.class",
- "apicheck/ApiCallTest4$InnerClass1.class.data=>bin/classes/test/pkg/ApiCallTest4$InnerClass1.class",
- "apicheck/ApiCallTest4$InnerClass2.class.data=>bin/classes/test/pkg/ApiCallTest4$InnerClass2.class",
- "apicheck/ApiCallTest4$InnerClass1$InnerInnerClass1.class.data=>bin/classes/test/pkg/ApiCallTest4$InnerClass1$InnerInnerClass1.class"
- ));
- }
-
- public void testApiTargetAnnotation() throws Exception {
- assertEquals(
- "src/foo/bar/ApiTargetTest.java:13: Error: Class requires API level 8 (current min is 1): org.w3c.dom.DOMErrorHandler [NewApi]\n" +
- " Class<?> clz = DOMErrorHandler.class; // API 8\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiTargetTest.java:25: Error: Class requires API level 8 (current min is 4): org.w3c.dom.DOMErrorHandler [NewApi]\n" +
- " Class<?> clz = DOMErrorHandler.class; // API 8\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "src/foo/bar/ApiTargetTest.java:39: Error: Class requires API level 8 (current min is 7): org.w3c.dom.DOMErrorHandler [NewApi]\n" +
- " Class<?> clz = DOMErrorHandler.class; // API 8\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "3 errors, 0 warnings\n" +
- "",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "apicheck/ApiTargetTest.java.txt=>src/foo/bar/ApiTargetTest.java",
- "apicheck/ApiTargetTest.class.data=>bin/classes/foo/bar/ApiTargetTest.class",
- "apicheck/ApiTargetTest$LocalClass.class.data=>bin/classes/foo/bar/ApiTargetTest$LocalClass.class"
- ));
- }
-
- public void testTargetAnnotationInner() throws Exception {
- assertEquals(
- "src/test/pkg/ApiTargetTest2.java:32: Error: Call requires API level 14 (current min is 3): new android.widget.GridLayout [NewApi]\n" +
- " new GridLayout(null, null, 0);\n" +
- " ~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "apicheck/ApiTargetTest2.java.txt=>src/test/pkg/ApiTargetTest2.java",
- "apicheck/ApiTargetTest2.class.data=>bin/classes/test/pkg/ApiTargetTest2.class",
- "apicheck/ApiTargetTest2$1.class.data=>bin/classes/test/pkg/ApiTargetTest2$1.class",
- "apicheck/ApiTargetTest2$1$2.class.data=>bin/classes/test/pkg/ApiTargetTest2$1$2.class",
- "apicheck/ApiTargetTest2$1$1.class.data=>bin/classes/test/pkg/ApiTargetTest2$1$1.class"
- ));
- }
-
- public void testSuper() throws Exception {
- // See http://code.google.com/p/android/issues/detail?id=36384
- assertEquals(
- "src/test/pkg/ApiCallTest7.java:8: Error: Call requires API level 9 (current min is 4): new java.io.IOException [NewApi]\n" +
- " super(message, cause); // API 9\n" +
- " ~~~~~\n" +
- "src/test/pkg/ApiCallTest7.java:12: Error: Call requires API level 9 (current min is 4): new java.io.IOException [NewApi]\n" +
- " super.toString(); throw new IOException((Throwable) null); // API 9\n" +
- " ~~~~~~~~~~~\n" +
- "2 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "apicheck/ApiCallTest7.java.txt=>src/test/pkg/ApiCallTest7.java",
- "apicheck/ApiCallTest7.class.data=>bin/classes/test/pkg/ApiCallTest7.class"
- ));
- }
-
- public void testEnums() throws Exception {
- // See http://code.google.com/p/android/issues/detail?id=36951
- assertEquals(
- "src/test/pkg/TestEnum.java:26: Error: Enum value requires API level 11 (current min is 4): android.graphics.PorterDuff.Mode#OVERLAY [NewApi]\n" +
- " case OVERLAY: {\n" +
- " ~~~~~~~\n" +
- "src/test/pkg/TestEnum.java:37: Error: Enum value requires API level 11 (current min is 4): android.graphics.PorterDuff.Mode#OVERLAY [NewApi]\n" +
- " case OVERLAY: {\n" +
- " ~~~~~~~\n" +
- "src/test/pkg/TestEnum.java:61: Error: Enum for switch requires API level 11 (current min is 4): android.renderscript.Element.DataType [NewApi]\n" +
- " switch (type) {\n" +
- " ^\n" +
- "3 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "apicheck/TestEnum.java.txt=>src/test/pkg/TestEnum.java",
- "apicheck/TestEnum.class.data=>bin/classes/test/pkg/TestEnum.class"
- ));
- }
-
- @Override
- public String getSuperClass(Project project, String name) {
- // For testInterfaceInheritance
- if (name.equals("android/database/sqlite/SQLiteStatement")) {
- return "android/database/sqlite/SQLiteProgram";
- } else if (name.equals("android/database/sqlite/SQLiteProgram")) {
- return "android/database/sqlite/SQLiteClosable";
- } else if (name.equals("android/database/sqlite/SQLiteClosable")) {
- return "java/lang/Object";
- }
- return null;
- }
-
- public void testInterfaceInheritance() throws Exception {
- // See http://code.google.com/p/android/issues/detail?id=38004
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "apicheck/CloseTest.java.txt=>src/test/pkg/CloseTest.java",
- "apicheck/CloseTest.class.data=>bin/classes/test/pkg/CloseTest.class"
- ));
- }
-
- public void testInnerClassPositions() throws Exception {
- // See http://code.google.com/p/android/issues/detail?id=38113
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "apicheck/ApiCallTest8.java.txt=>src/test/pkg/ApiCallTest8.java",
- "apicheck/ApiCallTest8.class.data=>bin/classes/test/pkg/ApiCallTest8.class"
- ));
- }
-
- public void testManifestReferences() throws Exception {
- assertEquals(
- "AndroidManifest.xml:15: Error: @android:style/Theme.Holo requires API level 11 (current min is 4) [NewApi]\n" +
- " android:theme=\"@android:style/Theme.Holo\" >\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/holomanifest.xml=>AndroidManifest.xml"
- ));
- }
-
- public void testSuppressFieldAnnotations() throws Exception {
- // See http://code.google.com/p/android/issues/detail?id=38626
- assertEquals(
- "src/test/pkg/ApiCallTest9.java:9: Error: Call requires API level 14 (current min is 4): new android.widget.GridLayout [NewApi]\n" +
- " private GridLayout field1 = new GridLayout(null);\n" +
- " ~~~~~~~~~~\n" +
- "src/test/pkg/ApiCallTest9.java:12: Error: Call requires API level 14 (current min is 4): new android.widget.GridLayout [NewApi]\n" +
- " private static GridLayout field2 = new GridLayout(null);\n" +
- " ~~~~~~~~~~\n" +
- "2 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "apicheck/ApiCallTest9.java.txt=>src/test/pkg/ApiCallTest9.java",
- "apicheck/ApiCallTest9.class.data=>bin/classes/test/pkg/ApiCallTest9.class"
- ));
- }
-
- public void test38195() throws Exception {
- // See http://code.google.com/p/android/issues/detail?id=38195
- assertEquals(
- "bin/classes/TestLint.class: Error: Call requires API level 16 (current min is 4): new android.database.SQLException [NewApi]\n" +
- "bin/classes/TestLint.class: Error: Call requires API level 9 (current min is 4): java.lang.String#isEmpty [NewApi]\n" +
- "bin/classes/TestLint.class: Error: Call requires API level 9 (current min is 4): new java.sql.SQLException [NewApi]\n" +
- "3 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- /*
- Compiled from "TestLint.java"
- public class test.pkg.TestLint extends java.lang.Object{
- public test.pkg.TestLint();
- Code:
- 0: aload_0
- 1: invokespecial #8; //Method java/lang/Object."<init>":()V
- 4: return
-
- public void test(java.lang.Exception) throws java.lang.Exception;
- Code:
- 0: ldc #19; //String
- 2: invokevirtual #21; //Method java/lang/String.isEmpty:()Z
- 5: istore_2
- 6: new #27; //class java/sql/SQLException
- 9: dup
- 10: ldc #29; //String error on upgrade:
- 12: aload_1
- 13: invokespecial #31; //Method java/sql/SQLException."<init>":
- (Ljava/lang/String;Ljava/lang/Throwable;)V
- 16: athrow
-
- public void test2(java.lang.Exception) throws java.lang.Exception;
- Code:
- 0: new #39; //class android/database/SQLException
- 3: dup
- 4: ldc #29; //String error on upgrade:
- 6: aload_1
- 7: invokespecial #41; //Method android/database/SQLException.
- "<init>":(Ljava/lang/String;Ljava/lang/Throwable;)V
- 10: athrow
- }
- */
- "apicheck/TestLint.class.data=>bin/classes/TestLint.class"
- ));
- }
-
- public void testAllowLocalMethodsImplementingInaccessible() throws Exception {
- // See http://code.google.com/p/android/issues/detail?id=39030
- assertEquals(
- "src/test/pkg/ApiCallTest10.java:25: Error: Call requires API level 14 (current min is 4): android.view.View#onPopulateAccessibilityEvent [NewApi]\n" +
- " super.onPopulateAccessibilityEvent(event); // Valid lint warning\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/ApiCallTest10.java:31: Error: Call requires API level 14 (current min is 4): android.view.View#dispatchGenericFocusedEvent [NewApi]\n" +
- " return super.dispatchGenericFocusedEvent(event); // Should flag this\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/ApiCallTest10.java:40: Error: Call requires API level 14 (current min is 4): android.view.View#dispatchHoverEvent [NewApi]\n" +
- " dispatchHoverEvent(null);\n" +
- " ~~~~~~~~~~~~~~~~~~\n" +
- "3 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "apicheck/ApiCallTest10.java.txt=>src/test/pkg/ApiCallTest10.java",
- "apicheck/ApiCallTest10.class.data=>bin/classes/test/pkg/ApiCallTest10.class"
- ));
- }
-
- public void testOverrideUnknownTarget() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "apicheck/ApiCallTest11.java.txt=>src/test/pkg/ApiCallTest11.java",
- "apicheck/ApiCallTest11.class.data=>bin/classes/test/pkg/ApiCallTest11.class"
- ));
- }
-
- public void testOverride() throws Exception {
- assertEquals(
- "src/test/pkg/ApiCallTest11.java:13: Error: This method is not overriding anything with the current build target, but will in API level 11 (current target is 3): test.pkg.ApiCallTest11#getActionBar [Override]\n" +
- " public ActionBar getActionBar() {\n" +
- " ~~~~~~~~~~~~\n" +
- "src/test/pkg/ApiCallTest11.java:17: Error: This method is not overriding anything with the current build target, but will in API level 17 (current target is 3): test.pkg.ApiCallTest11#isDestroyed [Override]\n" +
- " public boolean isDestroyed() {\n" +
- " ~~~~~~~~~~~\n" +
- "src/test/pkg/ApiCallTest11.java:39: Error: This method is not overriding anything with the current build target, but will in API level 11 (current target is 3): test.pkg.ApiCallTest11.MyLinear#setDividerDrawable [Override]\n" +
- " public void setDividerDrawable(Drawable dividerDrawable) {\n" +
- " ~~~~~~~~~~~~~~~~~~\n" +
- "3 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "project.properties1=>project.properties",
- "apicheck/ApiCallTest11.java.txt=>src/test/pkg/ApiCallTest11.java",
- "apicheck/ApiCallTest11.class.data=>bin/classes/test/pkg/ApiCallTest11.class",
- "apicheck/ApiCallTest11$MyLinear.class.data=>bin/classes/test/pkg/ApiCallTest11$MyLinear.class",
- "apicheck/ApiCallTest11$MyActivity.class.data=>bin/classes/test/pkg/ApiCallTest11$MyActivity.class"
- ));
- }
-
- public void testDateFormat() throws Exception {
- // See http://code.google.com/p/android/issues/detail?id=40876
- assertEquals(
- "src/test/pkg/ApiCallTest12.java:18: Error: Call requires API level 9 (current min is 4): java.text.DateFormatSymbols#getInstance [NewApi]\n" +
- " new SimpleDateFormat(\"yyyy-MM-dd\", DateFormatSymbols.getInstance());\n" +
- " ~~~~~~~~~~~\n" +
- "src/test/pkg/ApiCallTest12.java:23: Error: The pattern character 'L' requires API level 9 (current min is 4) : \"yyyy-MM-dd LL\" [NewApi]\n" +
- " new SimpleDateFormat(\"yyyy-MM-dd LL\", Locale.US);\n" +
- " ^\n" +
- "src/test/pkg/ApiCallTest12.java:25: Error: The pattern character 'c' requires API level 9 (current min is 4) : \"cc yyyy-MM-dd\" [NewApi]\n" +
- " SimpleDateFormat format = new SimpleDateFormat(\"cc yyyy-MM-dd\");\n" +
- " ^\n" +
- "3 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "project.properties1=>project.properties",
- "apicheck/ApiCallTest12.java.txt=>src/test/pkg/ApiCallTest12.java",
- "apicheck/ApiCallTest12.class.data=>bin/classes/test/pkg/ApiCallTest12.class"
- ));
- }
-
- public void testDateFormatOk() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk10.xml=>AndroidManifest.xml",
- "project.properties1=>project.properties",
- "apicheck/ApiCallTest12.java.txt=>src/test/pkg/ApiCallTest12.java",
- "apicheck/ApiCallTest12.class.data=>bin/classes/test/pkg/ApiCallTest12.class"
- ));
- }
-
- public void testJavaConstants() throws Exception {
- assertEquals(""
- + "src/test/pkg/ApiSourceCheck.java:5: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_STATE_MASK [InlinedApi]\n"
- + "import static android.view.View.MEASURED_STATE_MASK;\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:30: Warning: Field requires API level 11 (current min is 1): android.widget.ZoomControls#MEASURED_STATE_MASK [InlinedApi]\n"
- + " int x = MEASURED_STATE_MASK;\n"
- + " ~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:33: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_STATE_MASK [InlinedApi]\n"
- + " int y = android.view.View.MEASURED_STATE_MASK;\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:36: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_STATE_MASK [InlinedApi]\n"
- + " int z = View.MEASURED_STATE_MASK;\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:37: Warning: Field requires API level 14 (current min is 1): android.view.View#FIND_VIEWS_WITH_TEXT [InlinedApi]\n"
- + " int find2 = View.FIND_VIEWS_WITH_TEXT; // requires API 14\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:40: Warning: Field requires API level 12 (current min is 1): android.app.ActivityManager#MOVE_TASK_NO_USER_ACTION [InlinedApi]\n"
- + " int w = ActivityManager.MOVE_TASK_NO_USER_ACTION;\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:41: Warning: Field requires API level 14 (current min is 1): android.widget.ZoomButton#FIND_VIEWS_WITH_CONTENT_DESCRIPTION [InlinedApi]\n"
- + " int find1 = ZoomButton.FIND_VIEWS_WITH_CONTENT_DESCRIPTION; // requires\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:44: Warning: Field requires API level 9 (current min is 1): android.widget.ZoomControls#OVER_SCROLL_ALWAYS [InlinedApi]\n"
- + " int overScroll = OVER_SCROLL_ALWAYS; // requires API 9\n"
- + " ~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:47: Warning: Field requires API level 16 (current min is 1): android.widget.ZoomControls#IMPORTANT_FOR_ACCESSIBILITY_AUTO [InlinedApi]\n"
- + " int auto = IMPORTANT_FOR_ACCESSIBILITY_AUTO; // requires API 16\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:54: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_STATE_MASK [InlinedApi]\n"
- + " return (child.getMeasuredWidth() & View.MEASURED_STATE_MASK)\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:55: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_HEIGHT_STATE_SHIFT [InlinedApi]\n"
- + " | ((child.getMeasuredHeight() >> View.MEASURED_HEIGHT_STATE_SHIFT) & (View.MEASURED_STATE_MASK >> View.MEASURED_HEIGHT_STATE_SHIFT));\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:55: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_HEIGHT_STATE_SHIFT [InlinedApi]\n"
- + " | ((child.getMeasuredHeight() >> View.MEASURED_HEIGHT_STATE_SHIFT) & (View.MEASURED_STATE_MASK >> View.MEASURED_HEIGHT_STATE_SHIFT));\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:55: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_STATE_MASK [InlinedApi]\n"
- + " | ((child.getMeasuredHeight() >> View.MEASURED_HEIGHT_STATE_SHIFT) & (View.MEASURED_STATE_MASK >> View.MEASURED_HEIGHT_STATE_SHIFT));\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:90: Warning: Field requires API level 8 (current min is 1): android.R.id#custom [InlinedApi]\n"
- + " int custom = android.R.id.custom; // API 8\n"
- + " ~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:94: Warning: Field requires API level 13 (current min is 1): android.Manifest.permission#SET_POINTER_SPEED [InlinedApi]\n"
- + " String setPointerSpeed = permission.SET_POINTER_SPEED;\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:95: Warning: Field requires API level 13 (current min is 1): android.Manifest.permission#SET_POINTER_SPEED [InlinedApi]\n"
- + " String setPointerSpeed2 = Manifest.permission.SET_POINTER_SPEED;\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:120: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_STATE_MASK [InlinedApi]\n"
- + " int y = View.MEASURED_STATE_MASK; // Not OK\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:121: Warning: Field requires API level 11 (current min is 1): android.view.View#MEASURED_STATE_MASK [InlinedApi]\n"
- + " testBenignUsages(View.MEASURED_STATE_MASK); // Not OK\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck.java:51: Error: Field requires API level 14 (current min is 1): android.widget.ZoomButton#ROTATION_X [NewApi]\n"
- + " Object rotationX = ZoomButton.ROTATION_X; // Requires API 14\n"
- + " ~~~~~~~~~~\n"
- + "1 errors, 18 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "project.properties1=>project.properties",
- "apicheck/ApiSourceCheck.java.txt=>src/test/pkg/ApiSourceCheck.java",
- "apicheck/ApiSourceCheck.class.data=>bin/classes/test/pkg/ApiSourceCheck.class"
- ));
- }
-
- public void testStyleDeclaration() throws Exception {
- assertEquals(""
- + "res/values/styles2.xml:5: Error: android:actionBarStyle requires API level 11 (current min is 10) [NewApi]\n"
- + " <item name=\"android:actionBarStyle\">...</item>\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "1 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk10.xml=>AndroidManifest.xml",
- "project.properties1=>project.properties",
- "res/values/styles2.xml"
- ));
- }
-
- public void testStyleDeclarationInV9() throws Exception {
- assertEquals(""
- + "res/values-v9/styles2.xml:5: Error: android:actionBarStyle requires API level 11 (current min is 10) [NewApi]\n"
- + " <item name=\"android:actionBarStyle\">...</item>\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "1 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk10.xml=>AndroidManifest.xml",
- "project.properties1=>project.properties",
- "res/values/styles2.xml=>res/values-v9/styles2.xml"
- ));
- }
-
- public void testStyleDeclarationInV11() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk10.xml=>AndroidManifest.xml",
- "project.properties1=>project.properties",
- "res/values/styles2.xml=>res/values-v11/styles2.xml"
- ));
- }
-
- public void testStyleDeclarationInV14() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk10.xml=>AndroidManifest.xml",
- "project.properties1=>project.properties",
- "res/values/styles2.xml=>res/values-v14/styles2.xml"
- ));
- }
-
- public void testMovedConstants() throws Exception {
- assertEquals(""
- // These two constants were introduced in API 11; the other 3 were available
- // on subclass ListView from API 1
- + "src/test/pkg/ApiSourceCheck2.java:10: Warning: Field requires API level 11 (current min is 1): android.widget.AbsListView#CHOICE_MODE_MULTIPLE_MODAL [InlinedApi]\n"
- + " int mode2 = AbsListView.CHOICE_MODE_MULTIPLE_MODAL;\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/ApiSourceCheck2.java:14: Warning: Field requires API level 11 (current min is 1): android.widget.ListView#CHOICE_MODE_MULTIPLE_MODAL [InlinedApi]\n"
- + " int mode6 = ListView.CHOICE_MODE_MULTIPLE_MODAL;\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "0 errors, 2 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "project.properties1=>project.properties",
- "apicheck/ApiSourceCheck2.java.txt=>src/test/pkg/ApiSourceCheck2.java",
- "apicheck/ApiSourceCheck2.class.data=>bin/classes/test/pkg/ApiSourceCheck2.class"
- ));
- }
-
- public void testInheritCompatLibrary() throws Exception {
- assertEquals(""
- + "src/test/pkg/MyActivityImpl.java:8: Error: Call requires API level 11 (current min is 1): android.app.Activity#isChangingConfigurations [NewApi]\n"
- + " boolean isChanging = super.isChangingConfigurations();\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/MyActivityImpl.java:13: Error: Call requires API level 11 (current min is 1): android.app.Activity#isChangingConfigurations [NewApi]\n"
- + " return super.isChangingConfigurations();\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "src/test/pkg/MyActivityImpl.java:12: Error: This method is not overriding anything with the current build target, but will in API level 11 (current target is 3): test.pkg.MyActivityImpl#isChangingConfigurations [Override]\n"
- + " public boolean isChangingConfigurations() {\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "3 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "project.properties1=>project.properties",
- "apicheck/MyActivityImpl.java.txt=>src/test/pkg/MyActivityImpl.java",
- "apicheck/MyActivityImpl.class.data=>bin/classes/test/pkg/MyActivityImpl.class",
- "apicheck/android-support-v4.jar.data=>libs/android-support-v4.jar"
- ));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ApiLookupTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ApiLookupTest.java
deleted file mode 100644
index eaba6e6..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ApiLookupTest.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.android.tools.lint.detector.api.Detector;
-import com.android.tools.lint.detector.api.Severity;
-
-import java.io.File;
-import java.io.PrintWriter;
-import java.io.RandomAccessFile;
-import java.io.StringWriter;
-
-@SuppressWarnings("javadoc")
-public class ApiLookupTest extends AbstractCheckTest {
- private final ApiLookup mDb = ApiLookup.get(new TestLintClient());
-
- public void test1() {
- assertEquals(5, mDb.getFieldVersion("android/Manifest$permission", "AUTHENTICATE_ACCOUNTS"));
- assertTrue(mDb.getFieldVersion("android/R$attr", "absListViewStyle") <= 1);
- assertEquals(11, mDb.getFieldVersion("android/R$attr", "actionMenuTextAppearance"));
- assertEquals(5, mDb.getCallVersion("android/graphics/drawable/BitmapDrawable",
- "<init>", "(Landroid/content/res/Resources;Ljava/lang/String;)V"));
- assertEquals(4, mDb.getCallVersion("android/graphics/drawable/BitmapDrawable",
- "setTargetDensity", "(Landroid/util/DisplayMetrics;)V"));
- assertEquals(7, mDb.getClassVersion("android/app/WallpaperInfo"));
- assertEquals(11, mDb.getClassVersion("android/widget/StackView"));
- assertTrue(mDb.getClassVersion("ava/text/ChoiceFormat") <= 1);
-
- // Class lookup: Unknown class
- assertEquals(-1, mDb.getClassVersion("foo/Bar"));
- // Field lookup: Unknown class
- assertEquals(-1, mDb.getFieldVersion("foo/Bar", "FOOBAR"));
- // Field lookup: Unknown field
- assertEquals(-1, mDb.getFieldVersion("android/Manifest$permission", "FOOBAR"));
- // Method lookup: Unknown class
- assertEquals(-1, mDb.getCallVersion("foo/Bar",
- "<init>", "(Landroid/content/res/Resources;Ljava/lang/String;)V"));
- // Method lookup: Unknown name
- assertEquals(-1, mDb.getCallVersion("android/graphics/drawable/BitmapDrawable",
- "foo", "(Landroid/content/res/Resources;Ljava/lang/String;)V"));
- // Method lookup: Unknown argument list
- assertEquals(-1, mDb.getCallVersion("android/graphics/drawable/BitmapDrawable",
- "<init>", "(I)V"));
- }
-
- public void test2() {
- // Regression test:
- // This used to return 11 because of some wildcard syntax in the signature
- assertTrue(mDb.getCallVersion("java/lang/Object", "getClass", "()") <= 1);
- }
-
- public void testIssue26467() {
- assertTrue(mDb.getCallVersion("java/nio/ByteBuffer", "array", "()") <= 1);
- assertEquals(9, mDb.getCallVersion("java/nio/Buffer", "array", "()"));
- }
-
- public void testNoInheritedConstructors() {
- assertTrue(mDb.getCallVersion("java/util/zip/ZipOutputStream", "<init>", "()") <= 1);
- assertTrue(mDb.getCallVersion("android/app/AliasActivity", "<init>", "(Landroid/content/Context;I)") <= 1);
- }
-
- public void testIssue35190() {
- assertEquals(9, mDb.getCallVersion("java/io/IOException", "<init>",
- "(Ljava/lang/Throwable;)V"));
- }
-
- public void testInheritInterfaces() {
- // The onPreferenceStartFragment is inherited via the
- // android/preference/PreferenceFragment$OnPreferenceStartFragmentCallback
- // interface
- assertEquals(11, mDb.getCallVersion("android/preference/PreferenceActivity",
- "onPreferenceStartFragment",
- "(Landroid/preference/PreferenceFragment;Landroid/preference/Preference;)"));
- }
-
- public void testIsValidPackage() {
- assertTrue(mDb.isValidJavaPackage("java/lang/Integer"));
- assertTrue(mDb.isValidJavaPackage("javax/crypto/Cipher"));
- assertTrue(mDb.isValidJavaPackage("java/awt/font/NumericShaper"));
-
- assertFalse(mDb.isValidJavaPackage("javax/swing/JButton"));
- assertFalse(mDb.isValidJavaPackage("java/rmi/Naming"));
- assertFalse(mDb.isValidJavaPackage("java/lang/instrument/Instrumentation"));
- }
-
- @Override
- protected Detector getDetector() {
- fail("This is not used in the ApiDatabase test");
- return null;
- }
-
- private File mCacheDir;
- private StringBuilder mLogBuffer = new StringBuilder();
-
- public void testCorruptedCacheHandling() throws Exception {
- ApiLookup lookup;
-
- // Real cache:
- mCacheDir = new TestLintClient().getCacheDir(true);
- mLogBuffer.setLength(0);
- lookup = ApiLookup.get(new LookupTestClient());
- assertEquals(11, lookup.getFieldVersion("android/R$attr", "actionMenuTextAppearance"));
- assertNotNull(lookup);
- assertEquals("", mLogBuffer.toString()); // No warnings
- ApiLookup.dispose();
-
- // Custom cache dir: should also work
- mCacheDir = new File(getTempDir(), "test-cache");
- mCacheDir.mkdirs();
- mLogBuffer.setLength(0);
- lookup = ApiLookup.get(new LookupTestClient());
- assertEquals(11, lookup.getFieldVersion("android/R$attr", "actionMenuTextAppearance"));
- assertNotNull(lookup);
- assertEquals("", mLogBuffer.toString()); // No warnings
- ApiLookup.dispose();
-
- // Now truncate cache file
- File cacheFile = new File(mCacheDir,
- ApiLookup.getCacheFileName("api-versions.xml")); //$NON-NLS-1$
- mLogBuffer.setLength(0);
- assertTrue(cacheFile.exists());
- RandomAccessFile raf = new RandomAccessFile(cacheFile, "rw");
- // Truncate file in half
- raf.setLength(100); // Broken header
- raf.close();
- lookup = ApiLookup.get(new LookupTestClient());
- String message = mLogBuffer.toString();
- // NOTE: This test is incompatible with the DEBUG_FORCE_REGENERATE_BINARY and WRITE_STATS
- // flags in the ApiLookup class, so if the test fails during development and those are
- // set, clear them.
- assertTrue(message.contains("Please delete the file and restart the IDE/lint:"));
- assertTrue(message.contains(mCacheDir.getPath()));
- ApiLookup.dispose();
-
- mLogBuffer.setLength(0);
- assertTrue(cacheFile.exists());
- raf = new RandomAccessFile(cacheFile, "rw");
- // Truncate file in half in the data portion
- raf.setLength(raf.length() / 2);
- raf.close();
- lookup = ApiLookup.get(new LookupTestClient());
- // This data is now truncated: lookup returns the wrong size.
- try {
- assertNotNull(lookup);
- lookup.getFieldVersion("android/R$attr", "actionMenuTextAppearance");
- fail("Can't look up bogus data");
- } catch (Throwable t) {
- // Expected this: the database is corrupted.
- }
- assertTrue(message.contains("Please delete the file and restart the IDE/lint:"));
- assertTrue(message.contains(mCacheDir.getPath()));
- ApiLookup.dispose();
-
- mLogBuffer.setLength(0);
- assertTrue(cacheFile.exists());
- raf = new RandomAccessFile(cacheFile, "rw");
- // Truncate file to 0 bytes
- raf.setLength(0);
- raf.close();
- lookup = ApiLookup.get(new LookupTestClient());
- assertEquals(11, lookup.getFieldVersion("android/R$attr", "actionMenuTextAppearance"));
- assertNotNull(lookup);
- assertEquals("", mLogBuffer.toString()); // No warnings
- ApiLookup.dispose();
- }
-
- private final class LookupTestClient extends TestLintClient {
- @Override
- public File getCacheDir(boolean create) {
- assertNotNull(mCacheDir);
- if (create && !mCacheDir.exists()) {
- mCacheDir.mkdirs();
- }
- return mCacheDir;
- }
-
- @Override
- public void log(
- @NonNull Severity severity,
- @Nullable Throwable exception,
- @Nullable String format,
- @Nullable Object... args) {
- if (format != null) {
- mLogBuffer.append(String.format(format, args));
- mLogBuffer.append('\n');
- }
- if (exception != null) {
- StringWriter writer = new StringWriter();
- exception.printStackTrace(new PrintWriter(writer));
- mLogBuffer.append(writer.toString());
- mLogBuffer.append('\n');
- }
- }
-
- @Override
- public void log(Throwable exception, String format, Object... args) {
- log(Severity.WARNING, exception, format, args);
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ArraySizeDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ArraySizeDetectorTest.java
deleted file mode 100644
index 127e7f8..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ArraySizeDetectorTest.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class ArraySizeDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new ArraySizeDetector();
- }
- public void testArraySizes() throws Exception {
- assertEquals(
- "res/values/arrays.xml:3: Warning: Array security_questions has an inconsistent number of items (3 in values-nl-rNL/arrays.xml, 4 in values-cs/arrays.xml) [InconsistentArrays]\n" +
- " <string-array name=\"security_questions\">\n" +
- " ^\n" +
- " res/values-cs/arrays.xml:3: Declaration with array size (4)\n" +
- " res/values-es/strings.xml:12: Declaration with array size (4)\n" +
- " res/values-nl-rNL/arrays.xml:3: Declaration with array size (3)\n" +
- "res/values/arrays.xml:10: Warning: Array signal_strength has an inconsistent number of items (5 in values/arrays.xml, 6 in values-land/arrays.xml) [InconsistentArrays]\n" +
- " <array name=\"signal_strength\">\n" +
- " ^\n" +
- " res/values-land/arrays.xml:2: Declaration with array size (6)\n" +
- "0 errors, 2 warnings\n" +
- "",
-
- lintProject(
- "res/values/arrays.xml",
- "res/values-cs/arrays.xml",
- "res/values-land/arrays.xml",
- "res/values-nl-rNL/arrays.xml",
- "res/values-es/strings.xml"));
- }
-
- public void testMultipleArrays() throws Exception {
- assertEquals(
- "res/values/stringarrays.xml:3: Warning: Array map_density_desc has an inconsistent number of items (5 in values/stringarrays.xml, 1 in values-it/stringarrays.xml) [InconsistentArrays]\n" +
- " <string-array name=\"map_density_desc\">\n" +
- " ^\n" +
- " res/values-it/stringarrays.xml:6: Declaration with array size (1)\n" +
- "0 errors, 1 warnings\n",
-
- lintProject(
- "res/values-it/stringarrays.xml",
- "res/values/stringarrays.xml"));
- }
-
- public void testArraySizesSuppressed() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/values/arrays.xml",
- "res/values-land/arrays_ignore.xml=>res/values-land/arrays.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ButtonDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ButtonDetectorTest.java
deleted file mode 100644
index 989f33c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ButtonDetectorTest.java
+++ /dev/null
@@ -1,415 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-import com.android.tools.lint.detector.api.Issue;
-
-@SuppressWarnings("javadoc")
-public class ButtonDetectorTest extends AbstractCheckTest {
- private static Issue sTestIssue;
-
- @Override
- protected boolean isEnabled(Issue issue) {
- return super.isEnabled(issue) && sTestIssue == null || issue == sTestIssue;
-
- }
-
- @Override
- protected Detector getDetector() {
- return new ButtonDetector();
- }
-
- public void testButtonOrder() throws Exception {
- sTestIssue = ButtonDetector.ORDER;
- assertEquals(
- "res/layout/buttonbar.xml:12: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:44: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:92: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:124: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:140: Warning: OK button should be on the right (was \"Ok | CANCEL\", should be \"CANCEL | Ok\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:156: Warning: OK button should be on the right (was \"OK | Abort\", should be \"Abort | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:177: Warning: Cancel button should be on the left (was \"Send | Cancel\", should be \"Cancel | Send\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "0 errors, 7 warnings\n" +
- "",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "res/layout/buttonbar.xml",
- "res/values/buttonbar-values.xml"));
- }
-
- public void testButtonOrder2() throws Exception {
- // If the layout is in v14, it had better have the right order
- sTestIssue = ButtonDetector.ORDER;
- assertEquals(
- "res/layout-v14/buttonbar.xml:12: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-v14/buttonbar.xml:44: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-v14/buttonbar.xml:92: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-v14/buttonbar.xml:124: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-v14/buttonbar.xml:140: Warning: OK button should be on the right (was \"Ok | CANCEL\", should be \"CANCEL | Ok\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-v14/buttonbar.xml:156: Warning: OK button should be on the right (was \"OK | Abort\", should be \"Abort | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-v14/buttonbar.xml:177: Warning: Cancel button should be on the left (was \"Send | Cancel\", should be \"Cancel | Send\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "0 errors, 7 warnings\n" +
- "",
-
- lintProject(
- "minsdk5targetsdk14.xml=>AndroidManifest.xml",
- "res/layout/buttonbar.xml=>res/layout-v14/buttonbar.xml",
- "res/values/buttonbar-values.xml"));
- }
-
- public void testButtonOrder3() throws Exception {
- // Similar to test 3, but also complain if the -v version is *higher* than 14
- sTestIssue = ButtonDetector.ORDER;
- assertEquals(
- "res/layout-v16/buttonbar.xml:12: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-v16/buttonbar.xml:44: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-v16/buttonbar.xml:92: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-v16/buttonbar.xml:124: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-v16/buttonbar.xml:140: Warning: OK button should be on the right (was \"Ok | CANCEL\", should be \"CANCEL | Ok\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-v16/buttonbar.xml:156: Warning: OK button should be on the right (was \"OK | Abort\", should be \"Abort | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-v16/buttonbar.xml:177: Warning: Cancel button should be on the left (was \"Send | Cancel\", should be \"Cancel | Send\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "0 errors, 7 warnings\n" +
- "",
-
- lintProject(
- "minsdk5targetsdk14.xml=>AndroidManifest.xml",
- "res/layout/buttonbar.xml=>res/layout-v16/buttonbar.xml",
- "res/values/buttonbar-values.xml"));
- }
-
- public void testButtonOrder4() throws Exception {
- // Targeting 14 but using a layout that also needs to work for older platforms:
- sTestIssue = ButtonDetector.ORDER;
- assertEquals(
- "res/layout/buttonbar.xml:12: Warning: Layout uses the wrong button order for API >= 14: Create a layout-v14/buttonbar.xml file with opposite order: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:44: Warning: Layout uses the wrong button order for API >= 14: Create a layout-v14/buttonbar.xml file with opposite order: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:92: Warning: Layout uses the wrong button order for API >= 14: Create a layout-v14/buttonbar.xml file with opposite order: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:124: Warning: Layout uses the wrong button order for API >= 14: Create a layout-v14/buttonbar.xml file with opposite order: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:140: Warning: Layout uses the wrong button order for API >= 14: Create a layout-v14/buttonbar.xml file with opposite order: OK button should be on the right (was \"Ok | CANCEL\", should be \"CANCEL | Ok\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:156: Warning: Layout uses the wrong button order for API >= 14: Create a layout-v14/buttonbar.xml file with opposite order: OK button should be on the right (was \"OK | Abort\", should be \"Abort | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:177: Warning: Layout uses the wrong button order for API >= 14: Create a layout-v14/buttonbar.xml file with opposite order: Cancel button should be on the left (was \"Send | Cancel\", should be \"Cancel | Send\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "0 errors, 7 warnings\n" +
- "",
-
- lintProject(
- "minsdk5targetsdk14.xml=>AndroidManifest.xml",
- "res/layout/buttonbar.xml",
- "res/values/buttonbar-values.xml"));
- }
-
- public void testButtonOrder5() throws Exception {
- // If the layout is in a non-ICS folder and has the wrong button order,
- // but there is a v14 version of the layout, don't complain about the non-v14 version
- sTestIssue = ButtonDetector.ORDER;
- assertEquals(
- "No warnings.",
-
- lintProject(
- "minsdk5targetsdk14.xml=>AndroidManifest.xml",
- "res/layout/buttonbar.xml",
- "res/layout/layout1.xml=>res/layout-v14/buttonbar.xml",
- "res/values/buttonbar-values.xml"));
- }
-
- public void testSuppressed() throws Exception {
- sTestIssue = ButtonDetector.ORDER;
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "res/layout/buttonbar_suppressed.xml",
- "res/values/buttonbar-values.xml"));
- }
-
- public void testButtonOrderRelativeLayout() throws Exception {
- sTestIssue = ButtonDetector.ORDER;
- assertEquals(
- "No warnings.",
-
- lintProject("res/layout/buttonbar2.xml", "res/values/buttonbar-values.xml"));
- }
-
- public void testButtonOrderRelativeLayout2() throws Exception {
- sTestIssue = ButtonDetector.ORDER;
- assertEquals(
- "res/layout/buttonbar3.xml:27: Warning: Cancel button should be on the left [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "res/layout/buttonbar3.xml",
- "res/values/buttonbar-values.xml"));
- }
-
- public void testButtonOrderRelativeLayout3() throws Exception {
- sTestIssue = ButtonDetector.ORDER;
- assertEquals(
- "No warnings.",
-
- lintProject("res/layout/buttonbar4.xml", "res/values/buttonbar-values.xml"));
- }
-
-
- public void testCase() throws Exception {
- sTestIssue = ButtonDetector.CASE;
- assertEquals(
- "res/values/buttonbar-values.xml:9: Warning: The standard Android way to capitalize Ok is \"OK\" (tip: use @android:string/ok instead) [ButtonCase]\n" +
- " <string name=\"resume2\"> Ok </string>\n" +
- " ^\n" +
- "res/values/buttonbar-values.xml:10: Warning: The standard Android way to capitalize CANCEL is \"Cancel\" (tip: use @android:string/ok instead) [ButtonCase]\n" +
- " <string name=\"giveup2\">\"CANCEL\"</string>\n" +
- " ^\n" +
- "0 errors, 2 warnings\n" +
- "",
-
- lintProject("res/layout/buttonbar.xml", "res/values/buttonbar-values.xml"));
- }
-
- public void testBack() throws Exception {
- sTestIssue = ButtonDetector.BACKBUTTON;
- assertEquals(
- "res/layout/buttonbar.xml:183: Warning: Back buttons are not standard on Android; see design guide's navigation section [BackButton]\n" +
- " <Button\n" +
- " ^\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject("res/layout/buttonbar.xml", "res/values/buttonbar-values.xml"));
- }
-
- public void testOldApp() throws Exception {
- // Target SDK < 14 - no warnings on button order
- sTestIssue = ButtonDetector.ORDER;
- assertEquals(
- "No warnings.",
-
- lintProject(
- "minsdk5targetsdk9.xml=>AndroidManifest.xml",
- "res/layout/buttonbar.xml",
- "res/values/buttonbar-values.xml"));
- }
-
- public void testEnglishLocales() throws Exception {
- sTestIssue = ButtonDetector.ORDER;
- assertEquals(
- "res/layout-en-rGB/buttonbar.xml:12: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-en-rGB/buttonbar.xml:44: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-en-rGB/buttonbar.xml:92: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-en-rGB/buttonbar.xml:124: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-en-rGB/buttonbar.xml:140: Warning: OK button should be on the right (was \"Ok | CANCEL\", should be \"CANCEL | Ok\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-en-rGB/buttonbar.xml:156: Warning: OK button should be on the right (was \"OK | Abort\", should be \"Abort | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-en-rGB/buttonbar.xml:177: Warning: Cancel button should be on the left (was \"Send | Cancel\", should be \"Cancel | Send\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "0 errors, 7 warnings\n" +
- "",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "res/layout/buttonbar.xml=>res/layout-en-rGB/buttonbar.xml",
- "res/values/buttonbar-values.xml=>res/values-en-rGB/buttonbar-values.xml"));
- }
-
- public void testOtherLocales() throws Exception {
- sTestIssue = ButtonDetector.ORDER;
- assertEquals(
- // Hardcoded values only
- "res/layout-de/buttonbar.xml:12: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout-de/buttonbar.xml:44: Warning: OK button should be on the right (was \"OK | Cancel\", should be \"Cancel | OK\") [ButtonOrder]\n" +
- " <Button\n" +
- " ^\n" +
- "0 errors, 2 warnings\n" +
- "",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "res/layout/buttonbar.xml=>res/layout-de/buttonbar.xml",
- "res/values/buttonbar-values.xml=>res/values-de/buttonbar-values.xml"));
- }
-
- public void testOtherLocales2() throws Exception {
- sTestIssue = ButtonDetector.CASE;
- assertEquals(
- "No warnings.",
-
- lintProject("res/layout/buttonbar.xml=>res/layout-de/buttonbar.xml",
- "res/values/buttonbar-values.xml=>res/values-de/buttonbar-values.xml"));
- }
-
- public void testButtonStyle() throws Exception {
- sTestIssue = ButtonDetector.STYLE;
- assertEquals(
- "res/layout/buttonbar.xml:12: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:17: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:28: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:33: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:44: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:49: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:60: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:65: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:76: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:81: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:92: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:97: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:108: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:113: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:124: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:129: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:140: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:145: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:156: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/buttonbar.xml:161: Warning: Buttons in button bars should be borderless; use style=\"?android:attr/buttonBarButtonStyle\" (and ?android:attr/buttonBarStyle on the parent) [ButtonStyle]\n" +
- " <Button\n" +
- " ^\n" +
- "0 errors, 20 warnings\n",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "res/layout/buttonbar.xml",
- "res/layout/buttonbar2.xml",
- "res/layout/buttonbar3.xml",
- "res/values/buttonbar-values.xml"));
- }
-
- public void testButtonStyleOldMinSdk() throws Exception {
- sTestIssue = ButtonDetector.STYLE;
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "res/layout/buttonbar.xml",
- "res/layout/buttonbar2.xml",
- "res/layout/buttonbar3.xml",
- "res/values/buttonbar-values.xml"));
- }
-
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ChildCountDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ChildCountDetectorTest.java
deleted file mode 100644
index 517ca4d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ChildCountDetectorTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class ChildCountDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new ChildCountDetector();
- }
-
- public void testChildCount() throws Exception {
- assertEquals(
- "res/layout/has_children.xml:3: Warning: A list/grid should have no children declared in XML [AdapterViewChildren]\n" +
- "<ListView\n" +
- "^\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintFiles("res/layout/has_children.xml"));
- }
-
- public void testChildCount2() throws Exception {
- // A <requestFocus/> tag is okay.
- assertEquals(
- "No warnings.",
- lintFiles("res/layout/has_children2.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/CleanupDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/CleanupDetectorTest.java
deleted file mode 100644
index 01d462a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/CleanupDetectorTest.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class CleanupDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new CleanupDetector();
- }
-
- public void testRecycle() throws Exception {
- assertEquals(
- "src/test/pkg/RecycleTest.java:56: Warning: This TypedArray should be recycled after use with #recycle() [Recycle]\n" +
- " final TypedArray a = getContext().obtainStyledAttributes(attrs,\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/RecycleTest.java:63: Warning: This TypedArray should be recycled after use with #recycle() [Recycle]\n" +
- " final TypedArray a = getContext().obtainStyledAttributes(new int[0]);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/RecycleTest.java:79: Warning: This VelocityTracker should be recycled after use with #recycle() [Recycle]\n" +
- " VelocityTracker tracker = VelocityTracker.obtain();\n" +
- " ~~~~~~\n" +
- "src/test/pkg/RecycleTest.java:92: Warning: This MotionEvent should be recycled after use with #recycle() [Recycle]\n" +
- " MotionEvent event1 = MotionEvent.obtain(null);\n" +
- " ~~~~~~\n" +
- "src/test/pkg/RecycleTest.java:93: Warning: This MotionEvent should be recycled after use with #recycle() [Recycle]\n" +
- " MotionEvent event2 = MotionEvent.obtainNoHistory(null);\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/RecycleTest.java:98: Warning: This MotionEvent should be recycled after use with #recycle() [Recycle]\n" +
- " MotionEvent event2 = MotionEvent.obtainNoHistory(null); // Not recycled\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/RecycleTest.java:103: Warning: This MotionEvent should be recycled after use with #recycle() [Recycle]\n" +
- " MotionEvent event1 = MotionEvent.obtain(null); // Not recycled\n" +
- " ~~~~~~\n" +
- "src/test/pkg/RecycleTest.java:113: Warning: This MotionEvent has already been recycled [Recycle]\n" +
- " int contents2 = event1.describeContents(); // BAD, after recycle\n" +
- " ~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/RecycleTest.java:117: Warning: This TypedArray has already been recycled [Recycle]\n" +
- " example = a.getString(R.styleable.MyView_exampleString); // BAD, after recycle\n" +
- " ~~~~~~~~~\n" +
- "src/test/pkg/RecycleTest.java:129: Warning: This Parcel should be recycled after use with #recycle() [Recycle]\n" +
- " Parcel myparcel = Parcel.obtain();\n" +
- " ~~~~~~\n" +
- "0 errors, 10 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "project.properties1=>project.properties",
- "bytecode/RecycleTest.java.txt=>src/test/pkg/RecycleTest.java",
- "bytecode/RecycleTest.class.data=>bin/classes/test/pkg/RecycleTest.class"
- ));
- }
-
- public void testCommit() throws Exception {
- assertEquals("" +
- "src/test/pkg/CommitTest.java:25: Warning: This transaction should be completed with a commit() call [CommitTransaction]\n" +
- " getFragmentManager().beginTransaction(); // Missing commit\n" +
- " ~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/CommitTest.java:30: Warning: This transaction should be completed with a commit() call [CommitTransaction]\n" +
- " FragmentTransaction transaction2 = getFragmentManager().beginTransaction(); // Missing commit\n" +
- " ~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/CommitTest.java:39: Warning: This transaction should be completed with a commit() call [CommitTransaction]\n" +
- " getFragmentManager().beginTransaction(); // Missing commit\n" +
- " ~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/CommitTest.java:65: Warning: This transaction should be completed with a commit() call [Recycle]\n" +
- " getSupportFragmentManager().beginTransaction();\n" +
- " ~~~~~~~~~~~~~~~~\n" +
- "0 errors, 4 warnings\n",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "project.properties1=>project.properties",
- "bytecode/CommitTest.java.txt=>src/test/pkg/CommitTest.java",
- "bytecode/CommitTest.class.data=>bin/classes/test/pkg/CommitTest.class"
- ));
- }
-
- public void testCommit2() throws Exception {
- assertEquals(""
- + "No warnings.",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "project.properties1=>project.properties",
- "bytecode/DialogFragment.class.data=>bin/classes/test/pkg/DialogFragment.class"
- ));
- }
-
- public void testHasReturnType() throws Exception {
- assertTrue(CleanupDetector.hasReturnType("android/app/FragmentTransaction",
- "(Landroid/app/Fragment;)Landroid/app/FragmentTransaction;"));
- assertTrue(CleanupDetector.hasReturnType("android/app/FragmentTransaction",
- "()Landroid/app/FragmentTransaction;"));
- assertFalse(CleanupDetector.hasReturnType("android/app/FragmentTransaction",
- "()Landroid/app/FragmentTransactions;"));
- assertFalse(CleanupDetector.hasReturnType("android/app/FragmentTransaction",
- "()Landroid/app/FragmentTransactions"));
- assertFalse(CleanupDetector.hasReturnType("android/app/FragmentTransaction",
- "()android/app/FragmentTransaction;"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ColorUsageDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ColorUsageDetectorTest.java
deleted file mode 100644
index d1a04e1..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ColorUsageDetectorTest.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class ColorUsageDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new ColorUsageDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/pkg/WrongColor.java:9: Error: Should pass resolved color instead of resource id here: getResources().getColor(R.color.blue) [ResourceAsColor]\n" +
- " paint2.setColor(R.color.blue);\n" +
- " ~~~~~~~~~~~~\n" +
- "src/test/pkg/WrongColor.java:11: Error: Should pass resolved color instead of resource id here: getResources().getColor(R.color.red) [ResourceAsColor]\n" +
- " textView.setTextColor(R.color.red);\n" +
- " ~~~~~~~~~~~\n" +
- "src/test/pkg/WrongColor.java:12: Error: Should pass resolved color instead of resource id here: getResources().getColor(android.R.color.red) [ResourceAsColor]\n" +
- " textView.setTextColor(android.R.color.red);\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "3 errors, 0 warnings\n" +
- "",
-
- lintProject("src/test/pkg/WrongColor.java.txt=>src/test/pkg/WrongColor.java"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/CommentDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/CommentDetectorTest.java
deleted file mode 100644
index c352962..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/CommentDetectorTest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class CommentDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new CommentDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/pkg/Hidden.java:11: Warning: STOPSHIP comment found; points to code which must be fixed prior to release [StopShip]\n" +
- " // STOPSHIP\n" +
- " ~~~~~~~~\n" +
- "src/test/pkg/Hidden.java:12: Warning: STOPSHIP comment found; points to code which must be fixed prior to release [StopShip]\n" +
- " /* We must STOPSHIP! */\n" +
- " ~~~~~~~~\n" +
- "src/test/pkg/Hidden.java:5: Warning: Code might be hidden here; found unicode escape sequence which is interpreted as comment end, compiled code follows [EasterEgg]\n" +
- " /* \\u002a\\u002f static { System.out.println(\"I'm executed on class load\"); } \\u002f\\u002a */\n" +
- " ~~~~~~~~~~~~\n" +
- "src/test/pkg/Hidden.java:6: Warning: Code might be hidden here; found unicode escape sequence which is interpreted as comment end, compiled code follows [EasterEgg]\n" +
- " /* \\u002A\\U002F static { System.out.println(\"I'm executed on class load\"); } \\u002f\\u002a */\n" +
- " ~~~~~~~~~~~~\n" +
- "0 errors, 4 warnings\n",
-
- lintProject("src/test/pkg/Hidden.java.txt=>src/test/pkg/Hidden.java"));
- }
-
- public void test2() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject("src/test/pkg/SdCardTest.java.txt=>src/test/pkg/SdCardTest.java"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/CutPasteDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/CutPasteDetectorTest.java
deleted file mode 100644
index df02a41..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/CutPasteDetectorTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class CutPasteDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new CutPasteDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/pkg/PasteError.java:15: Warning: The id R.id.textView1 has already been looked up in this method; possible cut & paste error? [CutPasteId]\n" +
- " View view2 = findViewById(R.id.textView1);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " src/test/pkg/PasteError.java:14: First usage here\n" +
- "src/test/pkg/PasteError.java:71: Warning: The id R.id.textView1 has already been looked up in this method; possible cut & paste error? [CutPasteId]\n" +
- " view2 = findViewById(R.id.textView1);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " src/test/pkg/PasteError.java:68: First usage here\n" +
- "src/test/pkg/PasteError.java:78: Warning: The id R.id.textView1 has already been looked up in this method; possible cut & paste error? [CutPasteId]\n" +
- " view2 = findViewById(R.id.textView1);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " src/test/pkg/PasteError.java:76: First usage here\n" +
- "src/test/pkg/PasteError.java:86: Warning: The id R.id.textView1 has already been looked up in this method; possible cut & paste error? [CutPasteId]\n" +
- " view2 = findViewById(R.id.textView1);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " src/test/pkg/PasteError.java:83: First usage here\n" +
- "src/test/pkg/PasteError.java:95: Warning: The id R.id.textView1 has already been looked up in this method; possible cut & paste error? [CutPasteId]\n" +
- " view2 = findViewById(R.id.textView1);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " src/test/pkg/PasteError.java:91: First usage here\n" +
- "0 errors, 5 warnings\n",
-
- lintProject("src/test/pkg/PasteError.java.txt=>" +
- "src/test/pkg/PasteError.java"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/DeprecationDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/DeprecationDetectorTest.java
deleted file mode 100644
index f399014..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/DeprecationDetectorTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class DeprecationDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new DeprecationDetector();
- }
-
- public void testApi1() throws Exception {
- assertEquals(
- "res/layout/deprecation.xml:2: Warning: AbsoluteLayout is deprecated [Deprecated]\n" +
- "<AbsoluteLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
- "^\n" +
- "res/layout/deprecation.xml:18: Warning: android:editable is deprecated: Use an <EditText> to make it editable [Deprecated]\n" +
- " android:editable=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/deprecation.xml:26: Warning: android:editable is deprecated: <EditText> is already editable [Deprecated]\n" +
- " <EditText android:editable=\"true\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/deprecation.xml:27: Warning: android:editable is deprecated: Use inputType instead [Deprecated]\n" +
- " <EditText android:editable=\"false\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 4 warnings\n",
-
- lintProject(
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "res/layout/deprecation.xml"));
- }
-
- public void testApi4() throws Exception {
- assertEquals(
- "res/layout/deprecation.xml:2: Warning: AbsoluteLayout is deprecated [Deprecated]\n" +
- "<AbsoluteLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
- "^\n" +
- "res/layout/deprecation.xml:16: Warning: android:autoText is deprecated: Use inputType instead [Deprecated]\n" +
- " android:autoText=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/deprecation.xml:17: Warning: android:capitalize is deprecated: Use inputType instead [Deprecated]\n" +
- " android:capitalize=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/deprecation.xml:18: Warning: android:editable is deprecated: Use an <EditText> to make it editable [Deprecated]\n" +
- " android:editable=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/deprecation.xml:20: Warning: android:inputMethod is deprecated: Use inputType instead [Deprecated]\n" +
- " android:inputMethod=\"@+id/foo\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/deprecation.xml:21: Warning: android:numeric is deprecated: Use inputType instead [Deprecated]\n" +
- " android:numeric=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/deprecation.xml:22: Warning: android:password is deprecated: Use inputType instead [Deprecated]\n" +
- " android:password=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/deprecation.xml:23: Warning: android:phoneNumber is deprecated: Use inputType instead [Deprecated]\n" +
- " android:phoneNumber=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/deprecation.xml:26: Warning: android:editable is deprecated: <EditText> is already editable [Deprecated]\n" +
- " <EditText android:editable=\"true\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/deprecation.xml:27: Warning: android:editable is deprecated: Use inputType instead [Deprecated]\n" +
- " <EditText android:editable=\"false\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 10 warnings\n",
-
- lintProject(
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "res/layout/deprecation.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/DetectMissingPrefixTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/DetectMissingPrefixTest.java
deleted file mode 100644
index e8a6f23..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/DetectMissingPrefixTest.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class DetectMissingPrefixTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new DetectMissingPrefix();
- }
-
- public void test() throws Exception {
- assertEquals(
- "res/layout/namespace.xml:2: Error: Attribute is missing the Android namespace prefix [MissingPrefix]\n" +
- "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" xmlns:other=\"http://foo.bar\" android:id=\"@+id/newlinear\" android:orientation=\"vertical\" android:layout_width=\"match_parent\" android:layout_height=\"match_parent\" orientation=\"true\">\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/namespace.xml:3: Error: Attribute is missing the Android namespace prefix [MissingPrefix]\n" +
- " <Button style=\"@style/setupWizardOuterFrame\" android.text=\"Button\" android:id=\"@+id/button1\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\"></Button>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/namespace.xml:5: Error: Unexpected namespace prefix \"other\" found for tag LinearLayout [MissingPrefix]\n" +
- " <LinearLayout other:orientation=\"horizontal\"/>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "3 errors, 0 warnings\n",
-
- lintFiles("res/layout/namespace.xml"));
- }
-
- public void testCustomNamespace() throws Exception {
- assertEquals(
- "res/layout/namespace2.xml:8: Error: Attribute is missing the Android namespace prefix [MissingPrefix]\n" +
- " customprefix:orientation=\"vertical\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n" +
- "",
-
- lintFiles("res/layout/namespace2.xml"));
- }
-
- public void testManifest() throws Exception {
- assertEquals(
- "AndroidManifest.xml:4: Error: Attribute is missing the Android namespace prefix [MissingPrefix]\n" +
- " versionCode=\"1\"\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:11: Error: Attribute is missing the Android namespace prefix [MissingPrefix]\n" +
- " android.label=\"@string/app_name\" >\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:18: Error: Attribute is missing the Android namespace prefix [MissingPrefix]\n" +
- " <category name=\"android.intent.category.LAUNCHER\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "3 errors, 0 warnings\n",
-
- lintFiles("missingprefix.xml=>AndroidManifest.xml"));
- }
-
- public void testLayoutAttributes() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintFiles("res/layout/namespace3.xml"));
- }
-
- public void testLayoutAttributes2() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintFiles("res/layout/namespace4.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/DosLineEndingDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/DosLineEndingDetectorTest.java
deleted file mode 100644
index 3682420..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/DosLineEndingDetectorTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class DosLineEndingDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new DosLineEndingDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "res/layout/crcrlf.xml:4: Error: Incorrect line ending: found carriage return (\\r) without corresponding newline (\\n) [MangledCRLF]\n" +
- " android:layout_height=\"match_parent\" >\r\n" +
- "^\n" +
- "1 errors, 0 warnings\n",
- lintProject("res/layout/crcrlf.xml"));
- }
-
- public void testIgnore() throws Exception {
- assertEquals(
- "No warnings.",
- lintProject("res/layout/crcrlf_ignore.xml"));
- }
-
- public void testNegative() throws Exception {
- // Make sure we don't get warnings for a correct file
- assertEquals(
- "No warnings.",
- lintProject("res/layout/layout1.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/DuplicateIdDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/DuplicateIdDetectorTest.java
deleted file mode 100644
index 72a9035..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/DuplicateIdDetectorTest.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class DuplicateIdDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new DuplicateIdDetector();
- }
-
- public void testDuplicate() throws Exception {
- assertEquals(
- "res/layout/duplicate.xml:5: Warning: Duplicate id @+id/android_logo, already defined earlier in this layout [DuplicateIds]\n" +
- " <ImageButton android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/layout/duplicate.xml:4: @+id/android_logo originally defined here\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintFiles("res/layout/duplicate.xml"));
- }
-
- public void testDuplicateChains() throws Exception {
- assertEquals(
- "res/layout/layout1.xml:7: Warning: Duplicate id @+id/button1, defined or included multiple times in layout/layout1.xml: [layout/layout1.xml defines @+id/button1, layout/layout1.xml => layout/layout2.xml => layout/layout3.xml defines @+id/button1, layout/layout1.xml => layout/layout2.xml => layout/layout4.xml defines @+id/button1] [DuplicateIncludedIds]\n" +
- " <include\n" +
- " ^\n" +
- " res/layout/layout1.xml:13: Defined here\n" +
- " res/layout/layout3.xml:8: Defined here, included via layout/layout1.xml => layout/layout2.xml => layout/layout3.xml defines @+id/button1\n" +
- " res/layout/layout4.xml:8: Defined here, included via layout/layout1.xml => layout/layout2.xml => layout/layout4.xml defines @+id/button1\n" +
- "res/layout/layout1.xml:7: Warning: Duplicate id @+id/button2, defined or included multiple times in layout/layout1.xml: [layout/layout1.xml defines @+id/button2, layout/layout1.xml => layout/layout2.xml => layout/layout4.xml defines @+id/button2] [DuplicateIncludedIds]\n" +
- " <include\n" +
- " ^\n" +
- " res/layout/layout1.xml:19: Defined here\n" +
- " res/layout/layout4.xml:14: Defined here, included via layout/layout1.xml => layout/layout2.xml => layout/layout4.xml defines @+id/button2\n" +
- "res/layout/layout2.xml:18: Warning: Duplicate id @+id/button1, defined or included multiple times in layout/layout2.xml: [layout/layout2.xml => layout/layout3.xml defines @+id/button1, layout/layout2.xml => layout/layout4.xml defines @+id/button1] [DuplicateIncludedIds]\n" +
- " <include\n" +
- " ^\n" +
- " res/layout/layout3.xml:8: Defined here, included via layout/layout2.xml => layout/layout3.xml defines @+id/button1\n" +
- " res/layout/layout4.xml:8: Defined here, included via layout/layout2.xml => layout/layout4.xml defines @+id/button1\n" +
- "0 errors, 3 warnings\n" +
- "",
-
- // layout1: defines @+id/button1, button2
- // layout3: defines @+id/button1
- // layout4: defines @+id/button1, button2
- // layout1 include layout2
- // layout2 includes layout3 and layout4
-
- // Therefore, layout3 and layout4 have no problems
- // In layout2, there's a duplicate definition of button1 (coming from 3 and 4)
- // In layout1, there's a duplicate definition of button1 (coming from layout1, 3 and 4)
- // In layout1, there'sa duplicate definition of button2 (coming from 1 and 4)
-
- lintProject("res/layout/layout1.xml", "res/layout/layout2.xml",
- "res/layout/layout3.xml", "res/layout/layout4.xml"));
- }
-
- public void testSuppress() throws Exception {
- assertEquals(
- "res/layout/layout2.xml:18: Warning: Duplicate id @+id/button1, defined or included multiple times in layout/layout2.xml: [layout/layout2.xml => layout/layout3.xml defines @+id/button1, layout/layout2.xml => layout/layout4.xml defines @+id/button1] [DuplicateIncludedIds]\n" +
- " <include\n" +
- " ^\n" +
- " res/layout/layout3.xml:8: Defined here, included via layout/layout2.xml => layout/layout3.xml defines @+id/button1\n" +
- " res/layout/layout4.xml:8: Defined here, included via layout/layout2.xml => layout/layout4.xml defines @+id/button1\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "res/layout/layout1_ignore.xml=>res/layout/layout1.xml",
- "res/layout/layout2.xml",
- "res/layout/layout3.xml",
- "res/layout/layout4.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/DuplicateResourceDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/DuplicateResourceDetectorTest.java
deleted file mode 100644
index a4a5a68..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/DuplicateResourceDetectorTest.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class DuplicateResourceDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new DuplicateResourceDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "res/values/customattr2.xml:2: Error: ContentFrame has already been defined in this folder [DuplicateDefinition]\n" +
- " <declare-styleable name=\"ContentFrame\">\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- " res/values/customattr.xml:2: Previously defined here\n" +
- "res/values/strings2.xml:19: Error: wallpaper_instructions has already been defined in this folder [DuplicateDefinition]\n" +
- " <string name=\"wallpaper_instructions\">Tap image to set landscape wallpaper</string>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/values/strings.xml:29: Previously defined here\n" +
- "2 errors, 0 warnings\n",
-
- lintProject(
- "res/values/strings.xml",
- "res/values-land/strings.xml=>res/values/strings2.xml",
- "res/values-cs/strings.xml",
- "res/values/customattr.xml",
- "res/values/customattr.xml=>res/values/customattr2.xml"));
- }
-
- public void testOk() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/values/strings.xml",
- "res/values-cs/strings.xml",
- "res/values-de-rDE/strings.xml",
- "res/values-es/strings.xml",
- "res/values-es-rUS/strings.xml",
- "res/values-land/strings.xml",
- "res/values-cs/arrays.xml",
- "res/values-es/donottranslate.xml",
- "res/values-nl-rNL/strings.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ExtraTextDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ExtraTextDetectorTest.java
deleted file mode 100644
index 9f6c2d3..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ExtraTextDetectorTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class ExtraTextDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new ExtraTextDetector();
- }
-
- public void testBroken() throws Exception {
- assertEquals(
- "res/layout/broken.xml:6: Warning: Unexpected text found in layout file: \"ImageButton android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_heigh...\" [ExtraText]\n" +
- " <Button android:text=\"Button\" android:id=\"@+id/button2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\"></Button>\n" +
- " ^\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintProject("res/layout/broken.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/FieldGetterDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/FieldGetterDetectorTest.java
deleted file mode 100644
index aa7607f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/FieldGetterDetectorTest.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class FieldGetterDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new FieldGetterDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/bytecode/GetterTest.java:47: Warning: Calling getter method getFoo1() on self is slower than field access (mFoo1) [FieldGetter]\n" +
- " getFoo1();\n" +
- " ~~~~~~~\n" +
- "src/test/bytecode/GetterTest.java:48: Warning: Calling getter method getFoo2() on self is slower than field access (mFoo2) [FieldGetter]\n" +
- " getFoo2();\n" +
- " ~~~~~~~\n" +
- "src/test/bytecode/GetterTest.java:52: Warning: Calling getter method isBar1() on self is slower than field access (mBar1) [FieldGetter]\n" +
- " isBar1();\n" +
- " ~~~~~~\n" +
- "src/test/bytecode/GetterTest.java:54: Warning: Calling getter method getFoo1() on self is slower than field access (mFoo1) [FieldGetter]\n" +
- " this.getFoo1();\n" +
- " ~~~~~~~\n" +
- "src/test/bytecode/GetterTest.java:55: Warning: Calling getter method getFoo2() on self is slower than field access (mFoo2) [FieldGetter]\n" +
- " this.getFoo2();\n" +
- " ~~~~~~~\n" +
- "0 errors, 5 warnings\n" +
- "",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "bytecode/GetterTest.java.txt=>src/test/bytecode/GetterTest.java",
- "bytecode/GetterTest.class.data=>bin/classes/test/bytecode/GetterTest.class"
- ));
- }
-
- public void testPostFroyo() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "apicheck/minsdk10.xml=>AndroidManifest.xml",
- "bytecode/GetterTest.java.txt=>src/test/bytecode/GetterTest.java",
- "bytecode/GetterTest.class.data=>bin/classes/test/bytecode/GetterTest.class"
- ));
- }
-
- public void testLibraries() throws Exception {
- // This tests the infrastructure: it makes sure that we *don't* run this
- // check in jars that are on the jar library dependency path (testJar() checks
- // that it *does* work for local jar classes)
- assertEquals(
- "No warnings.",
-
- lintProject(
- "bytecode/classpath-lib=>.classpath",
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "bytecode/GetterTest.java.txt=>src/test/bytecode/GetterTest.java",
- "bytecode/GetterTest.jar.data=>libs/library.jar"
- ));
- }
-
- public void testJar() throws Exception {
- assertEquals(
- "src/test/bytecode/GetterTest.java:47: Warning: Calling getter method getFoo1() on self is slower than field access (mFoo1) [FieldGetter]\n" +
- " getFoo1();\n" +
- " ~~~~~~~\n" +
- "src/test/bytecode/GetterTest.java:48: Warning: Calling getter method getFoo2() on self is slower than field access (mFoo2) [FieldGetter]\n" +
- " getFoo2();\n" +
- " ~~~~~~~\n" +
- "src/test/bytecode/GetterTest.java:52: Warning: Calling getter method isBar1() on self is slower than field access (mBar1) [FieldGetter]\n" +
- " isBar1();\n" +
- " ~~~~~~\n" +
- "src/test/bytecode/GetterTest.java:54: Warning: Calling getter method getFoo1() on self is slower than field access (mFoo1) [FieldGetter]\n" +
- " this.getFoo1();\n" +
- " ~~~~~~~\n" +
- "src/test/bytecode/GetterTest.java:55: Warning: Calling getter method getFoo2() on self is slower than field access (mFoo2) [FieldGetter]\n" +
- " this.getFoo2();\n" +
- " ~~~~~~~\n" +
- "0 errors, 5 warnings\n" +
- "",
-
- lintProject(
- "bytecode/classpath-jar=>.classpath",
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "bytecode/GetterTest.java.txt=>src/test/bytecode/GetterTest.java",
- "bytecode/GetterTest.jar.data=>bin/classes.jar"
- ));
- }
-
- public void testTruncatedData() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "bytecode/classpath-jar=>.classpath",
- "bytecode/GetterTest.jar.data=>bin/test/pkg/bogus.class"
- ));
- }
-
- public void testCornerCases() throws Exception {
- assertEquals(
- "src/test/pkg/TestFieldGetter.java:21: Warning: Calling getter method getPath() on self is slower than field access (path) [FieldGetter]\n" +
- " getPath(); // Should be flagged\n" +
- " ~~~~~~~\n" +
- "0 errors, 1 warnings\n",
-
- lintProject(
- "bytecode/classpath-jar=>.classpath",
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "bytecode/TestFieldGetter.java.txt=>src/test/pkg/TestFieldGetter.java",
- "bytecode/TestFieldGetter.class.data=>bin/classes/test/pkg/TestFieldGetter.class"
- ));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/FragmentDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/FragmentDetectorTest.java
deleted file mode 100644
index 0654ddc..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/FragmentDetectorTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class FragmentDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new FragmentDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/pkg/FragmentTest.java:10: Error: This fragment class should be public (test.pkg.FragmentTest.Fragment1) [ValidFragment]\n" +
- " private static class Fragment1 extends Fragment {\n" +
- " ^\n" +
- "src/test/pkg/FragmentTest.java:15: Error: This fragment inner class should be static (test.pkg.FragmentTest.Fragment2) [ValidFragment]\n" +
- " public class Fragment2 extends Fragment {\n" +
- " ^\n" +
- "src/test/pkg/FragmentTest.java:21: Error: The default constructor must be public [ValidFragment]\n" +
- " private Fragment3() {\n" +
- " ~~~~~~~~~\n" +
- "src/test/pkg/FragmentTest.java:26: Error: This fragment should provide a default constructor (a public constructor with no arguments) (test.pkg.FragmentTest.Fragment4) [ValidFragment]\n" +
- " public static class Fragment4 extends Fragment {\n" +
- " ~~~~~~~~~\n" +
- "src/test/pkg/FragmentTest.java:27: Error: Avoid non-default constructors in fragments: use a default constructor plus Fragment#setArguments(Bundle) instead [ValidFragment]\n" +
- " private Fragment4(int dummy) {\n" +
- " ~~~~~~~~~\n" +
- "src/test/pkg/FragmentTest.java:36: Error: Avoid non-default constructors in fragments: use a default constructor plus Fragment#setArguments(Bundle) instead [ValidFragment]\n" +
- " public Fragment5(int dummy) {\n" +
- " ~~~~~~~~~\n" +
- "6 errors, 0 warnings\n",
-
- lintProject(
- "bytecode/FragmentTest$Fragment1.class.data=>bin/classes/test/pkg/FragmentTest$Fragment1.class",
- "bytecode/FragmentTest$Fragment2.class.data=>bin/classes/test/pkg/FragmentTest$Fragment2.class",
- "bytecode/FragmentTest$Fragment3.class.data=>bin/classes/test/pkg/FragmentTest$Fragment3.class",
- "bytecode/FragmentTest$Fragment4.class.data=>bin/classes/test/pkg/FragmentTest$Fragment4.class",
- "bytecode/FragmentTest$Fragment5.class.data=>bin/classes/test/pkg/FragmentTest$Fragment5.class",
- "bytecode/FragmentTest$Fragment6.class.data=>bin/classes/test/pkg/FragmentTest$Fragment6.class",
- "bytecode/FragmentTest$NotAFragment.class.data=>bin/classes/test/pkg/FragmentTest$NotAFragment.class",
- "bytecode/FragmentTest.java.txt=>src/test/pkg/FragmentTest.java"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/GridLayoutDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/GridLayoutDetectorTest.java
deleted file mode 100644
index dee52e1..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/GridLayoutDetectorTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class GridLayoutDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new GridLayoutDetector();
- }
-
- public void testGridLayout1() throws Exception {
- assertEquals(
- "res/layout/gridlayout.xml:36: Error: Column attribute (3) exceeds declared grid column count (2) [GridLayout]\n" +
- " android:layout_column=\"3\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n" +
- "",
- lintFiles("res/layout/gridlayout.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/HandlerDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/HandlerDetectorTest.java
deleted file mode 100644
index 1e9350c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/HandlerDetectorTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class HandlerDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new HandlerDetector();
- }
-
- public void testRegistered() throws Exception {
- assertEquals(
- "src/test/pkg/HandlerTest.java:12: Warning: This Handler class should be static or leaks might occur (test.pkg.HandlerTest.Inner) [HandlerLeak]\n" +
- " public class Inner extends Handler { // ERROR\n" +
- " ~~~~~\n" +
- "src/test/pkg/HandlerTest.java:18: Warning: This Handler class should be static or leaks might occur (test.pkg.HandlerTest.1) [HandlerLeak]\n" +
- " Handler anonymous = new Handler() { // ERROR\n" +
- " ~~~~~~~\n" +
- "0 errors, 2 warnings\n" +
- "",
-
- lintProject(
- "bytecode/HandlerTest.java.txt=>src/test/pkg/HandlerTest.java",
- "bytecode/HandlerTest.class.data=>bin/classes/test/pkg/HandlerTest.class",
- "bytecode/HandlerTest$Inner.class.data=>bin/classes/test/pkg/HandlerTest$Inner.class",
- "bytecode/HandlerTest$StaticInner.class.data=>bin/classes/test/pkg/HandlerTest$StaticInner.class",
- "bytecode/HandlerTest$1.class.data=>bin/classes/test/pkg/HandlerTest$1.class"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/HardcodedDebugModeDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/HardcodedDebugModeDetectorTest.java
deleted file mode 100644
index edb6c50..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/HardcodedDebugModeDetectorTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class HardcodedDebugModeDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new HardcodedDebugModeDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "AndroidManifest.xml:10: Warning: Avoid hardcoding the debug mode; leaving it out allows debug and release builds to automatically assign one [HardcodedDebugMode]\n" +
- " android:debuggable=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintProject("debuggable.xml=>AndroidManifest.xml"));
- }
-
- public void testOk() throws Exception {
- assertEquals(
- "No warnings.",
- lintProject("AndroidManifest.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/HardcodedValuesDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/HardcodedValuesDetectorTest.java
deleted file mode 100644
index b326fd4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/HardcodedValuesDetectorTest.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class HardcodedValuesDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new HardcodedValuesDetector();
- }
-
- public void testStrings() throws Exception {
- assertEquals(
- "res/layout/accessibility.xml:3: Warning: [I18N] Hardcoded string \"Button\", should use @string resource [HardcodedText]\n" +
- " <Button android:text=\"Button\" android:id=\"@+id/button1\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\"></Button>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/accessibility.xml:6: Warning: [I18N] Hardcoded string \"Button\", should use @string resource [HardcodedText]\n" +
- " <Button android:text=\"Button\" android:id=\"@+id/button2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\"></Button>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 2 warnings\n",
-
- lintFiles("res/layout/accessibility.xml"));
- }
-
- public void testMenus() throws Exception {
- assertEquals(
- "res/menu/menu.xml:7: Warning: [I18N] Hardcoded string \"My title 1\", should use @string resource [HardcodedText]\n" +
- " android:title=\"My title 1\">\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/menu/menu.xml:13: Warning: [I18N] Hardcoded string \"My title 2\", should use @string resource [HardcodedText]\n" +
- " android:title=\"My title 2\">\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 2 warnings\n",
-
- lintFiles("res/menu/menu.xml"));
- }
-
- public void testMenusOk() throws Exception {
- assertEquals(
- "No warnings.",
- lintFiles("res/menu/titles.xml"));
- }
-
- public void testSuppress() throws Exception {
- // All but one errors in the file contain ignore attributes - direct, inherited
- // and lists
- assertEquals(
- "res/layout/ignores.xml:61: Warning: [I18N] Hardcoded string \"Hardcoded\", should use @string resource [HardcodedText]\n" +
- " android:text=\"Hardcoded\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintFiles("res/layout/ignores.xml"));
- }
-
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/IconDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/IconDetectorTest.java
deleted file mode 100644
index 7cbbdc5..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/IconDetectorTest.java
+++ /dev/null
@@ -1,461 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.annotations.NonNull;
-import com.android.tools.lint.client.api.LintClient;
-import com.android.tools.lint.client.api.LintDriver;
-import com.android.tools.lint.detector.api.Detector;
-import com.android.tools.lint.detector.api.Issue;
-import com.android.tools.lint.detector.api.Project;
-
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-@SuppressWarnings("javadoc")
-public class IconDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new IconDetector();
- }
-
- private Set<Issue> mEnabled = new HashSet<Issue>();
- private boolean mAbbreviate;
-
- private static Set<Issue> ALL = new HashSet<Issue>();
- static {
- ALL.add(IconDetector.DUPLICATES_CONFIGURATIONS);
- ALL.add(IconDetector.DUPLICATES_NAMES);
- ALL.add(IconDetector.GIF_USAGE);
- ALL.add(IconDetector.ICON_DENSITIES);
- ALL.add(IconDetector.ICON_DIP_SIZE);
- ALL.add(IconDetector.ICON_EXTENSION);
- ALL.add(IconDetector.ICON_LOCATION);
- ALL.add(IconDetector.ICON_MISSING_FOLDER);
- ALL.add(IconDetector.ICON_NODPI);
- ALL.add(IconDetector.ICON_COLORS);
- ALL.add(IconDetector.ICON_XML_AND_PNG);
- ALL.add(IconDetector.ICON_LAUNCHER_SHAPE);
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- mAbbreviate = true;
- }
-
- @Override
- protected void configureDriver(LintDriver driver) {
- driver.setAbbreviating(mAbbreviate);
- }
-
- @Override
- protected TestConfiguration getConfiguration(LintClient client, Project project) {
- return new TestConfiguration(client, project, null) {
- @Override
- public boolean isEnabled(@NonNull Issue issue) {
- return super.isEnabled(issue) && mEnabled.contains(issue);
- }
- };
- }
-
- public void test() throws Exception {
- mEnabled = ALL;
- assertEquals(
- "res/drawable-mdpi/sample_icon.gif: Warning: Using the .gif format for bitmaps is discouraged [GifUsage]\n" +
- "res/drawable/ic_launcher.png: Warning: The ic_launcher.png icon has identical contents in the following configuration folders: drawable-mdpi, drawable [IconDuplicatesConfig]\n" +
- " res/drawable-mdpi/ic_launcher.png: <No location-specific message\n" +
- "res/drawable/ic_launcher.png: Warning: Found bitmap drawable res/drawable/ic_launcher.png in densityless folder [IconLocation]\n" +
- "res/drawable-hdpi: Warning: Missing the following drawables in drawable-hdpi: sample_icon.gif (found in drawable-mdpi) [IconDensities]\n" +
- "res: Warning: Missing density variation folders in res: drawable-xhdpi [IconMissingDensityFolder]\n" +
- "0 errors, 5 warnings\n" +
- "",
-
- lintProject(
- // Use minSDK4 to ensure that we get warnings about missing drawables
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "res/drawable/ic_launcher.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher.png",
- "res/drawable-mdpi/sample_icon.gif",
- // Make a dummy file named .svn to make sure it doesn't get seen as
- // an icon name
- "res/drawable-mdpi/sample_icon.gif=>res/drawable-hdpi/.svn",
- "res/drawable-hdpi/ic_launcher.png"));
- }
-
- public void testMixed() throws Exception {
- mEnabled = Collections.singleton(IconDetector.ICON_XML_AND_PNG);
- assertEquals(
- "res/drawable/background.xml: Warning: The following images appear both as density independent .xml files and as bitmap files: res/drawable-mdpi/background.png, res/drawable/background.xml [IconXmlAndPng]\n" +
- " res/drawable-mdpi/background.png: <No location-specific message\n" +
- "0 errors, 1 warnings\n",
-
- lintProject(
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "apicheck/minsdk4.xml=>res/drawable/background.xml",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/background.png"));
- }
-
- public void testApi1() throws Exception {
- mEnabled = ALL;
- assertEquals(
- "No warnings.",
-
- lintProject(
- // manifest file which specifies uses sdk = 2
- "apicheck/minsdk2.xml=>AndroidManifest.xml",
- "res/drawable/ic_launcher.png"));
- }
-
- public void test2() throws Exception {
- mEnabled = ALL;
- assertEquals(
- "res/drawable-hdpi/other.9.png: Warning: The following unrelated icon files have identical contents: appwidget_bg.9.png, other.9.png [IconDuplicates]\n" +
- " res/drawable-hdpi/appwidget_bg.9.png: <No location-specific message\n" +
- "res/drawable-hdpi/unrelated.png: Warning: The following unrelated icon files have identical contents: ic_launcher.png, unrelated.png [IconDuplicates]\n" +
- " res/drawable-hdpi/ic_launcher.png: <No location-specific message\n" +
- "res: Warning: Missing density variation folders in res: drawable-mdpi, drawable-xhdpi [IconMissingDensityFolder]\n" +
- "0 errors, 3 warnings\n" +
- "",
-
- lintProject(
- "res/drawable-hdpi/unrelated.png",
- "res/drawable-hdpi/appwidget_bg.9.png",
- "res/drawable-hdpi/appwidget_bg_focus.9.png",
- "res/drawable-hdpi/other.9.png",
- "res/drawable-hdpi/ic_launcher.png"
- ));
- }
-
- public void testNoDpi() throws Exception {
- mEnabled = ALL;
- assertEquals(
- "res/drawable-mdpi/frame.png: Warning: The following images appear in both -nodpi and in a density folder: frame.png [IconNoDpi]\n" +
- "res/drawable-xlarge-nodpi-v11/frame.png: Warning: The frame.png icon has identical contents in the following configuration folders: drawable-mdpi, drawable-nodpi, drawable-xlarge-nodpi-v11 [IconDuplicatesConfig]\n" +
- " res/drawable-nodpi/frame.png: <No location-specific message\n" +
- " res/drawable-mdpi/frame.png: <No location-specific message\n" +
- "res: Warning: Missing density variation folders in res: drawable-hdpi, drawable-xhdpi [IconMissingDensityFolder]\n" +
- "0 errors, 3 warnings\n" +
- "",
-
- lintProject(
- "res/drawable-mdpi/frame.png",
- "res/drawable-nodpi/frame.png",
- "res/drawable-xlarge-nodpi-v11/frame.png"));
- }
-
- public void testNoDpi2() throws Exception {
- mEnabled = ALL;
- // Having additional icon names in the no-dpi folder should not cause any complaints
- assertEquals(
- "res/drawable-xhdpi/frame.png: Warning: The image frame.png varies significantly in its density-independent (dip) size across the various density versions: drawable-ldpi/frame.png: 629x387 dp (472x290 px), drawable-mdpi/frame.png: 472x290 dp (472x290 px), drawable-hdpi/frame.png: 315x193 dp (472x290 px), drawable-xhdpi/frame.png: 236x145 dp (472x290 px) [IconDipSize]\n" +
- " res/drawable-hdpi/frame.png: <No location-specific message\n" +
- " res/drawable-mdpi/frame.png: <No location-specific message\n" +
- " res/drawable-ldpi/frame.png: <No location-specific message\n" +
- "res/drawable-xhdpi/frame.png: Warning: The following unrelated icon files have identical contents: frame.png, frame.png, frame.png, file1.png, file2.png, frame.png [IconDuplicates]\n" +
- " res/drawable-nodpi/file2.png: <No location-specific message\n" +
- " res/drawable-nodpi/file1.png: <No location-specific message\n" +
- " res/drawable-mdpi/frame.png: <No location-specific message\n" +
- " res/drawable-ldpi/frame.png: <No location-specific message\n" +
- " res/drawable-hdpi/frame.png: <No location-specific message\n" +
- "0 errors, 2 warnings\n" +
- "",
-
- lintProject(
- "res/drawable-mdpi/frame.png=>res/drawable-mdpi/frame.png",
- "res/drawable-mdpi/frame.png=>res/drawable-hdpi/frame.png",
- "res/drawable-mdpi/frame.png=>res/drawable-ldpi/frame.png",
- "res/drawable-mdpi/frame.png=>res/drawable-xhdpi/frame.png",
- "res/drawable-mdpi/frame.png=>res/drawable-nodpi/file1.png",
- "res/drawable-mdpi/frame.png=>res/drawable-nodpi/file2.png"));
- }
-
- public void testNoDpiMix() throws Exception {
- mEnabled = ALL;
- assertEquals(
- "res/drawable-mdpi/frame.xml: Warning: The following images appear in both -nodpi and in a density folder: frame.png, frame.xml [IconNoDpi]\n" +
- " res/drawable-mdpi/frame.png: <No location-specific message\n" +
- "res/drawable-nodpi/frame.xml: Warning: The following images appear both as density independent .xml files and as bitmap files: res/drawable-mdpi/frame.png, res/drawable-nodpi/frame.xml [IconXmlAndPng]\n" +
- " res/drawable-mdpi/frame.png: <No location-specific message\n" +
- "res: Warning: Missing density variation folders in res: drawable-hdpi, drawable-xhdpi [IconMissingDensityFolder]\n" +
- "0 errors, 3 warnings\n",
-
- lintProject(
- "res/drawable-mdpi/frame.png",
- "res/drawable/states.xml=>res/drawable-nodpi/frame.xml"));
- }
-
-
- public void testMixedFormat() throws Exception {
- mEnabled = ALL;
- // Test having a mixture of .xml and .png resources for the same name
- // Make sure we don't get:
- // drawable-hdpi: Warning: Missing the following drawables in drawable-hdpi: f.png (found in drawable-mdpi)
- // drawable-xhdpi: Warning: Missing the following drawables in drawable-xhdpi: f.png (found in drawable-mdpi)
- assertEquals(
- "res/drawable-xhdpi/f.xml: Warning: The following images appear both as density independent .xml files and as bitmap files: res/drawable-hdpi/f.xml, res/drawable-mdpi/f.png [IconXmlAndPng]\n" +
- " res/drawable-mdpi/f.png: <No location-specific message\n" +
- " res/drawable-hdpi/f.xml: <No location-specific message\n" +
- "0 errors, 1 warnings\n",
-
- lintProject(
- "res/drawable-mdpi/frame.png=>res/drawable-mdpi/f.png",
- "res/drawable/states.xml=>res/drawable-hdpi/f.xml",
- "res/drawable/states.xml=>res/drawable-xhdpi/f.xml"));
- }
-
- public void testMisleadingFileName() throws Exception {
- mEnabled = Collections.singleton(IconDetector.ICON_EXTENSION);
- assertEquals(
- "res/drawable-mdpi/frame.gif: Warning: Misleading file extension; named .gif but the file format is png [IconExtension]\n" +
- "res/drawable-mdpi/frame.jpg: Warning: Misleading file extension; named .jpg but the file format is png [IconExtension]\n" +
- "res/drawable-mdpi/myjpg.png: Warning: Misleading file extension; named .png but the file format is JPEG [IconExtension]\n" +
- "res/drawable-mdpi/sample_icon.jpeg: Warning: Misleading file extension; named .jpeg but the file format is gif [IconExtension]\n" +
- "res/drawable-mdpi/sample_icon.jpg: Warning: Misleading file extension; named .jpg but the file format is gif [IconExtension]\n" +
- "res/drawable-mdpi/sample_icon.png: Warning: Misleading file extension; named .png but the file format is gif [IconExtension]\n" +
- "0 errors, 6 warnings\n",
-
- lintProject(
- "res/drawable-mdpi/sample_icon.jpg=>res/drawable-mdpi/myjpg.jpg", // VALID
- "res/drawable-mdpi/sample_icon.jpg=>res/drawable-mdpi/myjpg.jpeg", // VALID
- "res/drawable-mdpi/frame.png=>res/drawable-mdpi/frame.gif",
- "res/drawable-mdpi/frame.png=>res/drawable-mdpi/frame.jpg",
- "res/drawable-mdpi/sample_icon.jpg=>res/drawable-mdpi/myjpg.png",
- "res/drawable-mdpi/sample_icon.gif=>res/drawable-mdpi/sample_icon.jpg",
- "res/drawable-mdpi/sample_icon.gif=>res/drawable-mdpi/sample_icon.jpeg",
- "res/drawable-mdpi/sample_icon.gif=>res/drawable-mdpi/sample_icon.png"));
- }
-
- public void testColors() throws Exception {
- mEnabled = Collections.singleton(IconDetector.ICON_COLORS);
- assertEquals(
- "res/drawable-mdpi/ic_menu_my_action.png: Warning: Action Bar icons should use a single gray color (#333333 for light themes (with 60%/30% opacity for enabled/disabled), and #FFFFFF with opacity 80%/30% for dark themes [IconColors]\n" +
- "res/drawable-mdpi-v11/ic_stat_my_notification.png: Warning: Notification icons must be entirely white [IconColors]\n" +
- "res/drawable-mdpi-v9/ic_stat_my_notification2.png: Warning: Notification icons must be entirely white [IconColors]\n" +
- "0 errors, 3 warnings\n",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_menu_my_action.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi-v11/ic_stat_my_notification.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi-v9/ic_stat_my_notification2.png",
- "res/drawable-mdpi/ic_menu_add_clip_normal.png")); // OK
- }
-
- public void testNotActionBarIcons() throws Exception {
- mEnabled = Collections.singleton(IconDetector.ICON_COLORS);
- assertEquals(
- "No warnings.",
-
- // No Java code designates the menu as an action bar menu
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "res/menu/menu.xml",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon1.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon2.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon3.png", // Not action bar
- "res/drawable-mdpi/ic_menu_add_clip_normal.png")); // OK
- }
-
- public void testActionBarIcons() throws Exception {
- mEnabled = Collections.singleton(IconDetector.ICON_COLORS);
- assertEquals(
- "res/drawable-mdpi/icon1.png: Warning: Action Bar icons should use a single gray color (#333333 for light themes (with 60%/30% opacity for enabled/disabled), and #FFFFFF with opacity 80%/30% for dark themes [IconColors]\n" +
- "res/drawable-mdpi/icon2.png: Warning: Action Bar icons should use a single gray color (#333333 for light themes (with 60%/30% opacity for enabled/disabled), and #FFFFFF with opacity 80%/30% for dark themes [IconColors]\n" +
- "0 errors, 2 warnings\n",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "res/menu/menu.xml",
- "src/test/pkg/ActionBarTest.java.txt=>src/test/pkg/ActionBarTest.java",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon1.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon2.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon3.png", // Not action bar
- "res/drawable-mdpi/ic_menu_add_clip_normal.png")); // OK
- }
-
- public void testOkActionBarIcons() throws Exception {
- mEnabled = Collections.singleton(IconDetector.ICON_COLORS);
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "res/menu/menu.xml",
- "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon1.png",
- "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon2.png"));
- }
-
- public void testNotificationIcons() throws Exception {
- mEnabled = Collections.singleton(IconDetector.ICON_COLORS);
- assertEquals(
- "res/drawable-mdpi/icon1.png: Warning: Notification icons must be entirely white [IconColors]\n" +
- "res/drawable-mdpi/icon2.png: Warning: Notification icons must be entirely white [IconColors]\n" +
- "res/drawable-mdpi/icon3.png: Warning: Notification icons must be entirely white [IconColors]\n" +
- "res/drawable-mdpi/icon4.png: Warning: Notification icons must be entirely white [IconColors]\n" +
- "res/drawable-mdpi/icon5.png: Warning: Notification icons must be entirely white [IconColors]\n" +
- "0 errors, 5 warnings\n",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "src/test/pkg/NotificationTest.java.txt=>src/test/pkg/NotificationTest.java",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon1.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon2.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon3.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon4.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon5.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon6.png", // not a notification
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon7.png", // ditto
- "res/drawable-mdpi/ic_menu_add_clip_normal.png")); // OK
- }
-
- public void testOkNotificationIcons() throws Exception {
- mEnabled = Collections.singleton(IconDetector.ICON_COLORS);
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "src/test/pkg/NotificationTest.java.txt=>src/test/pkg/NotificationTest.java",
- "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon1.png",
- "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon2.png",
- "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon3.png",
- "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon4.png",
- "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon5.png"));
- }
-
- public void testExpectedSize() throws Exception {
- mEnabled = Collections.singleton(IconDetector.ICON_EXPECTED_SIZE);
- assertEquals(
- "res/drawable-mdpi/ic_launcher.png: Warning: Incorrect icon size for drawable-mdpi/ic_launcher.png: expected 48x48, but was 24x24 [IconExpectedSize]\n" +
- "res/drawable-mdpi/icon1.png: Warning: Incorrect icon size for drawable-mdpi/icon1.png: expected 32x32, but was 48x48 [IconExpectedSize]\n" +
- "res/drawable-mdpi/icon3.png: Warning: Incorrect icon size for drawable-mdpi/icon3.png: expected 24x24, but was 48x48 [IconExpectedSize]\n" +
- "0 errors, 3 warnings\n",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "src/test/pkg/NotificationTest.java.txt=>src/test/pkg/NotificationTest.java",
- "res/menu/menu.xml",
- "src/test/pkg/ActionBarTest.java.txt=>src/test/pkg/ActionBarTest.java",
-
- // 3 wrong-sized icons:
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon1.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/icon3.png",
- "res/drawable-mdpi/stat_notify_alarm.png=>res/drawable-mdpi/ic_launcher.png",
-
- // OK sizes
- "res/drawable-mdpi/ic_menu_add_clip_normal.png=>res/drawable-mdpi/icon2.png",
- "res/drawable-mdpi/stat_notify_alarm.png=>res/drawable-mdpi/icon4.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher2.png"
- ));
- }
-
- public void testAbbreviate() throws Exception {
- mEnabled = Collections.singleton(IconDetector.ICON_DENSITIES);
- assertEquals(
- "res/drawable-hdpi: Warning: Missing the following drawables in drawable-hdpi: " +
- "ic_launcher10.png, ic_launcher11.png, ic_launcher12.png, ic_launcher2.png, " +
- "ic_launcher3.png... (6 more) [IconDensities]\n" +
- "res/drawable-xhdpi: Warning: Missing the following drawables in drawable-xhdpi: " +
- "ic_launcher10.png, ic_launcher11.png, ic_launcher12.png, ic_launcher2.png, " +
- "ic_launcher3.png... (6 more) [IconDensities]\n" +
- "0 errors, 2 warnings\n",
-
- lintProject(
- // Use minSDK4 to ensure that we get warnings about missing drawables
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "res/drawable/ic_launcher.png=>res/drawable-hdpi/ic_launcher1.png",
- "res/drawable/ic_launcher.png=>res/drawable-xhdpi/ic_launcher1.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher1.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher2.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher3.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher4.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher5.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher6.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher7.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher8.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher9.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher10.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher11.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher12.png"
- ));
- }
-
-
- public void testShowAll() throws Exception {
- mEnabled = Collections.singleton(IconDetector.ICON_DENSITIES);
- mAbbreviate = false;
- assertEquals(
- "res/drawable-hdpi: Warning: Missing the following drawables in drawable-hdpi: " +
- "ic_launcher10.png, ic_launcher11.png, ic_launcher12.png, ic_launcher2.png, " +
- "ic_launcher3.png, ic_launcher4.png, ic_launcher5.png, ic_launcher6.png, " +
- "ic_launcher7.png, ic_launcher8.png, ic_launcher9.png [IconDensities]\n" +
- "res/drawable-xhdpi: Warning: Missing the following drawables in drawable-xhdpi: " +
- "ic_launcher10.png, ic_launcher11.png, ic_launcher12.png, ic_launcher2.png," +
- " ic_launcher3.png, ic_launcher4.png, ic_launcher5.png, ic_launcher6.png, " +
- "ic_launcher7.png, ic_launcher8.png, ic_launcher9.png [IconDensities]\n" +
- "0 errors, 2 warnings\n",
-
- lintProject(
- // Use minSDK4 to ensure that we get warnings about missing drawables
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "res/drawable/ic_launcher.png=>res/drawable-hdpi/ic_launcher1.png",
- "res/drawable/ic_launcher.png=>res/drawable-xhdpi/ic_launcher1.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher1.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher2.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher3.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher4.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher5.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher6.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher7.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher8.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher9.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher10.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher11.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher12.png"
- ));
- }
-
- public void testIgnoreMissingFolders() throws Exception {
- mEnabled = Collections.singleton(IconDetector.ICON_DENSITIES);
- assertEquals(
- "No warnings.",
-
- lintProject(
- // Use minSDK4 to ensure that we get warnings about missing drawables
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "ignoremissing.xml=>lint.xml",
- "res/drawable/ic_launcher.png=>res/drawable-hdpi/ic_launcher1.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher1.png",
- "res/drawable/ic_launcher.png=>res/drawable-mdpi/ic_launcher2.png"
- ));
- }
-
- public void testSquareLauncher() throws Exception {
- mEnabled = Collections.singleton(IconDetector.ICON_LAUNCHER_SHAPE);
- assertEquals(
- "res/drawable-hdpi/ic_launcher_filled.png: Warning: Launcher icons should not fill every pixel of their square region; see the design guide for details [IconLauncherShape]\n" +
- "0 errors, 1 warnings\n",
-
- lintProject(
- "apicheck/minsdk4.xml=>AndroidManifest.xml",
- "res/drawable-hdpi/filled.png=>res/drawable-hdpi/ic_launcher_filled.png",
- "res/drawable-mdpi/sample_icon.gif=>res/drawable-mdpi/ic_launcher_2.gif"
- ));
- }
-} \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/InefficientWeightDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/InefficientWeightDetectorTest.java
deleted file mode 100644
index c642ab1..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/InefficientWeightDetectorTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class InefficientWeightDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new InefficientWeightDetector();
- }
-
- public void testWeights() throws Exception {
- assertEquals(
- "res/layout/inefficient_weight.xml:3: Error: Wrong orientation? No orientation specified, and the default is horizontal, yet this layout has multiple children where at least one has layout_width=\"match_parent\" [Orientation]\n" +
- "<LinearLayout\n" +
- "^\n" +
- "res/layout/inefficient_weight.xml:10: Warning: Use a layout_width of 0dip instead of match_parent for better performance [InefficientWeight]\n" +
- " android:layout_width=\"match_parent\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/inefficient_weight.xml:24: Warning: Use a layout_height of 0dip instead of wrap_content for better performance [InefficientWeight]\n" +
- " android:layout_height=\"wrap_content\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 2 warnings\n",
- lintFiles("res/layout/inefficient_weight.xml"));
- }
-
- public void testWeights2() throws Exception {
- assertEquals(
- "res/layout/nested_weights.xml:23: Warning: Nested weights are bad for performance [NestedWeights]\n" +
- " android:layout_weight=\"1\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintFiles("res/layout/nested_weights.xml"));
- }
-
- public void testWeights3() throws Exception {
- assertEquals(
- "res/layout/baseline_weights.xml:2: Warning: Set android:baselineAligned=\"false\" on this element for better performance [DisableBaselineAlignment]\n" +
- "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
- "^\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintFiles("res/layout/baseline_weights.xml"));
- }
-
- public void testWeights4() throws Exception {
- assertEquals(
- "res/layout/activity_item_two_pane.xml:1: Warning: Set android:baselineAligned=\"false\" on this element for better performance [DisableBaselineAlignment]\n" +
- "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
- "^\n" +
- "0 errors, 1 warnings\n",
- lintFiles("res/layout/activity_item_two_pane.xml"));
- }
-
- public void testNoVerticalWeights3() throws Exception {
- // Orientation=vertical
- assertEquals(
- "No warnings.",
- lintFiles("res/layout/baseline_weights2.xml"));
- }
-
- public void testNoVerticalWeights4() throws Exception {
- // Orientation not specified ==> horizontal
- assertEquals(
- "res/layout/baseline_weights3.xml:2: Warning: Set android:baselineAligned=\"false\" on this element for better performance [DisableBaselineAlignment]\n" +
- "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
- "^\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintFiles("res/layout/baseline_weights3.xml"));
- }
-
- public void testSuppressed() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintFiles("res/layout/inefficient_weight2.xml"));
- }
-
- public void testNestedWeights() throws Exception {
- // Regression test for http://code.google.com/p/android/issues/detail?id=22889
- // (Comment 8)
- assertEquals(
- "No warnings.",
-
- lintFiles("res/layout/nested_weights2.xml"));
- }
-
- public void testWrong0Dp() throws Exception {
- assertEquals(
- "res/layout/wrong0dp.xml:19: Error: Suspicious size: this will make the view invisible, should be used with layout_weight [Suspicious0dp]\n" +
- " android:layout_width=\"0dp\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/wrong0dp.xml:25: Error: Suspicious size: this will make the view invisible, should be used with layout_weight [Suspicious0dp]\n" +
- " android:layout_height=\"0dp\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/wrong0dp.xml:34: Error: Suspicious size: this will make the view invisible, probably intended for layout_height [Suspicious0dp]\n" +
- " android:layout_width=\"0dp\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/wrong0dp.xml:67: Error: Suspicious size: this will make the view invisible, probably intended for layout_width [Suspicious0dp]\n" +
- " android:layout_height=\"0dp\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/wrong0dp.xml:90: Error: Suspicious size: this will make the view invisible, probably intended for layout_width [Suspicious0dp]\n" +
- " android:layout_height=\"0dp\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "5 errors, 0 warnings\n",
-
- lintFiles("res/layout/wrong0dp.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/InvalidPackageDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/InvalidPackageDetectorTest.java
deleted file mode 100644
index b634255..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/InvalidPackageDetectorTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class InvalidPackageDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new InvalidPackageDetector();
- }
-
- public void testUnsupportedJavaLibraryCode() throws Exception {
- // See http://code.google.com/p/android/issues/detail?id=39109
- assertEquals(
- "libs/unsupported.jar: Error: Invalid package reference in library; not included in Android: java.awt. Referenced from test.pkg.LibraryClass. [InvalidPackage]\n" +
- "libs/unsupported.jar: Error: Invalid package reference in library; not included in Android: javax.swing. Referenced from test.pkg.LibraryClass. [InvalidPackage]\n" +
- "2 errors, 0 warnings\n",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "apicheck/layout.xml=>res/layout/layout.xml",
- "apicheck/themes.xml=>res/values/themes.xml",
- "apicheck/themes.xml=>res/color/colors.xml",
- "apicheck/unsupported.jar.data=>libs/unsupported.jar"
- ));
- }
-
- public void testOk() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/classpath=>.classpath",
- "apicheck/minsdk2.xml=>AndroidManifest.xml",
- "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class",
- "bytecode/GetterTest.jar.data=>libs/GetterTest.jar",
- "bytecode/classes.jar=>libs/classes.jar"
- ));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/JavaPerformanceDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/JavaPerformanceDetectorTest.java
deleted file mode 100644
index 5d47c5c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/JavaPerformanceDetectorTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class JavaPerformanceDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new JavaPerformanceDetector();
- }
-
- public void test() throws Exception {
- boolean isInAospEnvironment = System.getenv("ANDROID_BUILD_TOP") != null;
- assertEquals(
- "src/test/pkg/JavaPerformanceTest.java:28: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" +
- " new String(\"foo\");\n" +
- " ~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:29: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" +
- " String s = new String(\"bar\");\n" +
- " ~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:103: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" +
- " new String(\"flag me\");\n" +
- " ~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:109: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" +
- " new String(\"flag me\");\n" +
- " ~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:112: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" +
- " Bitmap.createBitmap(100, 100, null);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:113: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" +
- " android.graphics.Bitmap.createScaledBitmap(null, 100, 100, false);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:114: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" +
- " BitmapFactory.decodeFile(null);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:116: Warning: Avoid object allocations during draw operations: Use Canvas.getClipBounds(Rect) instead of Canvas.getClipBounds() which allocates a temporary Rect [DrawAllocation]\n" +
- " canvas.getClipBounds(); // allocates on your behalf\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:140: Warning: Avoid object allocations during draw/layout operations (preallocate and reuse instead) [DrawAllocation]\n" +
- " new String(\"foo\");\n" +
- " ~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:70: Warning: Use new SparseArray<String>(...) instead for better performance [UseSparseArrays]\n" +
- " Map<Integer, String> myMap = new HashMap<Integer, String>();\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:72: Warning: Use new SparseBooleanArray(...) instead for better performance [UseSparseArrays]\n" +
- " Map<Integer, Boolean> myBoolMap = new HashMap<Integer, Boolean>();\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:74: Warning: Use new SparseIntArray(...) instead for better performance [UseSparseArrays]\n" +
- " Map<Integer, Integer> myIntMap = new java.util.HashMap<Integer, Integer>();\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:190: Warning: Use new SparseIntArray(...) instead for better performance [UseSparseArrays]\n" +
- " new SparseArray<Integer>(); // Use SparseIntArray instead\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
-
- (isInAospEnvironment ?
- "src/test/pkg/JavaPerformanceTest.java:191: Warning: Use new SparseLongArray(...) instead for better performance [UseSparseArrays]\n" +
- " new SparseArray<Long>(); // Use SparseLongArray instead\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" : "") +
-
- "src/test/pkg/JavaPerformanceTest.java:192: Warning: Use new SparseBooleanArray(...) instead for better performance [UseSparseArrays]\n" +
- " new SparseArray<Boolean>(); // Use SparseBooleanArray instead\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:33: Warning: Use Integer.valueOf(5) instead [UseValueOf]\n" +
- " Integer i = new Integer(5);\n" +
- " ~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:145: Warning: Use Integer.valueOf(42) instead [UseValueOf]\n" +
- " Integer i1 = new Integer(42);\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:146: Warning: Use Long.valueOf(42L) instead [UseValueOf]\n" +
- " Long l1 = new Long(42L);\n" +
- " ~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:147: Warning: Use Boolean.valueOf(true) instead [UseValueOf]\n" +
- " Boolean b1 = new Boolean(true);\n" +
- " ~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:148: Warning: Use Character.valueOf('c') instead [UseValueOf]\n" +
- " Character c1 = new Character('c');\n" +
- " ~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:149: Warning: Use Float.valueOf(1.0f) instead [UseValueOf]\n" +
- " Float f1 = new Float(1.0f);\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/JavaPerformanceTest.java:150: Warning: Use Double.valueOf(1.0) instead [UseValueOf]\n" +
- " Double d1 = new Double(1.0);\n" +
- " ~~~~~~~~~~~~~~~\n" +
- (isInAospEnvironment ?
- "0 errors, 22 warnings\n" : "0 errors, 21 warnings\n"),
-
- lintProject("src/test/pkg/JavaPerformanceTest.java.txt=>" +
- "src/test/pkg/JavaPerformanceTest.java"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/LabelForDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/LabelForDetectorTest.java
deleted file mode 100644
index 6d69e00..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/LabelForDetectorTest.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class LabelForDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new LabelForDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "res/layout/labelfor.xml:54: Warning: No label views point to this text field with an android:labelFor=\"@+id/@+id/editText2\" attribute [LabelFor]\n" +
- " <EditText\n" +
- " ^\n" +
- "res/layout/labelfor.xml:61: Warning: No label views point to this text field with an android:labelFor=\"@+id/@+id/autoCompleteTextView2\" attribute [LabelFor]\n" +
- " <AutoCompleteTextView\n" +
- " ^\n" +
- "res/layout/labelfor.xml:68: Warning: No label views point to this text field with an android:labelFor=\"@+id/@+id/multiAutoCompleteTextView2\" attribute [LabelFor]\n" +
- " <MultiAutoCompleteTextView\n" +
- " ^\n" +
- "0 errors, 3 warnings\n",
-
- lintProject(
- "apicheck/minsdk17.xml=>AndroidManifest.xml",
- "res/layout/labelfor.xml"
- ));
- }
-
- public void testSuppressed() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/minsdk17.xml=>AndroidManifest.xml",
- "res/layout/labelfor_ignore.xml"
- ));
- }
-
-
- public void testOk() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/minsdk17.xml=>AndroidManifest.xml",
- "res/layout/accessibility.xml"
- ));
- }
-
- public void testNotApplicable() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "res/layout/labelfor.xml"
- ));
- }
-}
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/LocaleDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/LocaleDetectorTest.java
deleted file mode 100644
index 2ac3c4e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/LocaleDetectorTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class LocaleDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new LocaleDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/pkg/LocaleTest.java:11: Warning: Implicitly using the default locale is a common source of bugs: Use toUpperCase(Locale) instead [DefaultLocale]\n" +
- " System.out.println(\"WRONG\".toUpperCase());\n" +
- " ~~~~~~~~~~~\n" +
- "src/test/pkg/LocaleTest.java:16: Warning: Implicitly using the default locale is a common source of bugs: Use toLowerCase(Locale) instead [DefaultLocale]\n" +
- " System.out.println(\"WRONG\".toLowerCase());\n" +
- " ~~~~~~~~~~~\n" +
- "src/test/pkg/LocaleTest.java:20: Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale]\n" +
- " String.format(\"WRONG: %f\", 1.0f); // Implies locale\n" +
- " ~~~~~~\n" +
- "src/test/pkg/LocaleTest.java:21: Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale]\n" +
- " String.format(\"WRONG: %1$f\", 1.0f);\n" +
- " ~~~~~~\n" +
- "src/test/pkg/LocaleTest.java:22: Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale]\n" +
- " String.format(\"WRONG: %e\", 1.0f);\n" +
- " ~~~~~~\n" +
- "src/test/pkg/LocaleTest.java:23: Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale]\n" +
- " String.format(\"WRONG: %d\", 1.0f);\n" +
- " ~~~~~~\n" +
- "src/test/pkg/LocaleTest.java:24: Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale]\n" +
- " String.format(\"WRONG: %g\", 1.0f);\n" +
- " ~~~~~~\n" +
- "src/test/pkg/LocaleTest.java:25: Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale]\n" +
- " String.format(\"WRONG: %g\", 1.0f);\n" +
- " ~~~~~~\n" +
- "src/test/pkg/LocaleTest.java:26: Warning: Implicitly using the default locale is a common source of bugs: Use String.format(Locale, ...) instead [DefaultLocale]\n" +
- " String.format(\"WRONG: %1$tm %1$te,%1$tY\",\n" +
- " ~~~~~~\n" +
- "src/test/pkg/LocaleTest.java:32: Warning: To get local formatting use getDateInstance(), getDateTimeInstance(), or getTimeInstance(), or use new SimpleDateFormat(String template, Locale locale) with for example Locale.US for ASCII dates. [SimpleDateFormat]\n" +
- " new SimpleDateFormat(); // WRONG\n" +
- " ~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/LocaleTest.java:33: Warning: To get local formatting use getDateInstance(), getDateTimeInstance(), or getTimeInstance(), or use new SimpleDateFormat(String template, Locale locale) with for example Locale.US for ASCII dates. [SimpleDateFormat]\n" +
- " new SimpleDateFormat(\"yyyy-MM-dd\"); // WRONG\n" +
- " ~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/LocaleTest.java:34: Warning: To get local formatting use getDateInstance(), getDateTimeInstance(), or getTimeInstance(), or use new SimpleDateFormat(String template, Locale locale) with for example Locale.US for ASCII dates. [SimpleDateFormat]\n" +
- " new SimpleDateFormat(\"yyyy-MM-dd\", DateFormatSymbols.getInstance()); // WRONG\n" +
- " ~~~~~~~~~~~~~~~~\n" +
- "0 errors, 12 warnings\n",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "res/layout/onclick.xml=>res/layout/onclick.xml",
- "bytecode/LocaleTest.java.txt=>src/test/pkg/LocaleTest.java",
- "bytecode/LocaleTest.class.data=>bin/classes/test/pkg/LocaleTest.class"
- ));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestOrderDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestOrderDetectorTest.java
deleted file mode 100644
index 06e6fba..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestOrderDetectorTest.java
+++ /dev/null
@@ -1,323 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.annotations.NonNull;
-import com.android.tools.lint.client.api.LintClient;
-import com.android.tools.lint.detector.api.Detector;
-import com.android.tools.lint.detector.api.Issue;
-import com.android.tools.lint.detector.api.Project;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-@SuppressWarnings("javadoc")
-public class ManifestOrderDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new ManifestOrderDetector();
- }
-
- private Set<Issue> mEnabled = new HashSet<Issue>();
-
- @Override
- protected TestConfiguration getConfiguration(LintClient client, Project project) {
- return new TestConfiguration(client, project, null) {
- @Override
- public boolean isEnabled(@NonNull Issue issue) {
- return super.isEnabled(issue) && mEnabled.contains(issue);
- }
- };
- }
-
- public void testOrderOk() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.ORDER);
- assertEquals(
- "No warnings.",
- lintProject(
- "AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testBrokenOrder() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.ORDER);
- assertEquals(
- "AndroidManifest.xml:16: Warning: <uses-sdk> tag appears after <application> tag [ManifestOrder]\n" +
- " <uses-sdk android:minSdkVersion=\"Froyo\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "broken-manifest.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testMissingUsesSdk() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.USES_SDK);
- assertEquals(
- "AndroidManifest.xml: Warning: Manifest should specify a minimum API level with <uses-sdk android:minSdkVersion=\"?\" />; if it really supports all versions of Android set it to 1. [UsesMinSdkAttributes]\n" +
- "0 errors, 1 warnings\n",
- lintProject(
- "missingusessdk.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testMissingMinSdk() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.USES_SDK);
- assertEquals(
- "AndroidManifest.xml:7: Warning: <uses-sdk> tag should specify a minimum API level with android:minSdkVersion=\"?\" [UsesMinSdkAttributes]\n" +
- " <uses-sdk android:targetSdkVersion=\"10\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintProject(
- "missingmin.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testMissingTargetSdk() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.USES_SDK);
- assertEquals(
- "AndroidManifest.xml:7: Warning: <uses-sdk> tag should specify a target API level (the highest verified version; when running on later versions, compatibility behaviors may be enabled) with android:targetSdkVersion=\"?\" [UsesMinSdkAttributes]\n" +
- " <uses-sdk android:minSdkVersion=\"10\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n",
- lintProject(
- "missingtarget.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testOldTargetSdk() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.TARGET_NEWER);
- assertEquals(
- "AndroidManifest.xml:7: Warning: Not targeting the latest versions of Android; compatibility modes apply. Consider testing and updating this version. Consult the android.os.Build.VERSION_CODES javadoc for details. [OldTargetApi]\n" +
- " <uses-sdk android:minSdkVersion=\"10\" android:targetSdkVersion=\"14\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n",
- lintProject(
- "oldtarget.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testMultipleSdk() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.MULTIPLE_USES_SDK);
- assertEquals(
- "AndroidManifest.xml:8: Error: There should only be a single <uses-sdk> element in the manifest: merge these together [MultipleUsesSdk]\n" +
- " <uses-sdk android:targetSdkVersion=\"14\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " AndroidManifest.xml:7: Also appears here\n" +
- " AndroidManifest.xml:9: Also appears here\n" +
- "1 errors, 0 warnings\n",
-
- lintProject(
- "multiplesdk.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testWrongLocation() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.WRONG_PARENT);
- assertEquals(
- "AndroidManifest.xml:8: Error: The <uses-sdk> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" +
- " <uses-sdk android:minSdkVersion=\"Froyo\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:9: Error: The <uses-permission> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" +
- " <uses-permission />\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:10: Error: The <permission> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" +
- " <permission />\n" +
- " ~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:11: Error: The <permission-tree> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" +
- " <permission-tree />\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:12: Error: The <permission-group> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" +
- " <permission-group />\n" +
- " ~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:14: Error: The <uses-sdk> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" +
- " <uses-sdk />\n" +
- " ~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:15: Error: The <uses-configuration> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" +
- " <uses-configuration />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:16: Error: The <uses-feature> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" +
- " <uses-feature />\n" +
- " ~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:17: Error: The <supports-screens> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" +
- " <supports-screens />\n" +
- " ~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:18: Error: The <compatible-screens> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" +
- " <compatible-screens />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:19: Error: The <supports-gl-texture> element must be a direct child of the <manifest> root element [WrongManifestParent]\n" +
- " <supports-gl-texture />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:24: Error: The <uses-library> element must be a direct child of the <application> element [WrongManifestParent]\n" +
- " <uses-library />\n" +
- " ~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:25: Error: The <activity> element must be a direct child of the <application> element [WrongManifestParent]\n" +
- " <activity android:name=\".HelloWorld\"\n" +
- " ^\n" +
- "13 errors, 0 warnings\n" +
- "",
-
- lintProject("broken-manifest2.xml=>AndroidManifest.xml"));
- }
-
- public void testDuplicateActivity() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.DUPLICATE_ACTIVITY);
- assertEquals(
- "AndroidManifest.xml:16: Error: Duplicate registration for activity com.example.helloworld.HelloWorld [DuplicateActivity]\n" +
- " <activity android:name=\"com.example.helloworld.HelloWorld\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n" +
- "",
-
- lintProject(
- "duplicate-manifest.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testIgnoreDuplicateActivity() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.DUPLICATE_ACTIVITY);
- assertEquals(
- "No warnings.",
-
- lintProject(
- "duplicate-manifest-ignore.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testAllowBackup() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.ALLOW_BACKUP);
- assertEquals(
- "AndroidManifest.xml:9: Warning: Should explicitly set android:allowBackup to " +
- "true or false (it's true by default, and that can have some security " +
- "implications for the application's data) [AllowBackup]\n" +
- " <application\n" +
- " ^\n" +
- "0 errors, 1 warnings\n",
- lintProject(
- "AndroidManifest.xml",
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testAllowBackupOk() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.ALLOW_BACKUP);
- assertEquals(
- "No warnings.",
- lintProject(
- "allowbackup.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testAllowBackupOk2() throws Exception {
- // Requires build api >= 4
- mEnabled = Collections.singleton(ManifestOrderDetector.ALLOW_BACKUP);
- assertEquals(
- "No warnings.",
- lintProject(
- "AndroidManifest.xml",
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
-
- public void testAllowIgnore() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.ALLOW_BACKUP);
- assertEquals(
- "No warnings.",
- lintProject(
- "allowbackup_ignore.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testDuplicatePermissions() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.UNIQUE_PERMISSION);
- assertEquals(
- "AndroidManifest.xml:12: Error: Permission name SEND_SMS is not unique (appears in both foo.permission.SEND_SMS and bar.permission.SEND_SMS) [UniquePermission]\n" +
- " <permission android:name=\"bar.permission.SEND_SMS\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " AndroidManifest.xml:9: Previous permission here\n" +
- "1 errors, 0 warnings\n",
-
- lintProject(
- "duplicate_permissions1.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testDuplicatePermissionsMultiProject() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.UNIQUE_PERMISSION);
-
- File master = getProjectDir("MasterProject",
- // Master project
- "duplicate_permissions2.xml=>AndroidManifest.xml",
- "multiproject/main-merge.properties=>project.properties",
- "multiproject/MainCode.java.txt=>src/foo/main/MainCode.java"
- );
- File library = getProjectDir("LibraryProject",
- // Library project
- "duplicate_permissions3.xml=>AndroidManifest.xml",
- "multiproject/library.properties=>project.properties",
- "multiproject/LibraryCode.java.txt=>src/foo/library/LibraryCode.java",
- "multiproject/strings.xml=>res/values/strings.xml"
- );
- assertEquals(
- "LibraryProject/AndroidManifest.xml:9: Error: Permission name SEND_SMS is not unique (appears in both foo.permission.SEND_SMS and bar.permission.SEND_SMS) [UniquePermission]\n" +
- " <permission android:name=\"bar.permission.SEND_SMS\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n",
-
- checkLint(Arrays.asList(master, library)));
- }
-
- public void testMissingVersion() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.SET_VERSION);
- assertEquals(""
- + "AndroidManifest.xml:2: Warning: Should set android:versionCode to specify the application version [MissingVersion]\n"
- + "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n"
- + "^\n"
- + "AndroidManifest.xml:2: Warning: Should set android:versionName to specify the application version [MissingVersion]\n"
- + "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n"
- + "^\n"
- + "0 errors, 2 warnings\n",
- lintProject("no_version.xml=>AndroidManifest.xml"));
- }
-
- public void testIllegalReference() throws Exception {
- mEnabled = Collections.singleton(ManifestOrderDetector.ILLEGAL_REFERENCE);
- assertEquals(""
- + "AndroidManifest.xml:2: Warning: The android:versionCode cannot be a resource url, it must be a literal integer [IllegalResourceRef]\n"
- + "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n"
- + "^\n"
- + "AndroidManifest.xml:2: Warning: The android:versionName cannot be a resource url, it must be a literal string [IllegalResourceRef]\n"
- + "<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n"
- + "^\n"
- + "AndroidManifest.xml:7: Warning: The android:minSdkVersion cannot be a resource url, it must be a literal integer (or string if a preview codename) [IllegalResourceRef]\n"
- + " <uses-sdk android:minSdkVersion=\"@dimen/minSdkVersion\" android:targetSdkVersion=\"@dimen/targetSdkVersion\" />\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "AndroidManifest.xml:7: Warning: The android:targetSdkVersion cannot be a resource url, it must be a literal integer (or string if a preview codename) [IllegalResourceRef]\n"
- + " <uses-sdk android:minSdkVersion=\"@dimen/minSdkVersion\" android:targetSdkVersion=\"@dimen/targetSdkVersion\" />\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "0 errors, 4 warnings\n",
-
- lintProject("illegal_version.xml=>AndroidManifest.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestTypoDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestTypoDetectorTest.java
deleted file mode 100644
index f0ce60d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ManifestTypoDetectorTest.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.annotations.NonNull;
-import com.android.tools.lint.client.api.LintClient;
-import com.android.tools.lint.detector.api.Detector;
-import com.android.tools.lint.detector.api.Issue;
-import com.android.tools.lint.detector.api.Project;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.Set;
-
-@SuppressWarnings("javadoc")
-public class ManifestTypoDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new ManifestTypoDetector();
- }
-
- private Set<Issue> mEnabled = new HashSet<Issue>();
-
- @Override
- protected TestConfiguration getConfiguration(LintClient client, Project project) {
- return new TestConfiguration(client, project, null) {
- @Override
- public boolean isEnabled(@NonNull Issue issue) {
- return super.isEnabled(issue) && mEnabled.contains(issue);
- }
- };
- }
-
- public void testOk() throws Exception {
- mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE);
- assertEquals(
- "No warnings.",
- lintProject(
- "typo_not_found.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testTypoUsesSdk() throws Exception {
- mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE);
- assertEquals(
- "AndroidManifest.xml:7: " +
- "Warning: <use-sdk> looks like a typo; did you mean <uses-sdk> ? [ManifestTypos]\n" +
- " <use-sdk android:minSdkVersion=\"14\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "typo_uses_sdk.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testTypoUsesSdk2() throws Exception {
- mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE);
- assertEquals(
- "AndroidManifest.xml:7: " +
- "Warning: <user-sdk> looks like a typo; did you mean <uses-sdk> ? [ManifestTypos]\n" +
- " <user-sdk android:minSdkVersion=\"14\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "typo_uses_sdk2.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testTypoUsesPermission() throws Exception {
- mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE);
- assertEquals(
- "AndroidManifest.xml:9: " +
- "Warning: <use-permission> looks like a typo; " +
- "did you mean <uses-permission> ? [ManifestTypos]\n" +
- " <use-permission android:name=\"com.example.helloworld.permission\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "typo_uses_permission.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testTypoUsesPermission2() throws Exception {
- mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE);
- assertEquals(
- "AndroidManifest.xml:9: " +
- "Warning: <user-permission> looks like a typo; " +
- "did you mean <uses-permission> ? [ManifestTypos]\n" +
- " <user-permission android:name=\"com.example.helloworld.permission\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "typo_uses_permission2.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testTypoUsesFeature() throws Exception {
- mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE);
- assertEquals(
- "AndroidManifest.xml:11: " +
- "Warning: <use-feature> looks like a typo; " +
- "did you mean <uses-feature> ? [ManifestTypos]\n" +
- " <use-feature android:name=\"android.hardware.wifi\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "typo_uses_feature.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testTypoUsesFeature2() throws Exception {
- mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE);
- assertEquals(
- "AndroidManifest.xml:11: " +
- "Warning: <user-feature> looks like a typo; " +
- "did you mean <uses-feature> ? [ManifestTypos]\n" +
- " <user-feature android:name=\"android.hardware.wifi\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "typo_uses_feature2.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testTypoUsesLibrary() throws Exception {
- mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE);
- assertEquals(
- "AndroidManifest.xml:16: " +
- "Warning: <use-library> looks like a typo; " +
- "did you mean <uses-library> ? [ManifestTypos]\n" +
- " <use-library android:name=\"com.example.helloworld\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "typo_uses_library.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testTypoUsesLibrary2() throws Exception {
- mEnabled = Collections.singleton(ManifestTypoDetector.ISSUE);
- assertEquals(
- "AndroidManifest.xml:16: " +
- "Warning: <user-library> looks like a typo; " +
- "did you mean <uses-library> ? [ManifestTypos]\n" +
- " <user-library android:name=\"com.example.helloworld\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "typo_uses_library2.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/MathDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/MathDetectorTest.java
deleted file mode 100644
index da12bda..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/MathDetectorTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class MathDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new MathDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/bytecode/MathTest.java:11: Warning: Use java.lang.Math#cos instead of android.util.FloatMath#cos() since it is faster as of API 8 [FloatMath]\n" +
- " floatResult = FloatMath.cos(x);\n" +
- " ~~~\n" +
- "src/test/bytecode/MathTest.java:12: Warning: Use java.lang.Math#sin instead of android.util.FloatMath#sin() since it is faster as of API 8 [FloatMath]\n" +
- " floatResult = FloatMath.sin((float) y);\n" +
- " ~~~\n" +
- "src/test/bytecode/MathTest.java:13: Warning: Use java.lang.Math#ceil instead of android.util.FloatMath#ceil() since it is faster as of API 8 [FloatMath]\n" +
- " floatResult = android.util.FloatMath.ceil((float) y);\n" +
- " ~~~~\n" +
- "src/test/bytecode/MathTest.java:14: Warning: Use java.lang.Math#floor instead of android.util.FloatMath#floor() since it is faster as of API 8 [FloatMath]\n" +
- " System.out.println(FloatMath.floor(x));\n" +
- " ~~~~~\n" +
- "src/test/bytecode/MathTest.java:15: Warning: Use java.lang.Math#sqrt instead of android.util.FloatMath#sqrt() since it is faster as of API 8 [FloatMath]\n" +
- " System.out.println(FloatMath.sqrt(z));\n" +
- " ~~~~\n" +
- "0 errors, 5 warnings\n",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "bytecode/MathTest.java.txt=>src/test/bytecode/MathTest.java",
- "bytecode/MathTest.class.data=>bin/classes/test/bytecode/MathTest.class"
- ));
- }
-
- public void testNoWarningsPreFroyo() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "apicheck/minsdk2.xml=>AndroidManifest.xml",
- "bytecode/MathTest.java.txt=>src/test/bytecode/MathTest.java",
- "bytecode/MathTest.class.data=>bin/classes/test/bytecode/MathTest.class"
- ));
- }
-
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/MergeRootFrameLayoutDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/MergeRootFrameLayoutDetectorTest.java
deleted file mode 100644
index 22a001f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/MergeRootFrameLayoutDetectorTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class MergeRootFrameLayoutDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new MergeRootFrameLayoutDetector();
- }
-
-
- public void testMergeRefFromJava() throws Exception {
- assertEquals(
- "res/layout/simple.xml:3: Warning: This <FrameLayout> can be replaced with a <merge> tag [MergeRootFrame]\n" +
- "<FrameLayout\n" +
- "^\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintProject(
- "res/layout/simple.xml",
- "src/test/pkg/ImportFrameActivity.java.txt=>src/test/pkg/ImportFrameActivity.java"
- ));
- }
-
- public void testMergeRefFromInclude() throws Exception {
- assertEquals(
- "res/layout/simple.xml:3: Warning: This <FrameLayout> can be replaced with a <merge> tag [MergeRootFrame]\n" +
- "<FrameLayout\n" +
- "^\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintProject(
- "res/layout/simple.xml",
- "res/layout/simpleinclude.xml"
- ));
- }
-
- public void testMergeRefFromIncludeSuppressed() throws Exception {
- assertEquals(
- "No warnings.",
- lintProject(
- "res/layout/simple_ignore.xml=>res/layout/simple.xml",
- "res/layout/simpleinclude.xml"
- ));
- }
-
- public void testNotIncluded() throws Exception {
- assertEquals(
- "No warnings.",
- lintProject("res/layout/simple.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/MissingClassDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/MissingClassDetectorTest.java
deleted file mode 100644
index b3ff056..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/MissingClassDetectorTest.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import static com.android.tools.lint.checks.MissingClassDetector.INNERCLASS;
-import static com.android.tools.lint.checks.MissingClassDetector.INSTANTIATABLE;
-import static com.android.tools.lint.checks.MissingClassDetector.MISSING;
-
-import com.android.annotations.NonNull;
-import com.android.tools.lint.client.api.LintClient;
-import com.android.tools.lint.detector.api.Detector;
-import com.android.tools.lint.detector.api.Issue;
-import com.android.tools.lint.detector.api.Project;
-import com.android.tools.lint.detector.api.Scope;
-import com.google.common.collect.Sets;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.EnumSet;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-@SuppressWarnings("javadoc")
-public class MissingClassDetectorTest extends AbstractCheckTest {
- private EnumSet<Scope> mScopes;
- private Set<Issue> mEnabled = new HashSet<Issue>();
-
- @Override
- protected Detector getDetector() {
- return new MissingClassDetector();
- }
-
- @Override
- protected EnumSet<Scope> getLintScope(List<File> file) {
- return mScopes;
- }
-
- @Override
- protected TestConfiguration getConfiguration(LintClient client, Project project) {
- return new TestConfiguration(client, project, null) {
- @Override
- public boolean isEnabled(@NonNull Issue issue) {
- return super.isEnabled(issue) && mEnabled.contains(issue);
- }
- };
- }
-
- public void test() throws Exception {
- mScopes = null;
- mEnabled = Sets.newHashSet(MISSING);
- assertEquals(
- "AndroidManifest.xml:13: Error: Class referenced in the manifest, test.pkg.TestProvider, was not found in the project or the libraries [MissingRegistered]\n" +
- " <activity android:name=\".TestProvider\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:14: Error: Class referenced in the manifest, test.pkg.TestProvider2, was not found in the project or the libraries [MissingRegistered]\n" +
- " <service android:name=\"test.pkg.TestProvider2\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:15: Error: Class referenced in the manifest, test.pkg.TestService, was not found in the project or the libraries [MissingRegistered]\n" +
- " <provider android:name=\".TestService\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:16: Error: Class referenced in the manifest, test.pkg.OnClickActivity, was not found in the project or the libraries [MissingRegistered]\n" +
- " <receiver android:name=\"OnClickActivity\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:17: Error: Class referenced in the manifest, test.pkg.TestReceiver, was not found in the project or the libraries [MissingRegistered]\n" +
- " <service android:name=\"TestReceiver\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "5 errors, 0 warnings\n",
-
- lintProject(
- "bytecode/AndroidManifestWrongRegs.xml=>AndroidManifest.xml",
- "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class",
- "bytecode/.classpath=>.classpath"
- ));
- }
-
- public void testIncrementalInManifest() throws Exception {
- mScopes = Scope.MANIFEST_SCOPE;
- mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);
- assertEquals(
- "No warnings.",
-
- lintProject(
- "bytecode/AndroidManifestWrongRegs.xml=>AndroidManifest.xml",
- "bytecode/.classpath=>.classpath"
- ));
- }
-
- public void testNoWarningBeforeBuild() throws Exception {
- mScopes = null;
- mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);
- assertEquals(
- "No warnings.",
-
- lintProject(
- "bytecode/AndroidManifestWrongRegs.xml=>AndroidManifest.xml",
- "bytecode/.classpath=>.classpath"
- ));
- }
-
- public void testOkClasses() throws Exception {
- mScopes = null;
- mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);
- assertEquals(
- "No warnings.",
-
- lintProject(
- "bytecode/AndroidManifestRegs.xml=>AndroidManifest.xml",
- "bytecode/.classpath=>.classpath",
- "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java",
- "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class",
- "bytecode/TestService.java.txt=>src/test/pkg/TestService.java",
- "bytecode/TestService.class.data=>bin/classes/test/pkg/TestService.class",
- "bytecode/TestProvider.java.txt=>src/test/pkg/TestProvider.java",
- "bytecode/TestProvider.class.data=>bin/classes/test/pkg/TestProvider.class",
- "bytecode/TestProvider2.java.txt=>src/test/pkg/TestProvider2.java",
- "bytecode/TestProvider2.class.data=>bin/classes/test/pkg/TestProvider2.class",
- "bytecode/TestReceiver.java.txt=>src/test/pkg/TestReceiver.java",
- "bytecode/TestReceiver.class.data=>bin/classes/test/pkg/TestReceiver.class"
- ));
- }
-
- public void testOkLibraries() throws Exception {
- mScopes = null;
- mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);
- assertEquals(
- "No warnings.",
-
- lintProject(
- "bytecode/AndroidManifestRegs.xml=>AndroidManifest.xml",
- "bytecode/.classpath=>.classpath",
- "bytecode/classes.jar=>libs/classes.jar"
- ));
- }
-
- public void testLibraryProjects() throws Exception {
- mScopes = null;
- mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);
- File master = getProjectDir("MasterProject",
- // Master project
- "bytecode/AndroidManifestRegs.xml=>AndroidManifest.xml",
- "multiproject/main.properties=>project.properties",
- "bytecode/TestService.java.txt=>src/test/pkg/TestService.java",
- "bytecode/TestService.class.data=>bin/classes/test/pkg/TestService.class",
- "bytecode/.classpath=>.classpath"
- );
- File library = getProjectDir("LibraryProject",
- // Library project
- "multiproject/library-manifest.xml=>AndroidManifest.xml",
- "multiproject/library.properties=>project.properties",
- "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java",
- "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class",
- "bytecode/TestProvider.java.txt=>src/test/pkg/TestProvider.java",
- "bytecode/TestProvider.class.data=>bin/classes/test/pkg/TestProvider.class",
- "bytecode/TestProvider2.java.txt=>src/test/pkg/TestProvider2.java",
- "bytecode/TestProvider2.class.data=>bin/classes/test/pkg/TestProvider2.class"
- // Missing TestReceiver: Test should complain about just that class
- );
- assertEquals(""
- + "MasterProject/AndroidManifest.xml:32: Error: Class referenced in the manifest, test.pkg.TestReceiver, was not found in the project or the libraries [MissingRegistered]\n"
- + " <receiver android:name=\"TestReceiver\" />\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "1 errors, 0 warnings\n",
-
- checkLint(Arrays.asList(master, library)));
- }
-
- public void testInnerClassStatic() throws Exception {
- mScopes = null;
- mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);
- assertEquals(
- "src/test/pkg/Foo.java:8: Warning: This inner class should be static (test.pkg.Foo.Baz) [Instantiatable]\n" +
- " public class Baz extends Activity {\n" +
- " ^\n" +
- "0 errors, 1 warnings\n",
-
- lintProject(
- "registration/AndroidManifest.xml=>AndroidManifest.xml",
- "bytecode/.classpath=>.classpath",
- "registration/Foo.java.txt=>src/test/pkg/Foo.java",
- "registration/Foo.class.data=>bin/classes/test/pkg/Foo.class",
- "registration/Foo$Bar.class.data=>bin/classes/test/pkg/Foo$Bar.class",
- "registration/Foo$Baz.class.data=>bin/classes/test/pkg/Foo$Baz.class"
- ));
- }
-
- public void testInnerClassPublic() throws Exception {
- mScopes = null;
- mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);
- assertEquals(
- "src/test/pkg/Foo/Bar.java:6: Warning: The default constructor must be public [Instantiatable]\n" +
- " private Bar() {\n" +
- " ^\n" +
- "0 errors, 1 warnings\n",
-
- lintProject(
- "registration/AndroidManifestInner.xml=>AndroidManifest.xml",
- "bytecode/.classpath=>.classpath",
- "registration/Bar.java.txt=>src/test/pkg/Foo/Bar.java",
- "registration/Bar.class.data=>bin/classes/test/pkg/Foo/Bar.class"
- ));
- }
-
- public void testInnerClass() throws Exception {
- mScopes = null;
- mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);
- assertEquals(
- "AndroidManifest.xml:14: Error: Class referenced in the manifest, test.pkg.Foo.Bar, was not found in the project or the libraries [MissingRegistered]\n" +
- " <activity\n" +
- " ^\n" +
- "AndroidManifest.xml:23: Error: Class referenced in the manifest, test.pkg.Foo.Baz, was not found in the project or the libraries [MissingRegistered]\n" +
- " <activity\n" +
- " ^\n" +
- "2 errors, 0 warnings\n",
-
- lintProject(
- "registration/AndroidManifest.xml=>AndroidManifest.xml",
- "bytecode/.classpath=>.classpath",
- "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class",
- "registration/Foo.java.txt=>src/test/pkg/Foo.java"
- ));
- }
-
- public void testInnerClass2() throws Exception {
- mScopes = null;
- mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);
- assertEquals(
- "AndroidManifest.xml:14: Error: Class referenced in the manifest, test.pkg.Foo.Bar, was not found in the project or the libraries [MissingRegistered]\n" +
- " <activity\n" +
- " ^\n" +
- "1 errors, 0 warnings\n",
-
- lintProject(
- "registration/AndroidManifestInner.xml=>AndroidManifest.xml",
- "bytecode/.classpath=>.classpath",
- "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class",
- "registration/Bar.java.txt=>src/test/pkg/Foo/Bar.java"
- ));
- }
-
- public void testWrongSeparator1() throws Exception {
- mScopes = null;
- mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);
- assertEquals(
- "AndroidManifest.xml:14: Error: Class referenced in the manifest, test.pkg.Foo.Bar, was not found in the project or the libraries [MissingRegistered]\n" +
- " <activity\n" +
- " ^\n" +
- "1 errors, 0 warnings\n",
-
- lintProject(
- "registration/AndroidManifestWrong.xml=>AndroidManifest.xml",
- "bytecode/.classpath=>.classpath",
- "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class",
- "registration/Bar.java.txt=>src/test/pkg/Foo/Bar.java"
- ));
- }
-
- public void testWrongSeparator2() throws Exception {
- mScopes = null;
- mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);
- assertEquals(
- "AndroidManifest.xml:14: Error: Class referenced in the manifest, test.pkg.Foo.Bar, was not found in the project or the libraries [MissingRegistered]\n" +
- " <activity\n" +
- " ^\n" +
- "AndroidManifest.xml:15: Warning: Use '$' instead of '.' for inner classes (or use only lowercase letters in package names) [InnerclassSeparator]\n" +
- " android:name=\".Foo.Bar\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 1 warnings\n",
-
- lintProject(
- "registration/AndroidManifestWrong2.xml=>AndroidManifest.xml",
- "bytecode/.classpath=>.classpath",
- "apicheck/ApiCallTest.class.data=>bin/classes/foo/bar/ApiCallTest.class",
- "registration/Bar.java.txt=>src/test/pkg/Foo/Bar.java"
- ));
- }
-
- public void testNoClassesWithLibraries() throws Exception {
- mScopes = null;
- mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);
- assertEquals(
- "No warnings.",
-
- lintProject(
- "bytecode/AndroidManifestWrongRegs.xml=>AndroidManifest.xml",
- "bytecode/.classpath=>.classpath",
- "bytecode/GetterTest.jar.data=>libs/foo.jar"
- ));
- }
-
- public void testFragment() throws Exception {
- mScopes = null;
- mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);
- assertEquals(""
- + "res/layout/fragment2.xml:7: Error: Class referenced in the layout file, my.app.Fragment, was not found in the project or the libraries [MissingRegistered]\n"
- + " <fragment\n"
- + " ^\n"
- + "res/layout/fragment2.xml:12: Error: Class referenced in the layout file, my.app.MyView, was not found in the project or the libraries [MissingRegistered]\n"
- + " <view\n"
- + " ^\n"
- + "res/layout/fragment2.xml:17: Error: Class referenced in the layout file, my.app.Fragment2, was not found in the project or the libraries [MissingRegistered]\n"
- + " <fragment\n"
- + " ^\n"
- + "3 errors, 0 warnings\n",
-
- lintProject(
- "bytecode/AndroidManifestRegs.xml=>AndroidManifest.xml",
- "bytecode/.classpath=>.classpath",
- "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java",
- "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class",
- "bytecode/TestService.java.txt=>src/test/pkg/TestService.java",
- "bytecode/TestService.class.data=>bin/classes/test/pkg/TestService.class",
- "bytecode/TestProvider.java.txt=>src/test/pkg/TestProvider.java",
- "bytecode/TestProvider.class.data=>bin/classes/test/pkg/TestProvider.class",
- "bytecode/TestProvider2.java.txt=>src/test/pkg/TestProvider2.java",
- "bytecode/TestProvider2.class.data=>bin/classes/test/pkg/TestProvider2.class",
- "bytecode/TestReceiver.java.txt=>src/test/pkg/TestReceiver.java",
- "bytecode/TestReceiver.class.data=>bin/classes/test/pkg/TestReceiver.class",
- "registration/Foo.java.txt=>src/test/pkg/Foo.java",
- "registration/Foo.class.data=>bin/classes/test/pkg/Foo.class",
- "registration/Bar.java.txt=>src/test/pkg/Foo/Bar.java",
- "registration/Bar.class.data=>bin/classes/test/pkg/Foo/Bar.class",
-
- "res/layout/fragment2.xml"
- ));
- }
-
- public void testAnalytics() throws Exception {
- mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);
- assertEquals(""
- + "res/values/analytics.xml:13: Error: Class referenced in the analytics file, com.example.app.BaseActivity, was not found in the project or the libraries [MissingRegistered]\n"
- + " <string name=\"com.example.app.BaseActivity\">Home</string>\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "res/values/analytics.xml:14: Error: Class referenced in the analytics file, com.example.app.PrefsActivity, was not found in the project or the libraries [MissingRegistered]\n"
- + " <string name=\"com.example.app.PrefsActivity\">Preferences</string>\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "2 errors, 0 warnings\n",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "res/values/analytics.xml",
- "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java",
- "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class"
- ));
- }
-
- public void testCustomView() throws Exception {
- mEnabled = Sets.newHashSet(MISSING, INSTANTIATABLE, INNERCLASS);
- assertEquals(""
- + "res/layout/customview.xml:21: Error: Class referenced in the layout file, foo.bar.Baz, was not found in the project or the libraries [MissingRegistered]\n"
- + " <foo.bar.Baz\n"
- + " ^\n"
- + "1 errors, 0 warnings\n",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "res/layout/customview.xml",
- "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java",
- "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class"
- ));
- }
-
- public void testFragments() throws Exception {
- // Ensure that we don't do instantiation checks here since they are handled by
- // the FragmentDetector
- assertEquals(
- "No warnings.",
-
- lintProject(
- "bytecode/FragmentTest$Fragment1.class.data=>bin/classes/test/pkg/FragmentTest$Fragment1.class",
- "bytecode/FragmentTest$Fragment2.class.data=>bin/classes/test/pkg/FragmentTest$Fragment2.class",
- "bytecode/FragmentTest$Fragment3.class.data=>bin/classes/test/pkg/FragmentTest$Fragment3.class",
- "bytecode/FragmentTest$Fragment4.class.data=>bin/classes/test/pkg/FragmentTest$Fragment4.class",
- "bytecode/FragmentTest$Fragment5.class.data=>bin/classes/test/pkg/FragmentTest$Fragment5.class",
- "bytecode/FragmentTest$Fragment6.class.data=>bin/classes/test/pkg/FragmentTest$Fragment6.class",
- "bytecode/FragmentTest$NotAFragment.class.data=>bin/classes/test/pkg/FragmentTest$NotAFragment.class",
- "bytecode/FragmentTest.java.txt=>src/test/pkg/FragmentTest.java"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/MissingIdDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/MissingIdDetectorTest.java
deleted file mode 100644
index b72d8c8..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/MissingIdDetectorTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class MissingIdDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new MissingIdDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "res/layout/fragment.xml:7: Warning: This <fragment> tag should specify an id or a tag to preserve state across activity restarts [MissingId]\n" +
- " <fragment\n" +
- " ^\n" +
- "0 errors, 1 warnings\n",
-
- lintProject("res/layout/fragment.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/NamespaceDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/NamespaceDetectorTest.java
deleted file mode 100644
index 91aedb2..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/NamespaceDetectorTest.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class NamespaceDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new NamespaceDetector();
- }
-
- public void testCustom() throws Exception {
- assertEquals(
- "res/layout/customview.xml:5: Error: When using a custom namespace attribute in a library project, use the namespace \"http://schemas.android.com/apk/res-auto\" instead. [LibraryCustomView]\n" +
- " xmlns:foo=\"http://schemas.android.com/apk/res/foo\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n",
-
- lintProject(
- "multiproject/library-manifest.xml=>AndroidManifest.xml",
- "multiproject/library.properties=>project.properties",
- "res/layout/customview.xml"
- ));
- }
-
- public void testCustomOk() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "multiproject/library-manifest.xml=>AndroidManifest.xml",
-
- // Use a standard project properties instead: no warning since it's
- // not a library project:
- //"multiproject/library.properties=>project.properties",
-
- "res/layout/customview.xml"
- ));
- }
-
- public void testCustomOk2() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "multiproject/library-manifest.xml=>AndroidManifest.xml",
- "multiproject/library.properties=>project.properties",
- // This project already uses the res-auto package
- "res/layout/customview2.xml"
- ));
- }
-
- public void testTypo() throws Exception {
- assertEquals(
- "res/layout/wrong_namespace.xml:2: Warning: Unexpected namespace URI bound to the \"android\" prefix, was http://schemas.android.com/apk/res/andriod, expected http://schemas.android.com/apk/res/android [NamespaceTypo]\n" +
- "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/andriod\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject("res/layout/wrong_namespace.xml"));
- }
-
- public void testTypo2() throws Exception {
- assertEquals(
- "res/layout/wrong_namespace2.xml:2: Warning: URI is case sensitive: was \"http://schemas.android.com/apk/res/Android\", expected \"http://schemas.android.com/apk/res/android\" [NamespaceTypo]\n" +
- "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/Android\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject("res/layout/wrong_namespace2.xml"));
- }
-
- public void testTypo3() throws Exception {
- assertEquals(
- "res/layout/wrong_namespace3.xml:2: Warning: Unexpected namespace URI bound to the \"android\" prefix, was http://schemas.android.com/apk/res/androi, expected http://schemas.android.com/apk/res/android [NamespaceTypo]\n" +
- "<LinearLayout xmlns:a=\"http://schemas.android.com/apk/res/androi\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject("res/layout/wrong_namespace3.xml"));
- }
-
- public void testTypo4() throws Exception {
- assertEquals(
- "res/layout/wrong_namespace5.xml:2: Warning: Suspicious namespace: should start with http:// [NamespaceTypo]\n" +
- " xmlns:noturi=\"tp://schems.android.com/apk/res/com.my.package\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/wrong_namespace5.xml:3: Warning: Possible typo in URL: was \"http://schems.android.com/apk/res/com.my.package\", should probably be \"http://schemas.android.com/apk/res/com.my.package\" [NamespaceTypo]\n" +
- " xmlns:typo1=\"http://schems.android.com/apk/res/com.my.package\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/wrong_namespace5.xml:4: Warning: Possible typo in URL: was \"http://schems.android.comm/apk/res/com.my.package\", should probably be \"http://schemas.android.com/apk/res/com.my.package\" [NamespaceTypo]\n" +
- " xmlns:typo2=\"http://schems.android.comm/apk/res/com.my.package\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 3 warnings\n",
-
- lintProject("res/layout/wrong_namespace5.xml"));
- }
-
- public void testTypoOk() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject("res/layout/wrong_namespace4.xml"));
- }
-
- public void testUnused() throws Exception {
- assertEquals(
- "res/layout/unused_namespace.xml:3: Warning: Unused namespace unused1 [UnusedNamespace]\n" +
- " xmlns:unused1=\"http://schemas.android.com/apk/res/unused1\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/unused_namespace.xml:4: Warning: Unused namespace unused2 [UnusedNamespace]\n" +
- " xmlns:unused2=\"http://schemas.android.com/apk/res/unused1\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 2 warnings\n" +
- "",
-
- lintProject("res/layout/unused_namespace.xml"));
- }
-
- public void testUnusedOk() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject("res/layout/layout1.xml"));
- }
-
- public void testLayoutAttributesOk() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintFiles("res/layout/namespace3.xml"));
- }
-
- public void testLayoutAttributesOk2() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintFiles("res/layout/namespace4.xml"));
- }
-
- public void testLayoutAttributes() throws Exception {
- assertEquals(
- "res/layout/namespace3.xml:2: Error: When using a custom namespace attribute in a library project, use the namespace \"http://schemas.android.com/apk/res-auto\" instead. [LibraryCustomView]\n" +
- " xmlns:app=\"http://schemas.android.com/apk/res/com.example.apicalltest\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n",
-
- lintFiles("res/layout/namespace3.xml",
- "multiproject/library-manifest.xml=>AndroidManifest.xml",
- "multiproject/library.properties=>project.properties"));
- }
-
- public void testLayoutAttributes2() throws Exception {
- assertEquals(
- "res/layout/namespace4.xml:3: Error: When using a custom namespace attribute in a library project, use the namespace \"http://schemas.android.com/apk/res-auto\" instead. [LibraryCustomView]\n" +
- " xmlns:app=\"http://schemas.android.com/apk/res/com.example.apicalltest\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n",
-
- lintFiles("res/layout/namespace4.xml",
- "multiproject/library-manifest.xml=>AndroidManifest.xml",
- "multiproject/library.properties=>project.properties"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/NestedScrollingWidgetDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/NestedScrollingWidgetDetectorTest.java
deleted file mode 100644
index 55da17e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/NestedScrollingWidgetDetectorTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class NestedScrollingWidgetDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new NestedScrollingWidgetDetector();
- }
-
- public void testNested() throws Exception {
- assertEquals(
- "res/layout/scrolling.xml:13: Warning: The vertically scrolling ScrollView should not contain another vertically scrolling widget (ListView) [NestedScrolling]\n" +
- " <ListView\n" +
- " ^\n" +
- "0 errors, 1 warnings\n",
-
- lintFiles("res/layout/scrolling.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/NonInternationalizedSmsDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/NonInternationalizedSmsDetectorTest.java
deleted file mode 100644
index f875fa1..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/NonInternationalizedSmsDetectorTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class NonInternationalizedSmsDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new NonInternationalizedSmsDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/pkg/NonInternationalizedSmsDetectorTest.java:18: Warning: To make sure the SMS can be sent by all users, please start the SMS number with a + and a country code or restrict the code invocation to people in the country you are targeting. [UnlocalizedSms]\n" +
- " sms.sendMultipartTextMessage(\"001234567890\", null, null, null, null);\n" +
- " ~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject("src/test/pkg/NonInternationalizedSmsDetectorTest.java.txt=>src/test/pkg/NonInternationalizedSmsDetectorTest.java"));
- }
-} \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ObsoleteLayoutParamsDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ObsoleteLayoutParamsDetectorTest.java
deleted file mode 100644
index 87211a2..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ObsoleteLayoutParamsDetectorTest.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class ObsoleteLayoutParamsDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new ObsoleteLayoutParamsDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "res/layout/wrongparams.xml:11: Warning: Invalid layout param in a FrameLayout: layout_weight [ObsoleteLayoutParam]\n" +
- " android:layout_weight=\"1\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/wrongparams.xml:23: Warning: Invalid layout param in a LinearLayout: layout_alignParentLeft [ObsoleteLayoutParam]\n" +
- " android:layout_alignParentLeft=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/wrongparams.xml:24: Warning: Invalid layout param in a LinearLayout: layout_alignParentTop [ObsoleteLayoutParam]\n" +
- " android:layout_alignParentTop=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/wrongparams.xml:33: Warning: Invalid layout param in a LinearLayout: layout_alignBottom [ObsoleteLayoutParam]\n" +
- " android:layout_alignBottom=\"@+id/button1\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/wrongparams.xml:34: Warning: Invalid layout param in a LinearLayout: layout_toRightOf [ObsoleteLayoutParam]\n" +
- " android:layout_toRightOf=\"@+id/button1\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/wrongparams.xml:42: Warning: Invalid layout param in a LinearLayout: layout_alignLeft [ObsoleteLayoutParam]\n" +
- " android:layout_alignLeft=\"@+id/button1\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/wrongparams.xml:43: Warning: Invalid layout param in a LinearLayout: layout_below [ObsoleteLayoutParam]\n" +
- " android:layout_below=\"@+id/button1\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 7 warnings\n" +
- "",
-
- lintProject("res/layout/wrongparams.xml"));
- }
-
- public void test2() throws Exception {
- // Test <merge> and custom view handling
-
- assertEquals(
- "No warnings.",
-
- lintProject("res/layout/wrongparams2.xml"));
- }
-
- public void test3() throws Exception {
- // Test includes across files (wrong layout param on root element)
- assertEquals(
- "res/layout/wrongparams3.xml:5: Warning: Invalid layout param 'layout_alignParentTop' (included from within a LinearLayout in layout/wrongparams4.xml) [ObsoleteLayoutParam]\n" +
- " android:layout_alignParentTop=\"true\" >\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject("res/layout/wrongparams4.xml", "res/layout/wrongparams3.xml"));
- }
-
- public void test4() throws Exception {
- // Test includes with a <merge> (wrong layout param on child of root merge element)
- assertEquals(
- "res/layout/wrongparams5.xml:8: Warning: Invalid layout param 'layout_alignParentTop' (included from within a LinearLayout in layout/wrongparams6.xml) [ObsoleteLayoutParam]\n" +
- " android:layout_alignParentTop=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/wrongparams5.xml:15: Warning: Invalid layout param 'layout_alignParentLeft' (included from within a LinearLayout in layout/wrongparams6.xml) [ObsoleteLayoutParam]\n" +
- " android:layout_alignParentLeft=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 2 warnings\n" +
- "",
-
- lintProject("res/layout/wrongparams5.xml", "res/layout/wrongparams6.xml"));
- }
-
- public void testIgnore() throws Exception {
- assertEquals(
- // Ignoring all but one of the warnings
- "res/layout/wrongparams.xml:12: Warning: Invalid layout param in a FrameLayout: layout_weight [ObsoleteLayoutParam]\n" +
- " android:layout_weight=\"1\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject("res/layout/wrongparams_ignore.xml=>res/layout/wrongparams.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/OnClickDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/OnClickDetectorTest.java
deleted file mode 100644
index e4d8bb5..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/OnClickDetectorTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class OnClickDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new OnClickDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/pkg/OnClickActivity.java:27: Error: On click handler wrong5(View) must be public [OnClick]\n" +
- " void wrong5(View view) {\n" +
- " ~~~~~~\n" +
- "src/test/pkg/OnClickActivity.java:31: Error: On click handler wrong6(View) should not be static [OnClick]\n" +
- " public static void wrong6(View view) {\n" +
- " ~~~~~~\n" +
- "src/test/pkg/OnClickActivity.java:45: Error: On click handler wrong7(View) must be public [OnClick]\n" +
- " void wrong7(View view) {\n" +
- " ~~~~~~\n" +
- "res/layout/onclick.xml:10: Error: Corresponding method handler 'public void nonexistent(android.view.View)' not found [OnClick]\n" +
- " android:onClick=\"nonexistent\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/onclick.xml:16: Error: Corresponding method handler 'public void wrong1(android.view.View)' not found [OnClick]\n" +
- " android:onClick=\"wrong1\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/onclick.xml:22: Error: Corresponding method handler 'public void wrong2(android.view.View)' not found [OnClick]\n" +
- " android:onClick=\"wrong2\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/onclick.xml:28: Error: Corresponding method handler 'public void wrong3(android.view.View)' not found [OnClick]\n" +
- " android:onClick=\"wrong3\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/onclick.xml:34: Error: Corresponding method handler 'public void wrong4(android.view.View)' not found [OnClick]\n" +
- " android:onClick=\"wrong4\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/onclick.xml:58: Error: Corresponding method handler 'public void simple_typo(android.view.View)' not found (did you mean void test.pkg.OnClickActivity#simple_tyop(android.view.View) ?) [OnClick]\n" +
- " android:onClick=\"simple_typo\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "9 errors, 0 warnings\n",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "res/layout/onclick.xml=>res/layout/onclick.xml",
- "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java",
- "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class"
- ));
- }
-
- public void testOk() throws Exception {
- // No onClick attributes
- assertEquals(
- "No warnings.",
-
- lintProject("res/layout/accessibility.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/OverdrawDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/OverdrawDetectorTest.java
deleted file mode 100644
index 7da4004..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/OverdrawDetectorTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class OverdrawDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new OverdrawDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "res/layout/main.xml:5: Warning: Possible overdraw: Root element paints background @drawable/ic_launcher with a theme that also paints a background (inferred theme is @style/MyTheme_First) [Overdraw]\n" +
- " android:background=\"@drawable/ic_launcher\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/second.xml:5: Warning: Possible overdraw: Root element paints background @drawable/ic_launcher with a theme that also paints a background (inferred theme is @style/MyTheme) [Overdraw]\n" +
- " android:background=\"@drawable/ic_launcher\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/sixth.xml:4: Warning: Possible overdraw: Root element paints background @drawable/custombg with a theme that also paints a background (inferred theme is @style/MyTheme) [Overdraw]\n" +
- " android:background=\"@drawable/custombg\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/third.xml:5: Warning: Possible overdraw: Root element paints background @drawable/ic_launcher with a theme that also paints a background (inferred theme is @style/MyTheme_Third) [Overdraw]\n" +
- " android:background=\"@drawable/ic_launcher\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 4 warnings\n" +
- "",
-
- lintProject(
- "overdraw/.classpath=>.classpath",
- "overdraw/.project=>.project",
- "overdraw/AndroidManifest.xml=>AndroidManifest.xml",
- "overdraw/project.properties=>project.properties",
- "overdraw/res/drawable/custombg.xml=>res/drawable/custombg.xml",
- "overdraw/res/drawable/custombg2.xml=>res/drawable/custombg2.xml",
- "overdraw/res/drawable-hdpi/ic_launcher.png=>res/drawable-hdpi/ic_launcher.png",
- "overdraw/res/drawable-ldpi/ic_launcher.png=>res/drawable-ldpi/ic_launcher.png",
- "overdraw/res/drawable-mdpi/ic_launcher.png=>res/drawable-mdpi/ic_launcher.png",
- "overdraw/res/layout/sixth.xml=>res/layout/sixth.xml",
- "overdraw/res/layout/fifth.xml=>res/layout/fifth.xml",
- "overdraw/res/layout/fourth.xml=>res/layout/fourth.xml",
- "overdraw/res/layout/main.xml=>res/layout/main.xml",
- "overdraw/res/layout/second.xml=>res/layout/second.xml",
- "overdraw/res/layout/third.xml=>res/layout/third.xml",
- "overdraw/res/values/strings.xml=>res/values/strings.xml",
- "overdraw/res/values/styles.xml=>res/values/styles.xml",
-
- // Java files must be renamed in source tree
- "overdraw/gen/test/pkg/BuildConfig.java.txt=>gen/test/pkg/BuildConfig.java",
- "overdraw/gen/test/pkg/R.java.txt=>gen/test/pkg/R.java",
- "overdraw/src/test/pkg/FourthActivity.java.txt=>src/test/pkg/FourthActivity.java",
- "overdraw/src/test/pkg/OverdrawActivity.java.txt=>src/test/pkg/OverdrawActivity.java",
- "overdraw/src/test/pkg/SecondActivity.java.txt=>src/test/pkg/SecondActivity.java",
- "overdraw/src/test/pkg/ThirdActivity.java.txt=>src/test/pkg/ThirdActivity.java"
- ));
- }
-
- public void testSuppressed() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "overdraw/.classpath=>.classpath",
- "overdraw/.project=>.project",
- "overdraw/AndroidManifest.xml=>AndroidManifest.xml",
- "overdraw/project.properties=>project.properties",
- "overdraw/res/drawable/custombg.xml=>res/drawable/custombg.xml",
- "overdraw/res/drawable/custombg2.xml=>res/drawable/custombg2.xml",
- "overdraw/res/drawable-hdpi/ic_launcher.png=>res/drawable-hdpi/ic_launcher.png",
- "overdraw/res/drawable-ldpi/ic_launcher.png=>res/drawable-ldpi/ic_launcher.png",
- "overdraw/res/drawable-mdpi/ic_launcher.png=>res/drawable-mdpi/ic_launcher.png",
- "overdraw/res/layout/main_ignore.xml=>res/layout/main.xml",
- "overdraw/res/values/strings.xml=>res/values/strings.xml",
- "overdraw/res/values/styles.xml=>res/values/styles.xml",
-
- // Java files must be renamed in source tree
- "overdraw/gen/test/pkg/BuildConfig.java.txt=>gen/test/pkg/BuildConfig.java",
- "overdraw/gen/test/pkg/R.java.txt=>gen/test/pkg/R.java",
- "overdraw/src/test/pkg/FourthActivity.java.txt=>src/test/pkg/FourthActivity.java",
- "overdraw/src/test/pkg/OverdrawActivity.java.txt=>src/test/pkg/OverdrawActivity.java",
- "overdraw/src/test/pkg/SecondActivity.java.txt=>src/test/pkg/SecondActivity.java",
- "overdraw/src/test/pkg/ThirdActivity.java.txt=>src/test/pkg/ThirdActivity.java"
- ));
- }
-
-} \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/OverrideDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/OverrideDetectorTest.java
deleted file mode 100644
index 68f80f9..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/OverrideDetectorTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class OverrideDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new OverrideDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/pkg2/Class2.java:7: Error: This package private method may be unintentionally overriding method in pkg1.Class1 [DalvikOverride]\n" +
- " void method() { // Flag this as an accidental override\n" +
- " ~~~~~~\n" +
- " src/pkg1/Class1.java:4: This method is treated as overridden\n" +
- "1 errors, 0 warnings\n",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "src/pkg1/Class1.java.txt=>src/pkg1/Class1.java",
- "src/pkg2/Class2.java.txt=>src/pkg2/Class2.java",
- "bytecode/Class1.class.data=>bin/classes/pkg1/Class1.class",
- "bytecode/Class1$Class4.class.data=>bin/classes/pkg1/Class1$Class4.class",
- "bytecode/Class2.class.data=>bin/classes/pkg2/Class2.class",
- "bytecode/Class2$Class3.class.data=>bin/classes/pkg2/Class2$Class3.class"
- ));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/PrivateKeyDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/PrivateKeyDetectorTest.java
deleted file mode 100644
index ff72dcb..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/PrivateKeyDetectorTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class PrivateKeyDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new PrivateKeyDetector();
- }
-
- @Override
- protected boolean includeParentPath() {
- return true;
- }
-
- public void testPrivateKey() throws Exception {
- assertEquals(
- "res/private_key.pem: Warning: The res/private_key.pem file seems to be a private key file. Please make sure not to embed this in your APK file. [PackagedPrivateKey]\n" +
- "0 errors, 1 warnings\n",
- lintProject(
- // Not a private key file
- "res/values/strings.xml=>res/values/strings/xml",
- // Private key file
- "res/private_key.pem=>res/private_key.pem"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/PrivateResourceDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/PrivateResourceDetectorTest.java
deleted file mode 100644
index ce1b717..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/PrivateResourceDetectorTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class PrivateResourceDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new PrivateResourceDetector();
- }
-
- public void testPrivate() throws Exception {
- assertEquals(
- "res/layout/private.xml:3: Error: Illegal resource reference: @*android resources are private and not always present [PrivateResource]\n" +
- " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@*android:drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n" +
- "",
- lintProject("res/layout/private.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ProguardDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ProguardDetectorTest.java
deleted file mode 100644
index c493b8c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ProguardDetectorTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class ProguardDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new ProguardDetector();
- }
-
- public void testProguard() throws Exception {
- assertEquals(
- "proguard.cfg:21: Error: Obsolete ProGuard file; use -keepclasseswithmembers instead of -keepclasseswithmembernames [Proguard]\n" +
- "-keepclasseswithmembernames class * {\n" +
- "^\n" +
- "1 errors, 0 warnings\n" +
- "",
- lintFiles("proguard.cfg"));
- }
-
- public void testProguardNewPath() throws Exception {
- assertEquals(
- "proguard-project.txt:21: Error: Obsolete ProGuard file; use -keepclasseswithmembers instead of -keepclasseswithmembernames [Proguard]\n" +
- "-keepclasseswithmembernames class * {\n" +
- "^\n" +
- "1 errors, 0 warnings\n" +
- "",
- lintFiles("proguard.cfg=>proguard-project.txt"));
- }
-
- public void testProguardRandomName() throws Exception {
- assertEquals(
- "myfile.txt:21: Error: Obsolete ProGuard file; use -keepclasseswithmembers instead of -keepclasseswithmembernames [Proguard]\n" +
- "-keepclasseswithmembernames class * {\n" +
- "^\n" +
- "myfile.txt:8: Warning: Local ProGuard configuration contains general Android configuration: Inherit these settings instead? Modify project.properties to define proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:myfile.txt and then keep only project-specific configuration here [ProguardSplit]\n" +
- "-keep public class * extends android.app.Activity\n" +
- "^\n" +
- "1 errors, 1 warnings\n" +
- "",
- lintProject(
- "proguard.cfg=>myfile.txt",
- "proguard.properties=>project.properties"));
- }
-
- public void testSilent() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintFiles(
- "proguard.pro=>proguard.cfg",
- "project.properties1=>project.properties"));
- }
-
- public void testSilent2() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintFiles(
- "proguard.pro=>proguard.cfg",
- "project.properties3=>project.properties"));
- }
-
- public void testSplit() throws Exception {
- assertEquals(
- "proguard.cfg:14: Warning: Local ProGuard configuration contains general Android configuration: Inherit these settings instead? Modify project.properties to define proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard.cfg and then keep only project-specific configuration here [ProguardSplit]\n" +
- "-keep public class * extends android.app.Activity\n" +
- "^\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintFiles(
- "proguard.pro=>proguard.cfg",
- "project.properties2=>project.properties"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/PxUsageDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/PxUsageDetectorTest.java
deleted file mode 100644
index 68f218f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/PxUsageDetectorTest.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class PxUsageDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new PxUsageDetector();
- }
-
- public void testPx() throws Exception {
- assertEquals(
- "res/layout/now_playing_after.xml:49: Warning: Avoid using \"mm\" as units (it does not work accurately on all devices); use \"dp\" instead [InOrMmUsage]\n" +
- " android:layout_width=\"100mm\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/now_playing_after.xml:50: Warning: Avoid using \"in\" as units (it does not work accurately on all devices); use \"dp\" instead [InOrMmUsage]\n" +
- " android:layout_height=\"120in\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/now_playing_after.xml:41: Warning: Avoid using \"px\" as units; use \"dp\" instead [PxUsage]\n" +
- " android:layout_width=\"1px\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 3 warnings\n",
- lintFiles("res/layout/now_playing_after.xml"));
- }
-
- public void testSp() throws Exception {
- assertEquals(
- "res/layout/textsize.xml:11: Warning: Should use \"sp\" instead of \"dp\" for text sizes [SpUsage]\n" +
- " android:textSize=\"14dp\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/textsize.xml:16: Warning: Should use \"sp\" instead of \"dp\" for text sizes [SpUsage]\n" +
- " android:textSize=\"14dip\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/textsize.xml:33: Warning: Avoid using sizes smaller than 12sp: 11sp [SmallSp]\n" +
- " android:textSize=\"11sp\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/textsize.xml:37: Warning: Avoid using sizes smaller than 12sp: 6sp [SmallSp]\n" +
- " android:layout_height=\"6sp\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 4 warnings\n",
-
- lintFiles("res/layout/textsize.xml"));
- }
-
- public void testStyles() throws Exception {
- assertEquals(
- "res/values/pxsp.xml:23: Warning: Avoid using \"mm\" as units (it does not work accurately on all devices); use \"dp\" instead [InOrMmUsage]\n" +
- " <item name=\"android:textSize\">50mm</item>\n" +
- " ^\n" +
- "res/values/pxsp.xml:25: Warning: Avoid using \"in\" as units (it does not work accurately on all devices); use \"dp\" instead [InOrMmUsage]\n" +
- " 50in\n" +
- " ^\n" +
- "res/values/pxsp.xml:6: Warning: Should use \"sp\" instead of \"dp\" for text sizes [SpUsage]\n" +
- " <item name=\"android:textSize\">50dp</item>\n" +
- " ^\n" +
- "res/values/pxsp.xml:12: Warning: Should use \"sp\" instead of \"dp\" for text sizes [SpUsage]\n" +
- " <item name=\"android:textSize\"> 50dip </item>\n" +
- " ^\n" +
- "res/values/pxsp.xml:9: Warning: Avoid using \"px\" as units; use \"dp\" instead [PxUsage]\n" +
- " <item name=\"android:textSize\">50px</item>\n" +
- " ^\n" +
- "res/values/pxsp.xml:17: Warning: Avoid using \"px\" as units; use \"dp\" instead [PxUsage]\n" +
- " <item name=\"android:paddingRight\"> 50px </item>\n" +
- " ^\n" +
- "res/values/pxsp.xml:18: Warning: Avoid using \"px\" as units; use \"dp\" instead [PxUsage]\n" +
- " <item name=\"android:paddingTop\">50px</item>\n" +
- " ^\n" +
- "0 errors, 7 warnings\n",
-
- lintFiles("res/values/pxsp.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/RegistrationDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/RegistrationDetectorTest.java
deleted file mode 100644
index 23a5ac3..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/RegistrationDetectorTest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class RegistrationDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new RegistrationDetector();
- }
-
- public void testRegistered() throws Exception {
- assertEquals(
- "src/test/pkg/OnClickActivity.java:8: Warning: The <activity> test.pkg.OnClickActivity is not registered in the manifest [Registered]\n" +
- "public class OnClickActivity extends Activity {\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/TestProvider.java:8: Warning: The <provider> test.pkg.TestProvider is not registered in the manifest [Registered]\n" +
- "public class TestProvider extends ContentProvider {\n" +
- " ~~~~~~~~~~~~\n" +
- "src/test/pkg/TestProvider2.java:3: Warning: The <provider> test.pkg.TestProvider2 is not registered in the manifest [Registered]\n" +
- "public class TestProvider2 extends TestProvider {\n" +
- "^\n" +
- "src/test/pkg/TestService.java:7: Warning: The <service> test.pkg.TestService is not registered in the manifest [Registered]\n" +
- "public class TestService extends Service {\n" +
- " ~~~~~~~~~~~\n" +
- "0 errors, 4 warnings\n" +
- "",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java",
- "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class",
- "bytecode/TestService.java.txt=>src/test/pkg/TestService.java",
- "bytecode/TestService.class.data=>bin/classes/test/pkg/TestService.class",
- "bytecode/TestProvider.java.txt=>src/test/pkg/TestProvider.java",
- "bytecode/TestProvider.class.data=>bin/classes/test/pkg/TestProvider.class",
- "bytecode/TestProvider2.java.txt=>src/test/pkg/TestProvider2.java",
- "bytecode/TestProvider2.class.data=>bin/classes/test/pkg/TestProvider2.class",
- "bytecode/TestReceiver.java.txt=>src/test/pkg/TestReceiver.java",
- "bytecode/TestReceiver.class.data=>bin/classes/test/pkg/TestReceiver.class"
- ));
- }
-
- public void testNoDot() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "bytecode/AndroidManifestReg.xml=>AndroidManifest.xml",
- "bytecode/.classpath=>.classpath",
- "bytecode/CommentsActivity.java.txt=>src/test/pkg/Foo/CommentsActivity.java",
- "bytecode/CommentsActivity.class.data=>bin/classes/test/pkg/Foo/CommentsActivity.class"
- ));
- }
-
- public void testWrongRegistrations() throws Exception {
- assertEquals(
- "src/test/pkg/OnClickActivity.java:8: Warning: test.pkg.OnClickActivity is a <activity> but is registered in the manifest as a <receiver> [Registered]\n" +
- "public class OnClickActivity extends Activity {\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/TestProvider.java:8: Warning: test.pkg.TestProvider is a <provider> but is registered in the manifest as a <activity> [Registered]\n" +
- "public class TestProvider extends ContentProvider {\n" +
- " ~~~~~~~~~~~~\n" +
- "src/test/pkg/TestProvider2.java:3: Warning: test.pkg.TestProvider2 is a <provider> but is registered in the manifest as a <service> [Registered]\n" +
- "public class TestProvider2 extends TestProvider {\n" +
- "^\n" +
- "src/test/pkg/TestReceiver.java:7: Warning: test.pkg.TestReceiver is a <receiver> but is registered in the manifest as a <service> [Registered]\n" +
- "public class TestReceiver extends BroadcastReceiver {\n" +
- " ~~~~~~~~~~~~\n" +
- "src/test/pkg/TestService.java:7: Warning: test.pkg.TestService is a <service> but is registered in the manifest as a <provider> [Registered]\n" +
- "public class TestService extends Service {\n" +
- " ~~~~~~~~~~~\n" +
- "0 errors, 5 warnings\n" +
- "",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifestWrongRegs.xml=>AndroidManifest.xml",
- "bytecode/OnClickActivity.java.txt=>src/test/pkg/OnClickActivity.java",
- "bytecode/OnClickActivity.class.data=>bin/classes/test/pkg/OnClickActivity.class",
- "bytecode/AbstractActivity.java.txt=>src/test/pkg/AbstractActivity.java",
- "bytecode/AbstractActivity.class.data=>bin/classes/test/pkg/AbstractActivity.class",
- "bytecode/TestService.java.txt=>src/test/pkg/TestService.java",
- "bytecode/TestService.class.data=>bin/classes/test/pkg/TestService.class",
- "bytecode/TestProvider.java.txt=>src/test/pkg/TestProvider.java",
- "bytecode/TestProvider.class.data=>bin/classes/test/pkg/TestProvider.class",
- "bytecode/TestProvider2.java.txt=>src/test/pkg/TestProvider2.java",
- "bytecode/TestProvider2.class.data=>bin/classes/test/pkg/TestProvider2.class",
- "bytecode/TestReceiver.java.txt=>src/test/pkg/TestReceiver.java",
- "bytecode/TestReceiver.class.data=>bin/classes/test/pkg/TestReceiver.class",
- "bytecode/TestReceiver$1.class.data=>bin/classes/test/pkg/TestReceiver$1.class"
- ));
- }
-
- public void testLibraryProjects() throws Exception {
- // If a library project provides additional activities, it is not an error to
- // not register all of those here
- assertEquals(
- "No warnings.",
-
- lintProject(
- // Master project
- "multiproject/main-manifest.xml=>AndroidManifest.xml",
- "multiproject/main.properties=>project.properties",
-
- // Library project
- "multiproject/library-manifest.xml=>../LibraryProject/AndroidManifest.xml",
- "multiproject/library.properties=>../LibraryProject/project.properties",
-
- "bytecode/.classpath=>../LibraryProject/.classpath",
- "bytecode/OnClickActivity.java.txt=>../LibraryProject/src/test/pkg/OnClickActivity.java",
- "bytecode/OnClickActivity.class.data=>../LibraryProject/bin/classes/test/pkg/OnClickActivity.class"
- ));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/RequiredAttributeDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/RequiredAttributeDetectorTest.java
deleted file mode 100644
index 9b60532..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/RequiredAttributeDetectorTest.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class RequiredAttributeDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new RequiredAttributeDetector();
- }
-
- public void test() throws Exception {
- // Simple: Only consider missing attributes in the layout xml file
- // (though skip warnings on <merge> tags and under <GridLayout>
- assertEquals(
- "res/layout/size.xml:13: Error: The required layout_height attribute is missing [RequiredSize]\n" +
- " <RadioButton\n" +
- " ^\n" +
- "res/layout/size.xml:18: Error: The required layout_width attribute is missing [RequiredSize]\n" +
- " <EditText\n" +
- " ^\n" +
- "res/layout/size.xml:23: Error: The required layout_width and layout_height attributes are missing [RequiredSize]\n" +
- " <EditText\n" +
- " ^\n" +
- "3 errors, 0 warnings\n",
-
- lintProject("res/layout/size.xml"));
- }
-
- public void test2() throws Exception {
- // Consider styles (specifying sizes) and includes (providing sizes for the root tags)
- assertEquals(
- "res/layout/size2.xml:9: Error: The required layout_width and layout_height attributes are missing [RequiredSize]\n" +
- " <Button\n" +
- " ^\n" +
- "res/layout/size2.xml:18: Error: The required layout_height attribute is missing [RequiredSize]\n" +
- " <Button\n" +
- " ^\n" +
- "2 errors, 0 warnings\n",
-
- lintProject(
- "res/layout/size2.xml",
- "res/layout/sizeincluded.xml",
- "res/values/sizestyles.xml"
- ));
- }
-
- public void testInflaters() throws Exception {
- // Consider java inflation
- assertEquals(
- "res/layout/size5.xml:2: Error: The required layout_width and layout_height attributes are missing [RequiredSize]\n" +
- "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
- "^\n" +
- "1 errors, 0 warnings\n",
-
- lintProject(
- "src/test/pkg/InflaterTest.java.txt=>src/test/pkg/InflaterTest.java",
- "res/layout/sizeincluded.xml=>res/layout/size1.xml",
- "res/layout/sizeincluded.xml=>res/layout/size2.xml",
- "res/layout/sizeincluded.xml=>res/layout/size3.xml",
- "res/layout/sizeincluded.xml=>res/layout/size4.xml",
- "res/layout/sizeincluded.xml=>res/layout/size5.xml",
- "res/layout/sizeincluded.xml=>res/layout/size6.xml",
- "res/layout/sizeincluded.xml=>res/layout/size7.xml"
- ));
- }
-
- public void testRequestFocus() throws Exception {
- // See http://code.google.com/p/android/issues/detail?id=38700
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/layout/edit_type.xml"
- ));
- }
-
- public void testFrameworkStyles() throws Exception {
- // See http://code.google.com/p/android/issues/detail?id=38958
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/layout/listseparator.xml"
- ));
- }
-
- public void testThemeStyles() throws Exception {
- // Check that we don't complain about cases where the size is defined in a theme
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/layout/size.xml",
- "res/values/themes.xml"
- ));
- }
-
- public void testThemeStyles2() throws Exception {
- // Check that we don't complain about cases where the size is defined in a theme
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/layout/size.xml",
- "res/values/themes2.xml"
- ));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ScrollViewChildDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ScrollViewChildDetectorTest.java
deleted file mode 100644
index ba79c50..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ScrollViewChildDetectorTest.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class ScrollViewChildDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new ScrollViewChildDetector();
- }
-
- public void testScrollView() throws Exception {
- assertEquals(
- "res/layout/wrong_dimension.xml:10: Warning: This LinearLayout should use android:layout_width=\"wrap_content\" [ScrollViewSize]\n" +
- " android:layout_width=\"match_parent\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintFiles("res/layout/wrong_dimension.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/SdCardDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/SdCardDetectorTest.java
deleted file mode 100644
index 5ad46b9..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/SdCardDetectorTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class SdCardDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new SdCardDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/pkg/SdCardTest.java:13: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" +
- " private static final String SDCARD_TEST_HTML = \"/sdcard/test.html\";\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/SdCardTest.java:14: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" +
- " public static final String SDCARD_ROOT = \"/sdcard\";\n" +
- " ~~~~~~~~~\n" +
- "src/test/pkg/SdCardTest.java:15: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" +
- " public static final String PACKAGES_PATH = \"/sdcard/o/packages/\";\n" +
- " ~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/SdCardTest.java:16: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" +
- " File deviceDir = new File(\"/sdcard/vr\");\n" +
- " ~~~~~~~~~~~~\n" +
- "src/test/pkg/SdCardTest.java:20: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" +
- " android.os.Debug.startMethodTracing(\"/sdcard/launcher\");\n" +
- " ~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/SdCardTest.java:22: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" +
- " if (new File(\"/sdcard\").exists()) {\n" +
- " ~~~~~~~~~\n" +
- "src/test/pkg/SdCardTest.java:24: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" +
- " String FilePath = \"/sdcard/\" + new File(\"test\");\n" +
- " ~~~~~~~~~~\n" +
- "src/test/pkg/SdCardTest.java:29: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" +
- " intent.setDataAndType(Uri.parse(\"file://sdcard/foo.json\"), \"application/bar-json\");\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/SdCardTest.java:30: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" +
- " intent.putExtra(\"path-filter\", \"/sdcard(/.+)*\");\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/SdCardTest.java:31: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" +
- " intent.putExtra(\"start-dir\", \"/sdcard\");\n" +
- " ~~~~~~~~~\n" +
- "src/test/pkg/SdCardTest.java:32: Warning: Do not hardcode \"/data/\"; use Context.getFilesDir().getPath() instead [SdCardPath]\n" +
- " String mypath = \"/data/data/foo\";\n" +
- " ~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/SdCardTest.java:33: Warning: Do not hardcode \"/data/\"; use Context.getFilesDir().getPath() instead [SdCardPath]\n" +
- " String base = \"/data/data/foo.bar/test-profiling\";\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/SdCardTest.java:34: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" +
- " String s = \"file://sdcard/foo\";\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 13 warnings\n",
-
- lintProject("src/test/pkg/SdCardTest.java.txt=>src/test/pkg/SdCardTest.java"));
- }
-
- public void testSuppress() throws Exception {
- assertEquals(
- // The only reference in the file not covered by an annotation
- "src/test/pkg/SuppressTest5.java:40: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" +
- " String notAnnotated = \"/sdcard/mypath\";\n" +
- " ~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- // File with lots of /sdcard references, but with @SuppressLint warnings
- // on fields, methods, variable declarations etc
- lintProject("src/test/pkg/SuppressTest5.java.txt=>src/test/pkg/SuppressTest5.java"));
- }
-
- public void testUtf8Bom() throws Exception {
- assertEquals(
- "src/test/pkg/Utf8BomTest.java:4: Warning: Do not hardcode \"/sdcard/\"; use Environment.getExternalStorageDirectory().getPath() instead [SdCardPath]\n" +
- " String s = \"/sdcard/mydir\";\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject("src/test/pkg/Utf8BomTest.java.data=>src/test/pkg/Utf8BomTest.java"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/SecureRandomDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/SecureRandomDetectorTest.java
deleted file mode 100644
index 0ecbe02..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/SecureRandomDetectorTest.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class SecureRandomDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new SecureRandomDetector();
- }
-
- public void test1() throws Exception {
- assertEquals(
- "src/test/pkg/SecureRandomTest.java:12: Warning: It is dangerous to seed SecureRandom with the current time because that value is more predictable to an attacker than the default seed. [SecureRandom]\n" +
- " random1.setSeed(System.currentTimeMillis()); // OK\n" +
- " ~~~~~~~\n" +
- "src/test/pkg/SecureRandomTest.java:14: Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom]\n" +
- " random1.setSeed(0); // Wrong\n" +
- " ~~~~~~~\n" +
- "src/test/pkg/SecureRandomTest.java:15: Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom]\n" +
- " random1.setSeed(1); // Wrong\n" +
- " ~~~~~~~\n" +
- "src/test/pkg/SecureRandomTest.java:16: Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom]\n" +
- " random1.setSeed((int)1023); // Wrong\n" +
- " ~~~~~~~\n" +
- "src/test/pkg/SecureRandomTest.java:17: Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom]\n" +
- " random1.setSeed(1023L); // Wrong\n" +
- " ~~~~~~~\n" +
- "src/test/pkg/SecureRandomTest.java:18: Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom]\n" +
- " random1.setSeed(FIXED_SEED); // Wrong\n" +
- " ~~~~~~~\n" +
- "src/test/pkg/SecureRandomTest.java:28: Warning: Do not call setSeed() on a SecureRandom with a fixed seed: it is not secure. Use getSeed(). [SecureRandom]\n" +
- " random3.setSeed(0); // Wrong: owner is java/util/Random, but applied to SecureRandom object\n" +
- " ~~~~~~~\n" +
- "0 errors, 7 warnings\n" +
- "",
- // Missing error on line 40, using flow analysis to determine that the seed byte
- // array passed into the SecureRandom constructor is static.
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "res/layout/onclick.xml=>res/layout/onclick.xml",
- "bytecode/SecureRandomTest.java.txt=>src/test/pkg/SecureRandomTest.java",
- "bytecode/SecureRandomTest.class.data=>bin/classes/test/pkg/SecureRandomTest.class"
- ));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/SecurityDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/SecurityDetectorTest.java
deleted file mode 100644
index 198058d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/SecurityDetectorTest.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class SecurityDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new SecurityDetector();
- }
-
- public void testBroken() throws Exception {
- assertEquals(
- "AndroidManifest.xml:12: Warning: Exported service does not require permission [ExportedService]\n" +
- " <service\n" +
- " ^\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintProject(
- "exportservice1.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testBroken2() throws Exception {
- assertEquals(
- "AndroidManifest.xml:12: Warning: Exported service does not require permission [ExportedService]\n" +
- " <service\n" +
- " ^\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintProject(
- "exportservice2.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testBroken3() throws Exception {
- // Not defining exported, but have intent-filters
- assertEquals(
- "AndroidManifest.xml:12: Warning: Exported service does not require permission [ExportedService]\n" +
- " <service\n" +
- " ^\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintProject(
- "exportservice5.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testOk1() throws Exception {
- // Defines a permission on the <service> element
- assertEquals(
- "No warnings.",
- lintProject(
- "exportservice3.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testOk2() throws Exception {
- // Defines a permission on the parent <application> element
- assertEquals(
- "No warnings.",
- lintProject(
- "exportservice4.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testUri() throws Exception {
- assertEquals(
- "AndroidManifest.xml:25: Warning: Content provider shares everything; this is potentially dangerous. [GrantAllUris]\n" +
- " <grant-uri-permission android:path=\"/\"/>\n" +
- " ~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:26: Warning: Content provider shares everything; this is potentially dangerous. [GrantAllUris]\n" +
- " <grant-uri-permission android:pathPrefix=\"/\"/>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 2 warnings\n" +
- "",
-
- lintProject(
- "grantpermission.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- // exportprovider1.xml has two exported content providers with no permissions
- public void testContentProvider1() throws Exception {
- assertEquals(
- "AndroidManifest.xml:14: Warning: Exported content providers can provide access to potentially sensitive data [ExportedContentProvider]\n" +
- " <provider\n" +
- " ^\n" +
- "AndroidManifest.xml:20: Warning: Exported content providers can provide access to potentially sensitive data [ExportedContentProvider]\n" +
- " <provider\n" +
- " ^\n" +
- "0 errors, 2 warnings\n" +
- "",
- lintProject(
- "exportprovider1.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- // exportprovider2.xml has no un-permissioned exported content providers
- public void testContentProvider2() throws Exception {
- assertEquals(
- "No warnings.",
- lintProject(
- "exportprovider2.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testWorldWriteable() throws Exception {
- assertEquals(
- "src/test/pkg/WorldWriteableFile.java:26: Warning: Using MODE_WORLD_READABLE when creating files can be risky, review carefully [WorldReadableFiles]\n" +
- " out = openFileOutput(mFile.getName(), MODE_WORLD_READABLE);\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/WorldWriteableFile.java:31: Warning: Using MODE_WORLD_READABLE when creating files can be risky, review carefully [WorldReadableFiles]\n" +
- " prefs = getSharedPreferences(mContext, MODE_WORLD_READABLE);\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/WorldWriteableFile.java:25: Warning: Using MODE_WORLD_WRITEABLE when creating files can be risky, review carefully [WorldWriteableFiles]\n" +
- " out = openFileOutput(mFile.getName(), MODE_WORLD_WRITEABLE);\n" +
- " ~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/WorldWriteableFile.java:30: Warning: Using MODE_WORLD_WRITEABLE when creating files can be risky, review carefully [WorldWriteableFiles]\n" +
- " prefs = getSharedPreferences(mContext, MODE_WORLD_WRITEABLE);\n" +
- " ~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 4 warnings\n" +
- "",
-
- lintProject(
- // Java files must be renamed in source tree
- "src/test/pkg/WorldWriteableFile.java.txt=>src/test/pkg/WorldWriteableFile.java"));
- }
-
- public void testReceiver0() throws Exception {
- // Activities that do not have intent-filters do not need warnings
- assertEquals(
- "No warnings.",
- lintProject(
- "exportreceiver0.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testReceiver1() throws Exception {
- assertEquals(
- "AndroidManifest.xml:12: Warning: Exported receiver does not require permission [ExportedReceiver]\n" +
- " <receiver\n" +
- " ^\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintProject(
- "exportreceiver1.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testReceiver2() throws Exception {
- // Defines a permission on the <activity> element
- assertEquals(
- "No warnings.",
- lintProject(
- "exportreceiver2.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testReceiver3() throws Exception {
- // Defines a permission on the parent <application> element
- assertEquals(
- "No warnings.",
- lintProject(
- "exportreceiver3.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testReceiver4() throws Exception {
- // Not defining exported, but have intent-filters
- assertEquals(
- "AndroidManifest.xml:12: Warning: Exported receiver does not require permission [ExportedReceiver]\n" +
- " <receiver\n" +
- " ^\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintProject(
- "exportreceiver4.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testReceiver5() throws Exception {
- // Intent filter for standard Android action
- assertEquals(
- "No warnings.",
- lintProject(
- "exportreceiver5.xml=>AndroidManifest.xml",
- "res/values/strings.xml"));
- }
-
- public void testStandard() throws Exception {
- // Various regression tests for http://code.google.com/p/android/issues/detail?id=33976
- assertEquals(
- "No warnings.",
- lintProject("exportreceiver6.xml=>AndroidManifest.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/SetJavaScriptEnabledDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/SetJavaScriptEnabledDetectorTest.java
deleted file mode 100644
index 4979e6a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/SetJavaScriptEnabledDetectorTest.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class SetJavaScriptEnabledDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new SetJavaScriptEnabledDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/pkg/SetJavaScriptEnabled.java:14: Warning: Using setJavaScriptEnabled can introduce XSS vulnerabilities into you application, review carefully. [SetJavaScriptEnabled]\n" +
- " webView.getSettings().setJavaScriptEnabled(true); // bad\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintProject(
- "src/test/pkg/SetJavaScriptEnabled.java.txt=>src/test/pkg/SetJavaScriptEnabled.java"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/SharedPrefsDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/SharedPrefsDetectorTest.java
deleted file mode 100644
index 7035c21..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/SharedPrefsDetectorTest.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class SharedPrefsDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new SharedPrefsDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/pkg/SharedPrefsTest.java:54: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" +
- " SharedPreferences.Editor editor = preferences.edit();\n" +
- " ~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/SharedPrefsTest.java:62: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" +
- " SharedPreferences.Editor editor = preferences.edit();\n" +
- " ~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 2 warnings\n" +
- "",
-
- lintProject("src/test/pkg/SharedPrefsTest.java.txt=>" +
- "src/test/pkg/SharedPrefsTest.java"));
- }
-
- public void test2() throws Exception {
- // Regression test 1 for http://code.google.com/p/android/issues/detail?id=34322
- assertEquals(
- "src/test/pkg/SharedPrefsTest2.java:13: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" +
- " SharedPreferences.Editor editor = preferences.edit();\n" +
- " ~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/SharedPrefsTest2.java:17: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" +
- " Editor editor = preferences.edit();\n" +
- " ~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 2 warnings\n",
-
- lintProject("src/test/pkg/SharedPrefsTest2.java.txt=>" +
- "src/test/pkg/SharedPrefsTest2.java"));
- }
-
- public void test3() throws Exception {
- // Regression test 2 for http://code.google.com/p/android/issues/detail?id=34322
- assertEquals(
- "src/test/pkg/SharedPrefsTest3.java:13: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" +
- " Editor editor = preferences.edit();\n" +
- " ~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n",
-
- lintProject("src/test/pkg/SharedPrefsTest3.java.txt=>" +
- "src/test/pkg/SharedPrefsTest3.java"));
- }
-
- public void test4() throws Exception {
- // Regression test 3 for http://code.google.com/p/android/issues/detail?id=34322
- assertEquals(
- "No warnings.",
-
- lintProject("src/test/pkg/SharedPrefsTest4.java.txt=>" +
- "src/test/pkg/SharedPrefsTest4.java"));
- }
-
- public void test5() throws Exception {
- // Check fields too: http://code.google.com/p/android/issues/detail?id=39134
- assertEquals(
- "src/test/pkg/SharedPrefsTest5.java:16: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" +
- " mPreferences.edit().putString(PREF_FOO, \"bar\");\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/SharedPrefsTest5.java:17: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" +
- " mPreferences.edit().remove(PREF_BAZ).remove(PREF_FOO);\n" +
- " ~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/SharedPrefsTest5.java:26: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" +
- " preferences.edit().putString(PREF_FOO, \"bar\");\n" +
- " ~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/SharedPrefsTest5.java:27: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" +
- " preferences.edit().remove(PREF_BAZ).remove(PREF_FOO);\n" +
- " ~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/SharedPrefsTest5.java:32: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" +
- " preferences.edit().putString(PREF_FOO, \"bar\");\n" +
- " ~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/SharedPrefsTest5.java:33: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" +
- " preferences.edit().remove(PREF_BAZ).remove(PREF_FOO);\n" +
- " ~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/SharedPrefsTest5.java:38: Warning: SharedPreferences.edit() without a corresponding commit() or apply() call [CommitPrefEdits]\n" +
- " Editor editor = preferences.edit().putString(PREF_FOO, \"bar\");\n" +
- " ~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 7 warnings\n",
-
- lintProject("src/test/pkg/SharedPrefsTest5.java.txt=>" +
- "src/test/pkg/SharedPrefsTest5.java"));
- }
-
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/StateListDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/StateListDetectorTest.java
deleted file mode 100644
index 9ff67f4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/StateListDetectorTest.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class StateListDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new StateListDetector();
- }
-
- public void testStates() throws Exception {
- assertEquals(
- "res/drawable/states.xml:3: Warning: This item is unreachable because a previous item (item #1) is a more general match than this one [StateListReachable]\n" +
- " <item android:state_pressed=\"true\"\n" +
- " ^\n" +
- " res/drawable/states.xml:2: Earlier item which masks item\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintProject("res/drawable/states.xml"));
- }
-
- public void testCustomStates() throws Exception {
- assertEquals(
- "No warnings.",
- lintProject("res/drawable/states2.xml"));
- }
-
- public void testStates3() throws Exception {
- assertEquals(
- "res/drawable/states3.xml:24: Warning: This item is unreachable because a previous item (item #1) is a more general match than this one [StateListReachable]\n" +
- " <item android:state_checked=\"false\" android:state_window_focused=\"false\"\n" +
- " ^\n" +
- " res/drawable/states3.xml:18: Earlier item which masks item\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintProject("res/drawable/states3.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/StringFormatDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/StringFormatDetectorTest.java
deleted file mode 100644
index 47fbea1..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/StringFormatDetectorTest.java
+++ /dev/null
@@ -1,198 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import static com.android.tools.lint.checks.StringFormatDetector.isLocaleSpecific;
-
-import com.android.tools.lint.detector.api.Detector;
-
-import java.util.HashSet;
-import java.util.Set;
-
-@SuppressWarnings("javadoc")
-public class StringFormatDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new StringFormatDetector();
- }
-
- public void testAll() throws Exception {
- assertEquals(
- "src/test/pkg/StringFormatActivity.java:13: Error: Wrong argument type for formatting argument '#1' in hello: conversion is 'd', received String [StringFormatMatches]\n" +
- " String output1 = String.format(hello, target);\n" +
- " ~~~~~~\n" +
- " res/values-es/formatstrings.xml:3: Conflicting argument declaration here\n" +
- "src/test/pkg/StringFormatActivity.java:15: Error: Wrong argument count, format string hello2 requires 3 but format call supplies 2 [StringFormatMatches]\n" +
- " String output2 = String.format(hello2, target, \"How are you\");\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/values-es/formatstrings.xml:4: This definition requires 3 arguments\n" +
- "src/test/pkg/StringFormatActivity.java:24: Error: Wrong argument count, format string hello2 requires 3 but format call supplies 2 [StringFormatMatches]\n" +
- " String.format(getResources().getString(R.string.hello2), target, \"How are you\");\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/values-es/formatstrings.xml:4: This definition requires 3 arguments\n" +
- "src/test/pkg/StringFormatActivity.java:25: Error: Wrong argument count, format string hello2 requires 3 but format call supplies 2 [StringFormatMatches]\n" +
- " getResources().getString(hello2, target, \"How are you\");\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/values-es/formatstrings.xml:4: This definition requires 3 arguments\n" +
- "src/test/pkg/StringFormatActivity.java:26: Error: Wrong argument count, format string hello2 requires 3 but format call supplies 2 [StringFormatMatches]\n" +
- " getResources().getString(R.string.hello2, target, \"How are you\");\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/values-es/formatstrings.xml:4: This definition requires 3 arguments\n" +
- "src/test/pkg/StringFormatActivity.java:33: Error: Wrong argument type for formatting argument '#1' in hello: conversion is 'd', received String [StringFormatMatches]\n" +
- " String output1 = String.format(hello, target);\n" +
- " ~~~~~~\n" +
- " res/values-es/formatstrings.xml:3: Conflicting argument declaration here\n" +
- "res/values-es/formatstrings.xml:3: Error: Inconsistent formatting types for argument #1 in format string hello ('%1$d'): Found both 's' and 'd' (in values/formatstrings.xml) [StringFormatMatches]\n" +
- " <string name=\"hello\">%1$d</string>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/values/formatstrings.xml:3: Conflicting argument type here\n" +
- "res/values-es/formatstrings.xml:4: Warning: Inconsistent number of arguments in formatting string hello2; found both 2 and 3 [StringFormatCount]\n" +
- " <string name=\"hello2\">%3$d: %1$s, %2$s?</string>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/values/formatstrings.xml:4: Conflicting number of arguments here\n" +
- "res/values/formatstrings.xml:5: Warning: Formatting string 'missing' is not referencing numbered arguments [1, 2] [StringFormatCount]\n" +
- " <string name=\"missing\">Hello %3$s World</string>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "7 errors, 2 warnings\n" +
- "",
-
- lintProject(
- "res/values/formatstrings.xml",
- "res/values-es/formatstrings.xml",
- // Java files must be renamed in source tree
- "src/test/pkg/StringFormatActivity.java.txt=>src/test/pkg/StringFormatActivity.java"
- ));
- }
-
- public void testArgCount() {
- assertEquals(3, StringFormatDetector.getFormatArgumentCount(
- "First: %1$s, Second %2$s, Third %3$s", null));
- assertEquals(11, StringFormatDetector.getFormatArgumentCount(
- "Skipping stuff: %11$s", null));
- assertEquals(1, StringFormatDetector.getFormatArgumentCount(
- "First: %1$s, Skip \\%2$s", null));
- assertEquals(1, StringFormatDetector.getFormatArgumentCount(
- "First: %s, Skip \\%s", null));
-
- Set<Integer> indices = new HashSet<Integer>();
- assertEquals(11, StringFormatDetector.getFormatArgumentCount(
- "Skipping stuff: %2$d %11$s", indices));
- assertEquals(2, indices.size());
- assertTrue(indices.contains(2));
- assertTrue(indices.contains(11));
- }
-
- public void testArgType() {
- assertEquals("s", StringFormatDetector.getFormatArgumentType(
- "First: %1$s, Second %2$s, Third %3$s", 1));
- assertEquals("d", StringFormatDetector.getFormatArgumentType(
- "First: %1$s, Second %2$-5d, Third %3$s", 2));
- assertEquals("s", StringFormatDetector.getFormatArgumentType(
- "Skipping stuff: %11$s",11));
- assertEquals("d", StringFormatDetector.getFormatArgumentType(
- "First: %1$s, Skip \\%2$s, Value=%2$d", 2));
- }
-
- public void testWrongSyntax() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/values/formatstrings2.xml"
- ));
- }
-
- public void testDateStrings() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/values/formatstrings-version1.xml=>res/values-tl/donottranslate-cldr.xml",
- "res/values/formatstrings-version2.xml=>res/values/donottranslate-cldr.xml"
- ));
- }
-
- public void testUa() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/values/formatstrings-version1.xml=>res/values-tl/donottranslate-cldr.xml",
- "src/test/pkg/StringFormat2.java.txt=>src/test/pkg/StringFormat2.java"
- ));
- }
-
- public void testSuppressed() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/values/formatstrings_ignore.xml=>res/values/formatstrings.xml",
- "res/values-es/formatstrings_ignore.xml=>res/values-es/formatstrings.xml",
- "src/test/pkg/StringFormatActivity_ignore.java.txt=>src/test/pkg/StringFormatActivity.java"
- ));
- }
-
- public void testIssue27108() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject("res/values/formatstrings3.xml"));
- }
-
- public void testIssue39758() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/values/formatstrings4.xml",
- "src/test/pkg/StringFormatActivity2.java.txt=>src/test/pkg/StringFormatActivity2.java"));
- }
-
- public void testIssue42798() throws Exception {
- // http://code.google.com/p/android/issues/detail?id=42798
- // String playsCount = String.format(Locale.FRANCE, this.context.getString(R.string.gridview_views_count), article.playsCount);
- assertEquals(""
- + "src/test/pkg/StringFormat3.java:12: Error: Wrong argument type for formatting argument '#1' in gridview_views_count: conversion is 'd', received String [StringFormatMatches]\n"
- + " context.getString(R.string.gridview_views_count), \"wrong\");\n"
- + " ~~~~~~~\n"
- + " res/values/formatstrings5.xml:3: Conflicting argument declaration here\n"
- + "src/test/pkg/StringFormat3.java:13: Error: Wrong argument type for formatting argument '#1' in gridview_views_count: conversion is 'd', received String [StringFormatMatches]\n"
- + " String s4 = String.format(context.getString(R.string.gridview_views_count), \"wrong\");\n"
- + " ~~~~~~~\n"
- + " res/values/formatstrings5.xml:3: Conflicting argument declaration here\n"
- + "2 errors, 0 warnings\n",
-
- lintProject(
- "res/values/formatstrings5.xml",
- "src/test/pkg/StringFormat3.java.txt=>src/test/pkg/StringFormat3.java"));
- }
-
- public void testIsLocaleSpecific() throws Exception {
- assertFalse(isLocaleSpecific(""));
- assertFalse(isLocaleSpecific("Hello World!"));
- assertFalse(isLocaleSpecific("%% %n"));
- assertFalse(isLocaleSpecific(" %%f"));
- assertFalse(isLocaleSpecific("%x %A %c %b %B %h %n %%"));
- assertTrue(isLocaleSpecific("%f"));
- assertTrue(isLocaleSpecific(" %1$f "));
- assertTrue(isLocaleSpecific(" %5$e "));
- assertTrue(isLocaleSpecific(" %E "));
- assertTrue(isLocaleSpecific(" %g "));
- assertTrue(isLocaleSpecific(" %1$tm %1$te,%1$tY "));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/StyleCycleDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/StyleCycleDetectorTest.java
deleted file mode 100644
index d4823d7..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/StyleCycleDetectorTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class StyleCycleDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new StyleCycleDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "res/values/styles.xml:9: Error: Style DetailsPage_EditorialBuyButton should not extend itself [StyleCycle]\n" +
- "<style name=\"DetailsPage_EditorialBuyButton\" parent=\"@style/DetailsPage_EditorialBuyButton\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n" +
- "",
-
- lintProject("res/values/styles.xml"));
- }
-
- public void test2() throws Exception {
- assertEquals(
- "res/values/stylecycle.xml:3: Error: Potential cycle: PropertyToggle is the implied parent of PropertyToggle.Base and this defines the opposite [StyleCycle]\n" +
- " <style name=\"PropertyToggle\" parent=\"@style/PropertyToggle.Base\"></style>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n" +
- "",
-
- lintProject("res/values/stylecycle.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/SystemPermissionsDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/SystemPermissionsDetectorTest.java
deleted file mode 100644
index 061882c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/SystemPermissionsDetectorTest.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class SystemPermissionsDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new SystemPermissionsDetector();
- }
-
- public void testBrokenOrder() throws Exception {
- assertEquals(
- "AndroidManifest.xml:15: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.intent.category.MASTER_CLEAR.permission.C2D_MESSAGE\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:16: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.ACCESS_CACHE_FILESYSTEM\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:17: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.ACCESS_CHECKIN_PROPERTIES\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:18: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.ACCESS_MTP\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:19: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.ACCESS_SURFACE_FLINGER\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:20: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.ACCOUNT_MANAGER\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:21: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:22: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.ASEC_ACCESS\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:23: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.ASEC_CREATE\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:24: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.ASEC_DESTROY\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:25: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.ASEC_MOUNT_UNMOUNT\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:26: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.ASEC_RENAME\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:27: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.BACKUP\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:28: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.BIND_APPWIDGET\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:29: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.BIND_DEVICE_ADMIN\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:30: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.BIND_INPUT_METHOD\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:31: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.BIND_PACKAGE_VERIFIER\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:32: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.BIND_REMOTEVIEWS\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:33: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.BIND_TEXT_SERVICE\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:34: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.BIND_VPN_SERVICE\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:35: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.BIND_WALLPAPER\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:36: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.BRICK\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:37: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.BROADCAST_PACKAGE_REMOVED\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:38: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.BROADCAST_SMS\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:39: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.BROADCAST_WAP_PUSH\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:40: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.CALL_PRIVILEGED\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:41: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.CHANGE_BACKGROUND_DATA_SETTING\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:42: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.CHANGE_COMPONENT_ENABLED_STATE\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:43: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.CLEAR_APP_USER_DATA\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:44: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.CONFIRM_FULL_BACKUP\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:45: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.CONNECTIVITY_INTERNAL\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:46: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.CONTROL_LOCATION_UPDATES\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:47: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.COPY_PROTECTED_DATA\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:48: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.CRYPT_KEEPER\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:49: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.DELETE_CACHE_FILES\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:50: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.DELETE_PACKAGES\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:51: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.DEVICE_POWER\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:52: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.DIAGNOSTIC\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:53: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.DUMP\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:54: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.FACTORY_TEST\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:55: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.FORCE_BACK\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:56: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.FORCE_STOP_PACKAGES\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:57: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.GLOBAL_SEARCH\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:58: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.GLOBAL_SEARCH_CONTROL\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:59: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.HARDWARE_TEST\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:60: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.INJECT_EVENTS\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:61: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.INSTALL_LOCATION_PROVIDER\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:62: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.INSTALL_PACKAGES\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:63: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.INTERNAL_SYSTEM_WINDOW\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:64: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.MANAGE_APP_TOKENS\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:65: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.MANAGE_NETWORK_POLICY\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:66: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.MANAGE_USB\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:67: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.MASTER_CLEAR\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:68: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.MODIFY_NETWORK_ACCOUNTING\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:69: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.MODIFY_PHONE_STATE\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:70: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.MOVE_PACKAGE\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:71: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.NET_ADMIN\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:72: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.MODIFY_PHONE_STATE\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:73: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.PACKAGE_USAGE_STATS\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:74: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.PACKAGE_VERIFICATION_AGENT\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:75: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.PERFORM_CDMA_PROVISIONING\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:76: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.READ_FRAME_BUFFER\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:77: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.READ_INPUT_STATE\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:78: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.READ_NETWORK_USAGE_HISTORY\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:79: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.READ_PRIVILEGED_PHONE_STATE\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:80: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.REBOOT\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:81: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.RECEIVE_EMERGENCY_BROADCAST\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:82: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.REMOVE_TASKS\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:83: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.RETRIEVE_WINDOW_CONTENT\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:84: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.SEND_SMS_NO_CONFIRMATION\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:85: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.SET_ACTIVITY_WATCHER\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:86: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.SET_ORIENTATION\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:87: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.SET_POINTER_SPEED\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:88: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.SET_PREFERRED_APPLICATIONS\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:89: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.SET_SCREEN_COMPATIBILITY\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:90: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.SET_TIME\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:91: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.SET_WALLPAPER_COMPONENT\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:92: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.SHUTDOWN\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:93: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.STATUS_BAR\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:94: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.STATUS_BAR_SERVICE\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:95: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.STOP_APP_SWITCHES\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:96: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.UPDATE_DEVICE_STATS\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:97: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.WRITE_APN_SETTINGS\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:98: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.WRITE_GSERVICES\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:99: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.WRITE_MEDIA_STORAGE\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "AndroidManifest.xml:100: Error: Permission is only granted to system apps [ProtectedPermissions]\n" +
- " <uses-permission android:name=\"android.permission.WRITE_SECURE_SETTINGS\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "86 errors, 0 warnings\n",
-
- lintProject(
- "protectedpermissions.xml=>AndroidManifest.xml"));
- }
-
- public void testSuppressed() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject("protectedpermissions2.xml=>AndroidManifest.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/TextFieldDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TextFieldDetectorTest.java
deleted file mode 100644
index 795bc85..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/TextFieldDetectorTest.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class TextFieldDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new TextFieldDetector();
- }
-
- public void testField() throws Exception {
- assertEquals(
- "res/layout/note_edit.xml:50: Warning: This text field does not specify an inputType or a hint [TextFields]\n" +
- " <EditText\n" +
- " ^\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintFiles("res/layout/note_edit.xml"));
- }
-
- public void testTypeFromName() throws Exception {
- assertEquals(
- "res/layout/edit_type.xml:14: Warning: The view name (@+id/mypassword) suggests this is a password, but it does not include 'textPassword' in the inputType [TextFields]\n" +
- " android:inputType=\"text\" >\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/layout/edit_type.xml:10: id defined here\n" +
- "res/layout/edit_type.xml:45: Warning: The view name (@+id/password_length) suggests this is a number, but it does not include a numeric inputType (such as 'numberSigned') [TextFields]\n" +
- " android:inputType=\"text\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/layout/edit_type.xml:41: id defined here\n" +
- "res/layout/edit_type.xml:54: Warning: The view name (@+id/welcome_url) suggests this is a URI, but it does not include 'textUri' in the inputType [TextFields]\n" +
- " android:inputType=\"text\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/layout/edit_type.xml:50: id defined here\n" +
- "res/layout/edit_type.xml:63: Warning: The view name (@+id/start_date) suggests this is a date, but it does not include 'date' or 'datetime' in the inputType [TextFields]\n" +
- " android:inputType=\"text\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/layout/edit_type.xml:59: id defined here\n" +
- "res/layout/edit_type.xml:72: Warning: The view name (@+id/email_address) suggests this is an e-mail address, but it does not include 'textEmail' in the inputType [TextFields]\n" +
- " android:inputType=\"text\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/layout/edit_type.xml:68: id defined here\n" +
- "res/layout/edit_type.xml:81: Warning: The view name (@+id/login_pin) suggests this is a password, but it does not include 'numberPassword' in the inputType [TextFields]\n" +
- " android:inputType=\"textPassword\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/layout/edit_type.xml:77: id defined here\n" +
- "res/layout/edit_type.xml:83: Warning: This text field does not specify an inputType or a hint [TextFields]\n" +
- " <EditText\n" +
- " ^\n" +
- "res/layout/edit_type.xml:84: Warning: The view name (@+id/number_of_items) suggests this is a number, but it does not include a numeric inputType (such as 'numberSigned') [TextFields]\n" +
- " android:id=\"@+id/number_of_items\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 8 warnings\n",
-
- lintFiles("res/layout/edit_type.xml"));
- }
-
- public void testContainsWord() {
- assertFalse(containsWord("", "foob"));
- assertFalse(containsWord("foo", "foob"));
-
- assertTrue(containsWord("foo", "foo"));
- assertTrue(containsWord("Foo", "foo"));
- assertTrue(containsWord("foo_bar", "foo"));
- assertTrue(containsWord("bar_foo", "foo"));
- assertTrue(containsWord("bar_Foo", "foo"));
- assertTrue(containsWord("bar_foo_baz", "foo"));
- assertTrue(containsWord("bar_Foo_baz", "foo"));
- assertTrue(containsWord("barFooBaz", "foo"));
- assertTrue(containsWord("barFOO_", "foo"));
- assertTrue(containsWord("FooBaz", "foo"));
- assertTrue(containsWord("BarFoo", "foo"));
- assertFalse(containsWord("barfoo", "foo"));
- assertTrue(containsWord("barfoo", "foo", false, true));
- assertTrue(containsWord("foobar", "foo", true, false));
- assertFalse(containsWord("foobar", "foo"));
- assertFalse(containsWord("barfoobar", "foo"));
-
- assertTrue(containsWord("phoneNumber", "phone"));
- assertTrue(containsWord("phoneNumber", "number"));
- assertTrue(containsWord("uri_prefix", "uri"));
- assertTrue(containsWord("fooURI", "uri"));
- assertTrue(containsWord("my_url", "url"));
- assertTrue(containsWord("network_prefix_length", "length"));
-
- assertFalse(containsWord("sizer", "size"));
- assertFalse(containsWord("synthesize_to_filename", "size"));
- assertFalse(containsWord("update_text", "date"));
- assertFalse(containsWord("daten", "date"));
-
- assertFalse(containsWord("phonenumber", "phone"));
- assertFalse(containsWord("myphone", "phone"));
- assertTrue(containsWord("phonenumber", "phone", true, true));
- assertTrue(containsWord("myphone", "phone", true, true));
- assertTrue(containsWord("phoneNumber", "phone"));
-
- assertTrue(containsWord("phoneNumber", "phone"));
- assertTrue(containsWord("@id/phoneNumber", "phone"));
- assertTrue(containsWord("@+id/phoneNumber", "phone"));
- }
-
- private static boolean containsWord(String name, String word, boolean allowPrefix,
- boolean allowSuffix) {
- return TextFieldDetector.containsWord(name, word, allowPrefix, allowSuffix);
- }
-
- private static boolean containsWord(String name, String word) {
- return TextFieldDetector.containsWord(name, word);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/TextViewDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TextViewDetectorTest.java
deleted file mode 100644
index 0ee144b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/TextViewDetectorTest.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class TextViewDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new TextViewDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "res/layout/edit_textview.xml:13: Warning: Attribute android:autoText should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:autoText=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:14: Warning: Attribute android:bufferType should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:bufferType=\"editable\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:15: Warning: Attribute android:capitalize should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:capitalize=\"words\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:16: Warning: Attribute android:cursorVisible should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:cursorVisible=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:17: Warning: Attribute android:digits should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:digits=\"\"\n" +
- " ~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:18: Warning: Attribute android:editable should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:editable=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:19: Warning: Attribute android:editorExtras should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:editorExtras=\"@+id/foobar\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:22: Warning: Attribute android:imeActionId should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:imeActionId=\"@+id/foo\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:23: Warning: Attribute android:imeActionLabel should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:imeActionLabel=\"\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:24: Warning: Attribute android:imeOptions should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:imeOptions=\"\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:25: Warning: Attribute android:inputMethod should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:inputMethod=\"\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:26: Warning: Attribute android:inputType should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:inputType=\"text\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:27: Warning: Attribute android:numeric should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:numeric=\"\"\n" +
- " ~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:28: Warning: Attribute android:password should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:password=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:29: Warning: Attribute android:phoneNumber should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:phoneNumber=\"true\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:30: Warning: Attribute android:privateImeOptions should not be used with <TextView>: Change element type to <EditText> ? [TextViewEdits]\n" +
- " android:privateImeOptions=\"\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:38: Warning: Attribute android:cursorVisible should not be used with <Button>: intended for editable text widgets [TextViewEdits]\n" +
- " android:cursorVisible=\"true\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:44: Warning: Attribute android:cursorVisible should not be used with <CheckedTextView>: intended for editable text widgets [TextViewEdits]\n" +
- " android:cursorVisible=\"true\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:50: Warning: Attribute android:cursorVisible should not be used with <CheckBox>: intended for editable text widgets [TextViewEdits]\n" +
- " android:cursorVisible=\"true\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:56: Warning: Attribute android:cursorVisible should not be used with <RadioButton>: intended for editable text widgets [TextViewEdits]\n" +
- " android:cursorVisible=\"true\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:62: Warning: Attribute android:cursorVisible should not be used with <ToggleButton>: intended for editable text widgets [TextViewEdits]\n" +
- " android:cursorVisible=\"true\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/edit_textview.xml:83: Warning: Consider making the text value selectable by specifying android:textIsSelectable=\"true\" [SelectableText]\n" +
- " <TextView\n" +
- " ^\n" +
- "0 errors, 22 warnings\n",
-
- lintFiles(
- "apicheck/minsdk14.xml=>AndroidManifest.xml", // API >= 11 for selectable issue
- "res/layout/edit_textview.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/TitleDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TitleDetectorTest.java
deleted file mode 100644
index 7259cde..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/TitleDetectorTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class TitleDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new TitleDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "res/menu/titles.xml:3: Warning: Menu items should specify a title [MenuTitle]\n" +
- " <item android:id=\"@+id/action_bar_progress_spinner\"\n" +
- " ^\n" +
- "res/menu/titles.xml:12: Warning: Menu items should specify a title [MenuTitle]\n" +
- " <item android:id=\"@+id/menu_plus_one\"\n" +
- " ^\n" +
- "0 errors, 2 warnings\n",
-
- lintProject(
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "res/menu/titles.xml"));
- }
-
- public void testOk() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "apicheck/minsdk1.xml=>AndroidManifest.xml",
- "res/menu/titles.xml"));
- }
-
- public void testOk2() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject("res/menu-land/actions.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ToastDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ToastDetectorTest.java
deleted file mode 100644
index 07941b7..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ToastDetectorTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class ToastDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new ToastDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/pkg/ToastTest.java:31: Warning: Toast created but not shown: did you forget to call show() ? [ShowToast]\n" +
- " Toast.makeText(context, \"foo\", Toast.LENGTH_LONG);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/ToastTest.java:32: Warning: Expected duration Toast.LENGTH_SHORT or Toast.LENGTH_LONG, a custom duration value is not supported [ShowToast]\n" +
- " Toast toast = Toast.makeText(context, R.string.app_name, 5000);\n" +
- " ~~~~\n" +
- "src/test/pkg/ToastTest.java:32: Warning: Toast created but not shown: did you forget to call show() ? [ShowToast]\n" +
- " Toast toast = Toast.makeText(context, R.string.app_name, 5000);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "src/test/pkg/ToastTest.java:38: Warning: Toast created but not shown: did you forget to call show() ? [ShowToast]\n" +
- " Toast.makeText(context, \"foo\", Toast.LENGTH_LONG);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 4 warnings\n" +
- "",
-
- lintProject("src/test/pkg/ToastTest.java.txt=>src/test/pkg/ToastTest.java"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/TooManyViewsDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TooManyViewsDetectorTest.java
deleted file mode 100644
index 51b977d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/TooManyViewsDetectorTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class TooManyViewsDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new TooManyViewsDetector();
- }
-
- public void testTooMany() throws Exception {
- assertEquals(
- "res/layout/too_many.xml:399: Warning: too_many.xml has more than 80 views, bad for performance [TooManyViews]\n" +
- " <Button\n" +
- " ^\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintFiles("res/layout/too_many.xml"));
- }
-
- public void testTooDeep() throws Exception {
- assertEquals(
- "res/layout/too_deep.xml:46: Warning: too_deep.xml has more than 10 levels, bad for performance [TooDeepLayout]\n" +
- " <LinearLayout\n" +
- " ^\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintFiles("res/layout/too_deep.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/TranslationDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TranslationDetectorTest.java
deleted file mode 100644
index ee1a2f2..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/TranslationDetectorTest.java
+++ /dev/null
@@ -1,223 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class TranslationDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new TranslationDetector();
- }
-
- @Override
- protected boolean includeParentPath() {
- return true;
- }
-
- public void testTranslation() throws Exception {
- TranslationDetector.sCompleteRegions = false;
- assertEquals(
- // Sample files from the Home app
- "res/values/strings.xml:20: Error: \"show_all_apps\" is not translated in nl-rNL [MissingTranslation]\n" +
- " <string name=\"show_all_apps\">All</string>\n" +
- " ~~~~~~~~~~~~~~~~~~~~\n" +
- "res/values/strings.xml:23: Error: \"menu_wallpaper\" is not translated in nl-rNL [MissingTranslation]\n" +
- " <string name=\"menu_wallpaper\">Wallpaper</string>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/values/strings.xml:25: Error: \"menu_settings\" is not translated in cs, de-rDE, es, es-rUS, nl-rNL [MissingTranslation]\n" +
- " <string name=\"menu_settings\">Settings</string>\n" +
- " ~~~~~~~~~~~~~~~~~~~~\n" +
- "res/values-cs/arrays.xml:3: Error: \"security_questions\" is translated here but not found in default locale [ExtraTranslation]\n" +
- " <string-array name=\"security_questions\">\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/values-es/strings.xml:12: Also translated here\n" +
- "res/values-de-rDE/strings.xml:11: Error: \"continue_skip_label\" is translated here but not found in default locale [ExtraTranslation]\n" +
- " <string name=\"continue_skip_label\">\"Weiter\"</string>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "5 errors, 0 warnings\n" +
- "",
-
- lintProject(
- "res/values/strings.xml",
- "res/values-cs/strings.xml",
- "res/values-de-rDE/strings.xml",
- "res/values-es/strings.xml",
- "res/values-es-rUS/strings.xml",
- "res/values-land/strings.xml",
- "res/values-cs/arrays.xml",
- "res/values-es/donottranslate.xml",
- "res/values-nl-rNL/strings.xml"));
- }
-
- public void testTranslationWithCompleteRegions() throws Exception {
- TranslationDetector.sCompleteRegions = true;
- assertEquals(
- // Sample files from the Home app
- "res/values/strings.xml:19: Error: \"home_title\" is not translated in es-rUS [MissingTranslation]\n" +
- " <string name=\"home_title\">Home Sample</string>\n" +
- " ~~~~~~~~~~~~~~~~~\n" +
- "res/values/strings.xml:20: Error: \"show_all_apps\" is not translated in es-rUS, nl-rNL [MissingTranslation]\n" +
- " <string name=\"show_all_apps\">All</string>\n" +
- " ~~~~~~~~~~~~~~~~~~~~\n" +
- "res/values/strings.xml:23: Error: \"menu_wallpaper\" is not translated in es-rUS, nl-rNL [MissingTranslation]\n" +
- " <string name=\"menu_wallpaper\">Wallpaper</string>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/values/strings.xml:25: Error: \"menu_settings\" is not translated in cs, de-rDE, es-rUS, nl-rNL [MissingTranslation]\n" +
- " <string name=\"menu_settings\">Settings</string>\n" +
- " ~~~~~~~~~~~~~~~~~~~~\n" +
- "res/values/strings.xml:29: Error: \"wallpaper_instructions\" is not translated in es-rUS [MissingTranslation]\n" +
- " <string name=\"wallpaper_instructions\">Tap picture to set portrait wallpaper</string>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- " res/values-land/strings.xml:19: <No location-specific message\n" +
- "res/values-de-rDE/strings.xml:11: Error: \"continue_skip_label\" is translated here but not found in default locale [ExtraTranslation]\n" +
- " <string name=\"continue_skip_label\">\"Weiter\"</string>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "6 errors, 0 warnings\n" +
- "",
-
- lintProject(
- "res/values/strings.xml",
- "res/values-cs/strings.xml",
- "res/values-de-rDE/strings.xml",
- "res/values-es-rUS/strings.xml",
- "res/values-land/strings.xml",
- "res/values-nl-rNL/strings.xml"));
- }
-
- public void testHandleBom() throws Exception {
- // This isn't really testing translation detection; it's just making sure that the
- // XML parser doesn't bomb on BOM bytes (byte order marker) at the beginning of
- // the XML document
- assertEquals(
- "No warnings.",
- lintProject(
- "res/values-de/strings.xml"
- ));
- }
-
- public void testTranslatedArrays() throws Exception {
- TranslationDetector.sCompleteRegions = true;
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/values/translatedarrays.xml",
- "res/values-cs/translatedarrays.xml"));
- }
-
- public void testTranslationSuppresss() throws Exception {
- TranslationDetector.sCompleteRegions = false;
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/values/strings_ignore.xml=>res/values/strings.xml",
- "res/values-es/strings_ignore.xml=>res/values-es/strings.xml",
- "res/values-nl-rNL/strings.xml=>res/values-nl-rNL/strings.xml"));
- }
-
- public void testMixedTranslationArrays() throws Exception {
- // See issue http://code.google.com/p/android/issues/detail?id=29263
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/values/strings3.xml=>res/values/strings.xml",
- "res/values-fr/strings.xml=>res/values-fr/strings.xml"));
- }
-
- public void testLibraryProjects() throws Exception {
- // If a library project provides additional locales, that should not force
- // the main project to include all those translations
- assertEquals(
- "No warnings.",
-
- lintProject(
- // Master project
- "multiproject/main-manifest.xml=>AndroidManifest.xml",
- "multiproject/main.properties=>project.properties",
- "res/values/strings2.xml",
-
- // Library project
- "multiproject/library-manifest.xml=>../LibraryProject/AndroidManifest.xml",
- "multiproject/library.properties=>../LibraryProject/project.properties",
-
- "res/values/strings.xml=>../LibraryProject/res/values/strings.xml",
- "res/values-cs/strings.xml=>../LibraryProject/res/values-cs/strings.xml",
- "res/values-cs/strings.xml=>../LibraryProject/res/values-de/strings.xml",
- "res/values-cs/strings.xml=>../LibraryProject/res/values-nl/strings.xml"
- ));
- }
-
- public void testNonTranslatable1() throws Exception {
- TranslationDetector.sCompleteRegions = true;
- assertEquals(
- "res/values-nb/nontranslatable.xml:3: Error: The resource string \"dummy\" has been marked as translatable=\"false\" [ExtraTranslation]\n" +
- " <string name=\"dummy\">Ignore Me</string>\n" +
- " ~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n" +
- "",
-
- lintProject("res/values/nontranslatable.xml",
- "res/values/nontranslatable2.xml=>res/values-nb/nontranslatable.xml"));
- }
-
- public void testNonTranslatable2() throws Exception {
- TranslationDetector.sCompleteRegions = true;
- assertEquals(
- "res/values-nb/nontranslatable.xml:3: Error: Non-translatable resources should only be defined in the base values/ folder [ExtraTranslation]\n" +
- " <string name=\"dummy\" translatable=\"false\">Ignore Me</string>\n" +
- " ~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n" +
- "",
-
- lintProject("res/values/nontranslatable.xml=>res/values-nb/nontranslatable.xml"));
- }
-
- public void testSpecifiedLanguageOk() throws Exception {
- TranslationDetector.sCompleteRegions = false;
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/values-es/strings.xml=>res/values-es/strings.xml",
- "res/values-es-rUS/strings.xml"));
- }
-
- public void testSpecifiedLanguage() throws Exception {
- TranslationDetector.sCompleteRegions = false;
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/values-es/strings_locale.xml=>res/values/strings.xml",
- "res/values-es-rUS/strings.xml"));
- }
-
- public void testAnalytics() throws Exception {
- // See http://code.google.com/p/android/issues/detail?id=43070
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/values/analytics.xml",
- "res/values-es/donottranslate.xml" // to make app multilingual
- ));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/TypoDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TypoDetectorTest.java
deleted file mode 100644
index 3c49b3a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/TypoDetectorTest.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-import java.util.Arrays;
-
-@SuppressWarnings("javadoc")
-public class TypoDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new TypoDetector();
- }
-
- public void testPlainValues() throws Exception {
- assertEquals(
- "res/values/strings.xml:6: Warning: \"Andriod\" is a common misspelling; did you mean \"Android\" ? [Typos]\n" +
- " <string name=\"s2\">Andriod activites!</string>\n" +
- " ^\n" +
- "res/values/strings.xml:6: Warning: \"activites\" is a common misspelling; did you mean \"activities\" ? [Typos]\n" +
- " <string name=\"s2\">Andriod activites!</string>\n" +
- " ^\n" +
- "res/values/strings.xml:8: Warning: \"Cmoputer\" is a common misspelling; did you mean \"Computer\" ? [Typos]\n" +
- " <string name=\"s3\"> (Cmoputer </string>\n" +
- " ^\n" +
- "res/values/strings.xml:10: Warning: \"throught\" is a common misspelling; did you mean \"thought\" or \"through\" or \"throughout\" ? [Typos]\n" +
- " <string name=\"s4\"><b>throught</b></string>\n" +
- " ^\n" +
- "res/values/strings.xml:12: Warning: \"Seach\" is a common misspelling; did you mean \"Search\" ? [Typos]\n" +
- " <string name=\"s5\">Seach</string>\n" +
- " ^\n" +
- "res/values/strings.xml:16: Warning: \"Tuscon\" is a common misspelling; did you mean \"Tucson\" ? [Typos]\n" +
- " <string name=\"s7\">Tuscon tuscon</string>\n" +
- " ^\n" +
- "res/values/strings.xml:20: Warning: \"Ok\" is usually capitalized as \"OK\" [Typos]\n" +
- " <string name=\"dlg_button_ok\">Ok</string>\n" +
- " ^\n" +
- "0 errors, 7 warnings\n" +
- "",
- lintProject("res/values/typos.xml=>res/values/strings.xml"));
- }
-
- public void testEnLanguage() throws Exception {
- assertEquals(
- "res/values-en-rUS/strings-en.xml:6: Warning: \"Andriod\" is a common misspelling; did you mean \"Android\" ? [Typos]\n" +
- " <string name=\"s2\">Andriod activites!</string>\n" +
- " ^\n" +
- "res/values-en-rUS/strings-en.xml:6: Warning: \"activites\" is a common misspelling; did you mean \"activities\" ? [Typos]\n" +
- " <string name=\"s2\">Andriod activites!</string>\n" +
- " ^\n" +
- "res/values-en-rUS/strings-en.xml:8: Warning: \"Cmoputer\" is a common misspelling; did you mean \"Computer\" ? [Typos]\n" +
- " <string name=\"s3\"> (Cmoputer </string>\n" +
- " ^\n" +
- "res/values-en-rUS/strings-en.xml:10: Warning: \"throught\" is a common misspelling; did you mean \"thought\" or \"through\" or \"throughout\" ? [Typos]\n" +
- " <string name=\"s4\"><b>throught</b></string>\n" +
- " ^\n" +
- "res/values-en-rUS/strings-en.xml:12: Warning: \"Seach\" is a common misspelling; did you mean \"Search\" ? [Typos]\n" +
- " <string name=\"s5\">Seach</string>\n" +
- " ^\n" +
- "res/values-en-rUS/strings-en.xml:16: Warning: \"Tuscon\" is a common misspelling; did you mean \"Tucson\" ? [Typos]\n" +
- " <string name=\"s7\">Tuscon tuscon</string>\n" +
- " ^\n" +
- "res/values-en-rUS/strings-en.xml:20: Warning: \"Ok\" is usually capitalized as \"OK\" [Typos]\n" +
- " <string name=\"dlg_button_ok\">Ok</string>\n" +
- " ^\n" +
- "0 errors, 7 warnings\n" +
- "",
- lintProject("res/values/typos.xml=>res/values-en-rUS/strings-en.xml"));
- }
-
- public void testNorwegian() throws Exception {
- // UTF-8 handling
- assertEquals(
- "res/values-nb/typos.xml:6: Warning: \"Andriod\" is a common misspelling; did you mean \"Android\" ? [Typos]\n" +
- " <string name=\"s2\">Mer morro med Andriod</string>\n" +
- " ^\n" +
- "res/values-nb/typos.xml:6: Warning: \"morro\" is a common misspelling; did you mean \"moro\" ? [Typos]\n" +
- " <string name=\"s2\">Mer morro med Andriod</string>\n" +
- " ^\n" +
- "res/values-nb/typos.xml:8: Warning: \"Parallel\" is a common misspelling; did you mean \"Parallell\" ? [Typos]\n" +
- " <string name=\"s3\"> Parallel </string>\n" +
- " ^\n" +
- "res/values-nb/typos.xml:10: Warning: \"altid\" is a common misspelling; did you mean \"alltid\" ? [Typos]\n" +
- " <string name=\"s4\"><b>altid</b></string>\n" +
- " ^\n" +
- "res/values-nb/typos.xml:12: Warning: \"Altid\" is a common misspelling; did you mean \"Alltid\" ? [Typos]\n" +
- " <string name=\"s5\">Altid</string>\n" +
- " ^\n" +
- "res/values-nb/typos.xml:18: Warning: \"karriære\" is a common misspelling; did you mean \"karrière\" ? [Typos]\n" +
- " <string name=\"s7\">Koding er en spennende karriære</string>\n" +
- " ^\n" +
- "0 errors, 6 warnings\n" +
- "",
- lintProject("res/values-nb/typos.xml"));
- }
-
- public void testGerman() throws Exception {
- // Test globbing and multiple word matching
- assertEquals(
- "res/values-de/typos.xml:6: Warning: \"befindet eine\" is a common misspelling; did you mean \"befindet sich eine\" ? [Typos]\n" +
- " wo befindet eine ip\n" +
- " ^\n" +
- "res/values-de/typos.xml:9: Warning: \"Authorisierungscode\" is a common misspelling; did you mean \"Autorisierungscode\" ? [Typos]\n" +
- " <string name=\"s2\">(Authorisierungscode!)</string>\n" +
- " ^\n" +
- "res/values-de/typos.xml:10: Warning: \"zurück gefoobaren\" is a common misspelling; did you mean \"zurückgefoobaren\" ? [Typos]\n" +
- " <string name=\"s3\"> zurück gefoobaren!</string>\n" +
- " ^\n" +
- "0 errors, 3 warnings\n" +
- "",
- lintProject("res/values-de/typos.xml"));
- }
-
- public void testOk() throws Exception {
- assertEquals(
- "No warnings.",
- lintProject("res/values/typos.xml=>res/values-xy/strings.xml"));
- }
-
- public void testGetReplacements() {
- String s = "\"throught\" is a common misspelling; did you mean \"thought\" or " +
- "\"through\" or \"throughout\" ?\n";
- assertEquals("throught", TypoDetector.getTypo(s));
- assertEquals(Arrays.asList("thought", "through", "throughout"),
- TypoDetector.getSuggestions(s));
- }
-
- public void testNorwegianDefault() throws Exception {
- assertEquals(
- "res/values/typos.xml:5: Warning: \"altid\" is a common misspelling; did you mean \"alltid\" ? [Typos]\n" +
- " <string name=\"s4\"><b>altid</b></string>\n" +
- " ^\n" +
- "res/values/typos.xml:7: Warning: \"Altid\" is a common misspelling; did you mean \"Alltid\" ? [Typos]\n" +
- " <string name=\"s5\">Altid</string>\n" +
- " ^\n" +
- "0 errors, 2 warnings\n",
-
- lintProject("res/values-nb/typos_locale.xml=>res/values/typos.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/TypoLookupTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TypoLookupTest.java
deleted file mode 100644
index e57b8ce..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/TypoLookupTest.java
+++ /dev/null
@@ -1,523 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.client.api.LintClient;
-import com.android.tools.lint.detector.api.Detector;
-import com.google.common.base.Charsets;
-import com.google.common.base.Splitter;
-import com.google.common.io.Files;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.regex.Pattern;
-
-@SuppressWarnings("javadoc")
-public class TypoLookupTest extends AbstractCheckTest {
- private static final String SEPARATOR = "->";
-
- public void testCapitalization() throws Exception {
- LintClient client = new TestLintClient();
- // Make sure it can be read in
- TypoLookup db = TypoLookup.get(client, "de", null);
- assertNotNull(db);
- assertNotNull(db.getTypos("Andriod".getBytes(Charsets.UTF_8), 0, "Andriod".length()));
- }
-
- public void testDictionary_English() throws Exception {
- validateDictionary("en");
- }
-
- public void testDictionary_German() throws Exception {
- validateDictionary("de");
- }
-
- public void testDictionary_Spanish() throws Exception {
- validateDictionary("es");
- }
-
- public void testDictionary_Hungarian() throws Exception {
- validateDictionary("hu");
- }
-
- public void testDictionary_Italian() throws Exception {
- validateDictionary("it");
- }
-
- public void testDictionary_Norwegian() throws Exception {
- validateDictionary("nb");
- }
-
- public void testDictionary_Portuguese() throws Exception {
- validateDictionary("pt");
- }
-
- public void testDictionary_Turkish() throws Exception {
- validateDictionary("tr");
- }
-
- public void test1() {
- TypoLookup db = TypoLookup.get(new TestLintClient(), "en", null);
- assertNull(db.getTypos("hello", 0, "hello".length()));
- assertNull(db.getTypos("this", 0, "this".length()));
-
- assertNotNull(db.getTypos("wiht", 0, "wiht".length()));
- assertNotNull(db.getTypos("woudl", 0, "woudl".length()));
- assertEquals("would", db.getTypos("woudl", 0, "woudl".length()).get(1));
- assertEquals("would", db.getTypos(" woudl ", 2, 7).get(1));
- assertNotNull(db.getTypos("foo wiht bar", 4, 8));
-
- List<String> typos = db.getTypos("throught", 0, "throught".length());
- assertEquals("throught", typos.get(0)); // the typo
- assertEquals("thought", typos.get(1));
- assertEquals("through", typos.get(2));
- assertEquals("throughout", typos.get(3));
-
- // Capitalization handling
- assertNotNull(db.getTypos("Woudl", 0, "Woudl".length()));
- assertNotNull(db.getTypos("Enlish", 0, "Enlish".length()));
- assertNull(db.getTypos("enlish", 0, "enlish".length()));
- assertNull(db.getTypos("enlish".getBytes(Charsets.UTF_8), 0, "enlish".length()));
- assertNotNull(db.getTypos("ok", 0, "ok".length()));
- assertNotNull(db.getTypos("Ok", 0, "Ok".length()));
- assertNull(db.getTypos("OK", 0, "OK".length()));
- }
-
- public void testRegion() {
- TypoLookup db = TypoLookup.get(new TestLintClient(), "en", "US");
- assertNotNull(db.getTypos("wiht", 0, "wiht".length()));
- db = TypoLookup.get(new TestLintClient(), "en", "GB");
- assertNotNull(db.getTypos("wiht", 0, "wiht".length()));
- }
-
- public void test2() {
- TypoLookup db = TypoLookup.get(new TestLintClient(), "nb", null); //$NON-NLS-1$
- assertNull(db.getTypos("hello", 0, "hello".length()));
- assertNull(db.getTypos("this", 0, "this".length()));
-
- assertNotNull(db.getTypos("altid", 0, "altid".length()));
- assertEquals("alltid", db.getTypos("altid", 0, "altid".length()).get(1));
- assertEquals("alltid", db.getTypos(" altid ", 2, 7).get(1));
- assertNotNull(db.getTypos("foo altid bar", 4, 9));
-
- // Test utf-8 string which isn't ASCII
- String s = "karriære";
- byte[] sb = s.getBytes(Charsets.UTF_8);
- assertNotNull(db.getTypos(sb, 0, sb.length));
-
- assertEquals("karrière", db.getTypos(sb, 0, sb.length).get(1));
- }
-
- public void testMultiWords() {
- // Some language dictionaries contain multi-word sequences (e.g. where there's a
- // space on the left hand side). This needs some particular care in the lookup
- // which is usually word oriented.
- TypoLookup db = TypoLookup.get(new TestLintClient(), "de", "DE"); //$NON-NLS-1$
-
- // all zu->allzu
-
- // Text handling
- String t = "all zu";
- assertNotNull(db.getTypos(t, 0, t.length()));
- assertEquals("allzu", db.getTypos(t, 0, t.length()).get(1));
-
- // Byte handling
- byte[] text = "all zu".getBytes(Charsets.UTF_8);
- assertNotNull(db.getTypos(text, 0, text.length));
- assertEquals("allzu", db.getTypos(text, 0, text.length).get(1));
-
- // Test automatically extending search beyond current word
- text = "all zu".getBytes(Charsets.UTF_8);
- assertNotNull(db.getTypos(text, 0, 3));
- assertEquals("allzu", db.getTypos(text, 0, text.length).get(1));
-
-
- text = ") all zu (".getBytes(Charsets.UTF_8);
- assertNotNull(db.getTypos(text, 2, 8));
- assertEquals("allzu", db.getTypos(text, 2, 8).get(1));
-
- text = "am einem".getBytes(Charsets.UTF_8);
- assertNotNull(db.getTypos(text, 0, text.length));
- assertEquals("an einem", db.getTypos(text, 0, text.length).get(1));
- }
-
- public void testGlobbing() {
- TypoLookup db = TypoLookup.get(new TestLintClient(), "de", null);
-
- // Authorisierung*->Autorisierung*
- String text = "Authorisierungscode";
- byte[] bytes = text.getBytes(Charsets.UTF_8);
-
- assertNotNull(db.getTypos(text, 0, text.length()));
- assertEquals("Autorisierungscode", db.getTypos(text, 0, text.length()).get(1));
- assertEquals(text, db.getTypos(text, 0, text.length()).get(0));
-
- assertNotNull(db.getTypos(bytes, 0, bytes.length));
- assertEquals("Autorisierungscode", db.getTypos(bytes, 0, bytes.length).get(1));
-
- // befindet ein*->befindet sich ein*
- text = "wo befindet eine ip";
- assertEquals("befindet sich eine", db.getTypos(text, 3, 16).get(1));
-
- // zurück ge*->zurückge*
- text = "zurück gefoobaren";
- bytes = text.getBytes(Charsets.UTF_8);
- assertNotNull(db.getTypos(bytes, 0, bytes.length));
- assertEquals("zurückgefoobaren", db.getTypos(bytes, 0, bytes.length).get(1));
- }
-
- public void testComparisons() throws Exception {
- // Ensure that the two comparison methods agree
-
- LintClient client = new TestLintClient();
- for (String locale : new String[] { "de", "nb", "es", "en", "pt", "hu", "it", "tr" }) {
- File f = client.findResource(String.format("tools/support/typos-%1$s.txt", locale));
- assertTrue(locale, f != null && f.exists());
-
- Set<String> typos = new HashSet<String>(2000);
- List<String> lines = Files.readLines(f, Charsets.UTF_8);
- for (int i = 0, n = lines.size(); i < n; i++) {
- String line = lines.get(i);
- if (line.isEmpty() || line.trim().startsWith("#")) { //$NON-NLS-1$
- continue;
- }
-
- int index = line.indexOf(SEPARATOR);
- if (index == -1) {
- continue;
- }
- String typo = line.substring(0, index).trim();
- typos.add(typo);
- }
-
- List<String> words = new ArrayList<String>(typos);
-
- // Make sure that the two comparison methods agree on all the strings
- // (which should be in a semi-random order now that they're in a set ordered
- // by their hash codes)
-
- String prevText = words.get(0) + '\000';
- byte[] prevBytes = prevText.getBytes(Charsets.UTF_8);
-
- for (int i = 1; i < words.size(); i++) {
- String text = words.get(i) + '\000';;
- byte[] bytes = text.getBytes(Charsets.UTF_8);
-
- int textCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, text, 0,
- text.length());
- int byteCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, bytes, 0,
- bytes.length);
- assertEquals("Word " + text + " versus prev " + prevText + " at " + i,
- Math.signum(textCompare), Math.signum(byteCompare));
- }
- }
- }
-
- public void testComparison1() throws Exception {
- String prevText = "heraus gebracht\u0000";
- byte[] prevBytes = prevText.getBytes(Charsets.UTF_8);
-
- String text = "Päsident\u0000";
- byte[] bytes = text.getBytes(Charsets.UTF_8);
-
-
- int textCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, text, 0,
- text.length());
- int byteCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, bytes, 0,
- bytes.length);
- assertTrue(byteCompare < 0);
- assertTrue(textCompare < 0);
- assertEquals("Word " + text + " versus prev " + prevText,
- Math.signum(textCompare), Math.signum(byteCompare));
- }
-
- public void testComparison2() throws Exception {
- String prevText = "intepretation\u0000";
- byte[] prevBytes = prevText.getBytes(Charsets.UTF_8);
-
- String text = "Woudl\u0000";
- byte[] bytes = text.getBytes(Charsets.UTF_8);
-
- int textCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, text, 0, text.length());
- int byteCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, bytes, 0, bytes.length);
- assertTrue(byteCompare < 0);
- assertTrue(textCompare < 0);
- assertEquals("Word " + text + " versus prev " + prevText,
- Math.signum(textCompare), Math.signum(byteCompare));
-
- // Reverse capitalization and ensure that it's still the same
- prevText = "Intepretation\u0000";
- prevBytes = prevText.getBytes(Charsets.UTF_8);
-
- text = "woudl\u0000";
- bytes = text.getBytes(Charsets.UTF_8);
-
- textCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, text, 0, text.length());
- byteCompare = TypoLookup.compare(prevBytes, 0, (byte) 0, bytes, 0, bytes.length);
- assertTrue(byteCompare < 0);
- assertTrue(textCompare < 0);
- assertEquals("Word " + text + " versus prev " + prevText,
- Math.signum(textCompare), Math.signum(byteCompare));
- }
-
- // Some dictionaries contain actual sentences regarding usage; these must be stripped out.
- // They're just hardcoded here as we find them
- private static final String[] sRemove = new String[] {
- "- besser ganz darauf verzichten",
- "oft fälschlich für \"angekündigt\"",
- "hinausgehende* − insb. „darüber hinausgehende“",
- " - besser ganz darauf verzichten",
- "svw. bzw. so viel wie bzw. sprachverwandt"
- };
-
- private void validateDictionary(String locale) throws Exception {
- // Check that all the typo files are well formed
- LintClient client = new TestLintClient();
- File f = client.findResource(String.format("tools/support/typos-%1$s.txt", locale));
- assertTrue(locale, f != null && f.exists());
-
- Set<String> typos = new HashSet<String>(2000);
- List<Pattern> patterns = new ArrayList<Pattern>(100);
-
- List<String> lines = Files.readLines(f, Charsets.UTF_8);
- for (int i = 0, n = lines.size(); i < n; i++) {
- String line = lines.get(i);
- if (line.isEmpty() || line.trim().startsWith("#")) { //$NON-NLS-1$
- continue;
- }
-
- assertTrue(msg(f, i, "Line should contain '->': %1$s", line),
- line.contains(SEPARATOR));
- int index = line.indexOf(SEPARATOR);
- String typo = line.substring(0, index).trim();
- String replacements = line.substring(index + SEPARATOR.length()).trim();
-
- if (typo.contains("*") && !typo.endsWith("*")) {
- fixDictionary(f);
- fail(msg(f, i, "Globbing (*) not supported anywhere but at the tail: %1$s", line));
- } else if (typo.contains("*") && !replacements.contains("*")) {
- fail(msg(f, i, "No glob found in the replacements for %1$s", line));
- }
-
- if (replacements.indexOf(',') != -1) {
- Set<String> seen = new HashSet<String>();
- for (String s : Splitter.on(',').omitEmptyStrings().split(replacements)) {
- if (seen.contains(s)) {
- fixDictionary(f);
- fail(msg(f, i, "For typo " + typo
- + " there are repeated replacements (" + s + "): " + line));
- }
- }
- }
-
- assertTrue(msg(f, i, "Typo entry was empty: %1$s", line), !typo.isEmpty());
- assertTrue(msg(f, i, "Typo replacements was empty: %1$s", line),
- !replacements.isEmpty());
-
- for (String blacklist : sRemove) {
- if (replacements.contains(blacklist)) {
- fail(msg(f, i, "Replacements for typo %1$s contain description: %2$s",
- typo, replacements));
- }
- }
- if (typo.equals("sólo") && locale.equals("es")) {
- // sólo->solo
- // This seems to trigger a lot of false positives
- fail(msg(f, i, "Typo %1$s triggers a lot of false positives, should be omitted",
- typo));
- }
- if (locale.equals("tr") && (typo.equals("hiç bir")|| typo.equals("öğe"))) {
- // hiç bir->hiçbir
- // öğe->öge
- // According to a couple of native speakers these are not necessarily
- // typos
- fail(msg(f, i, "Typo %1$s triggers a lot of false positives, should be omitted",
- typo));
- }
-
- if (typo.contains("*")) {
- patterns.add(Pattern.compile(typo.replace("*", ".*")));
- } else if (!patterns.isEmpty()) {
- for (Pattern pattern : patterns) {
- if (pattern.matcher(typo).matches()) {
- fixDictionary(f);
- fail(msg(f, i, "The typo " + typo + " matches an earlier glob: ignoring"));
- continue;
- }
- }
- }
-
-
- if (typos.contains(typo)) {
- fixDictionary(f);
- fail(msg(f, i, "Typo appeared more than once on lhs: %1$s", typo));
- }
- typos.add(typo);
- }
-
- // Make sure it can be read in
- TypoLookup db = TypoLookup.get(client, locale, null);
- assertNotNull(db);
- assertNull(db.getTypos("abcdefghijklmnopqrstuvxyz", 0, 25));
- assertNull(db.getTypos("abcdefghijklmnopqrstuvxyz".getBytes(Charsets.UTF_8), 0, 25));
- assertNotNull(db.getTypos("Andriod", 0, "Andriod".length()));
- assertNotNull(db.getTypos("Andriod".getBytes(Charsets.UTF_8), 0, "Andriod".length()));
- }
-
- private void fixDictionary(File original) throws Exception {
- File fixed = new File(original.getParentFile(), "fixed-" + original.getName());
-
- Map<String, Integer> typos = new HashMap<String, Integer>(2000);
- List<Pattern> patterns = new ArrayList<Pattern>(100);
- List<String> lines = Files.readLines(original, Charsets.UTF_8);
- List<String> output = new ArrayList<String>(lines.size());
-
- wordLoop:
- for (int i = 0, n = lines.size(); i < n; i++) {
- String line = lines.get(i);
- if (line.isEmpty() || line.trim().startsWith("#")) { //$NON-NLS-1$
- output.add(line);
- continue;
- }
-
- if (!line.contains(SEPARATOR)) {
- System.err.println("Commented out line missing ->: " + line);
- output.add("# " + line);
- continue;
- }
- int index = line.indexOf(SEPARATOR);
- String typo = line.substring(0, index).trim();
- String replacements = line.substring(index + SEPARATOR.length()).trim();
-
- if (typo.isEmpty()) {
- System.err.println("Commented out line missing a typo on the lhs: " + line);
- output.add("# " + line);
- continue;
- }
- if (replacements.isEmpty()) {
- System.err.println("Commented out line missing replacements on the rhs: " + line);
- output.add("# " + line);
- continue;
- }
-
- // Ensure that all the replacements are unique
- if (replacements.indexOf(',') != -1) {
- Set<String> seen = new HashSet<String>();
- List<String> out = new ArrayList<String>();
- boolean rewrite = false;
- for (String s : Splitter.on(',').omitEmptyStrings().split(replacements)) {
- if (seen.contains(s)) {
- System.err.println("For typo " + typo
- + " there are repeated replacements (" + s + "): " + line);
- rewrite = true;
- }
- seen.add(s);
- out.add(s);
- }
- if (rewrite) {
- StringBuilder sb = new StringBuilder();
- for (String s : out) {
- if (sb.length() > 0) {
- sb.append(",");
- }
- sb.append(s);
- }
- replacements = sb.toString();
- line = typo + SEPARATOR + replacements;
- }
- }
-
- if (typo.contains("*")) {
- if (!typo.endsWith("*")) {
- // Globbing not supported anywhere but the end
- // Drop the whole word
- System.err.println("Skipping typo " + typo
- + " because globbing is only supported at the end of the word");
- continue;
- }
- patterns.add(Pattern.compile(typo.replace("*", ".*")));
- } else if (replacements.contains("*")) {
- System.err.println("Skipping typo " + typo + " because unexpected " +
- "globbing character found in replacements: "
- + replacements);
- continue;
- } else if (!patterns.isEmpty()) {
- for (Pattern pattern : patterns) {
- if (pattern.matcher(typo).matches()) {
- System.err.println("The typo " + typo
- + " matches an earlier glob: ignoring");
- continue wordLoop;
- }
- }
- }
-
- // TODO: Strip whitespace around ->, prefix of # etc such that reading in
- // the databases needs to do less work at runtime
-
- if (typos.containsKey(typo)) {
- int l = typos.get(typo);
- String prev = output.get(l);
- assertTrue(prev.startsWith(typo));
- // Append new replacements and put back into the list
- // (unless they're already listed as replacements)
- Set<String> seen = new HashSet<String>();
- for (String s : Splitter.on(',').split(prev.substring(prev.indexOf(SEPARATOR)
- + 2))) {
- seen.add(s);
- }
- for (String s : Splitter.on(',').omitEmptyStrings().split(replacements)) {
- if (!seen.contains(s)) {
- prev = prev + "," + s;
- }
- seen.add(s);
- }
- output.set(l, prev);
- } else {
- typos.put(typo, output.size());
- output.add(line);
- }
- }
-
- Writer writer = new BufferedWriter(new FileWriter(fixed));
- for (String line : output) {
- writer.write(line);
- writer.write('\n');
- }
- writer.close();
-
- System.err.println("==> Wrote fixed typo file to " + fixed.getPath());
- }
-
- private static String msg(File file, int line, String message, Object... args) {
- return file.getName() + ':' + Integer.toString(line + 1) + ':' + ' ' +
- String.format(message, args);
- }
-
- @Override
- protected Detector getDetector() {
- fail("This is not used in the TypoLookupTest");
- return null;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/TypographyDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/TypographyDetectorTest.java
deleted file mode 100644
index 5173011..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/TypographyDetectorTest.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import static com.android.tools.lint.checks.TypographyDetector.FRACTION_PATTERN;
-import static com.android.tools.lint.checks.TypographyDetector.GRAVE_QUOTATION;
-import static com.android.tools.lint.checks.TypographyDetector.HYPHEN_RANGE_PATTERN;
-import static com.android.tools.lint.checks.TypographyDetector.SINGLE_QUOTE;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class TypographyDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new TypographyDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "res/values/typography.xml:17: Warning: Replace \"-\" with an \"en dash\" character (–, &#8211;) ? [TypographyDashes]\n" +
- " <string name=\"ndash\">For ages 3-5</string>\n" +
- " ^\n" +
- "res/values/typography.xml:18: Warning: Replace \"-\" with an \"en dash\" character (–, &#8211;) ? [TypographyDashes]\n" +
- " <string name=\"ndash2\">Copyright 2007 - 2011</string>\n" +
- " ^\n" +
- "res/values/typography.xml:20: Warning: Replace \"--\" with an \"em dash\" character (—, &#8212;) ? [TypographyDashes]\n" +
- " <string name=\"mdash\">Not found -- please try again</string>\n" +
- " ^\n" +
- "res/values/typography.xml:24: Warning: Replace \"-\" with an \"en dash\" character (–, &#8211;) ? [TypographyDashes]\n" +
- " <item>Ages 3-5</item>\n" +
- " ^\n" +
- "res/values/typography.xml:15: Warning: Replace \"...\" with ellipsis character (…, &#8230;) ? [TypographyEllipsis]\n" +
- " <string name=\"ellipsis\">40 times...</string>\n" +
- " ^\n" +
- "res/values/typography.xml:12: Warning: Use fraction character ½ (&#189;) instead of 1/2 ? [TypographyFractions]\n" +
- " <string name=\"fraction1\">5 1/2 times</string>\n" +
- " ^\n" +
- "res/values/typography.xml:13: Warning: Use fraction character ¼ (&#188;) instead of 1/4 ? [TypographyFractions]\n" +
- " <string name=\"fraction4\">1/4 times</string>\n" +
- " ^\n" +
- "res/values/typography.xml:25: Warning: Use fraction character ½ (&#189;) instead of 1/2 ? [TypographyFractions]\n" +
- " <item>Age 5 1/2</item>\n" +
- " ^\n" +
- "res/values/typography.xml:3: Warning: Replace straight quotes ('') with directional quotes (‘’, &#8216; and &#8217;) ? [TypographyQuotes]\n" +
- " <string name=\"home_title\">Home 'Sample'</string>\n" +
- " ^\n" +
- "res/values/typography.xml:5: Warning: Replace straight quotes (\") with directional quotes (“”, &#8220; and &#8221;) ? [TypographyQuotes]\n" +
- " <string name=\"show_all_apps2\">Show \"All\"</string>\n" +
- " ^\n" +
- "res/values/typography.xml:6: Warning: Replace straight quotes (\") with directional quotes (“”, &#8220; and &#8221;) ? [TypographyQuotes]\n" +
- " <string name=\"escaped\">Skip \\\"All\\\"</string>\n" +
- " ^\n" +
- "res/values/typography.xml:7: Warning: Replace apostrophe (') with typographic apostrophe (’, &#8217;) ? [TypographyQuotes]\n" +
- " <string name=\"single\">Android's</string>\n" +
- " ^\n" +
- "res/values/typography.xml:9: Warning: Replace apostrophe (') with typographic apostrophe (’, &#8217;) ? [TypographyQuotes]\n" +
- " <string name=\"badquotes1\">`First'</string>\n" +
- " ^\n" +
- "res/values/typography.xml:10: Warning: Avoid quoting with grave accents; use apostrophes or better yet directional quotes instead [TypographyQuotes]\n" +
- " <string name=\"badquotes2\">``second''</string>\n" +
- " ^\n" +
- "res/values/typography.xml:11: Warning: Replace straight quotes ('') with directional quotes (‘’, &#8216; and &#8217;) ? [TypographyQuotes]\n" +
- " <string name=\"notbadquotes\">Type Option-` then 'Escape'</string>\n" +
- " ^\n" +
- "res/values/typography.xml:8: Warning: Replace (c) with copyright symbol © (&#169;) ? [TypographyOther]\n" +
- " <string name=\"copyright\">(c) 2011</string>\n" +
- " ^\n" +
- "0 errors, 16 warnings\n" +
- "",
-
- lintProject("res/values/typography.xml"));
- }
-
- public void testAnalytics() throws Exception {
- assertEquals(""
- + "No warnings.",
-
- lintProject("res/values/analytics.xml"));
- }
-
- public void testSingleQuotesRange() {
- assertTrue(SINGLE_QUOTE.matcher("Foo: 'bar'").matches());
- assertTrue(SINGLE_QUOTE.matcher("'Foo': bar").matches());
- assertTrue(SINGLE_QUOTE.matcher("\"'foo'\"").matches());
- assertTrue(SINGLE_QUOTE.matcher("\"'foo bar'\"").matches());
-
- assertFalse(SINGLE_QUOTE.matcher("foo bar'").matches());
- assertFalse(SINGLE_QUOTE.matcher("Mind your P's and Q's").matches());
-
- // This isn't asserted by the regexp: checked independently in
- // the detector. The goal here is to assert that we need to
- // have some text on either side of the quotes.
- //assertFalse(SINGLE_QUOTE.matcher("'foo bar'").matches());
- }
-
- public void testGraveRegexp() {
- assertTrue(GRAVE_QUOTATION.matcher("`a'").matches());
- assertTrue(GRAVE_QUOTATION.matcher(" `a' ").matches());
- assertTrue(GRAVE_QUOTATION.matcher(" ``a'' ").matches());
- assertFalse(GRAVE_QUOTATION.matcher("`a''").matches());
- }
-
- public void testFractionRegexp() {
- assertTrue(FRACTION_PATTERN.matcher("fraction 1/2.").matches());
- assertTrue(FRACTION_PATTERN.matcher("1/2").matches());
- assertTrue(FRACTION_PATTERN.matcher("1/3").matches());
- assertTrue(FRACTION_PATTERN.matcher("1/4").matches());
- assertTrue(FRACTION_PATTERN.matcher("3/4").matches());
- assertTrue(FRACTION_PATTERN.matcher("1 / 2").matches());
- assertTrue(FRACTION_PATTERN.matcher("1 / 3").matches());
- assertTrue(FRACTION_PATTERN.matcher("1 / 4").matches());
- assertTrue(FRACTION_PATTERN.matcher("3 / 4").matches());
-
- assertFalse(FRACTION_PATTERN.matcher("3 // 4").matches());
- assertFalse(FRACTION_PATTERN.matcher("11 / 2").matches());
- assertFalse(FRACTION_PATTERN.matcher("1 / 22").matches());
- }
-
- public void testNDashRegexp() {
- assertTrue(HYPHEN_RANGE_PATTERN.matcher("3-4").matches());
- assertTrue(HYPHEN_RANGE_PATTERN.matcher("13- 14").matches());
- assertTrue(HYPHEN_RANGE_PATTERN.matcher("13 - 14").matches());
- assertTrue(HYPHEN_RANGE_PATTERN.matcher("The range is 13 - 14").matches());
- assertTrue(HYPHEN_RANGE_PATTERN.matcher("13 - 14.").matches());
-
- assertFalse(HYPHEN_RANGE_PATTERN.matcher("13 - x").matches());
- assertFalse(HYPHEN_RANGE_PATTERN.matcher("x - 14").matches());
- assertFalse(HYPHEN_RANGE_PATTERN.matcher("x-y").matches());
- assertFalse(HYPHEN_RANGE_PATTERN.matcher("-y").matches());
- assertFalse(HYPHEN_RANGE_PATTERN.matcher("x-").matches());
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/UnusedResourceDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/UnusedResourceDetectorTest.java
deleted file mode 100644
index d668a81..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/UnusedResourceDetectorTest.java
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-import com.android.tools.lint.detector.api.Issue;
-
-import java.io.File;
-import java.util.Arrays;
-
-@SuppressWarnings("javadoc")
-public class UnusedResourceDetectorTest extends AbstractCheckTest {
- private boolean mEnableIds = false;
-
- @Override
- protected Detector getDetector() {
- return new UnusedResourceDetector();
- }
-
- @Override
- protected boolean isEnabled(Issue issue) {
- if (issue == UnusedResourceDetector.ISSUE_IDS) {
- return mEnableIds;
- } else {
- return true;
- }
- }
-
- public void testUnused() throws Exception {
- mEnableIds = false;
- assertEquals(
- "res/layout/accessibility.xml: Warning: The resource R.layout.accessibility appears to be unused [UnusedResources]\n" +
- "res/layout/main.xml: Warning: The resource R.layout.main appears to be unused [UnusedResources]\n" +
- "res/layout/other.xml: Warning: The resource R.layout.other appears to be unused [UnusedResources]\n" +
- "res/values/strings2.xml:3: Warning: The resource R.string.hello appears to be unused [UnusedResources]\n" +
- " <string name=\"hello\">Hello</string>\n" +
- " ~~~~~~~~~~~~\n" +
- "0 errors, 4 warnings\n" +
- "",
-
- lintProject(
- "res/values/strings2.xml",
- "res/layout/layout1.xml=>res/layout/main.xml",
- "res/layout/layout1.xml=>res/layout/other.xml",
-
- // Rename .txt files to .java
- "src/my/pkg/Test.java.txt=>src/my/pkg/Test.java",
- "gen/my/pkg/R.java.txt=>gen/my/pkg/R.java",
- "AndroidManifest.xml",
- "res/layout/accessibility.xml"));
- }
-
- public void testUnusedIds() throws Exception {
- mEnableIds = true;
-
- assertEquals(
- "res/layout/accessibility.xml: Warning: The resource R.layout.accessibility appears to be unused [UnusedResources]\n" +
- "Warning: The resource R.layout.main appears to be unused [UnusedResources]\n" +
- "Warning: The resource R.layout.other appears to be unused [UnusedResources]\n" +
- "Warning: The resource R.string.hello appears to be unused [UnusedResources]\n" +
- "Warning: The resource R.id.imageView1 appears to be unused [UnusedIds]\n" +
- "Warning: The resource R.id.include1 appears to be unused [UnusedIds]\n" +
- "Warning: The resource R.id.linearLayout2 appears to be unused [UnusedIds]\n" +
- "res/layout/accessibility.xml:2: Warning: The resource R.id.newlinear appears to be unused [UnusedIds]\n" +
- "<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" android:id=\"@+id/newlinear\" android:orientation=\"vertical\" android:layout_width=\"match_parent\" android:layout_height=\"match_parent\">\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/accessibility.xml:3: Warning: The resource R.id.button1 appears to be unused [UnusedIds]\n" +
- " <Button android:text=\"Button\" android:id=\"@+id/button1\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\"></Button>\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/accessibility.xml:4: Warning: The resource R.id.android_logo appears to be unused [UnusedIds]\n" +
- " <ImageView android:id=\"@+id/android_logo\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/accessibility.xml:5: Warning: The resource R.id.android_logo2 appears to be unused [UnusedIds]\n" +
- " <ImageButton android:importantForAccessibility=\"yes\" android:id=\"@+id/android_logo2\" android:layout_width=\"wrap_content\" android:layout_height=\"wrap_content\" android:src=\"@drawable/android_button\" android:focusable=\"false\" android:clickable=\"false\" android:layout_weight=\"1.0\" />\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 11 warnings\n" +
- "",
-
- lintProject(
- // Rename .txt files to .java
- "src/my/pkg/Test.java.txt=>src/my/pkg/Test.java",
- "gen/my/pkg/R.java.txt=>gen/my/pkg/R.java",
- "AndroidManifest.xml",
- "res/layout/accessibility.xml"));
- }
-
- public void testArrayReference() throws Exception {
- assertEquals(
- "res/values/arrayusage.xml:3: Warning: The resource R.array.my_array appears to be unused [UnusedResources]\n" +
- "<string-array name=\"my_array\">\n" +
- " ~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "AndroidManifest.xml",
- "res/values/arrayusage.xml"));
- }
-
- public void testAttrs() throws Exception {
- assertEquals(
- "res/layout/customattrlayout.xml: Warning: The resource R.layout.customattrlayout appears to be unused [UnusedResources]\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "res/values/customattr.xml",
- "res/layout/customattrlayout.xml",
- "unusedR.java.txt=>gen/my/pkg/R.java",
- "AndroidManifest.xml"));
- }
-
- public void testMultiProjectIgnoreLibraries() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- // Master project
- "multiproject/main-manifest.xml=>AndroidManifest.xml",
- "multiproject/main.properties=>project.properties",
- "multiproject/MainCode.java.txt=>src/foo/main/MainCode.java",
-
- // Library project
- "multiproject/library-manifest.xml=>../LibraryProject/AndroidManifest.xml",
- "multiproject/library.properties=>../LibraryProject/project.properties",
- "multiproject/LibraryCode.java.txt=>../LibraryProject/src/foo/library/LibraryCode.java",
- "multiproject/strings.xml=>../LibraryProject/res/values/strings.xml"
- ));
- }
-
- public void testMultiProject() throws Exception {
- File master = getProjectDir("MasterProject",
- // Master project
- "multiproject/main-manifest.xml=>AndroidManifest.xml",
- "multiproject/main.properties=>project.properties",
- "multiproject/MainCode.java.txt=>src/foo/main/MainCode.java"
- );
- File library = getProjectDir("LibraryProject",
- // Library project
- "multiproject/library-manifest.xml=>AndroidManifest.xml",
- "multiproject/library.properties=>project.properties",
- "multiproject/LibraryCode.java.txt=>src/foo/library/LibraryCode.java",
- "multiproject/strings.xml=>res/values/strings.xml"
- );
- assertEquals(
- // string1 is defined and used in the library project
- // string2 is defined in the library project and used in the master project
- // string3 is defined in the library project and not used anywhere
- "/TESTROOT/LibraryProject/res/values/strings.xml:7: Warning: The resource R.string.string3 appears to be unused [UnusedResources]\n" +
- " <string name=\"string3\">String 3</string>\n" +
- " ~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n",
-
- checkLint(Arrays.asList(master, library)));
- }
-
- public void testFqcnReference() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/layout/layout1.xml=>res/layout/main.xml",
- "src/test/pkg/UnusedReference.java.txt=>src/test/pkg/UnusedReference.java",
- "AndroidManifest.xml"));
- }
-
- public void testIgnoreXmlDrawable() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/drawable/ic_menu_help.xml",
- "gen/my/pkg/R2.java.txt=>gen/my/pkg/R.java"
- ));
- }
-
- public void testPlurals() throws Exception {
- assertEquals(
- "res/values/plurals.xml:3: Warning: The resource R.plurals.my_plural appears to be unused [UnusedResources]\n" +
- " <plurals name=\"my_plural\">\n" +
- " ~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "res/values/strings4.xml",
- "res/values/plurals.xml",
- "AndroidManifest.xml"));
- }
-
- public void testNoMerging() throws Exception {
- // http://code.google.com/p/android/issues/detail?id=36952
-
- File master = getProjectDir("MasterProject",
- // Master project
- "multiproject/main-manifest.xml=>AndroidManifest.xml",
- "multiproject/main.properties=>project.properties",
- "multiproject/MainCode.java.txt=>src/foo/main/MainCode.java"
- );
- File library = getProjectDir("LibraryProject",
- // Library project
- "multiproject/library-manifest.xml=>AndroidManifest.xml",
- "multiproject/library.properties=>project.properties",
- "multiproject/LibraryCode.java.txt=>src/foo/library/LibraryCode.java",
- "multiproject/strings.xml=>res/values/strings.xml"
- );
- assertEquals(
- // The strings are all referenced in the library project's manifest file
- // which in this project is merged in
- "/TESTROOT/LibraryProject/res/values/strings.xml:7: Warning: The resource R.string.string3 appears to be unused [UnusedResources]\n" +
- " <string name=\"string3\">String 3</string>\n" +
- " ~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n",
-
- checkLint(Arrays.asList(master, library)));
- }
-
- public void testLibraryMerging() throws Exception {
- // http://code.google.com/p/android/issues/detail?id=36952
- File master = getProjectDir("MasterProject",
- // Master project
- "multiproject/main-manifest.xml=>AndroidManifest.xml",
- "multiproject/main-merge.properties=>project.properties",
- "multiproject/MainCode.java.txt=>src/foo/main/MainCode.java"
- );
- File library = getProjectDir("LibraryProject",
- // Library project
- "multiproject/library-manifest.xml=>AndroidManifest.xml",
- "multiproject/library.properties=>project.properties",
- "multiproject/LibraryCode.java.txt=>src/foo/library/LibraryCode.java",
- "multiproject/strings.xml=>res/values/strings.xml"
- );
- assertEquals(
- // The strings are all referenced in the library project's manifest file
- // which in this project is merged in
- "No warnings.",
-
- checkLint(Arrays.asList(master, library)));
- }
-
- public void testCornerCase() throws Exception {
- // See http://code.google.com/p/projectlombok/issues/detail?id=415
- mEnableIds = true;
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/layout/accessibility.xml",
- "src/test/pkg/Foo.java.txt=>src/test/pkg/Foo.java",
- "AndroidManifest.xml"));
- }
-
- public void testAnalytics() throws Exception {
- // See http://code.google.com/p/android/issues/detail?id=42565
- mEnableIds = false;
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/values/analytics.xml"
- ));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/UseCompoundDrawableDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/UseCompoundDrawableDetectorTest.java
deleted file mode 100644
index 146ff6f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/UseCompoundDrawableDetectorTest.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class UseCompoundDrawableDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new UseCompoundDrawableDetector();
- }
-
- public void testCompound() throws Exception {
- assertEquals(
- "res/layout/compound.xml:3: Warning: This tag and its children can be replaced by one <TextView/> and a compound drawable [UseCompoundDrawables]\n" +
- "<LinearLayout\n" +
- "^\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintFiles("res/layout/compound.xml"));
- }
-
- public void testCompound2() throws Exception {
- // Ignore layouts that set a custom background
- assertEquals(
- "No warnings.",
- lintFiles("res/layout/compound2.xml"));
- }
-
- public void testCompound3() throws Exception {
- // Ignore layouts that set an image scale type
- assertEquals(
- "No warnings.",
- lintFiles("res/layout/compound3.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/UselessViewDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/UselessViewDetectorTest.java
deleted file mode 100644
index c34b987..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/UselessViewDetectorTest.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class UselessViewDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new UselessViewDetector();
- }
-
- public void testUseless() throws Exception {
- assertEquals(
- "res/layout/useless.xml:85: Warning: This FrameLayout view is useless (no children, no background, no id, no style) [UselessLeaf]\n" +
- " <FrameLayout\n" +
- " ^\n" +
- "res/layout/useless.xml:13: Warning: This LinearLayout layout or its FrameLayout parent is useless [UselessParent]\n" +
- " <LinearLayout\n" +
- " ^\n" +
- "res/layout/useless.xml:47: Warning: This LinearLayout layout or its FrameLayout parent is useless; transfer the background attribute to the other view [UselessParent]\n" +
- " <LinearLayout\n" +
- " ^\n" +
- "res/layout/useless.xml:65: Warning: This LinearLayout layout or its FrameLayout parent is useless; transfer the background attribute to the other view [UselessParent]\n" +
- " <LinearLayout\n" +
- " ^\n" +
- "0 errors, 4 warnings\n" +
- "",
- lintFiles("res/layout/useless.xml"));
- }
-
- public void testTabHost() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintFiles("res/layout/useless2.xml"));
- }
-
- public void testStyleAttribute() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintFiles("res/layout/useless3.xml"));
- }
-
- public void testUselessLeafRoot() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintFiles("res/layout/breadcrumbs_in_fragment.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/Utf8DetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/Utf8DetectorTest.java
deleted file mode 100644
index d1a118d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/Utf8DetectorTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class Utf8DetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new Utf8Detector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "res/layout/encoding.xml:1: Warning: iso-latin-1: Not using UTF-8 as the file encoding. This can lead to subtle bugs with non-ascii characters [EnforceUTF8]\n" +
- "<?xml version=\"1.0\" encoding=\"iso-latin-1\"?>\n" +
- " ~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
- lintProject("res/layout/encoding.xml"));
- }
-
- public void testWithR() throws Exception {
- assertEquals(
- "res/layout/encoding2.xml:1: Warning: iso-latin-1: Not using UTF-8 as the file encoding. This can lead to subtle bugs with non-ascii characters [EnforceUTF8]\n" +
- "<?xml version=\"1.0\" encoding=\"iso-latin-1\"?>\n" +
- " ~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
- // encoding2.xml = encoding.xml but with \n => \r
- lintProject("res/layout/encoding2.xml"));
- }
-
- public void testNegative() throws Exception {
- // Make sure we don't get warnings for a correct file
- assertEquals(
- "No warnings.",
- lintProject("res/layout/layout1.xml"));
- }
-
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ViewConstructorDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ViewConstructorDetectorTest.java
deleted file mode 100644
index a84a74f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ViewConstructorDetectorTest.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class ViewConstructorDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new ViewConstructorDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/bytecode/CustomView1.java: Warning: Custom view test/pkg/CustomView1 is missing constructor used by tools: (Context) or (Context,AttributeSet) or (Context,AttributeSet,int) [ViewConstructor]\n" +
- "src/test/bytecode/CustomView2.java: Warning: Custom view test/pkg/CustomView2 is missing constructor used by tools: (Context) or (Context,AttributeSet) or (Context,AttributeSet,int) [ViewConstructor]\n" +
- "0 errors, 2 warnings\n" +
- "",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "bytecode/CustomView1.java.txt=>src/test/bytecode/CustomView1.java",
- "bytecode/CustomView2.java.txt=>src/test/bytecode/CustomView2.java",
- "bytecode/CustomView3.java.txt=>src/test/bytecode/CustomView3.java",
- "bytecode/CustomView1.class.data=>bin/classes/test/bytecode/CustomView1.class",
- "bytecode/CustomView2.class.data=>bin/classes/test/bytecode/CustomView2.class",
- "bytecode/CustomView3.class.data=>bin/classes/test/bytecode/CustomView3.class"
- ));
- }
-
- public void testInheritLocal() throws Exception {
- assertEquals(
- "src/test/pkg/CustomViewTest.java: Warning: Custom view test/pkg/CustomViewTest is missing constructor used by tools: (Context) or (Context,AttributeSet) or (Context,AttributeSet,int) [ViewConstructor]\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "apicheck/Intermediate.java.txt=>src/test/pkg/Intermediate.java.txt",
- "src/test/pkg/CustomViewTest.java.txt=>src/test/pkg/CustomViewTest.java",
- "bytecode/CustomViewTest.class.data=>bin/classes/test/pkg/CustomViewTest.class",
- "apicheck/Intermediate.class.data=>bin/classes/test/pkg/Intermediate.class",
- "apicheck/Intermediate$IntermediateCustomV.class.data=>" +
- "bin/classes/test/pkg/Intermediate$IntermediateCustomV.class"
- ));
- }
-
- public void testAbstract() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "bytecode/AbstractCustomView.java.txt=>src/test/bytecode/AbstractCustomView.java",
- "bytecode/AbstractCustomView.class.data=>bin/classes/test/bytecode/AbstractCustomView.class"
- ));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ViewTagDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ViewTagDetectorTest.java
deleted file mode 100644
index 8d9e2d5..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ViewTagDetectorTest.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class ViewTagDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new ViewTagDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/pkg/ViewTagTest.java:21: Warning: Avoid setting views as values for setTag: Can lead to memory leaks in versions older than Android 4.0 [ViewTag]\n" +
- " view.setTag(android.R.id.button1, group); // ERROR\n" +
- " ~~~~~~\n" +
- "src/test/pkg/ViewTagTest.java:22: Warning: Avoid setting views as values for setTag: Can lead to memory leaks in versions older than Android 4.0 [ViewTag]\n" +
- " view.setTag(android.R.id.icon, view.findViewById(android.R.id.icon)); // ERROR\n" +
- " ~~~~~~\n" +
- "src/test/pkg/ViewTagTest.java:23: Warning: Avoid setting cursors as values for setTag: Can lead to memory leaks in versions older than Android 4.0 [ViewTag]\n" +
- " view.setTag(android.R.id.icon1, cursor1); // ERROR\n" +
- " ~~~~~~\n" +
- "src/test/pkg/ViewTagTest.java:24: Warning: Avoid setting cursors as values for setTag: Can lead to memory leaks in versions older than Android 4.0 [ViewTag]\n" +
- " view.setTag(android.R.id.icon2, cursor2); // ERROR\n" +
- " ~~~~~~\n" +
- "src/test/pkg/ViewTagTest.java:25: Warning: Avoid setting view holders as values for setTag: Can lead to memory leaks in versions older than Android 4.0 [ViewTag]\n" +
- " view.setTag(android.R.id.copy, new MyViewHolder()); // ERROR\n" +
- " ~~~~~~\n" +
- "0 errors, 5 warnings\n",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "res/layout/onclick.xml=>res/layout/onclick.xml",
- "bytecode/ViewTagTest.java.txt=>src/test/pkg/ViewTagTest.java",
- "bytecode/ViewTagTest.class.data=>bin/classes/test/pkg/ViewTagTest.class"
- ));
- }
-
- public void testICS() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "apicheck/minsdk14.xml=>AndroidManifest.xml",
- "res/layout/onclick.xml=>res/layout/onclick.xml",
- "bytecode/ViewTagTest.java.txt=>src/test/pkg/ViewTagTest.java",
- "bytecode/ViewTagTest.class.data=>bin/classes/test/pkg/ViewTagTest.class"
- ));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/ViewTypeDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/ViewTypeDetectorTest.java
deleted file mode 100644
index cf38197..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/ViewTypeDetectorTest.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class ViewTypeDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new ViewTypeDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/pkg/WrongCastActivity.java:13: Error: Unexpected cast to ToggleButton: layout tag was Button [WrongViewCast]\n" +
- " ToggleButton toggleButton = (ToggleButton) findViewById(R.id.button);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n",
-
- lintProject(
- "res/layout/casts.xml",
- "src/test/pkg/WrongCastActivity.java.txt=>src/test/pkg/WrongCastActivity.java"
- ));
- }
-
- public void test2() throws Exception {
- assertEquals(
- "src/test/pkg/WrongCastActivity.java:13: Error: Unexpected cast to ToggleButton: layout tag was Button|RadioButton [WrongViewCast]\n" +
- " ToggleButton toggleButton = (ToggleButton) findViewById(R.id.button);\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "1 errors, 0 warnings\n",
-
- lintProject(
- "res/layout/casts.xml",
- "res/layout/casts3.xml",
- "src/test/pkg/WrongCastActivity.java.txt=>src/test/pkg/WrongCastActivity.java"
- ));
- }
-
- public void test3() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/layout/casts.xml",
- "res/layout/casts4.xml",
- "src/test/pkg/WrongCastActivity.java.txt=>src/test/pkg/WrongCastActivity.java"
- ));
- }
-
- public void test27441() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/layout/casts2.xml",
- "src/test/pkg/WrongCastActivity2.java.txt=>src/test/pkg/WrongCastActivity2.java"
- ));
- }
-
- public void testCheckable() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "res/layout/casts2.xml",
- "src/test/pkg/WrongCastActivity3.java.txt=>src/test/pkg/WrongCastActivity3.java"
- ));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/WakelockDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/WakelockDetectorTest.java
deleted file mode 100644
index 21434bb..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/WakelockDetectorTest.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class WakelockDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new WakelockDetector();
- }
-
- public void test1() throws Exception {
- assertEquals(
- "src/test/pkg/WakelockActivity1.java:15: Warning: Found a wakelock acquire() but no release() calls anywhere [Wakelock]\n" +
- " mWakeLock.acquire(); // Never released\n" +
- " ~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "res/layout/onclick.xml=>res/layout/onclick.xml",
- "bytecode/WakelockActivity1.java.txt=>src/test/pkg/WakelockActivity1.java",
- "bytecode/WakelockActivity1.class.data=>bin/classes/test/pkg/WakelockActivity1.class"
- ));
- }
-
- public void test2() throws Exception {
- assertEquals(
- "src/test/pkg/WakelockActivity2.java:13: Warning: Wakelocks should be released in onPause, not onDestroy [Wakelock]\n" +
- " mWakeLock.release(); // Should be done in onPause instead\n" +
- " ~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "res/layout/onclick.xml=>res/layout/onclick.xml",
- "bytecode/WakelockActivity2.java.txt=>src/test/pkg/WakelockActivity2.java",
- "bytecode/WakelockActivity2.class.data=>bin/classes/test/pkg/WakelockActivity2.class"
- ));
- }
-
- public void test3() throws Exception {
- assertEquals(
- "src/test/pkg/WakelockActivity3.java:13: Warning: The release() call is not always reached [Wakelock]\n" +
- " lock.release(); // Should be in finally block\n" +
- " ~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "res/layout/onclick.xml=>res/layout/onclick.xml",
- "bytecode/WakelockActivity3.java.txt=>src/test/pkg/WakelockActivity3.java",
- "bytecode/WakelockActivity3.class.data=>bin/classes/test/pkg/WakelockActivity3.class"
- ));
- }
-
- public void test4() throws Exception {
- assertEquals(
- "src/test/pkg/WakelockActivity4.java:10: Warning: The release() call is not always reached [Wakelock]\n" +
- " getLock().release(); // Should be in finally block\n" +
- " ~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "res/layout/onclick.xml=>res/layout/onclick.xml",
- "bytecode/WakelockActivity4.java.txt=>src/test/pkg/WakelockActivity4.java",
- "bytecode/WakelockActivity4.class.data=>bin/classes/test/pkg/WakelockActivity4.class"
- ));
- }
-
- public void test5() throws Exception {
- assertEquals(
- "src/test/pkg/WakelockActivity5.java:13: Warning: The release() call is not always reached [Wakelock]\n" +
- " lock.release(); // Should be in finally block\n" +
- " ~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "res/layout/onclick.xml=>res/layout/onclick.xml",
- "bytecode/WakelockActivity5.java.txt=>src/test/pkg/WakelockActivity5.java",
- "bytecode/WakelockActivity5.class.data=>bin/classes/test/pkg/WakelockActivity5.class"
- ));
- }
-
- public void test6() throws Exception {
- assertEquals(
- "src/test/pkg/WakelockActivity6.java:19: Warning: The release() call is not always reached [Wakelock]\n" +
- " lock.release(); // Wrong\n" +
- " ~~~~~~~\n" +
- "src/test/pkg/WakelockActivity6.java:28: Warning: The release() call is not always reached [Wakelock]\n" +
- " lock.release(); // Wrong\n" +
- " ~~~~~~~\n" +
- "src/test/pkg/WakelockActivity6.java:65: Warning: The release() call is not always reached [Wakelock]\n" +
- " lock.release(); // Wrong\n" +
- " ~~~~~~~\n" +
- "0 errors, 3 warnings\n" +
- "",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "res/layout/onclick.xml=>res/layout/onclick.xml",
- "bytecode/WakelockActivity6.java.txt=>src/test/pkg/WakelockActivity6.java",
- "bytecode/WakelockActivity6.class.data=>bin/classes/test/pkg/WakelockActivity6.class"
- ));
- }
-
- public void test7() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "res/layout/onclick.xml=>res/layout/onclick.xml",
- "bytecode/WakelockActivity7.java.txt=>src/test/pkg/WakelockActivity7.java",
- "bytecode/WakelockActivity7.class.data=>bin/classes/test/pkg/WakelockActivity7.class"
- ));
- }
-
- public void test8() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "bytecode/WakelockActivity8.java.txt=>src/test/pkg/WakelockActivity8.java",
- "bytecode/WakelockActivity8.class.data=>bin/classes/test/pkg/WakelockActivity8.class"
- ));
- }
-
- public void testFlags() throws Exception {
- assertEquals(""
- + "src/test/pkg/PowerManagerFlagTest.java:15: Warning: Should not set both PARTIAL_WAKE_LOCK and ACQUIRE_CAUSES_WAKEUP. If you do not want the screen to turn on, get rid of ACQUIRE_CAUSES_WAKEUP [Wakelock]\n"
- + " pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK|ACQUIRE_CAUSES_WAKEUP, \"Test\"); // Bad\n"
- + " ~~~~~~~~~~~\n"
- + "0 errors, 1 warnings\n",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "bytecode/PowerManagerFlagTest.java.txt=>src/test/pkg/PowerManagerFlagTest.java",
- "bytecode/PowerManagerFlagTest.class.data=>bin/classes/test/pkg/PowerManagerFlagTest.class"
- ));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongCallDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/WrongCallDetectorTest.java
deleted file mode 100644
index ff557ab..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongCallDetectorTest.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class WrongCallDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new WrongCallDetector();
- }
-
- public void test() throws Exception {
- assertEquals(""
- + "src/test/pkg/LayoutTest.java:23: Error: Suspicious method call; should probably call \"layout\" rather than \"onLayout\" [WrongCall]\n"
- + " child.onLayout(changed, left, top, right, bottom); // Not OK\n"
- + " ~~~~~~~~\n"
- + "src/test/pkg/LayoutTest.java:25: Error: Suspicious method call; should probably call \"measure\" rather than \"onMeasure\" [WrongCall]\n"
- + " super.onMeasure(0, 0); // Not OK\n"
- + " ~~~~~~~~~\n"
- + "src/test/pkg/LayoutTest.java:26: Error: Suspicious method call; should probably call \"draw\" rather than \"onDraw\" [WrongCall]\n"
- + " super.onDraw(null); // Not OK\n"
- + " ~~~~~~\n"
- + "src/test/pkg/LayoutTest.java:33: Error: Suspicious method call; should probably call \"layout\" rather than \"onLayout\" [WrongCall]\n"
- + " super.onLayout(false, 0, 0, 0, 0); // Not OK\n"
- + " ~~~~~~~~\n"
- + "src/test/pkg/LayoutTest.java:34: Error: Suspicious method call; should probably call \"measure\" rather than \"onMeasure\" [WrongCall]\n"
- + " child.onMeasure(widthMeasureSpec, heightMeasureSpec); // Not OK\n"
- + " ~~~~~~~~~\n"
- + "src/test/pkg/LayoutTest.java:41: Error: Suspicious method call; should probably call \"draw\" rather than \"onDraw\" [WrongCall]\n"
- + " child.onDraw(canvas); // Not OK\n"
- + " ~~~~~~\n"
- + "6 errors, 0 warnings\n",
-
- lintProject(
- "bytecode/.classpath=>.classpath",
- "bytecode/AndroidManifest.xml=>AndroidManifest.xml",
- "res/layout/onclick.xml=>res/layout/onclick.xml",
- "bytecode/LayoutTest.java.txt=>src/test/pkg/LayoutTest.java",
- "bytecode/LayoutTest.class.data=>bin/classes/test/pkg/LayoutTest.class"
- ));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongCaseDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/WrongCaseDetectorTest.java
deleted file mode 100644
index 8f7ed9c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongCaseDetectorTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class WrongCaseDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new WrongCaseDetector();
- }
-
- public void test() throws Exception {
- assertEquals(""
- + "res/layout/case.xml:18: Warning: Invalid tag <Merge>; should be <merge> [WrongCase]\n"
- + "<Merge xmlns:android=\"http://schemas.android.com/apk/res/android\" >\n"
- + "^\n"
- + "res/layout/case.xml:20: Warning: Invalid tag <Fragment>; should be <fragment> [WrongCase]\n"
- + " <Fragment android:name=\"foo.bar.Fragment\" />\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "res/layout/case.xml:21: Warning: Invalid tag <Include>; should be <include> [WrongCase]\n"
- + " <Include layout=\"@layout/foo\" />\n"
- + " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n"
- + "res/layout/case.xml:22: Warning: Invalid tag <RequestFocus>; should be <requestFocus> [WrongCase]\n"
- + " <RequestFocus />\n"
- + " ~~~~~~~~~~~~~~~~\n"
- + "0 errors, 4 warnings\n",
-
- lintProject("res/layout/case.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongIdDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/WrongIdDetectorTest.java
deleted file mode 100644
index b3fd203..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongIdDetectorTest.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class WrongIdDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new WrongIdDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "res/layout/layout1.xml:14: Error: The id \"button5\" is not defined anywhere. Did you mean one of {button1, button2, button3, button4} ? [UnknownId]\n" +
- " android:layout_alignBottom=\"@+id/button5\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/layout1.xml:17: Error: The id \"my_id3\" is not defined anywhere. Did you mean my_id2 ? [UnknownId]\n" +
- " android:layout_alignRight=\"@+id/my_id3\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/layout1.xml:18: Error: The id \"my_id1\" is defined but not assigned to any views. Did you mean my_id2 ? [UnknownId]\n" +
- " android:layout_alignTop=\"@+id/my_id1\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/layout1.xml:15: Warning: The id \"my_id2\" is not referring to any views in this layout [UnknownIdInLayout]\n" +
- " android:layout_alignLeft=\"@+id/my_id2\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "3 errors, 1 warnings\n" +
- "",
-
- lintProject(
- "wrongid/layout1.xml=>res/layout/layout1.xml",
- "wrongid/layout2.xml=>res/layout/layout2.xml",
- "wrongid/ids.xml=>res/values/ids.xml"
- ));
- }
-
- public void testSingleFile() throws Exception {
- assertEquals(
- "res/layout/layout1.xml:14: Warning: The id \"button5\" is not referring to any views in this layout [UnknownIdInLayout]\n" +
- " android:layout_alignBottom=\"@+id/button5\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/layout1.xml:15: Warning: The id \"my_id2\" is not referring to any views in this layout [UnknownIdInLayout]\n" +
- " android:layout_alignLeft=\"@+id/my_id2\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/layout1.xml:17: Warning: The id \"my_id3\" is not referring to any views in this layout [UnknownIdInLayout]\n" +
- " android:layout_alignRight=\"@+id/my_id3\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "res/layout/layout1.xml:18: Warning: The id \"my_id1\" is not referring to any views in this layout [UnknownIdInLayout]\n" +
- " android:layout_alignTop=\"@+id/my_id1\"\n" +
- " ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 4 warnings\n" +
- "",
-
- lintFiles("wrongid/layout1.xml=>res/layout/layout1.xml"));
- }
-
- public void testSuppressed() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintProject(
- "wrongid/ignorelayout1.xml=>res/layout/layout1.xml",
- "wrongid/layout2.xml=>res/layout/layout2.xml",
- "wrongid/ids.xml=>res/values/ids.xml"
- ));
- }
-
- public void testSuppressedSingleFile() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintFiles("wrongid/ignorelayout1.xml=>res/layout/layout1.xml"));
- }
-
- public void testNewIdPrefix() throws Exception {
- assertEquals(
- "No warnings.",
-
- lintFiles("res/layout/default_item_badges.xml",
- "res/layout/detailed_item.xml"));
- }
-
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongImportDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/WrongImportDetectorTest.java
deleted file mode 100644
index c44f204..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongImportDetectorTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class WrongImportDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new WrongImportDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "src/test/pkg/BadImport.java:5: Warning: Don't include android.R here; use a fully qualified name for each usage instead [SuspiciousImport]\n" +
- "import android.R;\n" +
- "~~~~~~~~~~~~~~~~~\n" +
- "0 errors, 1 warnings\n" +
- "",
-
- lintProject(
- // Java files must be renamed in source tree
- "src/test/pkg/BadImport.java.txt=>src/test/pkg/BadImport.java"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongLocationDetectorTest.java b/lint/cli/src/test/java/com/android/tools/lint/checks/WrongLocationDetectorTest.java
deleted file mode 100644
index f30a604..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/WrongLocationDetectorTest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.checks;
-
-import com.android.tools.lint.detector.api.Detector;
-
-@SuppressWarnings("javadoc")
-public class WrongLocationDetectorTest extends AbstractCheckTest {
- @Override
- protected Detector getDetector() {
- return new WrongLocationDetector();
- }
-
- public void test() throws Exception {
- assertEquals(
- "res/layout/alias.xml:17: Error: This file should be placed in a values/ folder, not a layout/ folder [WrongFolder]\n" +
- "<resources>\n" +
- "^\n" +
- "1 errors, 0 warnings\n",
-
- lintProject("res/values/strings.xml=>res/layout/alias.xml"));
- }
-
- public void testOk() throws Exception {
- assertEquals("No warnings.",
-
- lintProject("res/values/strings.xml"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/AbstractActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/AbstractActivity.java.txt
deleted file mode 100644
index a9e0400..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/AbstractActivity.java.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-
-public abstract class AbstractActivity extends Activity {
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/AndroidManifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/AndroidManifest.xml
deleted file mode 100644
index 75ef31c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/AndroidManifest.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/allowbackup.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/allowbackup.xml
deleted file mode 100644
index 2a95252..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/allowbackup.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:allowBackup="true" >
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/allowbackup_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/allowbackup_ignore.xml
deleted file mode 100644
index 72f8bb4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/allowbackup_ignore.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- tools:ignore="AllowBackup"
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest.class.data
deleted file mode 100644
index 4e2b100..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest.java.txt
deleted file mode 100644
index 456dd8b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest.java.txt
+++ /dev/null
@@ -1,52 +0,0 @@
-package test.pkg;
-
-import org.w3c.dom.DOMError;
-import org.w3c.dom.DOMErrorHandler;
-import org.w3c.dom.DOMLocator;
-
-import android.view.ViewGroup.LayoutParams;
-import android.app.Activity;
-import android.app.ApplicationErrorReport;
-import android.app.ApplicationErrorReport.BatteryInfo;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuff.Mode;
-import android.widget.Chronometer;
-import android.widget.GridLayout;
-import dalvik.bytecode.OpcodeInfo;
-
-public class ApiCallTest extends Activity {
- public void method(Chronometer chronometer, DOMLocator locator) {
- // Virtual call
- getActionBar(); // API 11
-
- // Class references (no call or field access)
- DOMError error = null; // API 8
- Class<?> clz = DOMErrorHandler.class; // API 8
-
- // Method call
- chronometer.getOnChronometerTickListener(); // API 3
-
- // Inherited method call (from TextView
- chronometer.setTextIsSelectable(true); // API 11
-
- // Field access
- int field = OpcodeInfo.MAXIMUM_VALUE; // API 11
- int fillParent = LayoutParams.FILL_PARENT; // API 1
- // This is a final int, which means it gets inlined
- int matchParent = LayoutParams.MATCH_PARENT; // API 8
- // Field access: non final
- BatteryInfo batteryInfo = getReport().batteryInfo;
-
- // Enum access
- Mode mode = PorterDuff.Mode.OVERLAY; // API 11
- }
-
- // Return type
- GridLayout getGridLayout() { // API 14
- return null;
- }
-
- private ApplicationErrorReport getReport() {
- return null;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest10.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest10.class.data
deleted file mode 100644
index 23ef1bd..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest10.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest10.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest10.java.txt
deleted file mode 100644
index ae02a81..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest10.java.txt
+++ /dev/null
@@ -1,45 +0,0 @@
-package test.pkg;
-
-import android.os.Build;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.accessibility.AccessibilityEvent;
-
-public class ApiCallTest10 extends View {
- public ApiCallTest10() {
- super(null, null, 0);
- }
-
- @Override
- public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) {
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
- onPopulateAccessibilityEvent(event); // Shouldn't warn here: method
- // exists locally
- return true;
- }
- return super.dispatchPopulateAccessibilityEvent(event);
- }
-
- @Override
- public void onPopulateAccessibilityEvent(AccessibilityEvent event) {
- super.onPopulateAccessibilityEvent(event); // Valid lint warning
- // Additional override code here:
- }
-
- @Override
- protected boolean dispatchGenericFocusedEvent(MotionEvent event) {
- return super.dispatchGenericFocusedEvent(event); // Should flag this
- }
-
- protected boolean dispatchHoverEvent(int event) {
- return false;
- }
-
- public void test1() {
- // Should flag this, because the local method has the wrong signature
- dispatchHoverEvent(null);
-
- // Shouldn't flag this, local method makes it available
- dispatchGenericFocusedEvent(null);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11$MyActivity.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11$MyActivity.class.data
deleted file mode 100644
index 5368daf..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11$MyActivity.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11$MyLinear.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11$MyLinear.class.data
deleted file mode 100644
index 5ee9e96..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11$MyLinear.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11.class.data
deleted file mode 100644
index 17e10d6..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11.java.txt
deleted file mode 100644
index 8fb592c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest11.java.txt
+++ /dev/null
@@ -1,50 +0,0 @@
-package test.pkg;
-
-import android.annotation.SuppressLint;
-import android.app.ActionBar;
-import android.app.Activity;
-import android.content.Context;
-import android.graphics.drawable.Drawable;
-import android.widget.LinearLayout;
-
-public class ApiCallTest11 extends Activity {
- MyActivity mActionBarHost;
-
- public ActionBar getActionBar() {
- return mActionBarHost.getActionBar();
- }
-
- public boolean isDestroyed() {
- return true;
- }
-
- @SuppressLint("Override")
- public void finishAffinity() {
- }
-
- private class MyLinear extends LinearLayout {
- private Drawable mDividerDrawable;
-
- public MyLinear(Context context) {
- super(context);
- }
-
- /**
- * Javadoc here
- *
- *
- *
- *
- */
- public void setDividerDrawable(Drawable dividerDrawable) {
- mDividerDrawable = dividerDrawable;
- }
- }
-
- private class MyActivity {
- public ActionBar getActionBar() {
- return null;
- }
- }
-}
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest12.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest12.class.data
deleted file mode 100644
index 4056133..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest12.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest12.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest12.java.txt
deleted file mode 100644
index 6ac71db..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest12.java.txt
+++ /dev/null
@@ -1,30 +0,0 @@
-package test.pkg;
-
-import android.annotation.SuppressLint;
-import android.annotation.TargetApi;
-import android.os.Build;
-
-import java.text.DateFormatSymbols;
-import java.text.SimpleDateFormat;
-import java.util.Locale;
-
-@SuppressWarnings({ "unused", "javadoc" })
-@SuppressLint("SimpleDateFormat")
-public class ApiCallTest12 {
- public void test() {
- // Normal SimpleDateFormat calls
- new SimpleDateFormat();
- new SimpleDateFormat("yyyy-MM-dd");
- new SimpleDateFormat("yyyy-MM-dd", DateFormatSymbols.getInstance());
- new SimpleDateFormat("yyyy-MM-dd", Locale.US);
- new SimpleDateFormat("MMMM", Locale.US);
-
- // Flag format strings requiring API 9
- new SimpleDateFormat("yyyy-MM-dd LL", Locale.US);
-
- SimpleDateFormat format = new SimpleDateFormat("cc yyyy-MM-dd");
-
- // Escaped text
- new SimpleDateFormat("MM-dd 'My Location'", Locale.US);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest2.class.data
deleted file mode 100644
index 32c3657..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest2.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest2.java.txt
deleted file mode 100644
index aa6f344..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest2.java.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-package android.support.foo;
-
-import org.w3c.dom.DOMError;
-
-public class Foo {
- private void foo() {
- DOMError error = null; // API 8
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest3.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest3.class.data
deleted file mode 100644
index 3d39e74..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest3.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest3.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest3.java.txt
deleted file mode 100644
index d1ea3e4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest3.java.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-package test.pkg;
-
-/**
- * Call test where the parent class is some other project class which in turn
- * extends the public API
- */
-public class ApiCallTest3 extends Intermediate {
- public void foo() {
- // Virtual call
- getActionBar(); // API 11
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$1.class.data
deleted file mode 100644
index 8d3fbf7..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$1.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass1$InnerInnerClass1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass1$InnerInnerClass1.class.data
deleted file mode 100644
index 940b83d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass1$InnerInnerClass1.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass1.class.data
deleted file mode 100644
index 4da3d3b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass1.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass2.class.data
deleted file mode 100644
index c8e914b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4$InnerClass2.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4.class.data
deleted file mode 100644
index b51d04a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4.java.txt
deleted file mode 100644
index de6be04..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest4.java.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-package test.pkg;
-
-import android.annotation.SuppressLint;
-import android.widget.GridLayout;
-
-@SuppressWarnings("unused")
-public class ApiCallTest4 {
- public void foo() {
- new GridLayout(null, null, 0);
- }
-
- @SuppressLint("NewApi")
- void foo2() {
- // Inner class suppressed via a method in outer class
- new Runnable() {
- @Override
- public void run() {
- new GridLayout(null, null, 0);
- }
- };
- }
-
- @SuppressLint("NewApi")
- private class InnerClass1 {
- void foo() {
- new GridLayout(null, null, 0);
- }
-
- private class InnerInnerClass1 {
- public void foo() {
- new GridLayout(null, null, 0);
- }
- }
- }
-
- private class InnerClass2 {
- public void foo() {
- new GridLayout(null, null, 0);
- }
- }
-} \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.class.data
deleted file mode 100644
index ad0cd48..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.java.txt
deleted file mode 100644
index 4be8258..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest5.java.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-package test.pkg;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.view.View;
-
-public class ApiCallTest5 extends View {
- public ApiCallTest5(Context context) {
- super(context);
- }
-
- @SuppressWarnings("unused")
- @Override
- @TargetApi(2)
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- int measuredWidth = View.resolveSizeAndState(widthMeasureSpec,
- widthMeasureSpec, 0);
- int measuredHeight = resolveSizeAndState(heightMeasureSpec,
- heightMeasureSpec, 0);
- View.combineMeasuredStates(0, 0);
- ApiCallTest5.combineMeasuredStates(0, 0);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest6.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest6.class.data
deleted file mode 100644
index 7c0f3a7..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest6.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest6.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest6.java.txt
deleted file mode 100644
index ae6e5fa..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest6.java.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-package test.pkg;
-
-import java.io.IOException;
-
-public class ApiCallTest6 {
- public void test(Throwable throwable) {
- // IOException(Throwable) requires API 9
- IOException ioException = new IOException(throwable);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest7.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest7.class.data
deleted file mode 100644
index e9f739d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest7.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest7.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest7.java.txt
deleted file mode 100644
index 37ad6a7..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest7.java.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-package test.pkg;
-
-import java.io.IOException;
-
-@SuppressWarnings("serial")
-public class ApiCallTest7 extends IOException {
- public ApiCallTest7(String message, Throwable cause) {
- super(message, cause); // API 9
- }
-
- public void fun() throws IOException {
- super.toString(); throw new IOException((Throwable) null); // API 9
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest8.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest8.class.data
deleted file mode 100644
index b92e7d9..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest8.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest8.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest8.java.txt
deleted file mode 100644
index f742ad1..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest8.java.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-package test.pkg;
-
-import android.text.style.LeadingMarginSpan;
-
-@SuppressWarnings("unused")
-public class ApiCallTest8 {
- public void test() {
- LeadingMarginSpan.LeadingMarginSpan2 span = null;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest9.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest9.class.data
deleted file mode 100644
index f50ebab..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest9.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest9.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest9.java.txt
deleted file mode 100644
index 199231e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiCallTest9.java.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-package test.pkg;
-
-import android.annotation.SuppressLint;
-import android.widget.GridLayout;
-
-/** Test suppress on fields */
-public class ApiCallTest9 {
- // Actual initialization code lives in the synthetic method <init>
- private GridLayout field1 = new GridLayout(null);
-
- // Actual initialization code lives in the synthetic method <clinit>
- private static GridLayout field2 = new GridLayout(null);
-
- @SuppressLint("NewApi")
- private GridLayout field3 = new GridLayout(null);
-
- @SuppressLint("NewApi")
- private static GridLayout field4 = new GridLayout(null);
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck.class.data
deleted file mode 100644
index 726b8a5..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck.java.txt
deleted file mode 100644
index 429b388..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck.java.txt
+++ /dev/null
@@ -1,123 +0,0 @@
-package test.pkg;
-
-import android.util.Property;
-import android.view.View;
-import static android.view.View.MEASURED_STATE_MASK;
-import static android.os.Build.VERSION_CODES.JELLY_BEAN_MR1;
-import android.view.*;
-import android.annotation.*;
-import android.app.*;
-import android.widget.*;
-import static android.widget.ZoomControls.*;
-import android.Manifest.permission;
-import android.Manifest;
-
-/** Various tests for source-level checks */
-final class ApiSourceCheck extends LinearLayout {
- public ApiSourceCheck(android.content.Context context) {
- super(context);
- }
-
- /**
- * Return only the state bits of {@link #getMeasuredWidthAndState()} and
- * {@link #getMeasuredHeightAndState()}, combined into one integer. The
- * width component is in the regular bits {@link #MEASURED_STATE_MASK} and
- * the height component is at the shifted bits
- * {@link #MEASURED_HEIGHT_STATE_SHIFT}>>{@link #MEASURED_STATE_MASK}.
- */
- public static int m1(View child) {
- // from static import of field
- int x = MEASURED_STATE_MASK;
-
- // fully qualified name field access
- int y = android.view.View.MEASURED_STATE_MASK;
-
- // from explicitly imported class
- int z = View.MEASURED_STATE_MASK;
- int find2 = View.FIND_VIEWS_WITH_TEXT; // requires API 14
-
- // from wildcard import of package
- int w = ActivityManager.MOVE_TASK_NO_USER_ACTION;
- int find1 = ZoomButton.FIND_VIEWS_WITH_CONTENT_DESCRIPTION; // requires
- // API 14
- // from static wildcard import
- int overScroll = OVER_SCROLL_ALWAYS; // requires API 9
-
- // Inherited field from ancestor class (View)
- int auto = IMPORTANT_FOR_ACCESSIBILITY_AUTO; // requires API 16
-
- // object field reference: ensure that we don't get two errors
- // (one from source scan, the other from class scan)
- Object rotationX = ZoomButton.ROTATION_X; // Requires API 14
-
- // different type of expression than variable declaration
- return (child.getMeasuredWidth() & View.MEASURED_STATE_MASK)
- | ((child.getMeasuredHeight() >> View.MEASURED_HEIGHT_STATE_SHIFT) & (View.MEASURED_STATE_MASK >> View.MEASURED_HEIGHT_STATE_SHIFT));
- }
-
- @SuppressLint("NewApi")
- private void testSuppress1() {
- // Checks suppress on surrounding method
- int w = ActivityManager.MOVE_TASK_NO_USER_ACTION;
- }
-
- private void testSuppress2() {
- // Checks suppress on surrounding declaration statement
- @SuppressLint("NewApi")
- int w, z = ActivityManager.MOVE_TASK_NO_USER_ACTION;
- }
-
- @TargetApi(17)
- private void testTargetApi1() {
- // Checks @TargetApi on surrounding method
- int w, z = ActivityManager.MOVE_TASK_NO_USER_ACTION;
- }
-
- @TargetApi(android.os.Build.VERSION_CODES.JELLY_BEAN_MR1)
- private void testTargetApi2() {
- // Checks @TargetApi with codename
- int w, z = ActivityManager.MOVE_TASK_NO_USER_ACTION;
- }
-
- @TargetApi(JELLY_BEAN_MR1)
- private void testTargetApi3() {
- // Checks @TargetApi with codename
- int w, z = ActivityManager.MOVE_TASK_NO_USER_ACTION;
- }
-
- private void checkOtherFields() {
- // Look at fields that aren't capitalized
- int custom = android.R.id.custom; // API 8
- }
-
- private void innerclass() {
- String setPointerSpeed = permission.SET_POINTER_SPEED;
- String setPointerSpeed2 = Manifest.permission.SET_POINTER_SPEED;
- }
-
- private void test() {
- // Make sure that local variable references which look like fields,
- // even imported ones, aren't taken as invalid references
- int OVER_SCROLL_ALWAYS = 1, IMPORTANT_FOR_ACCESSIBILITY_AUTO = 2;
- int x = OVER_SCROLL_ALWAYS;
- int y = IMPORTANT_FOR_ACCESSIBILITY_AUTO;
- findViewById(IMPORTANT_FOR_ACCESSIBILITY_AUTO); // yes, nonsensical
- }
-
- private void testBenignUsages(int x) {
- // Certain types of usages (such as switch/case constants) are okay
- switch (x) {
- case View.MEASURED_STATE_MASK: { // OK
- break;
- }
- }
- if (x == View.MEASURED_STATE_MASK) { // OK
- }
- if (false || x == View.MEASURED_STATE_MASK) { // OK
- }
- if (x >= View.MEASURED_STATE_MASK) { // OK
- }
- int y = View.MEASURED_STATE_MASK; // Not OK
- testBenignUsages(View.MEASURED_STATE_MASK); // Not OK
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck2.class.data
deleted file mode 100644
index a37d62c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck2.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck2.java.txt
deleted file mode 100644
index adce4f0..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiSourceCheck2.java.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-package test.pkg;
-
-import android.widget.AbsListView;
-import android.widget.ListView;
-
-@SuppressWarnings("unused")
-public class ApiSourceCheck2 {
- public void test() {
- int mode1 = AbsListView.CHOICE_MODE_MULTIPLE;
- int mode2 = AbsListView.CHOICE_MODE_MULTIPLE_MODAL;
- int mode3 = AbsListView.CHOICE_MODE_NONE;
- int mode4 = AbsListView.CHOICE_MODE_SINGLE;
- int mode5 = ListView.CHOICE_MODE_MULTIPLE;
- int mode6 = ListView.CHOICE_MODE_MULTIPLE_MODAL;
- int mode7 = ListView.CHOICE_MODE_NONE;
- int mode8 = ListView.CHOICE_MODE_SINGLE;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest$LocalClass.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest$LocalClass.class.data
deleted file mode 100644
index 136eed5..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest$LocalClass.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest.class.data
deleted file mode 100644
index 7dc3d60..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest.java.txt
deleted file mode 100644
index 8626858..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest.java.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-package test.pkg;
-
-import org.w3c.dom.DOMErrorHandler;
-
-import android.annotation.TargetApi;
-
-// Test using the @TargetApi annotation to temporarily override
-// the required API levels
-@SuppressWarnings("unused")
-public class ApiTargetTest {
- public void test1() {
- // No annotation: should generate warning if manifest SDK < 8
- Class<?> clz = DOMErrorHandler.class; // API 8
- }
-
- // Temporarily setting method min sdk to 12
- @TargetApi(12)
- public void test2() {
- Class<?> clz = DOMErrorHandler.class; // API 8
- }
-
- // Temporarily setting method min sdk to 14
- @TargetApi(4)
- public void test3() {
- Class<?> clz = DOMErrorHandler.class; // API 8
- }
-
- // Temporarily setting class min sdk to 12
- @TargetApi(value=11)
- public static class LocalClass {
- public void test4() {
- Class<?> clz = DOMErrorHandler.class; // API 8
- }
-
- // Overriding class min sdk: this should generate
- // an API warning again
- @TargetApi(7)
- public void test5() {
- Class<?> clz = DOMErrorHandler.class; // API 8
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1$1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1$1.class.data
deleted file mode 100644
index f18f226..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1$1.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1$2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1$2.class.data
deleted file mode 100644
index ac3863e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1$2.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1.class.data
deleted file mode 100644
index f51c54b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2$1.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2.class.data
deleted file mode 100644
index defae98..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2.java.txt
deleted file mode 100644
index 7574805..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/ApiTargetTest2.java.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-package test.pkg;
-
-import android.annotation.TargetApi;
-import android.widget.GridLayout;
-
-// Test using the @TargetApi annotation on inner classes and anonymous inner classes
-@SuppressWarnings("unused")
-public class ApiTargetTest2 {
- @TargetApi(value=14)
- void foo2() {
- new Runnable() {
- @Override
- public void run() {
- new GridLayout(null, null, 0);
- }
-
- void foo3() {
- new Runnable() {
- @Override
- public void run() {
- new GridLayout(null, null, 0);
- }
- };
- }
-
- @TargetApi(value=3)
- void foo4() {
- new Runnable() {
- @Override
- public void run() {
- // This should be marked as an error since the effective target API is 3 here
- new GridLayout(null, null, 0);
- }
- };
- }
-
- };
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/CloseTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/CloseTest.class.data
deleted file mode 100644
index acb19e5..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/CloseTest.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/CloseTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/CloseTest.java.txt
deleted file mode 100644
index dc3e538..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/CloseTest.java.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-package test.pkg;
-
-import android.database.sqlite.SQLiteStatement;
-
-public class CloseTest {
- public void close(SQLiteStatement statement) {
- statement.close();
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate$IntermediateCustomV.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate$IntermediateCustomV.class.data
deleted file mode 100644
index cbf323c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate$IntermediateCustomV.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate.class.data
deleted file mode 100644
index 8d187da..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate.java.txt
deleted file mode 100644
index fea5c4f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/Intermediate.java.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.widget.Button;
-
-/** Local activity */
-public abstract class Intermediate extends Activity {
-
- /** Local Custom view */
- public abstract static class IntermediateCustomV extends Button {
- public IntermediateCustomV() {
- super(null);
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/MyActivityImpl.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/MyActivityImpl.class.data
deleted file mode 100644
index 6ae6b28..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/MyActivityImpl.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/MyActivityImpl.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/MyActivityImpl.java.txt
deleted file mode 100644
index e39daf8..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/MyActivityImpl.java.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.support.v4.app.FragmentActivity;
-
-public class MyActivityImpl extends FragmentActivity {
- public void test() {
- boolean isChanging = super.isChangingConfigurations();
- }
-
- @Override
- public boolean isChangingConfigurations() {
- return super.isChangingConfigurations();
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest1.class.data
deleted file mode 100644
index 60d4e81..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest1.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest1.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest1.java.txt
deleted file mode 100644
index a8775d7..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest1.java.txt
+++ /dev/null
@@ -1,137 +0,0 @@
-package test.pkg;
-
-import org.w3c.dom.DOMError;
-import org.w3c.dom.DOMErrorHandler;
-import org.w3c.dom.DOMLocator;
-
-import android.view.ViewGroup.LayoutParams;
-import android.annotations.tools.SuppressLint;
-import android.app.Activity;
-import android.app.ApplicationErrorReport;
-import android.app.ApplicationErrorReport.BatteryInfo;
-import android.graphics.PorterDuff;
-import android.graphics.PorterDuff.Mode;
-import android.widget.Chronometer;
-import android.widget.GridLayout;
-import dalvik.bytecode.OpcodeInfo;
-
-public class SuppressTest1 extends Activity {
- @SuppressLint("all")
- public void method1(Chronometer chronometer, DOMLocator locator) {
- // Virtual call
- getActionBar(); // API 11
-
- // Class references (no call or field access)
- DOMError error = null; // API 8
- Class<?> clz = DOMErrorHandler.class; // API 8
-
- // Method call
- chronometer.getOnChronometerTickListener(); // API 3
-
- // Inherited method call (from TextView
- chronometer.setTextIsSelectable(true); // API 11
-
- // Field access
- int field = OpcodeInfo.MAXIMUM_VALUE; // API 11
- int fillParent = LayoutParams.FILL_PARENT; // API 1
- // This is a final int, which means it gets inlined
- int matchParent = LayoutParams.MATCH_PARENT; // API 8
- // Field access: non final
- BatteryInfo batteryInfo = getReport().batteryInfo;
-
- // Enum access
- Mode mode = PorterDuff.Mode.OVERLAY; // API 11
- }
-
- @SuppressLint("NewApi")
- public void method2(Chronometer chronometer, DOMLocator locator) {
- // Virtual call
- getActionBar(); // API 11
-
- // Class references (no call or field access)
- DOMError error = null; // API 8
- Class<?> clz = DOMErrorHandler.class; // API 8
-
- // Method call
- chronometer.getOnChronometerTickListener(); // API 3
-
- // Inherited method call (from TextView
- chronometer.setTextIsSelectable(true); // API 11
-
- // Field access
- int field = OpcodeInfo.MAXIMUM_VALUE; // API 11
- int fillParent = LayoutParams.FILL_PARENT; // API 1
- // This is a final int, which means it gets inlined
- int matchParent = LayoutParams.MATCH_PARENT; // API 8
- // Field access: non final
- BatteryInfo batteryInfo = getReport().batteryInfo;
-
- // Enum access
- Mode mode = PorterDuff.Mode.OVERLAY; // API 11
- }
-
- @SuppressLint("SomethingElse")
- public void method3(Chronometer chronometer, DOMLocator locator) {
- // Virtual call
- getActionBar(); // API 11
-
- // Class references (no call or field access)
- DOMError error = null; // API 8
- Class<?> clz = DOMErrorHandler.class; // API 8
-
- // Method call
- chronometer.getOnChronometerTickListener(); // API 3
-
- // Inherited method call (from TextView
- chronometer.setTextIsSelectable(true); // API 11
-
- // Field access
- int field = OpcodeInfo.MAXIMUM_VALUE; // API 11
- int fillParent = LayoutParams.FILL_PARENT; // API 1
- // This is a final int, which means it gets inlined
- int matchParent = LayoutParams.MATCH_PARENT; // API 8
- // Field access: non final
- BatteryInfo batteryInfo = getReport().batteryInfo;
-
- // Enum access
- Mode mode = PorterDuff.Mode.OVERLAY; // API 11
- }
-
- @SuppressLint({"SomethingElse", "NewApi"})
- public void method4(Chronometer chronometer, DOMLocator locator) {
- // Virtual call
- getActionBar(); // API 11
-
- // Class references (no call or field access)
- DOMError error = null; // API 8
- Class<?> clz = DOMErrorHandler.class; // API 8
-
- // Method call
- chronometer.getOnChronometerTickListener(); // API 3
-
- // Inherited method call (from TextView
- chronometer.setTextIsSelectable(true); // API 11
-
- // Field access
- int field = OpcodeInfo.MAXIMUM_VALUE; // API 11
- int fillParent = LayoutParams.FILL_PARENT; // API 1
- // This is a final int, which means it gets inlined
- int matchParent = LayoutParams.MATCH_PARENT; // API 8
- // Field access: non final
- BatteryInfo batteryInfo = getReport().batteryInfo;
-
- // Enum access
- Mode mode = PorterDuff.Mode.OVERLAY; // API 11
- }
-
- // Return type
- @SuppressLint("NewApi")
- GridLayout getGridLayout() { // API 14
- return null;
- }
-
- @SuppressLint("all")
- private ApplicationErrorReport getReport() {
- return null;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest2.class.data
deleted file mode 100644
index fdb512b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest2.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest2.java.txt
deleted file mode 100644
index e325413..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest2.java.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-package test.pkg;
-
-import org.w3c.dom.DOMLocator;
-
-import android.annotations.tools.SuppressLint;
-import android.app.Activity;
-import android.app.ApplicationErrorReport;
-import android.widget.Chronometer;
-import android.widget.GridLayout;
-
-@SuppressLint("all")
-public class SuppressTest2 extends Activity {
- public void method(Chronometer chronometer, DOMLocator locator) {
- getActionBar(); // API 11
- }
-
- // Return type
- GridLayout getGridLayout() { // API 14
- return null;
- }
-
- private ApplicationErrorReport getReport() {
- return null;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest3.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest3.class.data
deleted file mode 100644
index 23e8b5c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest3.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest3.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest3.java.txt
deleted file mode 100644
index c430ce4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest3.java.txt
+++ /dev/null
@@ -1,25 +0,0 @@
-package test.pkg;
-
-import org.w3c.dom.DOMLocator;
-
-import android.annotations.tools.SuppressLint;
-import android.app.Activity;
-import android.app.ApplicationErrorReport;
-import android.widget.Chronometer;
-import android.widget.GridLayout;
-
-@SuppressLint("NewApi")
-public class SuppressTest3 extends Activity {
- public void method(Chronometer chronometer, DOMLocator locator) {
- getActionBar(); // API 11
- }
-
- // Return type
- GridLayout getGridLayout() { // API 14
- return null;
- }
-
- private ApplicationErrorReport getReport() {
- return null;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest4.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest4.class.data
deleted file mode 100644
index c85a4ff..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest4.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest4.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest4.java.txt
deleted file mode 100644
index 2fa2af8..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/SuppressTest4.java.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-package test.pkg;
-
-import android.annotations.tools.SuppressLint;
-import android.app.Activity;
-import android.app.ApplicationErrorReport;
-import android.app.ApplicationErrorReport.BatteryInfo;
-
-public class SuppressTest4 extends Activity {
- public void method() {
-
- // These annotations within the method do not end up
- // in the bytecode, so they have no effect. We need a
- // lint annotation check to find these.
-
- @SuppressLint("NewApi")
- ApplicationErrorReport report = null;
-
- @SuppressLint("NewApi")
- BatteryInfo batteryInfo = report.batteryInfo;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestEnum.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestEnum.class.data
deleted file mode 100644
index fa676b9..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestEnum.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestEnum.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestEnum.java.txt
deleted file mode 100644
index 2d68b28..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestEnum.java.txt
+++ /dev/null
@@ -1,67 +0,0 @@
-package test.pkg;
-
-import android.annotation.SuppressLint;
-import android.graphics.Bitmap.CompressFormat;
-import android.graphics.PorterDuff;
-
-@SuppressWarnings("incomplete-switch")
-public class TestEnum {
- public static void test1(final CompressFormat format) {
- switch (format) {
- case JPEG: {
- System.out.println("jpeg");
- break;
- }
- default: {
- System.out.println("Default");
- }
- }
- }
-
- public static void test2(final PorterDuff.Mode mode) {
- switch (mode) {
- case CLEAR: {
- System.out.println("clear");
- }
- case OVERLAY: {
- System.out.println("add");
- break;
- }
- }
-
- // Second usage: should also complain here
- switch (mode) {
- case CLEAR: {
- System.out.println("clear");
- }
- case OVERLAY: {
- System.out.println("add");
- break;
- }
- }
- }
-
- @SuppressLint("NewApi")
- public static void test3(PorterDuff.Mode mode) {
- // Third usage: no complaint because it's suppressed
- switch (mode) {
- case CLEAR: {
- System.out.println("clear");
- }
- case OVERLAY: {
- System.out.println("add");
- break;
- }
- }
- }
-
- public static void test4(final android.renderscript.Element.DataType type) {
- // Switch usage where the whole underlying enum requires a higher API level:
- // test customized error message
- switch (type) {
- case RS_FONT: {
- System.out.println("font");
- }
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestLint.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestLint.class.data
deleted file mode 100644
index 9e74a7a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/TestLint.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/android-support-v4.jar.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/android-support-v4.jar.data
deleted file mode 100644
index 6080877..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/android-support-v4.jar.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/classpath b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/classpath
deleted file mode 100644
index a4763d1..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/colors.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/colors.xml
deleted file mode 100644
index fc84a61..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/colors.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <color name="color1">@android:color/black</color>
- <!-- Requires API 14 -->
- <color name="color2">@android:color/holo_blue_bright</color>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/divider.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/divider.xml
deleted file mode 100644
index 4244319..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/divider.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_marginLeft="16dp"
- android:layout_marginRight="16dp"
- android:divider="?android:dividerHorizontal"
- android:orientation="horizontal"
- android:showDividers="middle"
- tools:context=".ItemListActivity" >
-
- <!--
- This layout is a two-pane layout for the Items
- master/detail flow. See res/values-large/refs.xml and
- res/values-sw600dp/refs.xml for an example of layout aliases
- that replace the single-pane version of the layout with
- this two-pane version.
-
- For more on layout aliases, see:
- http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters
- -->
-
- <fragment
- android:id="@+id/item_list"
- android:name="com.example.master.ItemListFragment"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- tools:layout="@android:layout/list_content" />
-
- <FrameLayout
- android:id="@+id/item_detail_container"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="3" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/holomanifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/holomanifest.xml
deleted file mode 100644
index 8890afc..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/holomanifest.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.bytecode"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="4" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".BytecodeTestsActivity"
- android:label="@string/app_name"
- android:theme="@android:style/Theme.Holo" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/layout.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/layout.xml
deleted file mode 100644
index 83b6b0a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/layout.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <!-- Requires API 5 -->
-
- <QuickContactBadge
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <!-- Requires API 11 -->
-
- <CalendarView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent" />
-
- <!-- Requires API 14 -->
-
- <GridLayout
- foo="@android:attr/actionBarSplitStyle"
- bar="@android:color/holo_red_light"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent" >
-
- <Button
- android:layout_width="fill_parent"
- android:layout_height="fill_parent" />
- </GridLayout>
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/layout_targetapi.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/layout_targetapi.xml
deleted file mode 100644
index 51ce945..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/layout_targetapi.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="fill_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- tools:targetApi="11" >
-
- <!-- Requires API 5 -->
-
- <QuickContactBadge
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <!-- Requires API 11 -->
-
- <CalendarView
- android:layout_width="fill_parent"
- android:layout_height="fill_parent" />
-
- <!-- Requires API 14 -->
-
- <GridLayout
- foo="@android:attr/actionBarSplitStyle"
- bar="@android:color/holo_red_light"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- tools:targetApi="ICE_CREAM_SANDWICH" >
-
- <Button
- android:layout_width="fill_parent"
- android:layout_height="fill_parent" />
- </GridLayout>
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk1.xml
deleted file mode 100644
index 6a9c919..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk1.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.bytecode"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="1" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".BytecodeTestsActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk10.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk10.xml
deleted file mode 100644
index 2896fc8..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk10.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.bytecode"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="10" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".BytecodeTestsActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk14.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk14.xml
deleted file mode 100644
index 391a8aa..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk14.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.bytecode"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".BytecodeTestsActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk17.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk17.xml
deleted file mode 100644
index 1837db9..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk17.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.bytecode"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="17" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".BytecodeTestsActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk2.xml
deleted file mode 100644
index 23a15be..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk2.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.bytecode"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="2" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".BytecodeTestsActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk4.xml
deleted file mode 100644
index be95440..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/minsdk4.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.bytecode"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="4" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".BytecodeTestsActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/themes.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/themes.xml
deleted file mode 100644
index 478940e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/themes.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <style name="Theme" parent="android:Theme"/>
-
- <style name="Theme.Test" parent="android:style/Theme.Light">
- <item name="android:windowNoTitle">true</item>
- <item name="android:windowContentOverlay">@null</item>
- <!-- Requires API 14 -->
- <item name="android:windowBackground"> @android:color/holo_red_light </item>
- </style>
-
- <style name="Theme.Test.Transparent">
- <item name="android:windowBackground">@android:color/transparent</item>
- </style>
-
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/unsupported.jar.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/unsupported.jar.data
deleted file mode 100644
index 7cbedc1..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/unsupported.jar.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/view.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/view.xml
deleted file mode 100644
index 2f9fc84..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/apicheck/view.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <!-- Requires API 5 -->
-
- <view
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- class="QuickContactBadge" />
-
- <!-- Requires API 11 -->
-
- <view
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- class="CalendarView" />
-
- <Button
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- unknown="?android:attr/dividerHorizontal"
- android:textColor="?android:attr/textColorLinkInverse" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/broken-manifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/broken-manifest.xml
deleted file mode 100644
index e55e908..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/broken-manifest.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.helloworld"
- android:versionCode="1"
- android:versionName="1.0">
- <application android:icon="@drawable/icon" android:label="@string/app_name">
- <activity android:name=".HelloWorld"
- android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
- </application>
- <uses-sdk android:minSdkVersion="Froyo" />
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/broken-manifest2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/broken-manifest2.xml
deleted file mode 100644
index 307046b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/broken-manifest2.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.helloworld"
- android:versionCode="1"
- android:versionName="1.0">
- <application android:icon="@drawable/icon" android:label="@string/app_name">
- <!-- Wrong declaration locations -->
- <uses-sdk android:minSdkVersion="Froyo" />
- <uses-permission />
- <permission />
- <permission-tree />
- <permission-group />
- <instrumentation />
- <uses-sdk />
- <uses-configuration />
- <uses-feature />
- <supports-screens />
- <compatible-screens />
- <supports-gl-texture />
-
- </application>
-
- <!-- Wrong declaration locations -->
- <uses-library />
- <activity android:name=".HelloWorld"
- android:label="@string/app_name" />
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/.classpath b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/.classpath
deleted file mode 100644
index a4763d1..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractActivity.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractActivity.class.data
deleted file mode 100644
index 85ebb78..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractActivity.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractActivity.java.txt
deleted file mode 100644
index a9e0400..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractActivity.java.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-
-public abstract class AbstractActivity extends Activity {
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.class.data
deleted file mode 100644
index 8dc3dc6..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.java.txt
deleted file mode 100644
index aedbafd..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AbstractCustomView.java.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-package test.pkg;
-
-import android.view.View;
-
-public abstract class AbstractCustomView extends View {
- public AbstractCustomView() {
- super(null);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifest.xml
deleted file mode 100644
index 2896fc8..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifest.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.bytecode"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="10" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".BytecodeTestsActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestReg.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestReg.xml
deleted file mode 100644
index 82fda69..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestReg.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.pkg.Foo"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="15" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name="CommentsActivity"
- android:label="@string/app_name" >
- </activity>
- </application>
-
-</manifest> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestRegs.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestRegs.xml
deleted file mode 100644
index e52f73c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestRegs.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2012 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.pkg"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="10" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <provider android:name=".TestProvider" />
- <provider android:name="test.pkg.TestProvider2" />
- <service android:name=".TestService" />
- <activity android:name="OnClickActivity" />
- <receiver android:name="TestReceiver" />
-
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestWrongRegs.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestWrongRegs.xml
deleted file mode 100644
index efe7213..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/AndroidManifestWrongRegs.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.pkg"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="10" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <!-- These registrations are bogus (wrong type) -->
- <activity android:name=".TestProvider" />
- <service android:name="test.pkg.TestProvider2" />
- <provider android:name=".TestService" />
- <receiver android:name="OnClickActivity" />
- <service android:name="TestReceiver" />
-
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class1$Class4.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class1$Class4.class.data
deleted file mode 100644
index bfd88db..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class1$Class4.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class1.class.data
deleted file mode 100644
index cee3058..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class1.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class2$Class3.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class2$Class3.class.data
deleted file mode 100644
index 2a58332..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class2$Class3.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class2.class.data
deleted file mode 100644
index 1b72f03..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/Class2.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommentsActivity.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommentsActivity.class.data
deleted file mode 100644
index 7f9f23b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommentsActivity.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommentsActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommentsActivity.java.txt
deleted file mode 100644
index 941a01d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommentsActivity.java.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-package test.pkg.Foo;
-
-import android.app.Activity;
-
-public class CommentsActivity extends Activity {
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommitTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommitTest.class.data
deleted file mode 100644
index 842fb21..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommitTest.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommitTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommitTest.java.txt
deleted file mode 100644
index 24edaf3..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CommitTest.java.txt
+++ /dev/null
@@ -1,91 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.app.Fragment;
-import android.app.FragmentManager;
-import android.app.FragmentTransaction;
-
-@SuppressWarnings("unused")
-public class CommitTest extends Activity {
- public void ok1() {
- getFragmentManager().beginTransaction().commit();
- }
-
- public void ok2() {
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
- transaction.commit();
- }
-
- public void ok3() {
- FragmentTransaction transaction = getFragmentManager().beginTransaction();
- transaction.commitAllowingStateLoss();
- }
-
- public void error1() {
- getFragmentManager().beginTransaction(); // Missing commit
- }
-
- public void error() {
- FragmentTransaction transaction1 = getFragmentManager().beginTransaction();
- FragmentTransaction transaction2 = getFragmentManager().beginTransaction(); // Missing commit
- transaction1.commit();
- }
-
- public void error3_public() {
- error3();
- }
-
- private void error3() {
- getFragmentManager().beginTransaction(); // Missing commit
- }
-
- public void ok4(FragmentManager manager, String tag) {
- FragmentTransaction ft = manager.beginTransaction();
- ft.add(null, tag);
- ft.commit();
- }
-
- // Support library
-
- private android.support.v4.app.FragmentManager getSupportFragmentManager() {
- return null;
- }
-
- public void ok5() {
- getSupportFragmentManager().beginTransaction().commit();
- }
-
- public void ok6(android.support.v4.app.FragmentManager manager, String tag) {
- android.support.v4.app.FragmentTransaction ft = manager.beginTransaction();
- ft.add(null, tag);
- ft.commit();
- }
-
- public void error4() {
- getSupportFragmentManager().beginTransaction();
- }
-
- android.support.v4.app.Fragment mFragment1 = null;
- Fragment mFragment2 = null;
-
- public void ok7() {
- getSupportFragmentManager().beginTransaction().add(android.R.id.content, mFragment1).commit();
- }
-
- public void ok8() {
- getFragmentManager().beginTransaction().add(android.R.id.content, mFragment2).commit();
- }
-
- public void ok10() {
- // Test chaining
- FragmentManager fragmentManager = getFragmentManager();
- fragmentManager.beginTransaction().addToBackStack("test").attach(mFragment2).detach(mFragment2)
- .disallowAddToBackStack().hide(mFragment2).setBreadCrumbShortTitle("test")
- .show(mFragment2).setCustomAnimations(0, 0).commit();
- }
-
- public void ok9() {
- FragmentManager fragmentManager = getFragmentManager();
- fragmentManager.beginTransaction().commit();
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView1.class.data
deleted file mode 100644
index d6a8ad7..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView1.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView1.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView1.java.txt
deleted file mode 100644
index e871e74..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView1.java.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-package test.pkg;
-
-import android.view.View;
-
-public class CustomView1 extends View {
- public CustomView1() {
- super(null);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView2.class.data
deleted file mode 100644
index 0788ef3..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView2.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView2.java.txt
deleted file mode 100644
index dccc8ec..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView2.java.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-package test.pkg;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.Button;
-
-public class CustomView2 extends Button {
- public CustomView2(boolean foo,
- Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView3.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView3.class.data
deleted file mode 100644
index a4b7c7d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView3.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView3.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView3.java.txt
deleted file mode 100644
index 86d983f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomView3.java.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-package test.pkg;
-
-import android.content.Context;
-import android.util.AttributeSet;
-import android.widget.TextView;
-
-public class CustomView3 extends TextView {
-
- public CustomView3(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- public CustomView3(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public CustomView3(Context context) {
- super(context);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomViewTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomViewTest.class.data
deleted file mode 100644
index e145fbc..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/CustomViewTest.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/DialogFragment.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/DialogFragment.class.data
deleted file mode 100644
index f57a263..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/DialogFragment.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment1.class.data
deleted file mode 100644
index 11a98dd..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment1.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment2.class.data
deleted file mode 100644
index d77579a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment2.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment3.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment3.class.data
deleted file mode 100644
index b1ec17d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment3.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment4.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment4.class.data
deleted file mode 100644
index f89f8ed..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment4.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment5.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment5.class.data
deleted file mode 100644
index 4a23e03..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment5.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment6.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment6.class.data
deleted file mode 100644
index 2e10e12..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$Fragment6.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$NotAFragment.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$NotAFragment.class.data
deleted file mode 100644
index 8f5b827..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$NotAFragment.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$ValidFragment1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$ValidFragment1.class.data
deleted file mode 100644
index a3354a7..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest$ValidFragment1.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest.class.data
deleted file mode 100644
index 6cc8387..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest.java.txt
deleted file mode 100644
index d27c04a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/FragmentTest.java.txt
+++ /dev/null
@@ -1,55 +0,0 @@
-package test.pkg;
-
-import android.annotation.SuppressLint;
-import android.app.Fragment;
-
-@SuppressWarnings("unused")
-public class FragmentTest {
-
- // Should be public
- private static class Fragment1 extends Fragment {
-
- }
-
- // Should be static
- public class Fragment2 extends Fragment {
-
- }
-
- // Should have a public constructor
- public static class Fragment3 extends Fragment {
- private Fragment3() {
- }
- }
-
- // Should have a public constructor with no arguments
- public static class Fragment4 extends Fragment {
- private Fragment4(int dummy) {
- }
- }
-
- // Should *only* have the default constructor, not the
- // multi-argument one
- public static class Fragment5 extends Fragment {
- public Fragment5() {
- }
- public Fragment5(int dummy) {
- }
- }
-
- // Suppressed
- @SuppressLint("ValidFragment")
- public static class Fragment6 extends Fragment {
- private Fragment6() {
- }
- }
-
- public static class ValidFragment1 extends Fragment {
- public ValidFragment1() {
- }
- }
-
- // (Not a fragment)
- private class NotAFragment {
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.class.data
deleted file mode 100644
index 73a9947..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.jar.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.jar.data
deleted file mode 100644
index f5ef6d1..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.jar.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.java.txt
deleted file mode 100644
index 25f3421..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/GetterTest.java.txt
+++ /dev/null
@@ -1,59 +0,0 @@
-package test.bytecode;
-
-public class GetterTest {
- private int mFoo1;
- private String mFoo2;
- private int mBar1;
- private static int sFoo4;
-
- public int getFoo1() {
- return mFoo1;
- }
-
- public String getFoo2() {
- return mFoo2;
- }
-
- public int isBar1() {
- return mBar1;
- }
-
- // Not "plain" getters:
-
- public String getFoo3() {
- // NOT a plain getter
- if (mFoo2 == null) {
- mFoo2 = "";
- }
- return mFoo2;
- }
-
- public int getFoo4() {
- // NOT a plain getter (using static)
- return sFoo4;
- }
-
- public int getFoo5(int x) {
- // NOT a plain getter (has extra argument)
- return sFoo4;
- }
-
- public int isBar2(String s) {
- // NOT a plain getter (has extra argument)
- return mFoo1;
- }
-
- public void test() {
- getFoo1();
- getFoo2();
- getFoo3();
- getFoo4();
- getFoo5(42);
- isBar1();
- isBar2("foo");
- this.getFoo1();
- this.getFoo2();
- this.getFoo3();
- this.getFoo4();
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$1.class.data
deleted file mode 100644
index ae65532..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$1.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$Inner.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$Inner.class.data
deleted file mode 100644
index 3975896..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$Inner.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$StaticInner.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$StaticInner.class.data
deleted file mode 100644
index 690ee89..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest$StaticInner.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest.class.data
deleted file mode 100644
index 93f9999..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest.java.txt
deleted file mode 100644
index 7622c98..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/HandlerTest.java.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-package test.pkg;
-
-import android.os.Handler;
-import android.os.Message;
-
-public class HandlerTest extends Handler { // OK
- public static class StaticInner extends Handler { // OK
- public void dispatchMessage(Message msg) {
- super.dispatchMessage(msg);
- };
- }
- public class Inner extends Handler { // ERROR
- public void dispatchMessage(Message msg) {
- super.dispatchMessage(msg);
- };
- }
- void method() {
- Handler anonymous = new Handler() { // ERROR
- public void dispatchMessage(Message msg) {
- super.dispatchMessage(msg);
- };
- };
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LayoutTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LayoutTest.class.data
deleted file mode 100644
index 27e6042..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LayoutTest.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LayoutTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LayoutTest.java.txt
deleted file mode 100644
index 28ab089..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LayoutTest.java.txt
+++ /dev/null
@@ -1,66 +0,0 @@
-package test.pkg;
-
-import android.content.Context;
-import android.graphics.Canvas;
-import android.util.AttributeSet;
-import android.view.ViewGroup;
-import android.widget.Button;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-
-@SuppressWarnings("unused")
-public class LayoutTest extends LinearLayout {
- private MyChild child;
-
- public LayoutTest(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right,
- int bottom) {
- super.onLayout(changed, left, top, right, bottom); // OK
- child.onLayout(changed, left, top, right, bottom); // Not OK
-
- super.onMeasure(0, 0); // Not OK
- super.onDraw(null); // Not OK
- child.layout(left, top, right, bottom); // OK
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec); // OK
- super.onLayout(false, 0, 0, 0, 0); // Not OK
- child.onMeasure(widthMeasureSpec, heightMeasureSpec); // Not OK
- child.measure(widthMeasureSpec, heightMeasureSpec); // OK
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas); // OK
- child.onDraw(canvas); // Not OK
- child.draw(canvas); // OK
- }
-
- private class MyChild extends FrameLayout {
- public MyChild(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right,
- int bottom) {
- super.onLayout(changed, left, top, right, bottom);
- }
-
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- super.onMeasure(widthMeasureSpec, heightMeasureSpec);
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LocaleTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LocaleTest.class.data
deleted file mode 100644
index 2b10aa9..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LocaleTest.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LocaleTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LocaleTest.java.txt
deleted file mode 100644
index 3c60c9d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/LocaleTest.java.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-package test.pkg;
-
-import java.text.*;
-import java.util.*;
-
-public class LocaleTest {
- public void testStrings() {
- System.out.println("OK".toUpperCase(Locale.getDefault()));
- System.out.println("OK".toUpperCase(Locale.US));
- System.out.println("OK".toUpperCase(Locale.CHINA));
- System.out.println("WRONG".toUpperCase());
-
- System.out.println("OK".toLowerCase(Locale.getDefault()));
- System.out.println("OK".toLowerCase(Locale.US));
- System.out.println("OK".toLowerCase(Locale.CHINA));
- System.out.println("WRONG".toLowerCase());
-
- String.format(Locale.getDefault(), "OK: %f", 1.0f);
- String.format("OK: %x %A %c %b %B %h %n %%", 1, 2, 'c', true, false, 5);
- String.format("WRONG: %f", 1.0f); // Implies locale
- String.format("WRONG: %1$f", 1.0f);
- String.format("WRONG: %e", 1.0f);
- String.format("WRONG: %d", 1.0f);
- String.format("WRONG: %g", 1.0f);
- String.format("WRONG: %g", 1.0f);
- String.format("WRONG: %1$tm %1$te,%1$tY",
- new GregorianCalendar(2012, GregorianCalendar.AUGUST, 27));
- }
-
- @android.annotation.SuppressLint("NewApi") // DateFormatSymbols requires API 9
- public void testSimpleDateFormat() {
- new SimpleDateFormat(); // WRONG
- new SimpleDateFormat("yyyy-MM-dd"); // WRONG
- new SimpleDateFormat("yyyy-MM-dd", DateFormatSymbols.getInstance()); // WRONG
- new SimpleDateFormat("yyyy-MM-dd", Locale.US); // OK
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/MathTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/MathTest.class.data
deleted file mode 100644
index 6647f1c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/MathTest.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/MathTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/MathTest.java.txt
deleted file mode 100644
index 0193f81..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/MathTest.java.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-package test.bytecode;
-
-import android.util.FloatMath;
-
-//Test data for the MathDetector
-public class MathTest {
- public float floatResult;
- public double doubleResult;
-
- public void floatToFloatTest(float x, double y, int z) {
- floatResult = FloatMath.cos(x);
- floatResult = FloatMath.sin((float) y);
- floatResult = android.util.FloatMath.ceil((float) y);
- System.out.println(FloatMath.floor(x));
- System.out.println(FloatMath.sqrt(z));
-
- // No warnings for plain math
- floatResult = (float) Math.cos(x);
- floatResult = (float) java.lang.Math.sin(x);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/OnClickActivity.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/OnClickActivity.class.data
deleted file mode 100644
index 216a865..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/OnClickActivity.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/OnClickActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/OnClickActivity.java.txt
deleted file mode 100644
index 557ba0a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/OnClickActivity.java.txt
+++ /dev/null
@@ -1,48 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.util.Log;
-import android.view.View;
-
-/** Test data for the OnClickDetector */
-public class OnClickActivity extends Activity {
- // Wrong argument type 1
- public void wrong1() {
- }
-
- // Wrong argument type 2
- public void wrong2(int i) {
- }
-
- // Wrong argument type 3
- public void wrong3(View view, int i) {
- }
-
- // Wrong return type
- public int wrong4(View view) {
- return 0;
- }
-
- // Wrong modifier (not public)
- void wrong5(View view) {
- }
-
- // Wrong modifier (is static)
- public static void wrong6(View view) {
- }
-
- public void ok(View view) {
- }
-
- // Ok: Unicode escapes
- public void my\u1234method(View view) {
- }
-
- // Typo
- public void simple_tyop(View view) {
- }
-
- void wrong7(View view) {
- Log.i("x", "wrong7: called");
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/PowerManagerFlagTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/PowerManagerFlagTest.class.data
deleted file mode 100644
index c8b4da9..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/PowerManagerFlagTest.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/PowerManagerFlagTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/PowerManagerFlagTest.java.txt
deleted file mode 100644
index c3794ed..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/PowerManagerFlagTest.java.txt
+++ /dev/null
@@ -1,18 +0,0 @@
-package test.pkg;
-
-import static android.os.PowerManager.ACQUIRE_CAUSES_WAKEUP;
-import static android.os.PowerManager.FULL_WAKE_LOCK;
-import static android.os.PowerManager.PARTIAL_WAKE_LOCK;
-import android.content.Context;
-import android.os.PowerManager;
-
-public class PowerManagerFlagTest {
- @SuppressWarnings("deprecation")
- public void test(Context context) {
- PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
-
- pm.newWakeLock(PARTIAL_WAKE_LOCK, "Test"); // OK
- pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK|ACQUIRE_CAUSES_WAKEUP, "Test"); // Bad
- pm.newWakeLock(FULL_WAKE_LOCK|ACQUIRE_CAUSES_WAKEUP, "Test"); // OK
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/RecycleTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/RecycleTest.class.data
deleted file mode 100644
index 3bdc829..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/RecycleTest.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/RecycleTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/RecycleTest.java.txt
deleted file mode 100644
index 2a026f2..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/RecycleTest.java.txt
+++ /dev/null
@@ -1,159 +0,0 @@
-package test.pkg;
-
-import com.unit.test.R;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.os.Message;
-import android.os.Parcel;
-import android.util.AttributeSet;
-import android.view.MotionEvent;
-import android.view.VelocityTracker;
-import android.view.View;
-
-@SuppressWarnings("unused")
-public class RecycleTest extends View {
- // ---- Check recycling TypedArrays ----
-
- public RecycleTest(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- public void ok1(AttributeSet attrs, int defStyle) {
- final TypedArray a = getContext().obtainStyledAttributes(attrs,
- R.styleable.MyView, defStyle, 0);
- String example = a.getString(R.styleable.MyView_exampleString);
- a.recycle();
- }
-
- public void ok2(AttributeSet attrs, int defStyle) {
- final TypedArray a = getContext().obtainStyledAttributes(attrs,
- R.styleable.MyView, defStyle, 0);
- String example = a.getString(R.styleable.MyView_exampleString);
- // If there's complicated logic, don't flag
- if (something()) {
- a.recycle();
- }
- }
-
- public TypedArray ok3(AttributeSet attrs, int defStyle) {
- // Value passes out of method: don't flag, caller might be recycling
- return getContext().obtainStyledAttributes(attrs, R.styleable.MyView,
- defStyle, 0);
- }
-
- private TypedArray myref;
-
- public void ok4(AttributeSet attrs, int defStyle) {
- // Value stored in a field: might be recycled later
- TypedArray ref = getContext().obtainStyledAttributes(attrs,
- R.styleable.MyView, defStyle, 0);
- myref = ref;
- }
-
- public void wrong1(AttributeSet attrs, int defStyle) {
- final TypedArray a = getContext().obtainStyledAttributes(attrs,
- R.styleable.MyView, defStyle, 0);
- String example = a.getString(R.styleable.MyView_exampleString);
- // a.recycle();
- }
-
- public void wrong2(AttributeSet attrs, int defStyle) {
- final TypedArray a = getContext().obtainStyledAttributes(new int[0]);
- // a.recycle();
- }
-
- public void unknown(AttributeSet attrs, int defStyle) {
- final TypedArray a = getContext().obtainStyledAttributes(attrs,
- R.styleable.MyView, defStyle, 0);
- // We don't know what this method is (usually it will be in a different
- // class)
- // so don't flag it; it might recycle
- handle(a);
- }
-
- // ---- Check recycling VelocityTracker ----
-
- public void tracker() {
- VelocityTracker tracker = VelocityTracker.obtain();
- }
-
- // ---- Check recycling Message ----
-
- public void message() {
- Message message1 = getHandler().obtainMessage();
- Message message2 = Message.obtain();
- }
-
- // ---- Check recycling MotionEvent ----
-
- public void motionEvent() {
- MotionEvent event1 = MotionEvent.obtain(null);
- MotionEvent event2 = MotionEvent.obtainNoHistory(null);
- }
-
- public void motionEvent2() {
- MotionEvent event1 = MotionEvent.obtain(null); // OK
- MotionEvent event2 = MotionEvent.obtainNoHistory(null); // Not recycled
- event1.recycle();
- }
-
- public void motionEvent3() {
- MotionEvent event1 = MotionEvent.obtain(null); // Not recycled
- MotionEvent event2 = MotionEvent.obtain(event1);
- event2.recycle();
- }
-
- // ---- Using recycled objects ----
-
- public void recycled() {
- MotionEvent event1 = MotionEvent.obtain(null); // Not recycled
- event1.recycle();
- int contents2 = event1.describeContents(); // BAD, after recycle
- final TypedArray a = getContext().obtainStyledAttributes(new int[0]);
- String example = a.getString(R.styleable.MyView_exampleString); // OK
- a.recycle();
- example = a.getString(R.styleable.MyView_exampleString); // BAD, after recycle
- }
-
- // ---- Check recycling Parcel ----
-
- public void parcelOk() {
- Parcel myparcel = Parcel.obtain();
- myparcel.createBinderArray();
- myparcel.recycle();
- }
-
- public void parcelMissing() {
- Parcel myparcel = Parcel.obtain();
- myparcel.createBinderArray();
- }
-
-
- // ---- Check suppress ----
-
- @SuppressLint("Recycle")
- public void recycledSuppress() {
- MotionEvent event1 = MotionEvent.obtain(null); // Not recycled
- event1.recycle();
- int contents2 = event1.describeContents(); // BAD, after recycle
- final TypedArray a = getContext().obtainStyledAttributes(new int[0]);
- String example = a.getString(R.styleable.MyView_exampleString); // OK
- }
-
- // ---- Stubs ----
-
- static void handle(TypedArray a) {
- // Unknown method
- }
-
- protected boolean something() {
- return true;
- }
-
- public android.content.res.TypedArray obtainStyledAttributes(
- AttributeSet set, int[] attrs, int defStyleAttr, int defStyleRes) {
- return null;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/SecureRandomTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/SecureRandomTest.class.data
deleted file mode 100644
index 3236187..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/SecureRandomTest.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/SecureRandomTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/SecureRandomTest.java.txt
deleted file mode 100644
index c05fbd9..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/SecureRandomTest.java.txt
+++ /dev/null
@@ -1,42 +0,0 @@
-package test.pkg;
-
-import java.security.SecureRandom;
-import java.util.Random;
-
-public class SecureRandomTest {
- private static final long FIXED_SEED = 1000L;
- protected int getDynamicSeed() { return 1; }
-
- public void testLiterals() {
- SecureRandom random1 = new SecureRandom();
- random1.setSeed(System.currentTimeMillis()); // OK
- random1.setSeed(getDynamicSeed()); // OK
- random1.setSeed(0); // Wrong
- random1.setSeed(1); // Wrong
- random1.setSeed((int)1023); // Wrong
- random1.setSeed(1023L); // Wrong
- random1.setSeed(FIXED_SEED); // Wrong
- }
-
- public void testRandomTypeOk() {
- Random random2 = new Random();
- random2.setSeed(0); // OK
- }
-
- public void testRandomTypeWrong() {
- Random random3 = new SecureRandom();
- random3.setSeed(0); // Wrong: owner is java/util/Random, but applied to SecureRandom object
- }
-
- public void testBytesOk() {
- SecureRandom random1 = new SecureRandom();
- byte[] seed = random1.generateSeed(4);
- random1.setSeed(seed); // OK
- }
-
- public void testBytesWrong() {
- SecureRandom random2 = new SecureRandom();
- byte[] seed = new byte[3];
- random2.setSeed(seed); // Wrong
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestFieldGetter.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestFieldGetter.class.data
deleted file mode 100644
index d922751..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestFieldGetter.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestFieldGetter.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestFieldGetter.java.txt
deleted file mode 100644
index 00da161..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestFieldGetter.java.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-package test.pkg;
-
-import java.io.File;
-import java.util.List;
-
-import android.content.Context;
-
-public class TestFieldGetter {
- private int path;
- private int foo;
-
- public int getPath() {
- return path;
- }
-
- public int getFoo() {
- return foo;
- }
-
- public void test(TestFieldGetter other) {
- getPath(); // Should be flagged
- other.getPath(); // Ignore
- File file = new File("/dummy");
- file.getPath(); // Ignore
- }
-
- public static void test2(TestFieldGetter other) {
- other.getPath(); // Ignore
- }
-
- public class Inner extends TestFieldGetter {
- public void test() {
- getFoo(); // Ignore
- }
- }
-} \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider.class.data
deleted file mode 100644
index 945742f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider.java.txt
deleted file mode 100644
index 2bf1bb8..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider.java.txt
+++ /dev/null
@@ -1,40 +0,0 @@
-package test.pkg;
-
-import android.content.ContentProvider;
-import android.content.ContentValues;
-import android.database.Cursor;
-import android.net.Uri;
-
-public class TestProvider extends ContentProvider {
- @Override
- public int delete(Uri uri, String selection, String[] selectionArgs) {
- return 0;
- }
-
- @Override
- public String getType(Uri uri) {
- return null;
- }
-
- @Override
- public Uri insert(Uri uri, ContentValues values) {
- return null;
- }
-
- @Override
- public boolean onCreate() {
- return false;
- }
-
- @Override
- public Cursor query(Uri uri, String[] projection, String selection,
- String[] selectionArgs, String sortOrder) {
- return null;
- }
-
- @Override
- public int update(Uri uri, ContentValues values, String selection,
- String[] selectionArgs) {
- return 0;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider2.class.data
deleted file mode 100644
index 0973dbe..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider2.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider2.java.txt
deleted file mode 100644
index 881975d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestProvider2.java.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-package test.pkg;
-
-public class TestProvider2 extends TestProvider {
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver$1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver$1.class.data
deleted file mode 100644
index 7ede85a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver$1.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver.class.data
deleted file mode 100644
index 6180e40..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver.java.txt
deleted file mode 100644
index 90893c8..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestReceiver.java.txt
+++ /dev/null
@@ -1,21 +0,0 @@
-package test.pkg;
-
-import android.content.BroadcastReceiver;
-import android.content.Context;
-import android.content.Intent;
-
-public class TestReceiver extends BroadcastReceiver {
-
- @Override
- public void onReceive(Context context, Intent intent) {
- }
-
- // Anonymous classes should NOT be counted as a must-register
- private BroadcastReceiver dummy() {
- return new BroadcastReceiver() {
- @Override
- public void onReceive(Context context, Intent intent) {
- }
- };
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestService.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestService.class.data
deleted file mode 100644
index a98f7aa..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestService.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestService.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestService.java.txt
deleted file mode 100644
index d3f128a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/TestService.java.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-package test.pkg;
-
-import android.app.Service;
-import android.content.Intent;
-import android.os.IBinder;
-
-public class TestService extends Service {
-
- @Override
- public IBinder onBind(Intent intent) {
- return null;
- }
-
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/ViewTagTest.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/ViewTagTest.class.data
deleted file mode 100644
index f26032c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/ViewTagTest.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/ViewTagTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/ViewTagTest.java.txt
deleted file mode 100644
index 8e72fd0..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/ViewTagTest.java.txt
+++ /dev/null
@@ -1,37 +0,0 @@
-package test.pkg;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.database.Cursor;
-import android.database.MatrixCursor;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.CursorAdapter;
-import android.widget.ImageView;
-import android.widget.TextView;
-
-@SuppressWarnings("unused")
-public abstract class ViewTagTest {
- public View newView(Context context, ViewGroup group, Cursor cursor1,
- MatrixCursor cursor2) {
- LayoutInflater inflater = LayoutInflater.from(context);
- View view = inflater.inflate(android.R.layout.activity_list_item, null);
- view.setTag(android.R.id.background, "Some random tag"); // OK
- view.setTag(android.R.id.button1, group); // ERROR
- view.setTag(android.R.id.icon, view.findViewById(android.R.id.icon)); // ERROR
- view.setTag(android.R.id.icon1, cursor1); // ERROR
- view.setTag(android.R.id.icon2, cursor2); // ERROR
- view.setTag(android.R.id.copy, new MyViewHolder()); // ERROR
- return view;
- }
-
- @SuppressLint("ViewTag")
- public void checkSuppress(Context context, View view) {
- view.setTag(android.R.id.icon, view.findViewById(android.R.id.icon));
- }
-
- private class MyViewHolder {
- View view;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity1.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity1.class.data
deleted file mode 100644
index d4733e6..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity1.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity1.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity1.java.txt
deleted file mode 100644
index 0b14691..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity1.java.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.os.PowerManager;
-
-public class WakelockActivity1 extends Activity {
- private PowerManager.WakeLock mWakeLock;
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- PowerManager manager = (PowerManager) getSystemService(POWER_SERVICE);
- mWakeLock = manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Test");
- mWakeLock.acquire(); // Never released
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity2.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity2.class.data
deleted file mode 100644
index 89e35c1..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity2.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity2.java.txt
deleted file mode 100644
index fa91a43..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity2.java.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.PowerManager;
-
-public class WakelockActivity2 extends Activity {
- private PowerManager.WakeLock mWakeLock;
-
- @Override
- protected void onDestroy() {
- super.onDestroy();
- if (mWakeLock != null && mWakeLock.isHeld()) {
- mWakeLock.release(); // Should be done in onPause instead
- }
- }
-
- @Override
- protected void onPause() {
- super.onDestroy();
- if (mWakeLock != null && mWakeLock.isHeld()) {
- mWakeLock.release(); // OK
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity3.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity3.class.data
deleted file mode 100644
index b430519..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity3.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity3.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity3.java.txt
deleted file mode 100644
index 8a842eb..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity3.java.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.PowerManager;
-
-public class WakelockActivity3 extends Activity {
- void wrongFlow() {
- PowerManager manager = (PowerManager) getSystemService(POWER_SERVICE);
- PowerManager.WakeLock lock =
- manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Test");
- lock.acquire();
- randomCall();
- lock.release(); // Should be in finally block
- }
-
- static void randomCall() {
- System.out.println("test");
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity4.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity4.class.data
deleted file mode 100644
index 8905203..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity4.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity4.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity4.java.txt
deleted file mode 100644
index 9d6331f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity4.java.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.PowerManager;
-
-public class WakelockActivity4 extends Activity {
- void wrongFlow2() {
- getLock().acquire();
- randomCall();
- getLock().release(); // Should be in finally block
- }
-
- private PowerManager.WakeLock mLock;
-
- PowerManager.WakeLock getLock() {
- if (mLock == null) {
- PowerManager manager = (PowerManager) getSystemService(POWER_SERVICE);
- mLock = manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Test");
- }
-
- return mLock;
- }
-
- static void randomCall() {
- System.out.println("test");
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity5.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity5.class.data
deleted file mode 100644
index 9eca365..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity5.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity5.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity5.java.txt
deleted file mode 100644
index 060f2b1..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity5.java.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.PowerManager;
-
-public class WakelockActivity5 extends Activity {
- void wrongFlow() {
- PowerManager manager = (PowerManager) getSystemService(POWER_SERVICE);
- PowerManager.WakeLock lock =
- manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Test");
- lock.acquire();
- randomCall();
- lock.release(); // Should be in finally block
- }
-
- static void randomCall() {
- System.out.println("test");
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity6.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity6.class.data
deleted file mode 100644
index 51fdf69..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity6.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity6.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity6.java.txt
deleted file mode 100644
index a122fa3..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity6.java.txt
+++ /dev/null
@@ -1,71 +0,0 @@
-package test.pkg;
-
-import com.example.test3.BuildConfig;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.os.PowerManager;
-import android.os.PowerManager.WakeLock;;
-
-public class WakelockActivity6 extends Activity {
- void wrongFlow1() {
- PowerManager manager = (PowerManager) getSystemService(POWER_SERVICE);
- PowerManager.WakeLock lock =
- manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Test");
- lock.acquire();
- if (getTaskId() == 50) {
- randomCall();
- } else {
- lock.release(); // Wrong
- }
- }
-
- void wrongFlow2(PowerManager.WakeLock lock) {
- lock.acquire();
- if (getTaskId() == 50) {
- randomCall();
- } else {
- lock.release(); // Wrong
- }
- }
-
- void okFlow1(WakeLock lock) {
- lock.acquire();
- try {
- randomCall();
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- lock.release(); // OK
- }
- }
-
- public void checkNullGuard(WakeLock lock) {
- lock.acquire();
- if (lock != null) {
- lock.release(); // OK
- }
- }
-
- @SuppressLint("Wakelock")
- public void checkDisabled1(PowerManager.WakeLock lock) {
- lock.acquire();
- randomCall();
- lock.release(); // Wrong, but disabled
- }
-
- void wrongFlow3(WakeLock lock) {
- int id = getTaskId();
- lock.acquire();
- if (id < 50) {
- System.out.println(1);
- } else {
- System.out.println(2);
- }
- lock.release(); // Wrong
- }
-
- static void randomCall() {
- System.out.println("test");
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity7.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity7.class.data
deleted file mode 100644
index 289b0d3..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity7.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity7.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity7.java.txt
deleted file mode 100644
index be48dac..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity7.java.txt
+++ /dev/null
@@ -1,17 +0,0 @@
-package test.pkg;
-
-import android.os.PowerManager.WakeLock;
-
-public class WakelockActivity7 {
- public void test(WakeLock lock) {
- try {
- lock.acquire();
- new Runnable() {
- public void run() {
- }
- };
- } finally {
- lock.release();
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity8.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity8.class.data
deleted file mode 100644
index 5bd3ae2..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity8.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity8.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity8.java.txt
deleted file mode 100644
index a6307c5..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/WakelockActivity8.java.txt
+++ /dev/null
@@ -1,24 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.os.PowerManager;
-import android.os.PowerManager.WakeLock;
-
-import com.google.io.demo.R;
-
-public class WakelockActivity8 extends Activity {
- private WakeLock mWakeLock;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- PowerManager manager = (PowerManager) getSystemService(POWER_SERVICE);
- mWakeLock = manager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "Test");
- mWakeLock.acquire();
- if (mWakeLock.isHeld()) {
- mWakeLock.release();
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classes.jar b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classes.jar
deleted file mode 100644
index fa52dcf..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classes.jar
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classpath-jar b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classpath-jar
deleted file mode 100644
index 53f7d6c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classpath-jar
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry kind="output" path="bin/classes.jar"/>
-</classpath>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classpath-lib b/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classpath-lib
deleted file mode 100644
index e730df8..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/bytecode/classpath-lib
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry kind="lib" path="libs/library.jar"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/debuggable.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/debuggable.xml
deleted file mode 100644
index 1c234e4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/debuggable.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:debuggable="true"
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate-manifest-ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate-manifest-ignore.xml
deleted file mode 100644
index 76cfd4d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate-manifest-ignore.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- package="com.example.helloworld"
- android:versionCode="1"
- android:versionName="1.0">
- <uses-sdk android:minSdkVersion="14" />
- <application android:icon="@drawable/icon" android:label="@string/app_name" tools:ignore="DuplicateActivity">
- <activity android:name=".HelloWorld"
- android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
- <activity android:name="com.example.helloworld.HelloWorld"
- android:label="@string/app_name">
- </activity>
-
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate-manifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate-manifest.xml
deleted file mode 100644
index e1fc3c6..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate-manifest.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.example.helloworld"
- android:versionCode="1"
- android:versionName="1.0">
- <uses-sdk android:minSdkVersion="14" />
- <application android:icon="@drawable/icon" android:label="@string/app_name">
- <activity android:name=".HelloWorld"
- android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
- <activity android:name="com.example.helloworld.HelloWorld"
- android:label="@string/app_name">
- </activity>
-
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions1.xml
deleted file mode 100644
index 511fa46..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions1.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <permission android:name="foo.permission.SEND_SMS"
- android:label="@string/foo"
- android:description="@string/foo" />
- <permission android:name="bar.permission.SEND_SMS"
- android:label="@string/foo"
- android:description="@string/foo" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions2.xml
deleted file mode 100644
index 3729f79..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions2.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <permission android:name="foo.permission.SEND_SMS"
- android:label="@string/foo"
- android:description="@string/foo" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions3.xml
deleted file mode 100644
index a1a0638..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/duplicate_permissions3.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <permission android:name="bar.permission.SEND_SMS"
- android:label="@string/foo"
- android:description="@string/foo" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity0.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity0.xml
deleted file mode 100644
index cc436d0..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity0.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:label="@string/app_name"
- android:name="com.sample.service.serviceClass" >
- </activity>
- </application>
-
-</manifest>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity1.xml
deleted file mode 100644
index 0fc80f3..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity1.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:label="@string/app_name"
- android:name="com.sample.service.serviceClass" >
- <intent-filter >
- <action android:name="com.sample.service.serviceClass" >
- </action>
- </intent-filter>
- </activity>
- <activity
- android:label="@string/app_name"
- android:name="com.sample.service.mainClass" >
- <intent-filter >
- <action android:name="com.sample.service.mainClass" >
- </action>
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity2.xml
deleted file mode 100644
index 2b4cf6a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity2.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:label="@string/app_name"
- android:name="com.sample.service.serviceClass"
- android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
- android:process=":remote" >
- <intent-filter >
- <action android:name="com.sample.service.serviceClass" >
- </action>
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity3.xml
deleted file mode 100644
index 191c699..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity3.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
- android:label="@string/app_name" >
- <activity
- android:label="@string/app_name"
- android:name="com.sample.service.serviceClass"
- android:process=":remote" >
- <intent-filter >
- <action android:name="com.sample.service.serviceClass" >
- </action>
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity4.xml
deleted file mode 100644
index 31345cc..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportactivity4.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:label="@string/app_name"
- android:name="com.sample.service.serviceClass"
- android:process=":remote" >
- <intent-filter >
- <action android:name="com.sample.service.serviceClass" >
- </action>
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportprovider1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportprovider1.xml
deleted file mode 100644
index 02ec2e0..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportprovider1.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
-
- <!-- exported implicitly, fail -->
- <provider
- android:name="com.sample.provider.providerClass1"
- android:authorities="com.sample.provider.providerData">
- </provider>
-
- <!-- exported explicitly, fail -->
- <provider
- android:exported="true"
- android:name="com.sample.provider.providerClass2"
- android:authorities="com.sample.provider.providerData">
- </provider>
-
- <!-- not exported, win -->
- <provider
- android:exported="false"
- android:name="com.sample.provider.providerClass3"
- android:authorities="com.sample.provider.providerData">
- </provider>
- </application>
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportprovider2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportprovider2.xml
deleted file mode 100644
index 4e3fc1b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportprovider2.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
-
- <!-- read+write permission attribute, win -->
- <provider
- android:name="com.sample.provider.providerClass"
- android:authorities="com.sample.provider.providerData"
- android:readPermission="com.sample.provider.READ_PERMISSON"
- android:writePermission="com.sample.provider.WRITE_PERMISSON">
- </provider>
-
- <!-- permission attribute, win -->
- <provider
- android:name="com.sample.provider.providerClass"
- android:authorities="com.sample.provider.providerData"
- android:permission="com.sample.provider.PERMISSION">
- </provider>
-
- <!-- path-permission, win -->
- <provider
- android:name="com.sample.provider.providerClass"
- android:authorities="com.sample.provider.providerData">
- <path-permission
- android:pathPrefix="/hello"
- android:permission="com.sample.provider.PERMISSION">
- </path-permission>
- </provider>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver0.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver0.xml
deleted file mode 100644
index f9c5190..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver0.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <receiver
- android:label="@string/app_name"
- android:name="com.sample.service.serviceClass" >
- </receiver>
- </application>
-
-</manifest>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver1.xml
deleted file mode 100644
index 0652d49..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver1.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <receiver
- android:label="@string/app_name"
- android:name="com.sample.service.serviceClass" >
- <intent-filter >
- <action android:name="com.sample.service.serviceClass" >
- </action>
- </intent-filter>
- </receiver>
- </application>
-
-</manifest>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver2.xml
deleted file mode 100644
index 46d5dcb..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver2.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <receiver
- android:label="@string/app_name"
- android:name="com.sample.service.serviceClass"
- android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
- android:process=":remote" >
- <intent-filter >
- <action android:name="com.sample.service.serviceClass" >
- </action>
- </intent-filter>
- </receiver>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver3.xml
deleted file mode 100644
index bc3ec8a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver3.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
- android:label="@string/app_name" >
- <receiver
- android:label="@string/app_name"
- android:name="com.sample.service.serviceClass"
- android:process=":remote" >
- <intent-filter >
- <action android:name="com.sample.service.serviceClass" >
- </action>
- </intent-filter>
- </receiver>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver4.xml
deleted file mode 100644
index 5d9a826..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver4.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <receiver
- android:label="@string/app_name"
- android:name="com.sample.service.serviceClass"
- android:process=":remote" >
- <intent-filter >
- <action android:name="com.sample.service.serviceClass" >
- </action>
- </intent-filter>
- </receiver>
- </application>
-
-</manifest>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver5.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver5.xml
deleted file mode 100644
index afa74cf..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver5.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name">
- <receiver>
- <intent-filter>
- <action android:name="android.intent.action.BOOT_COMPLETED" />
- </intent-filter>
- </receiver>
- </application>
-
-</manifest>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver6.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver6.xml
deleted file mode 100644
index b1ce3e3..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportreceiver6.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
-
- <receiver android:name=".DockReceiver" >
- <intent-filter>
- <action android:name="android.intent.action.DOCK_EVENT" />
- <action android:name="android.app.action.ENTER_CAR_MODE" />
- </intent-filter>
- </receiver>
-
- <receiver
- android:name="com.foo.BarReceiver"
- android:enabled="false" >
- <intent-filter>
- <action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
- <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
- </intent-filter>
- </receiver>
-
- <receiver
- android:name=".AppWidget"
- android:exported="true"
- android:label="@string/label" >
- <intent-filter>
- <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
- </intent-filter>
-
- <meta-data
- android:name="android.appwidget.provider"
- android:resource="@xml/config" />
- </receiver>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice1.xml
deleted file mode 100644
index 67e519f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice1.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <service
- android:exported="true"
- android:label="@string/app_name"
- android:name="com.sample.service.serviceClass"
- android:process=":remote" >
- <intent-filter >
- <action android:name="com.sample.service.serviceClass" >
- </action>
- </intent-filter>
- </service>
- </application>
-
-</manifest>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice2.xml
deleted file mode 100644
index 491a14f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice2.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <service
- android:label="@string/app_name"
- android:name="com.sample.service.serviceClass"
- android:process=":remote" >
- <intent-filter >
- <action android:name="com.sample.service.serviceClass" >
- </action>
- </intent-filter>
- </service>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice3.xml
deleted file mode 100644
index 8d5f166..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice3.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <service
- android:label="@string/app_name"
- android:name="com.sample.service.serviceClass"
- android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
- android:process=":remote" >
- <intent-filter >
- <action android:name="com.sample.service.serviceClass" >
- </action>
- </intent-filter>
- </service>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice4.xml
deleted file mode 100644
index f952225..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice4.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:permission="android.permission.RECEIVE_BOOT_COMPLETED"
- android:label="@string/app_name" >
- <service
- android:label="@string/app_name"
- android:name="com.sample.service.serviceClass"
- android:process=":remote" >
- <intent-filter >
- <action android:name="com.sample.service.serviceClass" >
- </action>
- </intent-filter>
- </service>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice5.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice5.xml
deleted file mode 100644
index c9b9a78..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/exportservice5.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <service
- android:label="@string/app_name"
- android:name="com.sample.service.serviceClass"
- android:process=":remote" >
- <intent-filter >
- <action android:name="com.sample.service.serviceClass" >
- </action>
- </intent-filter>
- </service>
- </application>
-
-</manifest>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/gen/my/pkg/R.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/gen/my/pkg/R.java.txt
deleted file mode 100644
index fad43bf..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/gen/my/pkg/R.java.txt
+++ /dev/null
@@ -1,23 +0,0 @@
-public final class R {
- public static final class attr {
- }
- public static final class drawable {
- public static final int ic_launcher=0x7f020000;
- }
- public static final class id {
- public static final int button1=0x7f050000;
- public static final int button2=0x7f050004;
- public static final int imageView1=0x7f050003;
- public static final int include1=0x7f050005;
- public static final int linearLayout1=0x7f050001;
- public static final int linearLayout2=0x7f050002;
- }
- public static final class layout {
- public static final int main=0x7f030000;
- public static final int other=0x7f030001;
- }
- public static final class string {
- public static final int app_name=0x7f040001;
- public static final int hello=0x7f040000;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/gen/my/pkg/R2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/gen/my/pkg/R2.java.txt
deleted file mode 100644
index ed8fd7d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/gen/my/pkg/R2.java.txt
+++ /dev/null
@@ -1,5 +0,0 @@
-public final class R {
- public static final class drawable {
- public static final int ic_menu_help=0x7f020000;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/grantpermission.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/grantpermission.xml
deleted file mode 100644
index e07c370..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/grantpermission.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity"
- android:permission="Foo" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <!-- good: -->
- <grant-uri-permission android:pathPrefix="/all_downloads/"/>
- <!-- bad: -->
- <grant-uri-permission android:path="/"/>
- <grant-uri-permission android:pathPrefix="/"/>
- <grant-uri-permission android:pathPattern=".*"/>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/ignoremissing.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/ignoremissing.xml
deleted file mode 100644
index 99d804e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/ignoremissing.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<lint>
- <issue id="IconDensities" severity="warning">
- <ignore path="res/drawable-hdpi" />
- </issue>
-</lint>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/illegal_version.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/illegal_version.xml
deleted file mode 100644
index 3028117..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/illegal_version.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="@dimen/versionCode"
- android:versionName="@dimen/versionName" >
-
- <uses-sdk android:minSdkVersion="@dimen/minSdkVersion" android:targetSdkVersion="@dimen/targetSdkVersion" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/minsdk5targetsdk14.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/minsdk5targetsdk14.xml
deleted file mode 100644
index 482b7fa..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/minsdk5targetsdk14.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.bytecode"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".BytecodeTestsActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/minsdk5targetsdk9.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/minsdk5targetsdk9.xml
deleted file mode 100644
index 1cc7596..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/minsdk5targetsdk9.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.bytecode"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="5" android:targetSdkVersion="9" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".BytecodeTestsActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingmin.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingmin.xml
deleted file mode 100644
index 19b3d0a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingmin.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.bytecode"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:targetSdkVersion="10" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".BytecodeTestsActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingprefix.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingprefix.xml
deleted file mode 100644
index 2bb6824..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingprefix.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android.label="@string/app_name" >
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingtarget.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingtarget.xml
deleted file mode 100644
index 1f4fba0..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingtarget.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.bytecode"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="10" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".BytecodeTestsActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingusessdk.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingusessdk.xml
deleted file mode 100644
index 00c0167..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/missingusessdk.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.bytecode"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".BytecodeTestsActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiplesdk.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiplesdk.xml
deleted file mode 100644
index 950cf4d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiplesdk.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.bytecode"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="5" />
- <uses-sdk android:targetSdkVersion="14" />
- <uses-sdk android:maxSdkVersion="15" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".BytecodeTestsActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/LibraryCode.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/LibraryCode.java.txt
deleted file mode 100644
index 25a9d75..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/LibraryCode.java.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-package foo.library;
-
-public class LibraryCode {
- static {
- System.out.println(R.string.string1);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/MainCode.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/MainCode.java.txt
deleted file mode 100644
index 7955e6b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/MainCode.java.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-package foo.main;
-
-public class MainCode {
- static {
- System.out.println(R.string.string2);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/library-manifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/library-manifest.xml
deleted file mode 100644
index ed6e65b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/library-manifest.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.library"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".LibraryProjectActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
-
- <!-- Dummy string references for unused resource check -->
- <meta-data
- android:name="com.google.android.backup.api_key"
- android:value="@string/string3" />
- <meta-data
- android:name="foo"
- android:value="@string/string1" />
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/library.properties b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/library.properties
deleted file mode 100644
index d525577..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/library.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-14
-android.library=true
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main-manifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main-manifest.xml
deleted file mode 100644
index 5c50721..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main-manifest.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.master"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".MasterProjectActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main-merge.properties b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main-merge.properties
deleted file mode 100644
index f1b8f95..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main-merge.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-14
-manifestmerger.enabled=true
-android.library.reference.1=../LibraryProject
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main.properties b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main.properties
deleted file mode 100644
index f366140..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/main.properties
+++ /dev/null
@@ -1,12 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-14
-android.library.reference.1=../LibraryProject
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/strings.xml
deleted file mode 100644
index f53e15f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/multiproject/strings.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <string name="app_name">LibraryProject</string>
- <string name="string1">String 1</string>
- <string name="string2">String 2</string>
- <string name="string3">String 3</string>
-
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/no_version.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/no_version.xml
deleted file mode 100644
index 1c3c0a4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/no_version.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/oldtarget.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/oldtarget.xml
deleted file mode 100644
index d72d7fc..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/oldtarget.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.bytecode"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="10" android:targetSdkVersion="14" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:name=".BytecodeTestsActivity"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/.classpath b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/.classpath
deleted file mode 100644
index a4763d1..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="gen"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
- <classpathentry kind="output" path="bin/classes"/>
-</classpath>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/.project b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/.project
deleted file mode 100644
index 5479f13..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/.project
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>overdraw</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>com.android.ide.eclipse.adt.ApkBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/AndroidManifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/AndroidManifest.xml
deleted file mode 100644
index c9c6127..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/AndroidManifest.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.pkg"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="10" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/MyTheme" >
- <activity
- android:name=".OverdrawActivity"
- android:label="@string/app_name"
- android:theme="@style/MyTheme.First" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <activity
- android:name=".SecondActivity"
- android:label="@string/app_name" >
- </activity>
- <activity
- android:name=".ThirdActivity"
- android:label="@string/app_name" >
- </activity>
- <activity
- android:name="test.pkg.FourthActivity"
- android:label="@string/app_name"
- android:theme="@style/MyTheme.Fourth" >
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/gen/test/pkg/BuildConfig.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/gen/test/pkg/BuildConfig.java.txt
deleted file mode 100644
index 57e2a0e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/gen/test/pkg/BuildConfig.java.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-/** Automatically generated file. DO NOT MODIFY */
-package test.pkg;
-
-public final class BuildConfig {
- public final static boolean DEBUG = true;
-} \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/gen/test/pkg/R.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/gen/test/pkg/R.java.txt
deleted file mode 100644
index c7900de..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/gen/test/pkg/R.java.txt
+++ /dev/null
@@ -1,34 +0,0 @@
-/* AUTO-GENERATED FILE. DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * aapt tool from the resource data it found. It
- * should not be modified by hand.
- */
-
-package test.pkg;
-
-public final class R {
- public static final class attr {
- }
- public static final class drawable {
- public static final int ic_launcher=0x7f020000;
- }
- public static final class layout {
- public static final int fifth=0x7f030000;
- public static final int fourth=0x7f030001;
- public static final int main=0x7f030002;
- public static final int second=0x7f030003;
- public static final int third=0x7f030004;
- }
- public static final class string {
- public static final int app_name=0x7f040001;
- public static final int hello=0x7f040000;
- }
- public static final class style {
- public static final int MyTheme=0x7f050000;
- public static final int MyTheme_First=0x7f050001;
- public static final int MyTheme_Fourth=0x7f050004;
- public static final int MyTheme_Second=0x7f050002;
- public static final int MyTheme_Third=0x7f050003;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/project.properties b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/project.properties
deleted file mode 100644
index f049142..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/project.properties
+++ /dev/null
@@ -1,11 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system use,
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-10
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-hdpi/ic_launcher.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index 8074c4c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-hdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-ldpi/ic_launcher.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-ldpi/ic_launcher.png
deleted file mode 100644
index 1095584..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-ldpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-mdpi/ic_launcher.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644
index a07c69f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable-mdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable/custombg.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable/custombg.xml
deleted file mode 100644
index a8e70d4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable/custombg.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<bitmap
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:src="@drawable/ic_launcher"
- android:tileMode="clamp" /> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable/custombg2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable/custombg2.xml
deleted file mode 100644
index 47513c3..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/drawable/custombg2.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:drawable="@drawable/ic_launcher" />
-</selector>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/fifth.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/fifth.xml
deleted file mode 100644
index 00a5c25..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/fifth.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="@drawable/custombg2"
- android:orientation="vertical" >
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/hello" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/fourth.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/fourth.xml
deleted file mode 100644
index 3102f2c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/fourth.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="@drawable/ic_launcher"
- android:orientation="vertical" >
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/hello" />
-
-</LinearLayout> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/main.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/main.xml
deleted file mode 100644
index 3102f2c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/main.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="@drawable/ic_launcher"
- android:orientation="vertical" >
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/hello" />
-
-</LinearLayout> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/main_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/main_ignore.xml
deleted file mode 100644
index 63f0fd3..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/main_ignore.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="@drawable/ic_launcher"
- tools:ignore="Overdraw"
- android:orientation="vertical" >
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/hello" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/second.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/second.xml
deleted file mode 100644
index 3102f2c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/second.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="@drawable/ic_launcher"
- android:orientation="vertical" >
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/hello" />
-
-</LinearLayout> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/sixth.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/sixth.xml
deleted file mode 100644
index 7f17c9e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/sixth.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:background="@drawable/custombg"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/hello" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/third.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/third.xml
deleted file mode 100644
index 3102f2c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/layout/third.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:background="@drawable/ic_launcher"
- android:orientation="vertical" >
-
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:text="@string/hello" />
-
-</LinearLayout> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/values/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/values/strings.xml
deleted file mode 100644
index bb302bc..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/values/strings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <string name="hello">Hello World, OverdrawActivity!</string>
- <string name="app_name">Overdraw</string>
-
-</resources> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/values/styles.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/values/styles.xml
deleted file mode 100644
index 5ab6ad6..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/res/values/styles.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <style name="MyTheme" parent="@android:style/Theme.Light">
- <item name="android:windowBackground">@drawable/ic_launcher</item>
- </style>
-
- <style name="MyTheme.First">
- <item name="android:textColor">#ff00ff00</item>
- </style>
-
- <style name="MyTheme.Second">
- <item name="android:windowIsTranslucent">true</item>
- </style>
-
- <style name="MyTheme.Third">
- <item name="android:textColor">#ff000000</item>
- </style>
-
- <style name="MyTheme.Fourth">
- <item name="android:windowBackground">@null</item>
- <item name="android:textColor">#ff000000</item>
- </style>
-
-</resources> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/FourthActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/FourthActivity.java.txt
deleted file mode 100644
index 04fac3f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/FourthActivity.java.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class FourthActivity extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.fourth);
- }
-} \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/OverdrawActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/OverdrawActivity.java.txt
deleted file mode 100644
index 8779c19..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/OverdrawActivity.java.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class OverdrawActivity extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- }
-} \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/SecondActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/SecondActivity.java.txt
deleted file mode 100644
index 52b7ca0..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/SecondActivity.java.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class SecondActivity extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.second);
- }
-} \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/ThirdActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/ThirdActivity.java.txt
deleted file mode 100644
index 3d4da95..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/overdraw/src/test/pkg/ThirdActivity.java.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class ThirdActivity extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setTheme(R.style.MyTheme_Third);
- setContentView(R.layout.third);
- }
-} \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.cfg b/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.cfg
deleted file mode 100644
index 12dd039..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.cfg
+++ /dev/null
@@ -1,36 +0,0 @@
--optimizationpasses 5
--dontusemixedcaseclassnames
--dontskipnonpubliclibraryclasses
--dontpreverify
--verbose
--optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-
--keep public class * extends android.app.Activity
--keep public class * extends android.app.Application
--keep public class * extends android.app.Service
--keep public class * extends android.content.BroadcastReceiver
--keep public class * extends android.content.ContentProvider
--keep public class * extends android.app.backup.BackupAgentHelper
--keep public class * extends android.preference.Preference
--keep public class com.android.vending.licensing.ILicensingService
-
--keepclasseswithmembernames class * {
- native <methods>;
-}
-
--keepclasseswithmembernames class * {
- public <init>(android.content.Context, android.util.AttributeSet);
-}
-
--keepclasseswithmembernames class * {
- public <init>(android.content.Context, android.util.AttributeSet, int);
-}
-
--keepclassmembers enum * {
- public static **[] values();
- public static ** valueOf(java.lang.String);
-}
-
--keep class * implements android.os.Parcelable {
- public static final android.os.Parcelable$Creator *;
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.pro b/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.pro
deleted file mode 100644
index 53f41fe..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.pro
+++ /dev/null
@@ -1,64 +0,0 @@
--optimizationpasses 5
--dontusemixedcaseclassnames
--dontskipnonpubliclibraryclasses
--verbose
--optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
--allowaccessmodification
--keepattributes *Annotation*
-
-
-# dex does not like code run through proguard optimize and preverify steps.
--dontoptimize
--dontpreverify
-
--keep public class * extends android.app.Activity
--keep public class * extends android.app.Application
--keep public class * extends android.app.Service
--keep public class * extends android.content.BroadcastReceiver
--keep public class * extends android.content.ContentProvider
--keep public class * extends android.app.backup.BackupAgent
--keep public class * extends android.preference.Preference
--keep public class com.android.vending.licensing.ILicensingService
-
-# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
--keepclasseswithmembernames class * {
- native <methods>;
-}
-
--keep public class * extends android.view.View {
- public <init>(android.content.Context);
- public <init>(android.content.Context, android.util.AttributeSet);
- public <init>(android.content.Context, android.util.AttributeSet, int);
- public void set*(...);
-}
-
--keepclasseswithmembers class * {
- public <init>(android.content.Context, android.util.AttributeSet);
-}
-
--keepclasseswithmembers class * {
- public <init>(android.content.Context, android.util.AttributeSet, int);
-}
-
--keepclassmembers class * extends android.app.Activity {
- public void *(android.view.View);
-}
-
-# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
--keepclassmembers enum * {
- public static **[] values();
- public static ** valueOf(java.lang.String);
-}
-
--keep class * implements android.os.Parcelable {
- public static final android.os.Parcelable$Creator *;
-}
-
--keepclassmembers class **.R$* {
- public static <fields>;
-}
-
-# The support library contains references to newer platform versions.
-# Don't warn about those in case this app is linking against an older
-# platform version. We know about them, and they are safe.
--dontwarn android.support.**
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.properties b/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.properties
deleted file mode 100644
index 989c3c7..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/proguard.properties
+++ /dev/null
@@ -1,2 +0,0 @@
-target=android-14
-proguard.config=${sdk.dir}/foo.cfg:${user.home}/bar.pro;myfile.txt
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties1 b/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties1
deleted file mode 100644
index 2b783dd..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties1
+++ /dev/null
@@ -1,14 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this:
-#proguard.config=proguard.cfg
-
-# Project target.
-target=android-3
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties2 b/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties2
deleted file mode 100644
index d9a28ec..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties2
+++ /dev/null
@@ -1,14 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this:
-proguard.config=proguard.cfg
-
-# Project target.
-target=android-3
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties3 b/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties3
deleted file mode 100644
index 3cb9d31..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties3
+++ /dev/null
@@ -1,11 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-
-# Project target.
-target=android-3
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties4 b/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties4
deleted file mode 100644
index fca9311..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/project.properties4
+++ /dev/null
@@ -1,14 +0,0 @@
-# This file is automatically generated by Android Tools.
-# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
-#
-# This file must be checked in Version Control Systems.
-#
-# To customize properties used by the Ant build system edit
-# "ant.properties", and override values to adapt the script to your
-# project structure.
-#
-# To enable ProGuard to shrink and obfuscate your code, uncomment this:
-proguard.config=${sdk.dir}/tools/proguard/android-defaults.pro:proguard.pro
-
-# Project target.
-target=android-3
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/protectedpermissions.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/protectedpermissions.xml
deleted file mode 100644
index 8b62497..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/protectedpermissions.xml
+++ /dev/null
@@ -1,116 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <!-- No warnings for those -->
- <uses-permission android:name="android.permission.GET_ACCOUNTS" />
- <uses-permission android:name="android.permission.SEND_SMS" />
- <uses-permission android:name="android.permission.INTERNET" />
-
- <!-- Warnings for those -->
- <uses-permission android:name="android.intent.category.MASTER_CLEAR.permission.C2D_MESSAGE" />
- <uses-permission android:name="android.permission.ACCESS_CACHE_FILESYSTEM" />
- <uses-permission android:name="android.permission.ACCESS_CHECKIN_PROPERTIES" />
- <uses-permission android:name="android.permission.ACCESS_MTP" />
- <uses-permission android:name="android.permission.ACCESS_SURFACE_FLINGER" />
- <uses-permission android:name="android.permission.ACCOUNT_MANAGER" />
- <uses-permission android:name="android.permission.ALLOW_ANY_CODEC_FOR_PLAYBACK" />
- <uses-permission android:name="android.permission.ASEC_ACCESS" />
- <uses-permission android:name="android.permission.ASEC_CREATE" />
- <uses-permission android:name="android.permission.ASEC_DESTROY" />
- <uses-permission android:name="android.permission.ASEC_MOUNT_UNMOUNT" />
- <uses-permission android:name="android.permission.ASEC_RENAME" />
- <uses-permission android:name="android.permission.BACKUP" />
- <uses-permission android:name="android.permission.BIND_APPWIDGET" />
- <uses-permission android:name="android.permission.BIND_DEVICE_ADMIN" />
- <uses-permission android:name="android.permission.BIND_INPUT_METHOD" />
- <uses-permission android:name="android.permission.BIND_PACKAGE_VERIFIER" />
- <uses-permission android:name="android.permission.BIND_REMOTEVIEWS" />
- <uses-permission android:name="android.permission.BIND_TEXT_SERVICE" />
- <uses-permission android:name="android.permission.BIND_VPN_SERVICE" />
- <uses-permission android:name="android.permission.BIND_WALLPAPER" />
- <uses-permission android:name="android.permission.BRICK" />
- <uses-permission android:name="android.permission.BROADCAST_PACKAGE_REMOVED" />
- <uses-permission android:name="android.permission.BROADCAST_SMS" />
- <uses-permission android:name="android.permission.BROADCAST_WAP_PUSH" />
- <uses-permission android:name="android.permission.CALL_PRIVILEGED" />
- <uses-permission android:name="android.permission.CHANGE_BACKGROUND_DATA_SETTING" />
- <uses-permission android:name="android.permission.CHANGE_COMPONENT_ENABLED_STATE" />
- <uses-permission android:name="android.permission.CLEAR_APP_USER_DATA" />
- <uses-permission android:name="android.permission.CONFIRM_FULL_BACKUP" />
- <uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />
- <uses-permission android:name="android.permission.CONTROL_LOCATION_UPDATES" />
- <uses-permission android:name="android.permission.COPY_PROTECTED_DATA" />
- <uses-permission android:name="android.permission.CRYPT_KEEPER" />
- <uses-permission android:name="android.permission.DELETE_CACHE_FILES" />
- <uses-permission android:name="android.permission.DELETE_PACKAGES" />
- <uses-permission android:name="android.permission.DEVICE_POWER" />
- <uses-permission android:name="android.permission.DIAGNOSTIC" />
- <uses-permission android:name="android.permission.DUMP" />
- <uses-permission android:name="android.permission.FACTORY_TEST" />
- <uses-permission android:name="android.permission.FORCE_BACK" />
- <uses-permission android:name="android.permission.FORCE_STOP_PACKAGES" />
- <uses-permission android:name="android.permission.GLOBAL_SEARCH" />
- <uses-permission android:name="android.permission.GLOBAL_SEARCH_CONTROL" />
- <uses-permission android:name="android.permission.HARDWARE_TEST" />
- <uses-permission android:name="android.permission.INJECT_EVENTS" />
- <uses-permission android:name="android.permission.INSTALL_LOCATION_PROVIDER" />
- <uses-permission android:name="android.permission.INSTALL_PACKAGES" />
- <uses-permission android:name="android.permission.INTERNAL_SYSTEM_WINDOW" />
- <uses-permission android:name="android.permission.MANAGE_APP_TOKENS" />
- <uses-permission android:name="android.permission.MANAGE_NETWORK_POLICY" />
- <uses-permission android:name="android.permission.MANAGE_USB" />
- <uses-permission android:name="android.permission.MASTER_CLEAR" />
- <uses-permission android:name="android.permission.MODIFY_NETWORK_ACCOUNTING" />
- <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
- <uses-permission android:name="android.permission.MOVE_PACKAGE" />
- <uses-permission android:name="android.permission.NET_ADMIN" />
- <uses-permission android:name="android.permission.MODIFY_PHONE_STATE" />
- <uses-permission android:name="android.permission.PACKAGE_USAGE_STATS" />
- <uses-permission android:name="android.permission.PACKAGE_VERIFICATION_AGENT" />
- <uses-permission android:name="android.permission.PERFORM_CDMA_PROVISIONING" />
- <uses-permission android:name="android.permission.READ_FRAME_BUFFER" />
- <uses-permission android:name="android.permission.READ_INPUT_STATE" />
- <uses-permission android:name="android.permission.READ_NETWORK_USAGE_HISTORY" />
- <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" />
- <uses-permission android:name="android.permission.REBOOT" />
- <uses-permission android:name="android.permission.RECEIVE_EMERGENCY_BROADCAST" />
- <uses-permission android:name="android.permission.REMOVE_TASKS" />
- <uses-permission android:name="android.permission.RETRIEVE_WINDOW_CONTENT" />
- <uses-permission android:name="android.permission.SEND_SMS_NO_CONFIRMATION" />
- <uses-permission android:name="android.permission.SET_ACTIVITY_WATCHER" />
- <uses-permission android:name="android.permission.SET_ORIENTATION" />
- <uses-permission android:name="android.permission.SET_POINTER_SPEED" />
- <uses-permission android:name="android.permission.SET_PREFERRED_APPLICATIONS" />
- <uses-permission android:name="android.permission.SET_SCREEN_COMPATIBILITY" />
- <uses-permission android:name="android.permission.SET_TIME" />
- <uses-permission android:name="android.permission.SET_WALLPAPER_COMPONENT" />
- <uses-permission android:name="android.permission.SHUTDOWN" />
- <uses-permission android:name="android.permission.STATUS_BAR" />
- <uses-permission android:name="android.permission.STATUS_BAR_SERVICE" />
- <uses-permission android:name="android.permission.STOP_APP_SWITCHES" />
- <uses-permission android:name="android.permission.UPDATE_DEVICE_STATS" />
- <uses-permission android:name="android.permission.WRITE_APN_SETTINGS" />
- <uses-permission android:name="android.permission.WRITE_GSERVICES" />
- <uses-permission android:name="android.permission.WRITE_MEDIA_STORAGE" />
- <uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/protectedpermissions2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/protectedpermissions2.xml
deleted file mode 100644
index d3b88da..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/protectedpermissions2.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <!-- No warnings for these: -->
- <uses-permission android:name="android.permission.GET_ACCOUNTS" />
- <uses-permission android:name="android.permission.SEND_SMS" />
- <uses-permission android:name="android.permission.INTERNET" />
-
- <!-- Warnings for these: -->
- <uses-permission android:name="android.intent.category.MASTER_CLEAR.permission.C2D_MESSAGE" tools:ignore="ProtectedPermissions" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifest.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifest.xml
deleted file mode 100644
index 0b07cdf..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifest.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.pkg"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk
- android:minSdkVersion="8"
- android:targetSdkVersion="16" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/AppTheme" >
- <activity
- android:name=".Foo$Bar"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- <activity
- android:name=".Foo$Baz"
- android:label="@string/app_name" >
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestInner.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestInner.xml
deleted file mode 100644
index 1b87d9d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestInner.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.pkg.Foo"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk
- android:minSdkVersion="8"
- android:targetSdkVersion="16" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/AppTheme" >
- <activity
- android:name=".Bar"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestWrong.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestWrong.xml
deleted file mode 100644
index bfdcde0..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestWrong.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.pkg.Foo"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk
- android:minSdkVersion="8"
- android:targetSdkVersion="16" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/AppTheme" >
- <activity
- android:name="test.pkg.Foo.Bar"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestWrong2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestWrong2.xml
deleted file mode 100644
index 8773e0f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/AndroidManifestWrong2.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="test.pkg"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk
- android:minSdkVersion="8"
- android:targetSdkVersion="16" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name"
- android:theme="@style/AppTheme" >
- <activity
- android:name=".Foo.Bar"
- android:label="@string/app_name" >
- <intent-filter>
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Bar.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Bar.class.data
deleted file mode 100644
index e51a0e8..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Bar.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Bar.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Bar.java.txt
deleted file mode 100644
index b514f11..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Bar.java.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-package test.pkg.Foo;
-
-import android.app.Activity;
-
-public class Bar extends Activity {
- private Bar() {
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo$Bar.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo$Bar.class.data
deleted file mode 100644
index da45ebb..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo$Bar.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo$Baz.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo$Baz.class.data
deleted file mode 100644
index aadd767..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo$Baz.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo.class.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo.class.data
deleted file mode 100644
index aafcc73..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo.class.data
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo.java.txt
deleted file mode 100644
index a647030..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/registration/Foo.java.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-
-public class Foo {
- public static class Bar extends Activity {
- }
- public class Baz extends Activity {
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/appwidget_bg.9.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/appwidget_bg.9.png
deleted file mode 100644
index d9af8fb..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/appwidget_bg.9.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/appwidget_bg_focus.9.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/appwidget_bg_focus.9.png
deleted file mode 100644
index ee098af..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/appwidget_bg_focus.9.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/filled.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/filled.png
deleted file mode 100644
index 59fd90a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/filled.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/ic_launcher.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index 8074c4c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/other.9.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/other.9.png
deleted file mode 100644
index d9af8fb..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/other.9.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/unrelated.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/unrelated.png
deleted file mode 100644
index 8074c4c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-hdpi/unrelated.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/frame.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/frame.png
deleted file mode 100644
index 840b2c2..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/frame.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/ic_menu_add_clip_normal.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/ic_menu_add_clip_normal.png
deleted file mode 100644
index 26f5afe..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/ic_menu_add_clip_normal.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/sample_icon.gif b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/sample_icon.gif
deleted file mode 100644
index 1a0be94..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/sample_icon.gif
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/sample_icon.jpg b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/sample_icon.jpg
deleted file mode 100644
index f872487..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/sample_icon.jpg
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/stat_notify_alarm.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/stat_notify_alarm.png
deleted file mode 100644
index c61626c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-mdpi/stat_notify_alarm.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-nodpi/frame.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-nodpi/frame.png
deleted file mode 100644
index 840b2c2..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-nodpi/frame.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-xlarge-nodpi-v11/frame.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-xlarge-nodpi-v11/frame.png
deleted file mode 100644
index 840b2c2..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable-xlarge-nodpi-v11/frame.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/ic_launcher.png b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/ic_launcher.png
deleted file mode 100644
index a07c69f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/ic_launcher.png
+++ /dev/null
Binary files differ
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/ic_menu_help.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/ic_menu_help.xml
deleted file mode 100644
index 41f840f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/ic_menu_help.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<bitmap xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:src="@android:drawable/ic_menu_help"
- tools:ignore="UnusedResources" />
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states.xml
deleted file mode 100644
index 3dedb64..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:color="#ff000000"/> <!-- WRONG, SHOULD BE LAST -->
- <item android:state_pressed="true"
- android:color="#ffff0000"/> <!-- pressed -->
- <item android:state_focused="true"
- android:color="#ff0000ff"/> <!-- focused -->
-</selector>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states2.xml
deleted file mode 100644
index dac176d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states2.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<selector xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res/com.domain.pkg">
-<item
- app:mystate_custom="false"
- android:drawable="@drawable/item" />
-</selector>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states3.xml
deleted file mode 100644
index c3fc533..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/drawable/states3.xml
+++ /dev/null
@@ -1,49 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2008 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<selector xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:state_checked="false" android:state_window_focused="false"
- android:drawable="@drawable/btn_star_big_off" />
- <item android:state_checked="true" android:state_window_focused="false"
- android:drawable="@drawable/btn_star_big_on" />
- <item android:state_checked="true" android:state_window_focused="false"
- android:state_enabled="false" android:drawable="@drawable/btn_star_big_on_disable" />
- <item android:state_checked="false" android:state_window_focused="false"
- android:state_enabled="false" android:drawable="@drawable/btn_star_big_off_disable" />
-
- <item android:state_checked="true" android:state_pressed="true"
- android:drawable="@drawable/btn_star_big_on_pressed" />
- <item android:state_checked="false" android:state_pressed="true"
- android:drawable="@drawable/btn_star_big_off_pressed" />
-
- <item android:state_checked="true" android:state_focused="true"
- android:drawable="@drawable/btn_star_big_on_selected" />
- <item android:state_checked="false" android:state_focused="true"
- android:drawable="@drawable/btn_star_big_off_selected" />
-
- <item android:state_checked="true" android:state_focused="true" android:state_enabled="false"
- android:drawable="@drawable/btn_star_big_on_disable_focused" />
- <item android:state_checked="true" android:state_focused="false" android:state_enabled="false"
- android:drawable="@drawable/btn_star_big_on_disable" />
-
- <item android:state_checked="false" android:state_focused="true" android:state_enabled="false"
- android:drawable="@drawable/btn_star_big_off_disable_focused" />
- <item android:state_checked="false" android:state_focused="false" android:state_enabled="false"
- android:drawable="@drawable/btn_star_big_off_disable" />
-
- <item android:state_checked="false" android:drawable="@drawable/btn_star_big_off" />
- <item android:state_checked="true" android:drawable="@drawable/btn_star_big_on" />
-</selector> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/accessibility.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/accessibility.xml
deleted file mode 100644
index c00a880..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/accessibility.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
- <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
- <ImageView android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" />
- <ImageButton android:importantForAccessibility="yes" android:id="@+id/android_logo2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" />
- <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
- <Button android:id="@+android:id/summary" android:contentDescription="@string/label" />
- <ImageButton android:importantForAccessibility="no" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" />
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/accessibility2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/accessibility2.xml
deleted file mode 100644
index 3f45c26..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/accessibility2.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
- <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
- <ImageView android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" />
- <ImageButton android:importantForAccessibility="yes" android:id="@+id/android_logo2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" />
- <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
- <Button android:id="@+android:id/summary" android:contentDescription="@string/label" />
- <ImageButton android:importantForAccessibility="no" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" />
- <EditText android:hint="@string/label" android:id="@+android:id/summary" android:contentDescription="@string/label" />
- <EditText android:id="@+android:id/summary" android:contentDescription="@string/label" />
- <EditText tools:ignore="ContentDescription" android:hint="@string/label" android:id="@+android:id/summary" android:contentDescription="@string/label" />
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/activity_item_two_pane.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/activity_item_two_pane.xml
deleted file mode 100644
index b19047a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/activity_item_two_pane.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_marginLeft="16dp"
- android:layout_marginRight="16dp"
- android:divider="?android:attr/dividerHorizontal"
- android:orientation="horizontal"
- android:showDividers="middle"
- tools:context=".ItemListActivity" >
-
- <!--
- This layout is a two-pane layout for the Items
- master/detail flow. See res/values-large/refs.xml and
- res/values-sw600dp/refs.xml for an example of layout aliases
- that replace the single-pane version of the layout with
- this two-pane version.
-
- For more on layout aliases, see:
- http://developer.android.com/training/multiscreen/screensizes.html#TaskUseAliasFilters
- -->
-
- <fragment
- android:id="@+id/item_list"
- android:name="com.example.master.ItemListFragment"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="1"
- tools:layout="@android:layout/list_content" />
-
- <FrameLayout
- android:id="@+id/item_detail_container"
- android:layout_width="0dp"
- android:layout_height="match_parent"
- android:layout_weight="3" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights.xml
deleted file mode 100644
index fa5a39a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal" >
-
- <LinearLayout
- android:id="@+id/linearLayout1"
- android:layout_weight="0.3"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <Button
- android:id="@+id/button3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
- </LinearLayout>
-
- <FrameLayout
- android:id="@+id/frameLayout1"
- android:layout_weight="0.7"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
- </FrameLayout>
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights2.xml
deleted file mode 100644
index 2e4af6b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights2.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <LinearLayout
- android:id="@+id/linearLayout1"
- android:layout_weight="0.3"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <Button
- android:id="@+id/button3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
- </LinearLayout>
-
- <FrameLayout
- android:id="@+id/frameLayout1"
- android:layout_weight="0.7"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
- </FrameLayout>
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights3.xml
deleted file mode 100644
index 079bd24..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/baseline_weights3.xml
+++ /dev/null
@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <LinearLayout
- android:id="@+id/linearLayout1"
- android:layout_weight="0.3"
- android:layout_width="wrap_content"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <Button
- android:id="@+id/button3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
- </LinearLayout>
-
- <FrameLayout
- android:id="@+id/frameLayout1"
- android:layout_weight="0.7"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
- </FrameLayout>
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/breadcrumbs_in_fragment.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/breadcrumbs_in_fragment.xml
deleted file mode 100644
index 5e8824a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/breadcrumbs_in_fragment.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="0dip"
- android:layout_height="0dip"
- android:visibility="gone" />
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/broken.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/broken.xml
deleted file mode 100644
index 5dd9d2d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/broken.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
- <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
- <ImageView android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" />
- ImageButton android:id="@+id/android_logo2" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" />
- <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
- <Button android:id="@+android:id/summary" android:contentDescription="@string/label" />
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar.xml
deleted file mode 100644
index d02d49b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar.xml
+++ /dev/null
@@ -1,188 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <!-- Hardcoded strings, wrong order -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="OK" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Cancel" />
- </LinearLayout>
-
- <!-- Hardcoded strings, right order -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Cancel" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="OK" />
- </LinearLayout>
-
- <!-- @android:string resources, wrong order -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@android:string/ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@android:string/cancel" />
- </LinearLayout>
-
- <!-- @android:string resources, right order -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@android:string/cancel" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@android:string/ok" />
- </LinearLayout>
-
- <!-- @string/ok/cancel resources, right order -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/cancel" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/ok" />
- </LinearLayout>
-
- <!-- @string/ok/cancel resources, wrong order -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/cancel" />
- </LinearLayout>
-
- <!-- Random name resources, right order -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/giveup" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/resume" />
- </LinearLayout>
-
- <!-- Random name resources, wrong order -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/resume" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/giveup" />
- </LinearLayout>
-
- <!-- Random name resources with varying case, wrong order -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/resume2" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/giveup2" />
- </LinearLayout>
-
- <!-- Resources with only one of OK and Cancel, wrong order -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/abort" />
- </LinearLayout>
-
- <!-- Resources with only one of OK and Cancel, wrong order -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:layout_width="wrap_content" android:background="?android:attr/selectableItemBackground"
- android:layout_height="wrap_content"
- android:text="@string/send" />
-
- <Button
- android:layout_width="wrap_content" android:background="?android:attr/selectableItemBackground"
- android:layout_height="wrap_content"
- android:text="@string/cancel" />
- </LinearLayout>
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/goback" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar2.xml
deleted file mode 100644
index f6ae19b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar2.xml
+++ /dev/null
@@ -1,52 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
-
- <ProgressBar
- android:id="@+id/loading_progress"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true"
- android:layout_marginBottom="60dip"
- android:layout_marginLeft="40dip"
- android:layout_marginTop="40dip"
- android:max="10000" />
-
- <TextView
- android:id="@+id/text"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:layout_alignWithParentIfMissing="true"
- android:layout_marginBottom="60dip"
- android:layout_marginLeft="40dip"
- android:layout_marginTop="40dip"
- android:layout_toRightOf="@id/loading_progress"
- android:ellipsize="end"
- android:maxLines="3"
- android:paddingRight="120dip"
- android:text="@string/creating_instant_mix"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <Button
- android:id="@+id/cancel"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_alignRight="@id/text"
- android:layout_below="@id/text"
- android:background="@null"
- android:text="@string/cancel" />
-
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_above="@id/cancel"
- android:layout_alignLeft="@id/cancel"
- android:layout_alignRight="@id/cancel"
- android:scaleType="fitXY"
- android:src="@drawable/menu_list_divider" />
-
-</RelativeLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar3.xml
deleted file mode 100644
index 8dbcb10..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar3.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_gravity="center_horizontal"
- android:text="@string/weekpicker_title"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:background="#ffffff"
- android:padding="6dip" >
-
- <Button
- android:id="@+id/set"
- android:layout_width="120dip"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:text="@string/weekpicker_set" />
-
- <Button
- android:id="@+id/cancel"
- android:layout_width="120dip"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:text="@string/cancel" />
- </RelativeLayout>
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar4.xml
deleted file mode 100644
index 9fe69d5..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar4.xml
+++ /dev/null
@@ -1,55 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:visibility="gone" >
-
- <RatingBar
- android:id="@+id/review_form_rating"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:numStars="5"
- android:stepSize="1" />
-
- <EditText
- android:id="@+id/review_form_title"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_toLeftOf="@id/review_form_rating"
- android:hint="@string/review_form_title_hint"
- android:inputType="text|textCapSentences|textAutoCorrect"
- android:lines="1" />
-
- <EditText
- android:id="@+id/review_form_review"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_below="@id/review_form_title"
- android:gravity="top"
- android:hint="@string/review_form_content_hint"
- android:inputType="text|textCapSentences|textAutoCorrect|textMultiLine"
- android:minLines="3"
- android:singleLine="false"
- android:visibility="gone" />
-
- <Button
- android:id="@+id/review_form_submit"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentRight="true"
- android:layout_below="@id/review_form_review"
- android:text="@string/submit"
- android:visibility="gone" />
-
- <Button
- android:id="@+id/review_form_cancel"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/review_form_review"
- android:layout_toLeftOf="@id/review_form_submit"
- android:text="@string/cancel"
- android:visibility="gone" />
-
-</RelativeLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar_suppressed.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar_suppressed.xml
deleted file mode 100644
index a03824d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/buttonbar_suppressed.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <!-- Hardcoded strings, wrong order -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="OK"
- tools:ignore="ButtonOrder" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Cancel"
- tools:ignore="ButtonOrder" />
- </LinearLayout>
-
- <!-- @android:string resources, wrong order -->
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- tools:ignore="ButtonOrder" >
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@android:string/ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@android:string/cancel" />
- </LinearLayout>
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/case.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/case.xml
deleted file mode 100644
index 22e0eb6..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/case.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- ~ Copyright (C) 2013 The Android Open Source Project
- ~
- ~ Licensed under the Apache License, Version 2.0 (the "License");
- ~ you may not use this file except in compliance with the License.
- ~ You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- -->
-
-<Merge xmlns:android="http://schemas.android.com/apk/res/android" >
-
- <Fragment android:name="foo.bar.Fragment" />
- <Include layout="@layout/foo" />
- <RequestFocus />
-
-</Merge>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts.xml
deleted file mode 100644
index 40f01ed..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <EditText
- android:id="@+id/edittext"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="EditText" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts2.xml
deleted file mode 100644
index 249c02f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts2.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- unit test from issue 27441 -->
-<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <RadioGroup
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:orientation="vertical" >
-
- <RadioButton
- android:id="@+id/additional"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <Spinner
- android:id="@+id/reminder_lead"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
- </RadioGroup>
-
-</ScrollView>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts3.xml
deleted file mode 100644
index 990e5f0..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts3.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <RadioButton
- android:id="@+id/button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <EditText
- android:id="@+id/edittext"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="EditText" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts4.xml
deleted file mode 100644
index 371964e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/casts4.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <ToggleButton
- android:id="@+id/button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <EditText
- android:id="@+id/edittext"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="EditText" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound.xml
deleted file mode 100644
index f7b28ef..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
-
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound2.xml
deleted file mode 100644
index 24f45dc..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound2.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:background="@android:drawable/ic_dialog_alert"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound3.xml
deleted file mode 100644
index 68d42fa..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/compound3.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
-
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:scaleType="fitStart" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/crcrlf.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/crcrlf.xml
deleted file mode 100644
index d029725..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/crcrlf.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_centerVertical="true"
- android:text="Hello"
- tools:context=".MainActivity" />
-
-</RelativeLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/crcrlf_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/crcrlf_ignore.xml
deleted file mode 100644
index 680a765..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/crcrlf_ignore.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:ignore="MangledCRLF" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_centerHorizontal="true"
- android:layout_centerVertical="true"
- android:text="@string/app_name"
- tools:context=".MainActivity" />
-
-
-
-
-
-</RelativeLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customattrlayout.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customattrlayout.xml
deleted file mode 100644
index b4c49f0..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customattrlayout.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<foo.bar.ContentFrame
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:foobar="http://schemas.android.com/apk/res/foo.bar"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- foobar:contentId="@+id/test" />
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customview.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customview.xml
deleted file mode 100644
index 976d636..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customview.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- xmlns:other="http://schemas.foo.bar.com/other"
- xmlns:foo="http://schemas.android.com/apk/res/foo"
- android:id="@+id/newlinear"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <foo.bar.Baz
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button1"
- foo:misc="Custom attribute"
- tools:ignore="HardcodedText" >
- </foo.bar.Baz>
-
- <!-- Wrong namespace uri prefix: Don't warn -->
- <foo.bar.Baz
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button1"
- other:misc="Custom attribute"
- tools:ignore="HardcodedText" >
- </foo.bar.Baz>
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customview2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customview2.xml
deleted file mode 100644
index fcd43e6..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/customview2.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- xmlns:other="http://schemas.foo.bar.com/other"
- xmlns:foo="http://schemas.android.com/apk/res-auto"
- android:id="@+id/newlinear"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <foo.bar.Baz
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button1"
- foo:misc="Custom attribute"
- tools:ignore="HardcodedText" >
- </foo.bar.Baz>
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/default_item_badges.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/default_item_badges.xml
deleted file mode 100644
index 082a520..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/default_item_badges.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/video_badges"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/deprecation.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/deprecation.xml
deleted file mode 100644
index 70b7f23..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/deprecation.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_x="5dp"
- android:layout_y="100dp"
- android:text="Button" />
-
- <!-- Deprecated attributes -->
- <TextView
- android:autoText="true"
- android:capitalize="true"
- android:editable="true"
- android:enabled="true"
- android:inputMethod="@+id/foo"
- android:numeric="true"
- android:password="true"
- android:phoneNumber="true"
- android:singleLine="true" />
-
- <EditText android:editable="true" />
- <EditText android:editable="false" />
-
-</AbsoluteLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/detailed_item.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/detailed_item.xml
deleted file mode 100644
index a5d4226..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/detailed_item.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <FrameLayout
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_below="@id/video_badges" />
-
-</RelativeLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/duplicate.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/duplicate.xml
deleted file mode 100644
index e142e9e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/duplicate.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
- <Button android:text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
- <ImageView android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" />
- <ImageButton android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" />
- <Button android:text="Button" android:id="@+id/button2" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
-</LinearLayout>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/edit_textview.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/edit_textview.xml
deleted file mode 100644
index c0d8cda..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/edit_textview.xml
+++ /dev/null
@@ -1,94 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <!-- Various attributes that should be set on EditTexts, not TextViews -->
-
- <TextView
- android:text="label"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:autoText="true"
- android:bufferType="editable"
- android:capitalize="words"
- android:cursorVisible="true"
- android:digits=""
- android:editable="true"
- android:editorExtras="@+id/foobar"
- android:focusable="true"
- android:focusableInTouchMode="true"
- android:imeActionId="@+id/foo"
- android:imeActionLabel=""
- android:imeOptions=""
- android:inputMethod=""
- android:inputType="text"
- android:numeric=""
- android:password="true"
- android:phoneNumber="true"
- android:privateImeOptions="" />
-
- <!-- Various attributes that should be set on EditTexts, not Buttons -->
-
- <Button
- android:id="@+id/button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:cursorVisible="true" />
-
- <CheckedTextView
- android:id="@+id/checkedTextView"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:cursorVisible="true" />
-
- <CheckBox
- android:id="@+id/checkbox"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:cursorVisible="true" />
-
- <RadioButton
- android:id="@+id/radioButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:cursorVisible="true" />
-
- <ToggleButton
- android:id="@+id/toggleButton"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:cursorVisible="true" />
-
-
- <!-- Ok #1 -->
-
- <TextView
- android:text="label"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:bufferType="spannable"
- android:freezesText="true"
- android:editable="false"
- android:inputType="none" />
-
- <!-- Ok #2 -->
-
- <TextView
- android:text="label"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <TextView
- android:id="@+id/dynamictext"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
-
- <TextView
- android:id="@+id/dynamictext"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textIsSelectable="true" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/edit_type.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/edit_type.xml
deleted file mode 100644
index 8f8cf90..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/edit_type.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <!-- Wrong: doesn't specify textPassword -->
-
- <EditText
- android:id="@+id/mypassword"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:inputType="text" >
-
- <requestFocus />
- </EditText>
-
- <!-- OK, specifies textPassword: -->
-
- <EditText
- android:id="@+id/password1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:inputType="text|numberPassword" />
-
- <!-- OK, specifies password: -->
-
- <EditText
- android:id="@+id/password2"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:inputType="text"
- android:password="true" />
-
- <!-- Wrong, doesn't include number -->
-
- <EditText
- android:id="@+id/password_length"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:inputType="text" />
-
- <!-- Wrong, doesn't include URL -->
-
- <EditText
- android:id="@+id/welcome_url"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:inputType="text" />
-
- <!-- Wrong, doesn't include date -->
-
- <EditText
- android:id="@+id/start_date"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:inputType="text" />
-
- <!-- Wrong, doesn't include e-mail -->
-
- <EditText
- android:id="@+id/email_address"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:inputType="text" />
-
- <!-- Wrong, uses wrong password type for PIN -->
-
- <EditText
- android:id="@+id/login_pin"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:inputType="textPassword" />
-
- <EditText
- android:id="@+id/number_of_items"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10" />
-
- <EditText
- style="@style/foo"
- android:id="@+id/number_of_items"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/encoding.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/encoding.xml
deleted file mode 100644
index 390aec4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/encoding.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="iso-latin-1"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/encoding2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/encoding2.xml
deleted file mode 100644
index fe6e092..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/encoding2.xml
+++ /dev/null
@@ -1 +0,0 @@
-<?xml version="1.0" encoding="iso-latin-1"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > </LinearLayout> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/fragment.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/fragment.xml
deleted file mode 100644
index bec72b2..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/fragment.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <fragment
- android:name="android.app.ListFragment"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <fragment
- android:name="android.app.DialogFragment"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:tag="mytag" />
-
- <fragment
- android:id="@+id/fragment3"
- android:name="android.preference.PreferenceFragment"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/fragment2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/fragment2.xml
deleted file mode 100644
index 3a672d1..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/fragment2.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <fragment
- class="my.app.Fragment"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <view
- class="my.app.MyView"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <fragment
- android:name="my.app.Fragment2"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <view
- android:name="test.pkg.TestService"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <view
- class="test.pkg.TestService"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <fragment
- android:name="test.pkg.TestService"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <fragment
- class="test.pkg.TestService"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <fragment
- class="test.pkg.Foo$Bar"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <fragment
- class="test.pkg.Nonexistent"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- tools:ignore="MissingRegistered" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/gridlayout.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/gridlayout.xml
deleted file mode 100644
index 026f673..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/gridlayout.xml
+++ /dev/null
@@ -1,41 +0,0 @@
-<!-- Copyright (C) 2010 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<GridLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:columnCount="2" >
- <Space
- android:layout_row="0"
- android:layout_column="0"
- android:layout_width="109dip"
- android:layout_height="108dip"/>
-
- <Button
- android:text="Button 1"
- android:layout_row="0"
- android:layout_column="1"
- />
-
- <Button
- android:text="Button 2"
- android:layout_row="1"
- android:layout_column="3"
- />
-
-</GridLayout>
-
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/has_children.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/has_children.xml
deleted file mode 100644
index cac27d4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/has_children.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<ListView
- xmlns:android="http://schemas.android.com/apk/res/android"
-
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <ListView
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
-</ListView> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/has_children2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/has_children2.xml
deleted file mode 100644
index bd8c301..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/has_children2.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<ListView
- xmlns:android="http://schemas.android.com/apk/res/android"
-
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <requestFocus/>
-
-</ListView>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/ignores.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/ignores.xml
deleted file mode 100644
index d4be910..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/ignores.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/newlinear"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <!-- Ignored via attribute, should be hidden -->
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button1"
- tools:ignore="HardcodedText" >
- </Button>
-
- <!-- Inherited ignore from parent -->
-
- <LinearLayout
- android:id="@+id/parent"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- tools:ignore="HardcodedText" >
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button2" >
- </Button>
- </LinearLayout>
-
- <!-- Hardcoded text warning ignored through "all" -->
-
- <Button
- android:id="@+id/button3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button3"
- tools:ignore="all" >
- </Button>
-
- <!-- Ignored through item in ignore list -->
-
- <Button
- android:id="@+id/button4"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Hardcoded"
- tools:ignore="NewApi,HardcodedText" >
- </Button>
-
- <!-- Not ignored: should show up as a warning -->
-
- <Button
- android:id="@+id/button5"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Hardcoded"
- tools:ignore="Other" >
- </Button>
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight.xml
deleted file mode 100644
index 196e00b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight.xml
+++ /dev/null
@@ -1,60 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
-
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1.0" />
-
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
-
- android:layout_width="match_parent"
- android:layout_height="match_parent"
-
- android:orientation="vertical">
-
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1.0" />
-
- </LinearLayout>
-
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
-
- android:layout_width="match_parent"
- android:layout_height="match_parent"
-
- android:orientation="vertical">
-
- <Button
- android:layout_width="match_parent"
- android:layout_height="0dip"
- android:layout_weight="1.0" />
-
- </LinearLayout>
-
- <LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/MyStyle"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <Button
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- </LinearLayout>
-
-
-</LinearLayout> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight2.xml
deleted file mode 100644
index 0e7f396..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/inefficient_weight2.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <SeekBar
- android:id="@+id/seekbar"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_gravity="center_vertical"
- android:layout_weight="1"
- android:max="100"
- android:paddingBottom="10dip"
- android:paddingLeft="15dip"
- android:paddingRight="15dip"
- android:paddingTop="10dip"
- android:secondaryProgress="0"
- tools:ignore="InefficientWeight" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/labelfor.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/labelfor.xml
deleted file mode 100644
index 7d4935c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/labelfor.xml
+++ /dev/null
@@ -1,84 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <TextView
- android:id="@+id/textView1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:labelFor="@+id/editText1"
- android:text="Medium Text"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <EditText
- android:id="@+id/editText1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:inputType="textPersonName" >
-
- <requestFocus />
- </EditText>
-
- <TextView
- android:id="@+id/textView2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:labelFor="@+id/autoCompleteTextView1"
- android:text="TextView" />
-
- <AutoCompleteTextView
- android:id="@+id/autoCompleteTextView1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:text="AutoCompleteTextView" />
-
- <TextView
- android:id="@+id/textView3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:labelFor="@+id/multiAutoCompleteTextView1"
- android:text="Large Text"
- android:textAppearance="?android:attr/textAppearanceLarge" />
-
- <MultiAutoCompleteTextView
- android:id="@+id/multiAutoCompleteTextView1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:text="MultiAutoCompleteTextView" />
-
- <EditText
- android:id="@+id/editText2"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:inputType="textPostalAddress" />
-
- <AutoCompleteTextView
- android:id="@+id/autoCompleteTextView2"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:text="AutoCompleteTextView" />
-
- <MultiAutoCompleteTextView
- android:id="@+id/multiAutoCompleteTextView2"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:text="MultiAutoCompleteTextView" />
-
- <EditText
- android:id="@+id/editText20"
- android:hint="Enter your address"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:inputType="textPostalAddress" />
-
-
-</LinearLayout> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/labelfor_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/labelfor_ignore.xml
deleted file mode 100644
index 41d2821..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/labelfor_ignore.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <EditText
- android:id="@+id/editText2"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:ems="10"
- android:inputType="textPostalAddress"
- tools:ignore="LabelFor"/>
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout1.xml
deleted file mode 100644
index efd6be0..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout1.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <include
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- layout="@layout/layout2" />
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout1_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout1_ignore.xml
deleted file mode 100644
index 13bd075..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout1_ignore.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <include
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- layout="@layout/layout2"
- tools:ignore="DuplicateIncludedIds" />
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout2.xml
deleted file mode 100644
index 9fc9c5f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout2.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <RadioButton
- android:id="@+id/radioButton1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="RadioButton" />
-
- <include
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- layout="@layout/layout3" />
-
- <include
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- layout="@layout/layout4" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout3.xml
deleted file mode 100644
index aa5a137..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout3.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <CheckBox
- android:id="@+id/checkBox1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="CheckBox" />
-
-</LinearLayout> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout4.xml
deleted file mode 100644
index 442efd4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/layout4.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/listseparator.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/listseparator.xml
deleted file mode 100644
index ac50ff7..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/listseparator.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-<TextView xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@id/text1"
- style="?android:attr/listSeparatorTextViewStyle" />
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace.xml
deleted file mode 100644
index a984333..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:other="http://foo.bar" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent" orientation="true">
- <Button style="@style/setupWizardOuterFrame" android.text="Button" android:id="@+id/button1" android:layout_width="wrap_content" android:layout_height="wrap_content"></Button>
- <ImageView android:style="@style/bogus" android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@drawable/android_button" android:focusable="false" android:clickable="false" android:layout_weight="1.0" />
- <LinearLayout other:orientation="horizontal"/>
-</LinearLayout>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace2.xml
deleted file mode 100644
index 59001c2..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace2.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout
- xmlns:customprefix="http://schemas.android.com/apk/res/android"
- xmlns:bogus="http://foo.com/bar"
- customprefix:id="@+id/newlinear"
- customprefix:layout_width="match_parent"
- customprefix:layout_height="match_parent"
- customprefix:orientation="vertical"
- orientation="true">
-
- <view class="foo.bar.LinearLayout">
- bogus:orientation="bogus"
- </view>
-
- <foo.bar.LinearLayout
- customprefix:id="@+id/newlinear2"
- customprefix:layout_width="match_parent"
- customprefix:layout_height="match_parent"
- customprefix:orientation="vertical"
- bogus:orientation="bogus"
- orientation="true">
-
- <view class="foo.bar.LinearLayout">
- bogus:orientation="bogus"
- </view>
-
- </foo.bar.LinearLayout>
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace3.xml
deleted file mode 100644
index fcc5aa4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace3.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res/com.example.apicalltest"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <com.example.library.MyView
- android:layout_width="300dp"
- android:layout_height="300dp"
- android:background="#ccc"
- android:paddingBottom="40dp"
- android:paddingLeft="20dp"
- app:exampleColor="#33b5e5"
- app:exampleDimension="24sp"
- app:exampleDrawable="@android:drawable/ic_menu_add"
- app:exampleString="Hello, MyView" />
-
-</FrameLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace4.xml
deleted file mode 100644
index e7ecb06..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/namespace4.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<android.support.v7.widget.GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- xmlns:app="http://schemas.android.com/apk/res/com.example.apicalltest"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- app:columnCount="1"
- tools:context=".MainActivity" >
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- app:layout_column="0"
- app:layout_gravity="center"
- app:layout_row="0"
- android:text="Button" />
-
-</android.support.v7.widget.GridLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/nested_weights.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/nested_weights.xml
deleted file mode 100644
index a375e06..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/nested_weights.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal" >
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <LinearLayout
- android:id="@+id/linearLayout1"
- android:layout_weight="1"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <Button
- android:id="@+id/button3"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="Button" />
- </LinearLayout>
-
- <FrameLayout
- android:id="@+id/frameLayout1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1" >
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
- </FrameLayout>
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/nested_weights2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/nested_weights2.xml
deleted file mode 100644
index 7002b89..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/nested_weights2.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent" >
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:orientation="horizontal" >
-
- <ImageView
- android:layout_width="32dp"
- android:layout_height="32dp"
- android:layout_gravity="center_vertical"
- android:src="@drawable/launcher_icon" />
-
- <TextView
- android:layout_width="0dp"
- android:layout_height="fill_parent"
- android:layout_gravity="center_vertical"
- android:layout_weight="1"
- android:text="test" />
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="fill_parent"
- android:layout_weight="1"
- android:layout_height="0dp"
- android:orientation="vertical" >
- </LinearLayout>
- </LinearLayout>
-
-</FrameLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/note_edit.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/note_edit.xml
deleted file mode 100644
index 0b84439..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/note_edit.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent">
- <include layout="@layout/colorstrip" android:layout_height="@dimen/colorstrip_height" android:layout_width="match_parent"/>
-
- <LinearLayout style="@style/TitleBar" android:id="@+id/header">
- <ImageView style="@style/TitleBarLogo"
- android:contentDescription="@string/description_logo"
- android:src="@drawable/title_logo" />
-
- <View style="@style/TitleBarSpring" />
-
- <ImageView style="@style/TitleBarSeparator" />
- <ImageButton style="@style/TitleBarAction"
- android:id="@+id/btn_title_refresh"
- android:contentDescription="@string/description_refresh"
- android:src="@drawable/ic_title_refresh"
- android:layout_width="wrap_content"
- android:layout_height="42dp"
- android:onClick="onRefreshClick" />
- <ProgressBar style="@style/TitleBarProgressIndicator"
- android:id="@+id/title_refresh_progress"
- android:layout_width="wrap_content"
- android:visibility="visible"/>
-
- <ImageView style="@style/TitleBarSeparator" />
- <ImageButton style="@style/TitleBarAction"
- android:contentDescription="@string/description_search"
- android:src="@drawable/ic_title_search"
- android:layout_width="wrap_content"
- android:layout_height="42dp"
- android:onClick="onSearchClick" />
- </LinearLayout>
-
- <LinearLayout
- android:id="@+id/noteArea"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:layout_margin="5dip">
- <EditText
- android:id="@android:id/text1"
- android:layout_height="fill_parent"
- android:hint="@string/note_hint"
- android:freezesText="true"
- android:gravity="top" android:layout_width="wrap_content" android:layout_weight="1">
- </EditText>
- <EditText
- android:id="@android:id/text2"
- android:layout_height="fill_parent"
- android:freezesText="true"
- android:gravity="top" android:layout_width="wrap_content" android:layout_weight="1">
- <requestFocus />
- </EditText>
- </LinearLayout>
-
- <LinearLayout
- android:orientation="horizontal"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- style="@android:style/ButtonBar">
- <Button
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:onClick="onSaveClick"
- android:text="@string/note_save" />
- <Button
- android:layout_width="0dip"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:onClick="onDiscardClick"
- android:text="@string/note_discard" />
- </LinearLayout>
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/now_playing_after.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/now_playing_after.xml
deleted file mode 100644
index 64f681c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/now_playing_after.xml
+++ /dev/null
@@ -1,53 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/now_playing"
- android:layout_width="fill_parent"
- android:layout_height="@dimen/now_playing_height"
- android:orientation="horizontal">
- <LinearLayout
- android:background="@color/background2"
- android:paddingLeft="14dip"
- android:paddingRight="14dip"
- android:paddingTop="10dip"
- android:paddingBottom="10dip"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:layout_weight="1"
- android:orientation="vertical">
- <TextView
- android:id="@+id/now_playing_title"
- android:duplicateParentState="true"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:textStyle="bold"
- android:textSize="@dimen/text_size_large"
- android:textColor="@color/foreground1"
- android:text="@string/now_playing_after_title"
- android:maxLines="2"
- android:ellipsize="end" />
- <TextView
- android:id="@+id/now_playing_subtitle"
- android:duplicateParentState="true"
- android:layout_width="fill_parent"
- android:layout_height="wrap_content"
- android:paddingTop="3dip"
- android:textColor="@color/foreground2"
- android:textSize="@dimen/text_size_small"
- android:text="@string/now_playing_after_subtitle"
- android:singleLine="true"
- android:ellipsize="end" />
- </LinearLayout>
- <View
- android:layout_width="1px"
- android:layout_height="fill_parent"
- android:background="@android:color/white" />
- <ImageButton
- android:background="@drawable/btn_now_playing_more"
- android:id="@+id/now_playing_more"
- android:src="@drawable/ic_now_playing_logo"
- android:padding="12dip"
- android:layout_width="100mm"
- android:layout_height="120in"
- android:onClick="onNowPlayingLogoClick"
- android:scaleType="center" />
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/onclick.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/onclick.xml
deleted file mode 100644
index 882c035..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/onclick.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="nonexistent"
- android:text="Button" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="wrong1"
- android:text="Button" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="wrong2"
- android:text="Button" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="wrong3"
- android:text="Button" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="wrong4"
- android:text="Button" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="wrong5"
- android:text="Button" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="wrong6"
- android:text="Button" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="ok"
- android:text="Button" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="simple_typo"
- android:text="Button" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="my\u1234method"
- android:text="Button" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="wrong7"
- android:text="Button" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:onClick="@string/ok"
- android:text="Button" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/private.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/private.xml
deleted file mode 100644
index c98797d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/private.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:id="@+id/newlinear" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent">
- <ImageView android:id="@+id/android_logo" android:layout_width="wrap_content" android:layout_height="wrap_content" android:src="@*android:drawable/android_button" android:focusable="false" android:clickable="false" />
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/scrolling.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/scrolling.xml
deleted file mode 100644
index 0bed702..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/scrolling.xml
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<ScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
-
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <ListView
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
- </LinearLayout>
-
-</ScrollView>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simple.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simple.xml
deleted file mode 100644
index d462c69..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simple.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
-
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simple_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simple_ignore.xml
deleted file mode 100644
index 1b3de90..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simple_ignore.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:ignore="MergeRootFrame" />
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simpleinclude.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simpleinclude.xml
deleted file mode 100644
index 4cb994b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/simpleinclude.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <include
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- layout="@layout/simple" />
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/size.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/size.xml
deleted file mode 100644
index e4d4a9b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/size.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <RadioButton
- android:id="@+id/button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <RadioButton
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:text="Button" />
-
- <EditText
- android:id="@+id/edittext"
- android:layout_height="wrap_content"
- android:text="EditText" />
-
- <EditText
- android:id="@+id/edittext2"
- android:text="EditText" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/size2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/size2.xml
deleted file mode 100644
index d06d00f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/size2.xml
+++ /dev/null
@@ -1,43 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- tools:ignore="HardcodedText" >
-
- <Button
- android:id="@+id/button1"
- android:text="Button" />
-
- <Button
- android:id="@+id/button2"
- style="@style/WidthAndHeight"
- android:text="Button" />
-
- <Button
- android:id="@+id/button3"
- style="@style/Width"
- android:text="Button" />
-
- <Button
- android:id="@+id/button4"
- style="@style/MyStyle"
- android:text="Button" />
-
- <Button
- android:id="@+id/button5"
- style="@style/MyStyle.Big"
- android:text="Button" />
-
- <Button
- android:id="@+id/button6"
- style="@style/MyOtherStyle"
- android:text="Button" />
-
- <include
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- layout="@layout/sizeincluded" />
-
-</LinearLayout> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/sizeincluded.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/sizeincluded.xml
deleted file mode 100644
index 5fccff6..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/sizeincluded.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:orientation="vertical" >
-
-</LinearLayout> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/textsize.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/textsize.xml
deleted file mode 100644
index 610867e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/textsize.xml
+++ /dev/null
@@ -1,51 +0,0 @@
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/LinearLayout1"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="14dp" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="14dip" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="14sp" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="@android/dimen/mysizedp" />
-
- <!-- Small -->
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="11sp" />
-
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="6sp" />
-
- <!-- No warnings: wrong attribute, size == 0, etc -->
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:textSize="0sp" />
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:marginTop="5sp" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/too_deep.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/too_deep.xml
deleted file mode 100644
index 7e92008..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/too_deep.xml
+++ /dev/null
@@ -1,85 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
-
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- </LinearLayout>
-
- </LinearLayout>
-
- </LinearLayout>
-
- </LinearLayout>
-
- </LinearLayout>
-
- </LinearLayout>
-
- </LinearLayout>
-
- </LinearLayout>
-
- </LinearLayout>
-
- </LinearLayout>
-
- </LinearLayout>
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/too_many.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/too_many.xml
deleted file mode 100644
index e2dbd6b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/too_many.xml
+++ /dev/null
@@ -1,413 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
-
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- </LinearLayout>
-
- </LinearLayout>
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Ok" />
-
- </LinearLayout>
-
- </LinearLayout>
-
-</FrameLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/unused_namespace.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/unused_namespace.xml
deleted file mode 100644
index f633e4b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/unused_namespace.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<foo.bar.LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:unused1="http://schemas.android.com/apk/res/unused1"
- xmlns:unused2="http://schemas.android.com/apk/res/unused1"
- xmlns:unused3="http://foo.bar.com/foo"
- xmlns:notunused="http://schemas.android.com/apk/res/notunused"
- xmlns:tools="http://schemas.android.com/tools" >
-
- <foo.bar.Button
- notunused:foo="Foo"
- tools:ignore="HardcodedText" >
- </foo.bar.Button>
-
-</foo.bar.LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless.xml
deleted file mode 100644
index c317235..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<merge xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <!-- Neither parent nor child define background: delete is okay -->
-
- <FrameLayout
- android:id="@+id/LinearLayout"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </LinearLayout>
- </FrameLayout>
-
- <!-- Both define background: cannot be deleted -->
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/bg" >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/bg" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </LinearLayout>
- </FrameLayout>
-
- <!-- Only child defines background: delete is okay -->
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/bg" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </LinearLayout>
- </FrameLayout>
-
- <!-- Only parent defines background: delete is okay -->
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/bg" >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <TextView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </LinearLayout>
- </FrameLayout>
-
- <!-- Leaf cannot be deleted because it has a background -->
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/bg" >
- </FrameLayout>
-
- <!-- Useless leaf -->
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
- </FrameLayout>
-</merge>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless2.xml
deleted file mode 100644
index a819036..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless2.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <TabWidget
- android:layout_width="match_parent"
- android:layout_height="wrap_content" />
-
- <FrameLayout
- android:layout_width="match_parent"
- android:layout_height="0px"
- android:layout_weight="1" >
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </FrameLayout>
- </LinearLayout>
-
-</TabHost>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless3.xml
deleted file mode 100644
index 1d9e9b7..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/useless3.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<TableRow
- xmlns:android="http://schemas.android.com/apk/res/android"
- style="@style/keyboard_table_row">
-</TableRow>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong0dp.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong0dp.xml
deleted file mode 100644
index 136329f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong0dp.xml
+++ /dev/null
@@ -1,103 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical"
- tools:ignore="HardcodedText" >
-
- <!-- Vertical Layout -->
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <!-- No weight: Always an error -->
-
- <Button
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="0dp"
- android:text="Button" />
-
- <!--
- 0dp not along the orientation axis is wrong;
- here layout_height is okay, layout_width is not
- -->
-
- <Button
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1.0"
- android:text="Button" />
-
- <!-- OK -->
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="0dp"
- android:layout_weight="1.0"
- android:text="Button" />
- </LinearLayout>
-
- <!-- Horizontal Layout -->
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="horizontal" >
-
- <!-- OK -->
-
- <Button
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1.0"
- android:text="Button" />
-
- <!-- Not OK -->
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="0dp"
- android:layout_weight="1.0"
- android:text="Button" />
- </LinearLayout>
-
- <!-- No orientation specified, so horizontal -->
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <!-- OK -->
-
- <Button
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_weight="1.0"
- android:text="Button" />
-
- <!-- Not OK -->
-
- <Button
- android:layout_width="wrap_content"
- android:layout_height="0dp"
- android:layout_weight="1.0"
- android:text="Button" />
-
- <!-- Check suppressed -->
-
- <Button
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:text="Button"
- tools:ignore="Suspicious0dp" />
- </LinearLayout>
-
-</FrameLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_dimension.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_dimension.xml
deleted file mode 100644
index 79b922b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_dimension.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-
-<HorizontalScrollView
- xmlns:android="http://schemas.android.com/apk/res/android"
-
- android:layout_width="match_parent"
- android:layout_height="match_parent">
-
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent" />
-
-</HorizontalScrollView>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace.xml
deleted file mode 100644
index c6e2143..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/andriod"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <include
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- layout="@layout/layout2" />
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace2.xml
deleted file mode 100644
index 49dc611..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace2.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/Android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <include
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- layout="@layout/layout2" />
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace3.xml
deleted file mode 100644
index 02252b4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace3.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:a="http://schemas.android.com/apk/res/androi"
- a:layout_width="match_parent"
- a:layout_height="match_parent"
- a:orientation="vertical" >
-
- <include
- a:layout_width="wrap_content"
- a:layout_height="wrap_content"
- layout="@layout/layout2" />
-
- <Button
- a:id="@+id/button1"
- a:layout_width="wrap_content"
- a:layout_height="wrap_content"
- a:text="Button" />
-
- <Button
- a:id="@+id/button2"
- a:layout_width="wrap_content"
- a:layout_height="wrap_content"
- a:text="Button" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace4.xml
deleted file mode 100644
index 4142622..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace4.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- This file does *not* have a wrong namespace: it's testdata to make sure we don't complain when "a" is defined for something unrelated -->
-<LinearLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:a="http://something/very/different"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <include
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- layout="@layout/layout2" />
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace5.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace5.xml
deleted file mode 100644
index ce0fc4b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrong_namespace5.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:noturi="tp://schems.android.com/apk/res/com.my.package"
- xmlns:typo1="http://schems.android.com/apk/res/com.my.package"
- xmlns:typo2="http://schems.android.comm/apk/res/com.my.package"
- xmlns:ok="http://foo.bar/res/unrelated"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
-</RelativeLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams.xml
deleted file mode 100644
index 9c8bd5c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="Button" />
-
- <LinearLayout
- android:id="@+id/relativeLayout1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true"
- android:layout_marginLeft="17dp"
- android:layout_marginTop="16dp"
- android:text="Button" />
-
- <TextView
- android:id="@+id/textView1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBottom="@+id/button1"
- android:layout_toRightOf="@+id/button1"
- android:text="Medium Text"
- android:textAppearance="?android:attr/textAppearanceMedium" />
-
- <RadioButton
- android:id="@+id/radioButton1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignLeft="@+id/button1"
- android:layout_below="@+id/button1"
- android:text="RadioButton" />
- </LinearLayout>
- <TableLayout
- android:id="@+id/tableLayout1"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <TableRow
- android:id="@+id/tableRow1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
-
- <Button
- android:id="@+id/button3"
- android:layout_column="0"
- android:layout_span="1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="Button" />
- </TableRow>
-
- <Button
- android:id="@+id/button4"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="Button" />
- </TableLayout>
-
- <GridLayout
- android:id="@+id/gridLayout1"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <Button
- android:id="@+id/button10"
- android:layout_column="0"
- android:layout_row="0"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </GridLayout>
-
-</FrameLayout>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams2.xml
deleted file mode 100644
index 309dffd..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams2.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<merge xmlns:android="http://schemas.android.com/apk/res/android" >
-
- <foo.bar.ActionBarHost
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
-
- <FrameLayout
- android:layout_width="fill_parent"
- android:layout_height="0dp"
- android:layout_weight="1" />
- </foo.bar.ActionBarHost>
-
-</merge>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams3.xml
deleted file mode 100644
index 79173c7..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams3.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_alignParentTop="true" >
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams4.xml
deleted file mode 100644
index 802e215..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams4.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <include
- android:id="@+id/include1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- layout="@layout/wrongparams3" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams5.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams5.xml
deleted file mode 100644
index 947bf48..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams5.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<merge xmlns:android="http://schemas.android.com/apk/res/android" >
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentTop="true"
- android:text="Button" />
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:text="Button" />
-
-</merge>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams6.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams6.xml
deleted file mode 100644
index 8691d7c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams6.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <include
- android:id="@+id/include1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- layout="@layout/wrongparams5" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams_ignore.xml
deleted file mode 100644
index d0e6ff0..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/layout/wrongparams_ignore.xml
+++ /dev/null
@@ -1,92 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="Button" />
-
- <LinearLayout
- android:id="@+id/relativeLayout1"
- android:layout_width="match_parent"
- android:layout_height="wrap_content" >
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_alignParentTop="true"
- android:layout_marginLeft="17dp"
- android:layout_marginTop="16dp"
- android:text="Button"
- tools:ignore="all" />
-
- <TextView
- android:id="@+id/textView1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBottom="@+id/button1"
- android:layout_toRightOf="@+id/button1"
- android:text="Medium Text"
- android:textAppearance="?android:attr/textAppearanceMedium"
- tools:ignore="ObsoleteLayoutParam" />
-
- <RadioButton
- android:id="@+id/radioButton1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignLeft="@+id/button1"
- android:layout_below="@+id/button1"
- android:text="RadioButton"
- tools:ignore="ObsoleteLayoutParam" />
- </LinearLayout>
- <TableLayout
- android:id="@+id/tableLayout1"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <TableRow
- android:id="@+id/tableRow1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" >
-
- <Button
- android:id="@+id/button3"
- android:layout_column="0"
- android:layout_span="1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="Button" />
- </TableRow>
-
- <Button
- android:id="@+id/button4"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_weight="1"
- android:text="Button" />
- </TableLayout>
-
- <GridLayout
- android:id="@+id/gridLayout1"
- android:layout_width="match_parent"
- android:layout_height="match_parent" >
-
- <Button
- android:id="@+id/button10"
- android:layout_column="0"
- android:layout_row="0"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
- </GridLayout>
-
-</FrameLayout>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions.xml
deleted file mode 100644
index 89fa751..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
-
- <item
- android:id="@+id/menu_search"
- android:showAsAction="always|collapseActionView"
- android:actionViewClass="android.widget.SearchView" />
-
- <group android:id="@+id/reader_items">
-
- <item
- android:id="@+id/menu_table_of_contents"
- android:showAsAction="always"
- android:actionLayout="@layout/action_table_of_contents" />
-
- <item
- android:id="@+id/menu_settings"
- android:showAsAction="always" />
-
- <item android:id="@+id/menu_mode"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_buy"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_about"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_share"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_keep"
- android:checkable="true"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_d"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_help"
- android:showAsAction="never" />
-
- </group>
-
- <group android:id="@+id/search_items">
-
- <item
- android:id="@+id/menu_table_of_contents"
- android:showAsAction="always"
- android:actionLayout="@layout/action_table_of_contents" />
-
- <item android:id="@+id/menu_search_exit"
- android:showAsAction="never" />
-
- </group>
-
-</menu>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions2.xml
deleted file mode 100644
index 35b85d4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions2.xml
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
-
- <item
- android:id="@+id/menu_search"
- android:showAsAction="always|collapseActionView"
- android:actionViewClass="android.widget.SearchView" />
-
- <group android:id="@+id/reader_items">
-
- <item
- android:id="@+id/menu_table_of_contents"
- android:showAsAction="always|collapseActionView"
- android:actionLayout="@layout/action_table_of_contents" />
-
- <item
- android:id="@+id/menu_settings"
- android:showAsAction="always|collapseActionView" />
-
- <item android:id="@+id/menu_mode"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_buy"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_about"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_share"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_keep"
- android:checkable="true"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_d"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_help"
- android:showAsAction="never" />
-
- </group>
-
- <group android:id="@+id/search_items">
-
- <item
- android:id="@+id/menu_table_of_contents"
- android:showAsAction="always|collapseActionView"
- android:actionLayout="@layout/action_table_of_contents" />
-
- <item android:id="@+id/menu_search_exit"
- android:showAsAction="never" />
-
- </group>
-
-</menu>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions2_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions2_ignore.xml
deleted file mode 100644
index 47cd32e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu-land/actions2_ignore.xml
+++ /dev/null
@@ -1,64 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools">
-
- <item
- android:id="@+id/menu_search"
- android:showAsAction="always|collapseActionView"
- android:actionViewClass="android.widget.SearchView"
- tools:ignore="AlwaysShowAction" />
-
- <group android:id="@+id/reader_items">
-
- <item
- android:id="@+id/menu_table_of_contents"
- android:showAsAction="always|collapseActionView"
- android:actionLayout="@layout/action_table_of_contents" />
-
- <item
- android:id="@+id/menu_settings"
- android:showAsAction="always|collapseActionView" />
-
- <item android:id="@+id/menu_mode"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_buy"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_about"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_share"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_keep"
- android:checkable="true"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_d"
- android:showAsAction="never" />
-
- <item
- android:id="@+id/menu_help"
- android:showAsAction="never" />
-
- </group>
-
- <group android:id="@+id/search_items">
-
- <item
- android:id="@+id/menu_table_of_contents"
- android:showAsAction="always|collapseActionView"
- android:actionLayout="@layout/action_table_of_contents" />
-
- <item android:id="@+id/menu_search_exit"
- android:showAsAction="never" />
-
- </group>
-
-</menu>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu/menu.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu/menu.xml
deleted file mode 100644
index 4f0839b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu/menu.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android" >
-
- <item
- android:id="@+id/item1"
- android:icon="@drawable/icon1"
- android:title="My title 1">
- </item>
- <item
- android:id="@+id/item2"
- android:icon="@drawable/icon2"
- android:showAsAction="ifRoom"
- android:title="My title 2">
- </item>
-
-</menu> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu/titles.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu/titles.xml
deleted file mode 100644
index a1ae5bb..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/menu/titles.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<menu xmlns:android="http://schemas.android.com/apk/res/android">
- <item android:id="@+id/action_bar_progress_spinner"
- android:showAsAction="always"
- android:background="@null"
- android:selectableItemBackground="@null"
- android:actionLayout="@layout/action_bar_progress_spinner_layout"/>
- <item android:id="@+id/refresh"
- android:title="@string/menu_refresh"
- android:showAsAction="always"
- android:icon="@drawable/ic_menu_refresh"/>
- <item android:id="@+id/menu_plus_one"
- android:showAsAction="always"
- android:icon="@drawable/ic_menu_plus1"/>
-</menu>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/private_key.pem b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/private_key.pem
deleted file mode 100644
index 03b9477..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/private_key.pem
+++ /dev/null
@@ -1,18 +0,0 @@
------BEGIN RSA PRIVATE KEY-----
-Proc-Type: 4,ENCRYPTED
-DEK-Info: DES-EDE3-CBC,77F426A58B274623
-
-FH1NdgJgrX1OGKM0WfzwWUWmLTmfawdaUPeFNJbz1+WJ5DEt1DmC6o0QkXoxIPC
-Te/+FS80gNruYgYIWu4WXWtCSdvSfGI8LP1JZ7hmMCW055J2mLVKT4o6HqAQnHrb
-hTATVG6CB/GdHTFPG3J65qIyTlG50jyzfwZtliMCCAWi+AaAlo5xzUe0DgedytB2
-sFkLq5EiD6066P/LXPH/Z5WJKiMCFOl0Gjwd3M9ohZufnWJPJT5ap2fm7OSJSfa6
-jPREY+UwhPyKkYOc2cWgojj6HrsSQlXPl176b1+31c19hhhRAtDfJBIU2OrOFVk/
-V88/Dm0I+ROyLme0rYfFg8uHz2aIymWEMds5ZKEFTFbBhaWbVYKIX7+82tftnd+P
-2kT15JAK9V27F0p4SRiWQ5RsDkT3rBWWjtk9Rptkrgec9WKoTaO2fT8bPaWFR/M1
-6X7kjMqhLw1sHmsSeDKx0YCWfS+gWh7RPWGQ2EfH2pxoZkWAR5R3cZCEn3Ia1BeV
-UTFWy+DwjEeSrNkO96E0WH1r8204cJAKK8cWS4HSAPMsQPf5cZjIrrAak/9Wupkq
-fnrB0Ae6GFO2gWHYQfbSWdEq6w5+S6XZyTauVyaJAjjIFWmegfaKWHzNvqCWJ4T
-YPsiptUrKz6WWYyhiUrNJQKcyGWHWrwMNIblWqSBNCa8OIVoaZiRibgO1SIafAGAS
-9MDXXVaY6rqx1yfZYDcWVgKGXTJhBXALCeGMWF43bvAmPq3M13QJA0rlO7lAUUF2
-5INqBUeJxZWYxn6tRr9WMty/UcYnPR3YHgt0RDZycvbcqPsU5tHk9Q==
------END RSA PRIVATE KEY----- \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/arrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/arrays.xml
deleted file mode 100644
index dd8e580..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/arrays.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string-array name="security_questions">
- <item>"Oblíbené jídlo?"</item>
- <item>"Město narození."</item>
- <item>"Jméno nejlepšího kamaráda z dětství?"</item>
- <item>"Název střední školy"</item>
- </string-array>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/strings.xml
deleted file mode 100644
index 2830534..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/strings.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="home_title">"Domů"</string>
- <string name="show_all_apps">"Vše"</string>
- <string name="menu_wallpaper">"Tapeta"</string>
- <string name="menu_search">"Hledat"</string>
- <!-- no translation found for menu_settings (1769059051084007158) -->
- <skip />
- <string name="wallpaper_instructions">"Klepnutím na obrázek nastavíte tapetu portrétu"</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/translatedarrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/translatedarrays.xml
deleted file mode 100644
index f20dd3a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-cs/translatedarrays.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<resources>
- <string name="item1">Item1-cs</string>
- <string name="item2">Item2-cs</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de-rDE/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de-rDE/strings.xml
deleted file mode 100644
index 82510ae..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de-rDE/strings.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="home_title">"Startseite"</string>
- <string name="show_all_apps">"Alle"</string>
- <string name="menu_wallpaper">"Bildschirmhintergrund"</string>
- <string name="menu_search">"Suchen"</string>
- <!-- no translation found for menu_settings (1769059051084007158) -->
- <skip />
- <string name="wallpaper_instructions">"Tippen Sie auf Bild, um Porträt-Bildschirmhintergrund einzustellen"</string>
- <string name="continue_skip_label">"Weiter"</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de/strings.xml
deleted file mode 100644
index 055dd52..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de/strings.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="app_name">Unit Test</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de/typos.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de/typos.xml
deleted file mode 100644
index 5108cc9..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-de/typos.xml
+++ /dev/null
@@ -1,14 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <string name="s1">
-
- wo befindet eine ip
-
- </string>
- <string name="s2">(Authorisierungscode!)</string>
- <string name="s3"> zurück gefoobaren!</string>
- <!-- escaped separator -->
- <string name="issue39599">"ü test\nciht zu"</string>
-
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es-rUS/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es-rUS/strings.xml
deleted file mode 100644
index 4de53dd..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es-rUS/strings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="menu_search">"Búsqueda"</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/donottranslate.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/donottranslate.xml
deleted file mode 100644
index f28594c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/donottranslate.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="full_wday_month_day_no_year">EEEE, d MMMM</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/formatstrings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/formatstrings.xml
deleted file mode 100644
index 4ef3d94..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/formatstrings.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="hello">%1$d</string>
- <string name="hello2">%3$d: %1$s, %2$s?</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/formatstrings_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/formatstrings_ignore.xml
deleted file mode 100644
index 0cf7008..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/formatstrings_ignore.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources xmlns:tools="http://schemas.android.com/tools">
- <string name="hello" tools:ignore="StringFormatMatches">%1$d</string>
- <string name="hello2" tools:ignore="StringFormatMatches,StringFormatCount">%3$d: %1$s, %2$s?</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings.xml
deleted file mode 100644
index ae5822a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="home_title">"Casa"</string>
- <string name="show_all_apps">"Todo"</string>
- <string name="menu_wallpaper">"Papel tapiz"</string>
- <string name="menu_search">"Búsqueda"</string>
- <!-- no translation found for menu_settings (1769059051084007158) -->
- <skip />
- <string name="wallpaper_instructions">"Puntee en la imagen para establecer papel tapiz vertical"</string>
-
- <string-array name="security_questions">
- <item>"Comida favorita"</item>
- <item>"Ciudad de nacimiento"</item>
- <item>"Nombre de tu mejor amigo/a de la infancia"</item>
- <item>"Nombre de tu colegio"</item>
- </string-array>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings_ignore.xml
deleted file mode 100644
index 4358448..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings_ignore.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="home_title">"Casa"</string>
- <string name="show_all_apps">"Todo"</string>
- <string name="menu_wallpaper">"Papel tapiz"</string>
- <string name="menu_search">"Búsqueda"</string>
- <!-- no translation found for menu_settings (1769059051084007158) -->
- <skip />
- <string name="wallpaper_instructions">"Puntee en la imagen para establecer papel tapiz vertical"</string>
- <string name="other" tools:ignore="ExtraTranslation">"?"</string>
-
- <string-array name="security_questions" tools:ignore="ExtraTranslation">
- <item>"Comida favorita"</item>
- <item>"Ciudad de nacimiento"</item>
- <item>"Nombre de tu mejor amigo/a de la infancia"</item>
- <item>"Nombre de tu colegio"</item>
- </string-array>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings_locale.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings_locale.xml
deleted file mode 100644
index b485dee..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-es/strings_locale.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2"
- xmlns:tools="http://schemas.android.com/tools"
- tools:locale="es">
- <string name="home_title">"Casa"</string>
- <string name="show_all_apps">"Todo"</string>
- <string name="menu_wallpaper">"Papel tapiz"</string>
- <string name="menu_search">"Búsqueda"</string>
- <!-- no translation found for menu_settings (1769059051084007158) -->
- <skip />
- <string name="wallpaper_instructions">"Puntee en la imagen para establecer papel tapiz vertical"</string>
-
- <string-array name="security_questions">
- <item>"Comida favorita"</item>
- <item>"Ciudad de nacimiento"</item>
- <item>"Nombre de tu mejor amigo/a de la infancia"</item>
- <item>"Nombre de tu colegio"</item>
- </string-array>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-fr/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-fr/strings.xml
deleted file mode 100644
index 85a28c9..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-fr/strings.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <string-array name="test_string_array">
- <item>Test (French)</item>
- </string-array>
-
-</resources> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-it/stringarrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-it/stringarrays.xml
deleted file mode 100644
index 7bd83e9..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-it/stringarrays.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version='1.0' encoding='utf-8'?>
-<resources>
- <string-array name="track_type_desc">
- <item>Pendenza</item>
- </string-array>
- <string-array name="map_density_desc">
- <item>Automatico (mappa leggibile su display HD)</item>
- </string-array>
- <string-array name="cache_size_desc">
- <item>Piccolo (100)</item>
- </string-array>
-</resources> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/arrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/arrays.xml
deleted file mode 100644
index 4495dfd..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/arrays.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<resources>
- <array name="signal_strength">
- <item>@drawable/ic_setups_signal_0</item>
- <item>@drawable/ic_setups_signal_1</item>
- <item>@drawable/ic_setups_signal_2</item>
- <item>@drawable/ic_setups_signal_3</item>
- <item>@drawable/ic_setups_signal_4</item>
- <item>@drawable/extra</item>
- </array>
-</resources>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/arrays_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/arrays_ignore.xml
deleted file mode 100644
index 24e76cd..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/arrays_ignore.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-<resources xmlns:tools="http://schemas.android.com/tools">
- <array name="signal_strength" tools:ignore="InconsistentArrays">
- <item>@drawable/ic_setups_signal_0</item>
- <item>@drawable/ic_setups_signal_1</item>
- <item>@drawable/ic_setups_signal_2</item>
- <item>@drawable/ic_setups_signal_3</item>
- <item>@drawable/ic_setups_signal_4</item>
- <item>@drawable/extra</item>
- </array>
-</resources>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/strings.xml
deleted file mode 100644
index 824df2a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-land/strings.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <!-- Wallpaper -->
- <string name="wallpaper_instructions">Tap image to set landscape wallpaper</string>
-</resources>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nb/typos.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nb/typos.xml
deleted file mode 100644
index 06cec0d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nb/typos.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <!-- No typos -->
- <string name="s1">Dette er en test</string>
- <!-- Plain typos -->
- <string name="s2">Mer morro med Andriod</string>
- <!-- Make capitalization match typo -->
- <string name="s3"> Parallel </string>
- <!-- Markup indirection -->
- <string name="s4"><b>altid</b></string>
- <!-- Typo, match capitalized -->
- <string name="s5">Altid</string>
- <!-- random words, shouldn't flag -->
- <string name="s6">abcdefg qwerty asdf jklm</string>
- <!-- typo, but should only match when capitalized -->
- <string name="s7">Midt-Østen midt-østen</string>
- <!-- Non-ASCII UTF-8 string -->
- <string name="s7">Koding er en spennende karriære</string>
- <string name="internet">"Koble til Internett.</string>
-
-</resources>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nb/typos_locale.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nb/typos_locale.xml
deleted file mode 100644
index ed1edd1..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nb/typos_locale.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources xmlns:tools="http://schemas.android.com/tools"
- tools:locale="nb">
- <!-- Markup indirection -->
- <string name="s4"><b>altid</b></string>
- <!-- Typo, match capitalized -->
- <string name="s5">Altid</string>
-</resources> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nl-rNL/arrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nl-rNL/arrays.xml
deleted file mode 100644
index 36faf96..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nl-rNL/arrays.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string-array name="security_questions">
- <item>"Favoriete eten?"</item>
- <item>"Geboorteplaats?"</item>
- <item>"Naam van middelbare school?"</item>
- </string-array>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nl-rNL/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nl-rNL/strings.xml
deleted file mode 100644
index 1bd9ea2..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values-nl-rNL/strings.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<resources xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
- <string name="home_title">"Start"</string>
- <!-- Commented out in the unit test to generate extra warnings:
- <string name="show_all_apps">"Alles"</string>
- <string name="menu_wallpaper">"Achtergrond"</string>
- -->
- <string name="menu_search">"Zoeken"</string>
- <!-- no translation found for menu_settings (1769059051084007158) -->
- <skip />
- <string name="wallpaper_instructions">"Tik op afbeelding om portretachtergrond in te stellen"</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/analytics.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/analytics.xml
deleted file mode 100644
index 8ea40a8..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/analytics.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<resources>
- <!--Replace placeholder ID with your tracking ID-->
- <string name="ga_trackingId">UA-12345678-1</string>
-
- <!--Enable Activity tracking-->
- <bool name="ga_autoActivityTracking">true</bool>
-
- <!--Enable automatic exception tracking-->
- <bool name="ga_reportUncaughtExceptions">true</bool>
-
- <!-- The screen names that will appear in your reporting -->
- <string name="com.example.app.BaseActivity">Home</string>
- <string name="com.example.app.PrefsActivity">Preferences</string>
- <string name="test.pkg.OnClickActivity">Clicks</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/arrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/arrays.xml
deleted file mode 100644
index de544b3..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/arrays.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-<resources>
- <!-- Choices for Locations in SetupWizard's Set Time and Data Activity -->
- <string-array name="security_questions">
- <item>Favorite food?</item>
- <item>City of birth?</item>
- <item>Best childhood friend\'s name?</item>
- <item>Highschool name?</item>
- </string-array>
-
- <array name="signal_strength">
- <item>@drawable/ic_setups_signal_0</item>
- <item>@drawable/ic_setups_signal_1</item>
- <item>@drawable/ic_setups_signal_2</item>
- <item>@drawable/ic_setups_signal_3</item>
- <item>@drawable/ic_setups_signal_4</item>
- </array>
-</resources>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/arrayusage.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/arrayusage.xml
deleted file mode 100644
index 0b890f7..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/arrayusage.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<resources>
-<string name="my_item">An Item</string>
-<string-array name="my_array">
- <item>@string/my_item</item>
-</string-array>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/buttonbar-values.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/buttonbar-values.xml
deleted file mode 100644
index 4a32e7d..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/buttonbar-values.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <string name="button"> Button </string>
- <string name="ok"> OK </string>
- <string name="cancel"> Cancel </string>
- <string name="resume"> OK </string>
- <string name="giveup"> Cancel </string>
- <string name="resume2"> Ok </string>
- <string name="giveup2">"CANCEL"</string>
- <string name="send"> Send </string>
- <string name="abort">Abort</string>
- <string name="goback">'Back'</string>
-
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/customattr.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/customattr.xml
deleted file mode 100644
index e1ca2d4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/customattr.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<resources>
- <declare-styleable name="ContentFrame">
- <attr name="content" format="reference" />
- <attr name="contentId" format="reference" />
- </declare-styleable>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings-version1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings-version1.xml
deleted file mode 100644
index 4d3e5a7..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings-version1.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="hour_minute_24">%-k:%M</string>
- <string name="numeric_date">%Y-%m-%d</string>
- <string name="month_day_year">%Y %B %-e</string>
- <string translatable="false" name="web_user_agent">
- Foo (Bar %s) Foo/731.11+ (Foo, like Bar) Version/1.2.3 Foo Bar/123.14.4
- </string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings-version2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings-version2.xml
deleted file mode 100644
index d1757f7..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings-version2.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="hour_minute_24">%H:%M</string>
- <string name="numeric_date">%-m/%-e/%Y</string>
- <string name="month_day_year">%B %-e, %Y</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings.xml
deleted file mode 100644
index 6b1985c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="hello">Hello %1$s</string>
- <string name="hello2">Hello %1$s, %2$s?</string>
- <string name="missing">Hello %3$s World</string>
- <string name="score">Score: %1$d</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings2.xml
deleted file mode 100644
index 23291d2..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings2.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="hour_minute_24">%H:%M</string>
- <string name="numeric_wday1_mdy1_time1_wday2_mdy2_time2">%5$s %1$s, %4$s-%2$s-%3$s – %10$s %6$s, %9$s-%7$s-%8$s</string>
- <string name="bogus">%2.99999s</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings3.xml
deleted file mode 100644
index 2424078..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings3.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="multiple_formats_with_percentage">%1$s 3%% %2$s</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings4.xml
deleted file mode 100644
index c4e245e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings4.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="formattest1">"%1$s, %2$tF %3$tR"</string>
- <string name="formattest2">%1$s, %2$tF %3$tR</string>
- <string name="formattest3">"Note: Start point RPM differs by %d%%.\n\n"</string>
- <string name="formattest4">Note: Start point RPM differs by %d%%.\n\n</string>
- <string name="formattest5">%s%% c</string>
- <string name="formattest6">%s%% </string>
- <string name="formattest7">%1$s%%</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings5.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings5.xml
deleted file mode 100644
index 6b14570..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings5.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="gridview_views_count">%d vues</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings_ignore.xml
deleted file mode 100644
index 9834119..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/formatstrings_ignore.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources xmlns:tools="http://schemas.android.com/tools">
- <string name="hello" tools:ignore="StringFormatMatches">Hello %1$s</string>
- <string name="hello2" tools:ignore="StringFormatMatches,StringFormatCount">Hello %1$s, %2$s?</string>
- <string name="missing" tools:ignore="StringFormatCount">Hello %3$s World</string>
- <string name="score">Score: %1$d</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/nontranslatable.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/nontranslatable.xml
deleted file mode 100644
index f608bff..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/nontranslatable.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="dummy" translatable="false">Ignore Me</string>
-</resources>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/nontranslatable2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/nontranslatable2.xml
deleted file mode 100644
index 4fcfdc6..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/nontranslatable2.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="dummy">Ignore Me</string>
-</resources>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/plurals.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/plurals.xml
deleted file mode 100644
index 703a841..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/plurals.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <plurals name="my_plural">
- <item quantity="one">@string/hello</item>
- <item quantity="few">@string/hello</item>
- <item quantity="other">@string/hello</item>
- </plurals>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/pxsp.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/pxsp.xml
deleted file mode 100644
index 7a44201..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/pxsp.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<resources>
- <style name="Style1">
- <item name="android:textSize">50sp</item>
- </style>
- <style name="Style2">
- <item name="android:textSize">50dp</item>
- </style>
- <style name="Style3">
- <item name="android:textSize">50px</item>
- </style>
- <style name="Style4">
- <item name="android:textSize"> 50dip </item>
- </style>
-
- <style name="Style5">
- <item name="android:paddingLeft">@dimen/whats_on_item_padding</item>
- <item name="android:paddingRight"> 50px </item>
- <item name="android:paddingTop">50px</item>
- <item name="android:paddingBottom">50dip</item>
- </style>
-
- <style name="Style6">
- <item name="android:textSize">50mm</item>
- <item name="android:textSize">
- 50in
- </item>
- </style>
-
- <style name="Widget.TabStrip" parent="Widget">
- <item name="android:divider">?android:attr/listDivider</item>
- <item name="android:showDividers">middle</item>
- <item name="android:dividerPadding">0px</item>
- </style>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/sizestyles.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/sizestyles.xml
deleted file mode 100644
index 468974e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/sizestyles.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <style name="WidthAndHeight" parent="@android:attr/textAppearanceMedium">
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">match_parent</item>
- </style>
-
- <style name="Width" parent="@android:attr/textAppearanceMedium">
- <item name="android:layout_width">match_parent</item>
- </style>
-
- <style name="MyStyle" parent="@style/WidthAndHeight"></style>
- <style name="MyStyle.Big"></style>
- <style name="MyOtherStyle" parent="@style/MyStyle.Big"></style>
-
-</resources> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/stringarrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/stringarrays.xml
deleted file mode 100644
index 6405580..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/stringarrays.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string-array name="map_density_desc">
- <item>Automatic (readable map on HD displays)</item>
- <item>1 map pixel = 1 screen pixel</item>
- <item>1 map pixel = 1.25 screen pixels</item>
- <item>1 map pixel = 1.5 screen pixels</item>
- <item>1 map pixel = 2 screen pixels</item>
- </string-array>
- <string-array name="spatial_resolution_desc">
- <item>5m/yd (fine, default)</item>
- </string-array>
-</resources> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings.xml
deleted file mode 100644
index 5aec951..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2007 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-
-<resources>
- <!-- Home -->
- <string name="home_title">Home Sample</string>
- <string name="show_all_apps">All</string>
-
- <!-- Home Menus -->
- <string name="menu_wallpaper">Wallpaper</string>
- <string name="menu_search">Search</string>
- <string name="menu_settings">Settings</string>
- <string name="dummy" translatable="false">Ignore Me</string>
-
- <!-- Wallpaper -->
- <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string>
-</resources>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings2.xml
deleted file mode 100644
index bce9e32..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings2.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="hello">Hello</string>
-</resources>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings3.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings3.xml
deleted file mode 100644
index 6da33ae..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings3.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="MissingTranslation">
-
- <string name="test_string">Test (English)</string>
-
- <string-array name="test_string_array">
- <item>@string/test_string</item>
- </string-array>
-
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings4.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings4.xml
deleted file mode 100644
index 76d88a4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings4.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources xmlns:tools="http://schemas.android.com/tools">
- <string name="hello">Hello</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings_ignore.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings_ignore.xml
deleted file mode 100644
index a69d4c8..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/strings_ignore.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources xmlns:tools="http://schemas.android.com/tools">
- <!-- Home -->
- <string name="home_title">Home Sample</string>
- <string name="show_all_apps" tools:ignore="MissingTranslation">All</string>
-
- <!-- Home Menus -->
- <string name="menu_wallpaper" tools:ignore="MissingTranslation">Wallpaper</string>
- <string name="menu_search">Search</string>
- <string name="menu_settings" tools:ignore="all">Settings</string>
- <string name="dummy" translatable="false">Ignore Me</string>
-
- <!-- Wallpaper -->
- <string name="wallpaper_instructions">Tap picture to set portrait wallpaper</string>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/stylecycle.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/stylecycle.xml
deleted file mode 100644
index 448eb9c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/stylecycle.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources xmlns:android="http://schemas.android.com/apk/res/android">
- <style name="PropertyToggle" parent="@style/PropertyToggle.Base"></style>
- <style name="PropertyToggle.Base"></style>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles.xml
deleted file mode 100644
index 34e2d6f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
-<style name="DetailsPage_BuyButton" parent="@style/DetailsPage_Button">
- <item name="android:textColor">@color/buy_button</item>
- <item name="android:background">@drawable/details_page_buy_button</item>
-</style>
-
-<style name="DetailsPage_EditorialBuyButton" parent="@style/DetailsPage_EditorialBuyButton" />
-<!-- Should have been:
-<style name="DetailsPage_EditorialBuyButton" parent="@style/DetailsPage_BuyButton" />
--->
-
-</resources>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles2.xml
deleted file mode 100644
index 45422cb..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/styles2.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<resources xmlns:android="http://schemas.android.com/apk/res/android">
- <style android:name="MyStyle" parent="android:Theme.Light">
- <!-- if the minSdk level is less then 11, then this should be a lint error, since android:actionBarStyle is since API 11,
- unless this is in a -v11 (or better) resource folder -->
- <item name="android:actionBarStyle">...</item>
- <item name="android:textColor">#999999</item>
- </style>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/themes.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/themes.xml
deleted file mode 100644
index eba1c3c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/themes.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<resources xmlns:android="http://schemas.android.com/apk/res/android">
-
- <style name="MyTheme" parent="@android:style/Theme">
- <item name="android:layout_width">wrap_content</item>
- <item name="android:layout_height">wrap_content</item>
- </style>
-
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/themes2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/themes2.xml
deleted file mode 100644
index b587923..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/themes2.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<resources xmlns:android="http://schemas.android.com/apk/res/android">
-
- <style name="MyStyle" parent="@style/Theme.Holo.Light"></style>
- <style name="MyStyle.Big"></style>
- <style name="MyOtherStyle" parent="@style/MyStyle.Big">
- <item name="android:layout_width">wrap_content</item>
- <item name="android:layout_height">wrap_content</item>
- </style>
-
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/translatedarrays.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/translatedarrays.xml
deleted file mode 100644
index 4707734..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/translatedarrays.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-<resources>
- <string name="item1">Item1</string>
- <string name="item2">Item2</string>
- <string-array name="myarray">
- <item>@string/item1</item>
- <item>@string/item2</item>
- </string-array>
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/typography.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/typography.xml
deleted file mode 100644
index 02ffb1c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/typography.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <string name="home_title">Home 'Sample'</string>
- <string name="show_all_apps">"All"</string>
- <string name="show_all_apps2">Show "All"</string>
- <string name="escaped">Skip \"All\"</string>
- <string name="single">Android's</string>
- <string name="copyright">(c) 2011</string>
- <string name="badquotes1">`First'</string>
- <string name="badquotes2">``second''</string>
- <string name="notbadquotes">Type Option-` then 'Escape'</string>
- <string name="fraction1">5 1/2 times</string>
- <string name="fraction4">1/4 times</string>
- <string name="notfraction">51/2 times, 1/20</string>
- <string name="ellipsis">40 times...</string>
- <string name="notellipsis">40 times.......</string>
- <string name="ndash">For ages 3-5</string>
- <string name="ndash2">Copyright 2007 - 2011</string>
- <string name="nontndash">x-y</string>
- <string name="mdash">Not found -- please try again</string>
- <string name="nontndash">----</string>
- <string name="notdirectional">A's and B's</string>
- <string-array name="typography">
- <item>Ages 3-5</item>
- <item>Age 5 1/2</item>
- </string-array>
- <string name="ndash">X Y Z: 10 10 -1</string>
- <string name="ga_trackingId">UA-0000-0</string>
-</resources>
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/typos.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/typos.xml
deleted file mode 100644
index dd24812..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/res/values/typos.xml
+++ /dev/null
@@ -1,25 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
- <!-- No typos -->
- <string name="s1">Home Sample</string>
- <!-- Plain typos -->
- <string name="s2">Andriod activites!</string>
- <!-- Make capitalization match typo -->
- <string name="s3"> (Cmoputer </string>
- <!-- Markup indirection -->
- <string name="s4"><b>throught</b></string>
- <!-- Typo, match capitalized -->
- <string name="s5">Seach</string>
- <!-- random words, shouldn't flag -->
- <string name="s6">abcdefg qwerty asdf jklm</string>
- <!-- typo, but should only match when capitalized -->
- <string name="s7">Tuscon tuscon</string>
- <!-- case changes only: valid -->
- <string name="s8">OK Cancel dialog with a long message</string>
- <!-- case changes only: invalid -->
- <string name="dlg_button_ok">Ok</string>
- <!-- escaped separator -->
- <string name="issue39599">"Please take a moment\nto rate ^1"</string>
- <!-- escaped separator 2 -->
- <string name="issue39599_2">"\nto</string>
-</resources> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/my/pkg/Test.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/my/pkg/Test.java.txt
deleted file mode 100644
index 3905b8c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/my/pkg/Test.java.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-package my.pgk;
-
-class Test {
- private static String s = " R.id.button1 \" "; // R.id.button1 should not be considered referenced
- static {
- System.out.println(R.id.button2);
- char c = '"';
- System.out.println(R.id.linearLayout1);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/pkg1/Class1.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/pkg1/Class1.java.txt
deleted file mode 100644
index 193ff3c..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/pkg1/Class1.java.txt
+++ /dev/null
@@ -1,29 +0,0 @@
-package pkg1;
-
-public class Class1 {
- void method() {
- }
-
- void method2(int foo) {
- }
-
- void method3() {
- }
-
- void method4() {
- }
-
- void method5() {
- }
-
- void method6() {
- }
-
- void method7() {
- }
-
- public static class Class4 extends Class1 {
- void method() { // Not an error: same package
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/pkg2/Class2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/pkg2/Class2.java.txt
deleted file mode 100644
index 651c021..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/pkg2/Class2.java.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-package pkg2;
-
-import android.annotation.SuppressLint;
-import pkg1.Class1;
-
-public class Class2 extends Class1 {
- void method() { // Flag this as an accidental override
- }
-
- void method2(String foo) { // not an override: different signature
- }
-
- static void method4() { // not an override: static
- }
-
- private void method3() { // not an override: private
- }
-
- protected void method5() { // not an override: protected
- }
-
- public void method6() { // not an override: public
- }
-
- @SuppressLint("DalvikOverride")
- public void method7() { // suppressed: no warning
- }
-
- public class Class3 extends Object {
- void method() { // Not an override: not a subclass
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionBarTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionBarTest.java.txt
deleted file mode 100644
index 217f3b6..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionBarTest.java.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.view.Menu;
-import android.view.MenuInflater;
-
-public class ActionBarTest extends Activity {
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- MenuInflater inflater = getMenuInflater();
- inflater.inflate(R.menu.menu, menu);
- return true;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest1.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest1.java.txt
deleted file mode 100644
index deeffde..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest1.java.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-package test.pkg;
-
-import android.view.MenuItem;
-
-public class ActionTest1 {
- public void foo() {
- System.out.println(MenuItem.SHOW_AS_ACTION_ALWAYS);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest1_ignore.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest1_ignore.java.txt
deleted file mode 100644
index 5fea6be..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest1_ignore.java.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-package test.pkg;
-
-import android.view.MenuItem;
-
-public class ActionTest1 {
- @SuppressLint("AlwaysShowAction")
- public void foo() {
- System.out.println(MenuItem.SHOW_AS_ACTION_ALWAYS);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest2.java.txt
deleted file mode 100644
index 2d5df6f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ActionTest2.java.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-package test.pkg;
-
-import android.view.MenuItem;
-
-public class ActionTest2 {
- public void foo() {
- System.out.println(MenuItem.SHOW_AS_ACTION_IF_ROOM);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/BadImport.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/BadImport.java.txt
deleted file mode 100644
index f5b4dd0..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/BadImport.java.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.R;
-import android.widget.*;
-
-public class BadImport {
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/CustomViewTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/CustomViewTest.java.txt
deleted file mode 100644
index 1862ccc..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/CustomViewTest.java.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-package test.pkg;
-
-import test.pkg.Intermediate.IntermediateCustomV;
-
-public class CustomViewTest extends IntermediateCustomV {
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Foo.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Foo.java.txt
deleted file mode 100644
index 6e16a72..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Foo.java.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-// http://code.google.com/p/projectlombok/issues/detail?id=415
-package test.pkg;
-public class X {
- public void X(Y parent) {
- parent.new Z(parent.getW()).execute();
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Hidden.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Hidden.java.txt
deleted file mode 100644
index 847cd88..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Hidden.java.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-package test.pkg;
-
-public class Hidden {
- // Innocent comment...?
- /* \u002a\u002f static { System.out.println("I'm executed on class load"); } \u002f\u002a */
- /* \u002A\U002F static { System.out.println("I'm executed on class load"); } \u002f\u002a */
- /* Normal \\u002A\U002F */ // OK
- static {
- String s = "\u002a\u002f"; // OK
- }
- // STOPSHIP
- /* We must STOPSHIP! */
- String x = "STOPSHIP"; // OK
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ImportFrameActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ImportFrameActivity.java.txt
deleted file mode 100644
index 510dadc..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ImportFrameActivity.java.txt
+++ /dev/null
@@ -1,13 +0,0 @@
-package test.pkg;
-
-import foo.bar.R;
-import android.app.Activity;
-import android.os.Bundle;
-
-public class ImportFrameActivity extends Activity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.simple);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/InflaterTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/InflaterTest.java.txt
deleted file mode 100644
index 5a4e346..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/InflaterTest.java.txt
+++ /dev/null
@@ -1,65 +0,0 @@
-package test.pkg;
-
-import com.example.includetest.R;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.Button;
-
-@SuppressWarnings("unused")
-public class InflaterTest extends Activity {
- private LayoutInflater mInflater;
- private View mRootView;
-
- private LayoutInflater getInflater() {
- if (mInflater == null) {
- mInflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
- }
- return mInflater;
- }
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- }
-
- public void testInflate1() {
- View.inflate(this, R.layout.size1, null);
- }
-
- public void testInflate2() {
- mRootView = getInflater().inflate(R.layout.size2, null);
- }
-
- public void testInflate4() {
- getInflater().inflate(R.layout.size3, null, false);
- }
-
- public void testInflate5() {
- int mylayout = R.layout.size4;
- getInflater().inflate(mylayout, null, false);
- }
-
- public void testNotNull(ViewGroup root) {
- getInflater().inflate(R.layout.size5, root, false); // Should be flagged
- }
-
- public void testInflate6() {
- int mylayout = R.layout.size7;
- View.inflate(this, mylayout, null);
- }
-
- public class MyButton extends Button {
- public MyButton(Context context) {
- super(context);
- }
-
- public void test() {
- inflate(getContext(), R.layout.size6, null);
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/JavaPerformanceTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/JavaPerformanceTest.java.txt
deleted file mode 100644
index a8caccb..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/JavaPerformanceTest.java.txt
+++ /dev/null
@@ -1,195 +0,0 @@
-package test.pkg;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Rect;
-import android.util.AttributeSet;
-import android.widget.Button;
-/** Some test data for the JavaPerformanceDetector */
-@SuppressWarnings("unused")
-public class JavaPerformanceTest extends Button {
- public JavaPerformanceTest(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- private Rect cachedRect;
-
- @Override
- protected void onDraw(android.graphics.Canvas canvas) {
- super.onDraw(canvas);
-
- // Various allocations:
- new String("foo");
- String s = new String("bar");
-
- // This one should not be reported:
- @SuppressLint("DrawAllocation")
- Integer i = new Integer(5);
-
- // Cached object initialized lazily: should not complain about these
- if (cachedRect == null) {
- cachedRect = new Rect(0, 0, 100, 100);
- }
- if (cachedRect == null || cachedRect.width() != 50) {
- cachedRect = new Rect(0, 0, 50, 100);
- }
-
- boolean b = Boolean.valueOf(true); // auto-boxing
- dummy(1, 2);
-
- // Non-allocations
- super.animate();
- dummy2(1, 2);
- int x = 4 + '5';
-
- // This will involve allocations, but we don't track
- // inter-procedural stuff here
- someOtherMethod();
- }
-
- void dummy(Integer foo, int bar) {
- dummy2(foo, bar);
- }
-
- void dummy2(int foo, int bar) {
- }
-
- void someOtherMethod() {
- // Allocations are okay here
- new String("foo");
- String s = new String("bar");
- boolean b = Boolean.valueOf(true); // auto-boxing
-
- // Sparse array candidates
- Map<Integer, String> myMap = new HashMap<Integer, String>();
- // Should use SparseBooleanArray
- Map<Integer, Boolean> myBoolMap = new HashMap<Integer, Boolean>();
- // Should use SparseIntArray
- Map<Integer, Integer> myIntMap = new java.util.HashMap<Integer, Integer>();
-
- // This one should not be reported:
- @SuppressLint("UseSparseArrays")
- Map<Integer, Object> myOtherMap = new HashMap<Integer, Object>();
- }
-
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec,
- boolean x) { // wrong signature
- new String("not an error");
- }
-
- protected void onMeasure(int widthMeasureSpec) { // wrong signature
- new String("not an error");
- }
-
- protected void onLayout(boolean changed, int left, int top, int right,
- int bottom, int wrong) { // wrong signature
- new String("not an error");
- }
-
- protected void onLayout(boolean changed, int left, int top, int right) {
- // wrong signature
- new String("not an error");
- }
-
- @Override
- protected void onLayout(boolean changed, int left, int top, int right,
- int bottom) {
- new String("flag me");
- }
-
- @SuppressWarnings("null") // not real code
- @Override
- protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
- new String("flag me");
-
- // Forbidden factory methods:
- Bitmap.createBitmap(100, 100, null);
- android.graphics.Bitmap.createScaledBitmap(null, 100, 100, false);
- BitmapFactory.decodeFile(null);
- Canvas canvas = null;
- canvas.getClipBounds(); // allocates on your behalf
- canvas.getClipBounds(null); // NOT an error
-
- final int layoutWidth = getWidth();
- final int layoutHeight = getHeight();
- if (mAllowCrop && (mOverlay == null || mOverlay.getWidth() != layoutWidth ||
- mOverlay.getHeight() != layoutHeight)) {
- mOverlay = Bitmap.createBitmap(layoutWidth, layoutHeight, Bitmap.Config.ARGB_8888);
- mOverlayCanvas = new Canvas(mOverlay);
- }
-
- if (widthMeasureSpec == 42) {
- throw new IllegalStateException("Test"); // NOT an allocation
- }
-
- // More lazy init tests
- boolean initialized = false;
- if (!initialized) {
- new String("foo");
- initialized = true;
- }
-
- // NOT lazy initialization
- if (!initialized || mOverlay == null) {
- new String("foo");
- }
- }
-
- void factories() {
- Integer i1 = new Integer(42);
- Long l1 = new Long(42L);
- Boolean b1 = new Boolean(true);
- Character c1 = new Character('c');
- Float f1 = new Float(1.0f);
- Double d1 = new Double(1.0);
-
- // The following should not generate errors:
- Object i2 = new foo.bar.Integer(42);
- Integer i3 = Integer.valueOf(42);
- }
-
- private boolean mAllowCrop;
- private Canvas mOverlayCanvas;
- private Bitmap mOverlay;
-
- @Override
- public void layout(int l, int t, int r, int b) {
- // Using "this." to reference fields
- if (this.shader == null)
- this.shader = new LinearGradient(0, 0, getWidth(), 0, GRADIENT_COLORS, null,
- TileMode.REPEAT);
- }
-
- @Override
- public void layout(int l, int t, int r, int b) {
- int width = getWidth();
- int height = getHeight();
-
- if ((shader == null) || (lastWidth != width) || (lastHeight != height))
- {
- lastWidth = width;
- lastHeight = height;
-
- shader = new LinearGradient(0, 0, width, 0, GRADIENT_COLORS, null, TileMode.REPEAT);
- }
- }
-
- @Override
- public void layout(int l, int t, int r, int b) {
- if ((shader == null) || (lastWidth != getWidth()) || (lastHeight != getHeight())) {
- }
- }
-
- public void inefficientSparseArray() {
- new SparseArray<Integer>(); // Use SparseIntArray instead
- new SparseArray<Long>(); // Use SparseLongArray instead
- new SparseArray<Boolean>(); // Use SparseBooleanArray instead
- new SparseArray<Object>(); // OK
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/NonInternationalizedSmsDetectorTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/NonInternationalizedSmsDetectorTest.java.txt
deleted file mode 100644
index 354f5bf..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/NonInternationalizedSmsDetectorTest.java.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-package foo.bar;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.telephony.SmsManager;
-
-public class NonInternationalizedSmsDetectorTest {
- private void sendLocalizedMessage(Context context) {
- // Don't warn here
- SmsManager sms = SmsManager.getDefault();
- sms.sendTextMessage("+1234567890", null, null, null, null);
- }
-
- private void sendAlternativeCountryPrefix(Context context) {
- // Do warn here
- SmsManager sms = SmsManager.getDefault();
- sms.sendMultipartTextMessage("001234567890", null, null, null, null);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/NotificationTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/NotificationTest.java.txt
deleted file mode 100644
index b03f7a8..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/NotificationTest.java.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-package test.pkg;
-
-import android.app.Notification;
-import android.app.Notification.Builder;
-import android.content.Context;
-import android.graphics.Bitmap;
-
-@SuppressWarnings({ "deprecation", "unused", "javadoc" })
-class NotificationTest {
- public void test1() {
- Notification notification = new Notification(R.drawable.icon1, "Test1", 0);
- }
-
- public void test2() {
- int resource = R.drawable.icon2;
- Notification notification = new Notification(resource, "Test1", 0);
- }
-
- public void test3() {
- int icon = R.drawable.icon3;
- CharSequence tickerText = "Hello";
- long when = System.currentTimeMillis();
- Notification notification = new Notification(icon, tickerText, when);
- }
-
- public void test4(Context context, String sender, String subject, Bitmap bitmap) {
- Notification notification = new Notification.Builder(context)
- .setContentTitle("New mail from " + sender.toString())
- .setContentText(subject).setSmallIcon(R.drawable.icon4)
- .setLargeIcon(bitmap).build();
- }
-
- public void test5(Context context, String sender, String subject, Bitmap bitmap) {
- Notification notification = new Builder(context)
- .setContentTitle("New mail from " + sender.toString())
- .setContentText(subject).setSmallIcon(R.drawable.icon5)
- .setLargeIcon(bitmap).build();
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/PasteError.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/PasteError.java.txt
deleted file mode 100644
index b12b56b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/PasteError.java.txt
+++ /dev/null
@@ -1,109 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.view.View;
-
-public class PasteError extends Activity {
- protected void ok() {
- Button button1 = (Button) findViewById(R.id.textView1);
- mView2 = findViewById(R.id.textView2);
- View view3 = findViewById(R.id.activity_main);
- }
-
- protected void error() {
- View view1 = findViewById(R.id.textView1);
- View view2 = findViewById(R.id.textView1);
- View view3 = findViewById(R.id.textView2);
- }
-
- protected void ok2() {
- View view1;
- if (true) {
- view1 = findViewById(R.id.textView1);
- } else {
- view1 = findViewById(R.id.textView1);
- }
- }
-
- @SuppressLint("CutPasteId")
- protected void suppressed() {
- View view1 = findViewById(R.id.textView1);
- View view2 = findViewById(R.id.textView1);
- }
-
- private void ok3() {
- if (view == null || view.findViewById(R.id.city_name) == null) {
- view = mInflater.inflate(R.layout.city_list_item, parent, false);
- }
- TextView name = (TextView) view.findViewById(R.id.city_name);
- }
-
- private void ok4() {
- mPrevAlbumWrapper = mPrevTrackLayout.findViewById(R.id.album_wrapper);
- mNextAlbumWrapper = mNextTrackLayout.findViewById(R.id.album_wrapper);
- }
-
- @Override
- public View getView(int position, View convertView, ViewGroup parent) {
- View listItem = convertView;
- if (getItemViewType(position) == VIEW_TYPE_HEADER) {
- TextView header = (TextView) listItem.findViewById(R.id.name);
- } else if (getItemViewType(position) == VIEW_TYPE_BOOLEAN) {
- TextView filterName = (TextView) listItem.findViewById(R.id.name);
- } else {
- TextView filterName = (TextView) listItem.findViewById(R.id.name);
- }
- }
-
- protected void ok_branch_1() {
- if (true) {
- view1 = findViewById(R.id.textView1);
- } else {
- view2 = findViewById(R.id.textView1);
- }
- }
-
- protected void error_branch_1() {
- if (true) {
- view1 = findViewById(R.id.textView1);
- }
- if (true) {
- view2 = findViewById(R.id.textView1);
- }
- }
-
- protected void error_branch_2() {
- view1 = findViewById(R.id.textView1);
- if (true) {
- view2 = findViewById(R.id.textView1);
- }
- }
-
- protected void error_branch_3() {
- view1 = findViewById(R.id.textView1);
- if (true) {
- } else {
- view2 = findViewById(R.id.textView1);
- }
- }
-
- protected void error_branch_4() {
- view1 = findViewById(R.id.textView1);
- if (true) {
- } else {
- if (true) {
- view2 = findViewById(R.id.textView1);
- }
- }
- }
-
- protected void ok_branch_2() {
- if (true) {
- view1 = findViewById(R.id.textView1);
- } else {
- if (true) {
- view2 = findViewById(R.id.textView1);
- }
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SdCardTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SdCardTest.java.txt
deleted file mode 100644
index 2087857..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SdCardTest.java.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-package test.pkg;
-
-import java.io.File;
-
-import android.content.Intent;
-import android.net.Uri;
-
-/**
- * Ignore comments - create("/sdcard/foo")
- */
-public class SdCardTest {
- private static final boolean PROFILE_STARTUP = true;
- private static final String SDCARD_TEST_HTML = "/sdcard/test.html";
- public static final String SDCARD_ROOT = "/sdcard";
- public static final String PACKAGES_PATH = "/sdcard/o/packages/";
- File deviceDir = new File("/sdcard/vr");
-
- public SdCardTest() {
- if (PROFILE_STARTUP) {
- android.os.Debug.startMethodTracing("/sdcard/launcher");
- }
- if (new File("/sdcard").exists()) {
- }
- String FilePath = "/sdcard/" + new File("test");
- System.setProperty("foo.bar", "file://sdcard");
-
-
- Intent intent = new Intent(Intent.ACTION_PICK);
- intent.setDataAndType(Uri.parse("file://sdcard/foo.json"), "application/bar-json");
- intent.putExtra("path-filter", "/sdcard(/.+)*");
- intent.putExtra("start-dir", "/sdcard");
- String mypath = "/data/data/foo";
- String base = "/data/data/foo.bar/test-profiling";
- String s = "file://sdcard/foo";
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SetJavaScriptEnabled.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SetJavaScriptEnabled.java.txt
deleted file mode 100644
index ad8383a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SetJavaScriptEnabled.java.txt
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.company.something;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.webkit.WebView;
-
-public class HelloWebApp extends Activity {
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- WebView webView = (WebView)findViewById(R.id.webView);
- webView.getSettings().setJavaScriptEnabled(true); // bad
- webView.getSettings().setJavaScriptEnabled(false); // good
- webView.loadUrl("file:///android_asset/www/index.html");
- }
-
- // Test Suppress
- // Constructor: See issue 35588
- @SuppressLint("SetJavaScriptEnabled")
- public HelloWebApp() {
- WebView webView = (WebView)findViewById(R.id.webView);
- webView.getSettings().setJavaScriptEnabled(true); // bad
- webView.getSettings().setJavaScriptEnabled(false); // good
- webView.loadUrl("file:///android_asset/www/index.html");
- }
-} \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest.java.txt
deleted file mode 100644
index 5261e34..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest.java.txt
+++ /dev/null
@@ -1,66 +0,0 @@
-package foo.bar;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.widget.Toast;
-
-public class SharedPrefsText {
- // OK 1
- public void onCreate1(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
- SharedPreferences.Editor editor = preferences.edit();
- editor.putString("foo", "bar");
- editor.putInt("bar", 42);
- editor.commit();
- }
-
- // OK 2
- public void onCreate2(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
- SharedPreferences.Editor editor = preferences.edit();
- editor.putString("foo", "bar");
- editor.putInt("bar", 42);
- if (apply) {
- editor.apply();
- }
- }
-
- // OK 3
- public boolean test1(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
- SharedPreferences.Editor editor = preferences.edit();
- editor.putString("foo", "bar");
- editor.putInt("bar", 42);
- return editor.apply();
- }
-
- // Not a bug
- public void test(Foo foo) {
- Bar bar1 = foo.edit();
- Bar bar2 = Foo.edit();
- Bar bar3 = edit();
- SharedPreferences.Editor editor = preferences.edit(42);
- apply();
- }
-
- // Bug
- public void bug1(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
- SharedPreferences.Editor editor = preferences.edit();
- editor.putString("foo", "bar");
- editor.putInt("bar", 42);
- }
-
- // Constructor test
- public SharedPrefsText(Context context) {
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
- SharedPreferences.Editor editor = preferences.edit();
- editor.putString("foo", "bar");
- }
- }
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest2.java.txt
deleted file mode 100644
index 20c3a21..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest2.java.txt
+++ /dev/null
@@ -1,19 +0,0 @@
-package test.pkg;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-
-@SuppressWarnings("unused")
-public class SharedPrefsTest2 extends Activity {
- public void test1(SharedPreferences preferences) {
- SharedPreferences.Editor editor = preferences.edit();
- }
-
- public void test2(SharedPreferences preferences) {
- Editor editor = preferences.edit();
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest3.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest3.java.txt
deleted file mode 100644
index e5baa00..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest3.java.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-package test.pkg;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.*;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-
-@SuppressWarnings("unused")
-public class SharedPrefsTest3 extends Activity {
- public void test(SharedPreferences preferences) {
- Editor editor = preferences.edit();
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest4.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest4.java.txt
deleted file mode 100644
index 28de959..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest4.java.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-package test.pkg;
-
-import android.annotation.SuppressLint;
-import android.app.Activity;
-import android.content.SharedPreferences;
-import foo.bar.Editor;
-import android.os.Bundle;
-import android.preference.PreferenceManager;
-
-@SuppressWarnings("unused")
-public class SharedPrefsTest4 extends Activity {
- public void test(SharedPreferences preferences) {
- Editor editor = preferences.edit();
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest5.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest5.java.txt
deleted file mode 100644
index f005162..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SharedPrefsTest5.java.txt
+++ /dev/null
@@ -1,54 +0,0 @@
-package test.pkg;
-
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.content.SharedPreferences.Editor;
-import android.preference.PreferenceManager;
-
-@SuppressWarnings("unused")
-class SharedPrefsTest5 {
- SharedPreferences mPreferences;
- private static final String PREF_FOO = "foo";
- private static final String PREF_BAZ = "bar";
-
- private void wrong() {
- // Field reference to preferences
- mPreferences.edit().putString(PREF_FOO, "bar");
- mPreferences.edit().remove(PREF_BAZ).remove(PREF_FOO);
- }
-
- private void ok() {
- mPreferences.edit().putString(PREF_FOO, "bar").commit();
- mPreferences.edit().remove(PREF_BAZ).remove(PREF_FOO).commit();
- }
-
- private void wrong2(SharedPreferences preferences) {
- preferences.edit().putString(PREF_FOO, "bar");
- preferences.edit().remove(PREF_BAZ).remove(PREF_FOO);
- }
-
- private void wrong3(Context context) {
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
- preferences.edit().putString(PREF_FOO, "bar");
- preferences.edit().remove(PREF_BAZ).remove(PREF_FOO);
- }
-
- private void wrong4(Context context) {
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
- Editor editor = preferences.edit().putString(PREF_FOO, "bar");
- }
-
- private void ok2(Context context) {
- SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
- preferences.edit().putString(PREF_FOO, "bar").commit();
- }
-
- private final SharedPreferences mPrefs;
-
- public void ok3() {
- final SharedPreferences.Editor editor = mPrefs.edit().putBoolean(
- PREF_FOO, true);
- editor.putString(PREF_BAZ, "");
- editor.apply();
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormat2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormat2.java.txt
deleted file mode 100644
index a09e44b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormat2.java.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class StringFormat2 extends Activity {
- public static final String buildUserAgent(Context context) {
- StringBuilder arg = new StringBuilder();
- // Snip
- final String base = context.getResources().getText(R.string.web_user_agent).toString();
- String ua = String.format(base, arg);
- return ua;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormat3.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormat3.java.txt
deleted file mode 100644
index d1bfe44..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormat3.java.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-
-public class StringFormat3 extends Activity {
- public final void test(Context context) {
- String s1 = String.format(Locale.FRANCE,
- context.getString(R.string.gridview_views_count), article.playsCount);
- String s2 = String.format(Locale.FRANCE,
- context.getString(R.string.gridview_views_count), 5);
- String s3 = String.format(Locale.FRANCE,
- context.getString(R.string.gridview_views_count), "wrong");
- String s4 = String.format(context.getString(R.string.gridview_views_count), "wrong");
- String s5 = String.format(context.getString(R.string.gridview_views_count), 5); // OK
- String s6 = String.format(Locale.getDefault(),
- context.getString(R.string.gridview_views_count), 5);
- String s7 = String.format(null,
- context.getString(R.string.gridview_views_count), 5);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity.java.txt
deleted file mode 100644
index c22828f..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity.java.txt
+++ /dev/null
@@ -1,35 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class StringFormatActivity extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- String target = "World";
- String hello = getResources().getString(R.string.hello);
- String output1 = String.format(hello, target);
- String hello2 = getResources().getString(R.string.hello2);
- String output2 = String.format(hello2, target, "How are you");
- setContentView(R.layout.main);
- String score = getResources().getString(R.string.score);
- int points = 50;
- boolean won = true;
- String output3 = String.format(score, points);
- String output4 = String.format(score, true); // wrong
- String output4 = String.format(score, won); // wrong
- String output5 = String.format(score, 75);
- String.format(getResources().getString(R.string.hello2), target, "How are you");
- getResources().getString(hello2, target, "How are you");
- getResources().getString(R.string.hello2, target, "How are you");
- }
-
- // Test constructor handling (issue 35588)
- public StringFormatActivity() {
- String target = "World";
- String hello = getResources().getString(R.string.hello);
- String output1 = String.format(hello, target);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity2.java.txt
deleted file mode 100644
index c039dce..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity2.java.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class StringFormatActivity2 extends Activity {
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- String target = "World";
- getResources().getString(R.string.formattest1, "hello");
- getResources().getString(R.string.formattest2, "hello");
- getResources().getString(R.string.formattest3, 42);
- getResources().getString(R.string.formattest4, 42);
- getResources().getString(R.string.formattest5, "hello");
- getResources().getString(R.string.formattest6, "hello");
- getResources().getString(R.string.formattest7, "hello");
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity_ignore.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity_ignore.java.txt
deleted file mode 100644
index 58717dc..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/StringFormatActivity_ignore.java.txt
+++ /dev/null
@@ -1,27 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.annotations.tools.SuppressLint;
-
-public class StringFormatActivity extends Activity {
- /** Called when the activity is first created. */
- @SuppressLint("all")
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- String target = "World";
- String hello = getResources().getString(R.string.hello);
- String output1 = String.format(hello, target);
- String hello2 = getResources().getString(R.string.hello2);
- String output2 = String.format(hello2, target, "How are you");
- setContentView(R.layout.main);
- String score = getResources().getString(R.string.score);
- int points = 50;
- boolean won = true;
- String output3 = String.format(score, points);
- String output4 = String.format(score, true); // wrong
- String output4 = String.format(score, won); // wrong
- String output5 = String.format(score, 75);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SuppressTest5.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SuppressTest5.java.txt
deleted file mode 100644
index 1646216..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/SuppressTest5.java.txt
+++ /dev/null
@@ -1,57 +0,0 @@
-package test.pkg;
-
-import android.annotations.tools.SuppressLint;
-
-@SuppressWarnings("unused")
-public class SuppressTest5 {
- private String suppressVariable() {
- @SuppressLint("SdCardPath")
- String string = "/sdcard/mypath1";
- return string;
- }
-
- @SuppressLint("SdCardPath")
- private String suppressMethod() {
- String string = "/sdcard/mypath2";
- return string;
- }
-
- @SuppressLint("SdCardPath")
- private static class SuppressClass {
- private String suppressMethod() {
- String string = "/sdcard/mypath3";
- return string;
- }
- }
-
- private String suppressAll() {
- @SuppressLint("all")
- String string = "/sdcard/mypath4";
- return string;
- }
-
- private String suppressCombination() {
- @SuppressLint({"foo1", "foo2", "SdCardPath"})
- String string = "/sdcard/mypath5";
-
- // This is NOT annotated and *should* generate
- // a warning (here to make sure we don't just
- // suppress everything when we see an annotation
- String notAnnotated = "/sdcard/mypath";
-
- return string;
- }
-
- private String suppressWarnings() {
- @SuppressWarnings("all")
- String string = "/sdcard/mypath6";
-
- @SuppressWarnings("SdCardPath")
- String string2 = "/sdcard/mypath7";
-
- return string;
- }
-
- @SuppressLint("SdCardPath")
- private String supressField = "/sdcard/mypath8";
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ToastTest.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ToastTest.java.txt
deleted file mode 100644
index ce8af3a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/ToastTest.java.txt
+++ /dev/null
@@ -1,41 +0,0 @@
-package foo.bar;
-
-import android.app.Activity;
-import android.content.Context;
-import android.os.Bundle;
-import android.widget.Toast;
-
-public class ToastTest {
- private Toast createToast(Context context) {
- // Don't warn here
- return Toast.makeText(context, "foo", Toast.LENGTH_LONG);
- }
-
- private void showToast(Context context) {
- // Don't warn here
- Toast toast = Toast.makeText(context, "foo", Toast.LENGTH_LONG);
- System.out.println("Other intermediate code here");
- int temp = 5 + 2;
- toast.show();
- }
-
- private void showToast2(Context context) {
- // Don't warn here
- int duration = Toast.LENGTH_LONG;
- Toast.makeText(context, "foo", Toast.LENGTH_LONG).show();
- Toast.makeText(context, R.string.app_name, duration).show();
- }
-
- private void broken(Context context) {
- // Errors
- Toast.makeText(context, "foo", Toast.LENGTH_LONG);
- Toast toast = Toast.makeText(context, R.string.app_name, 5000);
- toast.getDuration();
- }
-
- // Constructor test
- public ToastTest(Context context) {
- Toast.makeText(context, "foo", Toast.LENGTH_LONG);
- }
-}
-
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/UnusedReference.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/UnusedReference.java.txt
deleted file mode 100644
index 5d7cb87..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/UnusedReference.java.txt
+++ /dev/null
@@ -1,12 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.Bundle;
-
-public class UnusedReference extends Activity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(test.pkg.R.layout.main);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Utf8BomTest.java.data b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Utf8BomTest.java.data
deleted file mode 100644
index c8fefcd..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/Utf8BomTest.java.data
+++ /dev/null
@@ -1,5 +0,0 @@
-package test.pkg;
-
-public class Utf8BomTest {
- String s = "/sdcard/mydir";
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WorldWriteableFile.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WorldWriteableFile.java.txt
deleted file mode 100644
index 1e6285b..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WorldWriteableFile.java.txt
+++ /dev/null
@@ -1,38 +0,0 @@
-package test.pkg;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.InputStream;
-import java.io.FileNotFoundException;
-import android.content.Context;
-import android.content.SharedPreferences;
-import android.app.Activity;
-import android.os.Bundle;
-
-public class WorldWriteableFile {
- File mFile;
- Context mContext;
-
- public void foo() {
- OutputStream out = null;
- SharedPreferences prefs = null;
-
- boolean success = false;
- try {
- out = openFileOutput(mFile.getName()); // ok
- out = openFileOutput(mFile.getName(), MODE_PRIVATE); // ok
- out = openFileOutput(mFile.getName(), MODE_WORLD_WRITEABLE);
- out = openFileOutput(mFile.getName(), MODE_WORLD_READABLE);
-
- prefs = getSharedPreferences(mContext, 0); // ok
- prefs = getSharedPreferences(mContext, MODE_PRIVATE); // ok
- prefs = getSharedPreferences(mContext, MODE_WORLD_WRITEABLE);
- prefs = getSharedPreferences(mContext, MODE_WORLD_READABLE);
- // Flickr.get().downloadPhoto(params[0], Flickr.PhotoSize.LARGE,
- // out);
- success = true;
- } catch (FileNotFoundException e) {
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongAnnotation.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongAnnotation.java.txt
deleted file mode 100644
index 45743ce..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongAnnotation.java.txt
+++ /dev/null
@@ -1,36 +0,0 @@
-package test.pkg;
-
-import android.annotation.SuppressLint;
-import android.view.View;
-
-public class WrongAnnotation {
- @Override
- @SuppressLint("NewApi") // Valid: class-file check on method
- public static void foobar(View view, @SuppressLint("NewApi") int foo) { // Invalid: class-file check
- @SuppressLint("NewApi") // Invalid
- boolean a;
- @SuppressLint({"SdCardPath", "NewApi"}) // Invalid: class-file based check on local variable
- boolean b;
- @android.annotation.SuppressLint({"SdCardPath", "NewApi"}) // Invalid (FQN)
- boolean c;
- @SuppressLint("SdCardPath") // Valid: AST-based check
- boolean d;
- }
-
- @SuppressLint("NewApi")
- private int field1;
-
- @SuppressLint("NewApi")
- private int field2 = 5;
-
- static {
- // Local variable outside method: invalid
- @SuppressLint("NewApi")
- int localvar = 5;
- }
-
- private static void test() {
- @SuppressLint("NewApi") // Invalid
- int a = View.MEASURED_STATE_MASK;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity.java.txt
deleted file mode 100644
index 45e53d0..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity.java.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-package test.pkg;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.widget.*;
-
-public class WrongCastActivity extends Activity {
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.casts);
- Button button = (Button) findViewById(R.id.button);
- ToggleButton toggleButton = (ToggleButton) findViewById(R.id.button);
- TextView textView = (TextView) findViewById(R.id.edittext);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity2.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity2.java.txt
deleted file mode 100644
index 7cd422a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity2.java.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-package test.pkg;
-
-import android.app.*;
-import android.view.*;
-import android.widget.*;
-
-public class WrongCastActivity2 extends Activity {
- private TextView additionalButton;
-
- private void configureAdditionalButton(View bodyView) {
- this.additionalButton = (TextView) bodyView
- .findViewById(R.id.additional);
- Object x = (AdapterView<?>) bodyView.findViewById(R.id.reminder_lead);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity3.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity3.java.txt
deleted file mode 100644
index 1701600..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongCastActivity3.java.txt
+++ /dev/null
@@ -1,11 +0,0 @@
-package test.pkg;
-
-import android.app.*;
-import android.view.*;
-import android.widget.*;
-
-public class WrongCastActivity3 extends Activity {
- private void test() {
- final Checkable check = (Checkable) findViewById(R.id.additional);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongColor.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongColor.java.txt
deleted file mode 100644
index cacd834..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/src/test/pkg/WrongColor.java.txt
+++ /dev/null
@@ -1,16 +0,0 @@
-package test.pkg;
-
-import android.view.*;
-import android.widget.*;
-
-public class WrongColor {
- public void foo(TextView textView) {
- Paint paint2 = new Paint();
- paint2.setColor(R.color.blue);
- // Wrong
- textView.setTextColor(R.color.red);
- textView.setTextColor(android.R.color.red);
- // OK
- textView.setTextColor(getResources().getColor(R.color.red));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_not_found.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_not_found.xml
deleted file mode 100644
index 9cd3640..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_not_found.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <uses-permission android:name="com.example.helloworld.permission" />
-
- <uses-feature android:name="android.hardware.wifi" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <uses-library android:name="com.example.helloworld" />
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_feature.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_feature.xml
deleted file mode 100644
index cff7f2e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_feature.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <uses-permission android:name="com.example.helloworld.permission" />
-
- <use-feature android:name="android.hardware.wifi" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <uses-library android:name="com.example.helloworld" />
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_feature2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_feature2.xml
deleted file mode 100644
index d4d8f6e..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_feature2.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <uses-permission android:name="com.example.helloworld.permission" />
-
- <user-feature android:name="android.hardware.wifi" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <uses-library android:name="com.example.helloworld" />
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_library.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_library.xml
deleted file mode 100644
index 5273642..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_library.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <uses-permission android:name="com.example.helloworld.permission" />
-
- <uses-feature android:name="android.hardware.wifi" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <use-library android:name="com.example.helloworld" />
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_library2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_library2.xml
deleted file mode 100644
index 966caf4..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_library2.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <uses-permission android:name="com.example.helloworld.permission" />
-
- <uses-feature android:name="android.hardware.wifi" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <user-library android:name="com.example.helloworld" />
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_permission.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_permission.xml
deleted file mode 100644
index 18a31ae..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_permission.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <use-permission android:name="com.example.helloworld.permission" />
-
- <uses-feature android:name="android.hardware.wifi" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <uses-library android:name="com.example.helloworld" />
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_permission2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_permission2.xml
deleted file mode 100644
index 2f070c5..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_permission2.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <uses-sdk android:minSdkVersion="14" />
-
- <user-permission android:name="com.example.helloworld.permission" />
-
- <uses-feature android:name="android.hardware.wifi" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <uses-library android:name="com.example.helloworld" />
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_sdk.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_sdk.xml
deleted file mode 100644
index c086515..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_sdk.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <use-sdk android:minSdkVersion="14" />
-
- <uses-permission android:name="com.example.helloworld.permission" />
-
- <uses-feature android:name="android.hardware.wifi" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <uses-library android:name="com.example.helloworld" />
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_sdk2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_sdk2.xml
deleted file mode 100644
index 148a3fc..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/typo_uses_sdk2.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="foo.bar2"
- android:versionCode="1"
- android:versionName="1.0" >
-
- <user-sdk android:minSdkVersion="14" />
-
- <uses-permission android:name="com.example.helloworld.permission" />
-
- <uses-feature android:name="android.hardware.wifi" />
-
- <application
- android:icon="@drawable/ic_launcher"
- android:label="@string/app_name" >
- <uses-library android:name="com.example.helloworld" />
- <activity
- android:label="@string/app_name"
- android:name=".Foo2Activity" >
- <intent-filter >
- <action android:name="android.intent.action.MAIN" />
-
- <category android:name="android.intent.category.LAUNCHER" />
- </intent-filter>
- </activity>
- </application>
-
-</manifest> \ No newline at end of file
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/unusedR.java.txt b/lint/cli/src/test/java/com/android/tools/lint/checks/data/unusedR.java.txt
deleted file mode 100644
index 3eae431..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/unusedR.java.txt
+++ /dev/null
@@ -1,14 +0,0 @@
-/* AUTO-GENERATED FILE. DO NOT MODIFY.
- *
- * This class was automatically generated by the
- * aapt tool from the resource data it found. It
- * should not be modified by hand.
- */
-
-package my.pkg;
-
-public final class R {
- public static final class attr {
- public static final int contentId=0x7f020000;
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/ids.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/ids.xml
deleted file mode 100644
index 07e8ae9..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/ids.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<resources>
-
- <item name="my_id1" type="id"/>
-
-</resources>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/ignorelayout1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/ignorelayout1.xml
deleted file mode 100644
index bc6d5fd..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/ignorelayout1.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:tools="http://schemas.android.com/tools"
- android:id="@+id/RelativeLayout1"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
-
- <!-- my_id1 is defined in ids.xml, my_id2 is defined in main2, my_id3 does not exist -->
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBottom="@+id/button5"
- android:layout_alignLeft="@+id/my_id2"
- android:layout_alignParentTop="true"
- android:layout_alignRight="@+id/my_id3"
- android:layout_alignTop="@+id/my_id1"
- android:text="Button"
- tools:ignore="UnknownIdInLayout,UnknownId" />
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/button1"
- android:text="Button" />
-
- <Button
- android:id="@+id/button3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/button2"
- android:text="Button" />
-
- <Button
- android:id="@+id/button4"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/button3"
- android:text="Button" />
-
-</RelativeLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/layout1.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/layout1.xml
deleted file mode 100644
index 073dddd..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/layout1.xml
+++ /dev/null
@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:id="@+id/RelativeLayout1"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:orientation="vertical" >
-
- <!-- my_id1 is defined in ids.xml, my_id2 is defined in main2, my_id3 does not exist -->
-
- <Button
- android:id="@+id/button1"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignBottom="@+id/button5"
- android:layout_alignLeft="@+id/my_id2"
- android:layout_alignParentTop="true"
- android:layout_alignRight="@+id/my_id3"
- android:layout_alignTop="@+id/my_id1"
- android:text="Button" />
-
- <Button
- android:id="@+id/button2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/button1"
- android:text="Button" />
-
- <Button
- android:id="@+id/button3"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/button2"
- android:text="Button" />
-
- <Button
- android:id="@+id/button4"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_alignParentLeft="true"
- android:layout_below="@+id/button3"
- android:text="Button" />
-
-</RelativeLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/layout2.xml b/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/layout2.xml
deleted file mode 100644
index 54dd91a..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/checks/data/wrongid/layout2.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:orientation="vertical" >
-
- <Button
- android:id="@+id/my_id2"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button" />
-
-</LinearLayout>
diff --git a/lint/cli/src/test/java/com/android/tools/lint/client/api/DefaultSdkInfoTest.java b/lint/cli/src/test/java/com/android/tools/lint/client/api/DefaultSdkInfoTest.java
deleted file mode 100644
index afdc985..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/client/api/DefaultSdkInfoTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.client.api;
-
-import junit.framework.TestCase;
-
-@SuppressWarnings("javadoc")
-public class DefaultSdkInfoTest extends TestCase {
- public void testGetParentClass() {
- DefaultSdkInfo info = new DefaultSdkInfo();
- assertNull(info.getParentViewClass("android.view.View"));
- assertEquals("android.view.View", info.getParentViewClass("android.view.ViewGroup"));
- assertEquals("android.view.ViewGroup",
- info.getParentViewClass("android.widget.LinearLayout"));
- assertEquals("android.widget.LinearLayout",
- info.getParentViewClass("android.widget.TableLayout"));
- }
-
- public void testGetParentName() {
- DefaultSdkInfo info = new DefaultSdkInfo();
- assertNull(info.getParentViewName("View"));
- assertEquals("View", info.getParentViewName("ViewGroup"));
- assertEquals("ViewGroup", info.getParentViewName("LinearLayout"));
- assertEquals("LinearLayout", info.getParentViewName("TableLayout"));
- }
-
- public void testIsSubViewOf() {
- DefaultSdkInfo info = new DefaultSdkInfo();
- assertTrue(info.isSubViewOf("Button", "Button"));
- assertTrue(info.isSubViewOf("TextView", "Button"));
- assertTrue(info.isSubViewOf("TextView", "RadioButton"));
- assertTrue(info.isSubViewOf("AdapterView", "Spinner"));
- assertTrue(info.isSubViewOf("AdapterView<?>", "Spinner"));
- assertFalse(info.isSubViewOf("Button", "TextView"));
- assertFalse(info.isSubViewOf("CheckBox", "ToggleButton"));
- assertFalse(info.isSubViewOf("ToggleButton", "CheckBox"));
- assertTrue(info.isSubViewOf("LinearLayout", "LinearLayout"));
- assertTrue(info.isSubViewOf("LinearLayout", "TableLayout"));
- assertFalse(info.isSubViewOf("TableLayout", "LinearLayout"));
- assertTrue(info.isSubViewOf("TextView", "EditText"));
- assertFalse(info.isSubViewOf("EditText", "TextView"));
- assertTrue(info.isSubViewOf("View", "TextView"));
- assertFalse(info.isSubViewOf("TextView", "View"));
- assertFalse(info.isSubViewOf("Spinner", "AdapterView<?>"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/client/api/LintClientTest.java b/lint/cli/src/test/java/com/android/tools/lint/client/api/LintClientTest.java
deleted file mode 100644
index a4376d8..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/client/api/LintClientTest.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.client.api;
-
-import com.android.tools.lint.Main;
-
-import junit.framework.TestCase;
-
-@SuppressWarnings("javadoc")
-public class LintClientTest extends TestCase {
- public void test() throws Exception {
- Main client = new Main();
- int max = client.getHighestKnownApiLevel();
- assertTrue(max >= 16);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/client/api/LintDriverTest.java b/lint/cli/src/test/java/com/android/tools/lint/client/api/LintDriverTest.java
deleted file mode 100644
index f4dba93..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/client/api/LintDriverTest.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.client.api;
-
-import com.android.tools.lint.client.api.LintDriver.ClassEntry;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-@SuppressWarnings("javadoc")
-public class LintDriverTest extends TestCase {
- public void testClassEntryCompare() throws Exception {
- ClassEntry c0 = new ClassEntry(new File("/a1/Foo.class"), null, null, null);
- ClassEntry c1 = new ClassEntry(new File("/a1/Foo.clazz"), null, null, null);
- ClassEntry c2 = new ClassEntry(new File("/a1/Foo$Inner1.class"), null, null, null);
- ClassEntry c3 = new ClassEntry(new File("/a1/Foo$Inner1$Inner.class"), null, null, null);
- ClassEntry c4 = new ClassEntry(new File("/a2/Foo$Inner2.clas"), null, null, null);
- ClassEntry c5 = new ClassEntry(new File("/a2/Foo$Inner2.class"), null, null, null);
-
- List<ClassEntry> expected = Arrays.asList(c0, c1, c2, c3, c4, c5);
- List<ClassEntry> list = new ArrayList<ClassEntry>(expected);
- Collections.sort(list);
- assertEquals(list, list);
-
- List<ClassEntry> list2 = Arrays.asList(c5, c4, c3, c2, c1, c0);
- Collections.sort(list2);
- assertEquals(expected, list2);
-
- List<ClassEntry> list3 = Arrays.asList(c3, c0, c1, c5, c2, c4);
- Collections.sort(list3);
- assertEquals(expected, list3);
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/client/api/ProjectTest.java b/lint/cli/src/test/java/com/android/tools/lint/client/api/ProjectTest.java
deleted file mode 100644
index 4f3c9ef..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/client/api/ProjectTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.client.api;
-
-import com.android.tools.lint.checks.AbstractCheckTest;
-import com.android.tools.lint.checks.UnusedResourceDetector;
-import com.android.tools.lint.detector.api.Detector;
-
-import java.io.File;
-import java.util.Arrays;
-
-public class ProjectTest extends AbstractCheckTest {
- @Override
- protected boolean ignoreSystemErrors() {
- return false;
- }
-
- public void testCycle() throws Exception {
- // Ensure that a cycle in library project dependencies doesn't cause
- // infinite directory traversal
- File master = getProjectDir("MasterProject",
- // Master project
- "multiproject/main-manifest.xml=>AndroidManifest.xml",
- "multiproject/main.properties=>project.properties",
- "multiproject/MainCode.java.txt=>src/foo/main/MainCode.java"
- );
- File library = getProjectDir("LibraryProject",
- // Library project
- "multiproject/library-manifest.xml=>AndroidManifest.xml",
- "multiproject/main.properties=>project.properties", // RECURSIVE - points to self
- "multiproject/LibraryCode.java.txt=>src/foo/library/LibraryCode.java",
- "multiproject/strings.xml=>res/values/strings.xml"
- );
-
- assertEquals(""
- + "MasterProject/project.properties: Error: Circular library dependencies; check your project.properties files carefully [LintError]\n"
- + "1 errors, 0 warnings\n",
-
- checkLint(Arrays.asList(master, library)));
- }
-
- @Override
- protected Detector getDetector() {
- return new UnusedResourceDetector();
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/detector/api/ClassContextTest.java b/lint/cli/src/test/java/com/android/tools/lint/detector/api/ClassContextTest.java
deleted file mode 100644
index 71c3486..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/detector/api/ClassContextTest.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.detector.api;
-
-import junit.framework.TestCase;
-
-@SuppressWarnings("javadoc")
-public class ClassContextTest extends TestCase {
- public void testCreateSignature() {
- assertEquals("foo.bar.Foo.Bar",
- ClassContext.createSignature("foo/bar/Foo$Bar", null, null));
- assertEquals("void foo.bar.Foo.Bar#name(int)",
- ClassContext.createSignature("foo/bar/Foo$Bar", "name", "(I)V"));
- assertEquals("void foo.bar.Foo.Bar#name(Integer)",
- ClassContext.createSignature("foo/bar/Foo$Bar", "name", "(Ljava/lang/Integer;)V"));
- }
-
- public void testGetInternalName() {
- assertEquals("foo/bar/Foo$Bar",
- ClassContext.getInternalName("foo.bar.Foo.Bar"));
- }
-
- public void testGetFqcn() {
- assertEquals("foo.bar.Foo.Bar", ClassContext.getFqcn("foo/bar/Foo$Bar"));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/detector/api/IssueTest.java b/lint/cli/src/test/java/com/android/tools/lint/detector/api/IssueTest.java
deleted file mode 100644
index c8aaf12..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/detector/api/IssueTest.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.detector.api;
-
-import static com.android.SdkConstants.AUTO_URI;
-import static com.android.tools.lint.detector.api.Issue.convertMarkup;
-import junit.framework.TestCase;
-
-@SuppressWarnings("javadoc")
-public class IssueTest extends TestCase {
- public void testConvertMarkup() throws Exception {
- assertEquals("", convertMarkup("", true));
-
- // Normal escapes
- assertEquals("foo bar", convertMarkup("foo bar", true));
- assertEquals("foo<br/>\nbar", convertMarkup("foo\nbar", true));
- assertEquals("foo<br/>\nbar", convertMarkup("foo\nbar", true));
- assertEquals("&lt;&amp;>'\"", convertMarkup("<&>'\"", true));
-
- // HTML Formatting
- assertEquals("<code>@TargetApi(11)</code>, ", convertMarkup("`@TargetApi(11)`, ",
- true));
- assertEquals("with <code>getArguments()</code>.",
- convertMarkup("with `getArguments()`.",
- true));
- assertEquals("(<code>dip</code>)", convertMarkup("(`dip`)", true));
- assertEquals(" <code>0dp</code> ", convertMarkup(" `0dp` ", true));
- assertEquals(
- "resources under <code>$ANDROID_SK/platforms/android-$VERSION/data/res/.</code>",
- convertMarkup(
- "resources under `$ANDROID_SK/platforms/android-$VERSION/data/res/.`",
- true));
- assertEquals("wrong format. Instead of <code>-keepclasseswithmembernames</code> use ",
- convertMarkup("wrong format. Instead of `-keepclasseswithmembernames` use ",
- true));
- assertEquals("<code>exported=false</code>)", convertMarkup("`exported=false`)",
- true));
- assertEquals("by setting <code>inputType=\"text\"</code>.",
- convertMarkup("by setting `inputType=\"text\"`.", true));
- assertEquals("* <code>View(Context context)</code><br/>\n",
- convertMarkup("* `View(Context context)`\n", true));
- assertEquals("The <code>@+id/</code> syntax", convertMarkup("The `@+id/` syntax",
- true));
- assertEquals("", convertMarkup("", true));
- assertEquals("", convertMarkup("", true));
- assertEquals("This is <b>bold</b>", convertMarkup("This is *bold*", true));
- assertEquals("Visit <a href=\"http://google.com\">http://google.com</a>.",
- convertMarkup("Visit http://google.com.", true));
- assertEquals("This is <code>monospace</code>!", convertMarkup("This is `monospace`!",
- true));
- assertEquals(
- "See <a href=\"http://developer.android.com/reference/android/view/" +
- "WindowManager.LayoutParams.html#FLAG_KEEP_SCREEN_ON\">http://developer." +
- "android.com/reference/android/view/WindowManager.LayoutParams.html#" +
- "FLAG_KEEP_SCREEN_ON</a>.",
- convertMarkup(
- "See http://developer.android.com/reference/android/view/WindowManager.Layout" +
- "Params.html#FLAG_KEEP_SCREEN_ON.", true));
-
- // Text formatting
- assertEquals("@TargetApi(11), ", convertMarkup("`@TargetApi(11)`, ", false));
- assertEquals("with getArguments().", convertMarkup("with `getArguments()`.", false));
- assertEquals("bold", convertMarkup("*bold*", false));
- assertEquals("Visit http://google.com.", convertMarkup("Visit http://google.com.",
- false));
-
- // Corners (match at the beginning and end)
- assertEquals("<b>bold</b>", convertMarkup("*bold*", true));
- assertEquals("<code>monospace</code>!", convertMarkup("`monospace`!", true));
-
- // Not formatting
- assertEquals("a*b", convertMarkup("a*b", true));
- assertEquals("a* b*", convertMarkup("a* b*", true));
- assertEquals("*a *b", convertMarkup("*a *b", true));
- assertEquals("Prefix is http:// ", convertMarkup("Prefix is http:// ", true));
- assertEquals("", convertMarkup("", true));
- assertEquals("", convertMarkup("", true));
- assertEquals("", convertMarkup("", true));
- assertEquals("", convertMarkup("", true));
- assertEquals("This is * not * bold", convertMarkup("This is * not * bold", true));
- assertEquals("* List item 1<br/>\n* List Item 2",
- convertMarkup("* List item 1\n* List Item 2", true));
- assertEquals("myhttp://foo.bar", convertMarkup("myhttp://foo.bar", true));
- }
-
- public void testConvertMarkup2() throws Exception {
- // http at the end:
- // Explanation from ManifestOrderDetector#TARGET_NEWER
- String explanation =
- "When your application runs on a version of Android that is more recent than your " +
- "targetSdkVersion specifies that it has been tested with, various compatibility " +
- "modes kick in. This ensures that your application continues to work, but it may " +
- "look out of place. For example, if the targetSdkVersion is less than 14, your " +
- "app may get an option button in the UI.\n" +
- "\n" +
- "To fix this issue, set the targetSdkVersion to the highest available value. Then " +
- "test your app to make sure everything works correctly. You may want to consult " +
- "the compatibility notes to see what changes apply to each version you are adding " +
- "support for: " +
- "http://developer.android.com/reference/android/os/Build.VERSION_CODES.html";
-
- assertEquals(
- "When your application runs on a version of Android that is more recent than your " +
- "targetSdkVersion specifies that it has been tested with, various compatibility " +
- "modes kick in. This ensures that your application continues to work, but it may " +
- "look out of place. For example, if the targetSdkVersion is less than 14, your " +
- "app may get an option button in the UI.<br/>\n" +
- "<br/>\n" +
- "To fix this issue, set the targetSdkVersion to the highest available value. Then " +
- "test your app to make sure everything works correctly. You may want to consult " +
- "the compatibility notes to see what changes apply to each version you are adding " +
- "support for: " +
- "<a href=\"http://developer.android.com/reference/android/os/Build.VERSION_CODES." +
- "html\">http://developer.android.com/reference/android/os/Build.VERSION_CODES.html" +
- "</a>",
- convertMarkup(explanation, true));
- }
-
- public void testConvertMarkup3() throws Exception {
- // embedded http markup test
- // Explanation from NamespaceDetector#CUSTOMVIEW
- String explanation =
- "When using a custom view with custom attributes in a library project, the layout " +
- "must use the special namespace " + AUTO_URI + " instead of a URI which includes " +
- "the library project's own package. This will be used to automatically adjust the " +
- "namespace of the attributes when the library resources are merged into the " +
- "application project.";
- assertEquals(
- "When using a custom view with custom attributes in a library project, the layout " +
- "must use the special namespace " +
- "<a href=\"http://schemas.android.com/apk/res-auto\">" +
- "http://schemas.android.com/apk/res-auto</a> " +
- "instead of a URI which includes the library project's own package. " +
- "This will be used to automatically adjust the namespace of the attributes when " +
- "the library resources are merged into the application project.",
- convertMarkup(explanation, true));
- }
-
- public void testConvertMarkup4() throws Exception {
- // monospace test
- String explanation =
- "The manifest should contain a `<uses-sdk>` element which defines the " +
- "minimum minimum API Level required for the application to run, " +
- "as well as the target version (the highest API level you have tested " +
- "the version for.)";
-
- assertEquals(
- "The manifest should contain a <code>&lt;uses-sdk></code> element which defines the " +
- "minimum minimum API Level required for the application to run, " +
- "as well as the target version (the highest API level you have tested " +
- "the version for.)",
- convertMarkup(explanation, true));
- }
-
- public void testConvertMarkup5() throws Exception {
- // monospace and bold test
- // From ManifestOrderDetector#MULTIPLE_USES_SDK
- String explanation =
- "The `<uses-sdk>` element should appear just once; the tools will *not* merge the " +
- "contents of all the elements so if you split up the atttributes across multiple " +
- "elements, only one of them will take effect. To fix this, just merge all the " +
- "attributes from the various elements into a single <uses-sdk> element.";
-
- assertEquals(
- "The <code>&lt;uses-sdk></code> element should appear just once; the tools " +
- "will <b>not</b> merge the " +
- "contents of all the elements so if you split up the atttributes across multiple " +
- "elements, only one of them will take effect. To fix this, just merge all the " +
- "attributes from the various elements into a single &lt;uses-sdk> element.",
- convertMarkup(explanation, true));
- }
-
- public void testConvertMarkup6() throws Exception {
- // Embedded code next to attributes
- // From AlwaysShowActionDetector#ISSUE
- String explanation =
- "Using `showAsAction=\"always\"` in menu XML, or `MenuItem.SHOW_AS_ACTION_ALWAYS` in "+
- "Java code is usually a deviation from the user interface style guide." +
- "Use `ifRoom` or the corresponding `MenuItem.SHOW_AS_ACTION_IF_ROOM` instead.\n" +
- "\n" +
- "If `always` is used sparingly there are usually no problems and behavior is " +
- "roughly equivalent to `ifRoom` but with preference over other `ifRoom` " +
- "items. Using it more than twice in the same menu is a bad idea.\n" +
- "\n" +
- "This check looks for menu XML files that contain more than two `always` " +
- "actions, or some `always` actions and no `ifRoom` actions. In Java code, " +
- "it looks for projects that contain references to `MenuItem.SHOW_AS_ACTION_ALWAYS` " +
- "and no references to `MenuItem.SHOW_AS_ACTION_IF_ROOM`.";
-
- assertEquals(
- "Using <code>showAsAction=\"always\"</code> in menu XML, or " +
- "<code>MenuItem.SHOW_AS_ACTION_ALWAYS</code> in Java code is usually a deviation " +
- "from the user interface style guide.Use <code>ifRoom</code> or the " +
- "corresponding <code>MenuItem.SHOW_AS_ACTION_IF_ROOM</code> instead.<br/>\n" +
- "<br/>\n" +
- "If <code>always</code> is used sparingly there are usually no problems and " +
- "behavior is roughly equivalent to <code>ifRoom</code> but with preference over " +
- "other <code>ifRoom</code> items. Using it more than twice in the same menu " +
- "is a bad idea.<br/>\n" +
- "<br/>\n" +
- "This check looks for menu XML files that contain more than two <code>always</code> " +
- "actions, or some <code>always</code> actions and no <code>ifRoom</code> actions. " +
- "In Java code, it looks for projects that contain references to " +
- "<code>MenuItem.SHOW_AS_ACTION_ALWAYS</code> and no references to " +
- "<code>MenuItem.SHOW_AS_ACTION_IF_ROOM</code>.",
- convertMarkup(explanation, true));
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/detector/api/LintUtilsTest.java b/lint/cli/src/test/java/com/android/tools/lint/detector/api/LintUtilsTest.java
deleted file mode 100644
index 7dfa260..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/detector/api/LintUtilsTest.java
+++ /dev/null
@@ -1,359 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.detector.api;
-
-import static com.android.tools.lint.detector.api.LintUtils.getLocaleAndRegion;
-import static com.android.tools.lint.detector.api.LintUtils.isImported;
-import static com.android.tools.lint.detector.api.LintUtils.splitPath;
-
-import com.android.annotations.Nullable;
-import com.android.tools.lint.LombokParser;
-import com.android.tools.lint.Main;
-import com.android.tools.lint.checks.BuiltinIssueRegistry;
-import com.android.tools.lint.client.api.IJavaParser;
-import com.android.tools.lint.client.api.LintDriver;
-import com.google.common.collect.Iterables;
-
-import java.io.BufferedOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-import lombok.ast.Node;
-
-@SuppressWarnings("javadoc")
-public class LintUtilsTest extends TestCase {
- public void testPrintList() throws Exception {
- assertEquals("foo, bar, baz",
- LintUtils.formatList(Arrays.asList("foo", "bar", "baz"), 3));
- assertEquals("foo, bar, baz",
- LintUtils.formatList(Arrays.asList("foo", "bar", "baz"), 5));
-
- assertEquals("foo, bar, baz... (3 more)",
- LintUtils.formatList(
- Arrays.asList("foo", "bar", "baz", "4", "5", "6"), 3));
- assertEquals("foo... (5 more)",
- LintUtils.formatList(
- Arrays.asList("foo", "bar", "baz", "4", "5", "6"), 1));
- assertEquals("foo, bar, baz",
- LintUtils.formatList(Arrays.asList("foo", "bar", "baz"), 0));
- }
-
- public void testEndsWith() throws Exception {
- assertTrue(LintUtils.endsWith("Foo", ""));
- assertTrue(LintUtils.endsWith("Foo", "o"));
- assertTrue(LintUtils.endsWith("Foo", "oo"));
- assertTrue(LintUtils.endsWith("Foo", "Foo"));
- assertTrue(LintUtils.endsWith("Foo", "FOO"));
- assertTrue(LintUtils.endsWith("Foo", "fOO"));
-
- assertFalse(LintUtils.endsWith("Foo", "f"));
- }
-
- public void testStartsWith() throws Exception {
- assertTrue(LintUtils.startsWith("FooBar", "Bar", 3));
- assertTrue(LintUtils.startsWith("FooBar", "BAR", 3));
- assertTrue(LintUtils.startsWith("FooBar", "Foo", 0));
- assertFalse(LintUtils.startsWith("FooBar", "Foo", 2));
- }
-
- public void testIsXmlFile() throws Exception {
- assertTrue(LintUtils.isXmlFile(new File("foo.xml")));
- assertTrue(LintUtils.isXmlFile(new File("foo.Xml")));
- assertTrue(LintUtils.isXmlFile(new File("foo.XML")));
-
- assertFalse(LintUtils.isXmlFile(new File("foo.png")));
- assertFalse(LintUtils.isXmlFile(new File("xml")));
- assertFalse(LintUtils.isXmlFile(new File("xml.png")));
- }
-
- public void testGetBasename() throws Exception {
- assertEquals("foo", LintUtils.getBaseName("foo.png"));
- assertEquals("foo", LintUtils.getBaseName("foo.9.png"));
- assertEquals(".foo", LintUtils.getBaseName(".foo"));
- }
-
- public void testEditDistance() {
- assertEquals(0, LintUtils.editDistance("kitten", "kitten"));
-
- // editing kitten to sitting has edit distance 3:
- // replace k with s
- // replace e with i
- // append g
- assertEquals(3, LintUtils.editDistance("kitten", "sitting"));
-
- assertEquals(3, LintUtils.editDistance("saturday", "sunday"));
- assertEquals(1, LintUtils.editDistance("button", "bitton"));
- assertEquals(6, LintUtils.editDistance("radiobutton", "bitton"));
- }
-
- public void testSplitPath() throws Exception {
- assertTrue(Arrays.equals(new String[] { "/foo", "/bar", "/baz" },
- Iterables.toArray(splitPath("/foo:/bar:/baz"), String.class)));
-
- assertTrue(Arrays.equals(new String[] { "/foo", "/bar" },
- Iterables.toArray(splitPath("/foo;/bar"), String.class)));
-
- assertTrue(Arrays.equals(new String[] { "/foo", "/bar:baz" },
- Iterables.toArray(splitPath("/foo;/bar:baz"), String.class)));
-
- assertTrue(Arrays.equals(new String[] { "\\foo\\bar", "\\bar\\foo" },
- Iterables.toArray(splitPath("\\foo\\bar;\\bar\\foo"), String.class)));
-
- assertTrue(Arrays.equals(new String[] { "${sdk.dir}\\foo\\bar", "\\bar\\foo" },
- Iterables.toArray(splitPath("${sdk.dir}\\foo\\bar;\\bar\\foo"),
- String.class)));
-
- assertTrue(Arrays.equals(new String[] { "${sdk.dir}/foo/bar", "/bar/foo" },
- Iterables.toArray(splitPath("${sdk.dir}/foo/bar:/bar/foo"),
- String.class)));
-
- assertTrue(Arrays.equals(new String[] { "C:\\foo", "/bar" },
- Iterables.toArray(splitPath("C:\\foo:/bar"), String.class)));
- }
-
- public void testCommonParen1() {
- assertEquals(new File("/a"), (LintUtils.getCommonParent(
- new File("/a/b/c/d/e"), new File("/a/c"))));
- assertEquals(new File("/a"), (LintUtils.getCommonParent(
- new File("/a/c"), new File("/a/b/c/d/e"))));
-
- assertEquals(new File("/"), LintUtils.getCommonParent(
- new File("/foo/bar"), new File("/bar/baz")));
- assertEquals(new File("/"), LintUtils.getCommonParent(
- new File("/foo/bar"), new File("/")));
- assertNull(LintUtils.getCommonParent(
- new File("C:\\Program Files"), new File("F:\\")));
- assertNull(LintUtils.getCommonParent(
- new File("C:/Program Files"), new File("F:/")));
-
- assertEquals(new File("/foo/bar/baz"), LintUtils.getCommonParent(
- new File("/foo/bar/baz"), new File("/foo/bar/baz")));
- assertEquals(new File("/foo/bar"), LintUtils.getCommonParent(
- new File("/foo/bar/baz"), new File("/foo/bar")));
- assertEquals(new File("/foo/bar"), LintUtils.getCommonParent(
- new File("/foo/bar/baz"), new File("/foo/bar/foo")));
- assertEquals(new File("/foo"), LintUtils.getCommonParent(
- new File("/foo/bar"), new File("/foo/baz")));
- assertEquals(new File("/foo"), LintUtils.getCommonParent(
- new File("/foo/bar"), new File("/foo/baz")));
- assertEquals(new File("/foo/bar"), LintUtils.getCommonParent(
- new File("/foo/bar"), new File("/foo/bar/baz")));
- }
-
- public void testCommonParent2() {
- assertEquals(new File("/"), LintUtils.getCommonParent(
- Arrays.asList(new File("/foo/bar"), new File("/bar/baz"))));
- assertEquals(new File("/"), LintUtils.getCommonParent(
- Arrays.asList(new File("/foo/bar"), new File("/"))));
- assertNull(LintUtils.getCommonParent(
- Arrays.asList(new File("C:\\Program Files"), new File("F:\\"))));
- assertNull(LintUtils.getCommonParent(
- Arrays.asList(new File("C:/Program Files"), new File("F:/"))));
-
- assertEquals(new File("/foo"), LintUtils.getCommonParent(
- Arrays.asList(new File("/foo/bar"), new File("/foo/baz"))));
- assertEquals(new File("/foo"), LintUtils.getCommonParent(
- Arrays.asList(new File("/foo/bar"), new File("/foo/baz"),
- new File("/foo/baz/f"))));
- assertEquals(new File("/foo/bar"), LintUtils.getCommonParent(
- Arrays.asList(new File("/foo/bar"), new File("/foo/bar/baz"),
- new File("/foo/bar/foo2/foo3"))));
- }
-
- public void testStripIdPrefix() throws Exception {
- assertEquals("foo", LintUtils.stripIdPrefix("@+id/foo"));
- assertEquals("foo", LintUtils.stripIdPrefix("@id/foo"));
- assertEquals("foo", LintUtils.stripIdPrefix("foo"));
- }
-
- public void testIdReferencesMatch() throws Exception {
- assertTrue(LintUtils.idReferencesMatch("@+id/foo", "@+id/foo"));
- assertTrue(LintUtils.idReferencesMatch("@id/foo", "@id/foo"));
- assertTrue(LintUtils.idReferencesMatch("@id/foo", "@+id/foo"));
- assertTrue(LintUtils.idReferencesMatch("@+id/foo", "@id/foo"));
-
- assertFalse(LintUtils.idReferencesMatch("@+id/foo", "@+id/bar"));
- assertFalse(LintUtils.idReferencesMatch("@id/foo", "@+id/bar"));
- assertFalse(LintUtils.idReferencesMatch("@+id/foo", "@id/bar"));
- assertFalse(LintUtils.idReferencesMatch("@+id/foo", "@+id/bar"));
-
- assertFalse(LintUtils.idReferencesMatch("@+id/foo", "@+id/foo1"));
- assertFalse(LintUtils.idReferencesMatch("@id/foo", "@id/foo1"));
- assertFalse(LintUtils.idReferencesMatch("@id/foo", "@+id/foo1"));
- assertFalse(LintUtils.idReferencesMatch("@+id/foo", "@id/foo1"));
-
- assertFalse(LintUtils.idReferencesMatch("@+id/foo1", "@+id/foo"));
- assertFalse(LintUtils.idReferencesMatch("@id/foo1", "@id/foo"));
- assertFalse(LintUtils.idReferencesMatch("@id/foo1", "@+id/foo"));
- assertFalse(LintUtils.idReferencesMatch("@+id/foo1", "@id/foo"));
- }
-
- private static void checkEncoding(String encoding, boolean writeBom, String lineEnding)
- throws Exception {
- StringBuilder sb = new StringBuilder();
-
- // Norwegian extra vowel characters such as "latin small letter a with ring above"
- String value = "\u00e6\u00d8\u00e5";
- String expected = "First line." + lineEnding + "Second line." + lineEnding
- + "Third line." + lineEnding + value + lineEnding;
- sb.append(expected);
- File file = File.createTempFile("getEncodingTest" + encoding + writeBom, ".txt");
- file.deleteOnExit();
- BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(file));
- OutputStreamWriter writer = new OutputStreamWriter(stream, encoding);
-
- if (writeBom) {
- String normalized = encoding.toLowerCase().replace("-", "_");
- if (normalized.equals("utf_8")) {
- stream.write(0xef);
- stream.write(0xbb);
- stream.write(0xbf);
- } else if (normalized.equals("utf_16")) {
- stream.write(0xfe);
- stream.write(0xff);
- } else if (normalized.equals("utf_16le")) {
- stream.write(0xff);
- stream.write(0xfe);
- } else if (normalized.equals("utf_32")) {
- stream.write(0x0);
- stream.write(0x0);
- stream.write(0xfe);
- stream.write(0xff);
- } else if (normalized.equals("utf_32le")) {
- stream.write(0xff);
- stream.write(0xfe);
- stream.write(0x0);
- stream.write(0x0);
- } else {
- fail("Can't write BOM for encoding " + encoding);
- }
- }
- writer.write(sb.toString());
- writer.close();
-
- String s = LintUtils.getEncodedString(new Main(), file);
- assertEquals(expected, s);
- }
-
- public void testGetEncodedString() throws Exception {
- checkEncoding("utf-8", false /*bom*/, "\n");
- checkEncoding("UTF-8", false /*bom*/, "\n");
- checkEncoding("UTF_16", false /*bom*/, "\n");
- checkEncoding("UTF-16", false /*bom*/, "\n");
- checkEncoding("UTF_16LE", false /*bom*/, "\n");
-
- // Try BOM's
- checkEncoding("utf-8", true /*bom*/, "\n");
- checkEncoding("UTF-8", true /*bom*/, "\n");
- checkEncoding("UTF_16", true /*bom*/, "\n");
- checkEncoding("UTF-16", true /*bom*/, "\n");
- checkEncoding("UTF_16LE", true /*bom*/, "\n");
- checkEncoding("UTF_32", true /*bom*/, "\n");
- checkEncoding("UTF_32LE", true /*bom*/, "\n");
-
- // Make sure this works for \r and \r\n as well
- checkEncoding("UTF-16", false /*bom*/, "\r");
- checkEncoding("UTF_16LE", false /*bom*/, "\r");
- checkEncoding("UTF-16", false /*bom*/, "\r\n");
- checkEncoding("UTF_16LE", false /*bom*/, "\r\n");
- checkEncoding("UTF-16", true /*bom*/, "\r");
- checkEncoding("UTF_16LE", true /*bom*/, "\r");
- checkEncoding("UTF_32", true /*bom*/, "\r");
- checkEncoding("UTF_32LE", true /*bom*/, "\r");
- checkEncoding("UTF-16", true /*bom*/, "\r\n");
- checkEncoding("UTF_16LE", true /*bom*/, "\r\n");
- checkEncoding("UTF_32", true /*bom*/, "\r\n");
- checkEncoding("UTF_32LE", true /*bom*/, "\r\n");
- }
-
- public void testGetLocaleAndRegion() throws Exception {
- assertNull(getLocaleAndRegion(""));
- assertNull(getLocaleAndRegion("values"));
- assertNull(getLocaleAndRegion("values-xlarge-port"));
- assertEquals("en", getLocaleAndRegion("values-en"));
- assertEquals("pt-rPT", getLocaleAndRegion("values-pt-rPT-nokeys"));
- assertEquals("zh-rCN", getLocaleAndRegion("values-zh-rCN-keyshidden"));
- assertEquals("ms", getLocaleAndRegion("values-ms-keyshidden"));
- }
-
- public void testIsImported() throws Exception {
- assertFalse(isImported(getCompilationUnit(
- "package foo.bar;\n" +
- "class Foo {\n" +
- "}\n"),
- "android.app.Activity"));
-
- assertTrue(isImported(getCompilationUnit(
- "package foo.bar;\n" +
- "import foo.bar.*;\n" +
- "import android.app.Activity;\n" +
- "import foo.bar.Baz;\n" +
- "class Foo {\n" +
- "}\n"),
- "android.app.Activity"));
-
- assertTrue(isImported(getCompilationUnit(
- "package foo.bar;\n" +
- "import android.app.Activity;\n" +
- "class Foo {\n" +
- "}\n"),
- "android.app.Activity"));
-
- assertTrue(isImported(getCompilationUnit(
- "package foo.bar;\n" +
- "import android.app.*;\n" +
- "class Foo {\n" +
- "}\n"),
- "android.app.Activity"));
-
- assertFalse(isImported(getCompilationUnit(
- "package foo.bar;\n" +
- "import android.app.*;\n" +
- "import foo.bar.Activity;\n" +
- "class Foo {\n" +
- "}\n"),
- "android.app.Activity"));
- }
-
- private Node getCompilationUnit(String javaSource) {
- IJavaParser parser = new LombokParser();
- TestContext context = new TestContext(javaSource, new File("test"));
- Node compilationUnit = parser.parseJava(context);
- assertNotNull(javaSource, compilationUnit);
- return compilationUnit;
- }
-
- private class TestContext extends JavaContext {
- private final String mJavaSource;
- public TestContext(String javaSource, File file) {
- super(new LintDriver(new BuiltinIssueRegistry(),
- new Main()), new Main().getProject(new File("dummy"), new File("dummy")),
- null, file);
-
- mJavaSource = javaSource;
- }
-
- @Override
- @Nullable
- public String getContents() {
- return mJavaSource;
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/detector/api/LocationTest.java b/lint/cli/src/test/java/com/android/tools/lint/detector/api/LocationTest.java
deleted file mode 100644
index 6404202..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/detector/api/LocationTest.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.detector.api;
-
-import java.io.File;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-@SuppressWarnings("javadoc")
-public class LocationTest extends TestCase {
- public void testReverse() throws IOException {
- File file1 = new File("parent/location1");
- File file2 = new File("parent/location2");
- File file3 = new File("parent/location3");
- File file4 = new File("parent/location4");
-
- Location location1 = Location.create(file1);
- Location location2 = Location.create(file2);
- Location location3 = Location.create(file3);
- Location location4 = Location.create(file4);
-
- // 1-element location list
- assertSame(location1, Location.reverse(location1));
- assertFalse(containsCycle(location1));
-
- // 2-element location list
- location1.setSecondary(location2);
- assertSame(location2, Location.reverse(location1));
- assertFalse(containsCycle(location2));
- assertSame(location1, location2.getSecondary());
-
- // 3-element location list
- location1.setSecondary(location2);
- location2.setSecondary(location3);
- assertSame(location3, Location.reverse(location1));
- assertFalse(containsCycle(location3));
- assertSame(location2, location3.getSecondary());
- assertSame(location1, location2.getSecondary());
-
- // 4-element location list
- location1.setSecondary(location2);
- location2.setSecondary(location3);
- location3.setSecondary(location4);
- assertSame(location4, Location.reverse(location1));
- assertFalse(containsCycle(location4));
- assertSame(location3, location4.getSecondary());
- assertSame(location2, location3.getSecondary());
- assertSame(location1, location2.getSecondary());
- }
-
- public void testFaen() throws Exception {
- File[] paths = new File[] {
- new File("values-zh-rTW/arrays.xml"), new File("values-zh-rCN/arrays.xml"),
- new File("values-vi/arrays.xml"), new File("values-uk/arrays.xml"),
- new File("values-tr/arrays.xml"), new File("values-tl/arrays.xml"),
- new File("values-th/arrays.xml"), new File("values-sv/arrays.xml"),
- new File("values-sr/arrays.xml"), new File("values-sl/arrays.xml"),
- new File("values-sk/arrays.xml"), new File("values-ru/arrays.xml"),
- new File("values-ro/arrays.xml"), new File("values-rm/arrays.xml"),
- new File("values-pt-rPT/arrays.xml"), new File("values-pt/arrays.xml"),
- new File("values-pl/arrays.xml"), new File("values-nl/arrays.xml"),
- new File("values-nb/arrays.xml"), new File("values-lv/arrays.xml"),
- new File("values-lt/arrays.xml"), new File("values-ko/arrays.xml"),
- new File("values-ja/arrays.xml"), new File("values-iw/arrays.xml"),
- new File("values-it/arrays.xml"), new File("values-in/arrays.xml"),
- new File("values-hu/arrays.xml"), new File("values-hr/arrays.xml"),
- new File("values-fr/arrays.xml"), new File("values-fi/arrays.xml"),
- new File("values-fa/arrays.xml"), new File("values-es-rUS/arrays.xml"),
- new File("values-es/arrays.xml"), new File("values-en-rGB/arrays.xml"),
- new File("values-el/arrays.xml"), new File("values-de/arrays.xml"),
- new File("values-da/arrays.xml"), new File("values-cs/arrays.xml"),
- new File("values-ca/arrays.xml"), new File("values-bg/arrays.xml"),
- new File("values-ar/arrays.xml"), new File("values/arrays.xml")
- };
-
- Location last = null;
- for (int i = paths.length - 1; i >= 0; i--) {
- Location location = Location.create(paths[i]);
- location.setSecondary(last);
- last = location;
- }
-
- assertFalse(containsCycle(last));
- Location.reverse(last);
- assertFalse(containsCycle(last));
- }
-
- private static boolean containsCycle(Location location) {
- // Make sure there's no cycle: iterate
- Location a = location;
- Location b = location;
-
- while (true) {
- b = b.getSecondary();
- if (b == null) {
- // OK! Found list end
- return false;
- }
- if (b == a) {
- return true;
- }
- b = b.getSecondary();
- if (b == null) {
- // OK! Found list end
- return false;
- }
- if (b == a) {
- return true;
- }
-
- a = a.getSecondary();
- assert a != null;
- }
- }
-}
diff --git a/lint/cli/src/test/java/com/android/tools/lint/detector/api/ScopeTest.java b/lint/cli/src/test/java/com/android/tools/lint/detector/api/ScopeTest.java
deleted file mode 100644
index e95c502..0000000
--- a/lint/cli/src/test/java/com/android/tools/lint/detector/api/ScopeTest.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.tools.lint.detector.api;
-
-import java.util.EnumSet;
-
-import junit.framework.TestCase;
-
-@SuppressWarnings("javadoc")
-public class ScopeTest extends TestCase {
- public void testIntersect() {
- assertEquals(Scope.RESOURCE_FILE_SCOPE,
- Scope.intersect(Scope.RESOURCE_FILE_SCOPE, Scope.RESOURCE_FILE_SCOPE));
-
- assertEquals(EnumSet.of(Scope.RESOURCE_FILE),
- Scope.intersect(
- EnumSet.of(Scope.RESOURCE_FILE),
- EnumSet.of(Scope.RESOURCE_FILE)));
-
- assertEquals(EnumSet.of(Scope.RESOURCE_FILE),
- Scope.intersect(
- EnumSet.of(Scope.RESOURCE_FILE, Scope.JAVA_FILE),
- EnumSet.of(Scope.RESOURCE_FILE)));
-
- assertEquals(EnumSet.of(Scope.JAVA_FILE),
- Scope.intersect(
- EnumSet.of(Scope.RESOURCE_FILE, Scope.JAVA_FILE),
- EnumSet.of(Scope.JAVA_FILE)));
-
- assertEquals(EnumSet.of(Scope.RESOURCE_FILE),
- Scope.intersect(
- EnumSet.of(Scope.RESOURCE_FILE),
- EnumSet.of(Scope.RESOURCE_FILE, Scope.JAVA_FILE)));
-
- assertEquals(EnumSet.of(Scope.JAVA_FILE),
- Scope.intersect(
- EnumSet.of(Scope.JAVA_FILE),
- EnumSet.of(Scope.RESOURCE_FILE, Scope.JAVA_FILE)));
-
- assertTrue(Scope.intersect(
- EnumSet.of(Scope.JAVA_FILE), EnumSet.of(Scope.RESOURCE_FILE)).isEmpty());
- }
-}
diff --git a/lint/libs/Android.mk b/lint/libs/Android.mk
deleted file mode 100644
index 67aeea2..0000000
--- a/lint/libs/Android.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2011 The Android Open Source Project
-#
-CHECKERLIBS_LOCAL_DIR := $(call my-dir)
-include $(CHECKERLIBS_LOCAL_DIR)/lint_api/Android.mk
-include $(CHECKERLIBS_LOCAL_DIR)/lint_checks/Android.mk
diff --git a/lint/libs/lint_api/.classpath b/lint/libs/lint_api/.classpath
deleted file mode 100644
index 63e37d2..0000000
--- a/lint/libs/lint_api/.classpath
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry excluding="Android.mk" kind="src" path="src/main/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src-4.0.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-tree-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src-4.0.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src-4.0.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/lombok-ast/lombok-ast-0.2.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/lombok-ast/src-4.0.zip"/>
- <classpathentry combineaccessrules="false" kind="src" path="/layoutlib_api"/>
- <classpathentry combineaccessrules="false" kind="src" path="/sdklib"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/lint/libs/lint_api/.project b/lint/libs/lint_api/.project
deleted file mode 100644
index 7c50676..0000000
--- a/lint/libs/lint_api/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>lint-api</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/lint/libs/lint_api/.settings/org.eclipse.jdt.core.prefs b/lint/libs/lint_api/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/lint/libs/lint_api/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/lint/libs/lint_api/.settings/org.moreunit.prefs b/lint/libs/lint_api/.settings/org.moreunit.prefs
deleted file mode 100644
index 73d4d8e..0000000
--- a/lint/libs/lint_api/.settings/org.moreunit.prefs
+++ /dev/null
@@ -1,6 +0,0 @@
-#Tue Oct 18 10:20:08 PDT 2011
-eclipse.preferences.version=1
-org.moreunit.extendedTestMethodSearch=true
-org.moreunit.prefixes=
-org.moreunit.unitsourcefolder=lint-api\:src\:lint_check-tests\:src
-org.moreunit.useprojectsettings=true
diff --git a/lint/libs/lint_api/Android.mk b/lint/libs/lint_api/Android.mk
deleted file mode 100644
index e30db14..0000000
--- a/lint/libs/lint_api/Android.mk
+++ /dev/null
@@ -1,40 +0,0 @@
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# The lint_api code has moved to tools/base/lint_api.
-# The rule below uses the prebuilt lint_api.jar.
-#
-# If you want to run the tests, cd to tools/base/lint_api
-# and run ./gradlew :lint_api:test
-
-LOCAL_JAVA_LIBRARIES := \
- lombok-ast-0.2 \
- common \
- sdklib \
- layoutlib_api \
- asm-tools \
- asm-tree-tools \
- guava-tools
-
-LOCAL_MODULE := lint_api
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PREBUILT_JAVA_LIBRARIES := \
- ../../../../prebuilts/devtools/tools/lib/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/lint/libs/lint_api/NOTICE b/lint/libs/lint_api/NOTICE
deleted file mode 100644
index becc120..0000000
--- a/lint/libs/lint_api/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2011, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/lint/libs/lint_checks/.classpath b/lint/libs/lint_checks/.classpath
deleted file mode 100644
index 03bbecd..0000000
--- a/lint/libs/lint_checks/.classpath
+++ /dev/null
@@ -1,15 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/lint-api"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src-4.0.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-tree-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src-4.0.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/asm-tools/asm-analysis-4.0.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/asm-tools/src-4.0.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src-4.0.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/lombok-ast/lombok-ast-0.2.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/lombok-ast/src-4.0.zip"/>
- <classpathentry combineaccessrules="false" kind="src" path="/layoutlib_api"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry combineaccessrules="false" kind="src" path="/sdklib"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/lint/libs/lint_checks/.project b/lint/libs/lint_checks/.project
deleted file mode 100644
index 0dc9856..0000000
--- a/lint/libs/lint_checks/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>lint-checks</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/lint/libs/lint_checks/.settings/org.eclipse.jdt.core.prefs b/lint/libs/lint_checks/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/lint/libs/lint_checks/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/lint/libs/lint_checks/.settings/org.moreunit.prefs b/lint/libs/lint_checks/.settings/org.moreunit.prefs
deleted file mode 100644
index 1777680..0000000
--- a/lint/libs/lint_checks/.settings/org.moreunit.prefs
+++ /dev/null
@@ -1,5 +0,0 @@
-#Wed Oct 12 13:47:50 PDT 2011
-eclipse.preferences.version=1
-org.moreunit.prefixes=
-org.moreunit.unitsourcefolder=lint-checks\:src\:lint_check-tests\:src
-org.moreunit.useprojectsettings=true
diff --git a/lint/libs/lint_checks/Android.mk b/lint/libs/lint_checks/Android.mk
deleted file mode 100644
index 4229820..0000000
--- a/lint/libs/lint_checks/Android.mk
+++ /dev/null
@@ -1,43 +0,0 @@
-# Copyright 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# The lint_checks code has moved to tools/base/lint_checks.
-# The rule below uses the prebuilt lint_checks.jar.
-#
-# If you want to run the tests, cd to tools/base/lint_checks
-# and run ./gradlew :lint_checks:test
-# Only compile source java files in this lib.
-
-LOCAL_JAVA_LIBRARIES := \
- common \
- sdklib \
- layoutlib_api \
- lombok-ast-0.2 \
- lint_api \
- asm-tools \
- asm-tree-tools \
- asm-analysis-tools \
- guava-tools
-
-LOCAL_MODULE := lint_checks
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PREBUILT_JAVA_LIBRARIES := \
- ../../../../prebuilts/devtools/tools/lib/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/manifmerger/.classpath b/manifmerger/.classpath
deleted file mode 100644
index a8293f7..0000000
--- a/manifmerger/.classpath
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/test/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry combineaccessrules="false" kind="src" path="/SdkLib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/manifmerger/.gitignore b/manifmerger/.gitignore
deleted file mode 100644
index 4ff597c..0000000
--- a/manifmerger/.gitignore
+++ /dev/null
@@ -1,3 +0,0 @@
-bin
-build
-
diff --git a/manifmerger/.project b/manifmerger/.project
deleted file mode 100644
index 0d4dcb4..0000000
--- a/manifmerger/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>ManifestMerger</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/manifmerger/.settings/org.eclipse.jdt.core.prefs b/manifmerger/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100755
index 9dbff07..0000000
--- a/manifmerger/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/manifmerger/Android.mk b/manifmerger/Android.mk
deleted file mode 100644
index a9b4915..0000000
--- a/manifmerger/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-# Copyright 2011 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# The manifest-merger code has moved to tools/base/manifmerger.
-# The rule below uses the prebuilt manifmerger.jar.
-#
-# If you want to run the tests, cd to tools/base/manifmerger
-# and run ./gradlew :manifmerger:test
-
-LOCAL_MODULE := manifmerger
-LOCAL_MODULE_TAGS := optional
-LOCAL_JAVA_LIBRARIES := common sdklib
-
-LOCAL_PREBUILT_JAVA_LIBRARIES := \
- ../../prebuilts/devtools/tools/lib/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/monkeyrunner/Android.mk b/monkeyrunner/Android.mk
deleted file mode 100644
index 21cf67a..0000000
--- a/monkeyrunner/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Copyright (C) 2009 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-MONKEYRUNNER_LOCAL_DIR := $(call my-dir)
-include $(MONKEYRUNNER_LOCAL_DIR)/etc/Android.mk
-include $(MONKEYRUNNER_LOCAL_DIR)/src/Android.mk
-include $(MONKEYRUNNER_LOCAL_DIR)/test/Android.mk
diff --git a/monkeyrunner/MODULE_LICENSE_APACHE2 b/monkeyrunner/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/monkeyrunner/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/monkeyrunner/NOTICE b/monkeyrunner/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/monkeyrunner/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/monkeyrunner/etc/Android.mk b/monkeyrunner/etc/Android.mk
deleted file mode 100644
index dd7d651..0000000
--- a/monkeyrunner/etc/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Copyright (C) 2009 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_PREBUILT_EXECUTABLES := monkeyrunner
-LOCAL_MODULE_TAGS := debug
-include $(BUILD_HOST_PREBUILT)
diff --git a/monkeyrunner/etc/manifest.txt b/monkeyrunner/etc/manifest.txt
deleted file mode 100644
index 706842e..0000000
--- a/monkeyrunner/etc/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Main-Class: com.android.monkeyrunner.MonkeyRunnerStarter
diff --git a/monkeyrunner/etc/monkeyrunner b/monkeyrunner/etc/monkeyrunner
deleted file mode 100755
index 2485694..0000000
--- a/monkeyrunner/etc/monkeyrunner
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/bin/sh
-# Copyright 2005-2007, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
- newProg=`/bin/ls -ld "${prog}"`
- newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
- if expr "x${newProg}" : 'x/' >/dev/null; then
- prog="${newProg}"
- else
- progdir=`dirname "${prog}"`
- prog="${progdir}/${newProg}"
- fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/`basename "${prog}"`
-cd "${oldwd}"
-
-jarfile=monkeyrunner.jar
-frameworkdir="$progdir"
-libdir="$progdir"
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/tools/lib
- libdir=`dirname "$progdir"`/tools/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/framework
- libdir=`dirname "$progdir"`/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- echo `basename "$prog"`": can't find $jarfile"
- exit 1
-fi
-
-
-# Check args.
-if [ debug = "$1" ]; then
- # add this in for debugging
- java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
- shift 1
-else
- java_debug=
-fi
-
-if [ "$OSTYPE" = "cygwin" ] ; then
- jarpath=`cygpath -w "$frameworkdir/$jarfile"`
- progdir=`cygpath -w "$progdir"`
-else
- jarpath="$frameworkdir/$jarfile"
-fi
-
-# Figure out the path to the swt.jar for the current architecture.
-# if ANDROID_SWT is defined, then just use this.
-# else, if running in the Android source tree, then look for the correct swt folder in prebuilt
-# else, look for the correct swt folder in the SDK under tools/lib/
-swtpath=""
-if [ -n "$ANDROID_SWT" ]; then
- swtpath="$ANDROID_SWT"
-else
- vmarch=`java -jar "${frameworkdir}"/archquery.jar`
- if [ -n "$ANDROID_BUILD_TOP" ]; then
- osname=`uname -s | tr A-Z a-z`
- swtpath="${ANDROID_BUILD_TOP}/prebuilts/tools/${osname}-${vmarch}/swt"
- elif [ -d "$frameworkdir/$vmarch" ]; then
- swtpath="${frameworkdir}/${vmarch}"
- else
- swtpath="${frameworkdir}"
- fi
-fi
-
-if [ ! -d "$swtpath" ]; then
- echo "SWT folder '${swtpath}' does not exist."
- echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform."
- exit 1
-fi
-
-# need to use "java.ext.dirs" because "-jar" causes classpath to be ignored
-# might need more memory, e.g. -Xmx128M
-exec java -Xmx128M $os_opts $java_debug -Djava.ext.dirs="$frameworkdir:$swtpath" -Djava.library.path="$libdir" -Dcom.android.monkeyrunner.bindir="$progdir" -jar "$jarpath" "$@"
diff --git a/monkeyrunner/etc/monkeyrunner.bat b/monkeyrunner/etc/monkeyrunner.bat
deleted file mode 100644
index 5028b3f..0000000
--- a/monkeyrunner/etc/monkeyrunner.bat
+++ /dev/null
@@ -1,63 +0,0 @@
-@echo off
-rem Copyright (C) 2010 The Android Open Source Project
-rem
-rem Licensed under the Apache License, Version 2.0 (the "License");
-rem you may not use this file except in compliance with the License.
-rem You may obtain a copy of the License at
-rem
-rem http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-
-rem don't modify the caller's environment
-setlocal
-
-rem Set up prog to be the path of this script, including following symlinks,
-rem and set up progdir to be the fully-qualified pathname of its directory.
-set prog=%~f0
-
-rem Change current directory and drive to where the script is, to avoid
-rem issues with directories containing whitespaces.
-cd /d %~dp0
-
-rem Check we have a valid Java.exe in the path.
-set java_exe=
-call lib\find_java.bat
-if not defined java_exe goto :EOF
-
-set jarfile=monkeyrunner.jar
-set frameworkdir=
-set libdir=
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=lib\
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=..\framework\
-
-:JarFileOk
-
-set jarpath=%frameworkdir%%jarfile%
-
-if not defined ANDROID_SWT goto QueryArch
- set swt_path=%ANDROID_SWT%
- goto SwtDone
-
-:QueryArch
-
- for /f %%a in ('%java_exe% -jar %frameworkdir%archquery.jar') do set swt_path=%frameworkdir%%%a
-
-:SwtDone
-
-if exist %swt_path% goto SetPath
- echo SWT folder '%swt_path%' does not exist.
- echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
- exit /B
-
-:SetPath
-
-call %java_exe% -Xmx512m -Djava.ext.dirs=%frameworkdir%;%swt_path% -Dcom.android.monkeyrunner.bindir=..\framework -jar %jarpath% %*
diff --git a/monkeyrunner/jython/test/MonkeyRunner_test.py b/monkeyrunner/jython/test/MonkeyRunner_test.py
deleted file mode 100644
index cc4d1f2..0000000
--- a/monkeyrunner/jython/test/MonkeyRunner_test.py
+++ /dev/null
@@ -1,54 +0,0 @@
-#!/usr/bin/python2.4
-#
-# Copyright 2010, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the 'License');
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an 'AS IS' BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Test cases for com.android.monkeyrunner.MonkeyRunner."""
-
-import time
-import unittest
-
-from com.android.monkeyrunner import MonkeyRunner
-
-
-class TestMonkeyRunnerArgParsing(unittest.TestCase):
- """Test ArgParsing for the MonkeyRunner methods."""
- def testWaitForConnectionNoArgs(self):
- MonkeyRunner.waitForConnection()
-
- def testWaitForConnectionSingleArg(self):
- MonkeyRunner.waitForConnection(2)
-
- def testWaitForConnectionDoubleArg(self):
- MonkeyRunner.waitForConnection(2, '*')
-
- def testWaitForConnectionKeywordArg(self):
- MonkeyRunner.waitForConnection(timeout=2, deviceId='foo')
-
- def testWaitForConnectionKeywordArgTooMany(self):
- try:
- MonkeyRunner.waitForConnection(timeout=2, deviceId='foo', extra='fail')
- except TypeError:
- return
- self.fail('Should have raised TypeError')
-
- def testSleep(self):
- start = time.time()
- MonkeyRunner.sleep(1.5)
- end = time.time()
-
- self.assertTrue(end - start >= 1.5)
-
-if __name__ == '__main__':
- unittest.main()
diff --git a/monkeyrunner/jython/test/all_tests.py b/monkeyrunner/jython/test/all_tests.py
deleted file mode 100644
index 2dd0ab4..0000000
--- a/monkeyrunner/jython/test/all_tests.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/python2.4
-#
-# Copyright 2010, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-"""Test runner to run all the tests in this package."""
-
-import os
-import re
-import sys
-import unittest
-
-
-TESTCASE_RE = re.compile('_test\.py$')
-
-
-def AllTestFilesInDir(path):
- """Finds all the unit test files in the given path."""
- return filter(TESTCASE_RE.search, os.listdir(path))
-
-
-def suite(loader=unittest.defaultTestLoader):
- """Creates the all_tests TestSuite."""
- script_parent_path = os.path.abspath(os.path.dirname(sys.argv[0]))
- # Find all the _test.py files in the same directory we are in
- test_files = AllTestFilesInDir(script_parent_path)
- # Convert them into module names
- module_names = [os.path.splitext(f)[0] for f in test_files]
- # And import them
- modules = map(__import__, module_names)
- # And create the test suite for all these modules
- return unittest.TestSuite([loader.loadTestsFromModule(m) for m in modules])
-
-if __name__ == '__main__':
- result = unittest.TextTestRunner().run(suite())
- if not result.wasSuccessful():
- # On failure return an error code
- sys.exit(1)
diff --git a/monkeyrunner/scripts/help.py b/monkeyrunner/scripts/help.py
deleted file mode 100644
index ebc6c10..0000000
--- a/monkeyrunner/scripts/help.py
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/usr/bin/env monkeyrunner
-# Copyright 2010, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-from com.android.monkeyrunner import MonkeyRunner as mr
-
-import os
-import sys
-
-supported_formats = ['html', 'text', 'sdk-docs']
-
-if len(sys.argv) != 3:
- print 'help.py: format output'
- sys.exit(1)
-
-(format, saveto_path) = sys.argv[1:]
-
-if not format.lower() in supported_formats:
- print 'format %s is not a supported format' % format
- sys.exit(2)
-
-output = mr.help(format=format)
-if not output:
- print 'Error generating help format'
- sys.exit(3)
-
-dirname = os.path.dirname(saveto_path)
-try:
- os.makedirs(dirname)
-except:
- print 'oops'
- pass # It already existed
-
-fp = open(saveto_path, 'w')
-fp.write(output)
-fp.close()
-
-sys.exit(0)
diff --git a/monkeyrunner/scripts/monkey_playback.py b/monkeyrunner/scripts/monkey_playback.py
deleted file mode 100644
index 45d801a..0000000
--- a/monkeyrunner/scripts/monkey_playback.py
+++ /dev/null
@@ -1,70 +0,0 @@
-#!/usr/bin/env monkeyrunner
-# Copyright 2010, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-import sys
-from com.android.monkeyrunner import MonkeyRunner
-
-# The format of the file we are parsing is very carfeully constructed.
-# Each line corresponds to a single command. The line is split into 2
-# parts with a | character. Text to the left of the pipe denotes
-# which command to run. The text to the right of the pipe is a python
-# dictionary (it can be evaled into existence) that specifies the
-# arguments for the command. In most cases, this directly maps to the
-# keyword argument dictionary that could be passed to the underlying
-# command.
-
-# Lookup table to map command strings to functions that implement that
-# command.
-CMD_MAP = {
- 'TOUCH': lambda dev, arg: dev.touch(**arg),
- 'DRAG': lambda dev, arg: dev.drag(**arg),
- 'PRESS': lambda dev, arg: dev.press(**arg),
- 'TYPE': lambda dev, arg: dev.type(**arg),
- 'WAIT': lambda dev, arg: MonkeyRunner.sleep(**arg)
- }
-
-# Process a single file for the specified device.
-def process_file(fp, device):
- for line in fp:
- (cmd, rest) = line.split('|')
- try:
- # Parse the pydict
- rest = eval(rest)
- except:
- print 'unable to parse options'
- continue
-
- if cmd not in CMD_MAP:
- print 'unknown command: ' + cmd
- continue
-
- CMD_MAP[cmd](device, rest)
-
-
-def main():
- file = sys.argv[1]
- fp = open(file, 'r')
-
- device = MonkeyRunner.waitForConnection()
-
- process_file(fp, device)
- fp.close();
-
-
-if __name__ == '__main__':
- main()
-
-
-
diff --git a/monkeyrunner/scripts/monkey_recorder.py b/monkeyrunner/scripts/monkey_recorder.py
deleted file mode 100644
index 29e6e50..0000000
--- a/monkeyrunner/scripts/monkey_recorder.py
+++ /dev/null
@@ -1,20 +0,0 @@
-#!/usr/bin/env monkeyrunner
-# Copyright 2010, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from com.android.monkeyrunner import MonkeyRunner as mr
-from com.android.monkeyrunner.recorder import MonkeyRecorder as recorder
-
-device = mr.waitForConnection()
-recorder.start(device)
diff --git a/monkeyrunner/scripts/mr_pydoc.py b/monkeyrunner/scripts/mr_pydoc.py
deleted file mode 100644
index 5c35296..0000000
--- a/monkeyrunner/scripts/mr_pydoc.py
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/usr/bin/env monkeyrunner
-# Copyright 2010, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-import com.android.monkeyrunner.MonkeyRunnerHelp as mrh
-import pydoc
-import sys
-
-def create_page(title, document):
- return """
-page.title=%s
-@jd:body
-%s
-</body>
-</html>
-""" % (title, document)
-
-BASEDIR = 'frameworks/base/docs/html/guide/topics/testing/'
-
-def main():
- document = ""
-
- for clz in mrh.getAllDocumentedClasses():
- object, name = pydoc.resolve(str(clz), 0)
- document += pydoc.html.document(object, name)
-
- page = create_page('MonkeyRunner API', document)
- file = open(BASEDIR + 'monkeyrunner_api.html', 'w')
- file.write(page)
- file.close()
-
-if __name__ == '__main__':
- main()
diff --git a/monkeyrunner/src/Android.mk b/monkeyrunner/src/Android.mk
deleted file mode 100644
index ddaed16..0000000
--- a/monkeyrunner/src/Android.mk
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# Copyright (C) 2009 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_JAR_MANIFEST := ../etc/manifest.txt
-LOCAL_JAVA_LIBRARIES := \
- chimpchat \
- ddmlib \
- jython \
- guavalib \
- jsilver \
- sdklib \
- hierarchyviewerlib \
- swt
-
-LOCAL_JAVA_RESOURCE_DIRS := resources
-
-LOCAL_MODULE := monkeyrunner
-LOCAL_MODULE_TAGS := debug
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-include $(CLEAR_VARS)
-
-MR_GEN_DOC_DIR := $(OUT_DOCS)/gen/guide/developing/tools
-MONKEYRUNNER_GENERATED_DOC := $(MR_GEN_DOC_DIR)/monkeyrunner-api.jd
-
-HELP_PY_PATH := $(TOP)/sdk/monkeyrunner/scripts/help.py
-
-# Setup documentation generation so we can include the MonkeyRunner
-# docs in the SDK.
-$(MONKEYRUNNER_GENERATED_DOC): monkeyrunner
- mkdir -p $(MR_GEN_DOC_DIR)
- $(HOST_OUT)/bin/monkeyrunner $(HELP_PY_PATH) sdk-docs $<
-
-ALL_GENERATED_DOCS += $(MONKEYRUNNER_GENERATED_DOC)
diff --git a/monkeyrunner/src/com/android/monkeyrunner/JythonUtils.java b/monkeyrunner/src/com/android/monkeyrunner/JythonUtils.java
deleted file mode 100644
index badddff..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/JythonUtils.java
+++ /dev/null
@@ -1,504 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner;
-
-import java.lang.reflect.AccessibleObject;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.text.BreakIterator;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.python.core.ArgParser;
-import org.python.core.ClassDictInit;
-import org.python.core.Py;
-import org.python.core.PyBoolean;
-import org.python.core.PyDictionary;
-import org.python.core.PyFloat;
-import org.python.core.PyInteger;
-import org.python.core.PyList;
-import org.python.core.PyNone;
-import org.python.core.PyObject;
-import org.python.core.PyReflectedField;
-import org.python.core.PyReflectedFunction;
-import org.python.core.PyString;
-import org.python.core.PyStringMap;
-import org.python.core.PyTuple;
-
-import com.android.monkeyrunner.doc.MonkeyRunnerExported;
-import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Maps;
-import com.google.common.collect.Sets;
-import com.google.common.collect.ImmutableMap.Builder;
-
-/**
- * Collection of useful utilities function for interacting with the Jython interpreter.
- */
-public final class JythonUtils {
- private static final Logger LOG = Logger.getLogger(JythonUtils.class.getCanonicalName());
- private JythonUtils() { }
-
- /**
- * Mapping of PyObject classes to the java class we want to convert them to.
- */
- private static final Map<Class<? extends PyObject>, Class<?>> PYOBJECT_TO_JAVA_OBJECT_MAP;
- static {
- Builder<Class<? extends PyObject>, Class<?>> builder = ImmutableMap.builder();
-
- builder.put(PyString.class, String.class);
- // What python calls float, most people call double
- builder.put(PyFloat.class, Double.class);
- builder.put(PyInteger.class, Integer.class);
- builder.put(PyBoolean.class, Boolean.class);
-
- PYOBJECT_TO_JAVA_OBJECT_MAP = builder.build();
- }
-
- /**
- * Utility method to be called from Jython bindings to give proper handling of keyword and
- * positional arguments.
- *
- * @param args the PyObject arguments from the binding
- * @param kws the keyword arguments from the binding
- * @return an ArgParser for this binding, or null on error
- */
- public static ArgParser createArgParser(PyObject[] args, String[] kws) {
- StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();
- // Up 2 levels in the current stack to give us the calling function
- StackTraceElement element = stackTrace[2];
-
- String methodName = element.getMethodName();
- String className = element.getClassName();
-
- Class<?> clz;
- try {
- clz = Class.forName(className);
- } catch (ClassNotFoundException e) {
- LOG.log(Level.SEVERE, "Got exception: ", e);
- return null;
- }
-
- Method m;
-
- try {
- m = clz.getMethod(methodName, PyObject[].class, String[].class);
- } catch (SecurityException e) {
- LOG.log(Level.SEVERE, "Got exception: ", e);
- return null;
- } catch (NoSuchMethodException e) {
- LOG.log(Level.SEVERE, "Got exception: ", e);
- return null;
- }
-
- MonkeyRunnerExported annotation = m.getAnnotation(MonkeyRunnerExported.class);
- return new ArgParser(methodName, args, kws,
- annotation.args());
- }
-
- /**
- * Get a python floating point value from an ArgParser.
- *
- * @param ap the ArgParser to get the value from.
- * @param position the position in the parser
- * @return the double value
- */
- public static double getFloat(ArgParser ap, int position) {
- PyObject arg = ap.getPyObject(position);
-
- if (Py.isInstance(arg, PyFloat.TYPE)) {
- return ((PyFloat) arg).asDouble();
- }
- if (Py.isInstance(arg, PyInteger.TYPE)) {
- return ((PyInteger) arg).asDouble();
- }
- throw Py.TypeError("Unable to parse argument: " + position);
- }
-
- /**
- * Get a python floating point value from an ArgParser.
- *
- * @param ap the ArgParser to get the value from.
- * @param position the position in the parser
- * @param defaultValue the default value to return if the arg isn't specified.
- * @return the double value
- */
- public static double getFloat(ArgParser ap, int position, double defaultValue) {
- PyObject arg = ap.getPyObject(position, new PyFloat(defaultValue));
-
- if (Py.isInstance(arg, PyFloat.TYPE)) {
- return ((PyFloat) arg).asDouble();
- }
- if (Py.isInstance(arg, PyInteger.TYPE)) {
- return ((PyInteger) arg).asDouble();
- }
- throw Py.TypeError("Unable to parse argument: " + position);
- }
-
- /**
- * Get a list of arguments from an ArgParser.
- *
- * @param ap the ArgParser
- * @param position the position in the parser to get the argument from
- * @return a list of those items
- */
- @SuppressWarnings("unchecked")
- public static List<Object> getList(ArgParser ap, int position) {
- PyObject arg = ap.getPyObject(position, Py.None);
- if (Py.isInstance(arg, PyNone.TYPE)) {
- return Collections.emptyList();
- }
-
- List<Object> ret = Lists.newArrayList();
- PyList array = (PyList) arg;
- for (int x = 0; x < array.__len__(); x++) {
- PyObject item = array.__getitem__(x);
-
- Class<?> javaClass = PYOBJECT_TO_JAVA_OBJECT_MAP.get(item.getClass());
- if (javaClass != null) {
- ret.add(item.__tojava__(javaClass));
- }
- }
- return ret;
- }
-
- /**
- * Get a dictionary from an ArgParser. For ease of use, key types are always coerced to
- * strings. If key type cannot be coeraced to string, an exception is raised.
- *
- * @param ap the ArgParser to work with
- * @param position the position in the parser to get.
- * @return a Map mapping the String key to the value
- */
- public static Map<String, Object> getMap(ArgParser ap, int position) {
- PyObject arg = ap.getPyObject(position, Py.None);
- if (Py.isInstance(arg, PyNone.TYPE)) {
- return Collections.emptyMap();
- }
-
- Map<String, Object> ret = Maps.newHashMap();
- // cast is safe as getPyObjectbyType ensures it
- PyDictionary dict = (PyDictionary) arg;
- PyList items = dict.items();
- for (int x = 0; x < items.__len__(); x++) {
- // It's a list of tuples
- PyTuple item = (PyTuple) items.__getitem__(x);
- // We call str(key) on the key to get the string and then convert it to the java string.
- String key = (String) item.__getitem__(0).__str__().__tojava__(String.class);
- PyObject value = item.__getitem__(1);
-
- // Look up the conversion type and convert the value
- Class<?> javaClass = PYOBJECT_TO_JAVA_OBJECT_MAP.get(value.getClass());
- if (javaClass != null) {
- ret.put(key, value.__tojava__(javaClass));
- }
- }
- return ret;
- }
-
- private static PyObject convertObject(Object o) {
- if (o instanceof String) {
- return new PyString((String) o);
- } else if (o instanceof Double) {
- return new PyFloat((Double) o);
- } else if (o instanceof Integer) {
- return new PyInteger((Integer) o);
- } else if (o instanceof Float) {
- float f = (Float) o;
- return new PyFloat(f);
- } else if (o instanceof Boolean) {
- return new PyBoolean((Boolean) o);
- }
- return Py.None;
- }
-
- /**
- * Convert the given Java Map into a PyDictionary.
- *
- * @param map the map to convert
- * @return the python dictionary
- */
- public static PyDictionary convertMapToDict(Map<String, Object> map) {
- Map<PyObject, PyObject> resultMap = Maps.newHashMap();
-
- for (Entry<String, Object> entry : map.entrySet()) {
- resultMap.put(new PyString(entry.getKey()),
- convertObject(entry.getValue()));
- }
- return new PyDictionary(resultMap);
- }
-
- /**
- * This function should be called from classDictInit for any classes that are being exported
- * to jython. This jython converts all the MonkeyRunnerExported annotations for the given class
- * into the proper python form. It also removes any functions listed in the dictionary that
- * aren't specifically annotated in the java class.
- *
- * NOTE: Make sure the calling class implements {@link ClassDictInit} to ensure that
- * classDictInit gets called.
- *
- * @param clz the class to examine.
- * @param dict the dictionary to update.
- */
- public static void convertDocAnnotationsForClass(Class<?> clz, PyObject dict) {
- Preconditions.checkNotNull(dict);
- Preconditions.checkArgument(dict instanceof PyStringMap);
-
- // See if the class has the annotation
- if (clz.isAnnotationPresent(MonkeyRunnerExported.class)) {
- MonkeyRunnerExported doc = clz.getAnnotation(MonkeyRunnerExported.class);
- String fullDoc = buildClassDoc(doc, clz);
- dict.__setitem__("__doc__", new PyString(fullDoc));
- }
-
- // Get all the keys from the dict and put them into a set. As we visit the annotated methods,
- // we will remove them from this set. At the end, these are the "hidden" methods that
- // should be removed from the dict
- Collection<String> functions = Sets.newHashSet();
- for (PyObject item : dict.asIterable()) {
- functions.add(item.toString());
- }
-
- // And remove anything that starts with __, as those are pretty important to retain
- functions = Collections2.filter(functions, new Predicate<String>() {
- @Override
- public boolean apply(String value) {
- return !value.startsWith("__");
- }
- });
-
- // Look at all the methods in the class and find the one's that have the
- // @MonkeyRunnerExported annotation.
- for (Method m : clz.getMethods()) {
- if (m.isAnnotationPresent(MonkeyRunnerExported.class)) {
- String methodName = m.getName();
- PyObject pyFunc = dict.__finditem__(methodName);
- if (pyFunc != null && pyFunc instanceof PyReflectedFunction) {
- PyReflectedFunction realPyFunc = (PyReflectedFunction) pyFunc;
- MonkeyRunnerExported doc = m.getAnnotation(MonkeyRunnerExported.class);
-
- realPyFunc.__doc__ = new PyString(buildDoc(doc));
- functions.remove(methodName);
- }
- }
- }
-
- // Also look at all the fields (both static and instance).
- for (Field f : clz.getFields()) {
- if (f.isAnnotationPresent(MonkeyRunnerExported.class)) {
- String fieldName = f.getName();
- PyObject pyField = dict.__finditem__(fieldName);
- if (pyField != null && pyField instanceof PyReflectedField) {
- PyReflectedField realPyfield = (PyReflectedField) pyField;
- MonkeyRunnerExported doc = f.getAnnotation(MonkeyRunnerExported.class);
-
- // TODO: figure out how to set field documentation. __doc__ is Read Only
- // in this context.
- // realPyfield.__setattr__("__doc__", new PyString(buildDoc(doc)));
- functions.remove(fieldName);
- }
- }
- }
-
- // Now remove any elements left from the functions collection
- for (String name : functions) {
- dict.__delitem__(name);
- }
- }
-
- private static final Predicate<AccessibleObject> SHOULD_BE_DOCUMENTED = new Predicate<AccessibleObject>() {
- @Override
- public boolean apply(AccessibleObject ao) {
- return ao.isAnnotationPresent(MonkeyRunnerExported.class);
- }
- };
- private static final Predicate<Field> IS_FIELD_STATIC = new Predicate<Field>() {
- @Override
- public boolean apply(Field f) {
- return (f.getModifiers() & Modifier.STATIC) != 0;
- }
- };
-
- /**
- * build a jython doc-string for a class from the annotation and the fields
- * contained within the class
- *
- * @param doc the annotation
- * @param clz the class to be documented
- * @return the doc-string
- */
- private static String buildClassDoc(MonkeyRunnerExported doc, Class<?> clz) {
- // Below the class doc, we need to document all the documented field this class contains
- Collection<Field> annotatedFields = Collections2.filter(Arrays.asList(clz.getFields()), SHOULD_BE_DOCUMENTED);
- Collection<Field> staticFields = Collections2.filter(annotatedFields, IS_FIELD_STATIC);
- Collection<Field> nonStaticFields = Collections2.filter(annotatedFields, Predicates.not(IS_FIELD_STATIC));
-
- StringBuilder sb = new StringBuilder();
- for (String line : splitString(doc.doc(), 80)) {
- sb.append(line).append("\n");
- }
-
- if (staticFields.size() > 0) {
- sb.append("\nClass Fields: \n");
- for (Field f : staticFields) {
- sb.append(buildFieldDoc(f));
- }
- }
-
- if (nonStaticFields.size() > 0) {
- sb.append("\n\nFields: \n");
- for (Field f : nonStaticFields) {
- sb.append(buildFieldDoc(f));
- }
- }
-
- return sb.toString();
- }
-
- /**
- * Build a doc-string for the annotated field.
- *
- * @param f the field.
- * @return the doc-string.
- */
- private static String buildFieldDoc(Field f) {
- MonkeyRunnerExported annotation = f.getAnnotation(MonkeyRunnerExported.class);
- StringBuilder sb = new StringBuilder();
- int indentOffset = 2 + 3 + f.getName().length();
- String indent = makeIndent(indentOffset);
-
- sb.append(" ").append(f.getName()).append(" - ");
-
- boolean first = true;
- for (String line : splitString(annotation.doc(), 80 - indentOffset)) {
- if (first) {
- first = false;
- sb.append(line).append("\n");
- } else {
- sb.append(indent).append(line).append("\n");
- }
- }
-
-
- return sb.toString();
- }
-
- /**
- * Build a jython doc-string from the MonkeyRunnerExported annotation.
- *
- * @param doc the annotation to build from
- * @return a jython doc-string
- */
- private static String buildDoc(MonkeyRunnerExported doc) {
- Collection<String> docs = splitString(doc.doc(), 80);
- StringBuilder sb = new StringBuilder();
- for (String d : docs) {
- sb.append(d).append("\n");
- }
-
- if (doc.args() != null && doc.args().length > 0) {
- String[] args = doc.args();
- String[] argDocs = doc.argDocs();
-
- sb.append("\n Args:\n");
- for (int x = 0; x < doc.args().length; x++) {
- sb.append(" ").append(args[x]);
- if (argDocs != null && argDocs.length > x) {
- sb.append(" - ");
- int indentOffset = args[x].length() + 3 + 4;
- Collection<String> lines = splitString(argDocs[x], 80 - indentOffset);
- boolean first = true;
- String indent = makeIndent(indentOffset);
- for (String line : lines) {
- if (first) {
- first = false;
- sb.append(line).append("\n");
- } else {
- sb.append(indent).append(line).append("\n");
- }
- }
- }
- }
- }
-
- return sb.toString();
- }
-
- private static String makeIndent(int indentOffset) {
- if (indentOffset == 0) {
- return "";
- }
- StringBuffer sb = new StringBuffer();
- while (indentOffset > 0) {
- sb.append(' ');
- indentOffset--;
- }
- return sb.toString();
- }
-
- private static Collection<String> splitString(String source, int offset) {
- BreakIterator boundary = BreakIterator.getLineInstance();
- boundary.setText(source);
-
- List<String> lines = Lists.newArrayList();
- StringBuilder currentLine = new StringBuilder();
- int start = boundary.first();
-
- for (int end = boundary.next();
- end != BreakIterator.DONE;
- start = end, end = boundary.next()) {
- String b = source.substring(start, end);
- if (currentLine.length() + b.length() < offset) {
- currentLine.append(b);
- } else {
- // emit the old line
- lines.add(currentLine.toString());
- currentLine = new StringBuilder(b);
- }
- }
- lines.add(currentLine.toString());
- return lines;
- }
-
- /**
- * Obtain the set of method names available from Python.
- *
- * @param clazz Class to inspect.
- * @return set of method names annotated with {@code MonkeyRunnerExported}.
- */
- public static Set<String> getMethodNames(Class<?> clazz) {
- HashSet<String> methodNames = new HashSet<String>();
- for (Method m: clazz.getMethods()) {
- if (m.isAnnotationPresent(MonkeyRunnerExported.class)) {
- methodNames.add(m.getName());
- }
- }
- return methodNames;
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/MonkeyDevice.java b/monkeyrunner/src/com/android/monkeyrunner/MonkeyDevice.java
deleted file mode 100644
index 5dc7e7b..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/MonkeyDevice.java
+++ /dev/null
@@ -1,439 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner;
-
-import com.google.common.base.Functions;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Collections2;
-
-import com.android.chimpchat.ChimpChat;
-import com.android.chimpchat.core.By;
-import com.android.chimpchat.core.IChimpView;
-import com.android.chimpchat.core.IChimpDevice;
-import com.android.chimpchat.core.IChimpImage;
-import com.android.chimpchat.core.TouchPressType;
-import com.android.chimpchat.hierarchyviewer.HierarchyViewer;
-
-import com.android.monkeyrunner.doc.MonkeyRunnerExported;
-
-import org.python.core.ArgParser;
-import org.python.core.ClassDictInit;
-import org.python.core.Py;
-import org.python.core.PyDictionary;
-import org.python.core.PyList;
-import org.python.core.PyObject;
-import org.python.core.PyTuple;
-
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.logging.Logger;
-
-/*
- * Abstract base class that represents a single connected Android
- * Device and provides MonkeyRunner API methods for interacting with
- * that device. Each backend will need to create a concrete
- * implementation of this class.
- */
-@MonkeyRunnerExported(doc = "Represents a device attached to the system.")
-public class MonkeyDevice extends PyObject implements ClassDictInit {
- private static final Logger LOG = Logger.getLogger(MonkeyDevice.class.getName());
-
- public static void classDictInit(PyObject dict) {
- JythonUtils.convertDocAnnotationsForClass(MonkeyDevice.class, dict);
- }
-
- @MonkeyRunnerExported(doc = "Sends a DOWN event when used with touch() or press().")
- public static final String DOWN = TouchPressType.DOWN.getIdentifier();
-
- @MonkeyRunnerExported(doc = "Sends an UP event when used with touch() or press().")
- public static final String UP = TouchPressType.UP.getIdentifier();
-
- @MonkeyRunnerExported(doc = "Sends a DOWN event, immediately followed by an UP event when used with touch() or press()")
- public static final String DOWN_AND_UP = TouchPressType.DOWN_AND_UP.getIdentifier();
-
- @MonkeyRunnerExported(doc = "Sends a MOVE event when used with touch().")
- public static final String MOVE = TouchPressType.MOVE.getIdentifier();
-
- private IChimpDevice impl;
-
- public MonkeyDevice(IChimpDevice impl) {
- this.impl = impl;
- }
-
- public IChimpDevice getImpl() {
- return impl;
- }
-
- @MonkeyRunnerExported(doc = "Get the HierarchyViewer object for the device.",
- returns = "A HierarchyViewer object")
- public HierarchyViewer getHierarchyViewer(PyObject[] args, String[] kws) {
- return impl.getHierarchyViewer();
- }
-
- @MonkeyRunnerExported(doc =
- "Gets the device's screen buffer, yielding a screen capture of the entire display.",
- returns = "A MonkeyImage object (a bitmap wrapper)")
- public MonkeyImage takeSnapshot() {
- IChimpImage image = impl.takeSnapshot();
- return new MonkeyImage(image);
- }
-
- @MonkeyRunnerExported(doc = "Given the name of a variable on the device, " +
- "returns the variable's value",
- args = {"key"},
- argDocs = {"The name of the variable. The available names are listed in " +
- "http://developer.android.com/guide/topics/testing/monkeyrunner.html."},
- returns = "The variable's value")
- public String getProperty(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- return impl.getProperty(ap.getString(0));
- }
-
- @MonkeyRunnerExported(doc = "Synonym for getProperty()",
- args = {"key"},
- argDocs = {"The name of the system variable."},
- returns = "The variable's value.")
- public String getSystemProperty(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- return impl.getSystemProperty(ap.getString(0));
- }
-
- @MonkeyRunnerExported(doc = "Sends a touch event at the specified location",
- args = { "x", "y", "type" },
- argDocs = { "x coordinate in pixels",
- "y coordinate in pixels",
- "touch event type as returned by TouchPressType()"})
- public void touch(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- int x = ap.getInt(0);
- int y = ap.getInt(1);
-
- TouchPressType type = TouchPressType.fromIdentifier(ap.getString(2));
- if (type == null) {
- LOG.warning(String.format("Invalid TouchPressType specified (%s) default used instead",
- ap.getString(2)));
- type = TouchPressType.DOWN_AND_UP;
- }
-
- impl.touch(x, y, type);
- }
-
- @MonkeyRunnerExported(doc = "Simulates dragging (touch, hold, and move) on the device screen.",
- args = { "start", "end", "duration", "steps"},
- argDocs = { "The starting point for the drag (a tuple (x,y) in pixels)",
- "The end point for the drag (a tuple (x,y) in pixels",
- "Duration of the drag in seconds (default is 1.0 seconds)",
- "The number of steps to take when interpolating points. (default is 10)"})
- public void drag(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- PyObject startObject = ap.getPyObject(0);
- if (!(startObject instanceof PyTuple)) {
- throw Py.TypeError("Agrument 0 is not a tuple");
- }
- PyObject endObject = ap.getPyObject(1);
- if (!(endObject instanceof PyTuple)) {
- throw Py.TypeError("Agrument 1 is not a tuple");
- }
-
- PyTuple start = (PyTuple) startObject;
- PyTuple end = (PyTuple) endObject;
-
- int startx = (Integer) start.__getitem__(0).__tojava__(Integer.class);
- int starty = (Integer) start.__getitem__(1).__tojava__(Integer.class);
- int endx = (Integer) end.__getitem__(0).__tojava__(Integer.class);
- int endy = (Integer) end.__getitem__(1).__tojava__(Integer.class);
-
- double seconds = JythonUtils.getFloat(ap, 2, 1.0);
- long ms = (long) (seconds * 1000.0);
-
- int steps = ap.getInt(3, 10);
-
- impl.drag(startx, starty, endx, endy, steps, ms);
- }
-
- @MonkeyRunnerExported(doc = "Send a key event to the specified key",
- args = { "name", "type" },
- argDocs = { "the keycode of the key to press (see android.view.KeyEvent)",
- "touch event type as returned by TouchPressType(). To simulate typing a key, " +
- "send DOWN_AND_UP"})
- public void press(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String name = ap.getString(0);
- String touchType = ap.getString(1, DOWN_AND_UP);
-
- // The old docs had this string, and so in favor of maintaining
- // backwards compatibility, let's special case it to the new one.
- if (touchType.equals("DOWN_AND_UP")){
- touchType = "downAndUp";
- }
- TouchPressType type = TouchPressType.fromIdentifier(touchType);
-
- impl.press(name, type);
- }
-
- @MonkeyRunnerExported(doc = "Types the specified string on the keyboard. This is " +
- "equivalent to calling press(keycode,DOWN_AND_UP) for each character in the string.",
- args = { "message" },
- argDocs = { "The string to send to the keyboard." })
- public void type(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String message = ap.getString(0);
- impl.type(message);
- }
-
- @MonkeyRunnerExported(doc = "Executes an adb shell command and returns the result, if any.",
- args = { "cmd", "timeout"},
- argDocs = { "The adb shell command to execute.",
- "This arg is optional. It specifies the maximum amount of time during which the" +
- "command can go without any output. A value of 0 means the method" +
- "will wait forever. The unit of the timeout is millisecond"},
- returns = "The output from the command.")
- public String shell(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- String cmd = ap.getString(0);
-
- if (args.length == 2) {
- return impl.shell(cmd, ap.getInt(1));
- } else {
- return impl.shell(cmd);
- }
- }
-
- @MonkeyRunnerExported(doc = "Reboots the specified device into a specified bootloader.",
- args = { "into" },
- argDocs = { "the bootloader to reboot into: bootloader, recovery, or None"})
- public void reboot(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String into = ap.getString(0, null);
-
- impl.reboot(into);
- }
-
- @MonkeyRunnerExported(doc = "Installs the specified Android package (.apk file) " +
- "onto the device. If the package already exists on the device, it is replaced.",
- args = { "path" },
- argDocs = { "The package's path and filename on the host filesystem." },
- returns = "True if the install succeeded")
- public boolean installPackage(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String path = ap.getString(0);
- return impl.installPackage(path);
- }
-
- @MonkeyRunnerExported(doc = "Deletes the specified package from the device, including its " +
- "associated data and cache.",
- args = { "package"},
- argDocs = { "The name of the package to delete."},
- returns = "True if remove succeeded")
- public boolean removePackage(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String packageName = ap.getString(0);
- return impl.removePackage(packageName);
- }
-
- @MonkeyRunnerExported(doc = "Starts an Activity on the device by sending an Intent " +
- "constructed from the specified parameters.",
- args = { "uri", "action", "data", "mimetype", "categories", "extras",
- "component", "flags" },
- argDocs = { "The URI for the Intent.",
- "The action for the Intent.",
- "The data URI for the Intent",
- "The mime type for the Intent.",
- "A Python iterable containing the category names for the Intent.",
- "A dictionary of extras to add to the Intent. Types of these extras " +
- "are inferred from the python types of the values.",
- "The component of the Intent.",
- "An iterable of flags for the Intent." +
- "All arguments are optional. The default value for each argument is null." +
- "(see android.content.Intent)"})
-
- public void startActivity(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String uri = ap.getString(0, null);
- String action = ap.getString(1, null);
- String data = ap.getString(2, null);
- String mimetype = ap.getString(3, null);
- Collection<String> categories = Collections2.transform(JythonUtils.getList(ap, 4),
- Functions.toStringFunction());
- Map<String, Object> extras = JythonUtils.getMap(ap, 5);
- String component = ap.getString(6, null);
- int flags = ap.getInt(7, 0);
-
- impl.startActivity(uri, action, data, mimetype, categories, extras, component, flags);
- }
-
- @MonkeyRunnerExported(doc = "Sends a broadcast intent to the device.",
- args = { "uri", "action", "data", "mimetype", "categories", "extras",
- "component", "flags" },
- argDocs = { "The URI for the Intent.",
- "The action for the Intent.",
- "The data URI for the Intent",
- "The mime type for the Intent.",
- "An iterable of category names for the Intent.",
- "A dictionary of extras to add to the Intent. Types of these extras " +
- "are inferred from the python types of the values.",
- "The component of the Intent.",
- "An iterable of flags for the Intent." +
- "All arguments are optional. " + "" +
- "The default value for each argument is null." +
- "(see android.content.Context.sendBroadcast(Intent))"})
- public void broadcastIntent(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String uri = ap.getString(0, null);
- String action = ap.getString(1, null);
- String data = ap.getString(2, null);
- String mimetype = ap.getString(3, null);
- Collection<String> categories = Collections2.transform(JythonUtils.getList(ap, 4),
- Functions.toStringFunction());
- Map<String, Object> extras = JythonUtils.getMap(ap, 5);
- String component = ap.getString(6, null);
- int flags = ap.getInt(7, 0);
-
- impl.broadcastIntent(uri, action, data, mimetype, categories, extras, component, flags);
- }
-
- @MonkeyRunnerExported(doc = "Run the specified package with instrumentation and return " +
- "the output it generates. Use this to run a test package using " +
- "InstrumentationTestRunner.",
- args = { "className", "args" },
- argDocs = { "The class to run with instrumentation. The format is " +
- "packagename/classname. Use packagename to specify the Android package " +
- "to run, and classname to specify the class to run within that package. " +
- "For test packages, this is usually " +
- "testpackagename/InstrumentationTestRunner",
- "A map of strings to objects containing the arguments to pass to this " +
- "instrumentation (default value is None)." },
- returns = "A map of strings to objects for the output from the package. " +
- "For a test package, contains a single key-value pair: the key is 'stream' " +
- "and the value is a string containing the test output.")
-
- public PyDictionary instrument(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String packageName = ap.getString(0);
- Map<String, Object> instrumentArgs = JythonUtils.getMap(ap, 1);
- if (instrumentArgs == null) {
- instrumentArgs = Collections.emptyMap();
- }
-
- Map<String, Object> result = impl.instrument(packageName, instrumentArgs);
- return JythonUtils.convertMapToDict(result);
- }
-
- @MonkeyRunnerExported(doc = "Wake up the screen on the device")
- public void wake(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- impl.wake();
- }
-
-
- @MonkeyRunnerExported(doc = "Retrieve the properties that can be queried")
- public PyList getPropertyList(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- Collection<String> properties = impl.getPropertyList();
- return new PyList(properties);
- }
-
- @MonkeyRunnerExported(doc = "Retrieve the view ids for the current application")
- public PyList getViewIdList(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- Collection<String> viewIds = impl.getViewIdList();
- return new PyList(viewIds);
- }
-
- //Because the pythonic way is to have flatter hierarchies, rather than doing the
- //findView(By.id("foo")) style the java code uses, I'm going to expose them as individual
- //method calls. This is similar to WebDriver's python bindings.
- @MonkeyRunnerExported(doc = "Obtains the view with the specified id.",
- args = {"id"},
- argDocs = {"The id of the view to retrieve."},
- returns = "The view object with the specified id.")
- public MonkeyView getViewById(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- String id = ap.getString(0);
- IChimpView view = impl.getView(By.id(id));
- return new MonkeyView(view);
- }
-
- @MonkeyRunnerExported(doc = "Obtains the view with the specified accessibility ids.",
- args = {"windowId", "accessibility id"},
- argDocs = {"The window id of the view to retrieve.",
- "The accessibility id of the view to retrieve."},
- returns = "The view object with the specified id.")
- public MonkeyView getViewByAccessibilityIds(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- int windowId = ap.getInt(0);
- int accessibilityId = ap.getInt(1);
- IChimpView view = impl.getView(By.accessibilityIds(windowId, accessibilityId));
- return new MonkeyView(view);
- }
-
- @MonkeyRunnerExported(doc = "Obtains current root view",
- returns = "The root view object")
- public MonkeyView getRootView(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- return new MonkeyView(impl.getRootView());
- }
-
- @MonkeyRunnerExported(doc = "Obtains a list of views that contain the specified text.",
- args = {"text"},
- argDocs = {"The text to search for"},
- returns = "A list of view objects that contain the specified text.")
- public PyList getViewsByText(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- String text = ap.getString(0);
- Collection<IChimpView> views = impl.getViews(By.text(text));
- PyList pyViews = new PyList();
- for (IChimpView view : views) {
- pyViews.append(new MonkeyView(view));
- }
- return pyViews;
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/MonkeyFormatter.java b/monkeyrunner/src/com/android/monkeyrunner/MonkeyFormatter.java
deleted file mode 100644
index c4a5362..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/MonkeyFormatter.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner;
-
-import com.google.common.collect.Maps;
-
-import java.io.ByteArrayOutputStream;
-import java.io.PrintWriter;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Map;
-import java.util.logging.Formatter;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-/*
- * Custom Logging Formatter for MonkeyRunner that generates all log
- * messages on a single line.
- */
-public class MonkeyFormatter extends Formatter {
- public static final Formatter DEFAULT_INSTANCE = new MonkeyFormatter();
-
- private static final SimpleDateFormat FORMAT = new SimpleDateFormat("yyMMdd HH:mm:ss.SSS");
-
- private static Map<Level, String> LEVEL_TO_STRING_CACHE = Maps.newHashMap();
-
- private static final String levelToString(Level level) {
- String levelName = LEVEL_TO_STRING_CACHE.get(level);
- if (levelName == null) {
- levelName = level.getName().substring(0, 1);
- LEVEL_TO_STRING_CACHE.put(level, levelName);
- }
- return levelName;
- }
-
- private static String getHeader(LogRecord record) {
- StringBuilder sb = new StringBuilder();
-
- sb.append(FORMAT.format(new Date(record.getMillis()))).append(":");
- sb.append(levelToString(record.getLevel())).append(" ");
-
- sb.append("[").append(Thread.currentThread().getName()).append("] ");
-
- String loggerName = record.getLoggerName();
- if (loggerName != null) {
- sb.append("[").append(loggerName).append("]");
- }
- return sb.toString();
- }
-
- private class PrintWriterWithHeader extends PrintWriter {
- private final ByteArrayOutputStream out;
- private final String header;
-
- public PrintWriterWithHeader(String header) {
- this(header, new ByteArrayOutputStream());
- }
-
- public PrintWriterWithHeader(String header, ByteArrayOutputStream out) {
- super(out, true);
- this.header = header;
- this.out = out;
- }
-
- @Override
- public void println(Object x) {
- print(header);
- super.println(x);
- }
-
- @Override
- public void println(String x) {
- print(header);
- super.println(x);
- }
-
- @Override
- public String toString() {
- return out.toString();
- }
- }
-
- @Override
- public String format(LogRecord record) {
- Throwable thrown = record.getThrown();
- String header = getHeader(record);
-
- StringBuilder sb = new StringBuilder();
- sb.append(header);
- sb.append(" ").append(formatMessage(record));
- sb.append("\n");
-
- // Print the exception here if we caught it
- if (thrown != null) {
-
- PrintWriter pw = new PrintWriterWithHeader(header);
- thrown.printStackTrace(pw);
- sb.append(pw.toString());
- }
-
- return sb.toString();
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/MonkeyImage.java b/monkeyrunner/src/com/android/monkeyrunner/MonkeyImage.java
deleted file mode 100644
index bae6dc8..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/MonkeyImage.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner;
-
-import com.google.common.base.Preconditions;
-
-import com.android.chimpchat.core.IChimpImage;
-import com.android.monkeyrunner.doc.MonkeyRunnerExported;
-
-import org.python.core.ArgParser;
-import org.python.core.ClassDictInit;
-import org.python.core.PyInteger;
-import org.python.core.PyObject;
-import org.python.core.PyTuple;
-
-import java.util.logging.Logger;
-
-/**
- * Jython object to encapsulate images that have been taken.
- */
-@MonkeyRunnerExported(doc = "An image")
-public class MonkeyImage extends PyObject implements ClassDictInit {
- private static Logger LOG = Logger.getLogger(MonkeyImage.class.getCanonicalName());
-
- public static void classDictInit(PyObject dict) {
- JythonUtils.convertDocAnnotationsForClass(MonkeyImage.class, dict);
- }
-
- private final IChimpImage impl;
-
- public MonkeyImage(IChimpImage impl) {
- this.impl = impl;
- }
-
- public IChimpImage getImpl() {
- return impl;
- }
-
-
- @MonkeyRunnerExported(doc = "Converts the MonkeyImage into a particular format and returns " +
- "the result as a String. Use this to get access to the raw" +
- "pixels in a particular format. String output is for better " +
- "performance.",
- args = {"format"},
- argDocs = { "The destination format (for example, 'png' for Portable " +
- "Network Graphics format). The default is png." },
- returns = "The resulting image as a String.")
- public byte[] convertToBytes(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String format = ap.getString(0, "png");
- return impl.convertToBytes(format);
- }
-
- @MonkeyRunnerExported(doc = "Write the MonkeyImage to a file. If no " +
- "format is specified, this method guesses the output format " +
- "based on the extension of the provided file extension. If it is unable to guess the " +
- "format, it uses PNG.",
- args = {"path", "format"},
- argDocs = {"The output filename, optionally including its path",
- "The destination format (for example, 'png' for " +
- " Portable Network Graphics format." },
- returns = "boolean true if writing succeeded.")
- public boolean writeToFile(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String path = ap.getString(0);
- String format = ap.getString(1, null);
- return impl.writeToFile(path, format);
- }
-
- @MonkeyRunnerExported(doc = "Get a single ARGB (alpha, red, green, blue) pixel at location " +
- "x,y. The arguments x and y are 0-based, expressed in pixel dimensions. X increases " +
- "to the right, and Y increases towards the bottom. This method returns a tuple.",
- args = { "x", "y" },
- argDocs = { "the x offset of the pixel", "the y offset of the pixel" },
- returns = "A tuple of (A, R, G, B) for the pixel. Each item in the tuple has the " +
- "range 0-255.")
- public PyObject getRawPixel(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- int x = ap.getInt(0);
- int y = ap.getInt(1);
- int pixel = impl.getPixel(x, y);
- PyInteger a = new PyInteger((pixel & 0xFF000000) >> 24);
- PyInteger r = new PyInteger((pixel & 0x00FF0000) >> 16);
- PyInteger g = new PyInteger((pixel & 0x0000FF00) >> 8);
- PyInteger b = new PyInteger((pixel & 0x000000FF) >> 0);
- return new PyTuple(a, r, g ,b);
- }
-
- @MonkeyRunnerExported(doc = "Get a single ARGB (alpha, red, green, blue) pixel at location " +
- "x,y. The arguments x and y are 0-based, expressed in pixel dimensions. X increases " +
- "to the right, and Y increases towards the bottom. This method returns an Integer.",
- args = { "x", "y" },
- argDocs = { "the x offset of the pixel", "the y offset of the pixel" },
- returns = "An unsigned integer pixel for x,y. The 8 high-order bits are A, followed" +
- "by 8 bits for R, 8 for G, and 8 for B.")
- public int getRawPixelInt(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- int x = ap.getInt(0);
- int y = ap.getInt(1);
- return impl.getPixel(x, y);
- }
-
- @MonkeyRunnerExported(doc = "Compare this MonkeyImage object to aother MonkeyImage object.",
- args = {"other", "percent"},
- argDocs = {"The other MonkeyImage object.",
- "A float in the range 0.0 to 1.0, indicating the percentage " +
- "of pixels that need to be the same for the method to return 'true'. " +
- "Defaults to 1.0."},
- returns = "boolean 'true' if the two objects contain the same image.")
- public boolean sameAs(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- PyObject otherObject = ap.getPyObject(0);
- IChimpImage other = ((MonkeyImage) otherObject.__tojava__(MonkeyImage.class)).getImpl();
-
- double percent = JythonUtils.getFloat(ap, 1, 1.0);
-
- return impl.sameAs(other, percent);
- }
-
- @MonkeyRunnerExported(doc = "Copy a rectangular region of the image.",
- args = {"rect"},
- argDocs = {"A tuple (x, y, w, h) describing the region to copy. x and y specify " +
- "upper lefthand corner of the region. w is the width of the region in " +
- "pixels, and h is its height."},
- returns = "a MonkeyImage object representing the copied region.")
- public MonkeyImage getSubImage(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- PyTuple rect = (PyTuple) ap.getPyObjectByType(0, PyTuple.TYPE);
- int x = rect.__getitem__(0).asInt();
- int y = rect.__getitem__(1).asInt();
- int w = rect.__getitem__(2).asInt();
- int h = rect.__getitem__(3).asInt();
-
- IChimpImage image = impl.getSubImage(x, y, w, h);
- return new MonkeyImage(image);
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/MonkeyRect.java b/monkeyrunner/src/com/android/monkeyrunner/MonkeyRect.java
deleted file mode 100644
index 98b2ecc..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/MonkeyRect.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner;
-
-import com.android.chimpchat.core.ChimpRect;
-
-import com.android.monkeyrunner.doc.MonkeyRunnerExported;
-
-import org.python.core.ArgParser;
-import org.python.core.ClassDictInit;
-import org.python.core.PyInteger;
-import org.python.core.PyList;
-import org.python.core.PyObject;
-
-import java.util.List;
-import java.util.LinkedList;
-import java.util.logging.Logger;
-
-/*
- * A Jython wrap for the ChimpRect class that stores coordinate information for views
- */
-@MonkeyRunnerExported(doc = "Represents the coordinates of a rectangular object")
-public class MonkeyRect extends PyObject implements ClassDictInit {
- private static final Logger LOG = Logger.getLogger(MonkeyRect.class.getName());
-
- private ChimpRect rect;
-
- @MonkeyRunnerExported(doc = "The x coordinate of the left side of the rectangle")
- public int left;
- @MonkeyRunnerExported(doc = "The y coordinate of the top side of the rectangle")
- public int top;
- @MonkeyRunnerExported(doc = "The x coordinate of the right side of the rectangle")
- public int right;
- @MonkeyRunnerExported(doc = "The y coordinate of the bottom side of the rectangle")
- public int bottom;
-
- public static void classDictInit(PyObject dict) {
- JythonUtils.convertDocAnnotationsForClass(MonkeyRect.class, dict);
- }
-
- public MonkeyRect(ChimpRect rect) {
- this.rect = rect;
- this.left = rect.left;
- this.right = rect.right;
- this.top = rect.top;
- this.bottom = rect.bottom;
- }
-
- @MonkeyRunnerExported(doc = "Returns the width of the rectangle",
- returns = "The width of the rectangle as an integer")
- public PyInteger getWidth() {
- return new PyInteger(right-left);
- }
-
- @MonkeyRunnerExported(doc = "Returns the height of the rectangle",
- returns = "The height of the rectangle as an integer")
- public PyInteger getHeight() {
- return new PyInteger(bottom-top);
- }
-
- @MonkeyRunnerExported(doc = "Returns a two item list that contains the x and y value of " +
- "the center of the rectangle",
- returns = "The center coordinates as a two item list of integers")
- public PyList getCenter(){
- List<PyInteger> center = new LinkedList<PyInteger>();
- /* Center x coordinate */
- center.add(new PyInteger(left+(right-left)/2));
- /* Center y coordinate */
- center.add(new PyInteger(top+(bottom-top)/2));
- return new PyList(center);
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunner.java b/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunner.java
deleted file mode 100644
index d047052..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunner.java
+++ /dev/null
@@ -1,242 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner;
-
-import com.google.common.base.Functions;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Collections2;
-
-import com.android.chimpchat.ChimpChat;
-import com.android.chimpchat.core.IChimpBackend;
-import com.android.chimpchat.core.IChimpDevice;
-import com.android.chimpchat.core.IChimpImage;
-import com.android.chimpchat.core.ChimpImageBase;
-import com.android.monkeyrunner.doc.MonkeyRunnerExported;
-
-import org.python.core.ArgParser;
-import org.python.core.ClassDictInit;
-import org.python.core.PyException;
-import org.python.core.PyObject;
-
-import java.util.Collection;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.swing.JOptionPane;
-
-/**
- * This is the main interface class into the jython bindings.
- */
-@MonkeyRunnerExported(doc = "Main entry point for MonkeyRunner")
-public class MonkeyRunner extends PyObject implements ClassDictInit {
- private static final Logger LOG = Logger.getLogger(MonkeyRunner.class.getCanonicalName());
- private static ChimpChat chimpchat;
-
- public static void classDictInit(PyObject dict) {
- JythonUtils.convertDocAnnotationsForClass(MonkeyRunner.class, dict);
- }
-
- static void setChimpChat(ChimpChat chimp){
- chimpchat = chimp;
- }
-
-
- @MonkeyRunnerExported(doc = "Waits for the workstation to connect to the device.",
- args = {"timeout", "deviceId"},
- argDocs = {"The timeout in seconds to wait. The default is to wait indefinitely.",
- "A regular expression that specifies the device name. See the documentation " +
- "for 'adb' in the Developer Guide to learn more about device names."},
- returns = "A ChimpDevice object representing the connected device.")
- public static MonkeyDevice waitForConnection(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- long timeoutMs;
- try {
- double timeoutInSecs = JythonUtils.getFloat(ap, 0);
- timeoutMs = (long) (timeoutInSecs * 1000.0);
- } catch (PyException e) {
- timeoutMs = Long.MAX_VALUE;
- }
-
- IChimpDevice device = chimpchat.waitForConnection(timeoutMs,
- ap.getString(1, ".*"));
- MonkeyDevice chimpDevice = new MonkeyDevice(device);
- return chimpDevice;
- }
-
- @MonkeyRunnerExported(doc = "Pause the currently running program for the specified " +
- "number of seconds.",
- args = {"seconds"},
- argDocs = {"The number of seconds to pause."})
- public static void sleep(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- double seconds = JythonUtils.getFloat(ap, 0);
-
- long ms = (long) (seconds * 1000.0);
-
- try {
- Thread.sleep(ms);
- } catch (InterruptedException e) {
- LOG.log(Level.SEVERE, "Error sleeping", e);
- }
- }
-
- @MonkeyRunnerExported(doc = "Format and display the API reference for MonkeyRunner.",
- args = { "format" },
- argDocs = {"The desired format for the output, either 'text' for plain text or " +
- "'html' for HTML markup."},
- returns = "A string containing the help text in the desired format.")
- public static String help(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String format = ap.getString(0, "text");
-
- return MonkeyRunnerHelp.helpString(format);
- }
-
- @MonkeyRunnerExported(doc = "Display an alert dialog to the process running the current " +
- "script. The dialog is modal, so the script stops until the user dismisses the " +
- "dialog.",
- args = { "message", "title", "okTitle" },
- argDocs = {
- "The message to display in the dialog.",
- "The dialog's title. The default value is 'Alert'.",
- "The text to use in the dialog button. The default value is 'OK'."
- })
- public static void alert(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String message = ap.getString(0);
- String title = ap.getString(1, "Alert");
- String buttonTitle = ap.getString(2, "OK");
-
- alert(message, title, buttonTitle);
- }
-
- @MonkeyRunnerExported(doc = "Display a dialog that accepts input. The dialog is ," +
- "modal, so the script stops until the user clicks one of the two dialog buttons. To " +
- "enter a value, the user enters the value and clicks the 'OK' button. To quit the " +
- "dialog without entering a value, the user clicks the 'Cancel' button. Use the " +
- "supplied arguments for this method to customize the text for these buttons.",
- args = {"message", "initialValue", "title", "okTitle", "cancelTitle"},
- argDocs = {
- "The prompt message to display in the dialog.",
- "The initial value to supply to the user. The default is an empty string)",
- "The dialog's title. The default is 'Input'",
- "The text to use in the dialog's confirmation button. The default is 'OK'." +
- "The text to use in the dialog's 'cancel' button. The default is 'Cancel'."
- },
- returns = "The test entered by the user, or None if the user canceled the input;"
- )
- public static String input(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String message = ap.getString(0);
- String initialValue = ap.getString(1, "");
- String title = ap.getString(2, "Input");
-
- return input(message, initialValue, title);
- }
-
- @MonkeyRunnerExported(doc = "Display a choice dialog that allows the user to select a single " +
- "item from a list of items.",
- args = {"message", "choices", "title"},
- argDocs = {
- "The prompt message to display in the dialog.",
- "An iterable Python type containing a list of choices to display",
- "The dialog's title. The default is 'Input'" },
- returns = "The 0-based numeric offset of the selected item in the iterable.")
- public static int choice(PyObject[] args, String kws[]) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String message = ap.getString(0);
- Collection<String> choices = Collections2.transform(JythonUtils.getList(ap, 1),
- Functions.toStringFunction());
- String title = ap.getString(2, "Input");
-
- return choice(message, title, choices);
- }
-
- @MonkeyRunnerExported(doc = "Loads a MonkeyImage from a file.",
- args = { "path" },
- argDocs = {
- "The path to the file to load. This file path is in terms of the computer running " +
- "MonkeyRunner and not a path on the Android Device. " },
- returns = "A new MonkeyImage representing the specified file")
- public static MonkeyImage loadImageFromFile(PyObject[] args, String kws[]) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String path = ap.getString(0);
- IChimpImage image = ChimpImageBase.loadImageFromFile(path);
- return new MonkeyImage(image);
- }
-
- /**
- * Display an alert dialog.
- *
- * @param message the message to show.
- * @param title the title of the dialog box.
- * @param okTitle the title of the button.
- */
- public static void alert(String message, String title, String okTitle) {
- Object[] options = { okTitle };
- JOptionPane.showOptionDialog(null, message, title, JOptionPane.DEFAULT_OPTION,
- JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);
- }
-
- /**
- * Display a dialog allow the user to pick a choice from a list of choices.
- *
- * @param message the message to show.
- * @param title the title of the dialog box.
- * @param choices the list of the choices to display.
- * @return the index of the selected choice, or -1 if nothing was chosen.
- */
- public static int choice(String message, String title, Collection<String> choices) {
- Object[] possibleValues = choices.toArray();
- Object selectedValue = JOptionPane.showInputDialog(null, message, title,
- JOptionPane.QUESTION_MESSAGE, null, possibleValues, possibleValues[0]);
-
- for (int x = 0; x < possibleValues.length; x++) {
- if (possibleValues[x].equals(selectedValue)) {
- return x;
- }
- }
- // Error
- return -1;
- }
-
- /**
- * Display a dialog that allows the user to input a text string.
- *
- * @param message the message to show.
- * @param initialValue the initial value to display in the dialog
- * @param title the title of the dialog box.
- * @return the entered string, or null if cancelled
- */
- public static String input(String message, String initialValue, String title) {
- return (String) JOptionPane.showInputDialog(null, message, title,
- JOptionPane.QUESTION_MESSAGE, null, null, initialValue);
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunnerHelp.java b/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunnerHelp.java
deleted file mode 100644
index 746d240..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunnerHelp.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner;
-
-import com.google.clearsilver.jsilver.JSilver;
-import com.google.clearsilver.jsilver.data.Data;
-import com.google.clearsilver.jsilver.resourceloader.ClassLoaderResourceLoader;
-import com.google.clearsilver.jsilver.resourceloader.ResourceLoader;
-import com.google.common.base.Function;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Collections2;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-
-import com.android.monkeyrunner.doc.MonkeyRunnerExported;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.Member;
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * Utility class for generating inline help documentation
- */
-public final class MonkeyRunnerHelp {
- private MonkeyRunnerHelp() { }
-
- private static final String HELP = "help";
- private static final String NAME = "name";
- private static final String DOC = "doc";
- private static final String ARGUMENT = "argument";
- private static final String RETURNS = "returns";
- private static final String TYPE = "type";
-
- // Enum used to describe documented types.
- private enum Type {
- ENUM, FIELD, METHOD
- }
-
- private static void getAllExportedClasses(Set<Field> fields,
- Set<Method> methods,
- Set<Constructor<?>> constructors,
- Set<Class<?>> enums) {
- final Set<Class<?>> classesVisited = Sets.newHashSet();
- Set<Class<?>> classesToVisit = Sets.newHashSet();
- classesToVisit.add(MonkeyRunner.class);
-
- Predicate<Class<?>> haventSeen = new Predicate<Class<?>>() {
- public boolean apply(Class<?> clz) {
- return !classesVisited.contains(clz);
- }
- };
-
- while (!classesToVisit.isEmpty()) {
- classesVisited.addAll(classesToVisit);
-
- List<Class<?>> newClasses = Lists.newArrayList();
- for (Class<?> clz : classesToVisit) {
- // See if the class itself is annotated and is an enum
- if (clz.isEnum() && clz.isAnnotationPresent(MonkeyRunnerExported.class)) {
- enums.add(clz);
- }
-
- // Constructors
- for (Constructor<?> c : clz.getConstructors()) {
- newClasses.addAll(Collections2.filter(Arrays.asList(c.getParameterTypes()),
- haventSeen));
- if (c.isAnnotationPresent(MonkeyRunnerExported.class)) {
- constructors.add(c);
- }
- }
-
- // Fields
- for (Field f : clz.getFields()) {
- if (haventSeen.apply(f.getClass())) {
- newClasses.add(f.getClass());
- }
- if (f.isAnnotationPresent(MonkeyRunnerExported.class)) {
- fields.add(f);
- }
- }
-
- // Methods
- for (Method m : clz.getMethods()) {
- newClasses.addAll(Collections2.filter(Arrays.asList(m.getParameterTypes()),
- haventSeen));
- if (haventSeen.apply(m.getReturnType())) {
- newClasses.add(m.getReturnType());
- }
-
- if (m.isAnnotationPresent(MonkeyRunnerExported.class)) {
- methods.add(m);
- }
- }
-
- // Containing classes
- for (Class<?> toAdd : clz.getClasses()) {
- if (haventSeen.apply(toAdd)) {
- newClasses.add(toAdd);
- }
- }
- }
-
- classesToVisit.clear();
- classesToVisit.addAll(newClasses);
- }
- }
-
- private static Comparator<Member> MEMBER_SORTER = new Comparator<Member>() {
- public int compare(Member o1, Member o2) {
- return o1.getName().compareTo(o2.getName());
- }
- };
-
- private static Comparator<Class<?>> CLASS_SORTER = new Comparator<Class<?>>() {
- public int compare(Class<?> o1, Class<?> o2) {
- return o1.getName().compareTo(o2.getName());
- }
- };
-
- public static String helpString(String format) {
- ResourceLoader resourceLoader = new ClassLoaderResourceLoader(
- MonkeyRunner.class.getClassLoader(), "com/android/monkeyrunner");
- JSilver jsilver = new JSilver(resourceLoader);
-
- // Quick check for support formats
- if ("html".equals(format) || "text".equals(format) || "sdk-docs".equals(format)) {
- try {
- Data hdf = buildHelpHdf(jsilver);
- return jsilver.render(format + ".cs", hdf);
- } catch (IOException e) {
- return "";
- }
- } else if ("hdf".equals(format)) {
- Data hdf = buildHelpHdf(jsilver);
- return hdf.toString();
- }
- return "";
- }
-
- /**
- * Parse the value string into paragraphs and put them into the
- * HDF under this specified prefix. Each paragraph will appear
- * numbered under the prefix. For example:
- *
- * paragraphsIntoHDF("a.b.c", ....)
- *
- * Will create paragraphs under "a.b.c.0", "a.b.c.1", etc.
- *
- * @param prefix The prefix to put the values under.
- * @param value the value to parse paragraphs from.
- * @param hdf the HDF to add the entries to.
- */
- private static void paragraphsIntoHDF(String prefix, String value, Data hdf) {
- String paragraphs[] = value.split("\n");
- int x = 0;
- for (String para : paragraphs) {
- hdf.setValue(prefix + "." + x, para);
- x++;
- }
- }
-
- private static Data buildHelpHdf(JSilver jsilver) {
- Data hdf = jsilver.createData();
- int outputItemCount = 0;
-
- Set<Field> fields = Sets.newTreeSet(MEMBER_SORTER);
- Set<Method> methods = Sets.newTreeSet(MEMBER_SORTER);
- Set<Constructor<?>> constructors = Sets.newTreeSet(MEMBER_SORTER);
- Set<Class<?>> classes = Sets.newTreeSet(CLASS_SORTER);
- getAllExportedClasses(fields, methods, constructors, classes);
-
- for (Class<?> clz : classes) {
- String prefix = HELP + "." + outputItemCount + ".";
-
- hdf.setValue(prefix + NAME, clz.getCanonicalName());
- MonkeyRunnerExported annotation = clz.getAnnotation(MonkeyRunnerExported.class);
- paragraphsIntoHDF(prefix + DOC, annotation.doc(), hdf);
- hdf.setValue(prefix + TYPE, Type.ENUM.name());
-
- // Now go through the enumeration constants
- Object[] constants = clz.getEnumConstants();
- String[] argDocs = annotation.argDocs();
- if (constants.length > 0) {
- for (int x = 0; x < constants.length; x++) {
- String argPrefix = prefix + ARGUMENT + "." + x + ".";
- hdf.setValue(argPrefix + NAME, constants[x].toString());
- if (argDocs.length > x) {
- paragraphsIntoHDF(argPrefix + DOC, argDocs[x], hdf);
- }
- }
- }
- outputItemCount++;
- }
-
- for (Method m : methods) {
- String prefix = HELP + "." + outputItemCount + ".";
-
- MonkeyRunnerExported annotation = m.getAnnotation(MonkeyRunnerExported.class);
- String className = m.getDeclaringClass().getCanonicalName();
- String methodName = className + "." + m.getName();
- hdf.setValue(prefix + NAME, methodName);
- paragraphsIntoHDF(prefix + DOC, annotation.doc(), hdf);
- if (annotation.args().length > 0) {
- String[] argDocs = annotation.argDocs();
- String[] aargs = annotation.args();
- for (int x = 0; x < aargs.length; x++) {
- String argPrefix = prefix + ARGUMENT + "." + x + ".";
-
- hdf.setValue(argPrefix + NAME, aargs[x]);
- if (argDocs.length > x) {
- paragraphsIntoHDF(argPrefix + DOC, argDocs[x], hdf);
- }
- }
- }
- if (!"".equals(annotation.returns())) {
- paragraphsIntoHDF(prefix + RETURNS, annotation.returns(), hdf);
- }
- outputItemCount++;
- }
-
- return hdf;
- }
-
- public static Collection<String> getAllDocumentedClasses() {
- Set<Field> fields = Sets.newTreeSet(MEMBER_SORTER);
- Set<Method> methods = Sets.newTreeSet(MEMBER_SORTER);
- Set<Constructor<?>> constructors = Sets.newTreeSet(MEMBER_SORTER);
- Set<Class<?>> classes = Sets.newTreeSet(CLASS_SORTER);
- getAllExportedClasses(fields, methods, constructors, classes);
-
- // The classes object only captures classes that are specifically exporter, which isn't
- // good enough. So go through all the fields, methods, etc. and collect those classes as
- // as well
- Set<Class<?>> allClasses = Sets.newHashSet();
- allClasses.addAll(classes);
- for (Field f : fields) {
- allClasses.add(f.getDeclaringClass());
- }
- for (Method m : methods) {
- allClasses.add(m.getDeclaringClass());
- }
- for (Constructor<?> constructor : constructors) {
- allClasses.add(constructor.getDeclaringClass());
- }
-
- // And transform that collection into a list of simple names.
- return Collections2.transform(allClasses, new Function<Class<?>, String>() {
- @Override
- public String apply(Class<?> clz) {
- return clz.getName();
- }
- });
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunnerOptions.java b/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunnerOptions.java
deleted file mode 100644
index 33daccd..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunnerOptions.java
+++ /dev/null
@@ -1,186 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner;
-
-import com.google.common.collect.ImmutableList;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-public class MonkeyRunnerOptions {
- private static final Logger LOG = Logger.getLogger(MonkeyRunnerOptions.class.getName());
- private static String DEFAULT_MONKEY_SERVER_ADDRESS = "127.0.0.1";
- private static int DEFAULT_MONKEY_PORT = 12345;
-
- private final int port;
- private final String hostname;
- private final File scriptFile;
- private final String backend;
- private final Collection<File> plugins;
- private final Collection<String> arguments;
- private final Level logLevel;
-
- private MonkeyRunnerOptions(String hostname, int port, File scriptFile, String backend,
- Level logLevel, Collection<File> plugins, Collection<String> arguments) {
- this.hostname = hostname;
- this.port = port;
- this.scriptFile = scriptFile;
- this.backend = backend;
- this.logLevel = logLevel;
- this.plugins = plugins;
- this.arguments = arguments;
- }
-
- public int getPort() {
- return port;
- }
-
- public String getHostname() {
- return hostname;
- }
-
- public File getScriptFile() {
- return scriptFile;
- }
-
- public String getBackendName() {
- return backend;
- }
-
- public Collection<File> getPlugins() {
- return plugins;
- }
-
- public Collection<String> getArguments() {
- return arguments;
- }
-
- public Level getLogLevel() {
- return logLevel;
- }
-
- private static void printUsage(String message) {
- System.out.println(message);
- System.out.println("Usage: monkeyrunner [options] SCRIPT_FILE");
- System.out.println("");
- System.out.println(" -s MonkeyServer IP Address.");
- System.out.println(" -p MonkeyServer TCP Port.");
- System.out.println(" -v MonkeyServer Logging level (ALL, FINEST, FINER, FINE, CONFIG, INFO, WARNING, SEVERE, OFF)");
- System.out.println("");
- System.out.println("");
- }
-
- /**
- * Process the command-line options
- *
- * @return the parsed options, or null if there was an error.
- */
- public static MonkeyRunnerOptions processOptions(String[] args) {
- // parse command line parameters.
- int index = 0;
-
- String hostname = DEFAULT_MONKEY_SERVER_ADDRESS;
- File scriptFile = null;
- int port = DEFAULT_MONKEY_PORT;
- String backend = "adb";
- Level logLevel = Level.SEVERE;
-
- ImmutableList.Builder<File> pluginListBuilder = ImmutableList.builder();
- ImmutableList.Builder<String> argumentBuilder = ImmutableList.builder();
- while (index < args.length) {
- String argument = args[index++];
-
- if ("-s".equals(argument)) {
- if (index == args.length) {
- printUsage("Missing Server after -s");
- return null;
- }
- hostname = args[index++];
-
- } else if ("-p".equals(argument)) {
- // quick check on the next argument.
- if (index == args.length) {
- printUsage("Missing Server port after -p");
- return null;
- }
- port = Integer.parseInt(args[index++]);
-
- } else if ("-v".equals(argument)) {
- // quick check on the next argument.
- if (index == args.length) {
- printUsage("Missing Log Level after -v");
- return null;
- }
-
- logLevel = Level.parse(args[index++]);
- } else if ("-be".equals(argument)) {
- // quick check on the next argument.
- if (index == args.length) {
- printUsage("Missing backend name after -be");
- return null;
- }
- backend = args[index++];
- } else if ("-plugin".equals(argument)) {
- // quick check on the next argument.
- if (index == args.length) {
- printUsage("Missing plugin path after -plugin");
- return null;
- }
- File plugin = new File(args[index++]);
- if (!plugin.exists()) {
- printUsage("Plugin file doesn't exist");
- return null;
- }
-
- if (!plugin.canRead()) {
- printUsage("Can't read plugin file");
- return null;
- }
-
- pluginListBuilder.add(plugin);
- } else if ("-u".equals(argument)){
- // This is asking for unbuffered input. We can ignore this.
- } else if (argument.startsWith("-") &&
- // Once we have the scriptfile, the rest of the arguments go to jython.
- scriptFile == null) {
- // we have an unrecognized argument.
- printUsage("Unrecognized argument: " + argument + ".");
- return null;
- } else {
- if (scriptFile == null) {
- // get the filepath of the script to run.
- // This will be the last undashed argument.
- scriptFile = new File(argument);
- if (!scriptFile.exists()) {
- printUsage("Can't open specified script file");
- return null;
- }
- if (!scriptFile.canRead()) {
- printUsage("Can't open specified script file");
- return null;
- }
- } else {
- argumentBuilder.add(argument);
- }
- }
- };
-
- return new MonkeyRunnerOptions(hostname, port, scriptFile, backend, logLevel,
- pluginListBuilder.build(), argumentBuilder.build());
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunnerStarter.java b/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunnerStarter.java
deleted file mode 100644
index dd7aec9..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/MonkeyRunnerStarter.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner;
-
-import com.google.common.base.Predicate;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableMap;
-
-import com.android.chimpchat.ChimpChat;
-
-import org.python.util.PythonInterpreter;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.jar.Attributes;
-import java.util.jar.JarFile;
-import java.util.jar.Manifest;
-import java.util.logging.Formatter;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogManager;
-import java.util.logging.Logger;
-
-/**
- * MonkeyRunner is a host side application to control a monkey instance on a
- * device. MonkeyRunner provides some useful helper functions to control the
- * device as well as various other methods to help script tests. This class bootstraps
- * MonkeyRunner.
- */
-public class MonkeyRunnerStarter {
- private static final Logger LOG = Logger.getLogger(MonkeyRunnerStarter.class.getName());
- private static final String MONKEY_RUNNER_MAIN_MANIFEST_NAME = "MonkeyRunnerStartupRunner";
-
- private final ChimpChat chimp;
- private final MonkeyRunnerOptions options;
-
- public MonkeyRunnerStarter(MonkeyRunnerOptions options) {
- Map<String, String> chimp_options = new TreeMap<String, String>();
- chimp_options.put("backend", options.getBackendName());
- this.options = options;
- this.chimp = ChimpChat.getInstance(chimp_options);
- MonkeyRunner.setChimpChat(chimp);
- }
-
-
-
- private int run() {
- // This system property gets set by the included starter script
- String monkeyRunnerPath = System.getProperty("com.android.monkeyrunner.bindir") +
- File.separator + "monkeyrunner";
-
- Map<String, Predicate<PythonInterpreter>> plugins = handlePlugins();
- if (options.getScriptFile() == null) {
- ScriptRunner.console(monkeyRunnerPath);
- chimp.shutdown();
- return 0;
- } else {
- int error = ScriptRunner.run(monkeyRunnerPath, options.getScriptFile().getAbsolutePath(),
- options.getArguments(), plugins);
- chimp.shutdown();
- return error;
- }
- }
-
- private Predicate<PythonInterpreter> handlePlugin(File f) {
- JarFile jarFile;
- try {
- jarFile = new JarFile(f);
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Unable to open plugin file. Is it a jar file? " +
- f.getAbsolutePath(), e);
- return Predicates.alwaysFalse();
- }
- Manifest manifest;
- try {
- manifest = jarFile.getManifest();
- } catch (IOException e) {
- LOG.log(Level.SEVERE, "Unable to get manifest file from jar: " +
- f.getAbsolutePath(), e);
- return Predicates.alwaysFalse();
- }
- Attributes mainAttributes = manifest.getMainAttributes();
- String pluginClass = mainAttributes.getValue(MONKEY_RUNNER_MAIN_MANIFEST_NAME);
- if (pluginClass == null) {
- // No main in this plugin, so it always succeeds.
- return Predicates.alwaysTrue();
- }
- URL url;
- try {
- url = f.toURI().toURL();
- } catch (MalformedURLException e) {
- LOG.log(Level.SEVERE, "Unable to convert file to url " + f.getAbsolutePath(),
- e);
- return Predicates.alwaysFalse();
- }
- URLClassLoader classLoader = new URLClassLoader(new URL[] { url },
- ClassLoader.getSystemClassLoader());
- Class<?> clz;
- try {
- clz = Class.forName(pluginClass, true, classLoader);
- } catch (ClassNotFoundException e) {
- LOG.log(Level.SEVERE, "Unable to load the specified plugin: " + pluginClass, e);
- return Predicates.alwaysFalse();
- }
- Object loadedObject;
- try {
- loadedObject = clz.newInstance();
- } catch (InstantiationException e) {
- LOG.log(Level.SEVERE, "Unable to load the specified plugin: " + pluginClass, e);
- return Predicates.alwaysFalse();
- } catch (IllegalAccessException e) {
- LOG.log(Level.SEVERE, "Unable to load the specified plugin " +
- "(did you make it public?): " + pluginClass, e);
- return Predicates.alwaysFalse();
- }
- // Cast it to the right type
- if (loadedObject instanceof Runnable) {
- final Runnable run = (Runnable) loadedObject;
- return new Predicate<PythonInterpreter>() {
- public boolean apply(PythonInterpreter i) {
- run.run();
- return true;
- }
- };
- } else if (loadedObject instanceof Predicate<?>) {
- return (Predicate<PythonInterpreter>) loadedObject;
- } else {
- LOG.severe("Unable to coerce object into correct type: " + pluginClass);
- return Predicates.alwaysFalse();
- }
- }
-
- private Map<String, Predicate<PythonInterpreter>> handlePlugins() {
- ImmutableMap.Builder<String, Predicate<PythonInterpreter>> builder = ImmutableMap.builder();
- for (File f : options.getPlugins()) {
- builder.put(f.getAbsolutePath(), handlePlugin(f));
- }
- return builder.build();
- }
-
- /* Similar to above, when this fails, it no longer throws a
- * runtime exception, but merely will log the failure.
- */
-
-
- private static final void replaceAllLogFormatters(Formatter form, Level level) {
- LogManager mgr = LogManager.getLogManager();
- Enumeration<String> loggerNames = mgr.getLoggerNames();
- while (loggerNames.hasMoreElements()) {
- String loggerName = loggerNames.nextElement();
- Logger logger = mgr.getLogger(loggerName);
- for (Handler handler : logger.getHandlers()) {
- handler.setFormatter(form);
- handler.setLevel(level);
- }
- }
- }
-
- public static void main(String[] args) {
- MonkeyRunnerOptions options = MonkeyRunnerOptions.processOptions(args);
-
- if (options == null) {
- return;
- }
-
- // logging property files are difficult
- replaceAllLogFormatters(MonkeyFormatter.DEFAULT_INSTANCE, options.getLogLevel());
-
- MonkeyRunnerStarter runner = new MonkeyRunnerStarter(options);
- int error = runner.run();
-
- // This will kill any background threads as well.
- System.exit(error);
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/MonkeyView.java b/monkeyrunner/src/com/android/monkeyrunner/MonkeyView.java
deleted file mode 100644
index 8c1edb8..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/MonkeyView.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner;
-
-import com.google.common.base.Preconditions;
-
-import com.android.chimpchat.core.IChimpView;
-
-import com.android.monkeyrunner.doc.MonkeyRunnerExported;
-
-import org.python.core.ArgParser;
-import org.python.core.ClassDictInit;
-import org.python.core.PyBoolean;
-import org.python.core.PyInteger;
-import org.python.core.PyList;
-import org.python.core.PyObject;
-import org.python.core.PyString;
-
-import java.util.List;
-import java.util.logging.Logger;
-
-/*
- * Jython wrapper for the ChimpView class
- */
-@MonkeyRunnerExported(doc = "Represents a view object.")
-public class MonkeyView extends PyObject implements ClassDictInit {
- private static final Logger LOG = Logger.getLogger(MonkeyView.class.getName());
-
- private IChimpView impl;
-
- public static void classDictInit(PyObject dict) {
- JythonUtils.convertDocAnnotationsForClass(MonkeyView.class, dict);
- }
-
- public MonkeyView(IChimpView impl) {
- this.impl = impl;
- }
-
- @MonkeyRunnerExported(doc = "Get the checked status of the view",
- returns = "A boolean value for whether the item is checked or not")
- public PyBoolean getChecked(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- return new PyBoolean(impl.getChecked());
- }
-
- @MonkeyRunnerExported(doc = "Returns the class name of the view",
- returns = "The class name of the view as a string")
- public PyString getViewClass(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- return new PyString(impl.getViewClass());
- }
-
- @MonkeyRunnerExported(doc = "Returns the text contained by the view",
- returns = "The text contained in the view")
- public PyString getText(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- return new PyString(impl.getText());
- }
-
- @MonkeyRunnerExported(doc = "Returns the location of the view in the form of a MonkeyRect",
- returns = "The location of the view as a MonkeyRect object")
- public MonkeyRect getLocation(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- return new MonkeyRect(impl.getLocation());
- }
-
- @MonkeyRunnerExported(doc = "Returns the enabled status of the view",
- returns = "The enabled status of the view as a boolean")
- public PyBoolean getEnabled(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- return new PyBoolean(impl.getEnabled());
- }
-
- @MonkeyRunnerExported(doc = "Returns the selected status of the view",
- returns = "The selected status of the view as a boolean")
- public PyBoolean getSelected(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- return new PyBoolean(impl.getSelected());
- }
-
- @MonkeyRunnerExported(doc = "Sets the selected status of the view",
- args = {"selected"},
- argDocs = { "The boolean value to set selected to" })
- public void setSelected(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- PyBoolean pySelected = (PyBoolean) ap.getPyObject(0, new PyBoolean(false));
- boolean selected = (Boolean) pySelected.__tojava__(Boolean.class);
- impl.setSelected(selected);
- }
-
- @MonkeyRunnerExported(doc = "Returns the focused status of the view",
- returns = "The focused status of the view as a boolean")
- public PyBoolean getFocused(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- return new PyBoolean(impl.getFocused());
- }
-
- @MonkeyRunnerExported(doc = "Sets the focused status of the view",
- args = {"focused"},
- argDocs = { "The boolean value to set focused to" })
- public void setFocused(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- PyBoolean pyFocused = (PyBoolean) ap.getPyObject(0, new PyBoolean(false));
- boolean focused = (Boolean) pyFocused.__tojava__(Boolean.class);
- impl.setFocused(focused);
- }
-
- @MonkeyRunnerExported(doc = "Returns the parent of the current view",
- returns = "The parent of the view as a MonkeyView object")
- public MonkeyView getParent(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- MonkeyView parent = new MonkeyView(impl.getParent());
- return parent;
- }
-
- @MonkeyRunnerExported(doc = "Returns the children of the current view",
- returns = "The children of the view as a list of MonkeyView objects")
- public PyList getChildren(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- List<IChimpView> chimpChildren = impl.getChildren();
- PyList children = new PyList();
- for (IChimpView child : chimpChildren) {
- children.append(new MonkeyView(child));
- }
- return children;
- }
-
- @MonkeyRunnerExported(doc = "Returns the accessibility ids of the current view",
- returns = "The accessibility ids of the view as a list of ints")
- public PyList getAccessibilityIds(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- int[] ids = impl.getAccessibilityIds();
- PyList pyIds = new PyList();
- for (int i = 0; i < ids.length; i++) {
- pyIds.append(new PyInteger(ids[i]));
- }
- return pyIds;
- }
-
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/ScriptRunner.java b/monkeyrunner/src/com/android/monkeyrunner/ScriptRunner.java
deleted file mode 100644
index 3c96eeb..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/ScriptRunner.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner;
-
-import com.google.common.base.Predicate;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMap.Builder;
-import com.google.common.collect.Lists;
-
-import org.python.core.Py;
-import org.python.core.PyException;
-import org.python.core.PyJavaPackage;
-import org.python.core.PyList;
-import org.python.core.PyObject;
-import org.python.core.PyString;
-import org.python.core.PySystemState;
-import org.python.util.InteractiveConsole;
-import org.python.util.JLineConsole;
-import org.python.util.PythonInterpreter;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-/**
- * Runs Jython based scripts.
- */
-public class ScriptRunner {
- private static final Logger LOG = Logger.getLogger(MonkeyRunnerOptions.class.getName());
-
- /** The "this" scope object for scripts. */
- private final Object scope;
- private final String variable;
-
- /** Private constructor. */
- private ScriptRunner(Object scope, String variable) {
- this.scope = scope;
- this.variable = variable;
- }
-
- /** Creates a new instance for the given scope object. */
- public static ScriptRunner newInstance(Object scope, String variable) {
- return new ScriptRunner(scope, variable);
- }
-
- /**
- * Runs the specified Jython script. First runs the initialization script to
- * preload the appropriate client library version.
- *
- * @param scriptfilename the name of the file to run.
- * @param args the arguments passed in (excluding the filename).
- * @param plugins a list of plugins to load.
- * @return the error code from running the script.
- */
- public static int run(String executablePath, String scriptfilename,
- Collection<String> args, Map<String,
- Predicate<PythonInterpreter>> plugins) {
- // Add the current directory of the script to the python.path search path.
- File f = new File(scriptfilename);
-
- // Adjust the classpath so jython can access the classes in the specified classpath.
- Collection<String> classpath = Lists.newArrayList(f.getParent());
- classpath.addAll(plugins.keySet());
-
- String[] argv = new String[args.size() + 1];
- argv[0] = f.getAbsolutePath();
- int x = 1;
- for (String arg : args) {
- argv[x++] = arg;
- }
-
- initPython(executablePath, classpath, argv);
-
- PythonInterpreter python = new PythonInterpreter();
-
- // Now let the mains run.
- for (Map.Entry<String, Predicate<PythonInterpreter>> entry : plugins.entrySet()) {
- boolean success;
- try {
- success = entry.getValue().apply(python);
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Plugin Main through an exception.", e);
- continue;
- }
- if (!success) {
- LOG.severe("Plugin Main returned error for: " + entry.getKey());
- }
- }
-
- // Bind __name__ to __main__ so mains will run
- python.set("__name__", "__main__");
- // Also find __file__
- python.set("__file__", scriptfilename);
-
- try {
- python.execfile(scriptfilename);
- } catch (PyException e) {
- if (Py.SystemExit.equals(e.type)) {
- // Then recover the error code so we can pass it on
- return (Integer) e.value.__tojava__(Integer.class);
- }
- // Then some other kind of exception was thrown. Log it and return error;
- LOG.log(Level.SEVERE, "Script terminated due to an exception", e);
- return 1;
- }
- return 0;
- }
-
- public static void runString(String executablePath, String script) {
- initPython(executablePath);
- PythonInterpreter python = new PythonInterpreter();
- python.exec(script);
- }
-
- public static Map<String, PyObject> runStringAndGet(String executablePath,
- String script, String... names) {
- return runStringAndGet(executablePath, script, Arrays.asList(names));
- }
-
- public static Map<String, PyObject> runStringAndGet(String executablePath,
- String script, Collection<String> names) {
- initPython(executablePath);
- final PythonInterpreter python = new PythonInterpreter();
- python.exec(script);
-
- Builder<String, PyObject> builder = ImmutableMap.builder();
- for (String name : names) {
- builder.put(name, python.get(name));
- }
- return builder.build();
- }
-
- private static void initPython(String executablePath) {
- List<String> arg = Collections.emptyList();
- initPython(executablePath, arg, new String[] {""});
- }
-
- private static void initPython(String executablePath,
- Collection<String> pythonPath, String[] argv) {
- Properties props = new Properties();
-
- // Build up the python.path
- StringBuilder sb = new StringBuilder();
- sb.append(System.getProperty("java.class.path"));
- for (String p : pythonPath) {
- sb.append(":").append(p);
- }
- props.setProperty("python.path", sb.toString());
-
- /** Initialize the python interpreter. */
- // Default is 'message' which displays sys-package-mgr bloat
- // Choose one of error,warning,message,comment,debug
- props.setProperty("python.verbose", "error");
-
- // This needs to be set for sys.executable to function properly
- props.setProperty("python.executable", executablePath);
-
- PythonInterpreter.initialize(System.getProperties(), props, argv);
-
- String frameworkDir = System.getProperty("java.ext.dirs");
- File monkeyRunnerJar = new File(frameworkDir, "monkeyrunner.jar");
- if (monkeyRunnerJar.canRead()) {
- PySystemState.packageManager.addJar(monkeyRunnerJar.getAbsolutePath(), false);
- }
- }
-
- /**
- * Start an interactive python interpreter.
- */
- public static void console(String executablePath) {
- initPython(executablePath);
- InteractiveConsole python = new JLineConsole();
- python.interact();
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/controller/MonkeyController.java b/monkeyrunner/src/com/android/monkeyrunner/controller/MonkeyController.java
deleted file mode 100644
index 6fc4ea6..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/controller/MonkeyController.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner.controller;
-
-import com.android.chimpchat.ChimpChat;
-import com.android.chimpchat.core.IChimpDevice;
-
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.logging.Logger;
-import java.util.Map;
-import java.util.TreeMap;
-
-import javax.swing.JFrame;
-import javax.swing.SwingUtilities;
-
-/**
- * Application that can control an attached device using the network monkey. It has a window
- * that shows what the current screen looks like and allows the user to click in it. Clicking in
- * the window sends touch events to the attached device. It also supports keyboard input for
- * typing and has buttons to press to simulate physical buttons on the device.
- */
-public class MonkeyController extends JFrame {
- private static final Logger LOG = Logger.getLogger(MonkeyController.class.getName());
-
- public static void main(String[] args) {
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- Map<String, String> options = new TreeMap<String, String>();
- options.put("backend", "adb");
- ChimpChat chimpchat = ChimpChat.getInstance(options);
- final IChimpDevice device = chimpchat.waitForConnection();
- MonkeyControllerFrame mf = new MonkeyControllerFrame(device);
- mf.setVisible(true);
- mf.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosed(WindowEvent e) {
- device.dispose();
- }
- });
- }
- });
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/controller/MonkeyControllerFrame.java b/monkeyrunner/src/com/android/monkeyrunner/controller/MonkeyControllerFrame.java
deleted file mode 100644
index 8bb2513..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/controller/MonkeyControllerFrame.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner.controller;
-
-import com.android.chimpchat.core.PhysicalButton;
-import com.android.chimpchat.core.TouchPressType;
-import com.android.chimpchat.core.IChimpImage;
-import com.android.chimpchat.core.IChimpDevice;
-
-import java.awt.KeyEventDispatcher;
-import java.awt.KeyboardFocusManager;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.util.logging.Logger;
-
-import javax.swing.AbstractAction;
-import javax.swing.BoxLayout;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JToolBar;
-import javax.swing.SwingUtilities;
-import javax.swing.Timer;
-
-/**
- * Main window for MonkeyController.
- */
-public class MonkeyControllerFrame extends JFrame {
- private static final Logger LOG = Logger.getLogger(MonkeyControllerFrame.class.getName());
-
- private final JButton refreshButton = new JButton("Refresh");
- private final JButton variablesButton = new JButton("Variable");
- private final JLabel imageLabel = new JLabel();
- private final VariableFrame variableFrame;
-
- private final IChimpDevice device;
- private BufferedImage currentImage;
-
- private final TouchPressType DOWN_AND_UP = TouchPressType.DOWN_AND_UP;
-
- private final Timer timer = new Timer(1000, new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- updateScreen();
- }
- });
-
- private class PressAction extends AbstractAction {
- private final PhysicalButton button;
-
- public PressAction(PhysicalButton button) {
- this.button = button;
- }
- /* When this fails, it no longer throws a runtime exception,
- * but merely will log the failure.
- */
- public void actionPerformed(ActionEvent event) {
- device.press(button.getKeyName(), DOWN_AND_UP);
- updateScreen();
- }
- }
-
- private JButton createToolbarButton(PhysicalButton hardButton) {
- JButton button = new JButton(new PressAction(hardButton));
- button.setText(hardButton.getKeyName());
- return button;
- }
-
- public MonkeyControllerFrame(IChimpDevice chimpDevice) {
- super("MonkeyController");
- this.device = chimpDevice;
-
- setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
-
- setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
- JToolBar toolbar = new JToolBar();
-
- toolbar.add(createToolbarButton(PhysicalButton.HOME));
- toolbar.add(createToolbarButton(PhysicalButton.BACK));
- toolbar.add(createToolbarButton(PhysicalButton.SEARCH));
- toolbar.add(createToolbarButton(PhysicalButton.MENU));
-
- add(toolbar);
- add(refreshButton);
- add(variablesButton);
- add(imageLabel);
-
- refreshButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- updateScreen();
- }
- });
-
- variableFrame = new VariableFrame();
- variablesButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- variableFrame.setVisible(true);
- }
- });
-
- /* Similar to above, when the following two methods fail, they
- * no longer throw a runtime exception, but merely will log the failure.
- */
- imageLabel.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent event) {
- device.touch(event.getX(), event.getY(), DOWN_AND_UP);
- updateScreen();
- }
-
- });
-
- KeyboardFocusManager focusManager = KeyboardFocusManager.getCurrentKeyboardFocusManager();
- focusManager.addKeyEventDispatcher(new KeyEventDispatcher() {
- public boolean dispatchKeyEvent(KeyEvent event) {
- if (KeyEvent.KEY_TYPED == event.getID()) {
- device.type(Character.toString(event.getKeyChar()));
- }
- return false;
- }
- });
-
- SwingUtilities.invokeLater(new Runnable(){
- public void run() {
- init();
- variableFrame.init(device);
- }
- });
-
- pack();
- }
-
- private void updateScreen() {
- IChimpImage snapshot = device.takeSnapshot();
- currentImage = snapshot.createBufferedImage();
- imageLabel.setIcon(new ImageIcon(currentImage));
-
- pack();
- }
-
- private void init() {
- updateScreen();
- timer.start();
- }
-
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/controller/VariableFrame.java b/monkeyrunner/src/com/android/monkeyrunner/controller/VariableFrame.java
deleted file mode 100644
index f9c6ef3..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/controller/VariableFrame.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner.controller;
-
-import com.google.common.collect.Sets;
-
-import com.android.chimpchat.core.IChimpDevice;
-
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.Collection;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.swing.BoxLayout;
-import javax.swing.JButton;
-import javax.swing.JFrame;
-import javax.swing.JTable;
-import javax.swing.SwingUtilities;
-import javax.swing.WindowConstants;
-import javax.swing.event.TableModelEvent;
-import javax.swing.event.TableModelListener;
-import javax.swing.table.AbstractTableModel;
-
-/**
- * Swing Frame that displays all the variables that the monkey exposes on the device.
- */
-public class VariableFrame extends JFrame {
- private static final Logger LOG = Logger.getLogger(VariableFrame.class.getName());
- private static final ExecutorService EXECUTOR = Executors.newCachedThreadPool();
- private IChimpDevice device;
-
- private static class VariableHolder implements Comparable<VariableHolder> {
- private final String key;
- private final String value;
-
- public VariableHolder(String key, String value) {
- this.key = key;
- this.value = value;
- }
-
- public String getKey() {
- return key;
- }
-
- public String getValue() {
- return value;
- }
-
- public int compareTo(VariableHolder o) {
- return key.compareTo(o.key);
- }
- }
-
- private static <E> E getNthElement(Set<E> set, int offset) {
- int current = 0;
- for (E elem : set) {
- if (current == offset) {
- return elem;
- }
- current++;
- }
- return null;
- }
-
- private class VariableTableModel extends AbstractTableModel {
- private final TreeSet<VariableHolder> set = Sets.newTreeSet();
-
- public void refresh() {
- Collection<String> variables;
- variables = device.getPropertyList();
- for (final String variable : variables) {
- EXECUTOR.execute(new Runnable() {
- public void run() {
- String value;
- value = device.getProperty(variable);
- if (value == null) {
- value = "";
- }
- synchronized (set) {
- set.add(new VariableHolder(variable, value));
- SwingUtilities.invokeLater(new Runnable() {
- public void run() {
- VariableTableModel.this.fireTableDataChanged();
- }
- });
-
- }
- }
- });
- }
- }
-
- public int getColumnCount() {
- return 2;
- }
-
- public int getRowCount() {
- synchronized (set) {
- return set.size();
- }
- }
-
- public Object getValueAt(int rowIndex, int columnIndex) {
- VariableHolder nthElement;
- synchronized (set) {
- nthElement = getNthElement(set, rowIndex);
- }
- if (columnIndex == 0) {
- return nthElement.getKey();
- }
- return nthElement.getValue();
- }
- }
-
- public VariableFrame() {
- super("Variables");
- setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
- setLayout(new BoxLayout(getContentPane(), BoxLayout.Y_AXIS));
-
- final VariableTableModel tableModel = new VariableTableModel();
-
- JButton refreshButton = new JButton("Refresh");
- add(refreshButton);
- refreshButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- tableModel.refresh();
- }
- });
-
-
- JTable table = new JTable(tableModel);
- add(table);
-
- tableModel.addTableModelListener(new TableModelListener() {
- public void tableChanged(TableModelEvent e) {
- pack();
- }
- });
-
- this.addWindowListener(new WindowAdapter() {
- @Override
- public void windowOpened(WindowEvent e) {
- tableModel.refresh();
- }
- });
-
- pack();
- }
-
- public void init(IChimpDevice device) {
- this.device = device;
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/doc/MonkeyRunnerExported.java b/monkeyrunner/src/com/android/monkeyrunner/doc/MonkeyRunnerExported.java
deleted file mode 100644
index 33da2dd..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/doc/MonkeyRunnerExported.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner.doc;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Indicates that the annotated method is a public API to expose to the
- * scripting interface. Can be used to generate documentation of what
- * methods are exposed and also can be used to enforce visibility of
- * these methods in the scripting environment.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target({ ElementType.METHOD, ElementType.CONSTRUCTOR,
- ElementType.TYPE, ElementType.FIELD })
-public @interface MonkeyRunnerExported {
- /**
- * A documentation string for this method.
- */
- String doc();
-
- /**
- * The list of names for the keywords in this method in their proper positional order.
- *
- * For example:
- *
- * @MonkeyRunnerExported(args={"one", "two"})
- * public void foo();
- *
- * would allow calls like this:
- * foo(one=1, two=2)
- * foo(1, 2)
- */
- String[] args() default {};
-
- /**
- * The list of documentation for the arguments.
- */
- String[] argDocs() default {};
-
- /**
- * The documentation for the return type of this method.
- */
- String returns() default "returns nothing.";
-} \ No newline at end of file
diff --git a/monkeyrunner/src/com/android/monkeyrunner/easy/By.java b/monkeyrunner/src/com/android/monkeyrunner/easy/By.java
deleted file mode 100644
index d9891c6..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/easy/By.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.monkeyrunner.easy;
-
-import com.google.common.base.Preconditions;
-
-import com.android.chimpchat.hierarchyviewer.HierarchyViewer;
-import com.android.hierarchyviewerlib.models.ViewNode;
-import com.android.monkeyrunner.JythonUtils;
-import com.android.monkeyrunner.doc.MonkeyRunnerExported;
-
-import org.python.core.ArgParser;
-import org.python.core.ClassDictInit;
-import org.python.core.PyObject;
-
-/**
- * Select a view object based on some criteria.
- *
- * Currently supports the By.id criteria to search for an element by id.
- * In the future it will support other criteria such as:
- * By.classid - search by class.
- * By.hash - search by hashcode
- * and recursively searching under an already selected object.
- *
- * WARNING: This API is under development, expect the interface to change
- * without notice.
- *
- * TODO: Implement other selectors, like classid, hash, and so on.
- * TODO: separate java-only core from jython wrapper
- */
-public class By extends PyObject implements ClassDictInit {
- public static void classDictInit(PyObject dict) {
- JythonUtils.convertDocAnnotationsForClass(By.class, dict);
- }
-
- private String id;
-
- By(String id) {
- this.id = id;
- }
-
- @MonkeyRunnerExported(doc = "Select an object by id.",
- args = { "id" },
- argDocs = { "The identifier of the object." })
- public static By id(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- String id = ap.getString(0);
- return new By(id);
- }
-
- public static By id(String id) {
- return new By(id);
- }
-
- public ViewNode findView(HierarchyViewer viewer) {
- return viewer.findViewById(id);
- }
-
-
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/easy/EasyMonkeyDevice.java b/monkeyrunner/src/com/android/monkeyrunner/easy/EasyMonkeyDevice.java
deleted file mode 100644
index 439718f..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/easy/EasyMonkeyDevice.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.monkeyrunner.easy;
-
-import com.google.common.base.Preconditions;
-
-import com.android.chimpchat.core.TouchPressType;
-import com.android.chimpchat.hierarchyviewer.HierarchyViewer;
-import com.android.hierarchyviewerlib.models.ViewNode;
-import com.android.monkeyrunner.JythonUtils;
-import com.android.monkeyrunner.MonkeyDevice;
-import com.android.monkeyrunner.doc.MonkeyRunnerExported;
-
-import org.eclipse.swt.graphics.Point;
-import org.python.core.ArgParser;
-import org.python.core.ClassDictInit;
-import org.python.core.Py;
-import org.python.core.PyException;
-import org.python.core.PyInteger;
-import org.python.core.PyObject;
-import org.python.core.PyTuple;
-
-import java.util.Set;
-
-/**
- * Extends {@link MonkeyDevice} to support looking up views using a 'selector'.
- * Currently, only identifiers can be used as a selector. All methods on
- * MonkeyDevice can be used on this class in Python.
- *
- * WARNING: This API is under development, expect the interface to change
- * without notice.
- */
-@MonkeyRunnerExported(doc = "MonkeyDevice with easier methods to refer to objects.")
-public class EasyMonkeyDevice extends PyObject implements ClassDictInit {
- public static void classDictInit(PyObject dict) {
- JythonUtils.convertDocAnnotationsForClass(EasyMonkeyDevice.class, dict);
- }
-
- private MonkeyDevice mDevice;
- private HierarchyViewer mHierarchyViewer;
-
- private static final Set<String> EXPORTED_METHODS =
- JythonUtils.getMethodNames(EasyMonkeyDevice.class);
-
- @MonkeyRunnerExported(doc = "Creates EasyMonkeyDevice with an underlying MonkeyDevice.",
- args = { "device" },
- argDocs = { "MonkeyDevice to extend." })
- public EasyMonkeyDevice(MonkeyDevice device) {
- this.mDevice = device;
- this.mHierarchyViewer = device.getImpl().getHierarchyViewer();
- }
-
- @MonkeyRunnerExported(doc = "Sends a touch event to the selected object.",
- args = { "selector", "type" },
- argDocs = {
- "The selector identifying the object.",
- "The event type as returned by TouchPressType()." })
- public void touch(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- By selector = getSelector(ap, 0);
- String tmpType = ap.getString(1);
- TouchPressType type = TouchPressType.fromIdentifier(tmpType);
- Preconditions.checkNotNull(type, "Invalid touch type: " + tmpType);
- // TODO: try catch rethrow PyExc
- touch(selector, type);
- }
-
- public void touch(By selector, TouchPressType type) {
- Point p = getElementCenter(selector);
- mDevice.getImpl().touch(p.x, p.y, type);
- }
-
- @MonkeyRunnerExported(doc = "Types a string into the specified object.",
- args = { "selector", "text" },
- argDocs = {
- "The selector identifying the object.",
- "The text to type into the object." })
- public void type(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- By selector = getSelector(ap, 0);
- String text = ap.getString(1);
- type(selector, text);
- }
-
- public void type(By selector, String text) {
- Point p = getElementCenter(selector);
- mDevice.getImpl().touch(p.x, p.y, TouchPressType.DOWN_AND_UP);
- mDevice.getImpl().type(text);
- }
-
- @MonkeyRunnerExported(doc = "Locates the coordinates of the selected object.",
- args = { "selector" },
- argDocs = { "The selector identifying the object." },
- returns = "Tuple containing (x,y,w,h) location and size.")
- public PyTuple locate(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- By selector = getSelector(ap, 0);
-
- ViewNode node = selector.findView(mHierarchyViewer);
- Point p = HierarchyViewer.getAbsolutePositionOfView(node);
- PyTuple tuple = new PyTuple(
- new PyInteger(p.x),
- new PyInteger(p.y),
- new PyInteger(node.width),
- new PyInteger(node.height));
- return tuple;
- }
-
- @MonkeyRunnerExported(doc = "Checks if the specified object exists.",
- args = { "selector" },
- returns = "True if the object exists.",
- argDocs = { "The selector identifying the object." })
- public boolean exists(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- By selector = getSelector(ap, 0);
- return exists(selector);
- }
-
- public boolean exists(By selector) {
- ViewNode node = selector.findView(mHierarchyViewer);
- return node != null;
- }
-
- @MonkeyRunnerExported(doc = "Checks if the specified object is visible.",
- args = { "selector" },
- returns = "True if the object is visible.",
- argDocs = { "The selector identifying the object." })
- public boolean visible(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- By selector = getSelector(ap, 0);
- return visible(selector);
- }
-
- public boolean visible(By selector) {
- ViewNode node = selector.findView(mHierarchyViewer);
- return mHierarchyViewer.visible(node);
- }
-
- @MonkeyRunnerExported(doc = "Obtain the text in the selected input box.",
- args = { "selector" },
- argDocs = { "The selector identifying the object." },
- returns = "Text in the selected input box.")
- public String getText(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
-
- By selector = getSelector(ap, 0);
- return getText(selector);
- }
-
- public String getText(By selector) {
- ViewNode node = selector.findView(mHierarchyViewer);
- return mHierarchyViewer.getText(node);
- }
-
- @MonkeyRunnerExported(doc = "Gets the id of the focused window.",
- returns = "The symbolic id of the focused window or None.")
- public String getFocusedWindowId(PyObject[] args, String[] kws) {
- return getFocusedWindowId();
- }
-
- public String getFocusedWindowId() {
- return mHierarchyViewer.getFocusedWindowName();
- }
-
- /**
- * Forwards unknown methods to the original MonkeyDevice object.
- */
- @Override
- public PyObject __findattr_ex__(String name) {
- if (!EXPORTED_METHODS.contains(name)) {
- return mDevice.__findattr_ex__(name);
- }
- return super.__findattr_ex__(name);
- }
-
- /**
- * Get the selector object from the argument parser.
- *
- * @param ap argument parser to get it from.
- * @param i argument index.
- * @return selector object.
- */
- private By getSelector(ArgParser ap, int i) {
- return (By)ap.getPyObject(i).__tojava__(By.class);
- }
-
- /**
- * Get the coordinates of the element's center.
- *
- * @param selector the element selector
- * @return the (x,y) coordinates of the center
- */
- private Point getElementCenter(By selector) {
- ViewNode node = selector.findView(mHierarchyViewer);
- if (node == null) {
- throw new PyException(Py.ValueError,
- String.format("View not found: %s", selector));
- }
-
- Point p = HierarchyViewer.getAbsoluteCenterOfView(node);
- return p;
- }
-
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/easy/README b/monkeyrunner/src/com/android/monkeyrunner/easy/README
deleted file mode 100644
index 239bedd..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/easy/README
+++ /dev/null
@@ -1,27 +0,0 @@
-com.android.monkeyrunner.easy contains classes intended to make it easier
-to interact with applications using the MonkeyRunner framework. Instead of
-referencing a button or input box by x,y coordinate, they can be referenced
-by identifier, as in the following Python example:
-
-##############################################################################
-
-from com.android.monkeyrunner import MonkeyRunner, MonkeyDevice
-from com.android.monkeyrunner.easy import EasyMonkeyDevice
-from com.android.monkeyrunner.easy import By
-
-# Connect to the current device.
-device = MonkeyRunner.waitForConnection()
-
-# Use the EasyMonkey API, all methods on device are available in easy_device.
-easy_device = EasyMonkeyDevice(device)
-
-if not easy_device.visible(By.id('id/all_apps_button')):
- raise Error('Could not find the "all apps" button')
-
-print "Location of element:", easy_device.locate(By.id('id/all_apps_button'))
-
-easy_device.touch(By.id('id/all_apps_button'), 'DOWN_AND_UP')
-
-##############################################################################
-
-WARNING: This API is under development and may change without notice.
diff --git a/monkeyrunner/src/com/android/monkeyrunner/recorder/ActionListModel.java b/monkeyrunner/src/com/android/monkeyrunner/recorder/ActionListModel.java
deleted file mode 100644
index 5e0b7e7..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/recorder/ActionListModel.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner.recorder;
-
-import com.google.common.collect.Lists;
-
-import com.android.monkeyrunner.recorder.actions.Action;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.PrintWriter;
-import java.util.List;
-
-import javax.swing.AbstractListModel;
-
-/**
- * List model for managing actions.
- */
-public class ActionListModel extends AbstractListModel {
- private List<Action> actionList = Lists.newArrayList();
-
- /**
- * Add the specified action to the end of the list
- * @param a the action to add.
- */
- public void add(Action a) {
- actionList.add(a);
- int newIndex = actionList.size() - 1;
- this.fireIntervalAdded(this, newIndex, newIndex);
- }
-
- @Override
- public Object getElementAt(int arg0) {
- return actionList.get(arg0).getDisplayName();
- }
-
-
- @Override
- public int getSize() {
- return actionList.size();
- }
-
- /**
- * Serialize all the stored actions to the specified file.
- *
- * @param selectedFile the file to write to
- * @throws FileNotFoundException if the file can't be created.
- */
- public void export(File selectedFile) throws FileNotFoundException {
- PrintWriter out = new PrintWriter(selectedFile);
- for (Action a : actionList) {
- out.println(a.serialize());
- }
- out.close();
- }
-} \ No newline at end of file
diff --git a/monkeyrunner/src/com/android/monkeyrunner/recorder/MonkeyRecorder.java b/monkeyrunner/src/com/android/monkeyrunner/recorder/MonkeyRecorder.java
deleted file mode 100644
index c8b4553..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/recorder/MonkeyRecorder.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner.recorder;
-
-import com.android.chimpchat.ChimpChat;
-import com.android.chimpchat.core.IChimpDevice;
-import com.android.monkeyrunner.MonkeyDevice;
-
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.swing.WindowConstants;
-
-/**
- * Helper entry point for MonkeyRecorder.
- */
-public class MonkeyRecorder {
- private static final Logger LOG = Logger.getLogger(MonkeyRecorder.class.getName());
- // This lock is used to keep the python process blocked while the frame is runing.
- private static final Object LOCK = new Object();
-
- /**
- * Jython entry point for MonkeyRecorder. Meant to be called like this:
- *
- * <code>
- * from com.android.monkeyrunner import MonkeyRunner as mr
- * from com.android.monkeyrunner import MonkeyRecorder
- * MonkeyRecorder.start(mr.waitForConnection())
- * </code>
- *
- * @param device
- */
- public static void start(final MonkeyDevice device) {
- start(device.getImpl());
- }
-
- /* package */static void start(final IChimpDevice device) {
- MonkeyRecorderFrame frame = new MonkeyRecorderFrame(device);
- // TODO: this is a hack until the window listener works.
- frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
- frame.addWindowListener(new WindowAdapter() {
- @Override
- public void windowClosed(WindowEvent e) {
- device.dispose();
- synchronized (LOCK) {
- LOCK.notifyAll();
- }
- }
- });
-
- frame.setVisible(true);
- synchronized (LOCK) {
- try {
- LOCK.wait();
- } catch (InterruptedException e) {
- LOG.log(Level.SEVERE, "Unexpected Exception", e);
- }
- }
- }
-
- public static void main(String[] args) {
- ChimpChat chimp = ChimpChat.getInstance();
- MonkeyRecorder.start(chimp.waitForConnection());
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/recorder/MonkeyRecorderFrame.java b/monkeyrunner/src/com/android/monkeyrunner/recorder/MonkeyRecorderFrame.java
deleted file mode 100644
index 394b895..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/recorder/MonkeyRecorderFrame.java
+++ /dev/null
@@ -1,434 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner.recorder;
-
-import com.android.monkeyrunner.MonkeyDevice;
-import com.android.chimpchat.core.IChimpImage;
-import com.android.chimpchat.core.IChimpDevice;
-import com.android.monkeyrunner.recorder.actions.Action;
-import com.android.monkeyrunner.recorder.actions.DragAction;
-import com.android.monkeyrunner.recorder.actions.DragAction.Direction;
-import com.android.monkeyrunner.recorder.actions.PressAction;
-import com.android.monkeyrunner.recorder.actions.TouchAction;
-import com.android.monkeyrunner.recorder.actions.TypeAction;
-import com.android.monkeyrunner.recorder.actions.WaitAction;
-
-import java.awt.BorderLayout;
-import java.awt.Dimension;
-import java.awt.Graphics2D;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.awt.image.BufferedImage;
-import java.io.FileNotFoundException;
-import java.util.Map;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import javax.swing.BoxLayout;
-import javax.swing.ImageIcon;
-import javax.swing.JButton;
-import javax.swing.JComboBox;
-import javax.swing.JFileChooser;
-import javax.swing.JFrame;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JScrollPane;
-import javax.swing.JTextField;
-import javax.swing.SwingUtilities;
-import javax.swing.Timer;
-
-/**
- * MainFrame for MonkeyRecorder.
- */
-public class MonkeyRecorderFrame extends JFrame {
- private static final Logger LOG =
- Logger.getLogger(MonkeyRecorderFrame.class.getName());
-
- private final IChimpDevice device;
-
- private static final long serialVersionUID = 1L;
- private JPanel jContentPane = null;
- private JLabel display = null;
- private JScrollPane historyPanel = null;
- private JPanel actionPanel = null;
- private JButton waitButton = null;
- private JButton pressButton = null;
- private JButton typeButton = null;
- private JButton flingButton = null;
- private JButton exportActionButton = null;
-
- private JButton refreshButton = null;
-
- private BufferedImage currentImage; // @jve:decl-index=0:
- private BufferedImage scaledImage = new BufferedImage(320, 480,
- BufferedImage.TYPE_INT_ARGB); // @jve:decl-index=0:
-
- private JList historyList;
- private ActionListModel actionListModel;
-
- private final Timer refreshTimer = new Timer(1000, new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- refreshDisplay(); // @jve:decl-index=0:
- }
- });
-
- /**
- * This is the default constructor
- */
- public MonkeyRecorderFrame(IChimpDevice device) {
- this.device = device;
- initialize();
- }
-
- private void initialize() {
- this.setSize(400, 600);
- this.setContentPane(getJContentPane());
- this.setTitle("MonkeyRecorder");
-
- SwingUtilities.invokeLater(new Runnable() {
- @Override
- public void run() {
- refreshDisplay();
- }});
- refreshTimer.start();
- }
-
- private void refreshDisplay() {
- IChimpImage snapshot = device.takeSnapshot();
- currentImage = snapshot.createBufferedImage();
-
- Graphics2D g = scaledImage.createGraphics();
- g.drawImage(currentImage, 0, 0,
- scaledImage.getWidth(), scaledImage.getHeight(),
- null);
- g.dispose();
-
- display.setIcon(new ImageIcon(scaledImage));
-
- pack();
- }
-
- /**
- * This method initializes jContentPane
- *
- * @return javax.swing.JPanel
- */
- private JPanel getJContentPane() {
- if (jContentPane == null) {
- display = new JLabel();
- jContentPane = new JPanel();
- jContentPane.setLayout(new BorderLayout());
- jContentPane.add(display, BorderLayout.CENTER);
- jContentPane.add(getHistoryPanel(), BorderLayout.EAST);
- jContentPane.add(getActionPanel(), BorderLayout.NORTH);
-
- display.setPreferredSize(new Dimension(320, 480));
-
- display.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseClicked(MouseEvent event) {
- touch(event);
- }
- });
- }
- return jContentPane;
- }
-
- /**
- * This method initializes historyPanel
- *
- * @return javax.swing.JScrollPane
- */
- private JScrollPane getHistoryPanel() {
- if (historyPanel == null) {
- historyPanel = new JScrollPane();
- historyPanel.getViewport().setView(getHistoryList());
- }
- return historyPanel;
- }
-
- private JList getHistoryList() {
- if (historyList == null) {
- actionListModel = new ActionListModel();
- historyList = new JList(actionListModel);
- }
- return historyList;
- }
-
- /**
- * This method initializes actionPanel
- *
- * @return javax.swing.JPanel
- */
- private JPanel getActionPanel() {
- if (actionPanel == null) {
- actionPanel = new JPanel();
- actionPanel.setLayout(new BoxLayout(getActionPanel(), BoxLayout.X_AXIS));
- actionPanel.add(getWaitButton(), null);
- actionPanel.add(getPressButton(), null);
- actionPanel.add(getTypeButton(), null);
- actionPanel.add(getFlingButton(), null);
- actionPanel.add(getExportActionButton(), null);
- actionPanel.add(getRefreshButton(), null);
- }
- return actionPanel;
- }
-
- /**
- * This method initializes waitButton
- *
- * @return javax.swing.JButton
- */
- private JButton getWaitButton() {
- if (waitButton == null) {
- waitButton = new JButton();
- waitButton.setText("Wait");
- waitButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(java.awt.event.ActionEvent e) {
- String howLongStr = JOptionPane.showInputDialog("How many seconds to wait?");
- if (howLongStr != null) {
- float howLong = Float.parseFloat(howLongStr);
- addAction(new WaitAction(howLong));
- }
- }
- });
- }
- return waitButton;
- }
-
- /**
- * This method initializes pressButton
- *
- * @return javax.swing.JButton
- */
- private JButton getPressButton() {
- if (pressButton == null) {
- pressButton = new JButton();
- pressButton.setText("Press a Button");
- pressButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(java.awt.event.ActionEvent e) {
- JPanel panel = new JPanel();
- JLabel text = new JLabel("What button to press?");
- JComboBox keys = new JComboBox(PressAction.KEYS);
- keys.setEditable(true);
- JComboBox direction = new JComboBox(PressAction.DOWNUP_FLAG_MAP.values().toArray());
- panel.add(text);
- panel.add(keys);
- panel.add(direction);
-
- int result = JOptionPane.showConfirmDialog(null, panel, "Input", JOptionPane.OK_CANCEL_OPTION);
- if (result == JOptionPane.OK_OPTION) {
- // Look up the "flag" value for the press choice
- Map<String, String> lookupMap = PressAction.DOWNUP_FLAG_MAP.inverse();
- String flag = lookupMap.get(direction.getSelectedItem());
- addAction(new PressAction((String) keys.getSelectedItem(), flag));
- }
- }
- });
- }
- return pressButton;
- }
-
- /**
- * This method initializes typeButton
- *
- * @return javax.swing.JButton
- */
- private JButton getTypeButton() {
- if (typeButton == null) {
- typeButton = new JButton();
- typeButton.setText("Type Something");
- typeButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(java.awt.event.ActionEvent e) {
- String whatToType = JOptionPane.showInputDialog("What to type?");
- if (whatToType != null) {
- addAction(new TypeAction(whatToType));
- }
- }
- });
- }
- return typeButton;
- }
-
- /**
- * This method initializes flingButton
- *
- * @return javax.swing.JButton
- */
- private JButton getFlingButton() {
- if (flingButton == null) {
- flingButton = new JButton();
- flingButton.setText("Fling");
- flingButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(java.awt.event.ActionEvent e) {
- JPanel panel = new JPanel();
- panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
- panel.add(new JLabel("Which Direction to fling?"));
- JComboBox directionChooser = new JComboBox(DragAction.Direction.getNames());
- panel.add(directionChooser);
- panel.add(new JLabel("How long to drag (in ms)?"));
- JTextField ms = new JTextField();
- ms.setText("1000");
- panel.add(ms);
- panel.add(new JLabel("How many steps to do it in?"));
- JTextField steps = new JTextField();
- steps.setText("10");
- panel.add(steps);
-
-
-
- int result = JOptionPane.showConfirmDialog(null, panel, "Input", JOptionPane.OK_CANCEL_OPTION);
- if (result == JOptionPane.OK_OPTION) {
- DragAction.Direction dir =
- DragAction.Direction.valueOf((String) directionChooser.getSelectedItem());
- long millis = Long.parseLong(ms.getText());
- int numSteps = Integer.parseInt(steps.getText());
-
- addAction(newFlingAction(dir, numSteps, millis));
- }
- }
- });
- }
- return flingButton;
- }
-
- private DragAction newFlingAction(Direction dir, int numSteps, long millis) {
- int width = Integer.parseInt(device.getProperty("display.width"));
- int height = Integer.parseInt(device.getProperty("display.height"));
-
- // Adjust the w/h to a pct of the total size, so we don't hit things on the "outside"
- width = (int) (width * 0.8f);
- height = (int) (height * 0.8f);
- int minW = (int) (width * 0.2f);
- int minH = (int) (height * 0.2f);
-
- int midWidth = width / 2;
- int midHeight = height / 2;
-
- int startx = minW;
- int starty = minH;
- int endx = minW;
- int endy = minH;
-
- switch (dir) {
- case NORTH:
- startx = endx = midWidth;
- starty = height;
- break;
- case SOUTH:
- startx = endx = midWidth;
- endy = height;
- break;
- case EAST:
- starty = endy = midHeight;
- endx = width;
- break;
- case WEST:
- starty = endy = midHeight;
- startx = width;
- break;
- }
-
- return new DragAction(dir, startx, starty, endx, endy, numSteps, millis);
- }
-
- /**
- * This method initializes exportActionButton
- *
- * @return javax.swing.JButton
- */
- private JButton getExportActionButton() {
- if (exportActionButton == null) {
- exportActionButton = new JButton();
- exportActionButton.setText("Export Actions");
- exportActionButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(java.awt.event.ActionEvent ev) {
- JFileChooser fc = new JFileChooser();
- if (fc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
- try {
- actionListModel.export(fc.getSelectedFile());
- } catch (FileNotFoundException e) {
- LOG.log(Level.SEVERE, "Unable to save file", e);
- }
- }
- }
- });
- }
- return exportActionButton;
- }
-
- /**
- * This method initializes refreshButton
- *
- * @return javax.swing.JButton
- */
- private JButton getRefreshButton() {
- if (refreshButton == null) {
- refreshButton = new JButton();
- refreshButton.setText("Refresh Display");
- refreshButton.addActionListener(new java.awt.event.ActionListener() {
- @Override
- public void actionPerformed(java.awt.event.ActionEvent e) {
- refreshDisplay();
- }
- });
- }
- return refreshButton;
- }
-
- private void touch(MouseEvent event) {
- int x = event.getX();
- int y = event.getY();
-
- // Since we scaled the image down, our x/y are scaled as well.
- double scalex = ((double) currentImage.getWidth()) / ((double) scaledImage.getWidth());
- double scaley = ((double) currentImage.getHeight()) / ((double) scaledImage.getHeight());
-
- x = (int) (x * scalex);
- y = (int) (y * scaley);
-
- switch (event.getID()) {
- case MouseEvent.MOUSE_CLICKED:
- addAction(new TouchAction(x, y, MonkeyDevice.DOWN_AND_UP));
- break;
- case MouseEvent.MOUSE_PRESSED:
- addAction(new TouchAction(x, y, MonkeyDevice.DOWN));
- break;
- case MouseEvent.MOUSE_RELEASED:
- addAction(new TouchAction(x, y, MonkeyDevice.UP));
- break;
- }
- }
-
- public void addAction(Action a) {
- actionListModel.add(a);
- try {
- a.execute(device);
- } catch (Exception e) {
- LOG.log(Level.SEVERE, "Unable to execute action!", e);
- }
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/Action.java b/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/Action.java
deleted file mode 100644
index 905f1f1..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/Action.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner.recorder.actions;
-
-import com.android.chimpchat.core.IChimpDevice;
-
-/**
- * All actions that can be recorded must implement this interface.
- */
-public interface Action {
- /**
- * Serialize this action into a string. This method is called to put the list of actions into
- * a file.
- *
- * @return the serialized string
- */
- String serialize();
-
- /**
- * Get the printable name for this action. This method is used to show the Action in the UI.
- *
- * @return the display name
- */
- String getDisplayName();
-
- /**
- * Execute the given action.
- *
- * @param device the device to execute the action on.
- */
- void execute(IChimpDevice device) throws Exception;
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/DragAction.java b/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/DragAction.java
deleted file mode 100644
index 498bc6b..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/DragAction.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner.recorder.actions;
-
-import com.android.chimpchat.core.IChimpDevice;
-
-/**
- * Action to drag the "finger" across the device.
- */
-public class DragAction implements Action {
- private final long timeMs;
- private final int steps;
- private final int startx;
- private final int starty;
- private final int endx;
- private final int endy;
- private final Direction dir;
-
- public enum Direction {
- NORTH, SOUTH, EAST, WEST;
-
- private static String[] names;
- static {
- Direction[] values = Direction.values();
- names = new String[values.length];
- for (int x = 0; x < values.length; x++) {
- names[x] = values[x].name();
- }
- }
-
- public static String[] getNames() {
- return names;
- }
- }
-
- public DragAction(Direction dir,
- int startx, int starty, int endx, int endy,
- int numSteps, long millis) {
- this.dir = dir;
- this.startx = startx;
- this.starty = starty;
- this.endx = endx;
- this.endy = endy;
- steps = numSteps;
- timeMs = millis;
- }
-
- @Override
- public String getDisplayName() {
- return String.format("Fling %s", dir.name().toLowerCase());
- }
-
- @Override
- public String serialize() {
- float duration = timeMs / 1000.0f;
-
- String pydict = PyDictUtilBuilder.newBuilder().
- addTuple("start", startx, starty).
- addTuple("end", endx, endy).
- add("duration", duration).
- add("steps", steps).
- build();
- return "DRAG|" + pydict;
- }
-
- @Override
- public void execute(IChimpDevice device) {
- device.drag(startx, starty, endx, endy, steps, timeMs);
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/PressAction.java b/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/PressAction.java
deleted file mode 100644
index 4245736..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/PressAction.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner.recorder.actions;
-
-import com.google.common.collect.BiMap;
-import com.google.common.collect.ImmutableBiMap;
-
-import com.android.monkeyrunner.MonkeyDevice;
-import com.android.chimpchat.core.IChimpDevice;
-import com.android.chimpchat.core.TouchPressType;
-
-/**
- * Action to press a certain button.
- */
-public class PressAction implements Action {
- public static String[] KEYS = {
- "MENU", "HOME", "SEARCH",
- };
-
- public static final BiMap<String, String> DOWNUP_FLAG_MAP =
- ImmutableBiMap.of(MonkeyDevice.DOWN_AND_UP, "Press",
- MonkeyDevice.DOWN, "Down",
- MonkeyDevice.UP, "Up");
-
- private final String key;
- private final String downUpFlag;
-
- public PressAction(String key, String downUpFlag) {
- this.key = key;
- this.downUpFlag = downUpFlag;
- }
-
- public PressAction(String key) {
- this(key, MonkeyDevice.DOWN_AND_UP);
- }
-
- @Override
- public String getDisplayName() {
- return String.format("%s button %s",
- DOWNUP_FLAG_MAP.get(downUpFlag), key);
- }
-
- @Override
- public String serialize() {
- String pydict = PyDictUtilBuilder.newBuilder().
- add("name", key).
- add("type", downUpFlag).build();
- return "PRESS|" + pydict;
- }
-
- @Override
- public void execute(IChimpDevice device) {
- device.press(key, TouchPressType.fromIdentifier(downUpFlag));
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/PyDictUtilBuilder.java b/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/PyDictUtilBuilder.java
deleted file mode 100644
index 0cfbabe..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/PyDictUtilBuilder.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner.recorder.actions;
-
-/**
- * Utility class to create Python Dictionary Strings.
- *
- * {'key': 'value'}
- */
-public class PyDictUtilBuilder {
- private StringBuilder sb = new StringBuilder();
-
- public PyDictUtilBuilder() {
- sb.append("{");
- }
-
- public static PyDictUtilBuilder newBuilder() {
- return new PyDictUtilBuilder();
- }
-
- private void addHelper(String key, String value) {
- sb.append("'").append(key).append("'");
- sb.append(":").append(value).append(",");
- }
-
- public PyDictUtilBuilder add(String key, int value) {
- addHelper(key, Integer.toString(value));
- return this;
- }
-
- public PyDictUtilBuilder add(String key, float value) {
- addHelper(key, Float.toString(value));
- return this;
- }
-
- public PyDictUtilBuilder add(String key, String value) {
- addHelper(key, "'" + value + "'");
- return this;
- }
-
- public String build() {
- sb.append("}");
- return sb.toString();
- }
-
- public PyDictUtilBuilder addTuple(String key, int x, int y) {
- String valuestr = new StringBuilder().append("(").append(x).append(",").append(y).append(")").toString();
- addHelper(key, valuestr);
- return this;
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/TouchAction.java b/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/TouchAction.java
deleted file mode 100644
index 146bb55..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/TouchAction.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner.recorder.actions;
-
-import com.google.common.collect.BiMap;
-import com.google.common.collect.ImmutableBiMap;
-
-import com.android.monkeyrunner.MonkeyDevice;
-import com.android.chimpchat.core.IChimpDevice;
-import com.android.chimpchat.core.TouchPressType;
-
-/**
- * Action to touch the touchscreen at a certain location.
- */
-public class TouchAction implements Action {
- public static final BiMap<String, String> DOWNUP_FLAG_MAP =
- ImmutableBiMap.of(MonkeyDevice.DOWN_AND_UP, "Tap",
- MonkeyDevice.DOWN, "Down",
- MonkeyDevice.UP, "Up");
-
- private final int x;
- private final int y;
- private final String direction;
-
- public TouchAction(int x, int y, String direction) {
- this.x = x;
- this.y = y;
- this.direction = direction;
- }
-
- @Override
- public String getDisplayName() {
- return String.format("%s touchscreen at (%d, %d)",
- DOWNUP_FLAG_MAP.get(direction), x, y);
- }
-
- @Override
- public void execute(IChimpDevice device) throws Exception {
- device.touch(x, y, TouchPressType.fromIdentifier(direction));
- }
-
- @Override
- public String serialize() {
- String pydict = PyDictUtilBuilder.newBuilder().
- add("x", x).
- add("y", y).
- add("type", direction).build();
- return "TOUCH|" + pydict;
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/TypeAction.java b/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/TypeAction.java
deleted file mode 100644
index fd5f786..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/TypeAction.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner.recorder.actions;
-
-import com.android.chimpchat.core.IChimpDevice;
-
-/**
- * Action to type in a string on the device.
- */
-public class TypeAction implements Action {
- private final String whatToType;
-
- public TypeAction(String whatToType) {
- this.whatToType = whatToType;
- }
-
- @Override
- public String getDisplayName() {
- return String.format("Type \"%s\"", whatToType);
- }
-
- @Override
- public String serialize() {
- String pydict = PyDictUtilBuilder.newBuilder()
- .add("message", whatToType).build();
- return "TYPE|" + pydict;
- }
-
- @Override
- public void execute(IChimpDevice device) {
- device.type(whatToType);
- }
-}
diff --git a/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/WaitAction.java b/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/WaitAction.java
deleted file mode 100644
index d61570b..0000000
--- a/monkeyrunner/src/com/android/monkeyrunner/recorder/actions/WaitAction.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner.recorder.actions;
-
-import com.android.chimpchat.core.IChimpDevice;
-
-/**
- * Action that specifies to wait for a certain amount of time.
- */
-public class WaitAction implements Action {
- private final float howLongSeconds;
-
- public WaitAction(float howLongSeconds) {
- this.howLongSeconds = howLongSeconds;
- }
-
- public String getDisplayName() {
- return String.format("Wait for %g seconds", this.howLongSeconds);
- }
-
- public String serialize() {
- String pydict = PyDictUtilBuilder.newBuilder().add("seconds", howLongSeconds).build();
- return "WAIT|" + pydict;
- }
-
- public void execute(IChimpDevice device) throws Exception {
- long ms = (long) (1000.0f * howLongSeconds);
- Thread.sleep(ms);
- }
-}
diff --git a/monkeyrunner/src/resources/com/android/monkeyrunner/html.cs b/monkeyrunner/src/resources/com/android/monkeyrunner/html.cs
deleted file mode 100644
index 06415c6..0000000
--- a/monkeyrunner/src/resources/com/android/monkeyrunner/html.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-<html>
-<body>
-<h1>MonkeyRunner Help<h1>
-<h2>Table of Contents</h2>
-<ul>
-<?cs each:item = help ?>
-<li><a href="#<?cs name:item ?>"><?cs var:item.name ?></a></li>
-<?cs /each ?>
-</ul>
-<?cs each:item = help ?>
-<h2><a name="<?cs name:item ?>"><?cs var:item.name ?></a></h2>
- <?cs each:docpara = item.doc ?>
- <p><?cs var:docpara ?></p>
- <?cs /each ?>
- <?cs if:subcount(item.argument) ?>
-<h3>Args</h3>
-<ul>
- <?cs each:arg = item.argument ?>
- <li><?cs var:arg.name ?> - <?cs each:argdocpara = arg.doc ?><?cs var:argdocpara ?> <?cs /each ?>
- <?cs /each ?>
-</ul>
-<h3>Returns</h3>
-<p><?cs each:retdocpara = item.returns ?><?cs var:retdocpara ?> <?cs /each ?></p>
-<?cs /if ?>
-<?cs /each ?>
-</body>
-</html>
diff --git a/monkeyrunner/src/resources/com/android/monkeyrunner/sdk-docs.cs b/monkeyrunner/src/resources/com/android/monkeyrunner/sdk-docs.cs
deleted file mode 100644
index b4be1fe..0000000
--- a/monkeyrunner/src/resources/com/android/monkeyrunner/sdk-docs.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-page.title=UI/Application Exerciser Monkey API
-@jd:body
-
-<h2>MonkeyRunner Help<h2>
-<h3>Table of Contents</h3>
-<ul>
-<?cs each:item = help ?>
-<li><a href="#<?cs name:item ?>"><?cs var:item.name ?></a></li>
-<?cs /each ?>
-</ul>
-<?cs each:item = help ?>
-<h3><a name="<?cs name:item ?>"><?cs var:item.name ?></a></h3>
- <?cs each:docpara = item.doc ?>
- <p><?cs var:docpara ?></p>
- <?cs /each ?>
- <?cs if:subcount(item.argument) ?>
-<h4>Args</h4>
-<ul>
- <?cs each:arg = item.argument ?>
- <li><?cs var:arg.name ?> - <?cs each:argdocpara = arg.doc ?><?cs var:argdocpara ?> <?cs /each ?>
- <?cs /each ?>
-</ul>
-<h4>Returns</h4>
-<p><?cs each:retdocpara = item.returns ?><?cs var:retdocpara ?> <?cs /each ?></p>
-<?cs /if ?>
-<?cs /each ?>
-</body>
-</html>
diff --git a/monkeyrunner/src/resources/com/android/monkeyrunner/text.cs b/monkeyrunner/src/resources/com/android/monkeyrunner/text.cs
deleted file mode 100644
index 3a1741c..0000000
--- a/monkeyrunner/src/resources/com/android/monkeyrunner/text.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-MonkeyRunner help
-<?cs each:item = help ?>
-<?cs var:item.name ?>
- <?cs each:docpara = item.doc ?><?cs var:docpara ?>
- <?cs /each ?>
-
-<?cs if:subcount(item.argument) ?> Args:<?cs each:arg = item.argument ?>
- <?cs var:arg.name ?> - <?cs each:argdocpara = arg.doc ?><?cs var:argdocpara ?> <?cs /each ?><?cs /each ?>
-<?cs /if ?> Returns: <?cs each:retdocpara = item.returns ?><?cs var:retdocpara ?> <?cs /each ?>
-<?cs /each ?>
diff --git a/monkeyrunner/test/Android.mk b/monkeyrunner/test/Android.mk
deleted file mode 100644
index 6e2233b..0000000
--- a/monkeyrunner/test/Android.mk
+++ /dev/null
@@ -1,23 +0,0 @@
-#
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_MODULE := MonkeyRunnerTest
-LOCAL_JAVA_LIBRARIES := junit monkeyrunner ddmlib guavalib jython
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/monkeyrunner/test/com/android/monkeyrunner/AllTests.java b/monkeyrunner/test/com/android/monkeyrunner/AllTests.java
deleted file mode 100644
index 2e0bffd..0000000
--- a/monkeyrunner/test/com/android/monkeyrunner/AllTests.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestResult;
-import junit.framework.TestSuite;
-import junit.textui.TestRunner;
-
-/**
- * Test suite to run all the tests for MonkeyRunner.
- */
-public class AllTests {
- public static Test suite(Class<? extends TestCase>... classes) {
- TestSuite suite = new TestSuite();
- for (Class<? extends TestCase> clz : classes) {
- suite.addTestSuite(clz);
- }
- return suite;
- }
-
- public static void main(String args[]) {
- TestRunner tr = new TestRunner();
- TestResult result = tr.doRun(AllTests.suite(JythonUtilsTest.class,
- MonkeyRunnerOptionsTest.class));
- if (result.wasSuccessful()) {
- System.exit(0);
- } else {
- System.exit(1);
- }
- }
-}
diff --git a/monkeyrunner/test/com/android/monkeyrunner/JythonUtilsTest.java b/monkeyrunner/test/com/android/monkeyrunner/JythonUtilsTest.java
deleted file mode 100644
index 5f781f1..0000000
--- a/monkeyrunner/test/com/android/monkeyrunner/JythonUtilsTest.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner;
-
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Maps;
-
-import com.android.monkeyrunner.doc.MonkeyRunnerExported;
-
-import junit.framework.TestCase;
-
-import org.python.core.ArgParser;
-import org.python.core.ClassDictInit;
-import org.python.core.PyDictionary;
-import org.python.core.PyException;
-import org.python.core.PyObject;
-import org.python.core.PyString;
-
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Unit tests for the JythonUtils class.
- */
-public class JythonUtilsTest extends TestCase {
- private static final String PACKAGE_NAME = JythonUtilsTest.class.getPackage().getName();
- private static final String CLASS_NAME = JythonUtilsTest.class.getSimpleName();
- private static final String EXECUTABLE_PATH = "string";
-
- private static boolean called = false;
- private static double floatValue = 0.0;
- private static List<Object> listValue = null;
- private static Map<String, Object> mapValue;
-
- @MonkeyRunnerExported(doc = "", args = {"value"})
- public static void floatTest(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- called = true;
-
- floatValue = JythonUtils.getFloat(ap, 0);
- }
-
- @MonkeyRunnerExported(doc = "", args = {"value"})
- public static void listTest(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- called = true;
-
- listValue = JythonUtils.getList(ap, 0);
- }
-
- @MonkeyRunnerExported(doc = "", args = {"value"})
- public static void mapTest(PyObject[] args, String[] kws) {
- ArgParser ap = JythonUtils.createArgParser(args, kws);
- Preconditions.checkNotNull(ap);
- called = true;
-
- mapValue = JythonUtils.getMap(ap, 0);
- }
-
- @MonkeyRunnerExported(doc = "")
- public static PyDictionary convertMapTest(PyObject[] args, String[] kws) {
- Map<String, Object> map = Maps.newHashMap();
- map.put("string", "value");
- map.put("integer", 1);
- map.put("double", 3.14);
- return JythonUtils.convertMapToDict(map);
- }
-
- @Override
- protected void setUp() throws Exception {
- called = false;
- floatValue = 0.0;
- }
-
- private static PyObject call(String method) {
- return call(method, new String[]{ });
- }
- private static PyObject call(String method, String... args) {
- StringBuilder sb = new StringBuilder();
- sb.append("from ").append(PACKAGE_NAME);
- sb.append(" import ").append(CLASS_NAME).append("\n");
-
- // Exec line
- sb.append("result = ");
- sb.append(CLASS_NAME).append(".").append(method);
- sb.append("(");
- for (String arg : args) {
- sb.append(arg).append(",");
- }
- sb.append(")");
-
- return ScriptRunner.runStringAndGet(EXECUTABLE_PATH, sb.toString(), "result").get("result");
- }
-
- public void testSimpleCall() {
- call("floatTest", "0.0");
- assertTrue(called);
- }
-
- public void testMissingFloatArg() {
- try {
- call("floatTest");
- } catch(PyException e) {
- return;
- }
- fail("Should have thrown exception");
- }
-
- public void testBadFloatArgType() {
- try {
- call("floatTest", "\'foo\'");
- } catch(PyException e) {
- return;
- }
- fail("Should have thrown exception");
- }
-
- public void testFloatParse() {
- call("floatTest", "103.2");
- assertTrue(called);
- assertEquals(floatValue, 103.2);
- }
-
- public void testFloatParseInteger() {
- call("floatTest", "103");
- assertTrue(called);
- assertEquals(floatValue, 103.0);
- }
-
- public void testParseStringList() {
- call("listTest", "['a', 'b', 'c']");
- assertTrue(called);
- assertEquals(3, listValue.size());
- assertEquals("a", listValue.get(0));
- assertEquals("b", listValue.get(1));
- assertEquals("c", listValue.get(2));
- }
-
- public void testParseIntList() {
- call("listTest", "[1, 2, 3]");
- assertTrue(called);
- assertEquals(3, listValue.size());
- assertEquals(new Integer(1), listValue.get(0));
- assertEquals(new Integer(2), listValue.get(1));
- assertEquals(new Integer(3), listValue.get(2));
- }
-
- public void testParseMixedList() {
- call("listTest", "['a', 1, 3.14]");
- assertTrue(called);
- assertEquals(3, listValue.size());
- assertEquals("a", listValue.get(0));
- assertEquals(new Integer(1), listValue.get(1));
- assertEquals(new Double(3.14), listValue.get(2));
- }
-
- public void testParseOptionalList() {
- call("listTest");
- assertTrue(called);
- assertEquals(0, listValue.size());
- }
-
- public void testParsingNotAList() {
- try {
- call("listTest", "1.0");
- } catch (PyException e) {
- return;
- }
- fail("Should have thrown an exception");
- }
-
- public void testParseMap() {
- call("mapTest", "{'a': 0, 'b': 'bee', 3: 'cee'}");
- assertTrue(called);
- assertEquals(3, mapValue.size());
- assertEquals(new Integer(0), mapValue.get("a"));
- assertEquals("bee", mapValue.get("b"));
- // note: coerced key type
- assertEquals("cee", mapValue.get("3"));
- }
-
- public void testParsingNotAMap() {
- try {
- call("mapTest", "1.0");
- } catch (PyException e) {
- return;
- }
- fail("Should have thrown an exception");
- }
-
- public void testParseOptionalMap() {
- call("mapTest");
- assertTrue(called);
- assertEquals(0, mapValue.size());
- }
-
- public void testConvertMap() {
- PyDictionary result = (PyDictionary) call("convertMapTest");
- PyObject stringPyObject = result.__getitem__(new PyString("string"));
- String string = (String) stringPyObject.__tojava__(String.class);
- assertEquals("value", string);
-
- PyObject intPyObject = result.__getitem__(new PyString("integer"));
- int i = (Integer) intPyObject.__tojava__(Integer.class);
- assertEquals(i, 1);
-
- PyObject doublePyObject = result.__getitem__(new PyString("double"));
- double d = (Double) doublePyObject.__tojava__(Double.class);
- assertEquals(3.14, d);
- }
-
- /**
- * Base class to test overridden methods.
- */
- static class PythonMethodsClass extends PyObject implements ClassDictInit {
- public static void classDictInit(PyObject dict) {
- JythonUtils.convertDocAnnotationsForClass(PythonMethodsClass.class, dict);
- }
-
- @MonkeyRunnerExported(doc = "The first method.")
- public void firstMethod(PyObject[] args, String[] kws) {
- }
-
- @MonkeyRunnerExported(doc = "The second method.")
- public void secondMethod(PyObject[] args, String[] kws) {
- }
-
- public void unattributedMethod() {
- }
- }
-
- public void testGetPythonMethods() {
- Set<String> methods = JythonUtils.getMethodNames(PythonMethodsClass.class);
- assertEquals(2, methods.size());
- assertTrue(methods.contains("firstMethod"));
- assertTrue(methods.contains("secondMethod"));
-
- // Make sure it works on non-Jython objects.
- assertTrue(JythonUtils.getMethodNames(String.class).isEmpty());
- }
-}
diff --git a/monkeyrunner/test/com/android/monkeyrunner/MonkeyRunnerOptionsTest.java b/monkeyrunner/test/com/android/monkeyrunner/MonkeyRunnerOptionsTest.java
deleted file mode 100644
index fd23721..0000000
--- a/monkeyrunner/test/com/android/monkeyrunner/MonkeyRunnerOptionsTest.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.monkeyrunner;
-
-import junit.framework.TestCase;
-
-import java.io.File;
-import java.util.Iterator;
-
-/**
- * Unit Tests to test command line argument parsing.
- */
-public class MonkeyRunnerOptionsTest extends TestCase {
- // We need to use a file that actually exists
- private static final String FILENAME = "/etc/passwd";
-
- public void testSimpleArgs() {
- MonkeyRunnerOptions options =
- MonkeyRunnerOptions.processOptions(new String[] { FILENAME });
- assertEquals(options.getScriptFile(), new File(FILENAME));
- }
-
- public void testParsingArgsBeforeScriptName() {
- MonkeyRunnerOptions options =
- MonkeyRunnerOptions.processOptions(new String[] { "-be", "stub", FILENAME});
- assertEquals("stub", options.getBackendName());
- assertEquals(options.getScriptFile(), new File(FILENAME));
- }
-
- public void testParsingScriptArgument() {
- MonkeyRunnerOptions options =
- MonkeyRunnerOptions.processOptions(new String[] { FILENAME, "arg1", "arg2" });
- assertEquals(options.getScriptFile(), new File(FILENAME));
- Iterator<String> i = options.getArguments().iterator();
- assertEquals("arg1", i.next());
- assertEquals("arg2", i.next());
- }
-
- public void testParsingScriptArgumentWithDashes() {
- MonkeyRunnerOptions options =
- MonkeyRunnerOptions.processOptions(new String[] { FILENAME, "--arg1" });
- assertEquals(options.getScriptFile(), new File(FILENAME));
- assertEquals("--arg1", options.getArguments().iterator().next());
- }
-
- public void testMixedArgs() {
- MonkeyRunnerOptions options =
- MonkeyRunnerOptions.processOptions(new String[] { "-be", "stub", FILENAME,
- "arg1", "--debug=True"});
- assertEquals("stub", options.getBackendName());
- assertEquals(options.getScriptFile(), new File(FILENAME));
- Iterator<String> i = options.getArguments().iterator();
- assertEquals("arg1", i.next());
- assertEquals("--debug=True", i.next());
- }
-}
diff --git a/monkeyrunner/test/resources/com/android/monkeyrunner/adb/instrument_result.txt b/monkeyrunner/test/resources/com/android/monkeyrunner/adb/instrument_result.txt
deleted file mode 100644
index c127c0f..0000000
--- a/monkeyrunner/test/resources/com/android/monkeyrunner/adb/instrument_result.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-INSTRUMENTATION_STATUS: id=InstrumentationTestRunner
-INSTRUMENTATION_STATUS: current=1
-INSTRUMENTATION_STATUS: class=com.example.android.notepad.NotePadTest
-INSTRUMENTATION_STATUS: stream=.
-INSTRUMENTATION_STATUS: numtests=1
-INSTRUMENTATION_STATUS: test=testActivityTestCaseSetUpProperly
-INSTRUMENTATION_STATUS_CODE: 0
-INSTRUMENTATION_RESULT: result1=one
-INSTRUMENTATION_RESULT: result2=two
-INSTRUMENTATION_CODE: -1
diff --git a/monkeyrunner/test/resources/com/android/monkeyrunner/adb/multiline_instrument_result.txt b/monkeyrunner/test/resources/com/android/monkeyrunner/adb/multiline_instrument_result.txt
deleted file mode 100644
index 32fd901..0000000
--- a/monkeyrunner/test/resources/com/android/monkeyrunner/adb/multiline_instrument_result.txt
+++ /dev/null
@@ -1,15 +0,0 @@
-INSTRUMENTATION_STATUS: id=InstrumentationTestRunner
-INSTRUMENTATION_STATUS: current=1
-INSTRUMENTATION_STATUS: class=com.example.android.notepad.NotePadTest
-INSTRUMENTATION_STATUS: stream=.
-INSTRUMENTATION_STATUS: numtests=1
-INSTRUMENTATION_STATUS: test=testActivityTestCaseSetUpProperly
-INSTRUMENTATION_STATUS_CODE: 0
-INSTRUMENTATION_RESULT: stream=
-Test results for InstrumentationTestRunner=.
-Time: 2.242
-
-OK (1 test)
-
-
-INSTRUMENTATION_CODE: -1
diff --git a/monkeyrunner/test/resources/com/android/monkeyrunner/image1.png b/monkeyrunner/test/resources/com/android/monkeyrunner/image1.png
deleted file mode 100644
index 9ef1800..0000000
--- a/monkeyrunner/test/resources/com/android/monkeyrunner/image1.png
+++ /dev/null
Binary files differ
diff --git a/monkeyrunner/test/resources/com/android/monkeyrunner/image1.raw b/monkeyrunner/test/resources/com/android/monkeyrunner/image1.raw
deleted file mode 100644
index 99ec013..0000000
--- a/monkeyrunner/test/resources/com/android/monkeyrunner/image1.raw
+++ /dev/null
Binary files differ
diff --git a/monkeyrunner/test/resources/com/android/monkeyrunner/image2.png b/monkeyrunner/test/resources/com/android/monkeyrunner/image2.png
deleted file mode 100644
index 03ff0c1..0000000
--- a/monkeyrunner/test/resources/com/android/monkeyrunner/image2.png
+++ /dev/null
Binary files differ
diff --git a/monkeyrunner/test/resources/com/android/monkeyrunner/image2.raw b/monkeyrunner/test/resources/com/android/monkeyrunner/image2.raw
deleted file mode 100644
index 06e5b47..0000000
--- a/monkeyrunner/test/resources/com/android/monkeyrunner/image2.raw
+++ /dev/null
Binary files differ
diff --git a/ninepatch/.classpath b/ninepatch/.classpath
deleted file mode 100644
index fb50116..0000000
--- a/ninepatch/.classpath
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/ninepatch/.gitignore b/ninepatch/.gitignore
deleted file mode 100644
index ba077a4..0000000
--- a/ninepatch/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/ninepatch/.project b/ninepatch/.project
deleted file mode 100644
index 192f000..0000000
--- a/ninepatch/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>ninepatch</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/ninepatch/Android.mk b/ninepatch/Android.mk
deleted file mode 100644
index 5f6cbed..0000000
--- a/ninepatch/Android.mk
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under,src)
-
-LOCAL_MODULE := ninepatch
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-# Build all sub-directories
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/ninepatch/NOTICE b/ninepatch/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/ninepatch/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/ninepatch/src/com/android/ninepatch/GraphicsUtilities.java b/ninepatch/src/com/android/ninepatch/GraphicsUtilities.java
deleted file mode 100644
index e8d71d6..0000000
--- a/ninepatch/src/com/android/ninepatch/GraphicsUtilities.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ninepatch;
-
-import javax.imageio.ImageIO;
-import java.awt.image.BufferedImage;
-import java.awt.image.Raster;
-import java.awt.GraphicsConfiguration;
-import java.awt.GraphicsEnvironment;
-import java.awt.Graphics;
-import java.awt.Transparency;
-import java.net.URL;
-import java.io.IOException;
-import java.io.InputStream;
-
-public class GraphicsUtilities {
- public static BufferedImage loadCompatibleImage(URL resource) throws IOException {
- BufferedImage image = ImageIO.read(resource);
- return toCompatibleImage(image);
- }
-
- public static BufferedImage loadCompatibleImage(InputStream stream) throws IOException {
- BufferedImage image = ImageIO.read(stream);
- return toCompatibleImage(image);
- }
-
- public static BufferedImage createCompatibleImage(int width, int height) {
- return getGraphicsConfiguration().createCompatibleImage(width, height);
- }
-
- public static BufferedImage toCompatibleImage(BufferedImage image) {
- if (isHeadless()) {
- return image;
- }
-
- if (image.getColorModel().equals(getGraphicsConfiguration().getColorModel())) {
- return image;
- }
-
- BufferedImage compatibleImage = getGraphicsConfiguration().createCompatibleImage(
- image.getWidth(), image.getHeight(), image.getTransparency());
- Graphics g = compatibleImage.getGraphics();
- g.drawImage(image, 0, 0, null);
- g.dispose();
-
- return compatibleImage;
- }
-
- public static BufferedImage createCompatibleImage(BufferedImage image, int width, int height) {
- return getGraphicsConfiguration().createCompatibleImage(width, height,
- image.getTransparency());
- }
-
- private static GraphicsConfiguration getGraphicsConfiguration() {
- GraphicsEnvironment environment = GraphicsEnvironment.getLocalGraphicsEnvironment();
- return environment.getDefaultScreenDevice().getDefaultConfiguration();
- }
-
- private static boolean isHeadless() {
- return GraphicsEnvironment.isHeadless();
- }
-
- public static BufferedImage createTranslucentCompatibleImage(int width, int height) {
- return getGraphicsConfiguration().createCompatibleImage(width, height,
- Transparency.TRANSLUCENT);
- }
-
- public static int[] getPixels(BufferedImage img, int x, int y, int w, int h, int[] pixels) {
- if (w == 0 || h == 0) {
- return new int[0];
- }
-
- if (pixels == null) {
- pixels = new int[w * h];
- } else if (pixels.length < w * h) {
- throw new IllegalArgumentException("Pixels array must have a length >= w * h");
- }
-
- int imageType = img.getType();
- if (imageType == BufferedImage.TYPE_INT_ARGB || imageType == BufferedImage.TYPE_INT_RGB) {
- Raster raster = img.getRaster();
- return (int[]) raster.getDataElements(x, y, w, h, pixels);
- }
-
- // Unmanages the image
- return img.getRGB(x, y, w, h, pixels, 0, w);
- }
-}
diff --git a/ninepatch/src/com/android/ninepatch/NinePatch.java b/ninepatch/src/com/android/ninepatch/NinePatch.java
deleted file mode 100644
index 2803a9e..0000000
--- a/ninepatch/src/com/android/ninepatch/NinePatch.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ninepatch;
-
-import java.awt.Graphics2D;
-import java.awt.image.BufferedImage;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-/**
- * Represents a 9-Patch bitmap.
- *
- * DO NOT CHANGE THIS API OR OLDER VERSIONS OF LAYOUTLIB WILL CRASH.
- *
- * This is a full representation of a NinePatch with both a {@link BufferedImage} and a
- * {@link NinePatchChunk}.
- *
- * Newer versions of the Layoutlib will use only the {@link NinePatchChunk} as the default
- * nine patch drawable references a normal Android bitmap which contains a BufferedImage
- * through a Bitmap_Delegate.
- *
- */
-public class NinePatch {
- public static final String EXTENSION_9PATCH = ".9.png";
-
- private BufferedImage mImage;
- private NinePatchChunk mChunk;
-
- public BufferedImage getImage() {
- return mImage;
- }
-
- public NinePatchChunk getChunk() {
- return mChunk;
- }
-
- /**
- * LEGACY METHOD to run older versions of Android Layoutlib.
- * ==== DO NOT CHANGE ====
- *
- * Loads a 9 patch or regular bitmap.
- * @param fileUrl the URL of the file to load.
- * @param convert if <code>true</code>, non 9-patch bitmap will be converted into a 9 patch.
- * If <code>false</code> and the bitmap is not a 9 patch, the method will return
- * <code>null</code>.
- * @return a {@link NinePatch} or <code>null</code>.
- * @throws IOException
- */
- public static NinePatch load(URL fileUrl, boolean convert) throws IOException {
- BufferedImage image = null;
- try {
- image = GraphicsUtilities.loadCompatibleImage(fileUrl);
- } catch (MalformedURLException e) {
- // really this shouldn't be happening since we're not creating the URL manually.
- return null;
- }
-
- boolean is9Patch = fileUrl.getPath().toLowerCase().endsWith(EXTENSION_9PATCH);
-
- return load(image, is9Patch, convert);
- }
-
- /**
- * LEGACY METHOD to run older versions of Android Layoutlib.
- * ==== DO NOT CHANGE ====
- *
- * Loads a 9 patch or regular bitmap.
- * @param stream the {@link InputStream} of the file to load.
- * @param is9Patch whether the file represents a 9-patch
- * @param convert if <code>true</code>, non 9-patch bitmap will be converted into a 9 patch.
- * If <code>false</code> and the bitmap is not a 9 patch, the method will return
- * <code>null</code>.
- * @return a {@link NinePatch} or <code>null</code>.
- * @throws IOException
- */
- public static NinePatch load(InputStream stream, boolean is9Patch, boolean convert)
- throws IOException {
- BufferedImage image = null;
- try {
- image = GraphicsUtilities.loadCompatibleImage(stream);
- } catch (MalformedURLException e) {
- // really this shouldn't be happening since we're not creating the URL manually.
- return null;
- }
-
- return load(image, is9Patch, convert);
- }
-
- /**
- * LEGACY METHOD to run older versions of Android Layoutlib.
- * ==== DO NOT CHANGE ====
- *
- * Loads a 9 patch or regular bitmap.
- * @param image the source {@link BufferedImage}.
- * @param is9Patch whether the file represents a 9-patch
- * @param convert if <code>true</code>, non 9-patch bitmap will be converted into a 9 patch.
- * If <code>false</code> and the bitmap is not a 9 patch, the method will return
- * <code>null</code>.
- * @return a {@link NinePatch} or <code>null</code>.
- * @throws IOException
- */
- public static NinePatch load(BufferedImage image, boolean is9Patch, boolean convert) {
- if (is9Patch == false) {
- if (convert) {
- image = convertTo9Patch(image);
- } else {
- return null;
- }
- } else {
- ensure9Patch(image);
- }
-
- return new NinePatch(image);
- }
-
- /**
- * LEGACY METHOD to run older versions of Android Layoutlib.
- * ==== DO NOT CHANGE ====
- *
- * @return
- */
- public int getWidth() {
- return mImage.getWidth();
- }
-
- /**
- * LEGACY METHOD to run older versions of Android Layoutlib.
- * ==== DO NOT CHANGE ====
- *
- * @return
- */
- public int getHeight() {
- return mImage.getHeight();
- }
-
- /**
- * LEGACY METHOD to run older versions of Android Layoutlib.
- * ==== DO NOT CHANGE ====
- *
- * @param padding array of left, top, right, bottom padding
- * @return
- */
- public boolean getPadding(int[] padding) {
- mChunk.getPadding(padding);
- return true;
- }
-
-
- /**
- * LEGACY METHOD to run older versions of Android Layoutlib.
- * ==== DO NOT CHANGE ====
- *
- * @param graphics2D
- * @param x
- * @param y
- * @param scaledWidth
- * @param scaledHeight
- */
- public void draw(Graphics2D graphics2D, int x, int y, int scaledWidth, int scaledHeight) {
- mChunk.draw(mImage, graphics2D, x, y, scaledWidth, scaledHeight, 0 , 0);
- }
-
- private NinePatch(BufferedImage image) {
- mChunk = NinePatchChunk.create(image);
- mImage = extractBitmapContent(image);
- }
-
- private static void ensure9Patch(BufferedImage image) {
- int width = image.getWidth();
- int height = image.getHeight();
- for (int i = 0; i < width; i++) {
- int pixel = image.getRGB(i, 0);
- if (pixel != 0 && pixel != 0xFF000000) {
- image.setRGB(i, 0, 0);
- }
- pixel = image.getRGB(i, height - 1);
- if (pixel != 0 && pixel != 0xFF000000) {
- image.setRGB(i, height - 1, 0);
- }
- }
- for (int i = 0; i < height; i++) {
- int pixel = image.getRGB(0, i);
- if (pixel != 0 && pixel != 0xFF000000) {
- image.setRGB(0, i, 0);
- }
- pixel = image.getRGB(width - 1, i);
- if (pixel != 0 && pixel != 0xFF000000) {
- image.setRGB(width - 1, i, 0);
- }
- }
- }
-
- private static BufferedImage convertTo9Patch(BufferedImage image) {
- BufferedImage buffer = GraphicsUtilities.createTranslucentCompatibleImage(
- image.getWidth() + 2, image.getHeight() + 2);
-
- Graphics2D g2 = buffer.createGraphics();
- g2.drawImage(image, 1, 1, null);
- g2.dispose();
-
- return buffer;
- }
-
- private BufferedImage extractBitmapContent(BufferedImage image) {
- return image.getSubimage(1, 1, image.getWidth() - 2, image.getHeight() - 2);
- }
-
-}
diff --git a/ninepatch/src/com/android/ninepatch/NinePatchChunk.java b/ninepatch/src/com/android/ninepatch/NinePatchChunk.java
deleted file mode 100644
index 20abaeb..0000000
--- a/ninepatch/src/com/android/ninepatch/NinePatchChunk.java
+++ /dev/null
@@ -1,494 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ninepatch;
-
-import java.awt.Graphics2D;
-import java.awt.Rectangle;
-import java.awt.RenderingHints;
-import java.awt.image.BufferedImage;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * The chunk information for a nine patch.
- *
- * This does not represent the bitmap, only the chunk info responsible for the padding and the
- * stretching areas.
- *
- * Since android.graphics.drawable.NinePatchDrawable and android.graphics.NinePatch both deal with
- * the nine patch chunk as a byte[], this class is converted to and from byte[] through
- * serialization.
- *
- * This is meant to be used with the NinePatch_Delegate in Layoutlib API 5+.
- */
-public class NinePatchChunk implements Serializable {
-
- /** Generated Serial Version UID */
- private static final long serialVersionUID = -7353439224505296217L;
-
- private static final int[] sPaddingRect = new int[4];
-
- private boolean mVerticalStartWithPatch;
- private boolean mHorizontalStartWithPatch;
-
- private List<Rectangle> mFixed;
- private List<Rectangle> mPatches;
- private List<Rectangle> mHorizontalPatches;
- private List<Rectangle> mVerticalPatches;
-
- private Pair<Integer> mHorizontalPadding;
- private Pair<Integer> mVerticalPadding;
-
-
- /**
- * Data computed during drawing.
- */
- static final class DrawingData {
- private int mRemainderHorizontal;
- private int mRemainderVertical;
- private float mHorizontalPatchesSum;
- private float mVerticalPatchesSum;
- }
-
- /**
- * Computes and returns the 9-patch chunks.
- * @param image the image containing both the content and the control outer line.
- * @return the {@link NinePatchChunk}.
- */
- public static NinePatchChunk create(BufferedImage image) {
- NinePatchChunk chunk = new NinePatchChunk();
- chunk.findPatches(image);
- return chunk;
- }
-
- public void draw(BufferedImage image, Graphics2D graphics2D, int x, int y, int scaledWidth,
- int scaledHeight, int destDensity, int srcDensity) {
-
- boolean scaling = destDensity != srcDensity && destDensity != 0 && srcDensity != 0;
-
- if (scaling) {
- try {
- graphics2D = (Graphics2D) graphics2D.create();
-
- // scale and transform
- float densityScale = ((float) destDensity) / (float) srcDensity;
-
- // translate/rotate the canvas.
- graphics2D.translate(x, y);
- graphics2D.scale(densityScale, densityScale);
-
- // sets the new drawing bounds.
- scaledWidth /= densityScale;
- scaledHeight /= densityScale;
- x = y = 0;
-
- // draw
- draw(image, graphics2D, x, y, scaledWidth, scaledHeight);
- } finally {
- graphics2D.dispose();
- }
- } else {
- // non density-scaled rendering
- draw(image, graphics2D, x, y, scaledWidth, scaledHeight);
- }
- }
-
- private void draw(BufferedImage image, Graphics2D graphics2D, int x, int y, int scaledWidth,
- int scaledHeight) {
- if (scaledWidth <= 1 || scaledHeight <= 1) {
- return;
- }
-
- Graphics2D g = (Graphics2D)graphics2D.create();
- g.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
- RenderingHints.VALUE_INTERPOLATION_BILINEAR);
-
- try {
- if (mPatches.size() == 0) {
- g.drawImage(image, x, y, scaledWidth, scaledHeight, null);
- return;
- }
-
- g.translate(x, y);
- x = y = 0;
-
- DrawingData data = computePatches(scaledWidth, scaledHeight);
-
- int fixedIndex = 0;
- int horizontalIndex = 0;
- int verticalIndex = 0;
- int patchIndex = 0;
-
- boolean hStretch;
- boolean vStretch;
-
- float vWeightSum = 1.0f;
- float vRemainder = data.mRemainderVertical;
-
- vStretch = mVerticalStartWithPatch;
- while (y < scaledHeight - 1) {
- hStretch = mHorizontalStartWithPatch;
-
- int height = 0;
- float vExtra = 0.0f;
-
- float hWeightSum = 1.0f;
- float hRemainder = data.mRemainderHorizontal;
-
- while (x < scaledWidth - 1) {
- Rectangle r;
- if (!vStretch) {
- if (hStretch) {
- r = mHorizontalPatches.get(horizontalIndex++);
- float extra = r.width / data.mHorizontalPatchesSum;
- int width = (int) (extra * hRemainder / hWeightSum);
- hWeightSum -= extra;
- hRemainder -= width;
- g.drawImage(image, x, y, x + width, y + r.height, r.x, r.y,
- r.x + r.width, r.y + r.height, null);
- x += width;
- } else {
- r = mFixed.get(fixedIndex++);
- g.drawImage(image, x, y, x + r.width, y + r.height, r.x, r.y,
- r.x + r.width, r.y + r.height, null);
- x += r.width;
- }
- height = r.height;
- } else {
- if (hStretch) {
- r = mPatches.get(patchIndex++);
- vExtra = r.height / data.mVerticalPatchesSum;
- height = (int) (vExtra * vRemainder / vWeightSum);
- float extra = r.width / data.mHorizontalPatchesSum;
- int width = (int) (extra * hRemainder / hWeightSum);
- hWeightSum -= extra;
- hRemainder -= width;
- g.drawImage(image, x, y, x + width, y + height, r.x, r.y,
- r.x + r.width, r.y + r.height, null);
- x += width;
- } else {
- r = mVerticalPatches.get(verticalIndex++);
- vExtra = r.height / data.mVerticalPatchesSum;
- height = (int) (vExtra * vRemainder / vWeightSum);
- g.drawImage(image, x, y, x + r.width, y + height, r.x, r.y,
- r.x + r.width, r.y + r.height, null);
- x += r.width;
- }
-
- }
- hStretch = !hStretch;
- }
- x = 0;
- y += height;
- if (vStretch) {
- vWeightSum -= vExtra;
- vRemainder -= height;
- }
- vStretch = !vStretch;
- }
-
- } finally {
- g.dispose();
- }
- }
-
- /**
- * Fills the given array with the nine patch padding.
- *
- * @param padding array of left, top, right, bottom padding
- */
- public void getPadding(int[] padding) {
- padding[0] = mHorizontalPadding.mFirst; // left
- padding[2] = mHorizontalPadding.mSecond; // right
- padding[1] = mVerticalPadding.mFirst; // top
- padding[3] = mVerticalPadding.mSecond; // bottom
- }
-
- /**
- * Returns the padding as an int[] describing left, top, right, bottom.
- *
- * This method is not thread-safe and returns an array owned by the {@link NinePatchChunk}
- * class.
- * @return an internal array filled with the padding.
- */
- public int[] getPadding() {
- getPadding(sPaddingRect);
- return sPaddingRect;
- }
-
- private DrawingData computePatches(int scaledWidth, int scaledHeight) {
- DrawingData data = new DrawingData();
- boolean measuredWidth = false;
- boolean endRow = true;
-
- int remainderHorizontal = 0;
- int remainderVertical = 0;
-
- if (mFixed.size() > 0) {
- int start = mFixed.get(0).y;
- for (Rectangle rect : mFixed) {
- if (rect.y > start) {
- endRow = true;
- measuredWidth = true;
- }
- if (!measuredWidth) {
- remainderHorizontal += rect.width;
- }
- if (endRow) {
- remainderVertical += rect.height;
- endRow = false;
- start = rect.y;
- }
- }
- }
-
- data.mRemainderHorizontal = scaledWidth - remainderHorizontal;
- data.mRemainderVertical = scaledHeight - remainderVertical;
-
- data.mHorizontalPatchesSum = 0;
- if (mHorizontalPatches.size() > 0) {
- int start = -1;
- for (Rectangle rect : mHorizontalPatches) {
- if (rect.x > start) {
- data.mHorizontalPatchesSum += rect.width;
- start = rect.x;
- }
- }
- } else {
- int start = -1;
- for (Rectangle rect : mPatches) {
- if (rect.x > start) {
- data.mHorizontalPatchesSum += rect.width;
- start = rect.x;
- }
- }
- }
-
- data.mVerticalPatchesSum = 0;
- if (mVerticalPatches.size() > 0) {
- int start = -1;
- for (Rectangle rect : mVerticalPatches) {
- if (rect.y > start) {
- data.mVerticalPatchesSum += rect.height;
- start = rect.y;
- }
- }
- } else {
- int start = -1;
- for (Rectangle rect : mPatches) {
- if (rect.y > start) {
- data.mVerticalPatchesSum += rect.height;
- start = rect.y;
- }
- }
- }
-
- return data;
- }
-
-
- /**
- * Finds the 9-patch patches and padding from a {@link BufferedImage} image that contains
- * both the image content and the control outer lines.
- */
- private void findPatches(BufferedImage image) {
- // the size of the actual image content
- int width = image.getWidth() - 2;
- int height = image.getHeight() - 2;
-
- int[] row = null;
- int[] column = null;
-
- // extract the patch line. Make sure to start at 1 and be only as long as the image content,
- // to not include the outer control line.
- row = GraphicsUtilities.getPixels(image, 1, 0, width, 1, row);
- column = GraphicsUtilities.getPixels(image, 0, 1, 1, height, column);
-
- boolean[] result = new boolean[1];
- Pair<List<Pair<Integer>>> left = getPatches(column, result);
- mVerticalStartWithPatch = result[0];
-
- result = new boolean[1];
- Pair<List<Pair<Integer>>> top = getPatches(row, result);
- mHorizontalStartWithPatch = result[0];
-
- mFixed = getRectangles(left.mFirst, top.mFirst);
- mPatches = getRectangles(left.mSecond, top.mSecond);
-
- if (mFixed.size() > 0) {
- mHorizontalPatches = getRectangles(left.mFirst, top.mSecond);
- mVerticalPatches = getRectangles(left.mSecond, top.mFirst);
- } else {
- if (top.mFirst.size() > 0) {
- mHorizontalPatches = new ArrayList<Rectangle>(0);
- mVerticalPatches = getVerticalRectangles(height, top.mFirst);
- } else if (left.mFirst.size() > 0) {
- mHorizontalPatches = getHorizontalRectangles(width, left.mFirst);
- mVerticalPatches = new ArrayList<Rectangle>(0);
- } else {
- mHorizontalPatches = mVerticalPatches = new ArrayList<Rectangle>(0);
- }
- }
-
- // extract the padding line. Make sure to start at 1 and be only as long as the image
- // content, to not include the outer control line.
- row = GraphicsUtilities.getPixels(image, 1, height + 1, width, 1, row);
- column = GraphicsUtilities.getPixels(image, width + 1, 1, 1, height, column);
-
- top = getPatches(row, result);
- mHorizontalPadding = getPadding(top.mFirst);
-
- left = getPatches(column, result);
- mVerticalPadding = getPadding(left.mFirst);
- }
-
- private List<Rectangle> getVerticalRectangles(int imageHeight,
- List<Pair<Integer>> topPairs) {
- List<Rectangle> rectangles = new ArrayList<Rectangle>();
- for (Pair<Integer> top : topPairs) {
- int x = top.mFirst;
- int width = top.mSecond - top.mFirst;
-
- rectangles.add(new Rectangle(x, 0, width, imageHeight));
- }
- return rectangles;
- }
-
- private List<Rectangle> getHorizontalRectangles(int imageWidth,
- List<Pair<Integer>> leftPairs) {
- List<Rectangle> rectangles = new ArrayList<Rectangle>();
- for (Pair<Integer> left : leftPairs) {
- int y = left.mFirst;
- int height = left.mSecond - left.mFirst;
-
- rectangles.add(new Rectangle(0, y, imageWidth, height));
- }
- return rectangles;
- }
-
- private Pair<Integer> getPadding(List<Pair<Integer>> pairs) {
- if (pairs.size() == 0) {
- return new Pair<Integer>(0, 0);
- } else if (pairs.size() == 1) {
- if (pairs.get(0).mFirst == 0) {
- return new Pair<Integer>(pairs.get(0).mSecond - pairs.get(0).mFirst, 0);
- } else {
- return new Pair<Integer>(0, pairs.get(0).mSecond - pairs.get(0).mFirst);
- }
- } else {
- int index = pairs.size() - 1;
- return new Pair<Integer>(pairs.get(0).mSecond - pairs.get(0).mFirst,
- pairs.get(index).mSecond - pairs.get(index).mFirst);
- }
- }
-
- private List<Rectangle> getRectangles(List<Pair<Integer>> leftPairs,
- List<Pair<Integer>> topPairs) {
- List<Rectangle> rectangles = new ArrayList<Rectangle>();
- for (Pair<Integer> left : leftPairs) {
- int y = left.mFirst;
- int height = left.mSecond - left.mFirst;
- for (Pair<Integer> top : topPairs) {
- int x = top.mFirst;
- int width = top.mSecond - top.mFirst;
-
- rectangles.add(new Rectangle(x, y, width, height));
- }
- }
- return rectangles;
- }
-
- /**
- * Computes a list of Patch based on a pixel line.
- *
- * This returns both the fixed areas, and the patches (stretchable) areas.
- *
- * The return value is a pair of list. The first list ({@link Pair#mFirst}) is the list
- * of fixed area. The second list ({@link Pair#mSecond}) is the list of stretchable areas.
- *
- * Each area is defined as a Pair of (start, end) coordinate in the given line.
- *
- * @param pixels the pixels of the control line. The line should have the same length as the
- * content (i.e. it should be stripped of the first/last control pixel which are not
- * used)
- * @param startWithPatch a boolean array of size 1 used to return the boolean value of whether
- * a patch (stretchable area) is first or not.
- * @return
- */
- private Pair<List<Pair<Integer>>> getPatches(int[] pixels, boolean[] startWithPatch) {
- int lastIndex = 0;
- int lastPixel = pixels[0];
- boolean first = true;
-
- List<Pair<Integer>> fixed = new ArrayList<Pair<Integer>>();
- List<Pair<Integer>> patches = new ArrayList<Pair<Integer>>();
-
- for (int i = 0; i < pixels.length; i++) {
- int pixel = pixels[i];
- if (pixel != lastPixel) {
- if (lastPixel == 0xFF000000) {
- if (first) startWithPatch[0] = true;
- patches.add(new Pair<Integer>(lastIndex, i));
- } else {
- fixed.add(new Pair<Integer>(lastIndex, i));
- }
- first = false;
-
- lastIndex = i;
- lastPixel = pixel;
- }
- }
- if (lastPixel == 0xFF000000) {
- if (first) startWithPatch[0] = true;
- patches.add(new Pair<Integer>(lastIndex, pixels.length));
- } else {
- fixed.add(new Pair<Integer>(lastIndex, pixels.length));
- }
-
- if (patches.size() == 0) {
- patches.add(new Pair<Integer>(1, pixels.length));
- startWithPatch[0] = true;
- fixed.clear();
- }
-
- return new Pair<List<Pair<Integer>>>(fixed, patches);
- }
-
- /**
- * A pair of values.
- *
- * @param <E>
- */
- /*package*/ static class Pair<E> implements Serializable {
- /** Generated Serial Version UID */
- private static final long serialVersionUID = -2204108979541762418L;
- E mFirst;
- E mSecond;
-
- Pair(E first, E second) {
- mFirst = first;
- mSecond = second;
- }
-
- @Override
- public String toString() {
- return "Pair[" + mFirst + ", " + mSecond + "]";
- }
- }
-
-}
diff --git a/ninepatch/tests/.classpath b/ninepatch/tests/.classpath
deleted file mode 100644
index 26542d3..0000000
--- a/ninepatch/tests/.classpath
+++ /dev/null
@@ -1,8 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ninepatch"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/ninepatch/tests/.project b/ninepatch/tests/.project
deleted file mode 100644
index 3d049cf..0000000
--- a/ninepatch/tests/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>ninepatch-tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/ninepatch/tests/Android.mk b/ninepatch/tests/Android.mk
deleted file mode 100644
index 8a9fd71..0000000
--- a/ninepatch/tests/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright (C) 2010 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-
-include $(CLEAR_VARS)
-
-# Only compile source java files in this lib.
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_RESOURCE_DIRS := res
-
-LOCAL_MODULE := ninepatch-tests
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_JAVA_LIBRARIES := junit
-# bundle ninepatch inside the test jar for continuous tests
-LOCAL_STATIC_JAVA_LIBRARIES := ninepatch
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-# Build all sub-directories
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/ninepatch/tests/res/com/android/ninepatch/button.9.png b/ninepatch/tests/res/com/android/ninepatch/button.9.png
deleted file mode 100644
index 9d52f40..0000000
--- a/ninepatch/tests/res/com/android/ninepatch/button.9.png
+++ /dev/null
Binary files differ
diff --git a/ninepatch/tests/src/com/android/ninepatch/NinePatchTest.java b/ninepatch/tests/src/com/android/ninepatch/NinePatchTest.java
deleted file mode 100644
index 1722b55..0000000
--- a/ninepatch/tests/src/com/android/ninepatch/NinePatchTest.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ninepatch;
-
-import java.io.InputStream;
-
-import junit.framework.TestCase;
-
-public class NinePatchTest extends TestCase {
-
- private NinePatch mPatch;
-
- @Override
- protected void setUp() throws Exception {
- InputStream stream = this.getClass().getResourceAsStream("button.9.png");
-
- mPatch = NinePatch.load(stream, true /* is9Patch*/, false /* convert */);
- }
-
- public void test9PatchLoad() throws Exception {
- assertNotNull(mPatch);
- }
-
- public void test9PatchMinSize() {
- int[] padding = new int[4];
- mPatch.getPadding(padding);
- assertEquals(13, padding[0]);
- assertEquals(3, padding[1]);
- assertEquals(13, padding[2]);
- assertEquals(4, padding[3]);
- assertEquals(36, mPatch.getWidth());
- assertEquals(25, mPatch.getHeight());
- }
-}
diff --git a/rule_api/.classpath b/rule_api/.classpath
deleted file mode 100644
index f57bbca..0000000
--- a/rule_api/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/guava-tools.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src.zip"/>
- <classpathentry combineaccessrules="false" kind="src" path="/layoutlib_api"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/rule_api/.gitignore b/rule_api/.gitignore
deleted file mode 100644
index ba077a4..0000000
--- a/rule_api/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/rule_api/.project b/rule_api/.project
deleted file mode 100644
index 2e2a12e..0000000
--- a/rule_api/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>rule_api</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/rule_api/.settings/org.eclipse.jdt.core.prefs b/rule_api/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/rule_api/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/rule_api/Android.mk b/rule_api/Android.mk
deleted file mode 100644
index de6faf6..0000000
--- a/rule_api/Android.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under,src)
-LOCAL_JAVA_RESOURCE_DIRS := src
-
-LOCAL_JAVA_LIBRARIES := \
- common \
- layoutlib_api \
- guava-tools
-
-LOCAL_MODULE := rule_api
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/rule_api/NOTICE b/rule_api/NOTICE
deleted file mode 100644
index becc120..0000000
--- a/rule_api/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2011, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/rule_api/README.txt b/rule_api/README.txt
deleted file mode 100644
index b094e60..0000000
--- a/rule_api/README.txt
+++ /dev/null
@@ -1,10 +0,0 @@
-The Rule API is a library intended for view authors to add designtime
-support for their custom views in Android layout editors.
-
-NOTE: The API is *not* final and will very likely continue to change
-incompatibly until we finish it and incorporate feedback.
-
-The rule API attempts to be IDE agnostic, so it should not have
-specific dependencies on any tools. IDE vendors building layout
-editors should provide IDE-side implementations of the rule interfaces
-such that they can interact with view rules.
diff --git a/rule_api/src/com/android/ide/common/api/AbstractViewRule.java b/rule_api/src/com/android/ide/common/api/AbstractViewRule.java
deleted file mode 100644
index e23a567..0000000
--- a/rule_api/src/com/android/ide/common/api/AbstractViewRule.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.google.common.annotations.Beta;
-
-import java.util.List;
-
-/**
- * Default implementation of an {@link IViewRule}. This is a convenience
- * implementation which makes it easier to supply designtime behavior for a
- * custom view and just override the methods you are interested in.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- */
-@Beta
-public class AbstractViewRule implements IViewRule {
- @Override
- public boolean onInitialize(@NonNull String fqcn, @NonNull IClientRulesEngine engine) {
- return true;
- }
-
- @Override
- public void onDispose() {
- }
-
- @Override
- @Nullable
- public String getDisplayName() {
- // Default is to not override the selection display name.
- return null;
- }
-
- @Override
- @Nullable
- public List<String> getSelectionHint(@NonNull INode parentNode, @NonNull INode childNode) {
- return null;
- }
-
- @Override
- public void addLayoutActions(@NonNull List<RuleAction> actions, @NonNull INode parentNode,
- @NonNull List<? extends INode> children) {
- }
-
- @Override
- public void addContextMenuActions(@NonNull List<RuleAction> actions, @NonNull INode node) {
- }
-
- @Override
- @Nullable
- public String getDefaultActionId(@NonNull INode node) {
- return null;
- }
-
- @Override
- public void paintSelectionFeedback(@NonNull IGraphics graphics, @NonNull INode parentNode,
- @NonNull List<? extends INode> childNodes, @Nullable Object view) {
- }
-
- @Override
- @Nullable
- public DropFeedback onDropEnter(@NonNull INode targetNode, @Nullable Object targetView,
- @Nullable IDragElement[] elements) {
- return null;
- }
-
- @Override
- @Nullable
- public DropFeedback onDropMove(@NonNull INode targetNode, @NonNull IDragElement[] elements,
- @Nullable DropFeedback feedback, @NonNull Point p) {
- return null;
- }
-
- @Override
- public void onDropLeave(@NonNull INode targetNode, @NonNull IDragElement[] elements,
- @Nullable DropFeedback feedback) {
- // ignore
- }
-
- @Override
- public void onDropped(
- @NonNull INode targetNode,
- @NonNull IDragElement[] elements,
- @Nullable DropFeedback feedback,
- @NonNull Point p) {
- // ignore
- }
-
-
- @Override
- public void onPaste(@NonNull INode targetNode, @Nullable Object targetView,
- @NonNull IDragElement[] pastedElements) {
- }
-
- @Override
- public void onCreate(@NonNull INode node, @NonNull INode parent,
- @NonNull InsertType insertType) {
- }
-
- @Override
- public void onChildInserted(@NonNull INode child, @NonNull INode parent,
- @NonNull InsertType insertType) {
- }
-
- @Override
- public void onRemovingChildren(@NonNull List<INode> deleted, @NonNull INode parent,
- boolean moved) {
- }
-
- @Override
- @Nullable
- public DropFeedback onResizeBegin(@NonNull INode child, @NonNull INode parent,
- @Nullable SegmentType horizontalEdge,
- @Nullable SegmentType verticalEdge, @Nullable Object childView,
- @Nullable Object parentView) {
- return null;
- }
-
- @Override
- public void onResizeUpdate(@Nullable DropFeedback feedback, @NonNull INode child,
- @NonNull INode parent, @NonNull Rect newBounds,
- int modifierMask) {
- }
-
- @Override
- public void onResizeEnd(@Nullable DropFeedback feedback, @NonNull INode child,
- @NonNull INode parent, @NonNull Rect newBounds) {
- }
-}
diff --git a/rule_api/src/com/android/ide/common/api/DrawingStyle.java b/rule_api/src/com/android/ide/common/api/DrawingStyle.java
deleted file mode 100644
index 0712a21..0000000
--- a/rule_api/src/com/android/ide/common/api/DrawingStyle.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.google.common.annotations.Beta;
-
-/**
- * Drawing styles are used to distinguish the visual appearance of selection,
- * hovers, anchors, etc. Each style may have different colors, line thickness,
- * dashing style, transparency, etc.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- * </p>
- */
-@Beta
-public enum DrawingStyle {
- /**
- * The style used to draw the selected views
- */
- SELECTION,
-
- /**
- * The style used to draw guidelines - overlay lines which indicate
- * significant geometric positions.
- */
- GUIDELINE,
-
- /**
- * The style used to guideline shadows
- */
- GUIDELINE_SHADOW,
-
- /**
- * The style used to draw guidelines, in particular shared edges and center lines; this
- * is a dashed edge.
- */
- GUIDELINE_DASHED,
-
- /**
- * The style used to draw distance annotations
- */
- DISTANCE,
-
- /**
- * The style used to draw grids
- */
- GRID,
-
- /**
- * The style used for hovered views (e.g. when the mouse is directly on top
- * of the view)
- */
- HOVER,
-
- /**
- * The style used for hovered views (e.g. when the mouse is directly on top
- * of the view), when the hover happens to be the same object as the selection
- */
- HOVER_SELECTION,
-
- /**
- * The style used to draw anchors (lines to the other views the given view
- * is anchored to)
- */
- ANCHOR,
-
- /**
- * The style used to draw outlines (the structure of views)
- */
- OUTLINE,
-
- /**
- * The style used to draw the recipient/target View of a drop. This is
- * typically going to be the bounding-box of the view into which you are
- * adding a new child.
- */
- DROP_RECIPIENT,
-
- /**
- * The style used to draw a potential drop area <b>within</b> a
- * {@link #DROP_RECIPIENT}. For example, if you are dragging into a view
- * with a LinearLayout, the {@link #DROP_RECIPIENT} will be the view itself,
- * whereas each possible insert position between two children will be a
- * {@link #DROP_ZONE}. If the mouse is over a {@link #DROP_ZONE} it should
- * be drawn using the style {@link #DROP_ZONE_ACTIVE}.
- */
- DROP_ZONE,
-
- /**
- * The style used to draw a currently active drop zone within a drop
- * recipient. See the documentation for {@link #DROP_ZONE} for details on
- * the distinction between {@link #DROP_RECIPIENT}, {@link #DROP_ZONE} and
- * {@link #DROP_ZONE_ACTIVE}.
- */
- DROP_ZONE_ACTIVE,
-
- /**
- * The style used to draw a preview of where a dropped view would appear if
- * it were to be dropped at a given location.
- */
- DROP_PREVIEW,
-
- /**
- * The style used to preview a resize operation. Similar to {@link #DROP_PREVIEW}
- * but usually fainter to work better in combination with guidelines which
- * are often overlaid during resize.
- */
- RESIZE_PREVIEW,
-
- /**
- * The style used to show a proposed resize bound which is being rejected (for example,
- * because there is no near edge to attach to in a RelativeLayout).
- */
- RESIZE_FAIL,
-
- /**
- * The style used to draw help/hint text.
- */
- HELP,
-
- /**
- * The style used to draw illegal/error/invalid markers
- */
- INVALID,
-
- /**
- * The style used to highlight dependencies
- */
- DEPENDENCY,
-
- /**
- * The style used to draw an invalid cycle
- */
- CYCLE,
-
- /**
- * The style used to highlight the currently dragged views during a layout
- * move (if they are not hidden)
- */
- DRAGGED,
-
- /**
- * The style used to draw empty containers of zero bounds (which are padded
- * a bit to make them visible during a drag or selection).
- */
- EMPTY,
-
- /**
- * A style used for unspecified purposes; can be used by a client to have
- * yet another color that is domain specific; using this color constant
- * rather than your own hardcoded value means that you will be guaranteed to
- * pick up a color that is themed properly and will look decent with the
- * rest of the colors
- */
- CUSTOM1,
-
- /**
- * A second styled used for unspecified purposes; see {@link #CUSTOM1} for
- * details.
- */
- CUSTOM2
-}
diff --git a/rule_api/src/com/android/ide/common/api/DropFeedback.java b/rule_api/src/com/android/ide/common/api/DropFeedback.java
deleted file mode 100644
index 3920958..0000000
--- a/rule_api/src/com/android/ide/common/api/DropFeedback.java
+++ /dev/null
@@ -1,185 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.annotations.Nullable;
-import com.google.common.annotations.Beta;
-
-/**
- * Structure returned by onDropEnter/Move and passed to over onDropXyz methods.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- * </p>
- */
-@Beta
-public class DropFeedback {
- /**
- * User data that the rule can use in any way it wants to carry state from one
- * operation to another.
- * <p/>
- * Filled and owned by the view rule.
- */
- @Nullable
- public Object userData;
-
- /**
- * If true the next screen update will invoke the paint callback.
- * <p/>
- * Filled by the view rule to request a paint, and reset by the canvas after
- * the paint occurred.
- */
- public boolean requestPaint;
-
- /**
- * Set to false by the engine when entering a new view target.
- * The view rule should set this to true if the current view target is not
- * a valid drop zone.
- * <p/>
- * When set to true, the onDropped() method will not be called if the user releases
- * the mouse button. Depending on the platform or implementation, the mouse cursor
- * <em>may</em> reflect that the drop operation is invalid.
- * <p/>
- * Rationale: an operation like onDropEnter() is called each time the mouse enters
- * a new view target and is supposed to return null when the drop cannot happen
- * <em>at all</em> in that target. However a layout like RelativeLayout decorates
- * potential targets with "hot spots" that are suitable drop zones, whereas some
- * other parts of the view are not suitable drop zones. In this case the onDropEnter()
- * or onDropMove() operation would return a {@link DropFeedback} with
- * <code>invalidTarget=true</code>.
- */
- public boolean invalidTarget;
-
- /**
- * Painter invoked by the canvas to paint the feedback.
- * Filled by the view rule, called by the engine.
- * <p/>
- */
- @Nullable
- public IFeedbackPainter painter;
-
- /**
- * When set to a non-null valid rectangle, this informs the engine that a drag'n'drop
- * feedback wants to capture the mouse as long as it stays in the given area.
- * <p/>
- * When the mouse is captured, drop events will keep going to the rule that started the
- * capture and the current INode proxy will not change.
- * <p/>
- * Filled by the view rule, read by the engine.
- */
- @Nullable
- public Rect captureArea;
-
- /**
- * Set to true by the drag'n'drop engine when the current drag operation is a copy.
- * When false the operation is a move and <em>after</em> a successful drop the source
- * elements will be deleted.
- * <p/>
- * Filled by the engine, read by view rule.
- */
- public boolean isCopy;
-
- /**
- * The bounds of the drag, relative to the starting mouse position. For example, if
- * you have a rectangular view of size 100x80, and you start dragging at position
- * (15,20) from the top left corner of this rectangle, then the drag bounds would be
- * (-15,-20, 100x80).
- * <p>
- * NOTE: The coordinate units will be in layout/view coordinates. In other words, they
- * are unaffected by the canvas zoom.
- */
- @Nullable
- public Rect dragBounds;
-
- /**
- * The baseline of the primary dragged view. -1 means that the view does not have a baseline.
- */
- public int dragBaseline = -1;
-
- /**
- * Set to true when the drag'n'drop starts and ends in the same canvas of the
- * same Eclipse instance.
- * <p/>
- * Filled by the engine, read by view rule.
- */
- public boolean sameCanvas;
-
- /**
- * Density scale for pixels. To compute the dip (device independent pixel) in the
- * view from a layout coordinate, apply this scale.
- */
- public double dipScale = 1.0;
-
- /**
- * Initializes the drop feedback with the given user data and paint
- * callback. A paint is requested if the paint callback is non-null.
- *
- * @param userData Data stored for later retrieval by the client
- * @param painter A callback invoked to paint the drop feedback
- */
- public DropFeedback(@Nullable Object userData, @Nullable IFeedbackPainter painter) {
- this.userData = userData;
- this.painter = painter;
- this.requestPaint = painter != null;
- this.captureArea = null;
- }
-
- /**
- * A message to be displayed to the user, if any. Should not contain line separators.
- */
- @Nullable
- public String message;
-
- /**
- * An error message to be displayed to the user, if any. Should not contain line
- * separators.
- */
- @Nullable
- public String errorMessage;
-
- /**
- * A message to be displayed in a tooltip to the user, which should be short, but
- * can be multiple lines (use embedded newlines)
- */
- @Nullable
- public String tooltip;
-
- /**
- * Horizontal alignment for the tooltip, or null if no preference
- */
- @Nullable
- public SegmentType tooltipX;
-
- /**
- * Vertical alignment for the tooltip, or null if no preference
- */
- @Nullable
- public SegmentType tooltipY;
-
- /**
- * A mask of the currently held keyboard modifier keys - some combination of
- * {@link #MODIFIER1}, {@link #MODIFIER2}, {@link #MODIFIER3}, or none.
- */
- public int modifierMask;
-
- /** Bitmask value for modifier key 1 (Control on Windows/Linux, Command on Mac, etc) */
- public static final int MODIFIER1 = 1;
- /** Bitmask value for modifier key 2 (Shift) */
- public static final int MODIFIER2 = 2;
- /** Bitmask value for modifier key 3 (Alt on Windows/Linux, Option on Mac, etc) */
- public static final int MODIFIER3 = 4;
-}
diff --git a/rule_api/src/com/android/ide/common/api/IAttributeInfo.java b/rule_api/src/com/android/ide/common/api/IAttributeInfo.java
deleted file mode 100644
index 997eeb4..0000000
--- a/rule_api/src/com/android/ide/common/api/IAttributeInfo.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.android.resources.ResourceType;
-import com.google.common.annotations.Beta;
-
-import java.util.EnumSet;
-
-/**
- * Information about an attribute as gathered from the attrs.xml file where
- * the attribute was declared. This must include a format (string, reference, float, etc.),
- * possible flag or enum values, whether it's deprecated and its javadoc.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- * </p>
- */
-@Beta
-public interface IAttributeInfo {
-
- /** An attribute format, e.g. string, reference, float, etc. */
- public enum Format {
- STRING,
- BOOLEAN,
- INTEGER,
- FLOAT,
- COLOR,
- DIMENSION,
- FRACTION,
- ENUM,
- FLAG,
- REFERENCE;
-
- public static final EnumSet<Format> NONE = EnumSet.noneOf(Format.class);
- public static final EnumSet<Format> FLAG_SET = EnumSet.of(FLAG);
- public static final EnumSet<Format> ENUM_SET = EnumSet.of(ENUM);
- public static final EnumSet<Format> COLOR_SET = EnumSet.of(COLOR);
- public static final EnumSet<Format> STRING_SET = EnumSet.of(STRING);
- public static final EnumSet<Format> BOOLEAN_SET = EnumSet.of(BOOLEAN);
- public static final EnumSet<Format> INTEGER_SET = EnumSet.of(INTEGER);
- public static final EnumSet<Format> FLOAT_SET = EnumSet.of(FLOAT);
- public static final EnumSet<Format> DIMENSION_SET = EnumSet.of(DIMENSION);
- public static final EnumSet<Format> REFERENCE_SET = EnumSet.of(REFERENCE);
-
- /**
- * Returns an EnumSet containing only this format (which should not be
- * modified by the client)
- *
- * @return a new enum set containing exactly this format
- */
- @NonNull
- public EnumSet<Format> asSet() {
- switch (this) {
- case BOOLEAN:
- return BOOLEAN_SET;
- case COLOR:
- return COLOR_SET;
- case DIMENSION:
- return DIMENSION_SET;
- case ENUM:
- return ENUM_SET;
- case FLAG:
- return FLAG_SET;
- case FLOAT:
- return FLOAT_SET;
- case INTEGER:
- return INTEGER_SET;
- case STRING:
- return STRING_SET;
- case REFERENCE:
- return REFERENCE_SET;
- case FRACTION:
- default:
- return EnumSet.of(this);
- }
- }
-
- /** Returns the corresponding resource type for this attribute info,
- * or null if there is no known or corresponding resource type (such as for
- * enums and flags)
- *
- * @return the corresponding resource type, or null
- */
- @Nullable
- public ResourceType getResourceType() {
- switch (this) {
- case STRING:
- return ResourceType.STRING;
- case BOOLEAN:
- return ResourceType.BOOL;
- case COLOR:
- return ResourceType.COLOR;
- case DIMENSION:
- return ResourceType.DIMEN;
- case FRACTION:
- return ResourceType.FRACTION;
- case INTEGER:
- return ResourceType.INTEGER;
-
- // No direct corresponding resource type
- case ENUM:
- case FLAG:
- case FLOAT:
- case REFERENCE:
- return null;
- }
-
- return null;
- }
- }
-
- /** Returns the XML Name of the attribute */
- @NonNull
- public String getName();
-
- /** Returns the formats of the attribute. Cannot be null.
- * Should have at least one format. */
- @NonNull
- public EnumSet<Format> getFormats();
-
- /** Returns the values for enums. null for other types. */
- @Nullable
- public String[] getEnumValues();
-
- /** Returns the values for flags. null for other types. */
- @Nullable
- public String[] getFlagValues();
-
- /** Returns a short javadoc, .i.e. the first sentence. */
- @NonNull
- public String getJavaDoc();
-
- /** Returns the documentation for deprecated attributes. Null if not deprecated. */
- @Nullable
- public String getDeprecatedDoc();
-
- /** Returns the fully qualified class name of the view defining this attribute */
- @NonNull
- public String getDefinedBy();
-}
diff --git a/rule_api/src/com/android/ide/common/api/IClientRulesEngine.java b/rule_api/src/com/android/ide/common/api/IClientRulesEngine.java
deleted file mode 100644
index d77a00d..0000000
--- a/rule_api/src/com/android/ide/common/api/IClientRulesEngine.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.google.common.annotations.Beta;
-
-import java.util.Collection;
-import java.util.Map;
-
-/**
- * A Client Rules Engine is a set of methods that {@link IViewRule}s can use to
- * access the client public API of the Rules Engine.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- * </p>
- */
-@Beta
-public interface IClientRulesEngine {
-
- /**
- * Returns the FQCN for which the rule was loaded.
- *
- * @return the fully qualified name of the rule
- */
- @NonNull
- String getFqcn();
-
- /**
- * Returns the most recently rendered View object for this node, if any.
- *
- * @param node the node to look up the view object for
- * @return the corresponding view object, or null
- */
- @Nullable
- Object getViewObject(@NonNull INode node);
-
- /**
- * Prints a debug line in the Eclipse console using the ADT formatter.
- *
- * @param msg A String format message.
- * @param params Optional parameters for the message.
- */
- void debugPrintf(@NonNull String msg, Object...params);
-
- /**
- * Loads and returns an {@link IViewRule} for the given FQCN.
- *
- * @param fqcn A non-null, non-empty FQCN for the rule to load.
- * @return The rule that best matches the given FQCN according to the
- * inheritance chain. Rules are cached and requesting the same FQCN twice
- * is fast and will return the same rule instance.
- */
- @Nullable
- IViewRule loadRule(@NonNull String fqcn);
-
- /**
- * Returns the metadata associated with the given fully qualified class name. Note that
- * this will always return an {@link IViewMetadata} instance, even when the class name
- * is unknown to the layout editor, such as for custom views. In that case, some
- * heuristics will be applied to return metadata information such as guesses for
- * what the most common attribute is, and so on.
- *
- * @param fqcn a fully qualified class name for an Android view class
- * @return the metadata associated with the given fully qualified class name.
- */
- @NonNull
- IViewMetadata getMetadata(@NonNull String fqcn);
-
- /**
- * Displays the given message string in an alert dialog with an "OK" button.
- *
- * @param message the message to be shown
- */
- void displayAlert(@NonNull String message);
-
- /**
- * Displays a simple input alert dialog with an OK and Cancel buttons.
- *
- * @param message The message to display in the alert dialog.
- * @param value The initial value to display in the input field. Can be null.
- * @param filter An optional filter to validate the input. Specify null (or
- * a validator which always returns true) if you do not want
- * input validation.
- * @return Null if canceled by the user. Otherwise the possibly-empty input string.
- */
- @Nullable
- String displayInput(@NonNull String message, @Nullable String value,
- @Nullable IValidator filter);
-
- /**
- * Renames the given node
- *
- * @param node the node to be renamed
- * @return true if renaming was handled
- */
- boolean rename(INode node);
-
- /**
- * Returns the minimum API level that the current Android project is targeting.
- *
- * @return the minimum API level to be supported, or -1 if it cannot be determined
- */
- int getMinApiLevel();
-
- /**
- * Returns a resource name validator for the current project
- *
- * @param resourceTypeName resource type, such as "id", "string", and so on
- * @param uniqueInProject if true, the resource name must be unique in the
- * project (not already be defined anywhere else)
- * @param uniqueInLayout if true, the resource name must be unique at least
- * within the current layout. This only applies to {@code @id}
- * resources since only those resources can be defined in-place
- * within a layout
- * @param exists if true, the resource name must already exist
- * @param allowed allowed names (optional). This can for example be used to
- * request a unique-in-layout validator, but to remove the
- * current value of the node being edited from consideration such
- * that it allows you to leave the value the same
- * @return an {@link IValidator} for validating a new resource name in the
- * current project
- */
- @Nullable
- IValidator getResourceValidator(@NonNull String resourceTypeName,
- boolean uniqueInProject, boolean uniqueInLayout, boolean exists,
- String... allowed);
-
- /**
- * Displays an input dialog where the user can enter an Android reference value
- *
- * @param currentValue the current reference to select
- * @return the reference selected by the user, or null
- */
- @Nullable
- String displayReferenceInput(@Nullable String currentValue);
-
- /**
- * Displays an input dialog where the user can enter an Android resource name of the
- * given resource type ("id", "string", "drawable", and so on.)
- *
- * @param currentValue the current reference to select
- * @param resourceTypeName resource type, such as "id", "string", and so on (never
- * null)
- * @return the margins selected by the user in the same order as the input arguments,
- * or null
- */
- @Nullable
- String displayResourceInput(@NonNull String resourceTypeName, @Nullable String currentValue);
-
- /**
- * Displays an input dialog tailored for editing margin properties.
- *
- * @param all The current, initial value display for "all" margins (applied to all
- * sides)
- * @param left The current, initial value to display for the "left" margin
- * @param right The current, initial value to display for the "right" margin
- * @param top The current, initial value to display for the "top" margin
- * @param bottom The current, initial value to display for the "bottom" margin
- * @return an array of length 5 containing the user entered values for the all, left,
- * right, top and bottom margins respectively, or null if canceled
- */
- @Nullable
- String[] displayMarginInput(
- @Nullable String all,
- @Nullable String left,
- @Nullable String right,
- @Nullable String top,
- @Nullable String bottom);
-
- /**
- * Displays an input dialog tailored for inputing the source of an {@code <include>}
- * layout tag. This is similar to {@link #displayResourceInput} for resource type
- * "layout", but should also attempt to filter out layout resources that cannot be
- * included from the current context (because it would result in a cyclic dependency).
- *
- * @return the layout resource to include, or null if canceled
- */
- @Nullable
- String displayIncludeSourceInput();
-
- /**
- * Displays an input dialog tailored for inputing the source of a {@code <fragment>}
- * layout tag.
- *
- * @return the fully qualified class name of the fragment activity, or null if canceled
- */
- @Nullable
- String displayFragmentSourceInput();
-
- /**
- * Displays an input dialog tailored for inputing the source of a {@code <view>}
- * layout tag.
- *
- * @return the fully qualified class name of the custom view class, or null if canceled
- */
- @Nullable
- String displayCustomViewClassInput();
-
- /**
- * Select the given nodes
- *
- * @param nodes the nodes to be selected, never null
- */
- void select(@NonNull Collection<INode> nodes);
-
- /**
- * Triggers a redraw
- */
- void redraw();
-
- /**
- * Triggers a layout refresh and redraw
- */
- void layout();
-
- /**
- * Converts a pixel to a dp (device independent pixel) for the current screen density
- *
- * @param px the pixel dimension
- * @return the corresponding dp dimension
- */
- public int pxToDp(int px);
-
- /**
- * Converts a device independent pixel to a screen pixel for the current screen density
- *
- * @param dp the device independent pixel dimension
- * @return the corresponding pixel dimension
- */
- public int dpToPx(int dp);
-
- /**
- * Converts an IDE screen pixel distance to the corresponding layout distance. This
- * can be used to draw annotations on the graphics object that should be unaffected by
- * the zoom, or handle mouse events within a certain pixel distance regardless of the
- * screen zoom.
- *
- * @param pixels the size in IDE screen pixels
- * @return the corresponding pixel distance in the layout coordinate system
- */
- public int screenToLayout(int pixels);
-
- /**
- * Measure the preferred or actual ("wrap_content") size of the given nodes.
- *
- * @param parent the parent whose children should be measured
- * @param filter a filter to change attributes in the process of measuring, for
- * example forcing the layout_width to wrap_content or the layout_weight to
- * unset
- * @return the corresponding bounds of the nodes, or null if a rendering error occurs
- */
- @Nullable
- Map<INode, Rect> measureChildren(@NonNull INode parent, @Nullable AttributeFilter filter);
-
- /**
- * The {@link AttributeFilter} allows a client of
- * {@link IClientRulesEngine#measureChildren} to modify the actual XML values of the
- * nodes being rendered, for example to force width and height values to wrap_content
- * when measuring preferred size.
- */
- public interface AttributeFilter {
- /**
- * Returns the attribute value for the given node and attribute name. This filter
- * allows a client to adjust the attribute values that a node presents to the
- * layout library.
- * <p>
- * Returns "" to unset an attribute. Returns null to return the unfiltered value.
- *
- * @param node the node for which the attribute value should be returned
- * @param namespace the attribute namespace
- * @param localName the attribute local name
- * @return an override value, or null to return the unfiltered value
- */
- @Nullable
- String getAttribute(
- @NonNull INode node,
- @Nullable String namespace,
- @NonNull String localName);
- }
-
- /**
- * Given a UI root node and a potential XML node name, returns the first available id
- * that matches the pattern "prefix%d".
- * <p/>
- * TabWidget is a special case and the method will always return "@android:id/tabs".
- *
- * @param fqcn The fully qualified class name of the view to generate a unique id for
- * @return A suitable generated id in the attribute form needed by the XML id tag
- * (e.g. "@+id/something")
- */
- @NonNull
- public String getUniqueId(@NonNull String fqcn);
-
- /**
- * Returns the namespace URI for attributes declared and used inside the
- * app. (This is not the Android namespace.)
- *
- * @return the namespace URI
- */
- @NonNull
- public String getAppNameSpace();
-}
-
diff --git a/rule_api/src/com/android/ide/common/api/IColor.java b/rule_api/src/com/android/ide/common/api/IColor.java
deleted file mode 100755
index 26122a5..0000000
--- a/rule_api/src/com/android/ide/common/api/IColor.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.google.common.annotations.Beta;
-
-/**
- * A color, to be used with {@link IGraphics} draw operations.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- * </p>
- */
-@Beta
-public interface IColor {
- // pass
-}
diff --git a/rule_api/src/com/android/ide/common/api/IDragElement.java b/rule_api/src/com/android/ide/common/api/IDragElement.java
deleted file mode 100644
index 50a5014..0000000
--- a/rule_api/src/com/android/ide/common/api/IDragElement.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.google.common.annotations.Beta;
-
-/**
- * Represents an XML element with a name, attributes and inner elements.
- * <p/>
- * The semantic of the element name is to be a fully qualified class name of a View to inflate.
- * The element name is not expected to have a namespace.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- * </p>
- */
-@Beta
-public interface IDragElement {
-
- /**
- * Returns the element name, which must match a fully qualified class name of
- * a View to inflate.
- */
- @NonNull
- public abstract String getFqcn();
-
- /**
- * Returns the bounds of the element's node, if it originated from an existing
- * canvas. The rectangle is invalid and non-null when the element originated
- * from the object palette.
- *
- * The bounds are absolute for the canvas.
- */
- @NonNull
- public abstract Rect getBounds();
-
- /**
- * Returns the fully qualified class name of the parent, if the element originated
- * from an existing canvas. Returns null if the element has no parent, such as a top
- * level element or an element originating from the object palette.
- */
- @Nullable
- public abstract String getParentFqcn();
-
- /**
- * Returns the bounds of the element's parent, absolute for the canvas, or invalid if there
- * is no suitable parent. This is generally invalid when {@link #getParentFqcn()} is null.
- *
- * The returned rectangle can be invalid. It is never null.
- */
- @NonNull
- public abstract Rect getParentBounds();
-
- /**
- * Returns a list of attributes. The list can be empty but is never null.
- */
- @NonNull
- public abstract IDragAttribute[] getAttributes();
-
- /**
- * Returns the requested attribute or null if not found.
- */
- @Nullable
- public abstract IDragAttribute getAttribute(@Nullable String uri, @NonNull String localName);
-
- /**
- * Returns a list of inner elements. The list can be empty but is never null.
- */
- @NonNull
- public abstract IDragElement[] getInnerElements();
-
- /**
- * Returns true if the given {@link INode} represents this drag element
- *
- * @param node the node to be checked
- * @return true if the given node represents this drag element
- */
- public abstract boolean isSame(@NonNull INode node);
-
- /**
- * An XML attribute in the {@link IDragElement}.
- * <p/>
- * The attribute is always represented by a namespace URI, a name and a value.
- * The name cannot be empty.
- * The namespace URI can be empty for an attribute without a namespace but is never null.
- * The value can be empty but cannot be null.
- */
- public interface IDragAttribute {
-
- /**
- * Returns the namespace URI of the attribute.
- * Can be empty for an attribute without a namespace but is never null.
- */
- @NonNull
- public abstract String getUri();
-
- /** Returns the XML local name of the attribute. Cannot be null nor empty. */
- @NonNull
- public abstract String getName();
-
- /** Returns the value of the attribute. Cannot be null. Can be empty. */
- @NonNull
- public abstract String getValue();
- }
-}
-
diff --git a/rule_api/src/com/android/ide/common/api/IFeedbackPainter.java b/rule_api/src/com/android/ide/common/api/IFeedbackPainter.java
deleted file mode 100644
index 2b3d14d..0000000
--- a/rule_api/src/com/android/ide/common/api/IFeedbackPainter.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.google.common.annotations.Beta;
-
-/**
- * A feedback painter paints drop feedback during a drag &amp; drop operation.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- * </p>
- */
-@Beta
-public interface IFeedbackPainter {
- /**
- * Paints feedback for the given target node into the given graphics context.
- *
- * @param gc The graphics context to paint into
- * @param targetNode The node being dragged
- * @param feedback The feedback data
- */
- void paint(@NonNull IGraphics gc, @NonNull INode targetNode, @NonNull DropFeedback feedback);
-}
diff --git a/rule_api/src/com/android/ide/common/api/IGraphics.java b/rule_api/src/com/android/ide/common/api/IGraphics.java
deleted file mode 100644
index 1a7f64a..0000000
--- a/rule_api/src/com/android/ide/common/api/IGraphics.java
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.google.common.annotations.Beta;
-
-import java.util.List;
-
-/**
- * Represents a graphical context that rules can use to draw on the canvas.
- * <p/>
- * The wrapper GC is only valid during the context of a paint operation.
- * This means {@link IViewRule}s should not cache this object and call it at
- * just about any time, it is only valid during a call that actually receives
- * the GC wrapper.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- * </p>
- */
-@Beta
-public interface IGraphics {
-
- /**
- * Draws a line between 2 points, using the current foreground color and
- * alpha.
- */
- void drawLine(int x1, int y1, int x2, int y2);
-
- /**
- * Draws a line between 2 points, using the current foreground color and
- * alpha.
- */
- void drawLine(@NonNull Point p1, @NonNull Point p2);
-
- /**
- * Draws an arrow from (x1, y1) to (x2, y2).
- *
- * @param x1 The x coordinate of the beginning of the arrow
- * @param y1 The y coordinate of the beginning of the arrow
- * @param x2 The x coordinate of the end (point) of the arrow
- * @param y2 The y coordinate of the end (point) of the arrow
- * @param size The size of the arrowhead
- */
- void drawArrow(int x1, int y1, int x2, int y2, int size);
-
- /**
- * Draws a dot at the given position.
- *
- * @param x The x coordinate of the dot
- * @param y The y coordinate of the dot
- */
- void drawPoint(int x, int y);
-
- /**
- * Draws a rectangle outline between 2 points, using the current foreground
- * color and alpha.
- */
- void drawRect(int x1, int y1, int x2, int y2);
-
- /**
- * Draws a rectangle outline between 2 points, using the current foreground
- * color and alpha.
- */
- void drawRect(@NonNull Point p1, @NonNull Point p2);
-
- /**
- * Draws a rectangle outline between 2 points, using the current foreground
- * color and alpha.
- */
- void drawRect(@NonNull Rect r);
-
- /**
- * Fills a rectangle outline between 2 points, using the current background
- * color and alpha.
- */
- void fillRect(int x1, int y1, int x2, int y2);
-
- /**
- * Fills a rectangle outline between 2 points, using the current background
- * color and alpha.
- */
- void fillRect(@NonNull Point p1, @NonNull Point p2);
-
- /**
- * Fills a rectangle outline between 2 points, using the current background
- * color and alpha.
- */
- void fillRect(@NonNull Rect r);
-
- /**
- * Draws the given string, using the current foreground color. No tab
- * expansion or carriage return processing will be performed.
- *
- * @param string the string to be drawn.
- * @param x the x coordinate of the top left corner of the text.
- * @param y the y coordinate of the top left corner of the text.
- */
- void drawString(@NonNull String string, int x, int y);
-
- /**
- * Draws the given string, using the current foreground color. No tab
- * expansion or carriage return processing will be performed.
- *
- * @param string the string to be drawn.
- * @param topLeft the top left corner of the text.
- */
- void drawString(@NonNull String string, @NonNull Point topLeft);
-
- /**
- * Draw the given strings, using the current stroke color and alpha for the
- * text, and the current fill color and alpha for a rectangle behind the
- * bounding box fitting all the lines of text. Each subsequent string is
- * drawn on consecutive lines below the previous string.
- *
- * @param x The left edge to start each string at
- * @param y The top position of the first string; subsequent strings are
- * painted on lines below
- * @param strings An array of labels to be displayed (should not be null).
- * The actual String used is the {@link Object#toString()} value
- * of each list item.
- */
- void drawBoxedStrings(int x, int y, @NonNull List<?> strings);
-
- /**
- * Set up the graphics context to use the given style for subsequent drawing
- * operations.
- *
- * @param style The drawing style to be used. May not be null.
- */
- void useStyle(@NonNull DrawingStyle style);
-
- /**
- * Registers a color using 0x00rrggbb where each component is 0..0xFF.
- * <p/>
- * Transparency is handled separately using {@link #setAlpha(int)}.
- * <p/>
- * If the same color is registered twice, the same object will be returned.
- * <p/>
- * NOTE: It's preferable to use {@link #useStyle(DrawingStyle)} if possible
- * to ensure that your colors work properly across multiple current and
- * future themes.
- */
- @NonNull
- IColor registerColor(int rgb);
-
- /**
- * Returns the height, in pixels, of the default font.
- */
- int getFontHeight();
-
- /**
- * Returns the current foreground color.
- * The foreground color is used for drawing operations including when text is drawn.
- */
- @NonNull
- IColor getForeground();
-
- /**
- * Sets the foreground color. The foreground color is used for drawing
- * operations including when text is drawn.
- */
- void setForeground(@NonNull IColor color);
-
- /**
- * Returns the current background color. The background color is used for
- * fill operations.
- */
- @NonNull
- IColor getBackground();
-
- /**
- * Sets the background color. The background color is used for fill
- * operations.
- */
- void setBackground(@NonNull IColor color);
-
- /**
- * Returns the current alpha value (varies between 0 for transparent and 255
- * for opaque).
- *
- * @return The current alpha value in use
- */
- int getAlpha();
-
- /**
- * Sets the receiver's alpha value which must be
- * between 0 (transparent) and 255 (opaque).
- * <p>
- * This operation requires the operating system's advanced
- * graphics subsystem which may not be available on some
- * platforms.
- * <p>
- * TODO: Consider removing this method; it will usually be ignored because
- * most graphics operations apply the alpha from the current drawing style
- */
- void setAlpha(int alpha);
-
- /**
- * A line style for {@link IGraphics#setLineStyle(LineStyle)}.
- */
- enum LineStyle {
- /** Style for solid lines. */
- LINE_SOLID,
- /** Style for dashed lines. */
- LINE_DASH,
- /** Style for dotted lines. */
- LINE_DOT,
- /** Style for alternating dash-dot lines. */
- LINE_DASHDOT,
- /** Style for dash-dot-dot lines. */
- LINE_DASHDOTDOT
- }
-
- /**
- * Sets the current line style.
- */
- void setLineStyle(@NonNull LineStyle style);
-
- /**
- * Sets the width that will be used when drawing lines.
- * The operation is ignored if <var>width</var> is less than 1.
- */
- void setLineWidth(int width);
-}
diff --git a/rule_api/src/com/android/ide/common/api/IMenuCallback.java b/rule_api/src/com/android/ide/common/api/IMenuCallback.java
deleted file mode 100644
index 2ff3f8d..0000000
--- a/rule_api/src/com/android/ide/common/api/IMenuCallback.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.google.common.annotations.Beta;
-
-import java.util.List;
-
-/**
- * Callback interface for a {@link RuleAction}. The callback performs the actual
- * work of the action, and this level of indirection allows multiple actions (which
- * typically do not have their own class, only their own instances) to share a single
- * implementation callback class.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- * </p>
- */
-@Beta
-public interface IMenuCallback {
- /**
- * Performs the actual work promised by the {@link RuleAction}.
- * @param action The action being applied.
- * @param selectedNodes The nodes to apply the action to
- * @param valueId For a Choices action, the string id of the selected choice
- * @param newValue For a toggle or for a flag, true if the item is being
- * checked, false if being unchecked. For enums this is not
- * useful; however for flags it allows one to add or remove items
- * to the flag's choices.
- */
- void action(
- @NonNull RuleAction action,
- @NonNull List<? extends INode> selectedNodes,
- @Nullable String valueId,
- @Nullable Boolean newValue);
-
- /** Callback which does nothing */
- @NonNull
- public static final IMenuCallback NONE = new IMenuCallback() {
- @Override
- public void action(
- @NonNull RuleAction action,
- @NonNull
- List<? extends INode> selectedNodes,
- @Nullable String valueId,
- @Nullable Boolean newValue) {
- }
- };
-}
diff --git a/rule_api/src/com/android/ide/common/api/INode.java b/rule_api/src/com/android/ide/common/api/INode.java
deleted file mode 100644
index b137699..0000000
--- a/rule_api/src/com/android/ide/common/api/INode.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.android.ide.common.api.IDragElement.IDragAttribute;
-import com.google.common.annotations.Beta;
-
-import java.util.List;
-
-
-/**
- * Represents a view in the XML layout being edited.
- * Each view or layout maps to exactly one XML node, thus the name.
- * <p/>
- * The primordial characteristic of a node is the fully qualified View class name that
- * it represents (a.k.a FQCN), for example "android.view.View" or "android.widget.Button".
- * <p/>
- * There are 2 kind of nodes:
- * - Nodes matching a view actually rendered in the layout canvas have a valid "bounds"
- * rectangle that describe their position in pixels in the canvas. <br/>
- * - Nodes created by IViewRule scripts but not yet rendered have an invalid bounds rectangle
- * since they only exist in the uncommitted XML model and not yet in the rendered View model.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- * </p>
- */
-@Beta
-public interface INode {
-
- /**
- * Returns the FQCN of the view class represented by this node.
- */
- @NonNull
- String getFqcn();
-
- /**
- * Returns the bounds of this node.
- * <p/>
- * The bounds are valid when this node maps a view that is already rendered.
- * Typically, if the node is the target of a drag'n'drop operation then you can be
- * guaranteed that its bounds are known and thus are valid.
- * <p/>
- * However the bounds are invalid (e.g. not known yet) for new XML elements
- * that have just been created, e.g. by the {@link #appendChild(String)} method.
- *
- * @return A non-null rectangle, in canvas coordinates.
- */
- @NonNull
- Rect getBounds();
-
- /**
- * Returns the margins for this node.
- *
- * @return the margins for this node, never null
- */
- @NonNull
- Margins getMargins();
-
- /**
- * Returns the baseline of this node, or -1 if it has no baseline.
- * The baseline is the distance from the top down to the baseline.
- *
- * @return the baseline, or -1 if not applicable
- */
- int getBaseline();
-
- // ---- Hierarchy handling ----
-
- /**
- * Returns the root element of the view hierarchy.
- * <p/>
- * When a node is not attached to a hierarchy, it is its own root node.
- * This may return null if the {@link INode} was not created using a correct UiNode,
- * which is unlikely.
- */
- @Nullable
- INode getRoot();
-
- /**
- * Returns the parent node of this node, corresponding to the parent view in the layout.
- * The returned parent can be null when the node is the root element, or when the node is
- * not yet or no longer attached to the hierarchy.
- */
- @Nullable
- INode getParent();
-
- /**
- * Returns the list of valid children nodes. The list can be empty but not null.
- */
- @NonNull
- INode[] getChildren();
-
-
- // ---- XML Editing ---
-
- /**
- * Absolutely <em>all</em> calls that are going to edit the XML must be wrapped
- * by an editXml() call. This call creates both an undo context wrapper and an
- * edit-XML wrapper.
- *
- * @param undoName The UI name that will be given to the undo action.
- * @param callback The code to execute.
- */
- void editXml(@NonNull String undoName, @NonNull INodeHandler callback);
-
- // TODO define an exception that methods below will throw if editXml() is not wrapping
- // these calls.
-
- /**
- * Creates a new XML element as a child of this node's XML element.
- * <p/>
- * For this to work, the editor must have a descriptor for the given FQCN.
- * <p/>
- * This call must be done in the context of editXml().
- *
- * @param viewFqcn The FQCN of the element to create. The actual XML local name will
- * depend on whether this is an Android view or a custom project view.
- * @return The node for the newly created element. Can be null if we failed to create it.
- */
- @NonNull
- INode appendChild(@NonNull String viewFqcn);
-
- /**
- * Creates a new XML element as a child of this node's XML element and inserts
- * it at the specified position in the children list.
- * <p/>
- * For this to work, the editor must have a descriptor for the given FQCN.
- * <p/>
- * This call must be done in the context of editXml().
- *
- * @param viewFqcn The FQCN of the element to create. The actual XML local name will
- * depend on whether this is an Android view or a custom project view.
- * @param index Index of the child to insert before. If the index is out of bounds
- * (less than zero or larger that current last child), appends at the end.
- * @return The node for the newly created element. Can be null if we failed to create it.
- */
- @NonNull
- INode insertChildAt(@NonNull String viewFqcn, int index);
-
- /**
- * Removes the given XML element child from this node's list of children.
- * <p/>
- * This call must be done in the context of editXml().
- *
- * @param node The child to be deleted.
- */
- void removeChild(@NonNull INode node);
-
- /**
- * Sets an attribute for the underlying XML element.
- * Attributes are not written immediately -- instead the XML editor batches edits and
- * then commits them all together at once later.
- * <p/>
- * Custom attributes will be created on the fly.
- * <p/>
- * Passing an empty value actually <em>removes</em> an attribute from the XML.
- * <p/>
- * This call must be done in the context of editXml().
- *
- * @param uri The XML namespace URI of the attribute.
- * @param localName The XML <em>local</em> name of the attribute to set.
- * @param value It's value. Cannot be null. An empty value <em>removes</em> the attribute.
- * @return Whether the attribute was actually set or not.
- */
- boolean setAttribute(@Nullable String uri, @NonNull String localName, @Nullable String value);
-
- /**
- * Returns a given XML attribute.
- * <p/>
- * This looks up an attribute in the <em>current</em> XML source, not the in-memory model.
- * That means that if called in the context of {@link #editXml(String, INodeHandler)}, the value
- * returned here is not affected by {@link #setAttribute(String, String, String)} until
- * the editXml closure is completed and the actual XML is updated.
- *
- * @param uri The XML name-space URI of the attribute.
- * @param attrName The <em>local</em> name of the attribute.
- * @return the attribute as a {@link String}, if it exists, or <code>null</code>.
- */
- @Nullable
- String getStringAttr(@Nullable String uri, @NonNull String attrName);
-
- /**
- * Returns the {@link IAttributeInfo} for a given attribute.
- * <p/>
- * The information is useful to determine the format of an attribute (e.g. reference, string,
- * float, enum, flag, etc.) and in the case of enums and flags also gives the possible values.
- * <p/>
- * Note: in Android resources, an enum can only take one of the possible values (e.g.
- * "visibility" can be either "visible" or "none"), whereas a flag can accept one or more
- * value (e.g. "align" can be "center_vertical|center_horizontal".)
- * <p/>
- * Note that this method does not handle custom non-android attributes. It may either
- * return null for these or it may return a synthetic "string" format attribute depending
- * on how the attribute was loaded.
- *
- * @param uri The XML name-space URI of the attribute.
- * @param attrName The <em>local</em> name of the attribute.
- * @return the {@link IAttributeInfo} if the attribute is known, or <code>null</code>.
- */
- @Nullable
- public IAttributeInfo getAttributeInfo(@Nullable String uri, @NonNull String attrName);
-
- /**
- * Returns the list of all attributes declared by this node's descriptor.
- * <p/>
- * This returns a fixed list of all attributes known to the view or layout descriptor.
- * This list does not depend on whether the attributes are actually used in the
- * XML for this node.
- * <p/>
- * Note that for views, the list of attributes also includes the layout attributes
- * inherited from the parent view. This means callers must not cache this list based
- * solely on the type of the node, as its attribute list changes depending on the place
- * of the view in the view hierarchy.
- * <p/>
- * If you want attributes actually written in the XML and their values, please use
- * {@link #getStringAttr(String, String)} or {@link #getLiveAttributes()} instead.
- *
- * @return A non-null possibly-empty list of {@link IAttributeInfo}.
- */
- @NonNull
- public IAttributeInfo[] getDeclaredAttributes();
-
- /**
- * Returns the list of classes (fully qualified class names) that are
- * contributing properties to the {@link #getDeclaredAttributes()} attribute
- * list, in order from most specific to least specific (in other words,
- * android.view.View will be last in the list.) This is usually the same as
- * the super class chain of a view, but it skips any views that do not
- * contribute attributes.
- *
- * @return a list of views classes that contribute attributes to this node,
- * which is never null because at least android.view.View will
- * contribute attributes.
- */
- @NonNull
- public List<String> getAttributeSources();
-
- /**
- * Returns the list of all attributes defined in the XML for this node.
- * <p/>
- * This looks up an attribute in the <em>current</em> XML source, not the in-memory model.
- * That means that if called in the context of {@link #editXml(String, INodeHandler)}, the value
- * returned here is not affected by {@link #setAttribute(String, String, String)} until
- * the editXml closure is completed and the actual XML is updated.
- * <p/>
- * If you want a list of all possible attributes, whether used in the XML or not by
- * this node, please see {@link #getDeclaredAttributes()} instead.
- *
- * @return A non-null possibly-empty list of {@link IAttribute}.
- */
- @NonNull
- public IAttribute[] getLiveAttributes();
-
- // -----------
-
- /**
- * An XML attribute in an {@link INode} with a namespace URI, a name and its current value.
- * <p/>
- * The name cannot be empty.
- * The namespace URI can be empty for an attribute without a namespace but is never null.
- * The value can be empty but cannot be null.
- */
- public static interface IAttribute extends IDragAttribute { }
-}
diff --git a/rule_api/src/com/android/ide/common/api/INodeHandler.java b/rule_api/src/com/android/ide/common/api/INodeHandler.java
deleted file mode 100644
index e810487..0000000
--- a/rule_api/src/com/android/ide/common/api/INodeHandler.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.google.common.annotations.Beta;
-
-/**
- * A node handler is a callback which operates on a Node, such as for example
- * the implementation of an XML editing operation via
- * {@link INode#editXml(String, INodeHandler)}.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- * </p>
- */
-@Beta
-public interface INodeHandler {
- /**
- * Operates on the given node.
- *
- * @param node The node to be operated on
- */
- void handle(@NonNull INode node);
-}
diff --git a/rule_api/src/com/android/ide/common/api/IValidator.java b/rule_api/src/com/android/ide/common/api/IValidator.java
deleted file mode 100644
index 0b88a4b..0000000
--- a/rule_api/src/com/android/ide/common/api/IValidator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.google.common.annotations.Beta;
-
-/**
- * An IValidator can validate strings and return custom messages if validation
- * fails.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- */
-@Beta
-public interface IValidator {
- /**
- * Validates the given input string, and return null if the text is valid,
- * and otherwise return a description for why the text is invalid. Returning
- * an empty String ("") is acceptable (but should only be done when it is
- * obvious to the user why the String is not valid.)
- *
- * @param text The input string to be validated
- * @return Null if the text is valid, and otherwise a description (possibly
- * empty) for why the text is not valid.
- */
- @Nullable
- String validate(@NonNull String text);
-}
diff --git a/rule_api/src/com/android/ide/common/api/IViewMetadata.java b/rule_api/src/com/android/ide/common/api/IViewMetadata.java
deleted file mode 100644
index ea79e29..0000000
--- a/rule_api/src/com/android/ide/common/api/IViewMetadata.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.google.common.annotations.Beta;
-
-import java.util.List;
-
-/**
- * Metadata about a particular view. The metadata for a View can be found by asking the
- * {@link IClientRulesEngine} for the metadata for a given class via
- * {@link IClientRulesEngine#getMetadata}.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- */
-@Beta
-public interface IViewMetadata {
- /**
- * Returns the display name views of this type (a name suitable to display to the
- * user, normally capitalized and usually but not necessarily tied to the
- * implementation class). To be clear, a specific view may have an id attribute and a
- * text attribute, <b>neither</b> of these is the display name. Instead, the class
- * android.widget.ZoomControls may have the display name "Zoom Controls", and an
- * individual view created into a layout can for example have the id "ZoomControl01".
- *
- * @return the user visible name of views of this type (never null)
- */
- @NonNull
- public String getDisplayName();
-
- /**
- * Gets the insets for this view
- *
- * @return the insets for this view
- */
- @NonNull
- public Margins getInsets();
-
- /**
- * Returns the {@link FillPreference} of this view
- *
- * @return the {@link FillPreference} of this view, never null but may be
- * {@link FillPreference#NONE}
- */
- @NonNull
- public FillPreference getFillPreference();
-
- /**
- * Returns the most common attributes for this view.
- *
- * @return a list of attribute names (not including a namespace prefix) that
- * are commonly set for this type of view, never null
- */
- @NonNull
- public List<String> getTopAttributes();
-
- /**
- * Types of fill behavior that views can prefer.
- * <p>
- * TODO: Consider better names. FillPolicy? Stretchiness?
- */
- public enum FillPreference {
- /** This view does not want to fill */
- NONE,
- /** This view wants to always fill both horizontal and vertical */
- BOTH,
- /** This view wants to fill horizontally but not vertically */
- WIDTH,
- /** This view wants to fill vertically but not horizontally */
- HEIGHT,
- /**
- * This view wants to fill in the opposite dimension of the context, e.g. in a
- * vertical context it wants to fill horizontally, and vice versa
- */
- OPPOSITE,
- /** This view wants to fill horizontally, but only in a vertical context */
- WIDTH_IN_VERTICAL,
- /** This view wants to fill vertically, but only in a horizontal context */
- HEIGHT_IN_HORIZONTAL;
-
- /**
- * Returns true if this view wants to fill horizontally, if the context is
- * vertical or horizontal as indicated by the parameter.
- *
- * @param verticalContext If true, the context is vertical, otherwise it is
- * horizontal.
- * @return true if this view wants to fill horizontally
- */
- public boolean fillHorizontally(boolean verticalContext) {
- return (this == BOTH || this == WIDTH ||
- (verticalContext && (this == OPPOSITE || this == WIDTH_IN_VERTICAL)));
- }
-
- /**
- * Returns true if this view wants to fill vertically, if the context is
- * vertical or horizontal as indicated by the parameter.
- *
- * @param verticalContext If true, the context is vertical, otherwise it is
- * horizontal.
- * @return true if this view wants to fill vertically
- */
- public boolean fillVertically(boolean verticalContext) {
- return (this == BOTH || this == HEIGHT ||
- (!verticalContext && (this == OPPOSITE || this == HEIGHT_IN_HORIZONTAL)));
- }
- }
-}
diff --git a/rule_api/src/com/android/ide/common/api/IViewRule.java b/rule_api/src/com/android/ide/common/api/IViewRule.java
deleted file mode 100644
index 88b795f..0000000
--- a/rule_api/src/com/android/ide/common/api/IViewRule.java
+++ /dev/null
@@ -1,401 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-
-import java.util.List;
-
-
-/**
- * An {@link IViewRule} describes the rules that apply to a given Layout or View object
- * in the Graphical Layout Editor.
- * <p/>
- * Rules are implemented by builtin layout helpers, or 3rd party layout rule implementations
- * provided with or for a given 3rd party widget.
- * <p/>
- * A 3rd party layout rule should use the same fully qualified class name as the layout it
- * represents, plus "Rule" as a suffix. For example, the layout rule for the
- * LinearLayout class is LinearLayoutRule, in the same package.
- * <p/>
- * Rule instances are stateless. They are created once per View class to handle and are shared
- * across platforms or editor instances. As such, rules methods should never cache editor-specific
- * arguments that they might receive.
- * <p/>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- * </p>
- */
-public interface IViewRule {
-
- /**
- * This method is called by the rule engine when the script is first loaded.
- * It gives the rule a chance to initialize itself.
- *
- * @param fqcn The fully qualified class name of the Layout or View that will be managed by
- * this rule. This can be cached as it will never change for the lifetime of this rule
- * instance. This may or may not match the script's filename as it may be the fqcn of a
- * class derived from the one this rule can handle.
- * @param engine The engine that is managing the rules. A rule can store a reference to
- * the engine during initialization and then use it later to invoke some of the
- * {@link IClientRulesEngine} methods for example to request user input.
- * @return True if this rule can handle the given FQCN. False if the rule can't handle the
- * given FQCN, in which case the rule engine will find another rule matching a parent class.
- */
- boolean onInitialize(@NonNull String fqcn, @NonNull IClientRulesEngine engine);
-
- /**
- * This method is called by the rules engine just before the script is unloaded.
- */
- void onDispose();
-
- /**
- * Returns the class name to display when an element is selected in the layout editor.
- * <p/>
- * If null is returned, the layout editor will automatically shorten the class name using its
- * own heuristic, which is to keep the first 2 package components and the class name.
- * The class name is the <code>fqcn</code> argument that was given
- * to {@link #onInitialize(String,IClientRulesEngine)}.
- *
- * @return Null for the default behavior or a shortened string.
- */
- @Nullable
- String getDisplayName();
-
- /**
- * Invoked by the Rules Engine to produce a set of actions to customize
- * the context menu displayed for this view. The result is not cached and the
- * method is invoked every time the context menu is about to be shown.
- * <p>
- * The order of the menu items is determined by the sort priority set on
- * the actions.
- * <p/>
- * Most rules should consider calling super.{@link #addContextMenuActions(List, INode)}
- * as well.
- * <p/>
- * Menu actions are either toggles or fixed lists with one currently-selected
- * item. It is expected that the rule will need to recreate the actions with
- * different selections when a menu is going to shown, which is why the result
- * is not cached. However rules are encouraged to cache some or all of the result
- * to speed up following calls if it makes sense.
- *
- * @param actions a list of actions to add new context menu actions into. The order
- * of the actions in this list is not important; it will be sorted by
- * {@link RuleAction#getSortPriority()} later.
- * @param node the node to add actions for.
- */
- void addContextMenuActions(@NonNull List<RuleAction> actions, @NonNull INode node);
-
- /**
- * Returns the id of the default action to invoke for this view, typically when the
- * user presses F2. The id should correspond to the {@link RuleAction#getId()} returned
- * by one of the actions added by {@link #addContextMenuActions(List, INode)}.
- *
- * @param node the primary selected node
- * @return the id of default action, or null if none is default
- */
- @Nullable
- String getDefaultActionId(@NonNull INode node);
-
- /**
- * Invoked by the Rules Engine to ask the parent layout for the set of layout actions
- * to display in the layout bar. The layout rule should add these into the provided
- * list. The order the items are added in does not matter; the
- * {@link RuleAction#getSortPriority()} values will be used to sort the actions prior
- * to display, which makes it easier for parent rules and deriving rules to interleave
- * their respective actions.
- *
- * @param actions the list of actions to add newly registered actions into
- * @param parentNode the parent of the selection, or the selection itself if the root
- * @param targets the targeted/selected nodes, if any
- */
- void addLayoutActions(
- @NonNull List<RuleAction> actions,
- @NonNull INode parentNode,
- @NonNull List<? extends INode> targets);
-
- // ==== Selection ====
-
- /**
- * Returns a list of strings that will be displayed when a single child is being
- * selected in a layout corresponding to this rule. This gives the container a chance
- * to describe the child's layout attributes or other relevant information.
- * <p/>
- * Note that this is called only for single selections.
- * <p/>
- *
- * @param parentNode The parent of the node selected. Never null.
- * @param childNode The child node that was selected. Never null.
- * @return a list of strings to be displayed, or null or empty to display nothing
- */
- @Nullable
- List<String> getSelectionHint(@NonNull INode parentNode, @NonNull INode childNode);
-
- /**
- * Paints any layout-specific selection feedback for the given parent layout.
- *
- * @param graphics the graphics context to paint into
- * @param parentNode the parent layout node
- * @param childNodes the child nodes selected in the parent layout
- * @param view An instance of the view to be painted (may be null)
- */
- void paintSelectionFeedback(
- @NonNull IGraphics graphics,
- @NonNull INode parentNode,
- @NonNull List<? extends INode> childNodes,
- @Nullable Object view);
-
- // ==== Drag'n'drop support ====
-
- /**
- * Called when the d'n'd starts dragging over the target node. If
- * interested, returns a DropFeedback passed to onDrop/Move/Leave/Paint. If
- * not interested in drop, return null. Followed by a paint.
- *
- * @param targetNode the {@link INode} for the target layout receiving a
- * drop event
- * @param targetView the corresponding View object for the target layout, or
- * null if not known
- * @param elements an array of {@link IDragElement} element descriptors for
- * the dragged views. When there are more than one element, the
- * first element will always be the "primary" element (e.g. the
- * one that the mouse is actively dragging.)
- * @return a {@link DropFeedback} object with drop state (which will be
- * supplied to a follow-up {@link #onDropMove} call), or null if the
- * drop should be ignored
- */
- @Nullable
- DropFeedback onDropEnter(@NonNull INode targetNode, @Nullable Object targetView,
- @Nullable IDragElement[] elements);
-
- /**
- * Called after onDropEnter. Returns a DropFeedback passed to
- * onDrop/Move/Leave/Paint (typically same as input one). Returning null
- * will invalidate the drop workflow.
- *
- * @param targetNode the {@link INode} for the target layout receiving a
- * drop event
- * @param elements an array of {@link IDragElement} element descriptors for
- * the dragged views. When there are more than one element, the
- * first element will always be the "primary" element (e.g. the
- * one that the mouse is actively dragging.)
- * @param feedback the {@link DropFeedback} object created by
- * {@link #onDropEnter(INode, Object, IDragElement[])}
- * @param where the current mouse drag position
- * @return a {@link DropFeedback} (which is usually just the same one passed
- * into this method)
- */
- @Nullable
- DropFeedback onDropMove(
- @NonNull INode targetNode,
- @NonNull IDragElement[] elements,
- @Nullable DropFeedback feedback,
- @NonNull Point where);
-
- /**
- * Called when drop leaves the target without actually dropping.
- * <p/>
- * When switching between views, onDropLeave is called on the old node *after* onDropEnter
- * is called after a new node that returned a non-null feedback. The feedback received here
- * is the one given by the previous onDropEnter on the same target.
- * <p/>
- * E.g. call order is:
- * <pre>
- * - onDropEnter(node1) => feedback1
- * <i>...user moves to new view...</i>
- * - onDropEnter(node2) => feedback2
- * - onDropLeave(node1, feedback1)
- * <i>...user leaves canvas...</i>
- * - onDropLeave(node2, feedback2)
- * </pre>
- * @param targetNode the {@link INode} for the target layout receiving a
- * drop event
- * @param elements an array of {@link IDragElement} element descriptors for
- * the dragged views. When there are more than one element, the
- * first element will always be the "primary" element (e.g. the
- * one that the mouse is actively dragging.)
- * @param feedback the {@link DropFeedback} object created by
- * {@link #onDropEnter(INode, Object, IDragElement[])}
- */
- void onDropLeave(
- @NonNull INode targetNode,
- @NonNull IDragElement[] elements,
- @Nullable DropFeedback feedback);
-
- /**
- * Called when drop is released over the target to perform the actual drop.
- * <p>
- * TODO: Document that this method will be called under an edit lock so you can
- * directly manipulate the nodes without wrapping it in an
- * {@link INode#editXml(String, INodeHandler)} call.
- *
- * @param targetNode the {@link INode} for the target layout receiving a
- * drop event
- * @param elements an array of {@link IDragElement} element descriptors for
- * the dragged views. When there are more than one element, the
- * first element will always be the "primary" element (e.g. the
- * one that the mouse is actively dragging.)
- * @param feedback the {@link DropFeedback} object created by
- * {@link #onDropEnter(INode, Object, IDragElement[])}
- * @param where the mouse drop position
- */
- void onDropped(
- @NonNull INode targetNode,
- @NonNull IDragElement[] elements,
- @Nullable DropFeedback feedback,
- @NonNull Point where);
-
- /**
- * Called when pasting elements in an existing document on the selected target.
- *
- * @param targetNode The first node selected.
- * @param targetView the corresponding View object for the target layout, or
- * null if not known
- * @param pastedElements The elements being pasted.
- */
- void onPaste(@NonNull INode targetNode, @Nullable Object targetView,
- @NonNull IDragElement[] pastedElements);
-
- // ==== XML Creation ====
-
- /**
- * Called when a view for this rule is being created. This allows for the rule to
- * customize the newly created object. Note that this method is called not just when a
- * view is created from a palette drag, but when views are constructed via a drag-move
- * (where views are created in the destination and then deleted from the source), and
- * even when views are constructed programmatically from other view rules. The
- * {@link InsertType} parameter can be used to distinguish the context for the
- * insertion. For example, the <code>DialerFilterRule</code> will insert EditText children
- * when a DialerFilter is first created, but not during a copy/paste or a move.
- *
- * @param node the newly created node (which will always be a View that applies to
- * this {@link IViewRule})
- * @param parent the parent of the node (which may not yet contain the newly created
- * node in its child list)
- * @param insertType whether this node was created as part of a newly created view, or
- * as a copy, or as a move, etc.
- */
- void onCreate(@NonNull INode node, @NonNull INode parent, @NonNull InsertType insertType);
-
- /**
- * Called when a child for this view has been created and is being inserted into the
- * view parent for which this {@link IViewRule} applies. Allows the parent to perform
- * customizations of the object. As with {@link #onCreate}, the {@link InsertType}
- * parameter can be used to handle new creation versus moves versus copy/paste
- * operations differently.
- *
- * @param child the newly created node
- * @param parent the parent of the newly created node (which may not yet contain the
- * newly created node in its child list)
- * @param insertType whether this node was created as part of a newly created view, or
- * as a copy, or as a move, etc.
- */
- void onChildInserted(@NonNull INode child, @NonNull INode parent,
- @NonNull InsertType insertType);
-
- /**
- * Called when one or more children are about to be deleted by the user.
- * Note that children deleted programmatically from view rules (via
- * {@link INode#removeChild(INode)}) will not notify about deletion.
- * <p>
- * Note that this method will be called under an edit lock, so rules can
- * directly add/remove nodes and attributes as part of the deletion handling
- * (and their actions will be part of the same undo-unit.)
- * <p>
- * Note that when children are moved (such as when you drag a child within a
- * LinearLayout to move it from one position among the children to another),
- * that will also result in a
- * {@link #onChildInserted(INode, INode, InsertType)} (with the
- * {@code InsertType} set to {@link InsertType#MOVE_WITHIN}) and a remove
- * via this {@link #onRemovingChildren(List, INode, boolean)} method. When
- * the deletion is occurring as part of a local move (insert + delete), the
- * {@code moved} parameter to this method is set to true.
- *
- * @param deleted a nonempty list of children about to be deleted
- * @param parent the parent of the deleted children (which still contains
- * the children since this method is called before the deletion
- * is performed)
- * @param moved when true, the nodes are being deleted as part of a local
- * move (where copies are inserted elsewhere)
- */
- void onRemovingChildren(@NonNull List<INode> deleted, @NonNull INode parent,
- boolean moved);
-
- /**
- * Called by the IDE on the parent layout when a child widget is being resized. This
- * is called once at the beginning of the resizing operation. A horizontal edge,
- * or a vertical edge, or both, can be resized simultaneously.
- *
- * @param child the widget being resized
- * @param parent the layout containing the child
- * @param horizEdge The horizontal edge being resized, or null
- * @param verticalEdge the vertical edge being resized, or null
- * @param childView an instance of the resized node view, or null if not known
- * @param parentView an instance of the parent layout view object, or null if not known
- * @return a {@link DropFeedback} object which performs an update painter callback
- * etc.
- */
- @Nullable
- DropFeedback onResizeBegin(
- @NonNull INode child,
- @NonNull INode parent,
- @Nullable SegmentType horizEdge,
- @Nullable SegmentType verticalEdge,
- @Nullable Object childView,
- @Nullable Object parentView);
-
- /**
- * Called by the IDE on the parent layout when a child widget is being resized. This
- * is called repeatedly during the resize as the mouse is dragged to update the drag
- * bounds, recompute guidelines, etc. The resize has not yet been "committed" so the
- * XML should not be edited yet.
- *
- * @param feedback the {@link DropFeedback} object created in {@link #onResizeBegin}
- * @param child the widget being resized
- * @param parent the layout containing the child
- * @param newBounds the new bounds the user has chosen to resize the widget to,
- * in absolute coordinates
- * @param modifierMask The modifier keys currently pressed by the user, as a bitmask
- * of the constants {@link DropFeedback#MODIFIER1}, {@link DropFeedback#MODIFIER2}
- * and {@link DropFeedback#MODIFIER3}.
- */
- void onResizeUpdate(
- @Nullable DropFeedback feedback,
- @NonNull INode child,
- @NonNull INode parent,
- @NonNull Rect newBounds,
- int modifierMask);
-
- /**
- * Called by the IDE on the parent layout when a child widget is being resized. This
- * is called once at the end of the resize operation, if it was not canceled.
- * This method can call {@link INode#editXml} to update the node to reflect the
- * new bounds.
- *
- * @param feedback the {@link DropFeedback} object created in {@link #onResizeBegin}
- * @param child the widget being resized
- * @param parent the layout containing the child
- * @param newBounds the new bounds the user has chosen to resize the widget to,
- * in absolute coordinates
- */
- void onResizeEnd(
- @Nullable DropFeedback feedback,
- @NonNull INode child,
- @NonNull INode parent,
- @NonNull Rect newBounds);
-}
diff --git a/rule_api/src/com/android/ide/common/api/InsertType.java b/rule_api/src/com/android/ide/common/api/InsertType.java
deleted file mode 100644
index 26538ae..0000000
--- a/rule_api/src/com/android/ide/common/api/InsertType.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.google.common.annotations.Beta;
-
-/**
- * An enumerated type of different insertion events, such as an insertion from a
- * copy/paste operation or as the first half of a move operation.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- */
-@Beta
-public enum InsertType {
- /** The view is newly created (by for example a palette drag) */
- CREATE,
-
- /**
- * Same as {@link #CREATE} but when the views are constructed for previewing, for
- * example as part of a palette drag.
- */
- CREATE_PREVIEW,
-
- /** The view is being inserted here because it was moved from somewhere else within
- * the same layout */
- MOVE_WITHIN,
-
- /** The view is being inserted here because it was moved from some other layout */
- MOVE_INTO,
-
- /**
- * The view is being inserted here as a result of a copy/paste from elsewhere
- * (including drags, but not from the palette)
- */
- PASTE;
-
- /**
- * Returns true if this insert type is for a newly created view (for example a by
- * palette drag). Note that this includes both normal create events as well as well as
- * views created as part of previewing operations.
- *
- * @return true if this {@link InsertType} is for a newly created view
- */
- public boolean isCreate() {
- return this == CREATE || this == CREATE_PREVIEW;
- }
-}
diff --git a/rule_api/src/com/android/ide/common/api/MarginType.java b/rule_api/src/com/android/ide/common/api/MarginType.java
deleted file mode 100644
index 188f85c..0000000
--- a/rule_api/src/com/android/ide/common/api/MarginType.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.google.common.annotations.Beta;
-
-
-/**
- * A {@link MarginType} indicates whether a {@link Segment} corresponds to the visual edge
- * of the node, or whether it is offset by a margin in the edge's direction, or whether
- * it's both (which is the case when the margin is 0).
- * <p>
- * We need to keep track of the distinction because different constraints apply
- * differently w.r.t. margins. Let's say you have a target node with a 50 dp margin in all
- * directions. If you layout_alignTop with this node, the match will be on the visual
- * bounds of the target node (ignoring the margin). If you layout_above this node, you
- * will be offset by the margin on the target node. Therefore, we have to add <b>both</b>
- * edges (the bounds of the target node with and without edges) and check for matches on
- * each edge depending on the constraint being considered.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- */
-@Beta
-public enum MarginType {
- /**
- * This margin type is used for nodes that have margins, and this segment includes the
- * margin distance
- */
- WITH_MARGIN,
-
- /**
- * This margin type is used for nodes that have margins, and this segment does not
- * include the margin distance
- */
- WITHOUT_MARGIN,
-
- /**
- * This margin type is used for nodes that do not have margins, so margin edges and
- * non-margin edges are the same
- */
- NO_MARGIN;
-}
diff --git a/rule_api/src/com/android/ide/common/api/Margins.java b/rule_api/src/com/android/ide/common/api/Margins.java
deleted file mode 100644
index f38066f..0000000
--- a/rule_api/src/com/android/ide/common/api/Margins.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.google.common.annotations.Beta;
-import com.android.annotations.NonNull;
-
-/**
- * Set of margins - distances to outer left, top, right and bottom edges. These objects
- * can be used for both actual <b>margins</b> as well as insets - and in general any
- * deltas to the bounds of a rectangle.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- */
-@Beta
-public class Margins {
- /** The left margin */
- public final int left;
-
- /** The right margin */
- public final int right;
-
- /** The top margin */
- public final int top;
-
- /** The bottom margin */
- public final int bottom;
-
- /**
- * Creates a new {@link Margins} instance.
- *
- * @param left the left side margin
- * @param right the right side margin
- * @param top the top margin
- * @param bottom the bottom margin
- */
- public Margins(int left, int right, int top, int bottom) {
- super();
- this.left = left;
- this.right = right;
- this.top = top;
- this.bottom = bottom;
- }
-
- @NonNull
- @Override
- public String toString() {
- return "Margins [left=" + left + ", right=" + right + ", top=" + top + ", bottom=" + bottom
- + "]";
- }
-}
diff --git a/rule_api/src/com/android/ide/common/api/Point.java b/rule_api/src/com/android/ide/common/api/Point.java
deleted file mode 100644
index b13f12a..0000000
--- a/rule_api/src/com/android/ide/common/api/Point.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.google.common.annotations.Beta;
-import com.android.annotations.NonNull;
-
-
-/**
- * Mutable point.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- * </p>
- */
-@Beta
-public class Point {
- public int x, y;
-
- public Point(int x, int y) {
- this.x = x;
- this.y = y;
- }
-
- public Point(@NonNull Point p) {
- x = p.x;
- y = p.y;
- }
-
- /** Sets the point to the given coordinates. */
- public void set(int x, int y) {
- this.x = x;
- this.y = y;
- }
-
- /** Returns a new instance of a point with the same values. */
- @NonNull
- public Point copy() {
- return new Point(x, y);
- }
-
- /**
- * Offsets this point by adding the given x,y deltas to the x,y coordinates.
- * @return Returns self, for chaining.
- */
- @NonNull
- public Point offsetBy(int x, int y) {
- this.x += x;
- this.y += y;
- return this;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Point) {
- Point rhs = (Point) obj;
- return this.x == rhs.x && this.y == rhs.y;
- }
- return false;
- }
-
- @Override
- public int hashCode() {
- int h = x ^ ((y >> 16) & 0x0FFFF) ^ ((y & 0x0FFFF) << 16);
- return h;
- }
-
- @Override
- public String toString() {
- return String.format("Point [%dx%d]", x, y);
- }
-}
diff --git a/rule_api/src/com/android/ide/common/api/Rect.java b/rule_api/src/com/android/ide/common/api/Rect.java
deleted file mode 100644
index 88c04a6..0000000
--- a/rule_api/src/com/android/ide/common/api/Rect.java
+++ /dev/null
@@ -1,253 +0,0 @@
-/*
- * Copyright (C) 2009 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.google.common.annotations.Beta;
-
-
-/**
- * Mutable rectangle bounds.
- * <p/>
- * To be valid, w >= 1 and h >= 1.
- * By definition:
- * - right side = x + w - 1.
- * - bottom side = y + h - 1.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- * </p>
- */
-@Beta
-public class Rect {
- public int x, y, w, h;
-
- /** Initialize an invalid rectangle. */
- public Rect() {
- }
-
- /** Initialize rectangle to the given values. They can be invalid. */
- public Rect(int x, int y, int w, int h) {
- set(x, y, w, h);
- }
-
- /** Initialize rectangle to the given values. They can be invalid. */
- public Rect(@NonNull Rect r) {
- set(r);
- }
-
- /** Initialize rectangle to the given values. They can be invalid. */
- @NonNull
- public Rect set(int x, int y, int w, int h) {
- this.x = x;
- this.y = y;
- this.w = w;
- this.h = h;
- return this;
- }
-
- /** Initialize rectangle to match the given one. */
- @NonNull
- public Rect set(@NonNull Rect r) {
- set(r.x, r.y, r.w, r.h);
- return this;
- }
-
- /** Returns a new instance of a rectangle with the same values. */
- @NonNull
- public Rect copy() {
- return new Rect(x, y, w, h);
- }
-
- /** Returns true if the rectangle has valid bounds, i.e. w>0 and h>0. */
- public boolean isValid() {
- return w > 0 && h > 0;
- }
-
- /** Returns true if the rectangle contains the x,y coordinates, borders included. */
- public boolean contains(int x, int y) {
- return isValid()
- && x >= this.x
- && y >= this.y
- && x < (this.x + this.w)
- && y < (this.y + this.h);
- }
-
- /**
- * Returns true if this rectangle intersects the given rectangle.
- * Two rectangles intersect if they overlap.
- * @param other the other rectangle to test
- * @return true if the two rectangles overlap
- */
- public boolean intersects(@Nullable Rect other) {
- if (other == null) {
- return false;
- }
- if (x2() <= other.x
- || other.x2() <= x
- || y2() <= other.y
- || other.y2() <= y) {
- return false;
- }
-
- return true;
- }
-
- /** Returns true if the rectangle fully contains the given rectangle */
- public boolean contains(@Nullable Rect rect) {
- return rect != null && x <= rect.x
- && y <= rect.y
- && x2() >= rect.x2()
- && y2() >= rect.y2();
- }
-
- /** Returns true if the rectangle contains the x,y coordinates, borders included. */
- public boolean contains(@Nullable Point p) {
- return p != null && contains(p.x, p.y);
- }
-
- /**
- * Moves this rectangle by setting it's x,y coordinates to the new values.
- * @return Returns self, for chaining.
- */
- @NonNull
- public Rect moveTo(int x, int y) {
- this.x = x;
- this.y = y;
- return this;
- }
-
- /**
- * Offsets this rectangle by adding the given x,y deltas to the x,y coordinates.
- * @return Returns self, for chaining.
- */
- @NonNull
- public Rect offsetBy(int x, int y) {
- this.x += x;
- this.y += y;
- return this;
- }
-
- @NonNull
- public Point getCenter() {
- return new Point(x + (w > 0 ? w / 2 : 0),
- y + (h > 0 ? h / 2 : 0));
- }
-
- @NonNull
- public Point getTopLeft() {
- return new Point(x, y);
- }
-
- @NonNull
- public Point getBottomLeft() {
- return new Point(x,
- y + (h > 0 ? h : 0));
- }
-
- @NonNull
- public Point getTopRight() {
- return new Point(x + (w > 0 ? w : 0),
- y);
- }
-
- @NonNull
- public Point getBottomRight() {
- return new Point(x + (w > 0 ? w : 0),
- y + (h > 0 ? h : 0));
- }
-
- /**
- * Returns the X coordinate of the right hand side of the rectangle
- *
- * @return the X coordinate of the right hand side of the rectangle
- */
- public int x2() {
- return x + w;
- }
-
- /**
- * Returns the Y coordinate of the bottom of the rectangle
- *
- * @return the Y coordinate of the bottom of the rectangle
- */
- public int y2() {
- return y + h;
- }
-
- /**
- * Returns the X coordinate of the center of the rectangle
- *
- * @return the X coordinate of the center of the rectangle
- */
- public int centerX() {
- return x + w / 2;
- }
-
- /**
- * Returns the Y coordinate of the center of the rectangle
- *
- * @return the Y coordinate of the center of the rectangle
- */
- public int centerY() {
- return y + h / 2;
- }
-
- @Override
- public String toString() {
- return String.format("Rect [(%d,%d)-(%d,%d): %dx%d]", x, y, x + w, y + h, w, h);
- }
-
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof Rect) {
- Rect rhs = (Rect) obj;
- // validity must be equal on both sides.
- if (isValid() != rhs.isValid()) {
- return false;
- }
- // an invalid rect is equal to any other invalid rect regardless of coordinates
- if (!isValid() && !rhs.isValid()) {
- return true;
- }
-
- return this.x == rhs.x && this.y == rhs.y && this.w == rhs.w && this.h == rhs.h;
- }
-
- return false;
- }
-
- @Override
- public int hashCode() {
- int hc = x;
- hc ^= ((y >> 8) & 0x0FFFFFF) | ((y & 0x00000FF) << 24);
- hc ^= ((w >> 16) & 0x000FFFF) | ((w & 0x000FFFF) << 16);
- hc ^= ((h >> 24) & 0x00000FF) | ((h & 0x0FFFFFF) << 8);
- return hc;
- }
-
- /**
- * Returns the center point in the rectangle
- *
- * @return the center point in the rectangle
- */
- @NonNull
- public Point center() {
- return new Point(x + w / 2, y + h / 2);
- }
-}
diff --git a/rule_api/src/com/android/ide/common/api/ResizePolicy.java b/rule_api/src/com/android/ide/common/api/ResizePolicy.java
deleted file mode 100644
index f48095a..0000000
--- a/rule_api/src/com/android/ide/common/api/ResizePolicy.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.google.common.annotations.Beta;
-
-/**
- * A {@link ResizePolicy} records state for whether a widget is resizable, and if so, in
- * which directions
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- */
-@Beta
-public class ResizePolicy {
- private static final int NONE = 0;
- private static final int LEFT_EDGE = 1;
- private static final int RIGHT_EDGE = 2;
- private static final int TOP_EDGE = 4;
- private static final int BOTTOM_EDGE = 8;
- private static final int PRESERVE_RATIO = 16;
-
- // Aliases
- private static final int HORIZONTAL = LEFT_EDGE | RIGHT_EDGE;
- private static final int VERTICAL = TOP_EDGE | BOTTOM_EDGE;
- private static final int ANY = HORIZONTAL | VERTICAL;
-
- // Shared objects for common policies
-
- private static final ResizePolicy sAny = new ResizePolicy(ANY);
- private static final ResizePolicy sNone = new ResizePolicy(NONE);
- private static final ResizePolicy sHorizontal = new ResizePolicy(HORIZONTAL);
- private static final ResizePolicy sVertical = new ResizePolicy(VERTICAL);
- private static final ResizePolicy sScaled = new ResizePolicy(ANY | PRESERVE_RATIO);
-
- private final int mFlags;
-
-
- // Use factory methods to construct
- private ResizePolicy(int flags) {
- mFlags = flags;
- }
-
- /**
- * Returns true if this policy allows resizing in at least one direction
- *
- * @return true if this policy allows resizing in at least one direction
- */
- public boolean isResizable() {
- return (mFlags & ANY) != 0;
- }
-
- /**
- * Returns true if this policy allows resizing the top edge
- *
- * @return true if this policy allows resizing the top edge
- */
- public boolean topAllowed() {
- return (mFlags & TOP_EDGE) != 0;
- }
-
- /**
- * Returns true if this policy allows resizing the right edge
- *
- * @return true if this policy allows resizing the right edge
- */
- public boolean rightAllowed() {
- return (mFlags & RIGHT_EDGE) != 0;
- }
-
- /**
- * Returns true if this policy allows resizing the bottom edge
- *
- * @return true if this policy allows resizing the bottom edge
- */
- public boolean bottomAllowed() {
- return (mFlags & BOTTOM_EDGE) != 0;
- }
-
- /**
- * Returns true if this policy allows resizing the left edge
- *
- * @return true if this policy allows resizing the left edge
- */
- public boolean leftAllowed() {
- return (mFlags & LEFT_EDGE) != 0;
- }
-
- /**
- * Returns true if this policy requires resizing in an aspect-ratio preserving manner
- *
- * @return true if this policy requires resizing in an aspect-ratio preserving manner
- */
- public boolean isAspectPreserving() {
- return (mFlags & PRESERVE_RATIO) != 0;
- }
-
- /**
- * Returns a resize policy allowing resizing in any direction
- *
- * @return a resize policy allowing resizing in any direction
- */
- @NonNull
- public static ResizePolicy full() {
- return sAny;
- }
-
- /**
- * Returns a resize policy not allowing any resizing
- *
- * @return a policy which does not allow any resizing
- */
- @NonNull
- public static ResizePolicy none() {
- return sNone;
- }
-
- /**
- * Returns a resize policy allowing horizontal resizing only
- *
- * @return a policy which allows horizontal resizing only
- */
- @NonNull
- public static ResizePolicy horizontal() {
- return sHorizontal;
- }
-
- /**
- * Returns a resize policy allowing vertical resizing only
- *
- * @return a policy which allows vertical resizing only
- */
- @NonNull
- public static ResizePolicy vertical() {
- return sVertical;
- }
-
- /**
- * Returns a resize policy allowing scaled / aspect-ratio preserving resizing only
- *
- * @return a resize policy allowing scaled / aspect-ratio preserving resizing only
- */
- @NonNull
- public static ResizePolicy scaled() {
- return sScaled;
- }
-
- /**
- * Returns a resize policy with the specified resizability along the edges and the
- * given aspect ratio behavior
- * @param top whether the top edge is resizable
- * @param right whether the right edge is resizable
- * @param bottom whether the bottom edge is resizable
- * @param left whether the left edge is resizable
- * @param preserve whether the policy requires the aspect ratio to be preserved
- * @return a resize policy recording the constraints required by the parameters
- */
- @NonNull
- public static ResizePolicy create(boolean top, boolean right, boolean bottom, boolean left,
- boolean preserve) {
- int mask = NONE;
- if (top) mask |= TOP_EDGE;
- if (right) mask |= RIGHT_EDGE;
- if (bottom) mask |= BOTTOM_EDGE;
- if (left) mask |= LEFT_EDGE;
- if (preserve) mask |= PRESERVE_RATIO;
-
- return new ResizePolicy(mask);
- }
-}
diff --git a/rule_api/src/com/android/ide/common/api/RuleAction.java b/rule_api/src/com/android/ide/common/api/RuleAction.java
deleted file mode 100644
index 34b8837..0000000
--- a/rule_api/src/com/android/ide/common/api/RuleAction.java
+++ /dev/null
@@ -1,739 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.android.utils.Pair;
-import com.google.common.annotations.Beta;
-
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Pattern;
-
-/**
- * A {@link RuleAction} represents an action provided by an {@link IViewRule}, typically
- * shown in a context menu or in the layout actions bar.
- * <p/>
- * Each action should have a reasonably unique ID. This is used when multiple nodes
- * are selected to filter the actions down to just those actions that are supported
- * across all selected nodes. If an action does not support multiple nodes, it can
- * return false from {@link #supportsMultipleNodes()}.
- * <p/>
- * Actions can be grouped into a hierarchy of sub-menus using the {@link NestedAction} class,
- * or into a flat submenu using the {@link Choices} class.
- * <p/>
- * Actions (including separators) all have a "sort priority", and this is used to
- * sort the menu items or toolbar buttons into a specific order.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- * </p>
- */
-@Beta
-public class RuleAction implements Comparable<RuleAction> {
- /**
- * Character used to split multiple checked choices.
- * The pipe character "|" is used, to natively match Android resource flag separators.
- */
- public final static String CHOICE_SEP = "|"; //$NON-NLS-1$
-
- /**
- * Same as {@link #CHOICE_SEP} but safe for use in regular expressions.
- */
- public final static String CHOICE_SEP_PATTERN = Pattern.quote(CHOICE_SEP);
-
- /**
- * The unique id of the action.
- * @see #getId()
- */
- private final String mId;
- /**
- * The UI-visible title of the action.
- */
- private final String mTitle;
-
- /** A URL pointing to an icon, or null */
- private URL mIconUrl;
-
- /**
- * A callback executed when the action is selected in the context menu.
- */
- private final IMenuCallback mCallback;
-
- /**
- * The sorting priority of this item; actions can be sorted according to these
- */
- protected final int mSortPriority;
-
- /**
- * Whether this action supports multiple nodes, see
- * {@link #supportsMultipleNodes()} for details.
- */
- private final boolean mSupportsMultipleNodes;
-
- /**
- * Special value which will insert a separator in the choices' submenu.
- */
- public final static String SEPARATOR = "----";
-
- // Factories
-
- /**
- * Constructs a new separator which will be shown in places where separators
- * are supported such as context menus
- *
- * @param sortPriority a priority used for sorting this action
- * @return a new separator
- */
- @NonNull
- public static Separator createSeparator(int sortPriority) {
- return new Separator(sortPriority, true /* supportsMultipleNodes*/);
- }
-
- /**
- * Constructs a new base {@link RuleAction} with its ID, title and action callback.
- *
- * @param id The unique ID of the action. Must not be null.
- * @param title The title of the action. Must not be null.
- * @param callback The callback executed when the action is selected.
- * Must not be null.
- * @param iconUrl a URL pointing to an icon to use for this action, or null
- * @param sortPriority a priority used for sorting this action
- * @param supportsMultipleNodes whether this action supports multiple nodes,
- * see {@link #supportsMultipleNodes()} for details
- * @return the new {@link RuleAction}
- */
- @NonNull
- public static RuleAction createAction(
- @NonNull String id,
- @NonNull String title,
- @NonNull IMenuCallback callback,
- @Nullable URL iconUrl,
- int sortPriority,
- boolean supportsMultipleNodes) {
- RuleAction action = new RuleAction(id, title, callback, sortPriority,
- supportsMultipleNodes);
- action.setIconUrl(iconUrl);
-
- return action;
- }
-
- /**
- * Creates a new immutable toggle action.
- *
- * @param id The unique id of the action. Cannot be null.
- * @param title The UI-visible title of the context menu item. Cannot be null.
- * @param isChecked Whether the context menu item has a check mark.
- * @param callback A callback to execute when the context menu item is
- * selected.
- * @param iconUrl a URL pointing to an icon to use for this action, or null
- * @param sortPriority a priority used for sorting this action
- * @param supportsMultipleNodes whether this action supports multiple nodes,
- * see {@link #supportsMultipleNodes()} for details
- * @return the new {@link Toggle}
- */
- @NonNull
- public static Toggle createToggle(
- @NonNull String id,
- @NonNull String title,
- boolean isChecked,
- @NonNull IMenuCallback callback,
- @Nullable URL iconUrl,
- int sortPriority,
- boolean supportsMultipleNodes) {
- Toggle toggle = new Toggle(id, title, isChecked, callback, sortPriority,
- supportsMultipleNodes);
- toggle.setIconUrl(iconUrl);
- return toggle;
- }
-
- /**
- * Creates a new immutable multiple-choice action with a defined ordered set
- * of action children.
- *
- * @param id The unique id of the action. Cannot be null.
- * @param title The title of the action to be displayed to the user
- * @param provider Provides the actions to be shown as children of this
- * action
- * @param callback A callback to execute when the context menu item is
- * selected.
- * @param iconUrl the icon to use for the multiple choice action itself
- * @param sortPriority the sorting priority to use for the multiple choice
- * action itself
- * @param supportsMultipleNodes whether this action supports multiple nodes,
- * see {@link #supportsMultipleNodes()} for details
- * @return the new {@link NestedAction}
- */
- @NonNull
- public static NestedAction createChoices(
- @NonNull String id,
- @NonNull String title,
- @NonNull IMenuCallback callback,
- @Nullable URL iconUrl,
- int sortPriority,
- boolean supportsMultipleNodes,
- @NonNull ActionProvider provider) {
- NestedAction choices = new NestedAction(id, title, provider, callback,
- sortPriority, supportsMultipleNodes);
- choices.setIconUrl(iconUrl);
- return choices;
- }
-
- /**
- * Creates a new immutable multiple-choice action with a defined ordered set
- * of children.
- *
- * @param id The unique id of the action. Cannot be null.
- * @param title The title of the action to be displayed to the user
- * @param iconUrls The icon urls for the children items (may be null)
- * @param ids The internal ids for the children
- * @param current The id(s) of the current choice(s) that will be check
- * marked. Can be null. Can be an id not present in the choices
- * map. There can be more than one id separated by
- * {@link #CHOICE_SEP}.
- * @param callback A callback to execute when the context menu item is
- * selected.
- * @param titles The UI-visible titles of the children
- * @param iconUrl the icon to use for the multiple choice action itself
- * @param sortPriority the sorting priority to use for the multiple choice
- * action itself
- * @param supportsMultipleNodes whether this action supports multiple nodes,
- * see {@link #supportsMultipleNodes()} for details
- * @return the new {@link Choices}
- */
- @NonNull
- public static Choices createChoices(
- @NonNull String id,
- @NonNull String title,
- @NonNull IMenuCallback callback,
- @NonNull List<String> titles,
- @Nullable List<URL> iconUrls,
- @NonNull List<String> ids,
- @Nullable String current,
- @Nullable URL iconUrl,
- int sortPriority,
- boolean supportsMultipleNodes) {
- Choices choices = new Choices(id, title, callback, titles, iconUrls,
- ids, current, sortPriority, supportsMultipleNodes);
- choices.setIconUrl(iconUrl);
-
- return choices;
- }
-
- /**
- * Creates a new immutable multiple-choice action with a defined ordered set
- * of children.
- *
- * @param id The unique id of the action. Cannot be null.
- * @param title The title of the action to be displayed to the user
- * @param iconUrls The icon urls for the children items (may be null)
- * @param current The id(s) of the current choice(s) that will be check
- * marked. Can be null. Can be an id not present in the choices
- * map. There can be more than one id separated by
- * {@link #CHOICE_SEP}.
- * @param callback A callback to execute when the context menu item is
- * selected.
- * @param iconUrl the icon to use for the multiple choice action itself
- * @param sortPriority the sorting priority to use for the multiple choice
- * action itself
- * @param supportsMultipleNodes whether this action supports multiple nodes,
- * see {@link #supportsMultipleNodes()} for details
- * @param idsAndTitles a list of pairs (of ids and titles) to use for the
- * menu items
- * @return the new {@link Choices}
- */
- @NonNull
- public static Choices createChoices(
- @NonNull String id,
- @NonNull String title,
- @NonNull IMenuCallback callback,
- @Nullable List<URL> iconUrls,
- @Nullable String current,
- @Nullable URL iconUrl,
- int sortPriority,
- boolean supportsMultipleNodes,
- @NonNull List<Pair<String, String>> idsAndTitles) {
- int itemCount = idsAndTitles.size();
- List<String> titles = new ArrayList<String>(itemCount);
- List<String> ids = new ArrayList<String>(itemCount);
- for (Pair<String, String> pair : idsAndTitles) {
- ids.add(pair.getFirst());
- titles.add(pair.getSecond());
- }
- Choices choices = new Choices(id, title, callback, titles, iconUrls,
- ids, current, sortPriority, supportsMultipleNodes);
- choices.setIconUrl(iconUrl);
- return choices;
- }
-
- /**
- * Creates a new immutable multiple-choice action with lazily computed children.
- *
- * @param id The unique id of the action. Cannot be null.
- * @param title The title of the multiple-choice itself
- * @param callback A callback to execute when the context menu item is
- * selected.
- * @param provider the provider which provides choices lazily
- * @param current The id(s) of the current choice(s) that will be check
- * marked. Can be null. Can be an id not present in the choice
- * alternatives. There can be more than one id separated by
- * {@link #CHOICE_SEP}.
- * @param iconUrl the icon to use for the multiple choice action itself
- * @param sortPriority the sorting priority to use for the multiple choice
- * action itself
- * @param supportsMultipleNodes whether this action supports multiple nodes,
- * see {@link #supportsMultipleNodes()} for details
- * @return the new {@link Choices}
- */
- @NonNull
- public static Choices createChoices(
- @NonNull String id,
- @NonNull String title,
- IMenuCallback callback,
- @NonNull ChoiceProvider provider,
- @Nullable String current,
- @Nullable URL iconUrl,
- int sortPriority,
- boolean supportsMultipleNodes) {
- Choices choices = new DelayedChoices(id, title, callback,
- current, provider, sortPriority, supportsMultipleNodes);
- choices.setIconUrl(iconUrl);
- return choices;
- }
-
- /**
- * Creates a new {@link RuleAction} with the given id and the given title.
- * Actions which have the same id and the same title are deemed equivalent.
- *
- * @param id The unique id of the action, which must be similar for all actions that
- * perform the same task. Cannot be null.
- * @param title The UI-visible title of the action.
- * @param callback A callback to execute when the context menu item is
- * selected.
- * @param sortPriority a priority used for sorting this action
- * @param supportsMultipleNodes the new return value for
- * {@link #supportsMultipleNodes()}
- */
- private RuleAction(
- @NonNull String id,
- @NonNull String title,
- @NonNull IMenuCallback callback,
- int sortPriority,
- boolean supportsMultipleNodes) {
- mId = id;
- mTitle = title;
- mSortPriority = sortPriority;
- mSupportsMultipleNodes = supportsMultipleNodes;
- mCallback = callback;
- }
-
- /**
- * Returns the unique id of the action. In the context of a multiple selection,
- * actions which have the same id are collapsed together and must represent the same
- * action. Cannot be null.
- *
- * @return the unique id of the action, never null
- */
- @NonNull
- public String getId() {
- return mId;
- }
-
- /**
- * Returns the UI-visible title of the action, shown in the context menu.
- * Cannot be null.
- *
- * @return the user name of the action, never null
- */
- @NonNull
- public String getTitle() {
- return mTitle;
- }
-
- /**
- * Actions which have the same id and the same title are deemed equivalent.
- */
- @Override
- public boolean equals(Object obj) {
- if (obj instanceof RuleAction) {
- RuleAction rhs = (RuleAction) obj;
-
- if (mId != rhs.mId && !(mId != null && mId.equals(rhs.mId))) return false;
- if (mTitle != rhs.mTitle &&
- !(mTitle != null && mTitle.equals(rhs.mTitle))) return false;
- return true;
- }
- return false;
- }
-
- /**
- * Whether this action supports multiple nodes. An action which supports
- * multiple nodes can be applied to different nodes by passing in different
- * nodes to its callback. Some actions are hardcoded for a specific node (typically
- * one that isn't selected, such as an action which affects the parent of a selected
- * node), and these actions will not be added to the context menu when more than
- * one node is selected.
- *
- * @return true if this node supports multiple nodes
- */
- public boolean supportsMultipleNodes() {
- return mSupportsMultipleNodes;
- }
-
- /**
- * Actions which have the same id and the same title have the same hash code.
- */
- @Override
- public int hashCode() {
- int h = mId == null ? 0 : mId.hashCode();
- h = h ^ (mTitle == null ? 0 : mTitle.hashCode());
- return h;
- }
-
- /**
- * Gets a URL pointing to an icon to use for this action, if any.
- *
- * @return a URL pointing to an icon to use for this action, or null
- */
- public URL getIconUrl() {
- return mIconUrl;
- }
-
- /**
- * Sets a URL pointing to an icon to use for this action, if any.
- *
- * @param iconUrl a URL pointing to an icon to use for this action, or null
- * @return this action, to allow setter chaining
- */
- @NonNull
- public RuleAction setIconUrl(URL iconUrl) {
- mIconUrl = iconUrl;
-
- return this;
- }
-
- /**
- * Return a priority used for sorting this action
- *
- * @return a priority used for sorting this action
- */
- public int getSortPriority() {
- return mSortPriority;
- }
-
- /**
- * Returns the callback executed when the action is selected in the
- * context menu. Cannot be null.
- *
- * @return the callback, never null
- */
- @NonNull
- public IMenuCallback getCallback() {
- return mCallback;
- }
-
- // Implements Comparable<MenuAction>
- @Override
- public int compareTo(RuleAction other) {
- if (mSortPriority != other.mSortPriority) {
- return mSortPriority - other.mSortPriority;
- }
-
- return mTitle.compareTo(other.mTitle);
- }
-
- @NonNull
- @Override
- public String toString() {
- return "RuleAction [id=" + mId + ", title=" + mTitle + ", priority=" + mSortPriority + "]";
- }
-
- /** A separator to display between actions */
- public static class Separator extends RuleAction {
- /** Construct using the factory {@link #createSeparator(int)} */
- private Separator(int sortPriority, boolean supportsMultipleNodes) {
- super("_separator", "", IMenuCallback.NONE, sortPriority, //$NON-NLS-1$ //$NON-NLS-2$
- supportsMultipleNodes);
- }
- }
-
- /**
- * A toggle is a simple on/off action, displayed as an item in a context menu
- * with a check mark if the item is checked.
- * <p/>
- * Two toggles are equal if they have the same id, title and group-id.
- * It is expected for the checked state and action callback to be different.
- */
- public static class Toggle extends RuleAction {
- /**
- * True if the item is displayed with a check mark.
- */
- private final boolean mIsChecked;
-
- /**
- * Creates a new immutable toggle action.
- *
- * @param id The unique id of the action. Cannot be null.
- * @param title The UI-visible title of the context menu item. Cannot be null.
- * @param isChecked Whether the context menu item has a check mark.
- * @param callback A callback to execute when the context menu item is
- * selected.
- */
- private Toggle(
- @NonNull String id,
- @NonNull String title,
- boolean isChecked,
- @NonNull IMenuCallback callback,
- int sortPriority,
- boolean supportsMultipleNodes) {
- super(id, title, callback, sortPriority, supportsMultipleNodes);
- mIsChecked = isChecked;
- }
-
- /**
- * Returns true if the item is displayed with a check mark.
- *
- * @return true if the item is displayed with a check mark.
- */
- public boolean isChecked() {
- return mIsChecked;
- }
-
- /**
- * Two toggles are equal if they have the same id and title.
- * It is acceptable for the checked state and action callback to be different.
- */
- @Override
- public boolean equals(Object obj) {
- return super.equals(obj);
- }
-
- /**
- * Two toggles have the same hash code if they have the same id and title.
- */
- @Override
- public int hashCode() {
- return super.hashCode();
- }
- }
-
- /**
- * An ordered list of choices the user can choose between. For choosing between
- * actions, there is a {@link NestedAction} class.
- */
- public static class Choices extends RuleAction {
- protected List<String> mTitles;
- protected List<URL> mIconUrls;
- protected List<String> mIds;
- private boolean mRadio;
-
- /**
- * One or more id for the checked choice(s) that will be check marked.
- * Can be null. Can be an id not present in the choices map.
- */
- protected final String mCurrent;
-
- private Choices(
- @NonNull String id,
- @NonNull String title,
- @NonNull IMenuCallback callback,
- @NonNull List<String> titles,
- @Nullable List<URL> iconUrls,
- @NonNull List<String> ids,
- @Nullable String current,
- int sortPriority,
- boolean supportsMultipleNodes) {
- super(id, title, callback, sortPriority, supportsMultipleNodes);
- mTitles = titles;
- mIconUrls = iconUrls;
- mIds = ids;
- mCurrent = current;
- }
-
- /**
- * Returns the list of urls to icons to display for each choice, or null
- *
- * @return the list of urls to icons to display for each choice, or null
- */
- @Nullable
- public List<URL> getIconUrls() {
- return mIconUrls;
- }
-
- /**
- * Returns the list of ids for the menu choices, never null
- *
- * @return the list of ids for the menu choices, never null
- */
- @NonNull
- public List<String> getIds() {
- return mIds;
- }
-
- /**
- * Returns the titles to be displayed for the menu choices, never null
- *
- * @return the titles to be displayed for the menu choices, never null
- */
- @NonNull
- public List<String> getTitles() {
- return mTitles;
- }
-
- /**
- * Returns the current value of the choice
- *
- * @return the current value of the choice, possibly null
- */
- @Nullable
- public String getCurrent() {
- return mCurrent;
- }
-
- /**
- * Set whether this choice list is best visualized as a radio group (instead of a
- * dropdown)
- *
- * @param radio true if this choice list should be visualized as a radio group
- */
- public void setRadio(boolean radio) {
- mRadio = radio;
- }
-
- /**
- * Returns true if this choice list is best visualized as a radio group (instead
- * of a dropdown)
- *
- * @return true if this choice list should be visualized as a radio group
- */
- public boolean isRadio() {
- return mRadio;
- }
- }
-
- /**
- * An ordered list of actions the user can choose between. Similar to
- * {@link Choices} but for actions instead.
- */
- public static class NestedAction extends RuleAction {
- /** The provider to produce the list of nested actions when needed */
- private final ActionProvider mProvider;
-
- private NestedAction(
- @NonNull String id,
- @NonNull String title,
- @NonNull ActionProvider provider,
- @NonNull IMenuCallback callback,
- int sortPriority,
- boolean supportsMultipleNodes) {
- super(id, title, callback, sortPriority, supportsMultipleNodes);
- mProvider = provider;
- }
-
- /**
- * Returns the nested actions available for the given node
- *
- * @param node the node to look up nested actions for
- * @return a list of nested actions
- */
- @NonNull
- public List<RuleAction> getNestedActions(@NonNull INode node) {
- return mProvider.getNestedActions(node);
- }
- }
-
- /** Like {@link Choices}, but the set of choices is computed lazily */
- private static class DelayedChoices extends Choices {
- private final ChoiceProvider mProvider;
- private boolean mInitialized;
-
- private DelayedChoices(
- @NonNull String id,
- @NonNull String title,
- @NonNull IMenuCallback callback,
- @Nullable String current,
- @NonNull ChoiceProvider provider,
- int sortPriority, boolean supportsMultipleNodes) {
- super(id, title, callback, new ArrayList<String>(), new ArrayList<URL>(),
- new ArrayList<String>(), current, sortPriority, supportsMultipleNodes);
- mProvider = provider;
- }
-
- private void ensureInitialized() {
- if (!mInitialized) {
- mInitialized = true;
- mProvider.addChoices(mTitles, mIconUrls, mIds);
- }
- }
-
- @Override
- public List<URL> getIconUrls() {
- ensureInitialized();
- return mIconUrls;
- }
-
- @Override
- public @NonNull List<String> getIds() {
- ensureInitialized();
- return mIds;
- }
-
- @Override
- public @NonNull List<String> getTitles() {
- ensureInitialized();
- return mTitles;
- }
- }
-
- /**
- * Provides the set of nested action choices associated with a {@link NestedAction}
- * object when they are needed. Useful for lazy initialization of context
- * menus and popup menus until they are actually needed.
- */
- public interface ActionProvider {
- /**
- * Returns the nested actions available for the given node
- *
- * @param node the node to look up nested actions for
- * @return a list of nested actions
- */
- @NonNull
- public List<RuleAction> getNestedActions(@NonNull INode node);
- }
-
- /**
- * Provides the set of choices associated with an {@link Choices}
- * object when they are needed. Useful for lazy initialization of context
- * menus and popup menus until they are actually needed.
- */
- public interface ChoiceProvider {
- /**
- * Adds in the needed titles, iconUrls (if any) and ids.
- * Use {@link RuleAction#SEPARATOR} to create separators.
- *
- * @param titles a list of titles that the provider should append to
- * @param iconUrls a list of icon URLs that the provider should append to
- * @param ids a list of ids that the provider should append to
- */
- public void addChoices(
- @NonNull List<String> titles,
- @NonNull List<URL> iconUrls,
- @NonNull List<String> ids);
- }
-}
diff --git a/rule_api/src/com/android/ide/common/api/Segment.java b/rule_api/src/com/android/ide/common/api/Segment.java
deleted file mode 100644
index d31d9f8..0000000
--- a/rule_api/src/com/android/ide/common/api/Segment.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.google.common.annotations.Beta;
-
-/**
- * A segment is a straight horizontal or vertical line between two points, typically an
- * edge of a node but also possibly some internal segment like a baseline or a center
- * line, and it can be offset by a margin from the node's visible bounds.
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- */
-@Beta
-public class Segment {
- /** For horizontal lines, the y coordinate; for vertical lines the x */
- public final int at;
-
- /** The starting coordinate along the line */
- public final int from;
-
- /** The ending coordinate along the line */
- public final int to;
-
- /** Whether the edge is a top edge, a baseline edge, a left edge, etc */
- @NonNull
- public final SegmentType edgeType;
-
- /**
- * Whether the edge is offset from the node by a margin or not, or whether it has no
- * margin
- */
- @NonNull
- public final MarginType marginType;
-
- /** The node that contains this edge */
- @Nullable
- public final INode node;
-
- /**
- * The id of the node. May be null (in which case id should be generated when
- * move/resize is completed
- */
- @Nullable
- public final String id;
-
- public Segment(int at, int from, int to, @Nullable INode node, @Nullable String id,
- @NonNull SegmentType edgeType, @NonNull MarginType marginType) {
- this.at = at;
- this.from = from;
- this.to = to;
- this.node = node;
- this.id = id;
- this.edgeType = edgeType;
- this.marginType = marginType;
- }
-
- @NonNull
- @Override
- public String toString() {
- String nodeStr = node == null ? "null" : node.getFqcn().substring(
- node.getFqcn().lastIndexOf(('.')) + 1);
- return "Segment [edgeType=" + edgeType + ", node=" + nodeStr + ", at=" + at + ", id=" + id
- + ", from=" + from + ", to=" + to + ", marginType=" + marginType + "]";
- }
-}
diff --git a/rule_api/src/com/android/ide/common/api/SegmentType.java b/rule_api/src/com/android/ide/common/api/SegmentType.java
deleted file mode 100644
index 9da248a..0000000
--- a/rule_api/src/com/android/ide/common/api/SegmentType.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.ide.common.api;
-
-import com.android.annotations.NonNull;
-import com.android.annotations.Nullable;
-import com.google.common.annotations.Beta;
-
-/** A segment type describes the different roles or positions a segment can have in a node
- * <p>
- * <b>NOTE: This is not a public or final API; if you rely on this be prepared
- * to adjust your code for the next tools release.</b>
- */
-@Beta
-public enum SegmentType {
- /** Segment is on the left edge */
- @NonNull LEFT,
- /** Segment is on the top edge */
- @NonNull TOP,
- /** Segment is on the right edge */
- @NonNull RIGHT,
- /** Segment is on the bottom edge */
- @NonNull BOTTOM,
- /** Segment is along the baseline */
- @NonNull BASELINE,
- /** Segment is along the center vertically */
- @NonNull CENTER_VERTICAL,
- /** Segment is along the center horizontally */
- @NonNull CENTER_HORIZONTAL,
- /** Segment is on an unknown edge */
- @NonNull UNKNOWN;
-
- public boolean isHorizontal() {
- return this == TOP || this == BOTTOM || this == BASELINE || this == CENTER_HORIZONTAL;
- }
-
- /**
- * Returns the X coordinate for an edge of this type given its bounds
- *
- * @param node the node containing the edge
- * @param bounds the bounds of the node
- * @return the X coordinate for an edge of this type given its bounds
- */
- public int getX(@Nullable INode node, @NonNull Rect bounds) {
- // We pass in the bounds rather than look it up via node.getBounds() because
- // during a resize or move operation, we call this method to look up proposed
- // bounds rather than actual bounds
- switch (this) {
- case RIGHT:
- return bounds.x + bounds.w;
- case TOP:
- case BOTTOM:
- case CENTER_VERTICAL:
- return bounds.x + bounds.w / 2;
- case UNKNOWN:
- assert false;
- return bounds.x;
- case LEFT:
- case BASELINE:
- default:
- return bounds.x;
- }
- }
-
- /**
- * Returns the Y coordinate for an edge of this type given its bounds
- *
- * @param node the node containing the edge
- * @param bounds the bounds of the node
- * @return the Y coordinate for an edge of this type given its bounds
- */
- public int getY(@Nullable INode node, @NonNull Rect bounds) {
- switch (this) {
- case TOP:
- return bounds.y;
- case BOTTOM:
- return bounds.y + bounds.h;
- case BASELINE: {
- int baseline = node != null ? node.getBaseline() : -1;
- if (node == null) {
- // This happens when you are dragging an element and we don't have
- // a node (only an IDragElement) such as on a palette drag.
- // For now just hack it.
- baseline = (int) (bounds.h * 0.8f); // HACK
- }
- return bounds.y + baseline;
- }
- case UNKNOWN:
- assert false;
- return bounds.y;
- case RIGHT:
- case LEFT:
- case CENTER_HORIZONTAL:
- default:
- return bounds.y + bounds.h / 2;
- }
- }
-
- @Override
- public String toString() {
- return name();
- }
-}
diff --git a/screenshot/.classpath b/screenshot/.classpath
deleted file mode 100644
index b0326c8..0000000
--- a/screenshot/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/screenshot/.gitignore b/screenshot/.gitignore
deleted file mode 100644
index ba077a4..0000000
--- a/screenshot/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/screenshot/.project b/screenshot/.project
deleted file mode 100644
index f5d3f51..0000000
--- a/screenshot/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>screenshot</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/screenshot/Android.mk b/screenshot/Android.mk
deleted file mode 100644
index 7cf9090..0000000
--- a/screenshot/Android.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-SCREENSHOT2_LOCAL_DIR := $(call my-dir)
-include $(SCREENSHOT2_LOCAL_DIR)/etc/Android.mk
-include $(SCREENSHOT2_LOCAL_DIR)/src/Android.mk
diff --git a/screenshot/NOTICE b/screenshot/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/screenshot/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/screenshot/etc/Android.mk b/screenshot/etc/Android.mk
deleted file mode 100644
index 5107535..0000000
--- a/screenshot/etc/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_PREBUILT_EXECUTABLES := screenshot2
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/screenshot/etc/manifest.txt b/screenshot/etc/manifest.txt
deleted file mode 100644
index f52874a..0000000
--- a/screenshot/etc/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Main-Class: com.android.screenshot.Screenshot
diff --git a/screenshot/etc/screenshot2 b/screenshot/etc/screenshot2
deleted file mode 100755
index 10b921a..0000000
--- a/screenshot/etc/screenshot2
+++ /dev/null
@@ -1,74 +0,0 @@
-#!/bin/sh
-# Copyright 2005-2007, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
- newProg=`/bin/ls -ld "${prog}"`
- newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
- if expr "x${newProg}" : 'x/' >/dev/null; then
- prog="${newProg}"
- else
- progdir=`dirname "${prog}"`
- prog="${progdir}/${newProg}"
- fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/`basename "${prog}"`
-cd "${oldwd}"
-
-jarfile=screenshot2.jar
-frameworkdir="$progdir"
-libdir="$progdir"
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/tools/lib
- libdir=`dirname "$progdir"`/tools/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/framework
- libdir=`dirname "$progdir"`/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- echo `basename "$prog"`": can't find $jarfile"
- exit 1
-fi
-
-
-# Check args.
-if [ debug = "$1" ]; then
- # add this in for debugging
- java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
- shift 1
-else
- java_debug=
-fi
-
-if [ "$OSTYPE" = "cygwin" ] ; then
- jarpath=`cygpath -w "$frameworkdir/$jarfile"`
- progdir=`cygpath -w "$progdir"`
-else
- jarpath="$frameworkdir/$jarfile"
-fi
-
-# need to use "java.ext.dirs" because "-jar" causes classpath to be ignored
-# might need more memory, e.g. -Xmx128M
-exec java -Xmx128M $os_opts $java_debug -Djava.ext.dirs="$frameworkdir" -Djava.library.path="$libdir" -Dcom.android.screenshot.bindir="$progdir" -jar "$jarpath" "$@"
diff --git a/screenshot/src/Android.mk b/screenshot/src/Android.mk
deleted file mode 100644
index 8b5ea3a..0000000
--- a/screenshot/src/Android.mk
+++ /dev/null
@@ -1,27 +0,0 @@
-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-
-LOCAL_JAR_MANIFEST := ../etc/manifest.txt
-LOCAL_JAVA_LIBRARIES := \
- ddmlib
-LOCAL_MODULE := screenshot2
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
diff --git a/screenshot/src/com/android/screenshot/Screenshot.java b/screenshot/src/com/android/screenshot/Screenshot.java
deleted file mode 100644
index d93e6ff..0000000
--- a/screenshot/src/com/android/screenshot/Screenshot.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.screenshot;
-
-import com.android.ddmlib.AndroidDebugBridge;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.Log;
-import com.android.ddmlib.RawImage;
-import com.android.ddmlib.TimeoutException;
-import com.android.ddmlib.Log.ILogOutput;
-import com.android.ddmlib.Log.LogLevel;
-
-import java.awt.image.BufferedImage;
-import java.io.File;
-import java.io.IOException;
-
-import javax.imageio.ImageIO;
-
-/**
- * Connects to a device using ddmlib and dumps its event log as long as the device is connected.
- */
-public class Screenshot {
-
- public static void main(String[] args) {
- boolean device = false;
- boolean emulator = false;
- String serial = null;
- String filepath = null;
- boolean landscape = false;
-
- if (args.length == 0) {
- printUsageAndQuit();
- }
-
- // parse command line parameters.
- int index = 0;
- do {
- String argument = args[index++];
-
- if ("-d".equals(argument)) {
- if (emulator || serial != null) {
- printAndExit("-d conflicts with -e and -s", false /* terminate */);
- }
- device = true;
- } else if ("-e".equals(argument)) {
- if (device || serial != null) {
- printAndExit("-e conflicts with -d and -s", false /* terminate */);
- }
- emulator = true;
- } else if ("-s".equals(argument)) {
- // quick check on the next argument.
- if (index == args.length) {
- printAndExit("Missing serial number after -s", false /* terminate */);
- }
-
- if (device || emulator) {
- printAndExit("-s conflicts with -d and -e", false /* terminate */);
- }
-
- serial = args[index++];
- } else if ("-l".equals(argument)) {
- landscape = true;
- } else {
- // get the filepath and break.
- filepath = argument;
-
- // should not be any other device.
- if (index < args.length) {
- printAndExit("Too many arguments!", false /* terminate */);
- }
- }
- } while (index < args.length);
-
- /*
- * If no command-line switches and no serial number was passed on the
- * command-line, try to read a serial number from the shell environment.
- */
- if (!device && !emulator && serial == null) {
- String envSerial = System.getenv("ANDROID_SERIAL");
- if (envSerial != null) {
- serial = envSerial;
- }
- }
-
- if (filepath == null) {
- printUsageAndQuit();
- }
-
- Log.setLogOutput(new ILogOutput() {
- public void printAndPromptLog(LogLevel logLevel, String tag, String message) {
- System.err.println(logLevel.getStringValue() + ":" + tag + ":" + message);
- }
-
- public void printLog(LogLevel logLevel, String tag, String message) {
- System.err.println(logLevel.getStringValue() + ":" + tag + ":" + message);
- }
- });
-
- // init the lib
- // [try to] ensure ADB is running
- String adbLocation = System.getProperty("com.android.screenshot.bindir"); //$NON-NLS-1$
- if (adbLocation != null && adbLocation.length() != 0) {
- adbLocation += File.separator + "adb"; //$NON-NLS-1$
- } else {
- adbLocation = "adb"; //$NON-NLS-1$
- }
-
- AndroidDebugBridge.init(false /* debugger support */);
-
- try {
- AndroidDebugBridge bridge = AndroidDebugBridge.createBridge(
- adbLocation, true /* forceNewBridge */);
-
- // we can't just ask for the device list right away, as the internal thread getting
- // them from ADB may not be done getting the first list.
- // Since we don't really want getDevices() to be blocking, we wait here manually.
- int count = 0;
- while (bridge.hasInitialDeviceList() == false) {
- try {
- Thread.sleep(100);
- count++;
- } catch (InterruptedException e) {
- // pass
- }
-
- // let's not wait > 10 sec.
- if (count > 100) {
- System.err.println("Timeout getting device list!");
- return;
- }
- }
-
- // now get the devices
- IDevice[] devices = bridge.getDevices();
-
- if (devices.length == 0) {
- printAndExit("No devices found!", true /* terminate */);
- }
-
- IDevice target = null;
-
- if (emulator || device) {
- for (IDevice d : devices) {
- // this test works because emulator and device can't both be true at the same
- // time.
- if (d.isEmulator() == emulator) {
- // if we already found a valid target, we print an error and return.
- if (target != null) {
- if (emulator) {
- printAndExit("Error: more than one emulator launched!",
- true /* terminate */);
- } else {
- printAndExit("Error: more than one device connected!",true /* terminate */);
- }
- }
- target = d;
- }
- }
- } else if (serial != null) {
- for (IDevice d : devices) {
- if (serial.equals(d.getSerialNumber())) {
- target = d;
- break;
- }
- }
- } else {
- if (devices.length > 1) {
- printAndExit("Error: more than one emulator or device available!",
- true /* terminate */);
- }
- target = devices[0];
- }
-
- if (target != null) {
- try {
- System.out.println("Taking screenshot from: " + target.getSerialNumber());
- getDeviceImage(target, filepath, landscape);
- System.out.println("Success.");
- } catch (IOException e) {
- e.printStackTrace();
- }
- } else {
- printAndExit("Could not find matching device/emulator.", true /* terminate */);
- }
- } finally {
- AndroidDebugBridge.terminate();
- }
- }
-
- /*
- * Grab an image from an ADB-connected device.
- */
- private static void getDeviceImage(IDevice device, String filepath, boolean landscape)
- throws IOException {
- RawImage rawImage;
-
- try {
- rawImage = device.getScreenshot();
- } catch (TimeoutException e) {
- printAndExit("Unable to get frame buffer: timeout", true /* terminate */);
- return;
- } catch (Exception ioe) {
- printAndExit("Unable to get frame buffer: " + ioe.getMessage(), true /* terminate */);
- return;
- }
-
- // device/adb not available?
- if (rawImage == null)
- return;
-
- if (landscape) {
- rawImage = rawImage.getRotated();
- }
-
- // convert raw data to an Image
- BufferedImage image = new BufferedImage(rawImage.width, rawImage.height,
- BufferedImage.TYPE_INT_ARGB);
-
- int index = 0;
- int IndexInc = rawImage.bpp >> 3;
- for (int y = 0 ; y < rawImage.height ; y++) {
- for (int x = 0 ; x < rawImage.width ; x++) {
- int value = rawImage.getARGB(index);
- index += IndexInc;
- image.setRGB(x, y, value);
- }
- }
-
- if (!ImageIO.write(image, "png", new File(filepath))) {
- throw new IOException("Failed to find png writer");
- }
- }
-
- private static void printUsageAndQuit() {
- // 80 cols marker: 01234567890123456789012345678901234567890123456789012345678901234567890123456789
- System.out.println("Usage: screenshot2 [-d | -e | -s SERIAL] [-l] OUT_FILE");
- System.out.println("");
- System.out.println(" -d Uses the first device found.");
- System.out.println(" -e Uses the first emulator found.");
- System.out.println(" -s Targets the device by serial number.");
- System.out.println("");
- System.out.println(" -l Rotate images for landscape mode.");
- System.out.println("");
-
- System.exit(1);
- }
-
- private static void printAndExit(String message, boolean terminate) {
- System.out.println(message);
- if (terminate) {
- AndroidDebugBridge.terminate();
- }
- System.exit(1);
- }
-}
diff --git a/sdk_common/.classpath b/sdk_common/.classpath
deleted file mode 100644
index e5bbc54..0000000
--- a/sdk_common/.classpath
+++ /dev/null
@@ -1,11 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/layoutlib_api"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/misc/common/kxml2/kxml2-2.3.0.jar" sourcepath="/ANDROID_SRC/dalvik/libcore/xml/src/main/java"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src.zip"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry combineaccessrules="false" kind="src" path="/sdklib"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/sdk_common/.gitignore b/sdk_common/.gitignore
deleted file mode 100644
index fe99505..0000000
--- a/sdk_common/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-bin
-
diff --git a/sdk_common/.project b/sdk_common/.project
deleted file mode 100644
index ea6146d..0000000
--- a/sdk_common/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>sdk_common</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/sdk_common/.settings/org.eclipse.jdt.core.prefs b/sdk_common/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/sdk_common/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/sdk_common/.settings/org.moreunit.prefs b/sdk_common/.settings/org.moreunit.prefs
deleted file mode 100644
index b1e7a57..0000000
--- a/sdk_common/.settings/org.moreunit.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-eclipse.preferences.version=1
-org.moreunit.prefixes=
-org.moreunit.unitsourcefolder=sdk_common\:src\:sdk_common-tests\:src
-org.moreunit.useprojectsettings=true
diff --git a/sdk_common/Android.mk b/sdk_common/Android.mk
deleted file mode 100644
index 1550052..0000000
--- a/sdk_common/Android.mk
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# The sdk_common code has moved to tools/base/sdk_common.
-# The rule below uses the prebuilt sdk_common.jar.
-#
-# If you want to run the tests, cd to tools/base/sdk_common
-# and run ./gradlew :sdk_common:test
-
-LOCAL_JAVA_LIBRARIES := \
- layoutlib_api \
- common \
- kxml2-2.3.0 \
- guava-tools \
- sdklib
-
-LOCAL_MODULE := sdk_common
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PREBUILT_JAVA_LIBRARIES := \
- ../../prebuilts/devtools/tools/lib/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/sdk_common/NOTICE b/sdk_common/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/sdk_common/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/sdkmanager/.gitignore b/sdkmanager/.gitignore
deleted file mode 100644
index 7c578b4..0000000
--- a/sdkmanager/.gitignore
+++ /dev/null
@@ -1,7 +0,0 @@
-/app/bin
-/build
-/libs/build
-/libs/sdklib/bin
-/libs/sdklib/build
-/libs/sdkuilib/bin
-
diff --git a/sdkmanager/Android.mk b/sdkmanager/Android.mk
deleted file mode 100644
index fdc9968..0000000
--- a/sdkmanager/Android.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-SDKMANAGER_LOCAL_DIR := $(call my-dir)
-include $(SDKMANAGER_LOCAL_DIR)/app/Android.mk
-include $(SDKMANAGER_LOCAL_DIR)/libs/Android.mk
-
diff --git a/sdkmanager/MODULE_LICENSE_APACHE2 b/sdkmanager/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/sdkmanager/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/sdkmanager/app/.classpath b/sdkmanager/app/.classpath
deleted file mode 100644
index 98cdeb1..0000000
--- a/sdkmanager/app/.classpath
+++ /dev/null
@@ -1,16 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry excluding="**/Android.mk" kind="src" path="src/main/java"/>
- <classpathentry excluding="**/Android.mk" kind="src" path="src/test/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/sdklib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/sdkuilib"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/swt.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.core.commands_3.6.0.I20100512-1500.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.equinox.common_3.6.0.v20100503.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.jface_3.6.2.M20110210-1200.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/sdkmanager/app/.project b/sdkmanager/app/.project
deleted file mode 100644
index aa82db5..0000000
--- a/sdkmanager/app/.project
+++ /dev/null
@@ -1,19 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>SdkManager</name>
- <comment></comment>
- <projects>
- <project>SdkLib</project>
- <project>SdkUiLib</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/sdkmanager/app/.settings/org.eclipse.jdt.core.prefs b/sdkmanager/app/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/sdkmanager/app/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/sdkmanager/app/Android.mk b/sdkmanager/app/Android.mk
deleted file mode 100644
index 428b8a0..0000000
--- a/sdkmanager/app/Android.mk
+++ /dev/null
@@ -1,72 +0,0 @@
-# Copyright 2007 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-ORIG_LOCAL_PATH := $(call my-dir)
-LOCAL_PATH := $(ORIG_LOCAL_PATH)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src/main/java)
-LOCAL_JAVA_RESOURCE_DIRS := src/main/java
-
-LOCAL_JAR_MANIFEST := etc/manifest.txt
-
-# IMPORTANT: if you add a new dependency here, please make sure
-# to also check the following files:
-# sdkmanager/app/etc/manifest.txt
-# sdkmanager/app/etc/android.bat
-# (Note that we don't reference swt.jar in these files since
-# it is dynamically added by android.bat/.sh based on whether the
-# current VM is 32 or 64 bit.)
-LOCAL_JAVA_LIBRARIES := \
- common \
- guava-tools \
- sdklib \
- sdkuilib \
- swt \
- org.eclipse.jface_3.6.2.M20110210-1200 \
- org.eclipse.equinox.common_3.6.0.v20100503 \
- org.eclipse.core.commands_3.6.0.I20100512-1500
-
-LOCAL_MODULE := sdkmanager
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-# Build all sub-directories
-include $(call all-makefiles-under,$(LOCAL_PATH))
-
-
-# ----- TESTS ------
-# Copyright (C) 2011 The Android Open Source Project
-
-LOCAL_PATH := $(ORIG_LOCAL_PATH)
-include $(CLEAR_VARS)
-
-# Only compile source java files in this lib.
-LOCAL_SRC_FILES := $(call all-java-files-under, src/test/java)
-
-LOCAL_MODULE := sdkmanager-tests
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_JAVA_LIBRARIES := \
- guava-tools \
- httpclient-4.1.1 \
- httpcore-4.1 \
- httpmime-4.1.1 \
- junit \
- sdkmanager \
- sdklib
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
diff --git a/sdkmanager/app/NOTICE b/sdkmanager/app/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/sdkmanager/app/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/sdkmanager/app/etc/Android.mk b/sdkmanager/app/etc/Android.mk
deleted file mode 100644
index 8e3786e..0000000
--- a/sdkmanager/app/etc/Android.mk
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2008 The Android Open Source Project
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_PREBUILT_EXECUTABLES := android
-LOCAL_MODULE_TAGS := optional
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/sdkmanager/app/etc/android b/sdkmanager/app/etc/android
deleted file mode 100755
index f186ebb..0000000
--- a/sdkmanager/app/etc/android
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/bin/sh
-# Copyright 2005-2007, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
- newProg=`/bin/ls -ld "${prog}"`
- newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
- if expr "x${newProg}" : 'x/' >/dev/null; then
- prog="${newProg}"
- else
- progdir=`dirname "${prog}"`
- prog="${progdir}/${newProg}"
- fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/`basename "${prog}"`
-cd "${oldwd}"
-
-jarfile=sdkmanager.jar
-frameworkdir="$progdir"
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/tools/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/framework
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- echo `basename "$prog"`": can't find $jarfile"
- exit 1
-fi
-
-
-# Check args.
-if [ debug = "$1" ]; then
- # add this in for debugging
- java_debug=-agentlib:jdwp=transport=dt_socket,server=y,address=8050,suspend=y
- shift 1
-else
- java_debug=
-fi
-
-java_cmd="java"
-
-# Mac OS X needs an additional arg, or you get an "illegal thread" complaint.
-if [ `uname` = "Darwin" ]; then
- os_opts="-XstartOnFirstThread"
-else
- os_opts=
-fi
-
-if [ `uname` = "Linux" ]; then
- export GDK_NATIVE_WINDOWS=true
-fi
-
-if [ "$OSTYPE" = "cygwin" ] ; then
- jarpath=`cygpath -w "$frameworkdir/$jarfile"`
- jarpath="$jarpath;"`cygpath -w "$frameworkdir/swtmenubar.jar"`
- progdir=`cygpath -w "$progdir"`
-else
- jarpath="$frameworkdir/$jarfile:$frameworkdir/swtmenubar.jar"
-fi
-
-# Get the current content of java.ext.dirs so that we can add to it instead of replacing
-javaExtDirs=`"${java_cmd}" -jar "${frameworkdir}/archquery.jar" java.ext.dirs`
-
-# Figure out the path to the swt.jar for the current architecture.
-# if ANDROID_SWT is defined, then just use this.
-# else, if running in the Android source tree, then look for the correct swt folder in prebuilt
-# else, look for the correct swt folder in the SDK under tools/lib/
-swtpath=""
-if [ -n "$ANDROID_SWT" ]; then
- swtpath="$ANDROID_SWT"
-else
- vmarch=`"${java_cmd}" -jar "${frameworkdir}/archquery.jar"`
- if [ -n "$ANDROID_BUILD_TOP" ]; then
- osname=`uname -s | tr A-Z a-z`
- swtpath="${ANDROID_BUILD_TOP}/prebuilts/tools/${osname}-${vmarch}/swt"
- else
- swtpath="${frameworkdir}/${vmarch}"
- fi
-fi
-
-if [ ! -d "$swtpath" ]; then
- echo "SWT folder '${swtpath}' does not exist."
- echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform."
- exit 1
-fi
-
-# need to use "java.ext.dirs" because "-jar" causes classpath to be ignored
-exec "$java_cmd" \
- -Xmx256M $os_opts $java_debug \
- -Dcom.android.sdkmanager.toolsdir="$progdir" \
- -classpath "$jarpath:$swtpath/swt.jar" \
- com.android.sdkmanager.Main "$@"
diff --git a/sdkmanager/app/etc/android.bat b/sdkmanager/app/etc/android.bat
deleted file mode 100755
index 222ea88..0000000
--- a/sdkmanager/app/etc/android.bat
+++ /dev/null
@@ -1,84 +0,0 @@
-@echo off
-rem Copyright (C) 2007 The Android Open Source Project
-rem
-rem Licensed under the Apache License, Version 2.0 (the "License");
-rem you may not use this file except in compliance with the License.
-rem You may obtain a copy of the License at
-rem
-rem http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-
-rem Useful links:
-rem Command-line reference:
-rem http://technet.microsoft.com/en-us/library/bb490890.aspx
-
-rem don't modify the caller's environment
-setlocal
-
-rem Set up prog to be the path of this script, including following symlinks,
-rem and set up progdir to be the fully-qualified pathname of its directory.
-set prog=%~f0
-
-rem Grab current directory before we change it
-set work_dir="%cd%"
-
-rem Change current directory and drive to where the script is, to avoid
-rem issues with directories containing whitespaces.
-cd /d %~dp0
-
-
-rem Check we have a valid Java.exe in the path.
-set java_exe=
-call lib\find_java.bat
-if not defined java_exe goto :EOF
-
-set jar_path=lib\sdkmanager.jar;lib\swtmenubar.jar
-
-rem Set SWT.Jar path based on current architecture (x86 or x86_64)
-for /f %%a in ('%java_exe% -jar lib\archquery.jar') do set swt_path=lib\%%a
-
-:MkTempCopy
- rem Copy android.bat and its required libs to a temp dir.
- rem This avoids locking the tool dir in case the user is trying to update it.
-
- set tmp_dir=%TEMP%\temp-android-tool
- xcopy %swt_path% %tmp_dir%\%swt_path% /I /E /C /G /R /Y /Q > nul
- copy /B /D /Y lib\common.jar %tmp_dir%\lib\ > nul
- copy /B /D /Y lib\commons-codec* %tmp_dir%\lib\ > nul
- copy /B /D /Y lib\commons-compress* %tmp_dir%\lib\ > nul
- copy /B /D /Y lib\commons-logging* %tmp_dir%\lib\ > nul
- copy /B /D /Y lib\dvlib.jar %tmp_dir%\lib\ > nul
- copy /B /D /Y lib\guava* %tmp_dir%\lib\ > nul
- copy /B /D /Y lib\httpclient* %tmp_dir%\lib\ > nul
- copy /B /D /Y lib\httpcore* %tmp_dir%\lib\ > nul
- copy /B /D /Y lib\httpmime* %tmp_dir%\lib\ > nul
- copy /B /D /Y lib\layoutlib_api.jar %tmp_dir%\lib\ > nul
- copy /B /D /Y lib\org.eclipse.* %tmp_dir%\lib\ > nul
- copy /B /D /Y lib\sdk* %tmp_dir%\lib\ > nul
- copy /B /D /Y lib\swtmenubar.jar %tmp_dir%\lib\ > nul
-
- rem jar_path and swt_path are relative to PWD so we don't need to adjust them, just change dirs.
- set tools_dir=%cd%
- cd /d %tmp_dir%
-
-:EndTempCopy
-
-rem The global ANDROID_SWT always override the SWT.Jar path
-if defined ANDROID_SWT set swt_path=%ANDROID_SWT%
-
-if exist %swt_path% goto SetPath
- echo ERROR: SWT folder '%swt_path%' does not exist.
- echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
- goto :EOF
-
-:SetPath
-rem Finally exec the java program and end here.
-REM set REMOTE_DEBUG=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
-call %java_exe% %REMOTE_DEBUG% -Dcom.android.sdkmanager.toolsdir="%tools_dir%" -Dcom.android.sdkmanager.workdir=%work_dir% -classpath "%jar_path%;%swt_path%\swt.jar" com.android.sdkmanager.Main %*
-
-rem EOF
diff --git a/sdkmanager/app/etc/manifest.txt b/sdkmanager/app/etc/manifest.txt
deleted file mode 100644
index 44be3b8..0000000
--- a/sdkmanager/app/etc/manifest.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Main-Class: com.android.sdkmanager.Main
-Class-Path: common.jar sdklib.jar sdkuilib.jar swtmenubar.jar org.eclipse.jface_3.6.2.M20110210-1200.jar org.eclipse.equinox.common_3.6.0.v20100503.jar org.eclipse.core.commands_3.6.0.I20100512-1500.jar guava-tools.jar
diff --git a/sdkmanager/app/src/main/java/com/android/sdkmanager/Main.java b/sdkmanager/app/src/main/java/com/android/sdkmanager/Main.java
deleted file mode 100644
index 0ef18b8..0000000
--- a/sdkmanager/app/src/main/java/com/android/sdkmanager/Main.java
+++ /dev/null
@@ -1,1617 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.sdkmanager;
-
-import com.android.SdkConstants;
-import com.android.annotations.NonNull;
-import com.android.annotations.VisibleForTesting;
-import com.android.annotations.VisibleForTesting.Visibility;
-import com.android.io.FileWrapper;
-import com.android.prefs.AndroidLocation;
-import com.android.prefs.AndroidLocation.AndroidLocationException;
-import com.android.sdklib.IAndroidTarget;
-import com.android.sdklib.IAndroidTarget.IOptionalLibrary;
-import com.android.sdklib.ISystemImage;
-import com.android.sdklib.SdkManager;
-import com.android.sdklib.internal.avd.AvdInfo;
-import com.android.sdklib.internal.avd.AvdManager;
-import com.android.sdklib.internal.avd.HardwareProperties;
-import com.android.sdklib.internal.avd.HardwareProperties.HardwareProperty;
-import com.android.sdklib.internal.project.ProjectCreator;
-import com.android.sdklib.internal.project.ProjectCreator.OutputLevel;
-import com.android.sdklib.internal.project.ProjectProperties;
-import com.android.sdklib.internal.project.ProjectProperties.PropertyType;
-import com.android.sdklib.internal.project.ProjectPropertiesWorkingCopy;
-import com.android.sdklib.internal.repository.DownloadCache;
-import com.android.sdklib.internal.repository.DownloadCache.Strategy;
-import com.android.sdklib.internal.repository.packages.PlatformToolPackage;
-import com.android.sdklib.internal.repository.packages.ToolPackage;
-import com.android.sdklib.internal.repository.updater.SdkUpdaterNoWindow;
-import com.android.sdklib.repository.SdkAddonConstants;
-import com.android.sdklib.repository.SdkRepoConstants;
-import com.android.sdkuilib.internal.widgets.MessageBoxLog;
-import com.android.sdkuilib.repository.AvdManagerWindow;
-import com.android.sdkuilib.repository.AvdManagerWindow.AvdInvocationContext;
-import com.android.sdkuilib.repository.SdkUpdaterWindow;
-import com.android.sdkuilib.repository.SdkUpdaterWindow.SdkInvocationContext;
-import com.android.utils.ILogger;
-import com.android.utils.Pair;
-import com.android.xml.AndroidXPathFactory;
-
-import org.eclipse.swt.widgets.Display;
-import org.xml.sax.InputSource;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathExpressionException;
-
-/**
- * Main class for the 'android' application.
- */
-public class Main {
-
- /** Java property that defines the location of the sdk/tools directory. */
- public final static String TOOLSDIR = "com.android.sdkmanager.toolsdir";
- /** Java property that defines the working directory. On Windows the current working directory
- * is actually the tools dir, in which case this is used to get the original CWD. */
- private final static String WORKDIR = "com.android.sdkmanager.workdir";
-
- /** Value returned by {@link #resolveTargetName(String)} when the target id does not match. */
- private final static int INVALID_TARGET_ID = 0;
-
- private final static String[] BOOLEAN_YES_REPLIES = new String[] { "yes", "y" };
- private final static String[] BOOLEAN_NO_REPLIES = new String[] { "no", "n" };
-
- /** Path to the SDK folder. This is the parent of {@link #TOOLSDIR}. */
- private String mOsSdkFolder;
- /** Logger object. Use this to print normal output, warnings or errors. */
- private ILogger mSdkLog;
- /** The SDK manager parses the SDK folder and gives access to the content. */
- private SdkManager mSdkManager;
- /** Command-line processor with options specific to SdkManager. */
- private SdkCommandLine mSdkCommandLine;
- /** The working directory, either null or set to an existing absolute canonical directory. */
- private File mWorkDir;
-
- public static void main(String[] args) {
- new Main().run(args);
- }
-
- /** Used by tests to set the sdk manager. */
- @VisibleForTesting(visibility=Visibility.PRIVATE)
- void setSdkManager(SdkManager sdkManager) {
- mSdkManager = sdkManager;
- }
-
- /**
- * Runs the sdk manager app
- */
- private void run(String[] args) {
- createLogger();
- init();
- mSdkCommandLine.parseArgs(args);
- parseSdk();
- doAction();
- }
-
- /**
- * Creates the {@link #mSdkLog} object.
- * This must be done before {@link #init()} as it will be used to report errors.
- * This logger prints to the attached console.
- */
- private void createLogger() {
- mSdkLog = new ILogger() {
- @Override
- public void error(Throwable t, String errorFormat, Object... args) {
- if (errorFormat != null) {
- System.err.printf("Error: " + errorFormat, args);
- if (!errorFormat.endsWith("\n")) {
- System.err.printf("\n");
- }
- }
- if (t != null) {
- System.err.printf("Error: %s\n", t.getMessage());
- }
- }
-
- @Override
- public void warning(@NonNull String warningFormat, Object... args) {
- if (mSdkCommandLine.isVerbose()) {
- System.out.printf("Warning: " + warningFormat, args);
- if (!warningFormat.endsWith("\n")) {
- System.out.printf("\n");
- }
- }
- }
-
- @Override
- public void info(@NonNull String msgFormat, Object... args) {
- System.out.printf(msgFormat, args);
- }
-
- @Override
- public void verbose(@NonNull String msgFormat, Object... args) {
- System.out.printf(msgFormat, args);
- }
- };
- }
-
- /** For testing */
- public void setLogger(ILogger logger) {
- mSdkLog = logger;
- }
-
- /**
- * Init the application by making sure the SDK path is available and
- * doing basic parsing of the SDK.
- */
- private void init() {
- mSdkCommandLine = new SdkCommandLine(mSdkLog);
-
- // We get passed a property for the tools dir
- String toolsDirProp = System.getProperty(TOOLSDIR);
- if (toolsDirProp == null) {
- // for debugging, it's easier to override using the process environment
- toolsDirProp = System.getenv(TOOLSDIR);
- }
-
- if (toolsDirProp != null) {
- // got back a level for the SDK folder
- File tools;
- if (toolsDirProp.length() > 0) {
- tools = new File(toolsDirProp);
- mOsSdkFolder = tools.getParent();
- } else {
- try {
- tools = new File(".").getCanonicalFile();
- mOsSdkFolder = tools.getParent();
- } catch (IOException e) {
- // Will print an error below since mSdkFolder is not defined
- }
- }
- }
-
- if (mOsSdkFolder == null) {
- errorAndExit("The tools directory property is not set, please make sure you are executing %1$s",
- SdkConstants.androidCmdName());
- }
-
- // We might get passed a property for the working directory
- // Either it is a valid directory and mWorkDir is set to it's absolute canonical value
- // or mWorkDir remains null.
- String workDirProp = System.getProperty(WORKDIR);
- if (workDirProp == null) {
- workDirProp = System.getenv(WORKDIR);
- }
- if (workDirProp != null) {
- // This should be a valid directory
- mWorkDir = new File(workDirProp);
- try {
- mWorkDir = mWorkDir.getCanonicalFile().getAbsoluteFile();
- } catch (IOException e) {
- mWorkDir = null;
- }
- if (mWorkDir == null || !mWorkDir.isDirectory()) {
- errorAndExit("The working directory does not seem to be valid: '%1$s", workDirProp);
- }
- }
- }
-
- /**
- * Does the basic SDK parsing required for all actions
- */
- private void parseSdk() {
- mSdkManager = SdkManager.createManager(mOsSdkFolder, mSdkLog);
-
- if (mSdkManager == null) {
- errorAndExit("Unable to parse SDK content.");
- }
- }
-
- /**
- * Actually do an action...
- */
- private void doAction() {
-
- if (mSdkCommandLine.hasClearCache()) {
- DownloadCache d = new DownloadCache(Strategy.SERVE_CACHE);
- d.clearCache();
- mSdkLog.info("SDK Manager repository: manifest cache cleared.\n");
- }
-
- String verb = mSdkCommandLine.getVerb();
- String directObject = mSdkCommandLine.getDirectObject();
-
- if (SdkCommandLine.VERB_LIST.equals(verb)) {
- // list action.
- if (SdkCommandLine.OBJECT_TARGET.equals(directObject)) {
- displayTargetList();
-
- } else if (SdkCommandLine.OBJECT_AVD.equals(directObject)) {
- displayAvdList();
-
- } else if (SdkCommandLine.OBJECT_SDK.equals(directObject)) {
- displayRemoteSdkListNoUI();
-
- } else {
- displayTargetList();
- displayAvdList();
- }
-
- } else if (SdkCommandLine.VERB_CREATE.equals(verb)) {
- if (SdkCommandLine.OBJECT_AVD.equals(directObject)) {
- createAvd();
-
- } else if (SdkCommandLine.OBJECT_PROJECT.equals(directObject)) {
- createProject(false /*library*/);
-
- } else if (SdkCommandLine.OBJECT_TEST_PROJECT.equals(directObject)) {
- createTestProject();
-
- } else if (SdkCommandLine.OBJECT_LIB_PROJECT.equals(directObject)) {
- createProject(true /*library*/);
-
- } else if (SdkCommandLine.OBJECT_UITEST_PROJECT.equals(directObject)) {
- createUiTestProject();
-
- }
- } else if (SdkCommandLine.VERB_UPDATE.equals(verb)) {
- if (SdkCommandLine.OBJECT_AVD.equals(directObject)) {
- updateAvd();
-
- } else if (SdkCommandLine.OBJECT_PROJECT.equals(directObject)) {
- updateProject(false /*library*/);
-
- } else if (SdkCommandLine.OBJECT_TEST_PROJECT.equals(directObject)) {
- updateTestProject();
-
- } else if (SdkCommandLine.OBJECT_LIB_PROJECT.equals(directObject)) {
- updateProject(true /*library*/);
-
- } else if (SdkCommandLine.OBJECT_SDK.equals(directObject)) {
- if (mSdkCommandLine.getFlagNoUI(verb)) {
- updateSdkNoUI();
- } else {
- showSdkManagerWindow();
- }
-
- } else if (SdkCommandLine.OBJECT_ADB.equals(directObject)) {
- updateAdb();
-
- }
- } else if (SdkCommandLine.VERB_SDK.equals(verb)) {
- showSdkManagerWindow();
-
- } else if (SdkCommandLine.VERB_AVD.equals(verb)) {
- showAvdManagerWindow();
-
- } else if (SdkCommandLine.VERB_DELETE.equals(verb) &&
- SdkCommandLine.OBJECT_AVD.equals(directObject)) {
- deleteAvd();
-
- } else if (SdkCommandLine.VERB_MOVE.equals(verb) &&
- SdkCommandLine.OBJECT_AVD.equals(directObject)) {
- moveAvd();
-
- } else if (verb == null && directObject == null) {
- showSdkManagerWindow();
-
- } else {
- mSdkCommandLine.printHelpAndExit(null);
- }
- }
-
- /**
- * Display the main SDK Manager app window
- */
- private void showSdkManagerWindow() {
- try {
- MessageBoxLog errorLogger = new MessageBoxLog(
- "SDK Manager",
- Display.getCurrent(),
- true /*logErrorsOnly*/);
-
- SdkUpdaterWindow window = new SdkUpdaterWindow(
- null /* parentShell */,
- errorLogger,
- mOsSdkFolder,
- SdkInvocationContext.STANDALONE);
- window.open();
-
- errorLogger.displayResult(true);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Display the main AVD Manager app window
- */
- private void showAvdManagerWindow() {
- try {
- MessageBoxLog errorLogger = new MessageBoxLog(
- "AVD Manager",
- Display.getCurrent(),
- true /*logErrorsOnly*/);
-
- AvdManagerWindow window = new AvdManagerWindow(
- null /* parentShell */,
- errorLogger,
- mOsSdkFolder,
- AvdInvocationContext.STANDALONE);
-
- window.open();
-
- errorLogger.displayResult(true);
-
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- private void displayRemoteSdkListNoUI() {
- boolean force = mSdkCommandLine.getFlagForce();
- boolean useHttp = mSdkCommandLine.getFlagNoHttps();
- boolean all = mSdkCommandLine.getFlagAll();
- boolean extended = mSdkCommandLine.getFlagExtended();
- String proxyHost = mSdkCommandLine.getParamProxyHost();
- String proxyPort = mSdkCommandLine.getParamProxyPort();
-
- boolean obsolete = mSdkCommandLine.getFlagObsolete();
- all |= obsolete;
-
- SdkUpdaterNoWindow upd = new SdkUpdaterNoWindow(
- mOsSdkFolder,
- mSdkManager,
- mSdkLog,
- force,
- useHttp,
- proxyHost,
- proxyPort);
- upd.listRemotePackages(all, extended);
-
- if (obsolete) {
- mSdkLog.info("Note: Flag --obsolete is deprecated and will be removed in the next version.\n Please use --all instead.\n");
- }
- }
-
- /**
- * Updates the whole SDK without any UI, just using console output.
- */
- private void updateSdkNoUI() {
- boolean force = mSdkCommandLine.getFlagForce();
- boolean useHttp = mSdkCommandLine.getFlagNoHttps();
- boolean dryMode = mSdkCommandLine.getFlagDryMode();
- boolean all = mSdkCommandLine.getFlagAll();
- String proxyHost = mSdkCommandLine.getParamProxyHost();
- String proxyPort = mSdkCommandLine.getParamProxyPort();
-
- boolean obsolete = mSdkCommandLine.getFlagObsolete();
- all |= obsolete;
-
- // Check filter types.
- Pair<String, ArrayList<String>> filterResult =
- checkFilterValues(mSdkCommandLine.getParamFilter());
- if (filterResult.getFirst() != null) {
- // We got an error.
- errorAndExit(filterResult.getFirst());
- }
-
- SdkUpdaterNoWindow upd = new SdkUpdaterNoWindow(
- mOsSdkFolder,
- mSdkManager,
- mSdkLog,
- force,
- useHttp,
- proxyHost,
- proxyPort);
- upd.updateAll(filterResult.getSecond(), all, dryMode);
-
- if (obsolete) {
- mSdkLog.info("Note: Flag --obsolete is deprecated and will be removed in the next version.\n Please use --all instead.\n");
- }
- }
-
- /**
- * Checks the values from the filter parameter and returns a tuple
- * (error , accepted values). Either error is null and accepted values is not,
- * or the reverse.
- * <p/>
- * Note that this is a quick sanity check of the --filter parameter *before* we
- * start loading the remote repository sources. Loading the remotes takes a while
- * so it's worth doing a quick sanity check before hand.
- *
- * @param filter A comma-separated list of keywords
- * @return A pair <error string, usable values>, only one must be null and the other non-null.
- */
- @VisibleForTesting(visibility=Visibility.PRIVATE)
- Pair<String, ArrayList<String>> checkFilterValues(String filter) {
- ArrayList<String> pkgFilter = new ArrayList<String>();
-
- if (filter != null && filter.length() > 0) {
- // Available types
- Set<String> filterTypes = new TreeSet<String>();
- filterTypes.addAll(Arrays.asList(SdkRepoConstants.NODES));
- filterTypes.addAll(Arrays.asList(SdkAddonConstants.NODES));
-
- for (String t : filter.split(",")) { //$NON-NLS-1$
- if (t == null) {
- continue;
- }
- t = t.trim();
- if (t.length() <= 0) {
- continue;
- }
-
- if (t.indexOf('-') > 0 ||
- t.equals(ToolPackage.INSTALL_ID) ||
- t.equals(PlatformToolPackage.INSTALL_ID)) {
- // Heuristic: if the filter name contains a dash, it is probably
- // a variable package install id. Since we haven't loaded the remote
- // repositories we can't validate it yet, so just accept it.
- pkgFilter.add(t);
- continue;
- }
-
- if (t.replaceAll("[0-9]+", "").length() == 0) { //$NON-NLS-1$ //$NON-NLS-2$
- // If the filter argument *only* contains digits, accept it.
- // It's probably an index for the remote repository list,
- // which we can't validate yet.
- pkgFilter.add(t);
- continue;
- }
-
- if (filterTypes.contains(t)) {
- pkgFilter.add(t);
- continue;
- }
-
- return Pair.of(
- String.format(
- "Unknown package filter type '%1$s'.\nAccepted values are: %2$s",
- t,
- Arrays.toString(filterTypes.toArray())),
- null);
- }
- }
-
- return Pair.of(null, pkgFilter);
- }
-
- /**
- * Returns a configured {@link ProjectCreator} instance.
- */
- private ProjectCreator getProjectCreator() {
- ProjectCreator creator = new ProjectCreator(mSdkManager, mOsSdkFolder,
- mSdkCommandLine.isVerbose() ? OutputLevel.VERBOSE :
- mSdkCommandLine.isSilent() ? OutputLevel.SILENT :
- OutputLevel.NORMAL,
- mSdkLog);
- return creator;
- }
-
-
- /**
- * Creates a new Android project based on command-line parameters
- */
- private void createProject(boolean library) {
- String directObject = library? SdkCommandLine.OBJECT_LIB_PROJECT :
- SdkCommandLine.OBJECT_PROJECT;
-
- // get the target and try to resolve it.
- int targetId = resolveTargetName(mSdkCommandLine.getParamTargetId());
- IAndroidTarget[] targets = mSdkManager.getTargets();
- if (targetId == INVALID_TARGET_ID || targetId > targets.length) {
- errorAndExit("Target id is not valid. Use '%s list targets' to get the target ids.",
- SdkConstants.androidCmdName());
- }
- IAndroidTarget target = targets[targetId - 1]; // target id is 1-based
-
- ProjectCreator creator = getProjectCreator();
-
- String projectDir = getProjectLocation(mSdkCommandLine.getParamLocationPath());
-
- String projectName = mSdkCommandLine.getParamName();
- String packageName = mSdkCommandLine.getParamProjectPackage(directObject);
- String activityName = null;
- if (library == false) {
- activityName = mSdkCommandLine.getParamProjectActivity();
- }
-
- if (projectName != null &&
- !ProjectCreator.RE_PROJECT_NAME.matcher(projectName).matches()) {
- errorAndExit(
- "Project name '%1$s' contains invalid characters.\nAllowed characters are: %2$s",
- projectName, ProjectCreator.CHARS_PROJECT_NAME);
- return;
- }
-
- if (activityName != null &&
- !ProjectCreator.RE_ACTIVITY_NAME.matcher(activityName).matches()) {
- errorAndExit(
- "Activity name '%1$s' contains invalid characters.\nAllowed characters are: %2$s",
- activityName, ProjectCreator.CHARS_ACTIVITY_NAME);
- return;
- }
-
- if (packageName != null &&
- !ProjectCreator.RE_PACKAGE_NAME.matcher(packageName).matches()) {
- errorAndExit(
- "Package name '%1$s' contains invalid characters.\n" +
- "A package name must be constitued of two Java identifiers.\n" +
- "Each identifier allowed characters are: %2$s",
- packageName, ProjectCreator.CHARS_PACKAGE_NAME);
- return;
- }
-
- creator.createProject(projectDir,
- projectName,
- packageName,
- activityName,
- target,
- library,
- null /*pathToMain*/);
- }
-
- /**
- * Creates a new Android test project based on command-line parameters
- */
- private void createTestProject() {
-
- String projectDir = getProjectLocation(mSdkCommandLine.getParamLocationPath());
-
- // first check the path of the parent project, and make sure it's valid.
- String pathToMainProject = mSdkCommandLine.getParamTestProjectMain();
-
- File parentProject = new File(pathToMainProject);
- if (parentProject.isAbsolute() == false) {
- // if the path is not absolute, we need to resolve it based on the
- // destination path of the project
- try {
- parentProject = new File(projectDir, pathToMainProject).getCanonicalFile();
- } catch (IOException e) {
- errorAndExit("Unable to resolve Main project's directory: %1$s",
- pathToMainProject);
- return; // help Eclipse static analyzer understand we'll never execute the rest.
- }
- }
-
- if (parentProject.isDirectory() == false) {
- errorAndExit("Main project's directory does not exist: %1$s",
- pathToMainProject);
- return;
- }
-
- // now look for a manifest in there
- File manifest = new File(parentProject, SdkConstants.FN_ANDROID_MANIFEST_XML);
- if (manifest.isFile() == false) {
- errorAndExit("No AndroidManifest.xml file found in the main project directory: %1$s",
- parentProject.getAbsolutePath());
- return;
- }
-
- // now query the manifest for the package file.
- XPath xpath = AndroidXPathFactory.newXPath();
- String packageName, activityName;
-
- try {
- packageName = xpath.evaluate("/manifest/@package",
- new InputSource(new FileInputStream(manifest)));
-
- mSdkLog.info("Found main project package: %1$s\n", packageName);
-
- // now get the name of the first activity we find
- activityName = xpath.evaluate("/manifest/application/activity[1]/@android:name",
- new InputSource(new FileInputStream(manifest)));
- // xpath will return empty string when there's no match
- if (activityName == null || activityName.length() == 0) {
- activityName = null;
- } else {
- mSdkLog.info("Found main project activity: %1$s\n", activityName);
- }
- } catch (FileNotFoundException e) {
- // this shouldn't happen as we test it above.
- errorAndExit("No AndroidManifest.xml file found in main project.");
- return; // this is not strictly needed because errorAndExit will stop the execution,
- // but this makes the java compiler happy, wrt to uninitialized variables.
- } catch (XPathExpressionException e) {
- // looks like the main manifest is not valid.
- errorAndExit("Unable to parse main project manifest to get information.");
- return; // this is not strictly needed because errorAndExit will stop the execution,
- // but this makes the java compiler happy, wrt to uninitialized variables.
- }
-
- // now get the target hash
- ProjectProperties p = ProjectProperties.load(parentProject.getAbsolutePath(),
- PropertyType.PROJECT);
- if (p == null) {
- errorAndExit("Unable to load the main project's %1$s",
- PropertyType.PROJECT.getFilename());
- return;
- }
-
- String targetHash = p.getProperty(ProjectProperties.PROPERTY_TARGET);
- if (targetHash == null) {
- errorAndExit("Couldn't find the main project target");
- return;
- }
-
- // and resolve it.
- IAndroidTarget target = mSdkManager.getTargetFromHashString(targetHash);
- if (target == null) {
- errorAndExit(
- "Unable to resolve main project target '%1$s'. You may want to install the platform in your SDK.",
- targetHash);
- return;
- }
-
- mSdkLog.info("Found main project target: %1$s\n", target.getFullName());
-
- ProjectCreator creator = getProjectCreator();
-
- String projectName = mSdkCommandLine.getParamName();
-
- if (projectName != null &&
- !ProjectCreator.RE_PROJECT_NAME.matcher(projectName).matches()) {
- errorAndExit(
- "Project name '%1$s' contains invalid characters.\nAllowed characters are: %2$s",
- projectName, ProjectCreator.CHARS_PROJECT_NAME);
- return;
- }
-
- creator.createProject(projectDir,
- projectName,
- packageName,
- activityName,
- target,
- false /* library*/,
- pathToMainProject);
- }
-
- /**
- * Creates a new Android UI test project based on command-line parameters
- */
- private void createUiTestProject() {
-
- String projectDir = getProjectLocation(mSdkCommandLine.getParamLocationPath());
-
- // get the target and try to resolve it.
- int targetId = resolveTargetName(mSdkCommandLine.getParamTargetId());
- IAndroidTarget[] targets = mSdkManager.getTargets();
- if (targetId == INVALID_TARGET_ID || targetId > targets.length) {
- errorAndExit("Target id is not valid. Use '%s list targets' to get the target ids.",
- SdkConstants.androidCmdName());
- }
- IAndroidTarget target = targets[targetId - 1]; // target id is 1-based
-
- if (target.getVersion().getApiLevel() < 16) {
- errorAndExit("UI test projects can only target API 16 and above");
- }
-
- // get the project name
- String projectName = mSdkCommandLine.getParamName();
- // if none, use the folder name.
- if (projectName == null) {
- File f = new File(projectDir);
- projectName = f.getName();
- }
-
- try {
- // create src folder
- File srcFolder = new File(projectDir, SdkConstants.FD_SOURCES);
- srcFolder.mkdir();
-
- // create the local.prop file.
- // location of the SDK goes in localProperty
- ProjectPropertiesWorkingCopy localProperties = ProjectProperties.create(projectDir,
- PropertyType.LOCAL);
- localProperties.setProperty(ProjectProperties.PROPERTY_SDK, mOsSdkFolder);
- localProperties.save();
-
- // target goes in project properties
- ProjectPropertiesWorkingCopy projectProperties = ProjectProperties.create(projectDir,
- PropertyType.PROJECT);
- projectProperties.setProperty(ProjectProperties.PROPERTY_TARGET, target.hashString());
- projectProperties.save();
-
- // copy the build file using the keywords replacement.
- final Map<String, String> keywords = new HashMap<String, String>();
- keywords.put(ProjectCreator.PH_PROJECT_NAME, projectName);
-
- ProjectCreator creator = getProjectCreator();
-
- creator.installTemplate("uibuild.template",
- new File(projectDir, SdkConstants.FN_BUILD_XML),
- keywords);
- } catch (Exception e) {
- mSdkLog.error(e, null);
- }
- }
-
- /**
- * Updates an existing Android project based on command-line parameters
- * @param library whether the project is a library project.
- */
- private void updateProject(boolean library) {
- // get the target and try to resolve it.
- IAndroidTarget target = null;
- String targetStr = mSdkCommandLine.getParamTargetId();
- // For "update project" the target parameter is optional so having null is acceptable.
- // However if there's a value, it must be valid.
- if (targetStr != null) {
- IAndroidTarget[] targets = mSdkManager.getTargets();
- int targetId = resolveTargetName(targetStr);
- if (targetId == INVALID_TARGET_ID || targetId > targets.length) {
- errorAndExit("Target id '%1$s' is not valid. Use '%2$s list targets' to get the target ids.",
- targetStr,
- SdkConstants.androidCmdName());
- }
- target = targets[targetId - 1]; // target id is 1-based
- }
-
- ProjectCreator creator = getProjectCreator();
-
- String projectDir = getProjectLocation(mSdkCommandLine.getParamLocationPath());
-
- String libraryPath = library ? null :
- mSdkCommandLine.getParamProjectLibrary(SdkCommandLine.OBJECT_PROJECT);
-
- creator.updateProject(projectDir,
- target,
- mSdkCommandLine.getParamName(),
- libraryPath);
-
- if (library == false) {
- boolean doSubProjects = mSdkCommandLine.getParamSubProject();
- boolean couldHaveDone = false;
-
- // If there are any sub-folders with a manifest, try to update them as projects
- // too. This will take care of updating any underlying test project even if the
- // user changed the folder name.
- File[] files = new File(projectDir).listFiles();
- if (files != null) {
- for (File dir : files) {
- if (dir.isDirectory() &&
- new File(dir, SdkConstants.FN_ANDROID_MANIFEST_XML).isFile()) {
- if (doSubProjects) {
- creator.updateProject(dir.getPath(),
- target,
- mSdkCommandLine.getParamName(),
- null /*libraryPath*/);
- } else {
- couldHaveDone = true;
- }
- }
- }
- }
-
- if (couldHaveDone) {
- mSdkLog.info(
- "It seems that there are sub-projects. If you want to update them\nplease use the --%1$s parameter.\n",
- SdkCommandLine.KEY_SUBPROJECTS);
- }
- }
- }
-
- /**
- * Updates an existing test project with a new path to the main project.
- */
- private void updateTestProject() {
- ProjectCreator creator = getProjectCreator();
-
- String projectDir = getProjectLocation(mSdkCommandLine.getParamLocationPath());
-
- creator.updateTestProject(projectDir, mSdkCommandLine.getParamTestProjectMain(),
- mSdkManager);
- }
-
- /**
- * Adjusts the project location to make it absolute & canonical relative to the
- * working directory, if any.
- *
- * @return The project absolute path relative to {@link #mWorkDir} or the original
- * newProjectLocation otherwise.
- */
- private String getProjectLocation(String newProjectLocation) {
-
- // If the new project location is absolute, use it as-is
- File projectDir = new File(newProjectLocation);
- if (projectDir.isAbsolute()) {
- return newProjectLocation;
- }
-
- // if there's no working directory, just use the project location as-is.
- if (mWorkDir == null) {
- return newProjectLocation;
- }
-
- // Combine then and get an absolute canonical directory
- try {
- projectDir = new File(mWorkDir, newProjectLocation).getCanonicalFile();
-
- return projectDir.getPath();
- } catch (IOException e) {
- errorAndExit("Failed to combine working directory '%1$s' with project location '%2$s': %3$s",
- mWorkDir.getPath(),
- newProjectLocation,
- e.getMessage());
- return null;
- }
- }
-
- /**
- * Displays the list of available Targets (Platforms and Add-ons)
- */
- @VisibleForTesting(visibility=Visibility.PRIVATE)
- void displayTargetList() {
-
- // Compact output, suitable for scripts.
- if (mSdkCommandLine != null && mSdkCommandLine.getFlagCompact()) {
- char eol = mSdkCommandLine.getFlagEolNull() ? '\0' : '\n';
-
- for (IAndroidTarget target : mSdkManager.getTargets()) {
- mSdkLog.info("%1$s%2$c", target.hashString(), eol);
- }
-
- return;
- }
-
- mSdkLog.info("Available Android targets:\n");
-
- int index = 1;
- for (IAndroidTarget target : mSdkManager.getTargets()) {
- mSdkLog.info("----------\n");
- mSdkLog.info("id: %1$d or \"%2$s\"\n", index, target.hashString());
- mSdkLog.info(" Name: %s\n", target.getName());
- if (target.isPlatform()) {
- mSdkLog.info(" Type: Platform\n");
- mSdkLog.info(" API level: %s\n", target.getVersion().getApiString());
- mSdkLog.info(" Revision: %d\n", target.getRevision());
- } else {
- mSdkLog.info(" Type: Add-On\n");
- mSdkLog.info(" Vendor: %s\n", target.getVendor());
- mSdkLog.info(" Revision: %d\n", target.getRevision());
- if (target.getDescription() != null) {
- mSdkLog.info(" Description: %s\n", target.getDescription());
- }
- mSdkLog.info(" Based on Android %s (API level %s)\n",
- target.getVersionName(), target.getVersion().getApiString());
-
- // display the optional libraries.
- IOptionalLibrary[] libraries = target.getOptionalLibraries();
- if (libraries != null) {
- mSdkLog.info(" Libraries:\n");
- for (IOptionalLibrary library : libraries) {
- mSdkLog.info(" * %1$s (%2$s)\n",
- library.getName(), library.getJarName());
- mSdkLog.info(" %1$s\n", library.getDescription());
- }
- }
- }
-
- // get the target skins & ABIs
- displaySkinList(target, " Skins: ");
- displayAbiList (target, " ABIs : ");
-
- if (target.getUsbVendorId() != IAndroidTarget.NO_USB_ID) {
- mSdkLog.info(" Adds USB support for devices (Vendor: 0x%04X)\n",
- target.getUsbVendorId());
- }
-
- index++;
- }
- }
-
- /**
- * Displays the skins valid for the given target.
- */
- @VisibleForTesting(visibility=Visibility.PRIVATE)
- void displaySkinList(IAndroidTarget target, String message) {
- String[] skins = target.getSkins();
- String defaultSkin = target.getDefaultSkin();
- mSdkLog.info(message);
- if (skins != null) {
- boolean first = true;
- for (String skin : skins) {
- if (first == false) {
- mSdkLog.info(", ");
- } else {
- first = false;
- }
- mSdkLog.info(skin);
-
- if (skin.equals(defaultSkin)) {
- mSdkLog.info(" (default)");
- }
- }
- mSdkLog.info("\n");
- } else {
- mSdkLog.info("no skins.\n");
- }
- }
-
- /**
- * Displays the ABIs valid for the given target.
- */
- @VisibleForTesting(visibility=Visibility.PRIVATE)
- void displayAbiList(IAndroidTarget target, String message) {
- ISystemImage[] systemImages = target.getSystemImages();
- mSdkLog.info(message);
- if (systemImages.length > 0) {
- boolean first = true;
- for (ISystemImage si : systemImages) {
- if (first == false) {
- mSdkLog.info(", ");
- } else {
- first = false;
- }
- mSdkLog.info(si.getAbiType());
- }
- mSdkLog.info("\n");
- } else {
- mSdkLog.info("no ABIs.\n");
- }
- }
-
- /**
- * Displays the list of available AVDs for the given AvdManager.
- *
- * @param avdManager
- */
- @VisibleForTesting(visibility=Visibility.PRIVATE)
- void displayAvdList(AvdManager avdManager) {
-
- AvdInfo[] avds = avdManager.getValidAvds();
-
- // Compact output, suitable for scripts.
- if (mSdkCommandLine != null && mSdkCommandLine.getFlagCompact()) {
- char eol = mSdkCommandLine.getFlagEolNull() ? '\0' : '\n';
-
- for (int index = 0 ; index < avds.length ; index++) {
- AvdInfo info = avds[index];
- mSdkLog.info("%1$s%2$c", info.getName(), eol);
- }
-
- return;
- }
-
- mSdkLog.info("Available Android Virtual Devices:\n");
-
- for (int index = 0 ; index < avds.length ; index++) {
- AvdInfo info = avds[index];
- if (index > 0) {
- mSdkLog.info("---------\n");
- }
- mSdkLog.info(" Name: %s\n", info.getName());
- mSdkLog.info(" Path: %s\n", info.getDataFolderPath());
-
- // get the target of the AVD
- IAndroidTarget target = info.getTarget();
- if (target.isPlatform()) {
- mSdkLog.info(" Target: %s (API level %s)\n", target.getName(),
- target.getVersion().getApiString());
- } else {
- mSdkLog.info(" Target: %s (%s)\n", target.getName(), target
- .getVendor());
- mSdkLog.info(" Based on Android %s (API level %s)\n",
- target.getVersionName(), target.getVersion().getApiString());
- }
- mSdkLog.info(" ABI: %s\n", info.getAbiType());
-
- // display some extra values.
- Map<String, String> properties = info.getProperties();
- if (properties != null) {
- String skin = properties.get(AvdManager.AVD_INI_SKIN_NAME);
- if (skin != null) {
- mSdkLog.info(" Skin: %s\n", skin);
- }
- String sdcard = properties.get(AvdManager.AVD_INI_SDCARD_SIZE);
- if (sdcard == null) {
- sdcard = properties.get(AvdManager.AVD_INI_SDCARD_PATH);
- }
- if (sdcard != null) {
- mSdkLog.info(" Sdcard: %s\n", sdcard);
- }
- String snapshot = properties.get(AvdManager.AVD_INI_SNAPSHOT_PRESENT);
- if (snapshot != null) {
- mSdkLog.info("Snapshot: %s\n", snapshot);
- }
- }
- }
-
- // Are there some unused AVDs?
- AvdInfo[] badAvds = avdManager.getBrokenAvds();
-
- if (badAvds.length == 0) {
- return;
- }
-
- mSdkLog.info("\nThe following Android Virtual Devices could not be loaded:\n");
- boolean needSeparator = false;
- for (AvdInfo info : badAvds) {
- if (needSeparator) {
- mSdkLog.info("---------\n");
- }
- mSdkLog.info(" Name: %s\n", info.getName() == null ? "--" : info.getName());
- mSdkLog.info(" Path: %s\n",
- info.getDataFolderPath() == null ? "--" : info.getDataFolderPath());
-
- String error = info.getErrorMessage();
- mSdkLog.info(" Error: %s\n", error == null ? "Uknown error" : error);
- needSeparator = true;
- }
- }
-
- /**
- * Displays the list of available AVDs.
- */
- private void displayAvdList() {
- try {
- AvdManager avdManager = AvdManager.getInstance(mSdkManager, mSdkLog);
- displayAvdList(avdManager);
- } catch (AndroidLocationException e) {
- errorAndExit(e.getMessage());
- }
- }
-
- /**
- * Creates a new AVD. This is a text based creation with command line prompt.
- */
- private void createAvd() {
- // find a matching target
- int targetId = resolveTargetName(mSdkCommandLine.getParamTargetId());
- IAndroidTarget[] targets = mSdkManager.getTargets();
-
- if (targetId == INVALID_TARGET_ID || targetId > targets.length) {
- errorAndExit("Target id is not valid. Use '%s list targets' to get the target ids.",
- SdkConstants.androidCmdName());
- }
-
- IAndroidTarget target = targets[targetId-1]; // target id is 1-based
-
- try {
- boolean removePrevious = mSdkCommandLine.getFlagForce();
- AvdManager avdManager = AvdManager.getInstance(mSdkManager, mSdkLog);
-
- String avdName = mSdkCommandLine.getParamName();
-
- if (!AvdManager.RE_AVD_NAME.matcher(avdName).matches()) {
- errorAndExit(
- "AVD name '%1$s' contains invalid characters.\nAllowed characters are: %2$s",
- avdName, AvdManager.CHARS_AVD_NAME);
- return;
- }
-
- AvdInfo info = avdManager.getAvd(avdName, false /*validAvdOnly*/);
- if (info != null) {
- if (removePrevious) {
- mSdkLog.warning(
- "Android Virtual Device '%s' already exists and will be replaced.",
- avdName);
- } else {
- errorAndExit("Android Virtual Device '%s' already exists.\n" +
- "Use --force if you want to replace it.",
- avdName);
- return;
- }
- }
-
- String paramFolderPath = mSdkCommandLine.getParamLocationPath();
- File avdFolder = null;
- if (paramFolderPath != null) {
- avdFolder = new File(paramFolderPath);
- } else {
- avdFolder = AvdInfo.getDefaultAvdFolder(avdManager, avdName);
- }
-
- // Validate skin is either default (empty) or NNNxMMM or a valid skin name.
- Map<String, String> skinHardwareConfig = null;
- String skin = mSdkCommandLine.getParamSkin();
- if (skin != null && skin.length() == 0) {
- skin = null;
- }
-
- if (skin != null && target != null) {
- boolean valid = false;
- // Is it a know skin name for this target?
- for (String s : target.getSkins()) {
- if (skin.equalsIgnoreCase(s)) {
- skin = s; // Make skin names case-insensitive.
- valid = true;
-
- // get the hardware properties for this skin
- File skinFolder = avdManager.getSkinPath(skin, target);
- FileWrapper skinHardwareFile = new FileWrapper(skinFolder,
- AvdManager.HARDWARE_INI);
- if (skinHardwareFile.isFile()) {
- skinHardwareConfig = ProjectProperties.parsePropertyFile(
- skinHardwareFile, mSdkLog);
- }
- break;
- }
- }
-
- // Is it NNNxMMM?
- if (!valid) {
- valid = AvdManager.NUMERIC_SKIN_SIZE.matcher(skin).matches();
- }
-
- if (!valid) {
- displaySkinList(target, "Valid skins: ");
- errorAndExit("'%s' is not a valid skin name or size (NNNxMMM)", skin);
- return;
- }
- }
-
- String abiType = mSdkCommandLine.getParamAbi();
- if (target != null && (abiType == null || abiType.length() == 0)) {
- ISystemImage[] systemImages = target.getSystemImages();
- if (systemImages != null && systemImages.length == 1) {
- // Auto-select the single ABI available
- abiType = systemImages[0].getAbiType();
- mSdkLog.info("Auto-selecting single ABI %1$s\n", abiType);
- } else {
- displayAbiList(target, "Valid ABIs: ");
- errorAndExit("This platform has more than one ABI. Please specify one using --%1$s.",
- SdkCommandLine.KEY_ABI);
- }
- }
-
- Map<String, String> hardwareConfig = null;
- if (target != null && target.isPlatform()) {
- try {
- hardwareConfig = promptForHardware(target, skinHardwareConfig);
- } catch (IOException e) {
- errorAndExit(e.getMessage());
- }
- }
-
- @SuppressWarnings("unused") // oldAvdInfo is never read, yet useful for debugging
- AvdInfo oldAvdInfo = null;
- if (removePrevious) {
- oldAvdInfo = avdManager.getAvd(avdName, false /*validAvdOnly*/);
- }
-
- @SuppressWarnings("unused") // newAvdInfo is never read, yet useful for debugging
- AvdInfo newAvdInfo = avdManager.createAvd(avdFolder,
- avdName,
- target,
- abiType,
- skin,
- mSdkCommandLine.getParamSdCard(),
- hardwareConfig,
- mSdkCommandLine.getFlagSnapshot(),
- removePrevious,
- false, //edit existing
- mSdkLog);
-
- } catch (AndroidLocationException e) {
- errorAndExit(e.getMessage());
- }
- }
-
- /**
- * Delete an AVD. If the AVD name is not part of the available ones look for an
- * invalid AVD (one not loaded due to some error) to remove it too.
- */
- private void deleteAvd() {
- try {
- String avdName = mSdkCommandLine.getParamName();
- AvdManager avdManager = AvdManager.getInstance(mSdkManager, mSdkLog);
- AvdInfo info = avdManager.getAvd(avdName, false /*validAvdOnly*/);
-
- if (info == null) {
- errorAndExit("There is no Android Virtual Device named '%s'.", avdName);
- return;
- }
-
- avdManager.deleteAvd(info, mSdkLog);
- } catch (AndroidLocationException e) {
- errorAndExit(e.getMessage());
- }
- }
-
- /**
- * Moves an AVD.
- */
- private void moveAvd() {
- try {
- String avdName = mSdkCommandLine.getParamName();
- AvdManager avdManager = AvdManager.getInstance(mSdkManager, mSdkLog);
- AvdInfo info = avdManager.getAvd(avdName, true /*validAvdOnly*/);
-
- if (info == null) {
- errorAndExit("There is no valid Android Virtual Device named '%s'.", avdName);
- return;
- }
-
- // This is a rename if there's a new name for the AVD
- String newName = mSdkCommandLine.getParamMoveNewName();
- if (newName != null && newName.equals(info.getName())) {
- // same name, not actually a rename operation
- newName = null;
- }
-
- // This is a move (of the data files) if there's a new location path
- String paramFolderPath = mSdkCommandLine.getParamLocationPath();
- if (paramFolderPath != null) {
- // check if paths are the same. Use File methods to account for OS idiosyncrasies.
- try {
- File f1 = new File(paramFolderPath).getCanonicalFile();
- File f2 = new File(info.getDataFolderPath()).getCanonicalFile();
- if (f1.equals(f2)) {
- // same canonical path, so not actually a move
- paramFolderPath = null;
- }
- } catch (IOException e) {
- // Fail to resolve canonical path. Fail now since a move operation might fail
- // later and be harder to recover from.
- errorAndExit(e.getMessage());
- return;
- }
- }
-
- if (newName == null && paramFolderPath == null) {
- mSdkLog.warning("Move operation aborted: same AVD name, same canonical data path");
- return;
- }
-
- // If a rename was requested and no data move was requested, check if the original
- // data path is our default constructed from the AVD name. In this case we still want
- // to rename that folder too.
- if (newName != null && paramFolderPath == null) {
- // Compute the original data path
- File originalFolder = new File(
- AndroidLocation.getFolder() + AndroidLocation.FOLDER_AVD,
- info.getName() + AvdManager.AVD_FOLDER_EXTENSION);
- if (info.getDataFolderPath() != null &&
- originalFolder.equals(new File(info.getDataFolderPath()))) {
- try {
- // The AVD is using the default data folder path based on the AVD name.
- // That folder needs to be adjusted to use the new name.
- File f = new File(AndroidLocation.getFolder() + AndroidLocation.FOLDER_AVD,
- newName + AvdManager.AVD_FOLDER_EXTENSION);
- paramFolderPath = f.getCanonicalPath();
- } catch (IOException e) {
- // Fail to resolve canonical path. Fail now rather than later.
- errorAndExit(e.getMessage());
- }
- }
- }
-
- // Check for conflicts
- if (newName != null) {
- if (avdManager.getAvd(newName, false /*validAvdOnly*/) != null) {
- errorAndExit("There is already an AVD named '%s'.", newName);
- return;
- }
-
- File ini = info.getIniFile();
- if (ini.equals(AvdInfo.getDefaultIniFile(avdManager, newName))) {
- errorAndExit("The AVD file '%s' is in the way.", ini.getCanonicalPath());
- return;
- }
- }
-
- if (paramFolderPath != null && new File(paramFolderPath).exists()) {
- errorAndExit(
- "There is already a file or directory at '%s'.\nUse --path to specify a different data folder.",
- paramFolderPath);
- }
-
- avdManager.moveAvd(info, newName, paramFolderPath, mSdkLog);
- } catch (AndroidLocationException e) {
- errorAndExit(e.getMessage());
- } catch (IOException e) {
- errorAndExit(e.getMessage());
- }
- }
-
- /**
- * Updates a broken AVD.
- */
- private void updateAvd() {
- try {
- String avdName = mSdkCommandLine.getParamName();
- AvdManager avdManager = AvdManager.getInstance(mSdkManager, mSdkLog);
- avdManager.updateAvd(avdName, mSdkLog);
- } catch (AndroidLocationException e) {
- errorAndExit(e.getMessage());
- } catch (IOException e) {
- errorAndExit(e.getMessage());
- }
- }
-
- /**
- * Updates adb with the USB devices declared in the SDK add-ons.
- */
- private void updateAdb() {
- try {
- mSdkManager.updateAdb();
-
- mSdkLog.info(
- "adb has been updated. You must restart adb with the following commands\n" +
- "\tadb kill-server\n" +
- "\tadb start-server\n");
- } catch (AndroidLocationException e) {
- errorAndExit(e.getMessage());
- } catch (IOException e) {
- errorAndExit(e.getMessage());
- }
- }
-
-
-
- /**
- * Prompts the user to setup a hardware config for a Platform-based AVD.
- * @throws IOException
- */
- private Map<String, String> promptForHardware(IAndroidTarget createTarget,
- Map<String, String> skinHardwareConfig) throws IOException {
- byte[] readLineBuffer = new byte[256];
- String result;
- String defaultAnswer = "no";
-
- mSdkLog.info("%s is a basic Android platform.\n", createTarget.getName());
- mSdkLog.info("Do you wish to create a custom hardware profile [%s]",
- defaultAnswer);
-
- result = readLine(readLineBuffer).trim();
- // handle default:
- if (result.length() == 0) {
- result = defaultAnswer;
- }
-
- if (getBooleanReply(result) == false) {
- // no custom config, return the skin hardware config in case there is one.
- return skinHardwareConfig;
- }
-
- mSdkLog.info("\n"); // empty line
-
- // get the list of possible hardware properties
- File hardwareDefs = new File (mOsSdkFolder + File.separator +
- SdkConstants.OS_SDK_TOOLS_LIB_FOLDER, SdkConstants.FN_HARDWARE_INI);
- Map<String, HardwareProperty> hwMap = HardwareProperties.parseHardwareDefinitions(
- hardwareDefs, null /*sdkLog*/);
-
- HashMap<String, String> map = new HashMap<String, String>();
-
- // we just want to loop on the HardwareProperties
- HardwareProperty[] hwProperties = hwMap.values().toArray(
- new HardwareProperty[hwMap.size()]);
- for (int i = 0 ; i < hwProperties.length ;) {
- HardwareProperty property = hwProperties[i];
-
- String description = property.getDescription();
- if (description != null) {
- mSdkLog.info("%s: %s\n", property.getAbstract(), description);
- } else {
- mSdkLog.info("%s\n", property.getAbstract());
- }
-
- String defaultValue = property.getDefault();
- String defaultFromSkin = skinHardwareConfig != null ? skinHardwareConfig.get(
- property.getName()) : null;
-
- if (defaultFromSkin != null) {
- mSdkLog.info("%s [%s (from skin)]:", property.getName(), defaultFromSkin);
- } else if (defaultValue != null) {
- mSdkLog.info("%s [%s]:", property.getName(), defaultValue);
- } else {
- mSdkLog.info("%s (%s):", property.getName(), property.getType());
- }
-
- result = readLine(readLineBuffer);
- if (result.length() == 0) {
- if (defaultFromSkin != null || defaultValue != null) {
- if (defaultFromSkin != null) {
- // we need to write this one in the AVD file
- map.put(property.getName(), defaultFromSkin);
- }
-
- mSdkLog.info("\n"); // empty line
- i++; // go to the next property if we have a valid default value.
- // if there's no default, we'll redo this property
- }
- continue;
- }
-
- switch (property.getType()) {
- case BOOLEAN:
- try {
- if (getBooleanReply(result)) {
- map.put(property.getName(), "yes");
- i++; // valid reply, move to next property
- } else {
- map.put(property.getName(), "no");
- i++; // valid reply, move to next property
- }
- } catch (IOException e) {
- // display error, and do not increment i to redo this property
- mSdkLog.info("\n%s\n", e.getMessage());
- }
- break;
- case INTEGER:
- try {
- Integer.parseInt(result);
- map.put(property.getName(), result);
- i++; // valid reply, move to next property
- } catch (NumberFormatException e) {
- // display error, and do not increment i to redo this property
- mSdkLog.info("\n%s\n", e.getMessage());
- }
- break;
- case DISKSIZE:
- // TODO check validity
- map.put(property.getName(), result);
- i++; // valid reply, move to next property
- break;
- }
-
- mSdkLog.info("\n"); // empty line
- }
-
- return map;
- }
-
- /**
- * Reads a line from the input stream.
- * @param buffer
- * @throws IOException
- */
- private String readLine(byte[] buffer) throws IOException {
- int count = System.in.read(buffer);
-
- // is the input longer than the buffer?
- if (count == buffer.length && buffer[count-1] != 10) {
- // create a new temp buffer
- byte[] tempBuffer = new byte[256];
-
- // and read the rest
- String secondHalf = readLine(tempBuffer);
-
- // return a concat of both
- return new String(buffer, 0, count) + secondHalf;
- }
-
- // ignore end whitespace
- while (count > 0 && (buffer[count-1] == '\r' || buffer[count-1] == '\n')) {
- count--;
- }
-
- return new String(buffer, 0, count);
- }
-
- /**
- * Reads a line from the input stream, masking it as much as possible.
- */
- @SuppressWarnings("unused")
- private String promptPassword(String prompt) throws IOException {
-
- // Setup a thread that tries to overwrite any input by
- // masking the last character with a space. This is quite
- // crude but is a documented workaround to the lack of a
- // proper password getter.
- final AtomicBoolean keepErasing = new AtomicBoolean(true);
-
- Thread eraser = new Thread(new Runnable() {
- @Override
- public void run() {
- while (keepErasing.get()) {
- System.err.print("\b "); //$NON-NLS-1$. \b=Backspace
- try {
- Thread.sleep(10 /*millis*/);
- } catch (InterruptedException e) {
- // Ignore
- }
- }
- }
- }, "eraser"); //$NON-NLS-1$
-
- try {
- System.err.print(prompt);
- eraser.start();
- byte[] buffer = new byte[256];
- return readLine(buffer);
- } finally {
- keepErasing.set(false);
- try {
- eraser.join();
- } catch (InterruptedException e) {
- // Ignore
- }
- }
- }
-
- /**
- * Returns the boolean value represented by the string.
- * @throws IOException If the value is not a boolean string.
- */
- private boolean getBooleanReply(String reply) throws IOException {
-
- for (String valid : BOOLEAN_YES_REPLIES) {
- if (valid.equalsIgnoreCase(reply)) {
- return true;
- }
- }
-
- for (String valid : BOOLEAN_NO_REPLIES) {
- if (valid.equalsIgnoreCase(reply)) {
- return false;
- }
- }
-
- throw new IOException(String.format("%s is not a valid reply", reply));
- }
-
- private void errorAndExit(String format, Object...args) {
- mSdkLog.error(null, format, args);
- System.exit(1);
- }
-
- /**
- * Converts a symbolic target name (such as those accepted by --target on the command-line)
- * to an internal target index id. A valid target name is either a numeric target id (> 0)
- * or a target hash string.
- * <p/>
- * If the given target can't be mapped, {@link #INVALID_TARGET_ID} (0) is returned.
- * It's up to the caller to output an error.
- * <p/>
- * On success, returns a value > 0.
- */
- private int resolveTargetName(String targetName) {
-
- if (targetName == null) {
- return INVALID_TARGET_ID;
- }
-
- targetName = targetName.trim();
-
- // Case of an integer number
- if (targetName.matches("[0-9]*")) {
- try {
- int n = Integer.parseInt(targetName);
- return n < 1 ? INVALID_TARGET_ID : n;
- } catch (NumberFormatException e) {
- // Ignore. Should not happen.
- }
- }
-
- // Let's try to find a platform or addon name.
- IAndroidTarget[] targets = mSdkManager.getTargets();
- for (int i = 0; i < targets.length; i++) {
- if (targetName.equals(targets[i].hashString())) {
- return i + 1;
- }
- }
-
- return INVALID_TARGET_ID;
- }
-}
diff --git a/sdkmanager/app/src/main/java/com/android/sdkmanager/SdkCommandLine.java b/sdkmanager/app/src/main/java/com/android/sdkmanager/SdkCommandLine.java
deleted file mode 100644
index 6a74c29..0000000
--- a/sdkmanager/app/src/main/java/com/android/sdkmanager/SdkCommandLine.java
+++ /dev/null
@@ -1,599 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.sdkmanager;
-
-import com.android.sdklib.SdkManager;
-import com.android.sdklib.repository.SdkRepoConstants;
-import com.android.sdklib.util.CommandLineParser;
-import com.android.utils.ILogger;
-
-import java.util.Arrays;
-
-
-/**
- * Specific command-line flags for the {@link SdkManager}.
- */
-class SdkCommandLine extends CommandLineParser {
-
- /*
- * Steps needed to add a new action:
- * - Each action is defined as a "verb object" followed by parameters.
- * - Either reuse a VERB_ constant or define a new one.
- * - Either reuse an OBJECT_ constant or define a new one.
- * - Add a new entry to mAction with a one-line help summary.
- * - In the constructor, add a define() call for each parameter (either mandatory
- * or optional) for the given action.
- */
-
- public final static String VERB_LIST = "list"; //$NON-NLS-1$
- public final static String VERB_CREATE = "create"; //$NON-NLS-1$
- public final static String VERB_MOVE = "move"; //$NON-NLS-1$
- public final static String VERB_DELETE = "delete"; //$NON-NLS-1$
- public final static String VERB_UPDATE = "update"; //$NON-NLS-1$
- public final static String VERB_SDK = "sdk"; //$NON-NLS-1$
- public final static String VERB_AVD = "avd"; //$NON-NLS-1$
-
- public static final String OBJECT_SDK = "sdk"; //$NON-NLS-1$
- public static final String OBJECT_AVD = "avd"; //$NON-NLS-1$
- public static final String OBJECT_AVDS = "avds"; //$NON-NLS-1$
- public static final String OBJECT_TARGET = "target"; //$NON-NLS-1$
- public static final String OBJECT_TARGETS = "targets"; //$NON-NLS-1$
- public static final String OBJECT_PROJECT = "project"; //$NON-NLS-1$
- public static final String OBJECT_TEST_PROJECT = "test-project"; //$NON-NLS-1$
- public static final String OBJECT_UITEST_PROJECT = "uitest-project"; //$NON-NLS-1$
- public static final String OBJECT_LIB_PROJECT = "lib-project"; //$NON-NLS-1$
- public static final String OBJECT_ADB = "adb"; //$NON-NLS-1$
-
- public static final String ARG_ALIAS = "alias"; //$NON-NLS-1$
- public static final String ARG_ACTIVITY = "activity"; //$NON-NLS-1$
-
- public static final String KEY_ACTIVITY = ARG_ACTIVITY;
- public static final String KEY_PACKAGE = "package"; //$NON-NLS-1$
- public static final String KEY_MODE = "mode"; //$NON-NLS-1$
- public static final String KEY_TARGET_ID = OBJECT_TARGET;
- public static final String KEY_NAME = "name"; //$NON-NLS-1$
- public static final String KEY_LIBRARY = "library"; //$NON-NLS-1$
- public static final String KEY_PATH = "path"; //$NON-NLS-1$
- public static final String KEY_FILTER = "filter"; //$NON-NLS-1$
- public static final String KEY_SKIN = "skin"; //$NON-NLS-1$
- public static final String KEY_SDCARD = "sdcard"; //$NON-NLS-1$
- public static final String KEY_FORCE = "force"; //$NON-NLS-1$
- public static final String KEY_RENAME = "rename"; //$NON-NLS-1$
- public static final String KEY_SUBPROJECTS = "subprojects"; //$NON-NLS-1$
- public static final String KEY_MAIN_PROJECT = "main"; //$NON-NLS-1$
- public static final String KEY_NO_UI = "no-ui"; //$NON-NLS-1$
- public static final String KEY_NO_HTTPS = "no-https"; //$NON-NLS-1$
- public static final String KEY_PROXY_PORT = "proxy-port"; //$NON-NLS-1$
- public static final String KEY_PROXY_HOST = "proxy-host"; //$NON-NLS-1$
- public static final String KEY_DRY_MODE = "dry-mode"; //$NON-NLS-1$
- public static final String KEY_ALL = "all"; //$NON-NLS-1$
- public static final String KEY_EXTENDED = "extended"; //$NON-NLS-1$
- public static final String KEY_SNAPSHOT = "snapshot"; //$NON-NLS-1$
- public static final String KEY_COMPACT = "compact"; //$NON-NLS-1$
- public static final String KEY_EOL_NULL = "null"; //$NON-NLS-1$
- public static final String KEY_ABI = "abi"; //$NON-NLS-1$
- public static final String KEY_ACCOUNT = "account"; //$NON-NLS-1$
- public static final String KEY_KEYSTORE = "keystore"; //$NON-NLS-1$
- public static final String KEY_ALIAS = "alias"; //$NON-NLS-1$
- public static final String KEY_STOREPASS = "storepass"; //$NON-NLS-1$
- public static final String KEY_KEYPASS = "keypass"; //$NON-NLS-1$
- public static final String KEY_CLEAR_CACHE = "clear-cache"; //$NON-NLS-1$
-
- /**
- * Action definitions for SdkManager command line.
- * <p/>
- * This list serves two purposes: first it is used to know which verb/object
- * actions are acceptable on the command-line; second it provides a summary
- * for each action that is printed in the help.
- * <p/>
- * Each entry is a string array with:
- * <ul>
- * <li> the verb.
- * <li> an object (use #NO_VERB_OBJECT if there's no object).
- * <li> a description.
- * <li> an alternate form for the object (e.g. plural).
- * </ul>
- */
- private final static String[][] ACTIONS = {
-
- { VERB_SDK, NO_VERB_OBJECT,
- "Displays the SDK Manager window." },
- { VERB_AVD, NO_VERB_OBJECT,
- "Displays the AVD Manager window.",
- },
-
- { VERB_LIST, NO_VERB_OBJECT,
- "Lists existing targets or virtual devices." },
- { VERB_LIST, OBJECT_AVD,
- "Lists existing Android Virtual Devices.",
- OBJECT_AVDS },
- { VERB_LIST, OBJECT_TARGET,
- "Lists existing targets.",
- OBJECT_TARGETS },
- { VERB_LIST, OBJECT_SDK,
- "Lists remote SDK repository." },
-
- { VERB_CREATE, OBJECT_AVD,
- "Creates a new Android Virtual Device." },
- { VERB_MOVE, OBJECT_AVD,
- "Moves or renames an Android Virtual Device." },
- { VERB_DELETE, OBJECT_AVD,
- "Deletes an Android Virtual Device." },
- { VERB_UPDATE, OBJECT_AVD,
- "Updates an Android Virtual Device to match the folders of a new SDK." },
-
- { VERB_CREATE, OBJECT_PROJECT,
- "Creates a new Android project." },
- { VERB_UPDATE, OBJECT_PROJECT,
- "Updates an Android project (must already have an AndroidManifest.xml)." },
-
- { VERB_CREATE, OBJECT_TEST_PROJECT,
- "Creates a new Android project for a test package." },
- { VERB_UPDATE, OBJECT_TEST_PROJECT,
- "Updates the Android project for a test package (must already have an AndroidManifest.xml)." },
-
- { VERB_CREATE, OBJECT_LIB_PROJECT,
- "Creates a new Android library project." },
- { VERB_UPDATE, OBJECT_LIB_PROJECT,
- "Updates an Android library project (must already have an AndroidManifest.xml)." },
-
- { VERB_CREATE, OBJECT_UITEST_PROJECT,
- "Creates a new UI test project." },
-
- { VERB_UPDATE, OBJECT_ADB,
- "Updates adb to support the USB devices declared in the SDK add-ons." },
-
- { VERB_UPDATE, OBJECT_SDK,
- "Updates the SDK by suggesting new platforms to install if available." },
- };
-
- public SdkCommandLine(ILogger logger) {
- super(logger, ACTIONS);
-
- // The following defines the parameters of the actions defined in mAction.
-
- // --- generic actions that can work on any verb ---
-
- define(Mode.BOOLEAN, false,
- GLOBAL_FLAG_VERB, NO_VERB_OBJECT, ""/*shortName*/, KEY_CLEAR_CACHE, //$NON-NLS-1$
- "Clear the SDK Manager repository manifest cache.", false); //$NON-NLS-1$
-
- // --- list avds ---
-
- define(Mode.BOOLEAN, false,
- VERB_LIST, OBJECT_AVD, "c", KEY_COMPACT, //$NON-NLS-1$
- "Compact output (suitable for scripts)", false);
-
- define(Mode.BOOLEAN, false,
- VERB_LIST, OBJECT_AVD, "0", KEY_EOL_NULL, //$NON-NLS-1$
- "Terminates lines with \\0 instead of \\n (e.g. for xargs -0). Only used by --" + KEY_COMPACT + ".",
- false);
-
- // --- list targets ---
-
- define(Mode.BOOLEAN, false,
- VERB_LIST, OBJECT_TARGET, "c", KEY_COMPACT, //$NON-NLS-1$
- "Compact output (suitable for scripts)", false);
-
- define(Mode.BOOLEAN, false,
- VERB_LIST, OBJECT_TARGET, "0", KEY_EOL_NULL, //$NON-NLS-1$
- "Terminates lines with \\0 instead of \\n (e.g. for xargs -0) Only used by --" + KEY_COMPACT + ".",
- false);
-
- // --- create avd ---
-
- define(Mode.STRING, false,
- VERB_CREATE, OBJECT_AVD, "p", KEY_PATH, //$NON-NLS-1$
- "Directory where the new AVD will be created.", null);
- define(Mode.STRING, true,
- VERB_CREATE, OBJECT_AVD, "n", KEY_NAME, //$NON-NLS-1$
- "Name of the new AVD.", null);
- define(Mode.STRING, true,
- VERB_CREATE, OBJECT_AVD, "t", KEY_TARGET_ID, //$NON-NLS-1$
- "Target ID of the new AVD.", null);
- define(Mode.STRING, false,
- VERB_CREATE, OBJECT_AVD, "s", KEY_SKIN, //$NON-NLS-1$
- "Skin for the new AVD.", null);
- define(Mode.STRING, false,
- VERB_CREATE, OBJECT_AVD, "c", KEY_SDCARD, //$NON-NLS-1$
- "Path to a shared SD card image, or size of a new sdcard for the new AVD.", null);
- define(Mode.BOOLEAN, false,
- VERB_CREATE, OBJECT_AVD, "f", KEY_FORCE, //$NON-NLS-1$
- "Forces creation (overwrites an existing AVD)", false);
- define(Mode.BOOLEAN, false,
- VERB_CREATE, OBJECT_AVD, "a", KEY_SNAPSHOT, //$NON-NLS-1$
- "Place a snapshots file in the AVD, to enable persistence.", false);
- define(Mode.STRING, false,
- VERB_CREATE, OBJECT_AVD, "b", KEY_ABI, //$NON-NLS-1$
- "The ABI to use for the AVD. The default is to auto-select the ABI if the platform has only one ABI for its system images.",
- null);
-
- // --- delete avd ---
-
- define(Mode.STRING, true,
- VERB_DELETE, OBJECT_AVD, "n", KEY_NAME, //$NON-NLS-1$
- "Name of the AVD to delete.", null);
-
- // --- move avd ---
-
- define(Mode.STRING, true,
- VERB_MOVE, OBJECT_AVD, "n", KEY_NAME, //$NON-NLS-1$
- "Name of the AVD to move or rename.", null);
- define(Mode.STRING, false,
- VERB_MOVE, OBJECT_AVD, "r", KEY_RENAME, //$NON-NLS-1$
- "New name of the AVD.", null);
- define(Mode.STRING, false,
- VERB_MOVE, OBJECT_AVD, "p", KEY_PATH, //$NON-NLS-1$
- "Path to the AVD's new directory.", null);
-
- // --- update avd ---
-
- define(Mode.STRING, true,
- VERB_UPDATE, OBJECT_AVD, "n", KEY_NAME, //$NON-NLS-1$
- "Name of the AVD to update", null);
-
- // --- list sdk ---
-
- define(Mode.BOOLEAN, false,
- VERB_LIST, OBJECT_SDK, "u", KEY_NO_UI, //$NON-NLS-1$
- "Displays list result on console (no GUI)", true);
-
- define(Mode.BOOLEAN, false,
- VERB_LIST, OBJECT_SDK, "s", KEY_NO_HTTPS, //$NON-NLS-1$
- "Uses HTTP instead of HTTPS (the default) for downloads.", false);
-
- define(Mode.STRING, false,
- VERB_LIST, OBJECT_SDK, "", KEY_PROXY_PORT, //$NON-NLS-1$
- "HTTP/HTTPS proxy port (overrides settings if defined)",
- null);
-
- define(Mode.STRING, false,
- VERB_LIST, OBJECT_SDK, "", KEY_PROXY_HOST, //$NON-NLS-1$
- "HTTP/HTTPS proxy host (overrides settings if defined)",
- null);
-
- define(Mode.BOOLEAN, false,
- VERB_LIST, OBJECT_SDK, "a", KEY_ALL, //$NON-NLS-1$
- "Lists all available packages (including obsolete and installed ones)",
- false);
-
- define(Mode.BOOLEAN, false,
- VERB_LIST, OBJECT_SDK, "o", "obsolete", //$NON-NLS-1$
- "Deprecated. Please use --all instead.",
- false);
-
- define(Mode.BOOLEAN, false,
- VERB_LIST, OBJECT_SDK, "e", KEY_EXTENDED, //$NON-NLS-1$
- "Displays extended details on each package",
- false);
-
- // --- update sdk ---
-
- define(Mode.BOOLEAN, false,
- VERB_UPDATE, OBJECT_SDK, "u", KEY_NO_UI, //$NON-NLS-1$
- "Updates from command-line (does not display the GUI)", false);
-
- define(Mode.BOOLEAN, false,
- VERB_UPDATE, OBJECT_SDK, "s", KEY_NO_HTTPS, //$NON-NLS-1$
- "Uses HTTP instead of HTTPS (the default) for downloads.", false);
-
- define(Mode.STRING, false,
- VERB_UPDATE, OBJECT_SDK, "", KEY_PROXY_PORT, //$NON-NLS-1$
- "HTTP/HTTPS proxy port (overrides settings if defined)",
- null);
-
- define(Mode.STRING, false,
- VERB_UPDATE, OBJECT_SDK, "", KEY_PROXY_HOST, //$NON-NLS-1$
- "HTTP/HTTPS proxy host (overrides settings if defined)",
- null);
-
- define(Mode.BOOLEAN, false,
- VERB_UPDATE, OBJECT_SDK, "f", KEY_FORCE, //$NON-NLS-1$
- "Forces replacement of a package or its parts, even if something has been modified.",
- false);
-
- define(Mode.STRING, false,
- VERB_UPDATE, OBJECT_SDK, "t", KEY_FILTER, //$NON-NLS-1$
- "A filter that limits the update to the specified types of packages in the form of a comma-separated list of " +
- Arrays.toString(SdkRepoConstants.NODES) +
- ". This also accepts the identifiers returned by 'list sdk --extended'.",
- null);
-
- define(Mode.BOOLEAN, false,
- VERB_UPDATE, OBJECT_SDK, "a", KEY_ALL, //$NON-NLS-1$
- "Includes all packages (such as obsolete and non-dependent ones.)",
- false);
-
- define(Mode.BOOLEAN, false,
- VERB_UPDATE, OBJECT_SDK, "p", "obsolete", //$NON-NLS-1$
- "Deprecated. Please use --all instead.",
- false);
-
- define(Mode.BOOLEAN, false,
- VERB_UPDATE, OBJECT_SDK, "n", KEY_DRY_MODE, //$NON-NLS-1$
- "Simulates the update but does not download or install anything.",
- false);
-
- // --- create project ---
-
- /* Disabled for ADT 0.9 / Cupcake SDK 1.5_r1 release. [bug #1795718].
- This currently does not work, the alias build rules need to be fixed.
-
- define(Mode.ENUM, true,
- VERB_CREATE, OBJECT_PROJECT, "m", KEY_MODE, //$NON-NLS-1$
- "Project mode", new String[] { ARG_ACTIVITY, ARG_ALIAS });
- */
- define(Mode.STRING, true,
- VERB_CREATE, OBJECT_PROJECT,
- "p", KEY_PATH,
- "The new project's directory.", null);
- define(Mode.STRING, true,
- VERB_CREATE, OBJECT_PROJECT, "t", KEY_TARGET_ID, //$NON-NLS-1$
- "Target ID of the new project.", null);
- define(Mode.STRING, true,
- VERB_CREATE, OBJECT_PROJECT, "k", KEY_PACKAGE, //$NON-NLS-1$
- "Android package name for the application.", null);
- define(Mode.STRING, true,
- VERB_CREATE, OBJECT_PROJECT, "a", KEY_ACTIVITY, //$NON-NLS-1$
- "Name of the default Activity that is created.", null);
- define(Mode.STRING, false,
- VERB_CREATE, OBJECT_PROJECT, "n", KEY_NAME, //$NON-NLS-1$
- "Project name.", null);
-
- // --- create test-project ---
-
- define(Mode.STRING, true,
- VERB_CREATE, OBJECT_TEST_PROJECT, "p", KEY_PATH, //$NON-NLS-1$
- "The new project's directory.", null);
- define(Mode.STRING, false,
- VERB_CREATE, OBJECT_TEST_PROJECT, "n", KEY_NAME, //$NON-NLS-1$
- "Project name.", null);
- define(Mode.STRING, true,
- VERB_CREATE, OBJECT_TEST_PROJECT, "m", KEY_MAIN_PROJECT, //$NON-NLS-1$
- "Path to directory of the app under test, relative to the test project directory.",
- null);
-
- // --- create uitest-project ---
-
- define(Mode.STRING, true,
- VERB_CREATE, OBJECT_UITEST_PROJECT, "p", KEY_PATH, //$NON-NLS-1$
- "The new project's directory.", null);
- define(Mode.STRING, false,
- VERB_CREATE, OBJECT_UITEST_PROJECT, "n", KEY_NAME, //$NON-NLS-1$
- "Project name.", null);
- define(Mode.STRING, true,
- VERB_CREATE, OBJECT_UITEST_PROJECT, "t", KEY_TARGET_ID, //$NON-NLS-1$
- "Target ID of the new project.", null);
-
- // --- create lib-project ---
-
- define(Mode.STRING, true,
- VERB_CREATE, OBJECT_LIB_PROJECT, "p", KEY_PATH, //$NON-NLS-1$
- "The new project's directory.", null);
- define(Mode.STRING, true,
- VERB_CREATE, OBJECT_LIB_PROJECT, "t", KEY_TARGET_ID, //$NON-NLS-1$
- "Target ID of the new project.", null);
- define(Mode.STRING, false,
- VERB_CREATE, OBJECT_LIB_PROJECT, "n", KEY_NAME, //$NON-NLS-1$
- "Project name.", null);
- define(Mode.STRING, true,
- VERB_CREATE, OBJECT_LIB_PROJECT, "k", KEY_PACKAGE, //$NON-NLS-1$
- "Android package name for the library.", null);
-
- // --- update project ---
-
- define(Mode.STRING, true,
- VERB_UPDATE, OBJECT_PROJECT, "p", KEY_PATH, //$NON-NLS-1$
- "The project's directory.", null);
- define(Mode.STRING, false,
- VERB_UPDATE, OBJECT_PROJECT, "t", KEY_TARGET_ID, //$NON-NLS-1$
- "Target ID to set for the project.", null);
- define(Mode.STRING, false,
- VERB_UPDATE, OBJECT_PROJECT, "n", KEY_NAME, //$NON-NLS-1$
- "Project name.", null);
- define(Mode.BOOLEAN, false,
- VERB_UPDATE, OBJECT_PROJECT, "s", KEY_SUBPROJECTS, //$NON-NLS-1$
- "Also updates any projects in sub-folders, such as test projects.", false);
- define(Mode.STRING, false,
- VERB_UPDATE, OBJECT_PROJECT, "l", KEY_LIBRARY, //$NON-NLS-1$
- "Directory of an Android library to add, relative to this project's directory.",
- null);
-
- // --- update test project ---
-
- define(Mode.STRING, true,
- VERB_UPDATE, OBJECT_TEST_PROJECT, "p", KEY_PATH, //$NON-NLS-1$
- "The project's directory.", null);
- define(Mode.STRING, true,
- VERB_UPDATE, OBJECT_TEST_PROJECT, "m", KEY_MAIN_PROJECT, //$NON-NLS-1$
- "Directory of the app under test, relative to the test project directory.", null);
-
- // --- update lib project ---
-
- define(Mode.STRING, true,
- VERB_UPDATE, OBJECT_LIB_PROJECT, "p", KEY_PATH, //$NON-NLS-1$
- "The project's directory.", null);
- define(Mode.STRING, false,
- VERB_UPDATE, OBJECT_LIB_PROJECT, "t", KEY_TARGET_ID, //$NON-NLS-1$
- "Target ID to set for the project.", null);
-
- }
-
- @Override
- public boolean acceptLackOfVerb() {
- return true;
- }
-
- // -- some helpers for generic action flags
-
- /** Helper that returns true if --verbose was requested. */
- public boolean hasClearCache() {
- return
- ((Boolean) getValue(GLOBAL_FLAG_VERB, NO_VERB_OBJECT, KEY_CLEAR_CACHE)).booleanValue();
- }
-
- /** Helper to retrieve the --path value. */
- public String getParamLocationPath() {
- return (String) getValue(null, null, KEY_PATH);
- }
-
- /**
- * Helper to retrieve the --target id value.
- * The id is a string. It can be one of:
- * - an integer, in which case it's the index of the target (cf "android list targets")
- * - a symbolic name such as android-N for platforn API N
- * - a symbolic add-on name such as written in the avd/*.ini files,
- * e.g. "Google Inc.:Google APIs:3"
- */
- public String getParamTargetId() {
- return (String) getValue(null, null, KEY_TARGET_ID);
- }
-
- /** Helper to retrieve the --name value. */
- public String getParamName() {
- return (String) getValue(null, null, KEY_NAME);
- }
-
- /** Helper to retrieve the --skin value. */
- public String getParamSkin() {
- return (String) getValue(null, null, KEY_SKIN);
- }
-
- /** Helper to retrieve the --sdcard value. */
- public String getParamSdCard() {
- return (String) getValue(null, null, KEY_SDCARD);
- }
-
- /** Helper to retrieve the --force flag. */
- public boolean getFlagForce() {
- return ((Boolean) getValue(null, null, KEY_FORCE)).booleanValue();
- }
-
- /** Helper to retrieve the --snapshot flag. */
- public boolean getFlagSnapshot() {
- return ((Boolean) getValue(null, null, KEY_SNAPSHOT)).booleanValue();
- }
-
- // -- some helpers for avd action flags
-
- /** Helper to retrieve the --rename value for a move verb. */
- public String getParamMoveNewName() {
- return (String) getValue(VERB_MOVE, null, KEY_RENAME);
- }
-
-
- // -- some helpers for project action flags
-
- /** Helper to retrieve the --package value.
- * @param directObject the directObject of the action, either {@link #OBJECT_PROJECT}
- * or {@link #OBJECT_LIB_PROJECT}.
- */
- public String getParamProjectPackage(String directObject) {
- return ((String) getValue(null, directObject, KEY_PACKAGE));
- }
-
- /** Helper to retrieve the --activity for any project action. */
- public String getParamProjectActivity() {
- return ((String) getValue(null, OBJECT_PROJECT, KEY_ACTIVITY));
- }
-
- /** Helper to retrieve the --library value.
- * @param directObject the directObject of the action, either {@link #OBJECT_PROJECT}
- * or {@link #OBJECT_LIB_PROJECT}.
- */
- public String getParamProjectLibrary(String directObject) {
- return ((String) getValue(null, directObject, KEY_LIBRARY));
- }
-
-
- /** Helper to retrieve the --subprojects for any project action. */
- public boolean getParamSubProject() {
- return ((Boolean) getValue(null, OBJECT_PROJECT, KEY_SUBPROJECTS)).booleanValue();
- }
-
- // -- some helpers for test-project action flags
-
- /** Helper to retrieve the --main value. */
- public String getParamTestProjectMain() {
- return ((String) getValue(null, null, KEY_MAIN_PROJECT));
- }
-
-
- // -- some helpers for update sdk flags
-
- /** Helper to retrieve the --no-ui flag. */
- public boolean getFlagNoUI(String verb) {
- return ((Boolean) getValue(verb, null, KEY_NO_UI)).booleanValue();
- }
-
- /** Helper to retrieve the --no-https flag. */
- public boolean getFlagNoHttps() {
- return ((Boolean) getValue(null, null, KEY_NO_HTTPS)).booleanValue();
- }
-
- /** Helper to retrieve the --dry-mode flag. */
- public boolean getFlagDryMode() {
- return ((Boolean) getValue(null, null, KEY_DRY_MODE)).booleanValue();
- }
-
- /** Helper to retrieve the --obsolete flag. */
- public boolean getFlagObsolete() {
- return ((Boolean) getValue(null, null, "obsolete")).booleanValue();
- }
-
- /** Helper to retrieve the --all flag. */
- public boolean getFlagAll() {
- return ((Boolean) getValue(null, null, KEY_ALL)).booleanValue();
- }
-
- /** Helper to retrieve the --extended flag. */
- public boolean getFlagExtended() {
- return ((Boolean) getValue(null, null, KEY_EXTENDED)).booleanValue();
- }
-
- /** Helper to retrieve the --filter value. */
- public String getParamFilter() {
- return ((String) getValue(null, null, KEY_FILTER));
- }
-
- /** Helper to retrieve the --abi value. */
- public String getParamAbi() {
- return ((String) getValue(null, null, KEY_ABI));
- }
-
- /** Helper to retrieve the --proxy-host value. */
- public String getParamProxyHost() {
- return ((String) getValue(null, null, KEY_PROXY_HOST));
- }
-
- /** Helper to retrieve the --proxy-port value. */
- public String getParamProxyPort() {
- return ((String) getValue(null, null, KEY_PROXY_PORT));
- }
-
- // -- some helpers for list avds and list targets flags
-
- /** Helper to retrieve the --compact value. */
- public boolean getFlagCompact() {
- return ((Boolean) getValue(null, null, KEY_COMPACT)).booleanValue();
- }
-
- /** Helper to retrieve the --null value. */
- public boolean getFlagEolNull() {
- return ((Boolean) getValue(null, null, KEY_EOL_NULL)).booleanValue();
- }
-}
diff --git a/sdkmanager/app/src/test/java/com/android/sdklib/SdkManagerTestCase.java b/sdkmanager/app/src/test/java/com/android/sdklib/SdkManagerTestCase.java
deleted file mode 100755
index ab45785..0000000
--- a/sdkmanager/app/src/test/java/com/android/sdklib/SdkManagerTestCase.java
+++ /dev/null
@@ -1,272 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- Note: this file is duplicated from tools/base/sdklib/src/tests.
- The version of sdkmanager-tests in sdk.git does no longer have
- access to sdklib-tests.
- FIXME: if this generic enough, move it to test-utils.
-*/
-
-package com.android.sdklib;
-
-
-import com.android.SdkConstants;
-import com.android.prefs.AndroidLocation;
-import com.android.prefs.AndroidLocation.AndroidLocationException;
-import com.android.sdklib.internal.avd.AvdManager;
-import com.android.sdklib.io.FileOp;
-import com.android.sdklib.mock.MockLog;
-import com.android.sdklib.repository.PkgProps;
-import com.android.utils.ILogger;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-/**
- * Test case that allocates a temporary SDK, a temporary AVD base folder
- * with an SdkManager and an AvdManager that points to them.
- */
-public class SdkManagerTestCase extends TestCase {
-
- private File mFakeSdk;
- private MockLog mLog;
- private SdkManager mSdkManager;
- private TmpAvdManager mAvdManager;
-
- /** Returns the {@link MockLog} for this test case. */
- public MockLog getLog() {
- return mLog;
- }
-
- /** Returns the {@link SdkManager} for this test case. */
- public SdkManager getSdkManager() {
- return mSdkManager;
- }
-
- /** Returns the {@link AvdManager} for this test case. */
- public TmpAvdManager getAvdManager() {
- return mAvdManager;
- }
-
- /**
- * Sets up a {@link MockLog}, a fake SDK in a temporary directory
- * and an AVD Manager pointing to an initially-empty AVD directory.
- */
- @Override
- public void setUp() throws Exception {
- mLog = new MockLog();
- mFakeSdk = makeFakeSdk();
- mSdkManager = SdkManager.createManager(mFakeSdk.getAbsolutePath(), mLog);
- assertNotNull("SdkManager location was invalid", mSdkManager);
-
- mAvdManager = new TmpAvdManager(mSdkManager, mLog);
- }
-
- /**
- * Removes the temporary SDK and AVD directories.
- */
- @Override
- public void tearDown() throws Exception {
- deleteDir(mFakeSdk);
- }
-
- /**
- * A empty test method to placate the JUnit test runner, which doesn't
- * like TestCase classes with no test methods.
- */
- public void testPlaceholder() {
- }
-
- /**
- * An {@link AvdManager} that uses a temporary directory
- * located <em>inside</em> the SDK directory for testing.
- * The AVD list should be initially empty.
- */
- protected static class TmpAvdManager extends AvdManager {
-
- /*
- * Implementation detail:
- * - When the super.AvdManager constructor is invoked, it will invoke
- * the buildAvdFilesList() to fill the initial AVD list, which will in
- * turn call getBaseAvdFolder().
- * - That's why mTmpAvdRoot is initialized in getAvdRoot() rather than
- * in the constructor, since we can't initialize fields before the super()
- * call.
- */
-
- /**
- * AVD Root, initialized "lazily" when the AVD root is first requested.
- */
- private File mTmpAvdRoot;
-
- public TmpAvdManager(SdkManager sdkManager, ILogger log) throws AndroidLocationException {
- super(sdkManager, log);
- }
-
- @Override
- public String getBaseAvdFolder() throws AndroidLocationException {
- if (mTmpAvdRoot == null) {
- mTmpAvdRoot = new File(getSdkManager().getLocation(), "tmp_avds");
- mTmpAvdRoot.mkdirs();
- }
- return mTmpAvdRoot.getAbsolutePath();
- }
- }
-
- /**
- * Build enough of a skeleton SDK to make the tests pass.
- * <p/>
- * Ideally this wouldn't touch the file system but the current
- * structure of the SdkManager and AvdManager makes this difficult.
- *
- * @return Path to the temporary SDK root
- * @throws IOException
- */
- private File makeFakeSdk() throws IOException {
- // First we create a temp file to "reserve" the temp directory name we want to use.
- File sdkDir = File.createTempFile(
- this.getClass().getSimpleName() + '_' + this.getName(), null);
- // Then erase the file and make the directory
- sdkDir.delete();
- sdkDir.mkdirs();
-
- AndroidLocation.resetFolder();
- File addonsDir = new File(sdkDir, SdkConstants.FD_ADDONS);
- addonsDir.mkdir();
-
- File toolsDir = new File(sdkDir, SdkConstants.OS_SDK_TOOLS_FOLDER);
- toolsDir.mkdir();
- new File(toolsDir, SdkConstants.androidCmdName()).createNewFile();
- new File(toolsDir, SdkConstants.FN_EMULATOR).createNewFile();
-
- // TODO makePlatformTools with at least a source props
-
- File toolsLibEmuDir = new File(sdkDir, SdkConstants.OS_SDK_TOOLS_LIB_FOLDER + "emulator");
- toolsLibEmuDir.mkdirs();
- new File(toolsLibEmuDir, "snapshots.img").createNewFile();
- File platformsDir = new File(sdkDir, SdkConstants.FD_PLATFORMS);
-
- // Creating a fake target here on down
- File targetDir = makeFakeTargetInternal(platformsDir);
-
- File imagesDir = new File(targetDir, "images");
- makeFakeSysImgInternal(imagesDir, SdkConstants.ABI_ARMEABI);
-
- makeFakeSkinInternal(targetDir);
- makeFakeSourceInternal(sdkDir);
- return sdkDir;
- }
-
- /**
- * Creates the system image folder and places a fake userdata.img in it.
- *
- * @param systemImage A system image with a valid location.
- * @throws IOException if the file fails to be created.
- */
- protected void makeSystemImageFolder(ISystemImage systemImage) throws IOException {
- File imagesDir = systemImage.getLocation();
- imagesDir.mkdirs();
-
- makeFakeSysImgInternal(imagesDir, systemImage.getAbiType());
- }
-
- //----
-
- /** Utility used by {@link #makeFakeSdk()} to create a fake target with API 0, rev 0. */
- private File makeFakeTargetInternal(File platformsDir) throws IOException {
- File targetDir = new File(platformsDir, "v0_0");
- targetDir.mkdirs();
- new File(targetDir, SdkConstants.FN_FRAMEWORK_LIBRARY).createNewFile();
- new File(targetDir, SdkConstants.FN_FRAMEWORK_AIDL).createNewFile();
-
- File sourceProp = new File(targetDir, SdkConstants.FN_SOURCE_PROP);
- sourceProp.createNewFile();
- FileWriter out = new FileWriter(sourceProp);
- out.write(PkgProps.LAYOUTLIB_API + "=5\n");
- out.write(PkgProps.LAYOUTLIB_REV + "=2\n");
- out.close();
-
- File buildProp = new File(targetDir, SdkConstants.FN_BUILD_PROP);
- out = new FileWriter(buildProp);
- out.write(SdkManager.PROP_VERSION_RELEASE + "=0.0\n");
- out.write(SdkManager.PROP_VERSION_SDK + "=0\n");
- out.write(SdkManager.PROP_VERSION_CODENAME + "=REL\n");
- out.close();
- return targetDir;
- }
-
- /** Utility to create a fake sys image in the given folder. */
- private void makeFakeSysImgInternal(File imagesDir, String abiType) throws IOException {
- imagesDir.mkdirs();
- new File(imagesDir, "userdata.img").createNewFile();
-
- File sourceProp = new File(imagesDir, SdkConstants.FN_SOURCE_PROP);
- sourceProp.createNewFile();
- FileWriter out = new FileWriter(sourceProp);
- out.write(PkgProps.VERSION_API_LEVEL + "=0\n");
- out.write(PkgProps.SYS_IMG_ABI + "=" + abiType + "\n");
- out.close();
- }
-
- /** Utility to make a fake skin for the given target */
- private void makeFakeSkinInternal(File targetDir) {
- FileOp.append(targetDir, "skins", "HVGA").mkdirs();
- }
-
- /** Utility to create a fake source with a few files in the given sdk folder. */
- private void makeFakeSourceInternal(File sdkDir) throws IOException {
- File sourcesDir = FileOp.append(sdkDir, SdkConstants.FD_PKG_SOURCES, "android-0");
- sourcesDir.mkdirs();
-
- File sourceProp = new File(sourcesDir, SdkConstants.FN_SOURCE_PROP);
- sourceProp.createNewFile();
- FileWriter out = new FileWriter(sourceProp);
- out.write(PkgProps.VERSION_API_LEVEL + "=0\n");
- out.close();
-
- File dir1 = FileOp.append(sourcesDir, "src", "com", "android");
- dir1.mkdirs();
- FileOp.append(dir1, "File1.java").createNewFile();
- FileOp.append(dir1, "File2.java").createNewFile();
-
- FileOp.append(sourcesDir, "res", "values").mkdirs();
- FileOp.append(sourcesDir, "res", "values", "styles.xml").createNewFile();
- }
-
- /**
- * Recursive delete directory. Mostly for fake SDKs.
- *
- * @param root directory to delete
- */
- private void deleteDir(File root) {
- if (root.exists()) {
- for (File file : root.listFiles()) {
- if (file.isDirectory()) {
- deleteDir(file);
- } else {
- file.delete();
- }
- }
- root.delete();
- }
- }
-
-}
diff --git a/sdkmanager/app/src/test/java/com/android/sdklib/mock/MockLog.java b/sdkmanager/app/src/test/java/com/android/sdklib/mock/MockLog.java
deleted file mode 100644
index e64ed51..0000000
--- a/sdkmanager/app/src/test/java/com/android/sdklib/mock/MockLog.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-
-/*
- Note: this file is duplicated from tools/base/sdklib/src/tests.
- The version of sdkmanager-tests in sdk.git does no longer have
- access to sdklib-tests.
- FIXME: if this generic enough, move it to test-utils.
-*/
-
-package com.android.sdklib.mock;
-
-import com.android.annotations.NonNull;
-import com.android.utils.ILogger;
-
-import java.util.ArrayList;
-import java.util.Formatter;
-import java.util.List;
-
-/**
- * An instance of {@link ILogger} that captures all messages to an internal list.
- * Messages can be retrieved later using {@link #toString()}.
- * Useful for unit-tests.
- */
-public class MockLog implements ILogger {
- private ArrayList<String> mMessages = new ArrayList<String>();
-
- private void add(String code, String format, Object... args) {
- Formatter formatter = new Formatter();
- mMessages.add(formatter.format(code + format, args).toString());
- formatter.close();
- }
-
- @Override
- public void warning(@NonNull String format, Object... args) {
- add("W ", format, args);
- }
-
- @Override
- public void info(@NonNull String format, Object... args) {
- add("P ", format, args);
- }
-
- @Override
- public void verbose(@NonNull String format, Object... args) {
- add("V ", format, args);
- }
-
- @Override
- public void error(Throwable t, String format, Object... args) {
- if (t != null) {
- add("T", "%s", t.toString());
- }
- add("E ", format, args);
- }
-
- @Override
- public String toString() {
- return mMessages.toString();
- }
-
- @NonNull
- public List<String> getMessages() {
- return mMessages;
- }
-
- public void clear() {
- mMessages.clear();
- }
-}
diff --git a/sdkmanager/app/src/test/java/com/android/sdkmanager/AvdManagerTest.java b/sdkmanager/app/src/test/java/com/android/sdkmanager/AvdManagerTest.java
deleted file mode 100644
index a376490..0000000
--- a/sdkmanager/app/src/test/java/com/android/sdkmanager/AvdManagerTest.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.sdkmanager;
-
-import com.android.SdkConstants;
-import com.android.io.FileWrapper;
-import com.android.sdklib.IAndroidTarget;
-import com.android.sdklib.SdkManagerTestCase;
-import com.android.sdklib.internal.avd.AvdInfo;
-import com.android.sdklib.internal.project.ProjectProperties;
-
-import java.io.File;
-import java.util.Map;
-
-public class AvdManagerTest extends SdkManagerTestCase {
-
- private IAndroidTarget mTarget;
- private File mAvdFolder;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
-
- mTarget = getSdkManager().getTargets()[0];
- mAvdFolder = AvdInfo.getDefaultAvdFolder(getAvdManager(), getName());
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testCreateAvdWithoutSnapshot() {
-
- getAvdManager().createAvd(
- mAvdFolder,
- this.getName(),
- mTarget,
- SdkConstants.ABI_ARMEABI,
- null, // skinName
- null, // sdName
- null, // properties
- false, // createSnapshot
- false, // removePrevious
- false, // editExisting
- getLog());
-
- assertEquals("[P Created AVD '" + this.getName() + "' based on Android 0.0, ARM (armeabi) processor\n]",
- getLog().toString());
- assertTrue("Expected config.ini in " + mAvdFolder,
- new File(mAvdFolder, "config.ini").exists());
- Map<String, String> map = ProjectProperties.parsePropertyFile(
- new FileWrapper(mAvdFolder, "config.ini"), getLog());
- assertEquals("HVGA", map.get("skin.name"));
- assertEquals("platforms/v0_0/skins/HVGA", map.get("skin.path").replace(File.separatorChar, '/'));
- assertEquals("platforms/v0_0/images/", map.get("image.sysdir.1").replace(File.separatorChar, '/'));
- assertEquals(null, map.get("snapshot.present"));
- assertTrue("Expected userdata.img in " + mAvdFolder,
- new File(mAvdFolder, "userdata.img").exists());
- assertFalse("Expected NO snapshots.img in " + mAvdFolder,
- new File(mAvdFolder, "snapshots.img").exists());
- }
-
- public void testCreateAvdWithSnapshot() {
-
- getAvdManager().createAvd(
- mAvdFolder,
- this.getName(),
- mTarget,
- SdkConstants.ABI_ARMEABI,
- null, // skinName
- null, // sdName
- null, // properties
- true, // createSnapshot
- false, // removePrevious
- false, // editExisting
- getLog());
-
- assertEquals("[P Created AVD '" + this.getName() + "' based on Android 0.0, ARM (armeabi) processor\n]",
- getLog().toString());
- assertTrue("Expected snapshots.img in " + mAvdFolder,
- new File(mAvdFolder, "snapshots.img").exists());
- Map<String, String> map = ProjectProperties.parsePropertyFile(
- new FileWrapper(mAvdFolder, "config.ini"), getLog());
- assertEquals("true", map.get("snapshot.present"));
- }
-}
diff --git a/sdkmanager/app/src/test/java/com/android/sdkmanager/MainTest.java b/sdkmanager/app/src/test/java/com/android/sdkmanager/MainTest.java
deleted file mode 100644
index 24a644b..0000000
--- a/sdkmanager/app/src/test/java/com/android/sdkmanager/MainTest.java
+++ /dev/null
@@ -1,357 +0,0 @@
-/*
- * Copyright (C) 2010 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.sdkmanager;
-
-
-import com.android.SdkConstants;
-import com.android.sdklib.IAndroidTarget;
-import com.android.sdklib.SdkManager;
-import com.android.sdklib.SdkManagerTestCase;
-import com.android.sdklib.internal.avd.AvdInfo;
-import com.android.sdklib.internal.repository.CanceledByUserException;
-import com.android.sdklib.internal.repository.DownloadCache;
-import com.android.sdklib.internal.repository.DownloadCache.Strategy;
-import com.android.sdklib.internal.repository.NullTaskMonitor;
-import com.android.sdklib.repository.SdkAddonConstants;
-import com.android.sdklib.repository.SdkRepoConstants;
-import com.android.utils.Pair;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Set;
-import java.util.TreeSet;
-
-public class MainTest extends SdkManagerTestCase {
-
- private IAndroidTarget mTarget;
- private File mAvdFolder;
-
- @Override
- public void setUp() throws Exception {
- super.setUp();
-
- mTarget = getSdkManager().getTargets()[0];
- mAvdFolder = AvdInfo.getDefaultAvdFolder(getAvdManager(), getName());
- }
-
- @Override
- public void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testDisplayEmptyAvdList() {
- Main main = new Main();
- main.setLogger(getLog());
- getLog().clear();
- main.displayAvdList(getAvdManager());
- assertEquals("[P Available Android Virtual Devices:\n]", getLog().toString());
- }
-
- public void testDisplayAvdListOfOneNonSnapshot() {
- Main main = new Main();
- main.setLogger(getLog());
- getAvdManager().createAvd(
- mAvdFolder,
- this.getName(),
- mTarget,
- SdkConstants.ABI_ARMEABI,
- null, // skinName
- null, // sdName
- null, // properties
- false, // createSnapshot
- false, // removePrevious
- false, // editExisting
- getLog());
-
- getLog().clear();
- main.displayAvdList(getAvdManager());
- assertEquals(
- "[P Available Android Virtual Devices:\n"
- + ", P Name: " + this.getName() + "\n"
- + ", P Path: " + mAvdFolder + "\n"
- + ", P Target: Android 0.0 (API level 0)\n"
- + ", P ABI: armeabi\n"
- + ", P Skin: HVGA\n"
- + "]",
- getLog().toString());
- }
-
- public void testDisplayAvdListOfOneSnapshot() {
- Main main = new Main();
- main.setLogger(getLog());
-
- getAvdManager().createAvd(
- mAvdFolder,
- this.getName(),
- mTarget,
- SdkConstants.ABI_ARMEABI,
- null, // skinName
- null, // sdName
- null, // properties
- true, // createSnapshot
- false, // removePrevious
- false, // editExisting
- getLog());
-
- getLog().clear();
- main.displayAvdList(getAvdManager());
- assertEquals(
- "[P Available Android Virtual Devices:\n"
- + ", P Name: " + this.getName() + "\n"
- + ", P Path: " + mAvdFolder + "\n"
- + ", P Target: Android 0.0 (API level 0)\n"
- + ", P ABI: armeabi\n"
- + ", P Skin: HVGA\n"
- + ", P Snapshot: true\n"
- + "]",
- getLog().toString());
- }
-
- public void testDisplayTargetList() {
- Main main = new Main();
- main.setLogger(getLog());
- main.setSdkManager(getSdkManager());
- getLog().clear();
- main.displayTargetList();
- assertEquals(
- "[P Available Android targets:\n" +
- ", P ----------\n" +
- ", P id: 1 or \"android-0\"\n" +
- ", P Name: Android 0.0\n" +
- ", P Type: Platform\n" +
- ", P API level: 0\n" +
- ", P Revision: 1\n" +
- ", P Skins: , P \n" +
- ", P ABIs : , P armeabi, P \n" +
- "]",
- getLog().toString());
- }
-
- public void testDisplayAbiList() {
- Main main = new Main();
- main.setLogger(getLog());
- main.setSdkManager(getSdkManager());
- getLog().clear();
- main.displayAbiList(mTarget, "message");
- assertEquals(
- "[P message, P armeabi, P \n" +
- "]",
- getLog().toString());
- }
-
- public void testDisplaySkinList() {
- Main main = new Main();
- main.setLogger(getLog());
- main.setSdkManager(getSdkManager());
- getLog().clear();
- main.displaySkinList(mTarget, "message");
- assertEquals(
- "[P message, P \n" +
- "]",
- getLog().toString());
- }
-
- public void testSdkManagerHasChanged() throws IOException {
- Main main = new Main();
- main.setLogger(getLog());
- SdkManager sdkman = getSdkManager();
- main.setSdkManager(sdkman);
- getLog().clear();
-
- assertFalse(sdkman.hasChanged());
-
- File addonsDir = new File(sdkman.getLocation(), SdkConstants.FD_ADDONS);
- assertTrue(addonsDir.isDirectory());
-
- FileWriter readme = new FileWriter(new File(addonsDir, "android.txt"));
- readme.write("test\n");
- readme.close();
-
- // Adding a file doesn't alter sdk.hasChanged
- assertFalse(sdkman.hasChanged());
- sdkman.reloadSdk(getLog());
- assertFalse(sdkman.hasChanged());
-
- File fakeAddon = new File(addonsDir, "google-addon");
- fakeAddon.mkdirs();
- File sourceProps = new File(fakeAddon, SdkConstants.FN_SOURCE_PROP);
- FileWriter propsWriter = new FileWriter(sourceProps);
- propsWriter.write("revision=7\n");
- propsWriter.close();
-
- // Adding a directory does alter sdk.hasChanged even if not a real add-on
- assertTrue(sdkman.hasChanged());
- // Once reloaded, sdk.hasChanged will be reset
- sdkman.reloadSdk(getLog());
- assertFalse(sdkman.hasChanged());
-
- // Changing the source.properties file alters sdk.hasChanged
- propsWriter = new FileWriter(sourceProps);
- propsWriter.write("revision=8\n");
- propsWriter.close();
- assertTrue(sdkman.hasChanged());
- // Once reloaded, sdk.hasChanged will be reset
- sdkman.reloadSdk(getLog());
- assertFalse(sdkman.hasChanged());
- }
-
- public void testCheckFilterValues() {
- // These are the values we expect checkFilterValues() to match.
- String[] expectedValues = {
- "platform",
- "system-image",
- "tool",
- "platform-tool",
- "doc",
- "sample",
- "add-on",
- "extra",
- "source"
- };
-
- Set<String> expectedSet = new TreeSet<String>(Arrays.asList(expectedValues));
-
- // First check the values are actually defined in the proper arrays
- // in the Sdk*Constants.NODES
- for (String node : SdkRepoConstants.NODES) {
- assertTrue(
- String.format(
- "Error: value '%1$s' from SdkRepoConstants.NODES should be used in unit-test",
- node),
- expectedSet.contains(node));
- }
- for (String node : SdkAddonConstants.NODES) {
- assertTrue(
- String.format(
- "Error: value '%1$s' from SdkAddonConstants.NODES should be used in unit-test",
- node),
- expectedSet.contains(node));
- }
-
- // Now check none of these values are NOT present in the NODES arrays
- for (String node : SdkRepoConstants.NODES) {
- expectedSet.remove(node);
- }
- for (String node : SdkAddonConstants.NODES) {
- expectedSet.remove(node);
- }
- assertTrue(
- String.format(
- "Error: values %1$s are missing from Sdk[Repo|Addons]Constants.NODES",
- Arrays.toString(expectedSet.toArray())),
- expectedSet.isEmpty());
-
- // We're done with expectedSet now
- expectedSet = null;
-
- // Finally check that checkFilterValues accepts all these values, one by one.
- Main main = new Main();
- main.setLogger(getLog());
-
- for (int step = 0; step < 3; step++) {
- for (String value : expectedValues) {
- switch(step) {
- // step 0: use value as-is
- case 1:
- // add some whitespace before and after
- value = " " + value + " ";
- break;
- case 2:
- // same with some empty arguments that should get ignored
- value = " ," + value + " , ";
- break;
- }
-
- Pair<String, ArrayList<String>> result = main.checkFilterValues(value);
- assertNull(
- String.format("Expected error to be null for value '%1$s', got: %2$s",
- value, result.getFirst()),
- result.getFirst());
- assertEquals(
- String.format("[%1$s]", value.replace(',', ' ').trim()),
- Arrays.toString(result.getSecond().toArray()));
- }
- }
- }
-
- public void testLocalFileDownload() throws IOException, CanceledByUserException {
- Main main = new Main();
- main.setLogger(getLog());
- SdkManager sdkman = getSdkManager();
- main.setSdkManager(sdkman);
- getLog().clear();
-
- IAndroidTarget target = sdkman.getTargets()[0];
- File sourceProps = new File(target.getLocation(), SdkConstants.FN_SOURCE_PROP);
- assertTrue(sourceProps.isFile());
-
- String urlStr = getFileUrl(sourceProps);
- assertTrue(urlStr.startsWith("file:///"));
-
- DownloadCache cache = new DownloadCache(Strategy.DIRECT);
- NullTaskMonitor monitor = new NullTaskMonitor(getLog());
- Pair<InputStream, Integer> result = cache.openDirectUrl(urlStr, monitor);
- assertNotNull(result);
- assertEquals(200, result.getSecond().intValue());
-
- int len = (int) sourceProps.length();
- byte[] buf = new byte[len];
- FileInputStream is = new FileInputStream(sourceProps);
- is.read(buf);
- is.close();
- String expected = new String(buf, "UTF-8");
-
- buf = new byte[len];
- result.getFirst().read(buf);
- result.getFirst().close();
- String actual = new String(buf, "UTF-8");
- assertEquals(expected, actual);
- }
-
- private String getFileUrl(File file) throws IOException {
- // Note: to create a file:// URL, one would typically use something like
- // f.toURI().toURL().toString(). However this generates a broken path on
- // Windows, namely "C:\\foo" is converted to "file:/C:/foo" instead of
- // "file:///C:/foo" (i.e. there should be 3 / after "file:"). So we'll
- // do the correct thing manually.
-
- String path = file.getCanonicalPath();
- if (File.separatorChar != '/') {
- path = path.replace(File.separatorChar, '/');
- }
- // A file:// should start with 3 // (2 for file:// and 1 to make it an absolute
- // path. On Windows that should look like file:///C:/. Linux/Mac will already
- // have that leading / in their path so we need to compensate for windows.
- if (!path.startsWith("/")) {
- path = "/" + path;
- }
-
- // For some reason the URL class doesn't add the mandatory "//" after
- // the "file:" protocol name, so it has to be hacked into the path.
- URL url = new URL("file", null, "//" + path); //$NON-NLS-1$ //$NON-NLS-2$
- String result = url.toString();
- return result;
-
- }
-
-}
diff --git a/sdkmanager/app/src/test/java/com/android/sdkmanager/SdkCommandLineTest.java b/sdkmanager/app/src/test/java/com/android/sdkmanager/SdkCommandLineTest.java
deleted file mode 100644
index e88d892..0000000
--- a/sdkmanager/app/src/test/java/com/android/sdkmanager/SdkCommandLineTest.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * Copyright (C) 2008 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.sdkmanager;
-
-import com.android.utils.ILogger;
-import com.android.utils.StdLogger;
-
-import junit.framework.TestCase;
-
-public class SdkCommandLineTest extends TestCase {
-
- private StdLogger mLog;
-
- /**
- * A mock version of the {@link SdkCommandLine} class that does not
- * exits and discards its stdout/stderr output.
- */
- public static class MockSdkCommandLine extends SdkCommandLine {
- private boolean mExitCalled;
- private boolean mHelpCalled;
-
- public MockSdkCommandLine(ILogger logger) {
- super(logger);
- }
-
- @Override
- public void printHelpAndExitForAction(String verb, String directObject,
- String errorFormat, Object... args) {
- mHelpCalled = true;
- super.printHelpAndExitForAction(verb, directObject, errorFormat, args);
- }
-
- @Override
- protected void exit() {
- mExitCalled = true;
- }
-
- @Override
- protected void stdout(String format, Object... args) {
- // discard
- }
-
- @Override
- protected void stderr(String format, Object... args) {
- // discard
- }
-
- public boolean wasExitCalled() {
- return mExitCalled;
- }
-
- public boolean wasHelpCalled() {
- return mHelpCalled;
- }
- }
-
- @Override
- protected void setUp() throws Exception {
- mLog = new StdLogger(StdLogger.Level.VERBOSE);
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- /** Test list */
- public final void testList_Avd_Verbose() {
- MockSdkCommandLine c = new MockSdkCommandLine(mLog);
- c.parseArgs(new String[] { "-v", "list", "avd" });
- assertFalse(c.wasHelpCalled());
- assertFalse(c.wasExitCalled());
- assertEquals("list", c.getVerb());
- assertEquals("avd", c.getDirectObject());
- assertTrue(c.isVerbose());
- }
-
- public final void testList_Target() {
- MockSdkCommandLine c = new MockSdkCommandLine(mLog);
- c.parseArgs(new String[] { "list", "target" });
- assertFalse(c.wasHelpCalled());
- assertFalse(c.wasExitCalled());
- assertEquals("list", c.getVerb());
- assertEquals("target", c.getDirectObject());
- assertFalse(c.isVerbose());
- }
-
- public final void testList_None() {
- MockSdkCommandLine c = new MockSdkCommandLine(mLog);
- c.parseArgs(new String[] { "list" });
- assertFalse(c.wasHelpCalled());
- assertFalse(c.wasExitCalled());
- assertEquals("list", c.getVerb());
- assertEquals("", c.getDirectObject());
- assertFalse(c.isVerbose());
- }
-
- public final void testList_Invalid() {
- MockSdkCommandLine c = new MockSdkCommandLine(mLog);
- c.parseArgs(new String[] { "list", "unknown" });
- assertTrue(c.wasHelpCalled());
- assertTrue(c.wasExitCalled());
- assertEquals(null, c.getVerb());
- assertEquals(null, c.getDirectObject());
- assertFalse(c.isVerbose());
- }
-
- public final void testList_Plural() {
- MockSdkCommandLine c = new MockSdkCommandLine(mLog);
- c.parseArgs(new String[] { "list", "avds" });
- assertFalse(c.wasHelpCalled());
- assertFalse(c.wasExitCalled());
- assertEquals("list", c.getVerb());
- // we get the non-plural form
- assertEquals("avd", c.getDirectObject());
- assertFalse(c.isVerbose());
-
- c = new MockSdkCommandLine(mLog);
- c.parseArgs(new String[] { "list", "targets" });
- assertFalse(c.wasHelpCalled());
- assertFalse(c.wasExitCalled());
- assertEquals("list", c.getVerb());
- // we get the non-plural form
- assertEquals("target", c.getDirectObject());
- assertFalse(c.isVerbose());
- }
-
- public final void testCreate_Avd() {
- MockSdkCommandLine c = new MockSdkCommandLine(mLog);
- c.parseArgs(new String[] { "create", "avd", "-t", "android-100", "-n", "myProject" });
- assertFalse(c.wasHelpCalled());
- assertFalse(c.wasExitCalled());
- assertEquals("create", c.getVerb());
- assertEquals("avd", c.getDirectObject());
- assertFalse(c.getFlagSnapshot());
- assertEquals("android-100", c.getParamTargetId());
- assertEquals("myProject", c.getParamName());
- assertFalse(c.isVerbose());
- }
-
- public final void testCreate_Avd_Snapshot() {
- MockSdkCommandLine c = new MockSdkCommandLine(mLog);
- c.parseArgs(new String[] { "create", "avd", "-t", "android-100", "-n", "myProject", "-a" });
- assertFalse(c.wasHelpCalled());
- assertFalse(c.wasExitCalled());
- assertEquals("create", c.getVerb());
- assertEquals("avd", c.getDirectObject());
- assertTrue(c.getFlagSnapshot());
- assertEquals("android-100", c.getParamTargetId());
- assertEquals("myProject", c.getParamName());
- assertFalse(c.isVerbose());
- }
-
- public final void testDirectSdk() {
- MockSdkCommandLine c = new MockSdkCommandLine(mLog);
- c.parseArgs(new String[] { "sdk" });
- assertFalse(c.wasHelpCalled());
- assertFalse(c.wasExitCalled());
- assertEquals("sdk", c.getVerb());
- assertEquals("", c.getDirectObject());
- assertFalse(c.isVerbose());
- }
-
- public final void testDirectAvd() {
- MockSdkCommandLine c = new MockSdkCommandLine(mLog);
- c.parseArgs(new String[] { "avd" });
- assertFalse(c.wasHelpCalled());
- assertFalse(c.wasExitCalled());
- assertEquals("avd", c.getVerb());
- assertEquals("", c.getDirectObject());
- assertFalse(c.isVerbose());
- }
-
-}
diff --git a/sdkmanager/libs/Android.mk b/sdkmanager/libs/Android.mk
deleted file mode 100644
index a934aa7..0000000
--- a/sdkmanager/libs/Android.mk
+++ /dev/null
@@ -1,18 +0,0 @@
-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-SDKLIBS_LOCAL_DIR := $(call my-dir)
-include $(SDKLIBS_LOCAL_DIR)/sdklib/Android.mk
-include $(SDKLIBS_LOCAL_DIR)/sdkuilib/Android.mk
diff --git a/sdkmanager/libs/sdklib/.classpath b/sdkmanager/libs/sdklib/.classpath
deleted file mode 100644
index b2642d7..0000000
--- a/sdkmanager/libs/sdklib/.classpath
+++ /dev/null
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="src" path="src/test/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/commons-compress/commons-compress-1.0.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/http-client/commons-codec-1.4.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/http-client/commons-logging-1.1.1.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/http-client/httpclient-4.1.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/http-client/src/httpcomponents-client-4.1.1-src.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/http-client/httpcore-4.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/http-client/src/httpcomponents-core-4.1-src.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/http-client/httpmime-4.1.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/http-client/src/httpcomponents-client-4.1.1-src.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src.zip"/>
- <classpathentry combineaccessrules="false" kind="src" path="/dvlib"/>
- <classpathentry combineaccessrules="false" kind="src" path="/layoutlib_api"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/sdkmanager/libs/sdklib/.project b/sdkmanager/libs/sdklib/.project
deleted file mode 100644
index 97a8578..0000000
--- a/sdkmanager/libs/sdklib/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>SdkLib</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/sdkmanager/libs/sdklib/.settings/org.eclipse.core.resources.prefs b/sdkmanager/libs/sdklib/.settings/org.eclipse.core.resources.prefs
deleted file mode 100755
index 3d65728..0000000
--- a/sdkmanager/libs/sdklib/.settings/org.eclipse.core.resources.prefs
+++ /dev/null
@@ -1,4 +0,0 @@
-#Mon Aug 29 11:46:20 PDT 2011
-eclipse.preferences.version=1
-encoding//src/test/java/com/android/sdklib/testdata/addon_sample_1.xml=UTF-8
-encoding//src/test/java/com/android/sdklib/io/MockFileOpTest.java=UTF-8
diff --git a/sdkmanager/libs/sdklib/.settings/org.eclipse.jdt.core.prefs b/sdkmanager/libs/sdklib/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/sdkmanager/libs/sdklib/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/sdkmanager/libs/sdklib/.settings/org.eclipse.jdt.ui.prefs b/sdkmanager/libs/sdklib/.settings/org.eclipse.jdt.ui.prefs
deleted file mode 100755
index 4712267..0000000
--- a/sdkmanager/libs/sdklib/.settings/org.eclipse.jdt.ui.prefs
+++ /dev/null
@@ -1,55 +0,0 @@
-#Tue Aug 07 12:32:32 PDT 2012
-eclipse.preferences.version=1
-editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
-sp_cleanup.add_default_serial_version_id=true
-sp_cleanup.add_generated_serial_version_id=false
-sp_cleanup.add_missing_annotations=false
-sp_cleanup.add_missing_deprecated_annotations=true
-sp_cleanup.add_missing_methods=false
-sp_cleanup.add_missing_nls_tags=false
-sp_cleanup.add_missing_override_annotations=true
-sp_cleanup.add_missing_override_annotations_interface_methods=false
-sp_cleanup.add_serial_version_id=false
-sp_cleanup.always_use_blocks=true
-sp_cleanup.always_use_parentheses_in_expressions=false
-sp_cleanup.always_use_this_for_non_static_field_access=false
-sp_cleanup.always_use_this_for_non_static_method_access=false
-sp_cleanup.convert_to_enhanced_for_loop=false
-sp_cleanup.correct_indentation=false
-sp_cleanup.format_source_code=false
-sp_cleanup.format_source_code_changes_only=false
-sp_cleanup.make_local_variable_final=false
-sp_cleanup.make_parameters_final=false
-sp_cleanup.make_private_fields_final=true
-sp_cleanup.make_type_abstract_if_missing_method=false
-sp_cleanup.make_variable_declarations_final=false
-sp_cleanup.never_use_blocks=false
-sp_cleanup.never_use_parentheses_in_expressions=true
-sp_cleanup.on_save_use_additional_actions=true
-sp_cleanup.organize_imports=false
-sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
-sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
-sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
-sp_cleanup.remove_private_constructors=true
-sp_cleanup.remove_trailing_whitespaces=true
-sp_cleanup.remove_trailing_whitespaces_all=false
-sp_cleanup.remove_trailing_whitespaces_ignore_empty=true
-sp_cleanup.remove_unnecessary_casts=false
-sp_cleanup.remove_unnecessary_nls_tags=false
-sp_cleanup.remove_unused_imports=false
-sp_cleanup.remove_unused_local_variables=false
-sp_cleanup.remove_unused_private_fields=true
-sp_cleanup.remove_unused_private_members=false
-sp_cleanup.remove_unused_private_methods=true
-sp_cleanup.remove_unused_private_types=true
-sp_cleanup.sort_members=false
-sp_cleanup.sort_members_all=false
-sp_cleanup.use_blocks=false
-sp_cleanup.use_blocks_only_for_return_and_throw=false
-sp_cleanup.use_parentheses_in_expressions=false
-sp_cleanup.use_this_for_non_static_field_access=false
-sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
-sp_cleanup.use_this_for_non_static_method_access=false
-sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/sdkmanager/libs/sdklib/Android.mk b/sdkmanager/libs/sdklib/Android.mk
deleted file mode 100644
index c24fc5a..0000000
--- a/sdkmanager/libs/sdklib/Android.mk
+++ /dev/null
@@ -1,45 +0,0 @@
-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# The sdklib code has moved to tools/base/sdklib.
-# The rule below uses the prebuilt sdklib.jar if found.
-#
-# If you want to run the tests, cd to tools/base
-# and run ./gradlew :sdklib:test
-
-LOCAL_MODULE := sdklib
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_JAVA_LIBRARIES := \
- common \
- commons-codec-1.4 \
- commons-compress-1.0 \
- commons-logging-1.1.1 \
- dvlib \
- guava-tools \
- httpclient-4.1.1 \
- httpcore-4.1 \
- httpmime-4.1.1 \
- mkidentity-prebuilt \
- layoutlib_api
-
-LOCAL_PREBUILT_JAVA_LIBRARIES := \
- ../../../../prebuilts/devtools/tools/lib/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/sdkmanager/libs/sdklib/NOTICE b/sdkmanager/libs/sdklib/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/sdkmanager/libs/sdklib/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/sdkmanager/libs/sdklib/manifest.txt b/sdkmanager/libs/sdklib/manifest.txt
deleted file mode 100644
index 5d6cbd8..0000000
--- a/sdkmanager/libs/sdklib/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Class-Path: layoutlib_api.jar common.jar guava-tools.jar commons-compress-1.0.jar httpclient-4.1.1.jar httpcore-4.1.jar httpmime-4.1.1.jar commons-logging-1.1.1.jar commons-codec-1.4.jar dvlib.jar
diff --git a/sdkmanager/libs/sdkuilib/.classpath b/sdkmanager/libs/sdkuilib/.classpath
deleted file mode 100644
index 9b127cd..0000000
--- a/sdkmanager/libs/sdkuilib/.classpath
+++ /dev/null
@@ -1,21 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry excluding="**/Android.mk" kind="src" path="src"/>
- <classpathentry excluding="**/Android.mk" kind="src" path="tests"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/sdklib"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/swtmenubar.jar" sourcepath="/ANDROID_SRC/sdk/swtmenubar/src"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.core.commands_3.6.0.I20100512-1500.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.equinox.common_3.6.0.v20100503.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.jface_3.6.2.M20110210-1200.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/http-client/commons-codec-1.4.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/http-client/commons-logging-1.1.1.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/http-client/httpclient-4.1.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/http-client/src/httpcomponents-client-4.1.1-src.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/http-client/httpcore-4.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/http-client/src/httpcomponents-core-4.1-src.zip"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/http-client/httpmime-4.1.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/http-client/src/httpcomponents-client-4.1.1-src.zip"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/swt.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/layoutlib_api"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/sdkmanager/libs/sdkuilib/.project b/sdkmanager/libs/sdkuilib/.project
deleted file mode 100644
index 0fc6a73..0000000
--- a/sdkmanager/libs/sdkuilib/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>SdkUiLib</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/sdkmanager/libs/sdkuilib/.settings/org.eclipse.jdt.core.prefs b/sdkmanager/libs/sdkuilib/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/sdkmanager/libs/sdkuilib/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/sdkmanager/libs/sdkuilib/.settings/org.eclipse.jdt.ui.prefs b/sdkmanager/libs/sdkuilib/.settings/org.eclipse.jdt.ui.prefs
deleted file mode 100755
index cc5f0a2..0000000
--- a/sdkmanager/libs/sdkuilib/.settings/org.eclipse.jdt.ui.prefs
+++ /dev/null
@@ -1,55 +0,0 @@
-#Tue Aug 07 12:32:25 PDT 2012
-eclipse.preferences.version=1
-editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
-sp_cleanup.add_default_serial_version_id=true
-sp_cleanup.add_generated_serial_version_id=false
-sp_cleanup.add_missing_annotations=false
-sp_cleanup.add_missing_deprecated_annotations=true
-sp_cleanup.add_missing_methods=false
-sp_cleanup.add_missing_nls_tags=false
-sp_cleanup.add_missing_override_annotations=true
-sp_cleanup.add_missing_override_annotations_interface_methods=false
-sp_cleanup.add_serial_version_id=false
-sp_cleanup.always_use_blocks=true
-sp_cleanup.always_use_parentheses_in_expressions=false
-sp_cleanup.always_use_this_for_non_static_field_access=false
-sp_cleanup.always_use_this_for_non_static_method_access=false
-sp_cleanup.convert_to_enhanced_for_loop=false
-sp_cleanup.correct_indentation=false
-sp_cleanup.format_source_code=false
-sp_cleanup.format_source_code_changes_only=false
-sp_cleanup.make_local_variable_final=false
-sp_cleanup.make_parameters_final=false
-sp_cleanup.make_private_fields_final=true
-sp_cleanup.make_type_abstract_if_missing_method=false
-sp_cleanup.make_variable_declarations_final=false
-sp_cleanup.never_use_blocks=false
-sp_cleanup.never_use_parentheses_in_expressions=true
-sp_cleanup.on_save_use_additional_actions=true
-sp_cleanup.organize_imports=true
-sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
-sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
-sp_cleanup.qualify_static_member_accesses_with_declaring_class=false
-sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
-sp_cleanup.remove_private_constructors=true
-sp_cleanup.remove_trailing_whitespaces=true
-sp_cleanup.remove_trailing_whitespaces_all=true
-sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
-sp_cleanup.remove_unnecessary_casts=false
-sp_cleanup.remove_unnecessary_nls_tags=false
-sp_cleanup.remove_unused_imports=false
-sp_cleanup.remove_unused_local_variables=false
-sp_cleanup.remove_unused_private_fields=true
-sp_cleanup.remove_unused_private_members=false
-sp_cleanup.remove_unused_private_methods=true
-sp_cleanup.remove_unused_private_types=true
-sp_cleanup.sort_members=false
-sp_cleanup.sort_members_all=false
-sp_cleanup.use_blocks=false
-sp_cleanup.use_blocks_only_for_return_and_throw=false
-sp_cleanup.use_parentheses_in_expressions=false
-sp_cleanup.use_this_for_non_static_field_access=false
-sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
-sp_cleanup.use_this_for_non_static_method_access=false
-sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/sdkmanager/libs/sdkuilib/Android.mk b/sdkmanager/libs/sdkuilib/Android.mk
deleted file mode 100644
index 155da45..0000000
--- a/sdkmanager/libs/sdkuilib/Android.mk
+++ /dev/null
@@ -1,48 +0,0 @@
-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# The sdkuilib code has moved to tools/swt/sdkuilib.
-# The rule below uses the prebuilt sdkuilib.jar if found.
-#
-# If you want to run the tests, cd to tools/swt
-# and run ./gradlew :sdkuilib:test
-
-LOCAL_MODULE := sdkuilib
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_JAVA_LIBRARIES := \
- common \
- commons-codec-1.4 \
- commons-compress-1.0 \
- commons-logging-1.1.1 \
- httpclient-4.1.1 \
- httpcore-4.1 \
- httpmime-4.1.1 \
- org.eclipse.jface_3.6.2.M20110210-1200 \
- org.eclipse.equinox.common_3.6.0.v20100503 \
- org.eclipse.core.commands_3.6.0.I20100512-1500 \
- sdklib \
- layoutlib_api \
- swt \
- swtmenubar
-
-LOCAL_PREBUILT_JAVA_LIBRARIES := \
- ../../../../prebuilts/devtools/tools/lib/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/sdkmanager/libs/sdkuilib/NOTICE b/sdkmanager/libs/sdkuilib/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/sdkmanager/libs/sdkuilib/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/sdkmanager/libs/sdkuilib/README b/sdkmanager/libs/sdkuilib/README
deleted file mode 100644
index dee4a24..0000000
--- a/sdkmanager/libs/sdkuilib/README
+++ /dev/null
@@ -1,45 +0,0 @@
-Using the Eclipse project SdkUiLib
-----------------------------------
-
-1- sdkuilib requires SWT to compile.
-
-SWT is available in the tree under prebuild/<platform>/swt
-
-Because the build path cannot contain relative path that are not inside the project directory,
-the .classpath file references a user library called ANDROID_SWT.
-
-In order to compile the project:
-- Open Preferences > Java > Build Path > User Libraries
-- Create a new user library named ANDROID_SWT
-- Add the following 4 JAR files:
-
- - prebuilt/<platform>/swt/swt.jar
- - prebuilt/common/eclipse/org.eclipse.core.commands_3.*.jar
- - prebuilt/common/eclipse/org.eclipse.equinox.common_3.*.jar
- - prebuilt/common/eclipse/org.eclipse.jface_3.*.jar
-
-
-2- sdkuilib also requires the compiled swtmenubar library.
-
-Build the swtmenubar library:
-$ cd $TOP (top of Android tree)
-$ . build/envsetup.sh && lunch sdk-eng
-$ sdk/eclipse/scripts/create_sdkman_symlinks.sh
-
-Define a classpath variable in Eclipse:
-- Open Preferences > Java > Build Path > Classpath Variables
-- Create a new classpath variable named ANDROID_OUT_FRAMEWORK
-- Set its folder value to <Android tree>/out/host/<platform>/framework
-- Create a new classpath variable named ANDROID_SRC
-- Set its folder value to <Android tree>
-
-You might need to clean the SdkUiLib project (Project > Clean...) after
-you add the new classpath variable, otherwise previous errors might not
-go away automatically.
-
-The ANDROID_SRC part should be optional. It allows you to have access to
-the SwtMenuBar generic parts from the Java editor.
-
-
---
-EOF
diff --git a/sdkmanager/libs/sdkuilib/etc/manifest.txt b/sdkmanager/libs/sdkuilib/etc/manifest.txt
deleted file mode 100644
index 37def3a..0000000
--- a/sdkmanager/libs/sdkuilib/etc/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Class-Path: sdklib.jar layoutlib_api.jar common.jar commons-compress-1.0.jar httpclient-4.1.1.jar httpcore-4.1.jar httpmime-4.1.1.jar commons-logging-1.1.1.jar commons-codec-1.4.jar swtmenubar.jar swt.jar org.eclipse.jface_3.6.2.M20110210-1200.jar org.eclipse.equinox.common_3.6.0.v20100503.jar org.eclipse.core.commands_3.6.0.I20100512-1500.jar
diff --git a/sdkstats/.classpath b/sdkstats/.classpath
deleted file mode 100644
index 023d106..0000000
--- a/sdkstats/.classpath
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="src" path="tests"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/swt.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.core.commands_3.6.0.I20100512-1500.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.equinox.common_3.6.0.v20100503.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.jface_3.6.2.M20110210-1200.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/sdkstats/.gitignore b/sdkstats/.gitignore
deleted file mode 100644
index fe99505..0000000
--- a/sdkstats/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-bin
-
diff --git a/sdkstats/.project b/sdkstats/.project
deleted file mode 100644
index 4dbfa87..0000000
--- a/sdkstats/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>SdkStatsService</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/sdkstats/.settings/README.txt b/sdkstats/.settings/README.txt
deleted file mode 100644
index 9120b20..0000000
--- a/sdkstats/.settings/README.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Copy this in eclipse project as a .settings folder at the root.
-This ensure proper compilation compliance and warning/error levels. \ No newline at end of file
diff --git a/sdkstats/.settings/org.eclipse.jdt.core.prefs b/sdkstats/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/sdkstats/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/sdkstats/Android.mk b/sdkstats/Android.mk
deleted file mode 100644
index f4cabdc..0000000
--- a/sdkstats/Android.mk
+++ /dev/null
@@ -1,4 +0,0 @@
-# Copyright 2007 The Android Open Source Project
-#
-SDKSTATS_LOCAL_DIR := $(call my-dir)
-include $(SDKSTATS_LOCAL_DIR)/src/Android.mk
diff --git a/sdkstats/NOTICE b/sdkstats/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/sdkstats/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/sdkstats/README b/sdkstats/README
deleted file mode 100644
index 8ed0880..0000000
--- a/sdkstats/README
+++ /dev/null
@@ -1,11 +0,0 @@
-How to use the Eclipse projects for SdkStats.
-
-SdkStats requires SWT to compile.
-
-SWT is available in the depot under //device/prebuild/<platform>/swt
-
-Because the build path cannot contain relative path that are not inside the project directory,
-the .classpath file references a user library called ANDROID_SWT.
-
-In order to compile the project, make a user library called ANDROID_SWT containing the jar
-available at //device/prebuild/<platform>/swt.
diff --git a/sdkstats/src/Android.mk b/sdkstats/src/Android.mk
deleted file mode 100644
index 897fed8..0000000
--- a/sdkstats/src/Android.mk
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2007 The Android Open Source Project
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_JAVA_LIBRARIES := \
- common \
- swt \
- org.eclipse.jface_3.6.2.M20110210-1200 \
- org.eclipse.equinox.common_3.6.0.v20100503 \
- org.eclipse.core.commands_3.6.0.I20100512-1500
-LOCAL_MODULE := sdkstats
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/sdkstats/src/com/android/sdkstats/DdmsPreferenceStore.java b/sdkstats/src/com/android/sdkstats/DdmsPreferenceStore.java
deleted file mode 100755
index 890eae7..0000000
--- a/sdkstats/src/com/android/sdkstats/DdmsPreferenceStore.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.sdkstats;
-
-import com.android.prefs.AndroidLocation;
-import com.android.prefs.AndroidLocation.AndroidLocationException;
-
-import org.eclipse.jface.preference.PreferenceStore;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.util.Random;
-
-/**
- * Manages persistence settings for DDMS.
- *
- * For convenience, this also stores persistence settings related to the "server stats" ping
- * as well as some ADT settings that are SDK specific but not workspace specific.
- */
-public class DdmsPreferenceStore {
-
- public final static String PING_OPT_IN = "pingOptIn"; //$NON-NLS-1$
- private final static String PING_TIME = "pingTime"; //$NON-NLS-1$
- private final static String PING_ID = "pingId"; //$NON-NLS-1$
-
- private final static String ADT_USED = "adtUsed"; //$NON-NLS-1$
- private final static String LAST_SDK_PATH = "lastSdkPath"; //$NON-NLS-1$
-
- /**
- * PreferenceStore for DDMS.
- * Creation and usage must be synchronized on {@code DdmsPreferenceStore.class}.
- * Don't use it directly, instead retrieve it via {@link #getPreferenceStore()}.
- */
- private static volatile PreferenceStore sPrefStore;
-
- public DdmsPreferenceStore() {
- }
-
- /**
- * Returns the DDMS {@link PreferenceStore}.
- * This keeps a static reference on the store, so consequent calls will
- * return always the same store.
- */
- public PreferenceStore getPreferenceStore() {
- synchronized (DdmsPreferenceStore.class) {
- if (sPrefStore == null) {
- // get the location of the preferences
- String homeDir = null;
- try {
- homeDir = AndroidLocation.getFolder();
- } catch (AndroidLocationException e1) {
- // pass, we'll do a dummy store since homeDir is null
- }
-
- if (homeDir == null) {
- sPrefStore = new PreferenceStore();
- return sPrefStore;
- }
-
- assert homeDir != null;
-
- String rcFileName = homeDir + "ddms.cfg"; //$NON-NLS-1$
-
- // also look for an old pref file in the previous location
- String oldPrefPath = System.getProperty("user.home") //$NON-NLS-1$
- + File.separator + ".ddmsrc"; //$NON-NLS-1$
- File oldPrefFile = new File(oldPrefPath);
- if (oldPrefFile.isFile()) {
- FileOutputStream fileOutputStream = null;
- try {
- PreferenceStore oldStore = new PreferenceStore(oldPrefPath);
- oldStore.load();
-
- fileOutputStream = new FileOutputStream(rcFileName);
- oldStore.save(fileOutputStream, ""); //$NON-NLS-1$
- oldPrefFile.delete();
-
- PreferenceStore newStore = new PreferenceStore(rcFileName);
- newStore.load();
- sPrefStore = newStore;
- } catch (IOException e) {
- // create a new empty store.
- sPrefStore = new PreferenceStore(rcFileName);
- } finally {
- if (fileOutputStream != null) {
- try {
- fileOutputStream.close();
- } catch (IOException e) {
- // pass
- }
- }
- }
- } else {
- sPrefStore = new PreferenceStore(rcFileName);
-
- try {
- sPrefStore.load();
- } catch (IOException e) {
- System.err.println("Error Loading DDMS Preferences");
- }
- }
- }
-
- assert sPrefStore != null;
- return sPrefStore;
- }
- }
-
- /**
- * Save the prefs to the config file.
- */
- public void save() {
- PreferenceStore prefs = getPreferenceStore();
- synchronized (DdmsPreferenceStore.class) {
- try {
- prefs.save();
- }
- catch (IOException ioe) {
- // FIXME com.android.dmmlib.Log.w("ddms", "Failed saving prefs file: " + ioe.getMessage());
- }
- }
- }
-
- // ---- Utility methods to access some specific prefs ----
-
- /**
- * Indicates whether the ping ID is set.
- * This should be true when {@link #isPingOptIn()} is true.
- *
- * @return true if a ping ID is set, which means the user gave permission
- * to use the ping service.
- */
- public boolean hasPingId() {
- PreferenceStore prefs = getPreferenceStore();
- synchronized (DdmsPreferenceStore.class) {
- return prefs != null && prefs.contains(PING_ID);
- }
- }
-
- /**
- * Retrieves the current ping ID, if set.
- * To know if the ping ID is set, use {@link #hasPingId()}.
- * <p/>
- * There is no magic value reserved for "missing ping id or invalid store".
- * The only proper way to know if the ping id is missing is to use {@link #hasPingId()}.
- */
- public long getPingId() {
- PreferenceStore prefs = getPreferenceStore();
- synchronized (DdmsPreferenceStore.class) {
- // Note: getLong() returns 0L if the ID is missing so we do that too when
- // there's no store.
- return prefs == null ? 0L : prefs.getLong(PING_ID);
- }
- }
-
- /**
- * Generates a new random ping ID and saves it in the preference store.
- *
- * @return The new ping ID.
- */
- public long generateNewPingId() {
- PreferenceStore prefs = getPreferenceStore();
-
- Random rnd = new Random();
- long id = rnd.nextLong();
-
- synchronized (DdmsPreferenceStore.class) {
- prefs.setValue(PING_ID, id);
- try {
- prefs.save();
- } catch (IOException e) {
- /* ignore exceptions while saving preferences */
- }
- }
-
- return id;
- }
-
- /**
- * Returns the "ping opt in" value from the preference store.
- * This would be true if there's a valid preference store and
- * the user opted for sending ping statistics.
- */
- public boolean isPingOptIn() {
- PreferenceStore prefs = getPreferenceStore();
- synchronized (DdmsPreferenceStore.class) {
- return prefs != null && prefs.contains(PING_OPT_IN);
- }
- }
-
- /**
- * Saves the "ping opt in" value in the preference store.
- *
- * @param optIn The new user opt-in value.
- */
- public void setPingOptIn(boolean optIn) {
- PreferenceStore prefs = getPreferenceStore();
-
- synchronized (DdmsPreferenceStore.class) {
- prefs.setValue(PING_OPT_IN, optIn);
- try {
- prefs.save();
- } catch (IOException e) {
- /* ignore exceptions while saving preferences */
- }
- }
- }
-
- /**
- * Retrieves the ping time for the given app from the preference store.
- * Callers should use {@link System#currentTimeMillis()} for time stamps.
- *
- * @param app The app name identifier.
- * @return 0L if we don't have a preference store or there was no time
- * recorded in the store for the requested app. Otherwise the time stamp
- * from the store.
- */
- public long getPingTime(String app) {
- PreferenceStore prefs = getPreferenceStore();
- String timePref = PING_TIME + "." + app; //$NON-NLS-1$
- synchronized (DdmsPreferenceStore.class) {
- return prefs == null ? 0 : prefs.getLong(timePref);
- }
- }
-
- /**
- * Sets the ping time for the given app from the preference store.
- * Callers should use {@link System#currentTimeMillis()} for time stamps.
- *
- * @param app The app name identifier.
- * @param timeStamp The time stamp from the store.
- * 0L is a special value that should not be used.
- */
- public void setPingTime(String app, long timeStamp) {
- PreferenceStore prefs = getPreferenceStore();
- String timePref = PING_TIME + "." + app; //$NON-NLS-1$
- synchronized (DdmsPreferenceStore.class) {
- prefs.setValue(timePref, timeStamp);
- try {
- prefs.save();
- } catch (IOException ioe) {
- /* ignore exceptions while saving preferences */
- }
- }
- }
-
- /**
- * True if this is the first time the users runs ADT, which is detected by
- * the lack of the setting set using {@link #setAdtUsed(boolean)}
- * or this value being set to true.
- *
- * @return true if ADT has been used before
- *
- * @see #setAdtUsed(boolean)
- */
- public boolean isAdtUsed() {
- PreferenceStore prefs = getPreferenceStore();
- synchronized (DdmsPreferenceStore.class) {
- if (prefs == null || !prefs.contains(ADT_USED)) {
- return false;
- }
- return prefs.getBoolean(ADT_USED);
- }
- }
-
- /**
- * Sets whether the ADT startup wizard has been shown.
- * ADT sets first to false once the welcome wizard has been shown once.
- *
- * @param used true if ADT has been used
- */
- public void setAdtUsed(boolean used) {
- PreferenceStore prefs = getPreferenceStore();
- synchronized (DdmsPreferenceStore.class) {
- prefs.setValue(ADT_USED, used);
- try {
- prefs.save();
- } catch (IOException ioe) {
- /* ignore exceptions while saving preferences */
- }
- }
- }
-
- /**
- * Retrieves the last SDK OS path.
- * <p/>
- * This is just an information value, the path may not exist, may not
- * even be on an existing file system and/or may not point to an SDK
- * anymore.
- *
- * @return The last SDK OS path from the preference store, or null if
- * there is no store or an empty string if it is not defined.
- */
- public String getLastSdkPath() {
- PreferenceStore prefs = getPreferenceStore();
- synchronized (DdmsPreferenceStore.class) {
- return prefs == null ? null : prefs.getString(LAST_SDK_PATH);
- }
- }
-
- /**
- * Sets the last SDK OS path.
- *
- * @param osSdkPath The SDK OS Path. Can be null or empty.
- */
- public void setLastSdkPath(String osSdkPath) {
- PreferenceStore prefs = getPreferenceStore();
- synchronized (DdmsPreferenceStore.class) {
- prefs.setValue(LAST_SDK_PATH, osSdkPath);
- try {
- prefs.save();
- } catch (IOException ioe) {
- /* ignore exceptions while saving preferences */
- }
- }
- }
-}
diff --git a/sdkstats/src/com/android/sdkstats/SdkStatsPermissionDialog.java b/sdkstats/src/com/android/sdkstats/SdkStatsPermissionDialog.java
deleted file mode 100644
index f9856cc..0000000
--- a/sdkstats/src/com/android/sdkstats/SdkStatsPermissionDialog.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.sdkstats;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.program.Program;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Link;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.IOException;
-
-/**
- * Dialog to get user permission for ping service.
- */
-public class SdkStatsPermissionDialog extends Dialog {
- /* Text strings displayed in the opt-out dialog. */
- private static final String HEADER_TEXT =
- "Thanks for using the Android SDK!";
-
- /** Used in the ADT welcome wizard as well. */
- public static final String NOTICE_TEXT =
- "We know you just want to get started but please read this first.";
-
- /** Used in the preference pane (PrefsDialog) as well. */
- public static final String BODY_TEXT =
- "By choosing to send certain usage statistics to Google, you can " +
- "help us improve the Android SDK. These usage statistics lets us " +
- "measure things like active usage of the SDK, and let us know things " +
- "like which versions of the SDK are in use and which tools are the " +
- "most popular with developers. This limited data is not associated " +
- "with personal information about you, and is examined on an aggregate " +
- "basis, and is maintained in accordance with the Google Privacy Policy.";
-
- /** Used in the ADT welcome wizard as well. */
- public static final String PRIVACY_POLICY_LINK_TEXT =
- "<a href=\"http://www.google.com/intl/en/privacy.html\">Google " +
- "Privacy Policy</a>";
-
- /** Used in the preference pane (PrefsDialog) as well. */
- public static final String CHECKBOX_TEXT =
- "Send usage statistics to Google.";
-
- /** Used in the ADT welcome wizard as well. */
- public static final String FOOTER_TEXT =
- "If you later decide to change this setting, you can do so in the" +
- "\"ddms\" tool under \"File\" > \"Preferences\" > \"Usage Stats\".";
-
- private static final String BUTTON_TEXT = "Proceed";
-
- /** List of Linux browser commands to try, in order (see openUrl). */
- private static final String[] LINUX_BROWSERS = new String[] {
- "firefox -remote openurl(%URL%,new-window)", //$NON-NLS-1$ running FF
- "mozilla -remote openurl(%URL%,new-window)", //$NON-NLS-1$ running Moz
- "firefox %URL%", //$NON-NLS-1$ new FF
- "mozilla %URL%", //$NON-NLS-1$ new Moz
- "kfmclient openURL %URL%", //$NON-NLS-1$ Konqueror
- "opera -newwindow %URL%", //$NON-NLS-1$ Opera
- };
-
- private static final boolean ALLOW_PING_DEFAULT = true;
- private boolean mAllowPing = ALLOW_PING_DEFAULT;
-
- public SdkStatsPermissionDialog(Shell parentShell) {
- super(parentShell);
- setBlockOnOpen(true);
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, Window.OK, BUTTON_TEXT, true);
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
- composite.setLayout(new GridLayout(1, false));
-
- final Label title = new Label(composite, SWT.CENTER | SWT.WRAP);
- final FontData[] fontdata = title.getFont().getFontData();
- for (int i = 0; i < fontdata.length; i++) {
- fontdata[i].setHeight(fontdata[i].getHeight() * 4 / 3);
- }
- title.setFont(new Font(getShell().getDisplay(), fontdata));
- title.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- title.setText(HEADER_TEXT);
-
- final Label notice = new Label(composite, SWT.WRAP);
- notice.setFont(title.getFont());
- notice.setForeground(new Color(getShell().getDisplay(), 255, 0, 0));
- notice.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- notice.setText(NOTICE_TEXT);
- notice.pack();
-
- final Label bodyText = new Label(composite, SWT.WRAP);
- GridData gd = new GridData();
- gd.widthHint = notice.getSize().x; // do not extend beyond the NOTICE text's width
- gd.grabExcessHorizontalSpace = true;
- bodyText.setLayoutData(gd);
- bodyText.setText(BODY_TEXT);
-
- final Link privacyLink = new Link(composite, SWT.NO_FOCUS);
- privacyLink.setText(PRIVACY_POLICY_LINK_TEXT);
- privacyLink.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- openUrl(event.text);
- }
- });
-
- final Button checkbox = new Button(composite, SWT.CHECK);
- checkbox.setSelection(ALLOW_PING_DEFAULT);
- checkbox.setText(CHECKBOX_TEXT);
- checkbox.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent event) {
- mAllowPing = checkbox.getSelection();
- }
- });
- checkbox.setFocus();
-
- final Label footer = new Label(composite, SWT.WRAP);
- gd = new GridData();
- gd.widthHint = notice.getSize().x;
- gd.grabExcessHorizontalSpace = true;
- footer.setLayoutData(gd);
- footer.setText(FOOTER_TEXT);
-
- return composite;
- }
-
- /**
- * Open a URL in an external browser.
- * @param url to open - MUST be sanitized and properly formed!
- */
- public static void openUrl(final String url) {
- // TODO: consider using something like BrowserLauncher2
- // (http://browserlaunch2.sourceforge.net/) instead of these hacks.
-
- // SWT's Program.launch() should work on Mac, Windows, and GNOME
- // (because the OS shell knows how to launch a default browser).
- if (!Program.launch(url)) {
- // Must be Linux non-GNOME (or something else broke).
- // Try a few Linux browser commands in the background.
- new Thread() {
- @Override
- public void run() {
- for (String cmd : LINUX_BROWSERS) {
- cmd = cmd.replaceAll("%URL%", url); //$NON-NLS-1$
- try {
- Process proc = Runtime.getRuntime().exec(cmd);
- if (proc.waitFor() == 0) break; // Success!
- } catch (InterruptedException e) {
- // Should never happen!
- throw new RuntimeException(e);
- } catch (IOException e) {
- // Swallow the exception and try the next browser.
- }
- }
-
- // TODO: Pop up some sort of error here?
- // (We're in a new thread; can't use the existing Display.)
- }
- }.start();
- }
- }
-
- public boolean getPingUserPreference() {
- return mAllowPing;
- }
-}
diff --git a/sdkstats/src/com/android/sdkstats/SdkStatsService.java b/sdkstats/src/com/android/sdkstats/SdkStatsService.java
deleted file mode 100644
index 79c2ef5..0000000
--- a/sdkstats/src/com/android/sdkstats/SdkStatsService.java
+++ /dev/null
@@ -1,558 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.sdkstats;
-
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLEncoder;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/** Utility class to send "ping" usage reports to the server. */
-public class SdkStatsService {
-
- protected static final String SYS_PROP_OS_ARCH = "os.arch"; //$NON-NLS-1$
- protected static final String SYS_PROP_JAVA_VERSION = "java.version"; //$NON-NLS-1$
- protected static final String SYS_PROP_OS_VERSION = "os.version"; //$NON-NLS-1$
- protected static final String SYS_PROP_OS_NAME = "os.name"; //$NON-NLS-1$
-
- /** Minimum interval between ping, in milliseconds. */
- private static final long PING_INTERVAL_MSEC = 86400 * 1000; // 1 day
-
- private static final boolean DEBUG = System.getenv("ANDROID_DEBUG_PING") != null; //$NON-NLS-1$
-
- private DdmsPreferenceStore mStore = new DdmsPreferenceStore();
-
- public SdkStatsService() {
- }
-
- /**
- * Send a "ping" to the Google toolbar server, if enough time has
- * elapsed since the last ping, and if the user has not opted out.
- * <p/>
- * This is a simplified version of {@link #ping(String[])} that only
- * sends an "application" name and a "version" string. See the explanation
- * there for details.
- *
- * @param app The application name that reports the ping (e.g. "emulator" or "ddms".)
- * Valid characters are a-zA-Z0-9 only.
- * @param version The version string (e.g. "12" or "1.2.3.4", 4 groups max.)
- * @see #ping(String[])
- */
- public void ping(String app, String version) {
- doPing(app, version, null);
- }
-
- /**
- * Send a "ping" to the Google toolbar server, if enough time has
- * elapsed since the last ping, and if the user has not opted out.
- * <p/>
- * The ping will not be sent if the user opt out dialog has not been shown yet.
- * Use {@link #checkUserPermissionForPing(Shell)} to display the dialog requesting
- * user permissions.
- * <p/>
- * Note: The actual ping (if any) is sent in a <i>non-daemon</i> background thread.
- * <p/>
- * The arguments are defined as follow:
- * <ul>
- * <li>Argument 0 is the "ping" command and is ignored.</li>
- * <li>Argument 1 is the application name that reports the ping (e.g. "emulator" or "ddms".)
- * Valid characters are a-zA-Z0-9 only.</li>
- * <li>Argument 2 is the version string (e.g. "12" or "1.2.3.4", 4 groups max.)</li>
- * <li>Arguments 3+ are optional and depend on the application name.</li>
- * <li>"emulator" application currently has 3 optional arguments:
- * <ul>
- * <li>Arugment 3: android_gl_vendor</li>
- * <li>Arugment 4: android_gl_renderer</li>
- * <li>Arugment 5: android_gl_version</li>
- * </ul>
- * </li>
- * </ul>
- *
- * @param arguments A non-empty non-null array of arguments to the ping as described above.
- */
- public void ping(String[] arguments) {
- if (arguments == null || arguments.length < 3) {
- throw new IllegalArgumentException(
- "Invalid ping arguments: expected ['ping', app, version] but got " +
- (arguments == null ? "null" : Arrays.toString(arguments)));
- }
- int len = arguments.length;
- String app = arguments[1];
- String version = arguments[2];
-
- Map<String, String> extras = new HashMap<String, String>();
-
- if ("emulator".equals(app)) { //$NON-NLS-1$
- if (len > 3) {
- extras.put("glm", sanitizeGlArg(arguments[3])); //$NON-NLS-1$ vendor
- }
- if (len > 4) {
- extras.put("glr", sanitizeGlArg(arguments[4])); //$NON-NLS-1$ renderer
- }
- if (len > 5) {
- extras.put("glv", sanitizeGlArg(arguments[5])); //$NON-NLS-1$ version
- }
- }
-
- doPing(app, version, extras);
- }
-
- private String sanitizeGlArg(String arg) {
- if (arg == null) {
- arg = ""; //$NON-NLS-1$
- } else {
- try {
- arg = arg.trim();
- arg = arg.replaceAll("[^A-Za-z0-9\\s_()./-]", " "); //$NON-NLS-1$ //$NON-NLS-2$
- arg = arg.replaceAll("\\s\\s+", " "); //$NON-NLS-1$ //$NON-NLS-2$
-
- // Guard from arbitrarily long parameters
- if (arg.length() > 128) {
- arg = arg.substring(0, 128);
- }
-
- arg = URLEncoder.encode(arg, "UTF-8"); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e) {
- arg = ""; //$NON-NLS-1$
- }
- }
-
- return arg;
- }
-
- /**
- * Display a dialog to the user providing information about the ping service,
- * and whether they'd like to opt-out of it.
- *
- * Once the dialog has been shown, it sets a preference internally indicating
- * that the user has viewed this dialog.
- */
- public void checkUserPermissionForPing(Shell parent) {
- if (!mStore.hasPingId()) {
- askUserPermissionForPing(parent);
- mStore.generateNewPingId();
- }
- }
-
- /**
- * Prompt the user for whether they want to opt out of reporting, and save the user
- * input in preferences.
- */
- private void askUserPermissionForPing(final Shell parent) {
- final Display display = parent.getDisplay();
- display.syncExec(new Runnable() {
- @Override
- public void run() {
- SdkStatsPermissionDialog dialog = new SdkStatsPermissionDialog(parent);
- dialog.open();
- mStore.setPingOptIn(dialog.getPingUserPreference());
- }
- });
- }
-
- // -------
-
- /**
- * Pings the usage stats server, as long as the prefs contain the opt-in boolean
- *
- * @param app The application name that reports the ping (e.g. "emulator" or "ddms".)
- * Will be normalized. Valid characters are a-zA-Z0-9 only.
- * @param version The version string (e.g. "12" or "1.2.3.4", 4 groups max.)
- * @param extras Extra key/value parameters to send. They are send as-is and must
- * already be well suited and escaped using {@link URLEncoder#encode(String, String)}.
- */
- protected void doPing(String app, String version, final Map<String, String> extras) {
- // Note: if you change the implementation here, you also need to change
- // the overloaded SdkStatsServiceTest.doPing() used for testing.
-
- // Validate the application and version input.
- final String nApp = normalizeAppName(app);
- final String nVersion = normalizeVersion(version);
-
- // If the user has not opted in, do nothing and quietly return.
- if (!mStore.isPingOptIn()) {
- // user opted out.
- return;
- }
-
- // If the last ping *for this app* was too recent, do nothing.
- long now = System.currentTimeMillis();
- long then = mStore.getPingTime(app);
- if (now - then < PING_INTERVAL_MSEC) {
- // too soon after a ping.
- return;
- }
-
- // Record the time of the attempt, whether or not it succeeds.
- mStore.setPingTime(app, now);
-
- // Send the ping itself in the background (don't block if the
- // network is down or slow or confused).
- final long id = mStore.getPingId();
- new Thread() {
- @Override
- public void run() {
- try {
- URL url = createPingUrl(nApp, nVersion, id, extras);
- actuallySendPing(url);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- }.start();
- }
-
-
- /**
- * Unconditionally send a "ping" request to the server.
- *
- * @param url The URL to send to the server.
- * * @throws IOException if the ping failed
- */
- private void actuallySendPing(URL url) throws IOException {
- assert url != null;
-
- if (DEBUG) {
- System.err.println("Ping: " + url.toString()); //$NON-NLS-1$
- }
-
- // Discard the actual response, but make sure it reads OK
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-
- // Believe it or not, a 404 response indicates success:
- // the ping was logged, but no update is configured.
- if (conn.getResponseCode() != HttpURLConnection.HTTP_OK &&
- conn.getResponseCode() != HttpURLConnection.HTTP_NOT_FOUND) {
- throw new IOException(
- conn.getResponseMessage() + ": " + url); //$NON-NLS-1$
- }
- }
-
- /**
- * Compute the ping URL to send the data to the server.
- *
- * @param app The application name that reports the ping (e.g. "emulator" or "ddms".)
- * Valid characters are a-zA-Z0-9 only.
- * @param version The version string already formatted as a 4 dotted group (e.g. "1.2.3.4".)
- * @param id of the local installation
- * @param extras Extra key/value parameters to send. They are send as-is and must
- * already be well suited and escaped using {@link URLEncoder#encode(String, String)}.
- */
- protected URL createPingUrl(String app, String version, long id, Map<String, String> extras)
- throws UnsupportedEncodingException, MalformedURLException {
-
- String osName = URLEncoder.encode(getOsName(), "UTF-8"); //$NON-NLS-1$
- String osArch = URLEncoder.encode(getOsArch(), "UTF-8"); //$NON-NLS-1$
- String jvmArch = URLEncoder.encode(getJvmInfo(), "UTF-8"); //$NON-NLS-1$
-
- // Include the application's name as part of the as= value.
- // Share the user ID for all apps, to allow unified activity reports.
-
- String extraStr = ""; //$NON-NLS-1$
- if (extras != null && !extras.isEmpty()) {
- StringBuilder sb = new StringBuilder();
- for (Map.Entry<String, String> entry : extras.entrySet()) {
- sb.append('&').append(entry.getKey()).append('=').append(entry.getValue());
- }
- extraStr = sb.toString();
- }
-
- URL url = new URL(
- "http", //$NON-NLS-1$
- "tools.google.com", //$NON-NLS-1$
- "/service/update?as=androidsdk_" + app + //$NON-NLS-1$
- "&id=" + Long.toHexString(id) + //$NON-NLS-1$
- "&version=" + version + //$NON-NLS-1$
- "&os=" + osName + //$NON-NLS-1$
- "&osa=" + osArch + //$NON-NLS-1$
- "&vma=" + jvmArch + //$NON-NLS-1$
- extraStr);
- return url;
- }
-
- /**
- * Detects and reports the host OS: "linux", "win" or "mac".
- * For Windows and Mac also append the version, so for example
- * Win XP will return win-5.1.
- */
- protected String getOsName() { // made protected for testing
- String os = getSystemProperty(SYS_PROP_OS_NAME);
-
- if (os == null || os.length() == 0) {
- return "unknown"; //$NON-NLS-1$
- }
-
- String os2 = os.toLowerCase(Locale.US);
-
- if (os2.startsWith("mac")) { //$NON-NLS-1$
- os = "mac"; //$NON-NLS-1$
- String osVers = getOsVersion();
- if (osVers != null) {
- os = os + '-' + osVers;
- }
- } else if (os2.startsWith("win")) { //$NON-NLS-1$
- os = "win"; //$NON-NLS-1$
- String osVers = getOsVersion();
- if (osVers != null) {
- os = os + '-' + osVers;
- }
- } else if (os2.startsWith("linux")) { //$NON-NLS-1$
- os = "linux"; //$NON-NLS-1$
-
- } else if (os.length() > 32) {
- // Unknown -- send it verbatim so we can see it
- // but protect against arbitrarily long values
- os = os.substring(0, 32);
- }
- return os;
- }
-
- /**
- * Detects and returns the OS architecture: x86, x86_64, ppc.
- * This may differ or be equal to the JVM architecture in the sense that
- * a 64-bit OS can run a 32-bit JVM.
- */
- protected String getOsArch() { // made protected for testing
- String arch = getJvmArch();
-
- if ("x86_64".equals(arch)) { //$NON-NLS-1$
- // This is a simple case: the JVM runs in 64-bit so the
- // OS must be a 64-bit one.
- return arch;
-
- } else if ("x86".equals(arch)) { //$NON-NLS-1$
- // This is the misleading case: the JVM is 32-bit but the OS
- // might be either 32 or 64. We can't tell just from this
- // property.
- // Macs are always on 64-bit, so we just need to figure it
- // out for Windows and Linux.
-
- String os = getOsName();
- if (os.startsWith("win")) { //$NON-NLS-1$
- // When WOW64 emulates a 32-bit environment under a 64-bit OS,
- // it sets PROCESSOR_ARCHITEW6432 to AMD64 or IA64 accordingly.
- // Ref: http://msdn.microsoft.com/en-us/library/aa384274(v=vs.85).aspx
-
- String w6432 = getSystemEnv("PROCESSOR_ARCHITEW6432"); //$NON-NLS-1$
- if (w6432 != null && w6432.indexOf("64") != -1) { //$NON-NLS-1$
- return "x86_64"; //$NON-NLS-1$
- }
- } else if (os.startsWith("linux")) { //$NON-NLS-1$
- // Let's try the obvious. This works in Ubuntu and Debian
- String s = getSystemEnv("HOSTTYPE"); //$NON-NLS-1$
-
- s = sanitizeOsArch(s);
- if (s.indexOf("86") != -1) { //$NON-NLS-1$
- arch = s;
- }
- }
- }
-
- return arch;
- }
-
- /**
- * Returns the version of the OS version if it is defined as X.Y, or null otherwise.
- * <p/>
- * Example of returned versions can be found at http://lopica.sourceforge.net/os.html
- * <p/>
- * This method removes any exiting micro versions.
- * Returns null if the version doesn't match X.Y.Z.
- */
- protected String getOsVersion() { // made protected for testing
- Pattern p = Pattern.compile("(\\d+)\\.(\\d+).*"); //$NON-NLS-1$
- String osVers = getSystemProperty(SYS_PROP_OS_VERSION);
- if (osVers != null && osVers.length() > 0) {
- Matcher m = p.matcher(osVers);
- if (m.matches()) {
- return m.group(1) + '.' + m.group(2);
- }
- }
- return null;
- }
-
- /**
- * Detects and returns the JVM info: version + architecture.
- * Examples: 1.4-ppc, 1.6-x86, 1.7-x86_64
- */
- protected String getJvmInfo() { // made protected for testing
- return getJvmVersion() + '-' + getJvmArch();
- }
-
- /**
- * Returns the major.minor Java version.
- * <p/>
- * The "java.version" property returns something like "1.6.0_20"
- * of which we want to return "1.6".
- */
- protected String getJvmVersion() { // made protected for testing
- String version = getSystemProperty(SYS_PROP_JAVA_VERSION);
-
- if (version == null || version.length() == 0) {
- return "unknown"; //$NON-NLS-1$
- }
-
- Pattern p = Pattern.compile("(\\d+)\\.(\\d+).*"); //$NON-NLS-1$
- Matcher m = p.matcher(version);
- if (m.matches()) {
- return m.group(1) + '.' + m.group(2);
- }
-
- // Unknown version. Send it as-is within a reasonable size limit.
- if (version.length() > 8) {
- version = version.substring(0, 8);
- }
- return version;
- }
-
- /**
- * Detects and returns the JVM architecture.
- * <p/>
- * The HotSpot JVM has a private property for this, "sun.arch.data.model",
- * which returns either "32" or "64". However it's not in any kind of spec.
- * <p/>
- * What we want is to know whether the JVM is running in 32-bit or 64-bit and
- * the best indicator is to use the "os.arch" property.
- * - On a 32-bit system, only a 32-bit JVM can run so it will be x86 or ppc.<br/>
- * - On a 64-bit system, a 32-bit JVM will also return x86 since the OS needs
- * to masquerade as a 32-bit OS for backward compatibility.<br/>
- * - On a 64-bit system, a 64-bit JVM will properly return x86_64.
- * <pre>
- * JVM: Java 32-bit Java 64-bit
- * Windows: x86 x86_64
- * Linux: x86 x86_64
- * Mac untested x86_64
- * </pre>
- */
- protected String getJvmArch() { // made protected for testing
- String arch = getSystemProperty(SYS_PROP_OS_ARCH);
- return sanitizeOsArch(arch);
- }
-
- private String sanitizeOsArch(String arch) {
- if (arch == null || arch.length() == 0) {
- return "unknown"; //$NON-NLS-1$
- }
-
- if (arch.equalsIgnoreCase("x86_64") || //$NON-NLS-1$
- arch.equalsIgnoreCase("ia64") || //$NON-NLS-1$
- arch.equalsIgnoreCase("amd64")) { //$NON-NLS-1$
- return "x86_64"; //$NON-NLS-1$
- }
-
- if (arch.length() >= 4 && arch.charAt(0) == 'i' && arch.indexOf("86") == 2) { //$NON-NLS-1$
- // Any variation of iX86 counts as x86 (i386, i486, i686).
- return "x86"; //$NON-NLS-1$
- }
-
- if (arch.equalsIgnoreCase("PowerPC")) { //$NON-NLS-1$
- return "ppc"; //$NON-NLS-1$
- }
-
- // Unknown arch. Send it as-is but protect against arbitrarily long values.
- if (arch.length() > 32) {
- arch = arch.substring(0, 32);
- }
- return arch;
- }
-
- /**
- * Normalize the supplied application name.
- *
- * @param app to report
- */
- protected String normalizeAppName(String app) {
- // Filter out \W , non-word character: [^a-zA-Z_0-9]
- String app2 = app.replaceAll("\\W", ""); //$NON-NLS-1$ //$NON-NLS-2$
-
- if (app.length() == 0) {
- throw new IllegalArgumentException("Bad app name: " + app); //$NON-NLS-1$
- }
-
- return app2;
- }
-
- /**
- * Validate the supplied application version, and normalize the version.
- *
- * @param version supplied by caller
- * @return normalized dotted quad version
- */
- protected String normalizeVersion(String version) {
-
- Pattern regex = Pattern.compile(
- //1=major 2=minor 3=micro 4=build | 5=rc
- "^(\\d+)(?:\\.(\\d+))?(?:\\.(\\d+))?(?:\\.(\\d+)| +rc(\\d+))?"); //$NON-NLS-1$
-
- Matcher m = regex.matcher(version);
- if (m != null && m.lookingAt()) {
- StringBuilder normal = new StringBuilder();
- for (int i = 1; i <= 4; i++) {
- int v = 0;
- // If build is null but we have an rc, take that number instead as the 4th part.
- if (i == 4 &&
- i < m.groupCount() &&
- m.group(i) == null &&
- m.group(i+1) != null) {
- i++;
- }
- if (m.group(i) != null) {
- try {
- v = Integer.parseInt(m.group(i));
- } catch (Exception ignore) {
- }
- }
- if (i > 1) {
- normal.append('.');
- }
- normal.append(v);
- }
- return normal.toString();
- }
-
- throw new IllegalArgumentException("Bad version: " + version); //$NON-NLS-1$
- }
-
- /**
- * Calls {@link System#getProperty(String)}.
- * Allows unit-test to override the return value.
- * @see System#getProperty(String)
- */
- protected String getSystemProperty(String name) {
- return System.getProperty(name);
- }
-
- /**
- * Calls {@link System#getenv(String)}.
- * Allows unit-test to override the return value.
- * @see System#getenv(String)
- */
- protected String getSystemEnv(String name) {
- return System.getenv(name);
- }
-}
diff --git a/sdkstats/tests/com/android/sdkstats/SdkStatsServiceTest.java b/sdkstats/tests/com/android/sdkstats/SdkStatsServiceTest.java
deleted file mode 100755
index 9982bb7..0000000
--- a/sdkstats/tests/com/android/sdkstats/SdkStatsServiceTest.java
+++ /dev/null
@@ -1,544 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.sdkstats;
-
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-public class SdkStatsServiceTest extends TestCase {
-
- private static class MockSdkStatsService extends SdkStatsService {
-
- private final String mOsName;
- private final String mOsVersion;
- private final String mOsArch;
- private final String mJavaVersion;
- private final Map<String, String> mEnvVars = new HashMap<String, String>();
- private URL mPingUrlResult;
-
- public MockSdkStatsService(String osName,
- String osVersion,
- String osArch,
- String javaVersion) {
- mOsName = osName;
- mOsVersion = osVersion;
- mOsArch = osArch;
- mJavaVersion = javaVersion;
- }
-
- public URL getPingUrlResult() {
- return mPingUrlResult;
- }
-
- public void setSystemEnv(String varName, String value) {
- mEnvVars.put(varName, value);
- }
-
- @Override
- protected String getSystemProperty(String name) {
- if (SdkStatsService.SYS_PROP_OS_NAME.equals(name)) {
- return mOsName;
- } else if (SdkStatsService.SYS_PROP_OS_VERSION.equals(name)) {
- return mOsVersion;
- } else if (SdkStatsService.SYS_PROP_OS_ARCH.equals(name)) {
- return mOsArch;
- } else if (SdkStatsService.SYS_PROP_JAVA_VERSION.equals(name)) {
- return mJavaVersion;
- }
- // Don't use current properties values, we don't want the tests to be flaky
- fail("SdkStatsServiceTest doesn't define a system.property for " + name);
- return null;
- }
-
- @Override
- protected String getSystemEnv(String name) {
- if (mEnvVars.containsKey(name)) {
- return mEnvVars.get(name);
- }
- // Don't use current env vars, we don't want the tests to be flaky
- fail("SdkStatsServiceTest doesn't define a system.getenv for " + name);
- return null;
- }
-
- @Override
- protected void doPing(String app, String version,
- Map<String, String> extras) {
- // The super.doPing() does:
- // 1- normalize input,
- // 2- check the ping time,
- // 3- check/create the pind id,
- // 4- create the ping URL
- // 5- and send the network ping in a thread.
- // In this mock version we just do steps 1 and 4 and record the URL;
- // obvious we don't check the ping time in the prefs nor send the actual ping.
-
- // Validate the application and version input.
- final String nApp = normalizeAppName(app);
- final String nVersion = normalizeVersion(version);
-
- long id = 0x42;
- try {
- mPingUrlResult = createPingUrl(nApp, nVersion, id, extras);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
- }
-
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- }
-
- @Override
- protected void tearDown() throws Exception {
- super.tearDown();
- }
-
- public void testSdkStatsService_getJvmArch() {
- MockSdkStatsService m;
-
- m = new MockSdkStatsService("Windows", "4.0", "x86", "1.7");
- assertEquals("x86", m.getJvmArch());
- m = new MockSdkStatsService("Windows", "4.0", "i386", "1.7");
- assertEquals("x86", m.getJvmArch());
- m = new MockSdkStatsService("Windows", "4.0", "i486", "1.7");
- assertEquals("x86", m.getJvmArch());
- m = new MockSdkStatsService("Linux", "4.0", "i486-linux", "1.7");
- assertEquals("x86", m.getJvmArch());
- m = new MockSdkStatsService("Windows", "4.0", "i586", "1.7");
- assertEquals("x86", m.getJvmArch());
- m = new MockSdkStatsService("Windows", "4.0", "i686", "1.7");
- assertEquals("x86", m.getJvmArch());
-
- m = new MockSdkStatsService("Mac OS", "10.0", "x86_64", "1.7");
- assertEquals("x86_64", m.getJvmArch());
- m = new MockSdkStatsService("Mac OS", "8.0", "PowerPC", "1.7");
- assertEquals("ppc", m.getJvmArch());
-
- m = new MockSdkStatsService("Mac OS", "4.0", "x86_64", "1.7");
- assertEquals("x86_64", m.getJvmArch());
- m = new MockSdkStatsService("Windows", "4.0", "ia64", "1.7");
- assertEquals("x86_64", m.getJvmArch());
- m = new MockSdkStatsService("Windows", "4.0", "amd64", "1.7");
- assertEquals("x86_64", m.getJvmArch());
-
- m = new MockSdkStatsService("Windows", "4.0", "atom", "1.7");
- assertEquals("atom", m.getJvmArch());
-
- // 32 chars max
- m = new MockSdkStatsService("Windows", "4.0",
- "one3456789ten3456789twenty6789thirty6789", "1.7");
- assertEquals("one3456789ten3456789twenty6789th", m.getJvmArch());
-
- m = new MockSdkStatsService("Windows", "4.0", "", "1.7");
- assertEquals("unknown", m.getJvmArch());
-
- m = new MockSdkStatsService("Windows", "4.0", null, "1.7");
- assertEquals("unknown", m.getJvmArch());
- }
-
- public void testSdkStatsService_getJvmVersion() {
- MockSdkStatsService m;
-
- m = new MockSdkStatsService("Windows", "4.0", "x86", "1.7.8_09");
- assertEquals("1.7", m.getJvmVersion());
-
- m = new MockSdkStatsService("Windows", "4.0", "x86", "");
- assertEquals("unknown", m.getJvmVersion());
-
- m = new MockSdkStatsService("Windows", "4.0", "x86", null);
- assertEquals("unknown", m.getJvmVersion());
-
- // 8 chars max
- m = new MockSdkStatsService("Windows", "4.0", "x86",
- "one3456789ten3456789twenty6789thirty6789");
- assertEquals("one34567", m.getJvmVersion());
- }
-
- public void testSdkStatsService_getJvmInfo() {
- MockSdkStatsService m;
-
- m = new MockSdkStatsService("Windows", "4.0", "x86", "1.7.8_09");
- assertEquals("1.7-x86", m.getJvmInfo());
-
- m = new MockSdkStatsService("Windows", "4.0", "amd64", "1.7.8_09");
- assertEquals("1.7-x86_64", m.getJvmInfo());
-
- m = new MockSdkStatsService("Windows", "4.0", "", "");
- assertEquals("unknown-unknown", m.getJvmInfo());
-
- m = new MockSdkStatsService("Windows", "4.0", null, null);
- assertEquals("unknown-unknown", m.getJvmInfo());
-
- // 8+32 chars max
- m = new MockSdkStatsService("Windows", "4.0",
- "one3456789ten3456789twenty6789thirty6789",
- "one3456789ten3456789twenty6789thirty6789");
- assertEquals("one34567-one3456789ten3456789twenty6789th", m.getJvmInfo());
- }
-
- public void testSdkStatsService_getOsVersion() {
- MockSdkStatsService m;
-
- m = new MockSdkStatsService("Windows", "4.0.32", "x86", "1.7.8_09");
- assertEquals("4.0", m.getOsVersion());
-
- m = new MockSdkStatsService("Windows", "4.0", "x86", "1.7.8_09");
- assertEquals("4.0", m.getOsVersion());
-
- m = new MockSdkStatsService("Windows", "4", "x86", "1.7.8_09");
- assertEquals(null, m.getOsVersion());
-
- m = new MockSdkStatsService("Windows", "4.0;extrainfo", "x86", "1.7.8_09");
- assertEquals("4.0", m.getOsVersion());
-
- m = new MockSdkStatsService("Mac OS", "10.8.32", "x86_64", "1.7.8_09");
- assertEquals("10.8", m.getOsVersion());
-
- m = new MockSdkStatsService("Mac OS", "10.8", "x86_64", "1.7.8_09");
- assertEquals("10.8", m.getOsVersion());
-
- m = new MockSdkStatsService("Other", "", "x86_64", "1.7.8_09");
- assertEquals(null, m.getOsVersion());
-
- m = new MockSdkStatsService("Other", null, "x86_64", "1.7.8_09");
- assertEquals(null, m.getOsVersion());
- }
-
- public void testSdkStatsService_getOsArch() {
- MockSdkStatsService m;
-
- // 64 bit jvm
- m = new MockSdkStatsService("Mac OS", "10.8.32", "x86_64", "1.7.8_09");
- assertEquals("x86_64", m.getOsArch());
-
- m = new MockSdkStatsService("Windows", "8.32", "x86_64", "1.7.8_09");
- assertEquals("x86_64", m.getOsArch());
-
- m = new MockSdkStatsService("Linux", "8.32", "x86_64", "1.7.8_09");
- assertEquals("x86_64", m.getOsArch());
-
- // 32 bit jvm with 32 vs 64 bit os
- m = new MockSdkStatsService("Windows", "8.32", "x86", "1.7.8_09");
- m.setSystemEnv("PROCESSOR_ARCHITEW6432", null);
- assertEquals("x86", m.getOsArch());
-
- m = new MockSdkStatsService("Windows", "8.32", "x86", "1.7.8_09");
- m.setSystemEnv("PROCESSOR_ARCHITEW6432", "AMD64");
- assertEquals("x86_64", m.getOsArch());
-
- m = new MockSdkStatsService("Windows", "8.32", "x86", "1.7.8_09");
- m.setSystemEnv("PROCESSOR_ARCHITEW6432", "IA64");
- assertEquals("x86_64", m.getOsArch());
-
- // 32 bit jvm with 32 vs 64 bit os
- m = new MockSdkStatsService("Linux", "8.32", "x86", "1.7.8_09");
- m.setSystemEnv("HOSTTYPE", null);
- assertEquals("x86", m.getOsArch());
-
- m = new MockSdkStatsService("Linux", "8.32", "x86", "1.7.8_09");
- m.setSystemEnv("HOSTTYPE", "i686-linux");
- assertEquals("x86", m.getOsArch());
-
- m = new MockSdkStatsService("Linux", "8.32", "x86", "1.7.8_09");
- m.setSystemEnv("HOSTTYPE", "AMD64");
- assertEquals("x86_64", m.getOsArch());
-
- m = new MockSdkStatsService("Linux", "8.32", "x86", "1.7.8_09");
- m.setSystemEnv("HOSTTYPE", "x86_64");
- assertEquals("x86_64", m.getOsArch());
- }
-
- public void testSdkStatsService_getOsName() {
- MockSdkStatsService m;
-
- m = new MockSdkStatsService("Mac OS", "10.8.32", "x86_64", "1.7.8_09");
- assertEquals("mac-10.8", m.getOsName());
-
- m = new MockSdkStatsService("mac", "10", "x86", "1.7.8_09");
- assertEquals("mac", m.getOsName());
-
- m = new MockSdkStatsService("Windows", "6.2", "x86_64", "1.7.8_09");
- assertEquals("win-6.2", m.getOsName());
-
- m = new MockSdkStatsService("win", "6.2", "x86", "1.7.8_09");
- assertEquals("win-6.2", m.getOsName());
-
- m = new MockSdkStatsService("win", "6", "x86_64", "1.7.8_09");
- assertEquals("win", m.getOsName());
-
- m = new MockSdkStatsService("Linux", "foobuntu-32", "x86", "1.7.8_09");
- assertEquals("linux", m.getOsName());
-
- m = new MockSdkStatsService("linux", "1", "x86_64", "1.7.8_09");
- assertEquals("linux", m.getOsName());
-
- m = new MockSdkStatsService("PowerPC", "32", "ppc", "1.7.8_09");
- assertEquals("PowerPC", m.getOsName());
-
- m = new MockSdkStatsService("freebsd", "42", "x86_64", "1.7.8_09");
- assertEquals("freebsd", m.getOsName());
-
- m = new MockSdkStatsService("openbsd", "43", "x86_64", "1.7.8_09");
- assertEquals("openbsd", m.getOsName());
-
- // 32 chars max
- m = new MockSdkStatsService("one3456789ten3456789twenty6789thirty6789",
- "42", "x86_64", "1.7.8_09");
- assertEquals("one3456789ten3456789twenty6789th", m.getOsName());
- }
-
- public void testSdkStatsService_parseVersion() {
- // Tests that the version parses supports the new "major.minor.micro rcPreview" format
- // as well as "x.y.z.t" formats as well as Eclipse's "x.y.z.v2012somedate" formats.
-
- MockSdkStatsService m;
- m = new MockSdkStatsService("Windows", "6.2", "x86_64", "1.7.8_09");
-
- m.ping("monitor", "21");
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_monitor&" +
- "id=42&" +
- "version=21.0.0.0&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64",
- m.getPingUrlResult().toString());
-
- m.ping("monitor", "21.1");
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_monitor&" +
- "id=42&" +
- "version=21.1.0.0&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64",
- m.getPingUrlResult().toString());
-
- m.ping("monitor", "21.2.03");
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_monitor&" +
- "id=42&" +
- "version=21.2.3.0&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64",
- m.getPingUrlResult().toString());
-
- m.ping("monitor", "21.2.3.4");
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_monitor&" +
- "id=42&" +
- "version=21.2.3.4&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64",
- m.getPingUrlResult().toString());
-
- // More than 4 parts or extra stuff that is not an "rc" preview are ignored.
- m.ping("monitor", "21.2.3.4.5.6.7.8");
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_monitor&" +
- "id=42&" +
- "version=21.2.3.4&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64",
- m.getPingUrlResult().toString());
-
- m.ping("monitor", "21.2.3.4.v20120101 the rest is ignored");
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_monitor&" +
- "id=42&" +
- "version=21.2.3.4&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64",
- m.getPingUrlResult().toString());
-
- // If the "rc" preview integer is present, it's equivalent to a 4th number.
- m.ping("monitor", "21 rc4");
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_monitor&" +
- "id=42&" +
- "version=21.0.0.4&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64",
- m.getPingUrlResult().toString());
-
- m.ping("monitor", "21.01 rc5");
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_monitor&" +
- "id=42&" +
- "version=21.1.0.5&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64",
- m.getPingUrlResult().toString());
-
- m.ping("monitor", "21.02.03 rc6");
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_monitor&" +
- "id=42&" +
- "version=21.2.3.6&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64",
- m.getPingUrlResult().toString());
-
- // If there's a 4-part version number, the rc preview number isn't used.
- m.ping("monitor", "21.2.3.4 rc7");
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_monitor&" +
- "id=42&" +
- "version=21.2.3.4&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64",
- m.getPingUrlResult().toString());
-
- // For Eclipse plugins, the 4th part might be a date. It is ignored.
- m.ping("eclipse", "21.2.3.v20120102235958");
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_eclipse&" +
- "id=42&" +
- "version=21.2.3.0&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64",
- m.getPingUrlResult().toString());
- }
-
- public void testSdkStatsService_glPing() {
- MockSdkStatsService m;
- m = new MockSdkStatsService("Windows", "6.2", "x86_64", "1.7.8_09");
-
- // Send emulator ping with just emulator version, no GL stuff
- m.ping("emulator", "12");
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_emulator&" +
- "id=42&" +
- "version=12.0.0.0&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64",
- m.getPingUrlResult().toString());
-
- // Send emulator ping with just emulator version, no GL stuff.
- // This is the same request but using the variable string list API, arg 0 is the "ping" app.
- m.ping(new String[] { "ping", "emulator", "12" });
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_emulator&" +
- "id=42&" +
- "version=12.0.0.0&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64",
- m.getPingUrlResult().toString());
-
- // Send a ping for a non-emulator app with extra parameters, no GL stuff
- m.ping(new String[] { "ping", "not-emulator", "12", "arg1", "arg2", "arg3" });
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_notemulator&" +
- "id=42&" +
- "version=12.0.0.0&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64",
- m.getPingUrlResult().toString());
-
- // Send a ping for the emulator app with extra parameters, GL stuff is added, 3 parameters
- m.ping(new String[] { "ping", "emulator", "12", "Vendor Inc.", "Some cool_GPU!!! (fast one!)", "1.2.3.4_preview" });
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_emulator&" +
- "id=42&" +
- "version=12.0.0.0&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64&" +
- "glm=Vendor+Inc.&" +
- "glr=Some+cool_GPU+%28fast+one+%29&" +
- "glv=1.2.3.4_preview",
- m.getPingUrlResult().toString());
-
- // Send a ping for the emulator app with extra parameters, GL stuff is added, 2 parameters
- m.ping(new String[] { "ping", "emulator", "12", "Vendor Inc.", "Some cool_GPU!!! (fast one!)" });
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_emulator&" +
- "id=42&" +
- "version=12.0.0.0&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64&" +
- "glm=Vendor+Inc.&" +
- "glr=Some+cool_GPU+%28fast+one+%29",
- m.getPingUrlResult().toString());
-
- // Send a ping for the emulator app with extra parameters, GL stuff is added, 1 parameter
- m.ping(new String[] { "ping", "emulator", "12", "Vendor Inc." });
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_emulator&" +
- "id=42&" +
- "version=12.0.0.0&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64&" +
- "glm=Vendor+Inc.",
- m.getPingUrlResult().toString());
-
- // Parameters that are more than 128 chars are cut short.
- m.ping(new String[] { "ping", "emulator", "12",
- // 130 chars each
- "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
- "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789",
- "0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789" });
- assertEquals(
- "http://tools.google.com/service/update?" +
- "as=androidsdk_emulator&" +
- "id=42&" +
- "version=12.0.0.0&" +
- "os=win-6.2&" +
- "osa=x86_64&" +
- "vma=1.7-x86_64&" +
- "glm=01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567&" +
- "glr=01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567&" +
- "glv=01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567",
- m.getPingUrlResult().toString());
- }
-}
diff --git a/swtmenubar/.classpath b/swtmenubar/.classpath
deleted file mode 100644
index d0bf6fd..0000000
--- a/swtmenubar/.classpath
+++ /dev/null
@@ -1,10 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/swt.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.core.commands_3.6.0.I20100512-1500.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.equinox.common_3.6.0.v20100503.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.jface_3.6.2.M20110210-1200.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/swtmenubar/.gitignore b/swtmenubar/.gitignore
deleted file mode 100644
index ba077a4..0000000
--- a/swtmenubar/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/swtmenubar/.project b/swtmenubar/.project
deleted file mode 100644
index 484282a..0000000
--- a/swtmenubar/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>SwtMenuBar</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/swtmenubar/Android.mk b/swtmenubar/Android.mk
deleted file mode 100644
index 699eeb3..0000000
--- a/swtmenubar/Android.mk
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# Copyright (C) 2011 The Android Open Source Project
-#
-# Licensed under the Eclipse Public License, Version 1.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.eclipse.org/org/documents/epl-v10.php
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-# The swtmenubar code has moved to tools/swt/swtmenubar.
-# The rule below uses the prebuilt swtmenubar.jar if found.
-
-LOCAL_MODULE := swtmenubar
-LOCAL_MODULE_TAGS := optional
-LOCAL_JAVA_LIBRARIES := \
- swt \
- org.eclipse.jface_3.6.2.M20110210-1200
-
-LOCAL_PREBUILT_JAVA_LIBRARIES := \
- ../../prebuilts/devtools/tools/lib/$(LOCAL_MODULE)$(COMMON_JAVA_PACKAGE_SUFFIX)
-
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/swtmenubar/MODULE_LICENSE_EPL b/swtmenubar/MODULE_LICENSE_EPL
deleted file mode 100644
index e69de29..0000000
--- a/swtmenubar/MODULE_LICENSE_EPL
+++ /dev/null
diff --git a/swtmenubar/NOTICE b/swtmenubar/NOTICE
deleted file mode 100644
index 49c101d..0000000
--- a/swtmenubar/NOTICE
+++ /dev/null
@@ -1,224 +0,0 @@
-*Eclipse Public License - v 1.0*
-
-THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE
-PUBLIC LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF
-THE PROGRAM CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.
-
-*1. DEFINITIONS*
-
-"Contribution" means:
-
-a) in the case of the initial Contributor, the initial code and
-documentation distributed under this Agreement, and
-b) in the case of each subsequent Contributor:
-
-i) changes to the Program, and
-
-ii) additions to the Program;
-
-where such changes and/or additions to the Program originate from and
-are distributed by that particular Contributor. A Contribution
-'originates' from a Contributor if it was added to the Program by such
-Contributor itself or anyone acting on such Contributor's behalf.
-Contributions do not include additions to the Program which: (i) are
-separate modules of software distributed in conjunction with the Program
-under their own license agreement, and (ii) are not derivative works of
-the Program.
-
-"Contributor" means any person or entity that distributes the Program.
-
-"Licensed Patents " mean patent claims licensable by a Contributor which
-are necessarily infringed by the use or sale of its Contribution alone
-or when combined with the Program.
-
-"Program" means the Contributions distributed in accordance with this
-Agreement.
-
-"Recipient" means anyone who receives the Program under this Agreement,
-including all Contributors.
-
-*2. GRANT OF RIGHTS*
-
-a) Subject to the terms of this Agreement, each Contributor hereby
-grants Recipient a non-exclusive, worldwide, royalty-free copyright
-license to reproduce, prepare derivative works of, publicly display,
-publicly perform, distribute and sublicense the Contribution of such
-Contributor, if any, and such derivative works, in source code and
-object code form.
-
-b) Subject to the terms of this Agreement, each Contributor hereby
-grants Recipient a non-exclusive, worldwide, royalty-free patent license
-under Licensed Patents to make, use, sell, offer to sell, import and
-otherwise transfer the Contribution of such Contributor, if any, in
-source code and object code form. This patent license shall apply to the
-combination of the Contribution and the Program if, at the time the
-Contribution is added by the Contributor, such addition of the
-Contribution causes such combination to be covered by the Licensed
-Patents. The patent license shall not apply to any other combinations
-which include the Contribution. No hardware per se is licensed hereunder.
-
-c) Recipient understands that although each Contributor grants the
-licenses to its Contributions set forth herein, no assurances are
-provided by any Contributor that the Program does not infringe the
-patent or other intellectual property rights of any other entity. Each
-Contributor disclaims any liability to Recipient for claims brought by
-any other entity based on infringement of intellectual property rights
-or otherwise. As a condition to exercising the rights and licenses
-granted hereunder, each Recipient hereby assumes sole responsibility to
-secure any other intellectual property rights needed, if any. For
-example, if a third party patent license is required to allow Recipient
-to distribute the Program, it is Recipient's responsibility to acquire
-that license before distributing the Program.
-
-d) Each Contributor represents that to its knowledge it has sufficient
-copyright rights in its Contribution, if any, to grant the copyright
-license set forth in this Agreement.
-
-*3. REQUIREMENTS*
-
-A Contributor may choose to distribute the Program in object code form
-under its own license agreement, provided that:
-
-a) it complies with the terms and conditions of this Agreement; and
-
-b) its license agreement:
-
-i) effectively disclaims on behalf of all Contributors all warranties
-and conditions, express and implied, including warranties or conditions
-of title and non-infringement, and implied warranties or conditions of
-merchantability and fitness for a particular purpose;
-
-ii) effectively excludes on behalf of all Contributors all liability for
-damages, including direct, indirect, special, incidental and
-consequential damages, such as lost profits;
-
-iii) states that any provisions which differ from this Agreement are
-offered by that Contributor alone and not by any other party; and
-
-iv) states that source code for the Program is available from such
-Contributor, and informs licensees how to obtain it in a reasonable
-manner on or through a medium customarily used for software exchange.
-
-When the Program is made available in source code form:
-
-a) it must be made available under this Agreement; and
-
-b) a copy of this Agreement must be included with each copy of the Program.
-
-Contributors may not remove or alter any copyright notices contained
-within the Program.
-
-Each Contributor must identify itself as the originator of its
-Contribution, if any, in a manner that reasonably allows subsequent
-Recipients to identify the originator of the Contribution.
-
-*4. COMMERCIAL DISTRIBUTION*
-
-Commercial distributors of software may accept certain responsibilities
-with respect to end users, business partners and the like. While this
-license is intended to facilitate the commercial use of the Program, the
-Contributor who includes the Program in a commercial product offering
-should do so in a manner which does not create potential liability for
-other Contributors. Therefore, if a Contributor includes the Program in
-a commercial product offering, such Contributor ("Commercial
-Contributor") hereby agrees to defend and indemnify every other
-Contributor ("Indemnified Contributor") against any losses, damages and
-costs (collectively "Losses") arising from claims, lawsuits and other
-legal actions brought by a third party against the Indemnified
-Contributor to the extent caused by the acts or omissions of such
-Commercial Contributor in connection with its distribution of the
-Program in a commercial product offering. The obligations in this
-section do not apply to any claims or Losses relating to any actual or
-alleged intellectual property infringement. In order to qualify, an
-Indemnified Contributor must: a) promptly notify the Commercial
-Contributor in writing of such claim, and b) allow the Commercial
-Contributor to control, and cooperate with the Commercial Contributor
-in, the defense and any related settlement negotiations. The Indemnified
-Contributor may participate in any such claim at its own expense.
-
-For example, a Contributor might include the Program in a commercial
-product offering, Product X. That Contributor is then a Commercial
-Contributor. If that Commercial Contributor then makes performance
-claims, or offers warranties related to Product X, those performance
-claims and warranties are such Commercial Contributor's responsibility
-alone. Under this section, the Commercial Contributor would have to
-defend claims against the other Contributors related to those
-performance claims and warranties, and if a court requires any other
-Contributor to pay any damages as a result, the Commercial Contributor
-must pay those damages.
-
-*5. NO WARRANTY*
-
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED
-ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
-EITHER EXPRESS OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES
-OR CONDITIONS OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR
-A PARTICULAR PURPOSE. Each Recipient is solely responsible for
-determining the appropriateness of using and distributing the Program
-and assumes all risks associated with its exercise of rights under this
-Agreement , including but not limited to the risks and costs of program
-errors, compliance with applicable laws, damage to or loss of data,
-programs or equipment, and unavailability or interruption of operations.
-
-*6. DISCLAIMER OF LIABILITY*
-
-EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR
-ANY CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT,
-INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING
-WITHOUT LIMITATION LOST PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OR
-DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS GRANTED
-HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
-
-*7. GENERAL*
-
-If any provision of this Agreement is invalid or unenforceable under
-applicable law, it shall not affect the validity or enforceability of
-the remainder of the terms of this Agreement, and without further action
-by the parties hereto, such provision shall be reformed to the minimum
-extent necessary to make such provision valid and enforceable.
-
-If Recipient institutes patent litigation against any entity (including
-a cross-claim or counterclaim in a lawsuit) alleging that the Program
-itself (excluding combinations of the Program with other software or
-hardware) infringes such Recipient's patent(s), then such Recipient's
-rights granted under Section 2(b) shall terminate as of the date such
-litigation is filed.
-
-All Recipient's rights under this Agreement shall terminate if it fails
-to comply with any of the material terms or conditions of this Agreement
-and does not cure such failure in a reasonable period of time after
-becoming aware of such noncompliance. If all Recipient's rights under
-this Agreement terminate, Recipient agrees to cease use and distribution
-of the Program as soon as reasonably practicable. However, Recipient's
-obligations under this Agreement and any licenses granted by Recipient
-relating to the Program shall continue and survive.
-
-Everyone is permitted to copy and distribute copies of this Agreement,
-but in order to avoid inconsistency the Agreement is copyrighted and may
-only be modified in the following manner. The Agreement Steward reserves
-the right to publish new versions (including revisions) of this
-Agreement from time to time. No one other than the Agreement Steward has
-the right to modify this Agreement. The Eclipse Foundation is the
-initial Agreement Steward. The Eclipse Foundation may assign the
-responsibility to serve as the Agreement Steward to a suitable separate
-entity. Each new version of the Agreement will be given a distinguishing
-version number. The Program (including Contributions) may always be
-distributed subject to the version of the Agreement under which it was
-received. In addition, after a new version of the Agreement is
-published, Contributor may elect to distribute the Program (including
-its Contributions) under the new version. Except as expressly stated in
-Sections 2(a) and 2(b) above, Recipient receives no rights or licenses
-to the intellectual property of any Contributor under this Agreement,
-whether expressly, by implication, estoppel or otherwise. All rights in
-the Program not expressly granted under this Agreement are reserved.
-
-This Agreement is governed by the laws of the State of New York and the
-intellectual property laws of the United States of America. No party to
-this Agreement will bring a legal action under this Agreement more than
-one year after the cause of action arose. Each party waives its rights
-to a jury trial in any resulting litigation.
-
-
-
diff --git a/swtmenubar/README b/swtmenubar/README
deleted file mode 100755
index ba7c25a..0000000
--- a/swtmenubar/README
+++ /dev/null
@@ -1,80 +0,0 @@
-Using the Eclipse project SwtMenuBar
-------------------------------------
-
-This project provides a platform-specific way to hook into
-the default OS menu bar.
-
-On MacOS, it allows an SWT app to have an About menu item
-and to hook into the default Preferences menu item.
-
-On Windows and Linux, an SWT Menu should be provided (typically
-named "Tools") into which the About and Options menu items
-will be added.
-
-
-Consequently the implementation contains platform-specific source
-folders for the Java files that rely on a platform-specific version
-of SWT.jar.
-
-Right now we have the following source folders:
-- src/ - Generic implementation for all platforms.
-- src-darwin/ - Implementation for MacOS Carbon.
-
-*Only* the default "src/" folder is declared in the project .classpath
-so that the project can be opened in Eclipse on any platform and still
-work. However that means that on MacOS the custom src-darwin folder is
-not used by default.
-
-
-
-1- To build the library:
-
-Do not use Eclipse to build the library. Instead use the makefile:
-
-$ cd $TOP_OF_ANDROID_TREE
-$ . build/envsetup.sh && lunch sdk-eng
-$ make swtmenubar
-
-This will create a Jar in <Android tree>/out/host/<platform>/framework/
-that can then be included in the target application.
-
-
-2- To use the library in a target application:
-
-Build the swtmenubar library as explained in step 1.
-
-In the target application, define a classpath variable in Eclipse:
-- Open Preferences > Java > Build Path > Classpath Variables
-- Create a new classpath variable named ANDROID_OUT_FRAMEWORK
-- Set its folder value to <Android tree>/out/host/<platform>/framework
-
-Then add a variable to the Build Path of the target project:
-- Open Project > Properties > Java Build Path
-- Select the "Libraries" tab
-- Use "Add Variable"
-- Select ANDROID_OUT_FRAMEWORK
-- Select "Extend..."
-- Select swtmenubar.jar (which you previously built at step 1)
-
-
-3- Tip for developing this library:
-
-Keep in mind that src-darwin folder must not be added to the
-source folder list, otherwise the library would not compile
-on Windows or Linux.
-
-If you change anything to IMenuBarCallback, make sure to test
-on a Mac to be sure you're not breaking the API.
-
-To work on this on a Mac, you can either:
-a- simply temporarily add src-darwin as a source folder to the
- build path and remove it before submitting.
-b- or directly edit the java files and rebuild the library using
- 'make swtmenubar' from a shell.
-
-To test the library, use 'make swtmenubar'. This will build the
-library in out/... and the sdkmanager project is already setup
-to find it there.
-
---
-EOF
diff --git a/testutils/.classpath b/testutils/.classpath
deleted file mode 100644
index 3134241..0000000
--- a/testutils/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src/main/java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src.zip"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/testutils/.gitignore b/testutils/.gitignore
deleted file mode 100644
index c745919..0000000
--- a/testutils/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-bin
-build
diff --git a/testutils/.project b/testutils/.project
deleted file mode 100644
index 53319e5..0000000
--- a/testutils/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>testutils</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/testutils/.settings/org.eclipse.jdt.core.prefs b/testutils/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/testutils/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/testutils/Android.mk b/testutils/Android.mk
deleted file mode 100644
index 42876f8..0000000
--- a/testutils/Android.mk
+++ /dev/null
@@ -1,49 +0,0 @@
-#
-# Copyright (C) 2008 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under,src/main/java)
-
-LOCAL_JAR_MANIFEST := manifest.txt
-
-# IMPORTANT: if you add a new dependency here, please make sure
-# to also check the following files:
-# testutils/manifest.txt
-LOCAL_JAVA_LIBRARIES := \
- common \
- junit \
- guava-tools
-
-LOCAL_MODULE := sdktestutils
-
-LOCAL_MODULE_TAGS := optional
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-# Build tests
-
-include $(CLEAR_VARS)
-
-# Only compile source java files in this lib.
-LOCAL_SRC_FILES := $(call all-java-files-under, src/main/java)
-
-LOCAL_MODULE := sdktestutils-tests
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_JAVA_LIBRARIES := common sdktestutils junit
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/testutils/NOTICE b/testutils/NOTICE
deleted file mode 100644
index 002f1cb..0000000
--- a/testutils/NOTICE
+++ /dev/null
@@ -1,189 +0,0 @@
-
- Copyright (c) 2005-2012, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
diff --git a/testutils/manifest.txt b/testutils/manifest.txt
deleted file mode 100644
index b0f908d..0000000
--- a/testutils/manifest.txt
+++ /dev/null
@@ -1 +0,0 @@
-Class-Path: guava-tools.jar
diff --git a/testutils/src/main/java/com/android/testutils/SdkTestCase.java b/testutils/src/main/java/com/android/testutils/SdkTestCase.java
deleted file mode 100644
index 6a4d54a..0000000
--- a/testutils/src/main/java/com/android/testutils/SdkTestCase.java
+++ /dev/null
@@ -1,436 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Eclipse Public License, Version 1.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.eclipse.org/org/documents/epl-v10.php
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.android.testutils;
-
-import com.android.SdkConstants;
-import com.google.common.base.Charsets;
-import com.google.common.collect.Sets;
-import com.google.common.io.ByteStreams;
-import com.google.common.io.Closeables;
-import com.google.common.io.Files;
-import com.google.common.io.InputSupplier;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-/**
- * Common test case for SDK unit tests. Contains a number of general utility methods
- * to help writing test cases, such as looking up a temporary directory, comparing golden
- * files, computing string diffs, etc.
- */
-@SuppressWarnings("javadoc")
-public class SdkTestCase extends TestCase {
- public static final String TEST_PROJECT_PACKAGE = "com.android.eclipse.tests"; //$NON-NLS-1$
-
- /** Update golden files if different from the actual results */
- private static final boolean UPDATE_DIFFERENT_FILES = false;
- /** Create golden files if missing */
- private static final boolean UPDATE_MISSING_FILES = true;
- private static File sTempDir = null;
- protected static Set<File> sCleanDirs = Sets.newHashSet();
-
- protected String getTestDataRelPath() {
- return "eclipse/plugins/com.android.ide.eclipse.tests/src/com/android/ide/eclipse/adt/"
- + "internal/editors/layout/refactoring/testdata";
- }
-
- public static int getCaretOffset(String fileContent, String caretLocation) {
- assertTrue(caretLocation, caretLocation.contains("^")); //$NON-NLS-1$
-
- int caretDelta = caretLocation.indexOf("^"); //$NON-NLS-1$
- assertTrue(caretLocation, caretDelta != -1);
-
- // String around caret/range without the range and caret marker characters
- String caretContext;
- if (caretLocation.contains("[^")) { //$NON-NLS-1$
- caretDelta--;
- assertTrue(caretLocation, caretLocation.startsWith("[^", caretDelta)); //$NON-NLS-1$
- int caretRangeEnd = caretLocation.indexOf(']', caretDelta + 2);
- assertTrue(caretLocation, caretRangeEnd != -1);
- caretContext = caretLocation.substring(0, caretDelta)
- + caretLocation.substring(caretDelta + 2, caretRangeEnd)
- + caretLocation.substring(caretRangeEnd + 1);
- } else {
- caretContext = caretLocation.substring(0, caretDelta)
- + caretLocation.substring(caretDelta + 1); // +1: skip "^"
- }
-
- int caretContextIndex = fileContent.indexOf(caretContext);
- assertTrue("Caret content " + caretContext + " not found in file",
- caretContextIndex != -1);
- return caretContextIndex + caretDelta;
- }
-
- public static String addSelection(String newFileContents, int selectionBegin, int selectionEnd) {
- // Insert selection markers -- [ ] for the selection range, ^ for the caret
- String newFileWithCaret;
- if (selectionBegin < selectionEnd) {
- newFileWithCaret = newFileContents.substring(0, selectionBegin) + "[^"
- + newFileContents.substring(selectionBegin, selectionEnd) + "]"
- + newFileContents.substring(selectionEnd);
- } else {
- // Selected range
- newFileWithCaret = newFileContents.substring(0, selectionBegin) + "^"
- + newFileContents.substring(selectionBegin);
- }
-
- return newFileWithCaret;
- }
-
- public static String getCaretContext(String file, int offset) {
- int windowSize = 20;
- int begin = Math.max(0, offset - windowSize / 2);
- int end = Math.min(file.length(), offset + windowSize / 2);
-
- return "..." + file.substring(begin, offset) + "^" + file.substring(offset, end) + "...";
- }
-
- /** Get the location to write missing golden files to */
- protected File getTargetDir() {
- // Set $ADT_SDK_SOURCE_PATH to point to your git "sdk" directory; if done, then
- // if you run a unit test which refers to a golden file which does not exist, it
- // will be created directly into the test data directory and you can rerun the
- // test
- // and it should pass (after you verify that the golden file contains the correct
- // result of course).
- String sdk = System.getenv("ADT_SDK_SOURCE_PATH");
- if (sdk != null) {
- File sdkPath = new File(sdk);
- if (sdkPath.exists()) {
- File testData = new File(sdkPath, getTestDataRelPath().replace('/',
- File.separatorChar));
- if (testData.exists()) {
- addCleanupDir(testData);
- return testData;
- }
- }
- }
- return getTempDir();
- }
-
- public static File getTempDir() {
- if (sTempDir == null) {
- File base = new File(System.getProperty("java.io.tmpdir")); //$NON-NLS-1$
- if (SdkConstants.CURRENT_PLATFORM == SdkConstants.PLATFORM_DARWIN) {
- base = new File("/tmp"); //$NON-NLS-1$
- }
-
- // On Windows, we don't want to pollute the temp folder (which is generally
- // already incredibly busy). So let's create a temp folder for the results.
-
- Calendar c = Calendar.getInstance();
- String name = String.format("sdkTests_%1$tF_%1$tT", c).replace(':', '-'); //$NON-NLS-1$
- File tmpDir = new File(base, name);
- if (!tmpDir.exists() && tmpDir.mkdir()) {
- sTempDir = tmpDir;
- } else {
- sTempDir = base;
- }
- addCleanupDir(sTempDir);
- }
-
- return sTempDir;
- }
-
- protected String removeSessionData(String data) {
- return data;
- }
-
- protected InputStream getTestResource(String relativePath, boolean expectExists) {
- String path = "testdata" + File.separator + relativePath; //$NON-NLS-1$
- InputStream stream = SdkTestCase.class.getResourceAsStream(path);
- if (!expectExists && stream == null) {
- return null;
- }
- return stream;
- }
-
- @SuppressWarnings("resource")
- protected String readTestFile(String relativePath, boolean expectExists) throws IOException {
- InputStream stream = getTestResource(relativePath, expectExists);
- if (expectExists) {
- assertNotNull(relativePath + " does not exist", stream);
- } else if (stream == null) {
- return null;
- }
-
- String xml = new String(ByteStreams.toByteArray(stream), Charsets.UTF_8);
- Closeables.closeQuietly(stream);
- assertTrue(xml.length() > 0);
-
- // Remove any references to the project name such that we are isolated from
- // that in golden file.
- // Appears in strings.xml etc.
- xml = removeSessionData(xml);
-
- return xml;
- }
-
- protected void assertEqualsGolden(String basename, String actual) throws IOException {
- assertEqualsGolden(basename, actual, basename.substring(basename.lastIndexOf('.') + 1));
- }
-
- protected void assertEqualsGolden(String basename, String actual, String newExtension)
- throws IOException {
- String testName = getName();
- if (testName.startsWith("test")) {
- testName = testName.substring(4);
- if (Character.isUpperCase(testName.charAt(0))) {
- testName = Character.toLowerCase(testName.charAt(0)) + testName.substring(1);
- }
- }
- String expectedName;
- String extension = basename.substring(basename.lastIndexOf('.') + 1);
- if (newExtension == null) {
- newExtension = extension;
- }
- expectedName = basename.substring(0, basename.indexOf('.'))
- + "-expected-" + testName + '.' + newExtension;
- String expected = readTestFile(expectedName, false);
- if (expected == null) {
- File expectedPath = new File(
- UPDATE_MISSING_FILES ? getTargetDir() : getTempDir(), expectedName);
- Files.write(actual, expectedPath, Charsets.UTF_8);
- System.out.println("Expected - written to " + expectedPath + ":\n");
- System.out.println(actual);
- fail("Did not find golden file (" + expectedName + "): Wrote contents as "
- + expectedPath);
- } else {
- if (!expected.replaceAll("\r\n", "\n").equals(actual.replaceAll("\r\n", "\n"))) {
- File expectedPath = new File(getTempDir(), expectedName);
- File actualPath = new File(getTempDir(),
- expectedName.replace("expected", "actual"));
- Files.write(expected, expectedPath, Charsets.UTF_8);
- Files.write(actual, actualPath, Charsets.UTF_8);
- // Also update data dir with the current value
- if (UPDATE_DIFFERENT_FILES) {
- Files.write(actual, new File(getTargetDir(), expectedName), Charsets.UTF_8);
- }
- System.out.println("The files differ: diff " + expectedPath + " "
- + actualPath);
- assertEquals("The files differ - see " + expectedPath + " versus " + actualPath,
- expected, actual);
- }
- }
- }
-
- /** Creates a diff of two strings */
- public static String getDiff(String before, String after) {
- return getDiff(before.split("\n"), after.split("\n"));
- }
-
- public static String getDiff(String[] before, String[] after) {
- // Based on the LCS section in http://introcs.cs.princeton.edu/java/96optimization/
- StringBuilder sb = new StringBuilder();
-
- int n = before.length;
- int m = after.length;
-
- // Compute longest common subsequence of x[i..m] and y[j..n] bottom up
- int[][] lcs = new int[n + 1][m + 1];
- for (int i = n - 1; i >= 0; i--) {
- for (int j = m - 1; j >= 0; j--) {
- if (before[i].equals(after[j])) {
- lcs[i][j] = lcs[i + 1][j + 1] + 1;
- } else {
- lcs[i][j] = Math.max(lcs[i + 1][j], lcs[i][j + 1]);
- }
- }
- }
-
- int i = 0;
- int j = 0;
- while ((i < n) && (j < m)) {
- if (before[i].equals(after[j])) {
- i++;
- j++;
- } else {
- sb.append("@@ -");
- sb.append(Integer.toString(i + 1));
- sb.append(" +");
- sb.append(Integer.toString(j + 1));
- sb.append('\n');
- while (i < n && j < m && !before[i].equals(after[j])) {
- if (lcs[i + 1][j] >= lcs[i][j + 1]) {
- sb.append('-');
- if (!before[i].trim().isEmpty()) {
- sb.append(' ');
- }
- sb.append(before[i]);
- sb.append('\n');
- i++;
- } else {
- sb.append('+');
- if (!after[j].trim().isEmpty()) {
- sb.append(' ');
- }
- sb.append(after[j]);
- sb.append('\n');
- j++;
- }
- }
- }
- }
-
- if (i < n || j < m) {
- assert i == n || j == m;
- sb.append("@@ -");
- sb.append(Integer.toString(i + 1));
- sb.append(" +");
- sb.append(Integer.toString(j + 1));
- sb.append('\n');
- for (; i < n; i++) {
- sb.append('-');
- if (!before[i].trim().isEmpty()) {
- sb.append(' ');
- }
- sb.append(before[i]);
- sb.append('\n');
- }
- for (; j < m; j++) {
- sb.append('+');
- if (!after[j].trim().isEmpty()) {
- sb.append(' ');
- }
- sb.append(after[j]);
- sb.append('\n');
- }
- }
-
- return sb.toString();
- }
-
- protected void deleteFile(File dir) {
- if (dir.isDirectory()) {
- for (File f : dir.listFiles()) {
- deleteFile(f);
- }
- } else if (dir.isFile()) {
- assertTrue(dir.getPath(), dir.delete());
- }
- }
-
- protected File makeTestFile(String name, String relative,
- final InputStream contents) throws IOException {
- return makeTestFile(getTargetDir(), name, relative, contents);
- }
-
- protected File makeTestFile(File dir, String name, String relative,
- final InputStream contents) throws IOException {
- if (relative != null) {
- dir = new File(dir, relative);
- if (!dir.exists()) {
- boolean mkdir = dir.mkdirs();
- assertTrue(dir.getPath(), mkdir);
- }
- } else if (!dir.exists()) {
- boolean mkdir = dir.mkdirs();
- assertTrue(dir.getPath(), mkdir);
- }
- File tempFile = new File(dir, name);
- if (tempFile.exists()) {
- tempFile.delete();
- }
-
- Files.copy(new InputSupplier<InputStream>() {
- @Override
- public InputStream getInput() throws IOException {
- return contents;
- }
- }, tempFile);
-
- return tempFile;
- }
-
- protected File getTestfile(File targetDir, String relativePath) throws IOException {
- // Support replacing filenames and paths with a => syntax, e.g.
- // dir/file.txt=>dir2/dir3/file2.java
- // will read dir/file.txt from the test data and write it into the target
- // directory as dir2/dir3/file2.java
-
- String targetPath = relativePath;
- int replaceIndex = relativePath.indexOf("=>"); //$NON-NLS-1$
- if (replaceIndex != -1) {
- // foo=>bar
- targetPath = relativePath.substring(replaceIndex + "=>".length());
- relativePath = relativePath.substring(0, replaceIndex);
- }
-
- InputStream stream = getTestResource(relativePath, true);
- assertNotNull(relativePath + " does not exist", stream);
- int index = targetPath.lastIndexOf('/');
- String relative = null;
- String name = targetPath;
- if (index != -1) {
- name = targetPath.substring(index + 1);
- relative = targetPath.substring(0, index);
- }
-
- return makeTestFile(targetDir, name, relative, stream);
- }
-
- protected static void addCleanupDir(File dir) {
- sCleanDirs.add(dir);
- try {
- sCleanDirs.add(dir.getCanonicalFile());
- } catch (IOException e) {
- fail(e.getLocalizedMessage());
- }
- sCleanDirs.add(dir.getAbsoluteFile());
- }
-
- protected String cleanup(String result) {
- List<File> sorted = new ArrayList<File>(sCleanDirs);
- // Process dirs in order such that we match longest substrings first
- Collections.sort(sorted, new Comparator<File>() {
- @Override
- public int compare(File file1, File file2) {
- String path1 = file1.getPath();
- String path2 = file2.getPath();
- int delta = path2.length() - path1.length();
- if (delta != 0) {
- return delta;
- } else {
- return path1.compareTo(path2);
- }
- }
- });
-
- for (File dir : sorted) {
- if (result.contains(dir.getPath())) {
- result = result.replace(dir.getPath(), "/TESTROOT");
- }
- }
-
- // The output typically contains a few directory/filenames.
- // On Windows we need to change the separators to the unix-style
- // forward slash to make the test as OS-agnostic as possible.
- if (File.separatorChar != '/') {
- result = result.replace(File.separatorChar, '/');
- }
-
- return result;
- }
-}
diff --git a/testutils/src/test/.classpath b/testutils/src/test/.classpath
deleted file mode 100644
index 271183e..0000000
--- a/testutils/src/test/.classpath
+++ /dev/null
@@ -1,9 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="java"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/guava-tools/guava-13.0.1.jar" sourcepath="/ANDROID_SRC/prebuilts/tools/common/guava-tools/src.zip"/>
- <classpathentry combineaccessrules="false" kind="src" path="/testutils"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/testutils/src/test/.project b/testutils/src/test/.project
deleted file mode 100644
index 3191084..0000000
--- a/testutils/src/test/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>testutils-tests</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/testutils/src/test/java/com/android/testutils/SdkTestCaseTest.java b/testutils/src/test/java/com/android/testutils/SdkTestCaseTest.java
deleted file mode 100644
index 9ab1a68..0000000
--- a/testutils/src/test/java/com/android/testutils/SdkTestCaseTest.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.testutils;
-
-import junit.framework.TestCase;
-
-@SuppressWarnings("javadoc")
-public class SdkTestCaseTest extends TestCase {
- public void testDiff() throws Exception {
- assertEquals(
- "",
- SdkTestCase.getDiff(
- "",
- ""));
- assertEquals(
- "",
- SdkTestCase.getDiff(
- "aaa",
- "aaa"));
- assertEquals(
- "@@ -1 +1\n" +
- "- aaa\n" +
- "@@ -2 +1\n" +
- "+ bbb\n",
- SdkTestCase.getDiff(
- "aaa",
- "bbb"));
- assertEquals(
- "@@ -1 +1\n" +
- "- this\n" +
- "@@ -4 +3\n" +
- "+ new\n",
- SdkTestCase.getDiff(
- "this\n" +
- "is\n" +
- "a\n" +
- "test\n",
-
- "is\n" +
- "a\n" +
- "new\n" +
- "test\n"));
- assertEquals(
- "@@ -4 +4\n" +
- "- line4\n" +
- "- line5\n" +
- "@@ -8 +6\n" +
- "- line8\n" +
- "+ line7.5\n",
- SdkTestCase.getDiff(
- "line1\n" +
- "line2\n" +
- "line3\n" +
- "line4\n" +
- "line5\n" +
- "line6\n" +
- "line7\n" +
- "line8\n" +
- "line9\n",
-
- "line1\n" +
- "line2\n" +
- "line3\n" +
- "line6\n" +
- "line7\n" +
- "line7.5\n" +
- "line9\n"));
- assertEquals(
- "@@ -8 +8\n" +
- "- android:id=\"@+id/textView1\"\n" +
- "+ android:id=\"@+id/output\"\n" +
- "@@ -19 +19\n" +
- "- android:layout_alignLeft=\"@+id/textView1\"\n" +
- "- android:layout_below=\"@+id/textView1\"\n" +
- "+ android:layout_alignLeft=\"@+id/output\"\n" +
- "+ android:layout_below=\"@+id/output\"\n",
-
- SdkTestCase.getDiff(
- "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
- " xmlns:tools=\"http://schemas.android.com/tools\"\n" +
- " android:layout_width=\"match_parent\"\n" +
- " android:layout_height=\"match_parent\"\n" +
- " tools:context=\".MainActivity\" >\n" +
- "\n" +
- " <TextView\n" +
- " android:id=\"@+id/textView1\"\n" +
- " android:layout_width=\"wrap_content\"\n" +
- " android:layout_height=\"wrap_content\"\n" +
- " android:layout_centerVertical=\"true\"\n" +
- " android:layout_toRightOf=\"@+id/button2\"\n" +
- " android:text=\"@string/hello_world\" />\n" +
- "\n" +
- " <Button\n" +
- " android:id=\"@+id/button1\"\n" +
- " android:layout_width=\"wrap_content\"\n" +
- " android:layout_height=\"wrap_content\"\n" +
- " android:layout_alignLeft=\"@+id/textView1\"\n" +
- " android:layout_below=\"@+id/textView1\"\n" +
- " android:layout_marginLeft=\"22dp\"\n" +
- " android:layout_marginTop=\"24dp\"\n" +
- " android:text=\"Button\" />\n" +
- "\n" +
- " <Button\n" +
- " android:id=\"@+id/button2\"\n" +
- " android:layout_width=\"wrap_content\"\n" +
- " android:layout_height=\"wrap_content\"\n" +
- " android:layout_alignParentLeft=\"true\"\n" +
- " android:layout_alignParentTop=\"true\"\n" +
- " android:text=\"Button\" />\n" +
- "\n" +
- "</RelativeLayout>",
-
- "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" +
- " xmlns:tools=\"http://schemas.android.com/tools\"\n" +
- " android:layout_width=\"match_parent\"\n" +
- " android:layout_height=\"match_parent\"\n" +
- " tools:context=\".MainActivity\" >\n" +
- "\n" +
- " <TextView\n" +
- " android:id=\"@+id/output\"\n" +
- " android:layout_width=\"wrap_content\"\n" +
- " android:layout_height=\"wrap_content\"\n" +
- " android:layout_centerVertical=\"true\"\n" +
- " android:layout_toRightOf=\"@+id/button2\"\n" +
- " android:text=\"@string/hello_world\" />\n" +
- "\n" +
- " <Button\n" +
- " android:id=\"@+id/button1\"\n" +
- " android:layout_width=\"wrap_content\"\n" +
- " android:layout_height=\"wrap_content\"\n" +
- " android:layout_alignLeft=\"@+id/output\"\n" +
- " android:layout_below=\"@+id/output\"\n" +
- " android:layout_marginLeft=\"22dp\"\n" +
- " android:layout_marginTop=\"24dp\"\n" +
- " android:text=\"Button\" />\n" +
- "\n" +
- " <Button\n" +
- " android:id=\"@+id/button2\"\n" +
- " android:layout_width=\"wrap_content\"\n" +
- " android:layout_height=\"wrap_content\"\n" +
- " android:layout_alignParentLeft=\"true\"\n" +
- " android:layout_alignParentTop=\"true\"\n" +
- " android:text=\"Button\" />\n" +
- "\n" +
- "</RelativeLayout>"));
- }
-}
diff --git a/traceview/.classpath b/traceview/.classpath
deleted file mode 100644
index 6cced4c..0000000
--- a/traceview/.classpath
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry excluding="resources/" kind="src" path="src"/>
- <classpathentry kind="src" path="src/resources"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/SdkStatsService"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/swt.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.core.commands_3.6.0.I20100512-1500.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.equinox.common_3.6.0.v20100503.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.jface_3.6.2.M20110210-1200.jar"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/traceview/.gitignore b/traceview/.gitignore
deleted file mode 100644
index ba077a4..0000000
--- a/traceview/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/traceview/.project b/traceview/.project
deleted file mode 100644
index 692297f..0000000
--- a/traceview/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>traceview</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/traceview/.settings/README.txt b/traceview/.settings/README.txt
deleted file mode 100644
index 9120b20..0000000
--- a/traceview/.settings/README.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Copy this in eclipse project as a .settings folder at the root.
-This ensure proper compilation compliance and warning/error levels. \ No newline at end of file
diff --git a/traceview/.settings/org.eclipse.jdt.core.prefs b/traceview/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/traceview/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/traceview/Android.mk b/traceview/Android.mk
deleted file mode 100644
index 2ce7b80..0000000
--- a/traceview/Android.mk
+++ /dev/null
@@ -1,5 +0,0 @@
-# Copyright 2007 The Android Open Source Project
-#
-TRACEVIEW_LOCAL_DIR := $(call my-dir)
-include $(TRACEVIEW_LOCAL_DIR)/etc/Android.mk
-include $(TRACEVIEW_LOCAL_DIR)/src/Android.mk
diff --git a/traceview/NOTICE b/traceview/NOTICE
deleted file mode 100644
index c5b1efa..0000000
--- a/traceview/NOTICE
+++ /dev/null
@@ -1,190 +0,0 @@
-
- Copyright (c) 2005-2008, The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
diff --git a/traceview/README b/traceview/README
deleted file mode 100644
index 6f4576a..0000000
--- a/traceview/README
+++ /dev/null
@@ -1,11 +0,0 @@
-Using the Eclipse projects for traceview.
-
-traceview requires SWT to compile.
-
-SWT is available in the depot under //device/prebuild/<platform>/swt
-
-Because the build path cannot contain relative path that are not inside the project directory,
-the .classpath file references a user library called ANDROID_SWT.
-
-In order to compile the project, make a user library called ANDROID_SWT containing the jar
-available at //device/prebuild/<platform>/swt.
diff --git a/traceview/etc/Android.mk b/traceview/etc/Android.mk
deleted file mode 100644
index 818ae9e..0000000
--- a/traceview/etc/Android.mk
+++ /dev/null
@@ -1,9 +0,0 @@
-# Copyright 2007 The Android Open Source Project
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_PREBUILT_EXECUTABLES := traceview
-LOCAL_MODULE_TAGS := debug
-include $(BUILD_HOST_PREBUILT)
-
diff --git a/traceview/etc/manifest.txt b/traceview/etc/manifest.txt
deleted file mode 100644
index e145b4a..0000000
--- a/traceview/etc/manifest.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Main-Class: com.android.traceview.MainWindow
-Class-Path: common.jar swt.jar org.eclipse.equinox.common_3.2.0.v20060603.jar org.eclipse.jface_3.2.0.I20060605-1400.jar org.eclipse.core.commands_3.2.0.I20060605-1400.jar guava-tools.jar
diff --git a/traceview/etc/traceview b/traceview/etc/traceview
deleted file mode 100755
index cd4a25f..0000000
--- a/traceview/etc/traceview
+++ /dev/null
@@ -1,108 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2005-2006, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
- newProg=`/bin/ls -ld "${prog}"`
- newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
- if expr "x${newProg}" : 'x/' >/dev/null; then
- prog="${newProg}"
- else
- progdir=`dirname "${prog}"`
- prog="${progdir}/${newProg}"
- fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-progname=`basename "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/"${progname}"
-cd "${oldwd}"
-
-jarfile=traceview.jar
-frameworkdir="$progdir"
-libdir="$progdir"
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/tools/lib
- libdir=`dirname "$progdir"`/tools/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/framework
- libdir=`dirname "$progdir"`/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- echo "${progname}: can't find $jarfile"
- exit 1
-fi
-
-javaCmd="java"
-
-os=`uname`
-if [ $os == 'Darwin' ]; then
- javaOpts="-Xmx1600M -XstartOnFirstThread"
-else
- javaOpts="-Xmx1600M"
-fi
-
-if [ `uname` = "Linux" ]; then
- export GDK_NATIVE_WINDOWS=true
-fi
-
-while expr "x$1" : 'x-J' >/dev/null; do
- opt=`expr "x$1" : 'x-J\(.*\)'`
- javaOpts="${javaOpts} -${opt}"
- shift
-done
-
-jarpath="$frameworkdir/$jarfile"
-
-# Figure out the path to the swt.jar for the current architecture.
-# if ANDROID_SWT is defined, then just use this.
-# else, if running in the Android source tree, then look for the correct swt folder in prebuilt
-# else, look for the correct swt folder in the SDK under tools/lib/
-swtpath=""
-if [ -n "$ANDROID_SWT" ]; then
- swtpath="$ANDROID_SWT"
-else
- vmarch=`${javaCmd} -jar "${frameworkdir}"/archquery.jar`
- if [ -n "$ANDROID_BUILD_TOP" ]; then
- osname=`uname -s | tr A-Z a-z`
- swtpath="${ANDROID_BUILD_TOP}/prebuilts/tools/${osname}-${vmarch}/swt"
- else
- swtpath="${frameworkdir}/${vmarch}"
- fi
-fi
-
-# Combine the swtpath and the framework dir path.
-if [ -d "$swtpath" ]; then
- frameworkdir="${swtpath}:${frameworkdir}"
-else
- echo "SWT folder '${swtpath}' does not exist."
- echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform."
- exit 1
-fi
-
-if [ -x $progdir/monitor ]; then
- echo "The standalone version of traceview is deprecated."
- echo "Please use Android Device Monitor (tools/monitor) instead."
-fi
-exec "${javaCmd}" $javaOpts -Djava.ext.dirs="$frameworkdir" -Dcom.android.traceview.toolsdir="$progdir" -jar "$jarpath" "$@"
diff --git a/traceview/etc/traceview.bat b/traceview/etc/traceview.bat
deleted file mode 100755
index 63416dd..0000000
--- a/traceview/etc/traceview.bat
+++ /dev/null
@@ -1,65 +0,0 @@
-@echo off
-rem Copyright (C) 2007 The Android Open Source Project
-rem
-rem Licensed under the Apache License, Version 2.0 (the "License");
-rem you may not use this file except in compliance with the License.
-rem You may obtain a copy of the License at
-rem
-rem http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-
-rem don't modify the caller's environment
-setlocal
-
-rem Set up prog to be the path of this script, including following symlinks,
-rem and set up progdir to be the fully-qualified pathname of its directory.
-set prog=%~f0
-
-rem Change current directory and drive to where the script is, to avoid
-rem issues with directories containing whitespaces.
-cd /d %~dp0
-
-rem Check we have a valid Java.exe in the path.
-set java_exe=
-call lib\find_java.bat
-if not defined java_exe goto :EOF
-
-set jarfile=traceview.jar
-set frameworkdir=
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=lib\
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=..\framework\
-
-:JarFileOk
-
-set jarpath=%frameworkdir%%jarfile%
-
-if not defined ANDROID_SWT goto QueryArch
- set swt_path=%ANDROID_SWT%
- goto SwtDone
-
-:QueryArch
-
- for /f %%a in ('%java_exe% -jar %frameworkdir%archquery.jar') do set swt_path=%frameworkdir%%%a
-
-:SwtDone
-
-if exist %swt_path% goto SetPath
- echo SWT folder '%swt_path%' does not exist.
- echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
- exit /B
-
-:SetPath
-set javaextdirs=%swt_path%;%frameworkdir%
-
-echo The standalone version of traceview is deprecated.
-echo Please use Android Device Monitor (tools/monitor) instead.
-call %java_exe% -Djava.ext.dirs=%javaextdirs% -Dcom.android.traceview.toolsdir= -jar %jarpath% %*
diff --git a/traceview/src/Android.mk b/traceview/src/Android.mk
deleted file mode 100644
index 1502a78..0000000
--- a/traceview/src/Android.mk
+++ /dev/null
@@ -1,20 +0,0 @@
-# Copyright 2007 The Android Open Source Project
-#
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_JAVA_RESOURCE_DIRS := resources
-
-LOCAL_SRC_FILES := $(call all-subdir-java-files)
-LOCAL_JAR_MANIFEST := ../etc/manifest.txt
-LOCAL_JAVA_LIBRARIES := \
- common \
- sdkstats \
- swt \
- org.eclipse.jface_3.6.2.M20110210-1200 \
- org.eclipse.equinox.common_3.6.0.v20100503 \
- org.eclipse.core.commands_3.6.0.I20100512-1500
-LOCAL_MODULE := traceview
-LOCAL_MODULE_TAGS := debug
-
-include $(BUILD_HOST_JAVA_LIBRARY)
diff --git a/traceview/src/com/android/traceview/Call.java b/traceview/src/com/android/traceview/Call.java
deleted file mode 100644
index 0330b05..0000000
--- a/traceview/src/com/android/traceview/Call.java
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-import org.eclipse.swt.graphics.Color;
-
-class Call implements TimeLineView.Block {
- final private ThreadData mThreadData;
- final private MethodData mMethodData;
- final Call mCaller; // the caller, or null if this is the root
-
- private String mName;
- private boolean mIsRecursive;
-
- long mGlobalStartTime;
- long mGlobalEndTime;
-
- long mThreadStartTime;
- long mThreadEndTime;
-
- long mInclusiveRealTime; // real time spent in this call including its children
- long mExclusiveRealTime; // real time spent in this call including its children
-
- long mInclusiveCpuTime; // cpu time spent in this call including its children
- long mExclusiveCpuTime; // cpu time spent in this call excluding its children
-
- Call(ThreadData threadData, MethodData methodData, Call caller) {
- mThreadData = threadData;
- mMethodData = methodData;
- mName = methodData.getProfileName();
- mCaller = caller;
- }
-
- public void updateName() {
- mName = mMethodData.getProfileName();
- }
-
- @Override
- public double addWeight(int x, int y, double weight) {
- return mMethodData.addWeight(x, y, weight);
- }
-
- @Override
- public void clearWeight() {
- mMethodData.clearWeight();
- }
-
- @Override
- public long getStartTime() {
- return mGlobalStartTime;
- }
-
- @Override
- public long getEndTime() {
- return mGlobalEndTime;
- }
-
- @Override
- public long getExclusiveCpuTime() {
- return mExclusiveCpuTime;
- }
-
- @Override
- public long getInclusiveCpuTime() {
- return mInclusiveCpuTime;
- }
-
- @Override
- public long getExclusiveRealTime() {
- return mExclusiveRealTime;
- }
-
- @Override
- public long getInclusiveRealTime() {
- return mInclusiveRealTime;
- }
-
- @Override
- public Color getColor() {
- return mMethodData.getColor();
- }
-
- @Override
- public String getName() {
- return mName;
- }
-
- public void setName(String name) {
- mName = name;
- }
-
- public ThreadData getThreadData() {
- return mThreadData;
- }
-
- public int getThreadId() {
- return mThreadData.getId();
- }
-
- @Override
- public MethodData getMethodData() {
- return mMethodData;
- }
-
- @Override
- public boolean isContextSwitch() {
- return mMethodData.getId() == -1;
- }
-
- @Override
- public boolean isIgnoredBlock() {
- // Ignore the top-level call or context switches within the top-level call.
- return mCaller == null || isContextSwitch() && mCaller.mCaller == null;
- }
-
- @Override
- public TimeLineView.Block getParentBlock() {
- return mCaller;
- }
-
- public boolean isRecursive() {
- return mIsRecursive;
- }
-
- void setRecursive(boolean isRecursive) {
- mIsRecursive = isRecursive;
- }
-
- void addCpuTime(long elapsedCpuTime) {
- mExclusiveCpuTime += elapsedCpuTime;
- mInclusiveCpuTime += elapsedCpuTime;
- }
-
- /**
- * Record time spent in the method call.
- */
- void finish() {
- if (mCaller != null) {
- mCaller.mInclusiveCpuTime += mInclusiveCpuTime;
- mCaller.mInclusiveRealTime += mInclusiveRealTime;
- }
-
- mMethodData.addElapsedExclusive(mExclusiveCpuTime, mExclusiveRealTime);
- if (!mIsRecursive) {
- mMethodData.addTopExclusive(mExclusiveCpuTime, mExclusiveRealTime);
- }
- mMethodData.addElapsedInclusive(mInclusiveCpuTime, mInclusiveRealTime,
- mIsRecursive, mCaller);
- }
-
- public static final class TraceAction {
- public static final int ACTION_ENTER = 0;
- public static final int ACTION_EXIT = 1;
-
- public final int mAction;
- public final Call mCall;
-
- public TraceAction(int action, Call call) {
- mAction = action;
- mCall = call;
- }
- }
-}
diff --git a/traceview/src/com/android/traceview/ColorController.java b/traceview/src/com/android/traceview/ColorController.java
deleted file mode 100644
index f5e4c0d..0000000
--- a/traceview/src/com/android/traceview/ColorController.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-import java.util.HashMap;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-
-public class ColorController {
- private static final int[] systemColors = { SWT.COLOR_BLUE, SWT.COLOR_RED,
- SWT.COLOR_GREEN, SWT.COLOR_CYAN, SWT.COLOR_MAGENTA, SWT.COLOR_DARK_BLUE,
- SWT.COLOR_DARK_RED, SWT.COLOR_DARK_GREEN, SWT.COLOR_DARK_YELLOW,
- SWT.COLOR_DARK_CYAN, SWT.COLOR_DARK_MAGENTA, SWT.COLOR_BLACK };
-
- private static RGB[] rgbColors = { new RGB(90, 90, 255), // blue
- new RGB(0, 240, 0), // green
- new RGB(255, 0, 0), // red
- new RGB(0, 255, 255), // cyan
- new RGB(255, 80, 255), // magenta
- new RGB(200, 200, 0), // yellow
- new RGB(40, 0, 200), // dark blue
- new RGB(150, 255, 150), // light green
- new RGB(150, 0, 0), // dark red
- new RGB(30, 150, 150), // dark cyan
- new RGB(200, 200, 255), // light blue
- new RGB(0, 120, 0), // dark green
- new RGB(255, 150, 150), // light red
- new RGB(140, 80, 140), // dark magenta
- new RGB(150, 100, 50), // brown
- new RGB(70, 70, 70), // dark grey
- };
-
- private static HashMap<Integer, Color> colorCache = new HashMap<Integer, Color>();
- private static HashMap<Integer, Image> imageCache = new HashMap<Integer, Image>();
-
- public ColorController() {
- }
-
- public static Color requestColor(Display display, RGB rgb) {
- return requestColor(display, rgb.red, rgb.green, rgb.blue);
- }
-
- public static Image requestColorSquare(Display display, RGB rgb) {
- return requestColorSquare(display, rgb.red, rgb.green, rgb.blue);
- }
-
- public static Color requestColor(Display display, int red, int green, int blue) {
- int key = (red << 16) | (green << 8) | blue;
- Color color = colorCache.get(key);
- if (color == null) {
- color = new Color(display, red, green, blue);
- colorCache.put(key, color);
- }
- return color;
- }
-
- public static Image requestColorSquare(Display display, int red, int green, int blue) {
- int key = (red << 16) | (green << 8) | blue;
- Image image = imageCache.get(key);
- if (image == null) {
- image = new Image(display, 8, 14);
- GC gc = new GC(image);
- Color color = requestColor(display, red, green, blue);
- gc.setBackground(color);
- gc.fillRectangle(image.getBounds());
- gc.dispose();
- imageCache.put(key, image);
- }
- return image;
- }
-
- public static void assignMethodColors(Display display, MethodData[] methods) {
- int nextColorIndex = 0;
- for (MethodData md : methods) {
- RGB rgb = rgbColors[nextColorIndex];
- if (++nextColorIndex == rgbColors.length)
- nextColorIndex = 0;
- Color color = requestColor(display, rgb);
- Image image = requestColorSquare(display, rgb);
- md.setColor(color);
- md.setImage(image);
-
- // Compute and set a faded color
- int fadedRed = 150 + rgb.red / 4;
- int fadedGreen = 150 + rgb.green / 4;
- int fadedBlue = 150 + rgb.blue / 4;
- RGB faded = new RGB(fadedRed, fadedGreen, fadedBlue);
- color = requestColor(display, faded);
- image = requestColorSquare(display, faded);
- md.setFadedColor(color);
- md.setFadedImage(image);
- }
- }
-}
diff --git a/traceview/src/com/android/traceview/DmTraceReader.java b/traceview/src/com/android/traceview/DmTraceReader.java
deleted file mode 100644
index 9bd6882..0000000
--- a/traceview/src/com/android/traceview/DmTraceReader.java
+++ /dev/null
@@ -1,754 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.BufferUnderflowException;
-import java.nio.ByteOrder;
-import java.nio.MappedByteBuffer;
-import java.nio.channels.FileChannel;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class DmTraceReader extends TraceReader {
- private static final int TRACE_MAGIC = 0x574f4c53;
-
- private static final int METHOD_TRACE_ENTER = 0x00; // method entry
- private static final int METHOD_TRACE_EXIT = 0x01; // method exit
- private static final int METHOD_TRACE_UNROLL = 0x02; // method exited by exception unrolling
-
- // When in dual clock mode, we report that a context switch has occurred
- // when skew between the real time and thread cpu clocks is more than this
- // many microseconds.
- private static final long MIN_CONTEXT_SWITCH_TIME_USEC = 100;
-
- private enum ClockSource {
- THREAD_CPU, WALL, DUAL,
- };
-
- private int mVersionNumber;
- private boolean mRegression;
- private ProfileProvider mProfileProvider;
- private String mTraceFileName;
- private MethodData mTopLevel;
- private ArrayList<Call> mCallList;
- private HashMap<String, String> mPropertiesMap;
- private HashMap<Integer, MethodData> mMethodMap;
- private HashMap<Integer, ThreadData> mThreadMap;
- private ThreadData[] mSortedThreads;
- private MethodData[] mSortedMethods;
- private long mTotalCpuTime;
- private long mTotalRealTime;
- private MethodData mContextSwitch;
- private int mRecordSize;
- private ClockSource mClockSource;
-
- // A regex for matching the thread "id name" lines in the .key file
- private static final Pattern mIdNamePattern = Pattern.compile("(\\d+)\t(.*)"); //$NON-NLS-1$
-
- public DmTraceReader(String traceFileName, boolean regression) throws IOException {
- mTraceFileName = traceFileName;
- mRegression = regression;
- mPropertiesMap = new HashMap<String, String>();
- mMethodMap = new HashMap<Integer, MethodData>();
- mThreadMap = new HashMap<Integer, ThreadData>();
- mCallList = new ArrayList<Call>();
-
- // Create a single top-level MethodData object to hold the profile data
- // for time spent in the unknown caller.
- mTopLevel = new MethodData(0, "(toplevel)");
- mContextSwitch = new MethodData(-1, "(context switch)");
- mMethodMap.put(0, mTopLevel);
- mMethodMap.put(-1, mContextSwitch);
- generateTrees();
- }
-
- void generateTrees() throws IOException {
- long offset = parseKeys();
- parseData(offset);
- analyzeData();
- }
-
- @Override
- public ProfileProvider getProfileProvider() {
- if (mProfileProvider == null)
- mProfileProvider = new ProfileProvider(this);
- return mProfileProvider;
- }
-
- private MappedByteBuffer mapFile(String filename, long offset) throws IOException {
- MappedByteBuffer buffer = null;
- FileInputStream dataFile = new FileInputStream(filename);
- try {
- File file = new File(filename);
- FileChannel fc = dataFile.getChannel();
- buffer = fc.map(FileChannel.MapMode.READ_ONLY, offset, file.length() - offset);
- buffer.order(ByteOrder.LITTLE_ENDIAN);
-
- return buffer;
- } finally {
- dataFile.close(); // this *also* closes the associated channel, fc
- }
- }
-
- private void readDataFileHeader(MappedByteBuffer buffer) {
- int magic = buffer.getInt();
- if (magic != TRACE_MAGIC) {
- System.err.printf(
- "Error: magic number mismatch; got 0x%x, expected 0x%x\n",
- magic, TRACE_MAGIC);
- throw new RuntimeException();
- }
-
- // read version
- int version = buffer.getShort();
- if (version != mVersionNumber) {
- System.err.printf(
- "Error: version number mismatch; got %d in data header but %d in options\n",
- version, mVersionNumber);
- throw new RuntimeException();
- }
- if (version < 1 || version > 3) {
- System.err.printf(
- "Error: unsupported trace version number %d. "
- + "Please use a newer version of TraceView to read this file.", version);
- throw new RuntimeException();
- }
-
- // read offset
- int offsetToData = buffer.getShort() - 16;
-
- // read startWhen
- buffer.getLong();
-
- // read record size
- if (version == 1) {
- mRecordSize = 9;
- } else if (version == 2) {
- mRecordSize = 10;
- } else {
- mRecordSize = buffer.getShort();
- offsetToData -= 2;
- }
-
- // Skip over offsetToData bytes
- while (offsetToData-- > 0) {
- buffer.get();
- }
- }
-
- private void parseData(long offset) throws IOException {
- MappedByteBuffer buffer = mapFile(mTraceFileName, offset);
- readDataFileHeader(buffer);
-
- ArrayList<TraceAction> trace = null;
- if (mClockSource == ClockSource.THREAD_CPU) {
- trace = new ArrayList<TraceAction>();
- }
-
- final boolean haveThreadClock = mClockSource != ClockSource.WALL;
- final boolean haveGlobalClock = mClockSource != ClockSource.THREAD_CPU;
-
- // Parse all call records to obtain elapsed time information.
- ThreadData prevThreadData = null;
- for (;;) {
- int threadId;
- int methodId;
- long threadTime, globalTime;
- try {
- int recordSize = mRecordSize;
-
- if (mVersionNumber == 1) {
- threadId = buffer.get();
- recordSize -= 1;
- } else {
- threadId = buffer.getShort();
- recordSize -= 2;
- }
-
- methodId = buffer.getInt();
- recordSize -= 4;
-
- switch (mClockSource) {
- case WALL:
- threadTime = 0;
- globalTime = buffer.getInt();
- recordSize -= 4;
- break;
- case DUAL:
- threadTime = buffer.getInt();
- globalTime = buffer.getInt();
- recordSize -= 8;
- break;
- default:
- case THREAD_CPU:
- threadTime = buffer.getInt();
- globalTime = 0;
- recordSize -= 4;
- break;
- }
-
- while (recordSize-- > 0) {
- buffer.get();
- }
- } catch (BufferUnderflowException ex) {
- break;
- }
-
- int methodAction = methodId & 0x03;
- methodId = methodId & ~0x03;
- MethodData methodData = mMethodMap.get(methodId);
- if (methodData == null) {
- String name = String.format("(0x%1$x)", methodId); //$NON-NLS-1$
- methodData = new MethodData(methodId, name);
- mMethodMap.put(methodId, methodData);
- }
-
- ThreadData threadData = mThreadMap.get(threadId);
- if (threadData == null) {
- String name = String.format("[%1$d]", threadId); //$NON-NLS-1$
- threadData = new ThreadData(threadId, name, mTopLevel);
- mThreadMap.put(threadId, threadData);
- }
-
- long elapsedGlobalTime = 0;
- if (haveGlobalClock) {
- if (!threadData.mHaveGlobalTime) {
- threadData.mGlobalStartTime = globalTime;
- threadData.mHaveGlobalTime = true;
- } else {
- elapsedGlobalTime = globalTime - threadData.mGlobalEndTime;
- }
- threadData.mGlobalEndTime = globalTime;
- }
-
- if (haveThreadClock) {
- long elapsedThreadTime = 0;
- if (!threadData.mHaveThreadTime) {
- threadData.mThreadStartTime = threadTime;
- threadData.mThreadCurrentTime = threadTime;
- threadData.mHaveThreadTime = true;
- } else {
- elapsedThreadTime = threadTime - threadData.mThreadEndTime;
- }
- threadData.mThreadEndTime = threadTime;
-
- if (!haveGlobalClock) {
- // Detect context switches whenever execution appears to switch from one
- // thread to another. This assumption is only valid on uniprocessor
- // systems (which is why we now have a dual clock mode).
- // We represent context switches in the trace by pushing a call record
- // with MethodData mContextSwitch onto the stack of the previous
- // thread. We arbitrarily set the start and end time of the context
- // switch such that the context switch occurs in the middle of the thread
- // time and itself accounts for zero thread time.
- if (prevThreadData != null && prevThreadData != threadData) {
- // Begin context switch from previous thread.
- Call switchCall = prevThreadData.enter(mContextSwitch, trace);
- switchCall.mThreadStartTime = prevThreadData.mThreadEndTime;
- mCallList.add(switchCall);
-
- // Return from context switch to current thread.
- Call top = threadData.top();
- if (top.getMethodData() == mContextSwitch) {
- threadData.exit(mContextSwitch, trace);
- long beforeSwitch = elapsedThreadTime / 2;
- top.mThreadStartTime += beforeSwitch;
- top.mThreadEndTime = top.mThreadStartTime;
- }
- }
- prevThreadData = threadData;
- } else {
- // If we have a global clock, then we can detect context switches (or blocking
- // calls or cpu suspensions or clock anomalies) by comparing global time to
- // thread time for successive calls that occur on the same thread.
- // As above, we represent the context switch using a special method call.
- long sleepTime = elapsedGlobalTime - elapsedThreadTime;
- if (sleepTime > MIN_CONTEXT_SWITCH_TIME_USEC) {
- Call switchCall = threadData.enter(mContextSwitch, trace);
- long beforeSwitch = elapsedThreadTime / 2;
- long afterSwitch = elapsedThreadTime - beforeSwitch;
- switchCall.mGlobalStartTime = globalTime - elapsedGlobalTime + beforeSwitch;
- switchCall.mGlobalEndTime = globalTime - afterSwitch;
- switchCall.mThreadStartTime = threadTime - afterSwitch;
- switchCall.mThreadEndTime = switchCall.mThreadStartTime;
- threadData.exit(mContextSwitch, trace);
- mCallList.add(switchCall);
- }
- }
-
- // Add thread CPU time.
- Call top = threadData.top();
- top.addCpuTime(elapsedThreadTime);
- }
-
- switch (methodAction) {
- case METHOD_TRACE_ENTER: {
- Call call = threadData.enter(methodData, trace);
- if (haveGlobalClock) {
- call.mGlobalStartTime = globalTime;
- }
- if (haveThreadClock) {
- call.mThreadStartTime = threadTime;
- }
- mCallList.add(call);
- break;
- }
- case METHOD_TRACE_EXIT:
- case METHOD_TRACE_UNROLL: {
- Call call = threadData.exit(methodData, trace);
- if (call != null) {
- if (haveGlobalClock) {
- call.mGlobalEndTime = globalTime;
- }
- if (haveThreadClock) {
- call.mThreadEndTime = threadTime;
- }
- }
- break;
- }
- default:
- throw new RuntimeException("Unrecognized method action: " + methodAction);
- }
- }
-
- // Exit any pending open-ended calls.
- for (ThreadData threadData : mThreadMap.values()) {
- threadData.endTrace(trace);
- }
-
- // Recreate the global timeline from thread times, if needed.
- if (!haveGlobalClock) {
- long globalTime = 0;
- prevThreadData = null;
- for (TraceAction traceAction : trace) {
- Call call = traceAction.mCall;
- ThreadData threadData = call.getThreadData();
-
- if (traceAction.mAction == TraceAction.ACTION_ENTER) {
- long threadTime = call.mThreadStartTime;
- globalTime += call.mThreadStartTime - threadData.mThreadCurrentTime;
- call.mGlobalStartTime = globalTime;
- if (!threadData.mHaveGlobalTime) {
- threadData.mHaveGlobalTime = true;
- threadData.mGlobalStartTime = globalTime;
- }
- threadData.mThreadCurrentTime = threadTime;
- } else if (traceAction.mAction == TraceAction.ACTION_EXIT) {
- long threadTime = call.mThreadEndTime;
- globalTime += call.mThreadEndTime - threadData.mThreadCurrentTime;
- call.mGlobalEndTime = globalTime;
- threadData.mGlobalEndTime = globalTime;
- threadData.mThreadCurrentTime = threadTime;
- } // else, ignore ACTION_INCOMPLETE calls, nothing to do
- prevThreadData = threadData;
- }
- }
-
- // Finish updating all calls and calculate the total time spent.
- for (int i = mCallList.size() - 1; i >= 0; i--) {
- Call call = mCallList.get(i);
-
- // Calculate exclusive real-time by subtracting inclusive real time
- // accumulated by children from the total span.
- long realTime = call.mGlobalEndTime - call.mGlobalStartTime;
- call.mExclusiveRealTime = Math.max(realTime - call.mInclusiveRealTime, 0);
- call.mInclusiveRealTime = realTime;
-
- call.finish();
- }
- mTotalCpuTime = 0;
- mTotalRealTime = 0;
- for (ThreadData threadData : mThreadMap.values()) {
- Call rootCall = threadData.getRootCall();
- threadData.updateRootCallTimeBounds();
- rootCall.finish();
- mTotalCpuTime += rootCall.mInclusiveCpuTime;
- mTotalRealTime += rootCall.mInclusiveRealTime;
- }
-
- if (mRegression) {
- System.out.format("totalCpuTime %dus\n", mTotalCpuTime);
- System.out.format("totalRealTime %dus\n", mTotalRealTime);
-
- dumpThreadTimes();
- dumpCallTimes();
- }
- }
-
- static final int PARSE_VERSION = 0;
- static final int PARSE_THREADS = 1;
- static final int PARSE_METHODS = 2;
- static final int PARSE_OPTIONS = 4;
-
- long parseKeys() throws IOException {
- long offset = 0;
- BufferedReader in = null;
- try {
- in = new BufferedReader(new InputStreamReader(
- new FileInputStream(mTraceFileName), "US-ASCII"));
-
- int mode = PARSE_VERSION;
- String line = null;
- while (true) {
- line = in.readLine();
- if (line == null) {
- throw new IOException("Key section does not have an *end marker");
- }
-
- // Calculate how much we have read from the file so far. The
- // extra byte is for the line ending not included by readLine().
- offset += line.length() + 1;
- if (line.startsWith("*")) {
- if (line.equals("*version")) {
- mode = PARSE_VERSION;
- continue;
- }
- if (line.equals("*threads")) {
- mode = PARSE_THREADS;
- continue;
- }
- if (line.equals("*methods")) {
- mode = PARSE_METHODS;
- continue;
- }
- if (line.equals("*end")) {
- break;
- }
- }
- switch (mode) {
- case PARSE_VERSION:
- mVersionNumber = Integer.decode(line);
- mode = PARSE_OPTIONS;
- break;
- case PARSE_THREADS:
- parseThread(line);
- break;
- case PARSE_METHODS:
- parseMethod(line);
- break;
- case PARSE_OPTIONS:
- parseOption(line);
- break;
- }
- }
- } catch (FileNotFoundException ex) {
- System.err.println(ex.getMessage());
- } finally {
- if (in != null) {
- in.close();
- }
- }
-
- if (mClockSource == null) {
- mClockSource = ClockSource.THREAD_CPU;
- }
-
- return offset;
- }
-
- void parseOption(String line) {
- String[] tokens = line.split("=");
- if (tokens.length == 2) {
- String key = tokens[0];
- String value = tokens[1];
- mPropertiesMap.put(key, value);
-
- if (key.equals("clock")) {
- if (value.equals("thread-cpu")) {
- mClockSource = ClockSource.THREAD_CPU;
- } else if (value.equals("wall")) {
- mClockSource = ClockSource.WALL;
- } else if (value.equals("dual")) {
- mClockSource = ClockSource.DUAL;
- }
- }
- }
- }
-
- void parseThread(String line) {
- String idStr = null;
- String name = null;
- Matcher matcher = mIdNamePattern.matcher(line);
- if (matcher.find()) {
- idStr = matcher.group(1);
- name = matcher.group(2);
- }
- if (idStr == null) return;
- if (name == null) name = "(unknown)";
-
- int id = Integer.decode(idStr);
- mThreadMap.put(id, new ThreadData(id, name, mTopLevel));
- }
-
- void parseMethod(String line) {
- String[] tokens = line.split("\t");
- int id = Long.decode(tokens[0]).intValue();
- String className = tokens[1];
- String methodName = null;
- String signature = null;
- String pathname = null;
- int lineNumber = -1;
- if (tokens.length == 6) {
- methodName = tokens[2];
- signature = tokens[3];
- pathname = tokens[4];
- lineNumber = Integer.decode(tokens[5]);
- pathname = constructPathname(className, pathname);
- } else if (tokens.length > 2) {
- if (tokens[3].startsWith("(")) {
- methodName = tokens[2];
- signature = tokens[3];
- } else {
- pathname = tokens[2];
- lineNumber = Integer.decode(tokens[3]);
- }
- }
-
- mMethodMap.put(id, new MethodData(id, className, methodName, signature,
- pathname, lineNumber));
- }
-
- private String constructPathname(String className, String pathname) {
- int index = className.lastIndexOf('/');
- if (index > 0 && index < className.length() - 1
- && pathname.endsWith(".java"))
- pathname = className.substring(0, index + 1) + pathname;
- return pathname;
- }
-
- private void analyzeData() {
- final TimeBase timeBase = getPreferredTimeBase();
-
- // Sort the threads into decreasing cpu time
- Collection<ThreadData> tv = mThreadMap.values();
- mSortedThreads = tv.toArray(new ThreadData[tv.size()]);
- Arrays.sort(mSortedThreads, new Comparator<ThreadData>() {
- @Override
- public int compare(ThreadData td1, ThreadData td2) {
- if (timeBase.getTime(td2) > timeBase.getTime(td1))
- return 1;
- if (timeBase.getTime(td2) < timeBase.getTime(td1))
- return -1;
- return td2.getName().compareTo(td1.getName());
- }
- });
-
- // Sort the methods into decreasing inclusive time
- Collection<MethodData> mv = mMethodMap.values();
- MethodData[] methods;
- methods = mv.toArray(new MethodData[mv.size()]);
- Arrays.sort(methods, new Comparator<MethodData>() {
- @Override
- public int compare(MethodData md1, MethodData md2) {
- if (timeBase.getElapsedInclusiveTime(md2) > timeBase.getElapsedInclusiveTime(md1))
- return 1;
- if (timeBase.getElapsedInclusiveTime(md2) < timeBase.getElapsedInclusiveTime(md1))
- return -1;
- return md1.getName().compareTo(md2.getName());
- }
- });
-
- // Count the number of methods with non-zero inclusive time
- int nonZero = 0;
- for (MethodData md : methods) {
- if (timeBase.getElapsedInclusiveTime(md) == 0)
- break;
- nonZero += 1;
- }
-
- // Copy the methods with non-zero time
- mSortedMethods = new MethodData[nonZero];
- int ii = 0;
- for (MethodData md : methods) {
- if (timeBase.getElapsedInclusiveTime(md) == 0)
- break;
- md.setRank(ii);
- mSortedMethods[ii++] = md;
- }
-
- // Let each method analyze its profile data
- for (MethodData md : mSortedMethods) {
- md.analyzeData(timeBase);
- }
-
- // Update all the calls to include the method rank in
- // their name.
- for (Call call : mCallList) {
- call.updateName();
- }
-
- if (mRegression) {
- dumpMethodStats();
- }
- }
-
- /*
- * This method computes a list of records that describe the the execution
- * timeline for each thread. Each record is a pair: (row, block) where: row:
- * is the ThreadData object block: is the call (containing the start and end
- * times)
- */
- @Override
- public ArrayList<TimeLineView.Record> getThreadTimeRecords() {
- TimeLineView.Record record;
- ArrayList<TimeLineView.Record> timeRecs;
- timeRecs = new ArrayList<TimeLineView.Record>();
-
- // For each thread, push a "toplevel" call that encompasses the
- // entire execution of the thread.
- for (ThreadData threadData : mSortedThreads) {
- if (!threadData.isEmpty() && threadData.getId() != 0) {
- record = new TimeLineView.Record(threadData, threadData.getRootCall());
- timeRecs.add(record);
- }
- }
-
- for (Call call : mCallList) {
- record = new TimeLineView.Record(call.getThreadData(), call);
- timeRecs.add(record);
- }
-
- if (mRegression) {
- dumpTimeRecs(timeRecs);
- System.exit(0);
- }
- return timeRecs;
- }
-
- private void dumpThreadTimes() {
- System.out.print("\nThread Times\n");
- System.out.print("id t-start t-end g-start g-end name\n");
- for (ThreadData threadData : mThreadMap.values()) {
- System.out.format("%2d %8d %8d %8d %8d %s\n",
- threadData.getId(),
- threadData.mThreadStartTime, threadData.mThreadEndTime,
- threadData.mGlobalStartTime, threadData.mGlobalEndTime,
- threadData.getName());
- }
- }
-
- private void dumpCallTimes() {
- System.out.print("\nCall Times\n");
- System.out.print("id t-start t-end g-start g-end excl. incl. method\n");
- for (Call call : mCallList) {
- System.out.format("%2d %8d %8d %8d %8d %8d %8d %s\n",
- call.getThreadId(), call.mThreadStartTime, call.mThreadEndTime,
- call.mGlobalStartTime, call.mGlobalEndTime,
- call.mExclusiveCpuTime, call.mInclusiveCpuTime,
- call.getMethodData().getName());
- }
- }
-
- private void dumpMethodStats() {
- System.out.print("\nMethod Stats\n");
- System.out.print("Excl Cpu Incl Cpu Excl Real Incl Real Calls Method\n");
- for (MethodData md : mSortedMethods) {
- System.out.format("%9d %9d %9d %9d %9s %s\n",
- md.getElapsedExclusiveCpuTime(), md.getElapsedInclusiveCpuTime(),
- md.getElapsedExclusiveRealTime(), md.getElapsedInclusiveRealTime(),
- md.getCalls(), md.getProfileName());
- }
- }
-
- private void dumpTimeRecs(ArrayList<TimeLineView.Record> timeRecs) {
- System.out.print("\nTime Records\n");
- System.out.print("id t-start t-end g-start g-end method\n");
- for (TimeLineView.Record record : timeRecs) {
- Call call = (Call) record.block;
- System.out.format("%2d %8d %8d %8d %8d %s\n",
- call.getThreadId(), call.mThreadStartTime, call.mThreadEndTime,
- call.mGlobalStartTime, call.mGlobalEndTime,
- call.getMethodData().getName());
- }
- }
-
- @Override
- public HashMap<Integer, String> getThreadLabels() {
- HashMap<Integer, String> labels = new HashMap<Integer, String>();
- for (ThreadData t : mThreadMap.values()) {
- labels.put(t.getId(), t.getName());
- }
- return labels;
- }
-
- @Override
- public MethodData[] getMethods() {
- return mSortedMethods;
- }
-
- @Override
- public ThreadData[] getThreads() {
- return mSortedThreads;
- }
-
- @Override
- public long getTotalCpuTime() {
- return mTotalCpuTime;
- }
-
- @Override
- public long getTotalRealTime() {
- return mTotalRealTime;
- }
-
- @Override
- public boolean haveCpuTime() {
- return mClockSource != ClockSource.WALL;
- }
-
- @Override
- public boolean haveRealTime() {
- return mClockSource != ClockSource.THREAD_CPU;
- }
-
- @Override
- public HashMap<String, String> getProperties() {
- return mPropertiesMap;
- }
-
- @Override
- public TimeBase getPreferredTimeBase() {
- if (mClockSource == ClockSource.WALL) {
- return TimeBase.REAL_TIME;
- }
- return TimeBase.CPU_TIME;
- }
-
- @Override
- public String getClockSource() {
- switch (mClockSource) {
- case THREAD_CPU:
- return "cpu time";
- case WALL:
- return "real time";
- case DUAL:
- return "real time, dual clock";
- }
- return null;
- }
-}
diff --git a/traceview/src/com/android/traceview/MainWindow.java b/traceview/src/com/android/traceview/MainWindow.java
deleted file mode 100644
index ebab72b..0000000
--- a/traceview/src/com/android/traceview/MainWindow.java
+++ /dev/null
@@ -1,300 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-import com.android.sdkstats.SdkStatsService;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.channels.FileChannel;
-import java.util.HashMap;
-import java.util.Properties;
-
-public class MainWindow extends ApplicationWindow {
-
- private final static String PING_NAME = "Traceview";
-
- private TraceReader mReader;
- private String mTraceName;
-
- // A global cache of string names.
- public static HashMap<String, String> sStringCache = new HashMap<String, String>();
-
- public MainWindow(String traceName, TraceReader reader) {
- super(null);
- mReader = reader;
- mTraceName = traceName;
-
- addMenuBar();
- }
-
- public void run() {
- setBlockOnOpen(true);
- open();
- }
-
- @Override
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
- shell.setText("Traceview: " + mTraceName);
-
- InputStream in = getClass().getClassLoader().getResourceAsStream(
- "icons/traceview-128.png");
- if (in != null) {
- shell.setImage(new Image(shell.getDisplay(), in));
- }
-
- shell.setBounds(100, 10, 1282, 900);
- }
-
- @Override
- protected Control createContents(Composite parent) {
- ColorController.assignMethodColors(parent.getDisplay(), mReader.getMethods());
- SelectionController selectionController = new SelectionController();
-
- GridLayout gridLayout = new GridLayout(1, false);
- gridLayout.marginWidth = 0;
- gridLayout.marginHeight = 0;
- gridLayout.horizontalSpacing = 0;
- gridLayout.verticalSpacing = 0;
- parent.setLayout(gridLayout);
-
- Display display = parent.getDisplay();
- Color darkGray = display.getSystemColor(SWT.COLOR_DARK_GRAY);
-
- // Create a sash form to separate the timeline view (on top)
- // and the profile view (on bottom)
- SashForm sashForm1 = new SashForm(parent, SWT.VERTICAL);
- sashForm1.setBackground(darkGray);
- sashForm1.SASH_WIDTH = 3;
- GridData data = new GridData(GridData.FILL_BOTH);
- sashForm1.setLayoutData(data);
-
- // Create the timeline view
- new TimeLineView(sashForm1, mReader, selectionController);
-
- // Create the profile view
- new ProfileView(sashForm1, mReader, selectionController);
- return sashForm1;
- }
-
- @Override
- protected MenuManager createMenuManager() {
- MenuManager manager = super.createMenuManager();
-
- MenuManager viewMenu = new MenuManager("View");
- manager.add(viewMenu);
-
- Action showPropertiesAction = new Action("Show Properties...") {
- @Override
- public void run() {
- showProperties();
- }
- };
- viewMenu.add(showPropertiesAction);
-
- return manager;
- }
-
- private void showProperties() {
- PropertiesDialog dialog = new PropertiesDialog(getShell());
- dialog.setProperties(mReader.getProperties());
- dialog.open();
- }
-
- /**
- * Convert the old two-file format into the current concatenated one.
- *
- * @param base Base path of the two files, i.e. base.key and base.data
- * @return Path to a temporary file that will be deleted on exit.
- * @throws IOException
- */
- private static String makeTempTraceFile(String base) throws IOException {
- // Make a temporary file that will go away on exit and prepare to
- // write into it.
- File temp = File.createTempFile(base, ".trace");
- temp.deleteOnExit();
-
- FileOutputStream dstStream = null;
- FileInputStream keyStream = null;
- FileInputStream dataStream = null;
-
- try {
- dstStream = new FileOutputStream(temp);
- FileChannel dstChannel = dstStream.getChannel();
-
- // First copy the contents of the key file into our temp file.
- keyStream = new FileInputStream(base + ".key");
- FileChannel srcChannel = keyStream.getChannel();
- long size = dstChannel.transferFrom(srcChannel, 0, srcChannel.size());
- srcChannel.close();
-
- // Then concatenate the data file.
- dataStream = new FileInputStream(base + ".data");
- srcChannel = dataStream.getChannel();
- dstChannel.transferFrom(srcChannel, size, srcChannel.size());
- } finally {
- if (dstStream != null) {
- dstStream.close(); // also closes dstChannel
- }
- if (keyStream != null) {
- keyStream.close(); // also closes srcChannel
- }
- if (dataStream != null) {
- dataStream.close();
- }
- }
-
- // Return the path of the temp file.
- return temp.getPath();
- }
-
- /**
- * Returns the tools revision number.
- */
- private static String getRevision() {
- Properties p = new Properties();
- try{
- String toolsdir = System.getProperty("com.android.traceview.toolsdir"); //$NON-NLS-1$
- File sourceProp;
- if (toolsdir == null || toolsdir.length() == 0) {
- sourceProp = new File("source.properties"); //$NON-NLS-1$
- } else {
- sourceProp = new File(toolsdir, "source.properties"); //$NON-NLS-1$
- }
-
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(sourceProp);
- p.load(fis);
- } finally {
- if (fis != null) {
- try {
- fis.close();
- } catch (IOException ignore) {
- }
- }
- }
-
- String revision = p.getProperty("Pkg.Revision"); //$NON-NLS-1$
- if (revision != null && revision.length() > 0) {
- return revision;
- }
- } catch (FileNotFoundException e) {
- // couldn't find the file? don't ping.
- } catch (IOException e) {
- // couldn't find the file? don't ping.
- }
-
- return null;
- }
-
-
- public static void main(String[] args) {
- TraceReader reader = null;
- boolean regression = false;
-
- // ping the usage server
-
- String revision = getRevision();
- if (revision != null) {
- new SdkStatsService().ping(PING_NAME, revision);
- }
-
- // Process command line arguments
- int argc = 0;
- int len = args.length;
- while (argc < len) {
- String arg = args[argc];
- if (arg.charAt(0) != '-') {
- break;
- }
- if (arg.equals("-r")) {
- regression = true;
- } else {
- break;
- }
- argc++;
- }
- if (argc != len - 1) {
- System.out.printf("Usage: java %s [-r] trace%n", MainWindow.class.getName());
- System.out.printf(" -r regression only%n");
- return;
- }
-
- String traceName = args[len - 1];
- File file = new File(traceName);
- if (file.exists() && file.isDirectory()) {
- System.out.printf("Qemu trace files not supported yet.\n");
- System.exit(1);
- // reader = new QtraceReader(traceName);
- } else {
- // If the filename as given doesn't exist...
- if (!file.exists()) {
- // Try appending .trace.
- if (new File(traceName + ".trace").exists()) {
- traceName = traceName + ".trace";
- // Next, see if it is the old two-file trace.
- } else if (new File(traceName + ".data").exists()
- && new File(traceName + ".key").exists()) {
- try {
- traceName = makeTempTraceFile(traceName);
- } catch (IOException e) {
- System.err.printf("cannot convert old trace file '%s'\n", traceName);
- System.exit(1);
- }
- // Otherwise, give up.
- } else {
- System.err.printf("trace file '%s' not found\n", traceName);
- System.exit(1);
- }
- }
-
- try {
- reader = new DmTraceReader(traceName, regression);
- } catch (IOException e) {
- System.err.printf("Failed to read the trace file");
- e.printStackTrace();
- System.exit(1);
- return;
- }
- }
-
- reader.getTraceUnits().setTimeScale(TraceUnits.TimeScale.MilliSeconds);
-
- Display.setAppName("Traceview");
- new MainWindow(traceName, reader).run();
- }
-}
diff --git a/traceview/src/com/android/traceview/MethodData.java b/traceview/src/com/android/traceview/MethodData.java
deleted file mode 100644
index 69c5247..0000000
--- a/traceview/src/com/android/traceview/MethodData.java
+++ /dev/null
@@ -1,513 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.HashMap;
-
-public class MethodData {
-
- private int mId;
- private int mRank = -1;
- private String mClassName;
- private String mMethodName;
- private String mSignature;
- private String mName;
- private String mProfileName;
- private String mPathname;
- private int mLineNumber;
- private long mElapsedExclusiveCpuTime;
- private long mElapsedInclusiveCpuTime;
- private long mTopExclusiveCpuTime;
- private long mElapsedExclusiveRealTime;
- private long mElapsedInclusiveRealTime;
- private long mTopExclusiveRealTime;
- private int[] mNumCalls = new int[2]; // index 0=normal, 1=recursive
- private Color mColor;
- private Color mFadedColor;
- private Image mImage;
- private Image mFadedImage;
- private HashMap<Integer, ProfileData> mParents;
- private HashMap<Integer, ProfileData> mChildren;
-
- // The parents of this method when this method was in a recursive call
- private HashMap<Integer, ProfileData> mRecursiveParents;
-
- // The children of this method when this method was in a recursive call
- private HashMap<Integer, ProfileData> mRecursiveChildren;
-
- private ProfileNode[] mProfileNodes;
- private int mX;
- private int mY;
- private double mWeight;
-
- public MethodData(int id, String className) {
- mId = id;
- mClassName = className;
- mMethodName = null;
- mSignature = null;
- mPathname = null;
- mLineNumber = -1;
- computeName();
- computeProfileName();
- }
-
- public MethodData(int id, String className, String methodName,
- String signature, String pathname, int lineNumber) {
- mId = id;
- mClassName = className;
- mMethodName = methodName;
- mSignature = signature;
- mPathname = pathname;
- mLineNumber = lineNumber;
- computeName();
- computeProfileName();
- }
-
- public double addWeight(int x, int y, double weight) {
- if (mX == x && mY == y)
- mWeight += weight;
- else {
- mX = x;
- mY = y;
- mWeight = weight;
- }
- return mWeight;
- }
-
- public void clearWeight() {
- mWeight = 0;
- }
-
- public int getRank() {
- return mRank;
- }
-
- public void setRank(int rank) {
- mRank = rank;
- computeProfileName();
- }
-
- public void addElapsedExclusive(long cpuTime, long realTime) {
- mElapsedExclusiveCpuTime += cpuTime;
- mElapsedExclusiveRealTime += realTime;
- }
-
- public void addElapsedInclusive(long cpuTime, long realTime,
- boolean isRecursive, Call parent) {
- if (isRecursive == false) {
- mElapsedInclusiveCpuTime += cpuTime;
- mElapsedInclusiveRealTime += realTime;
- mNumCalls[0] += 1;
- } else {
- mNumCalls[1] += 1;
- }
-
- if (parent == null)
- return;
-
- // Find the child method in the parent
- MethodData parentMethod = parent.getMethodData();
- if (parent.isRecursive()) {
- parentMethod.mRecursiveChildren = updateInclusive(cpuTime, realTime,
- parentMethod, this, false,
- parentMethod.mRecursiveChildren);
- } else {
- parentMethod.mChildren = updateInclusive(cpuTime, realTime,
- parentMethod, this, false, parentMethod.mChildren);
- }
-
- // Find the parent method in the child
- if (isRecursive) {
- mRecursiveParents = updateInclusive(cpuTime, realTime, this, parentMethod, true,
- mRecursiveParents);
- } else {
- mParents = updateInclusive(cpuTime, realTime, this, parentMethod, true,
- mParents);
- }
- }
-
- private HashMap<Integer, ProfileData> updateInclusive(long cpuTime, long realTime,
- MethodData contextMethod, MethodData elementMethod,
- boolean elementIsParent, HashMap<Integer, ProfileData> map) {
- if (map == null) {
- map = new HashMap<Integer, ProfileData>(4);
- } else {
- ProfileData profileData = map.get(elementMethod.mId);
- if (profileData != null) {
- profileData.addElapsedInclusive(cpuTime, realTime);
- return map;
- }
- }
-
- ProfileData elementData = new ProfileData(contextMethod,
- elementMethod, elementIsParent);
- elementData.setElapsedInclusive(cpuTime, realTime);
- elementData.setNumCalls(1);
- map.put(elementMethod.mId, elementData);
- return map;
- }
-
- public void analyzeData(TimeBase timeBase) {
- // Sort the parents and children into decreasing inclusive time
- ProfileData[] sortedParents;
- ProfileData[] sortedChildren;
- ProfileData[] sortedRecursiveParents;
- ProfileData[] sortedRecursiveChildren;
-
- sortedParents = sortProfileData(mParents, timeBase);
- sortedChildren = sortProfileData(mChildren, timeBase);
- sortedRecursiveParents = sortProfileData(mRecursiveParents, timeBase);
- sortedRecursiveChildren = sortProfileData(mRecursiveChildren, timeBase);
-
- // Add "self" time to the top of the sorted children
- sortedChildren = addSelf(sortedChildren);
-
- // Create the ProfileNode objects that we need
- ArrayList<ProfileNode> nodes = new ArrayList<ProfileNode>();
- ProfileNode profileNode;
- if (mParents != null) {
- profileNode = new ProfileNode("Parents", this, sortedParents,
- true, false);
- nodes.add(profileNode);
- }
- if (mChildren != null) {
- profileNode = new ProfileNode("Children", this, sortedChildren,
- false, false);
- nodes.add(profileNode);
- }
- if (mRecursiveParents!= null) {
- profileNode = new ProfileNode("Parents while recursive", this,
- sortedRecursiveParents, true, true);
- nodes.add(profileNode);
- }
- if (mRecursiveChildren != null) {
- profileNode = new ProfileNode("Children while recursive", this,
- sortedRecursiveChildren, false, true);
- nodes.add(profileNode);
- }
- mProfileNodes = nodes.toArray(new ProfileNode[nodes.size()]);
- }
-
- // Create and return a ProfileData[] array that is a sorted copy
- // of the given HashMap values.
- private ProfileData[] sortProfileData(HashMap<Integer, ProfileData> map,
- final TimeBase timeBase) {
- if (map == null)
- return null;
-
- // Convert the hash values to an array of ProfileData
- Collection<ProfileData> values = map.values();
- ProfileData[] sorted = values.toArray(new ProfileData[values.size()]);
-
- // Sort the array by elapsed inclusive time
- Arrays.sort(sorted, new Comparator<ProfileData>() {
- @Override
- public int compare(ProfileData pd1, ProfileData pd2) {
- if (timeBase.getElapsedInclusiveTime(pd2) > timeBase.getElapsedInclusiveTime(pd1))
- return 1;
- if (timeBase.getElapsedInclusiveTime(pd2) < timeBase.getElapsedInclusiveTime(pd1))
- return -1;
- return 0;
- }
- });
- return sorted;
- }
-
- private ProfileData[] addSelf(ProfileData[] children) {
- ProfileData[] pdata;
- if (children == null) {
- pdata = new ProfileData[1];
- } else {
- pdata = new ProfileData[children.length + 1];
- System.arraycopy(children, 0, pdata, 1, children.length);
- }
- pdata[0] = new ProfileSelf(this);
- return pdata;
- }
-
- public void addTopExclusive(long cpuTime, long realTime) {
- mTopExclusiveCpuTime += cpuTime;
- mTopExclusiveRealTime += realTime;
- }
-
- public long getTopExclusiveCpuTime() {
- return mTopExclusiveCpuTime;
- }
-
- public long getTopExclusiveRealTime() {
- return mTopExclusiveRealTime;
- }
-
- public int getId() {
- return mId;
- }
-
- private void computeName() {
- if (mMethodName == null) {
- mName = mClassName;
- return;
- }
-
- StringBuilder sb = new StringBuilder();
- sb.append(mClassName);
- sb.append("."); //$NON-NLS-1$
- sb.append(mMethodName);
- sb.append(" "); //$NON-NLS-1$
- sb.append(mSignature);
- mName = sb.toString();
- }
-
- public String getName() {
- return mName;
- }
-
- public String getClassName() {
- return mClassName;
- }
-
- public String getMethodName() {
- return mMethodName;
- }
-
- public String getProfileName() {
- return mProfileName;
- }
-
- public String getSignature() {
- return mSignature;
- }
-
- public void computeProfileName() {
- if (mRank == -1) {
- mProfileName = mName;
- return;
- }
-
- StringBuilder sb = new StringBuilder();
- sb.append(mRank);
- sb.append(" "); //$NON-NLS-1$
- sb.append(getName());
- mProfileName = sb.toString();
- }
-
- public String getCalls() {
- return String.format("%d+%d", mNumCalls[0], mNumCalls[1]);
- }
-
- public int getTotalCalls() {
- return mNumCalls[0] + mNumCalls[1];
- }
-
- public Color getColor() {
- return mColor;
- }
-
- public void setColor(Color color) {
- mColor = color;
- }
-
- public void setImage(Image image) {
- mImage = image;
- }
-
- public Image getImage() {
- return mImage;
- }
-
- @Override
- public String toString() {
- return getName();
- }
-
- public long getElapsedExclusiveCpuTime() {
- return mElapsedExclusiveCpuTime;
- }
-
- public long getElapsedExclusiveRealTime() {
- return mElapsedExclusiveRealTime;
- }
-
- public long getElapsedInclusiveCpuTime() {
- return mElapsedInclusiveCpuTime;
- }
-
- public long getElapsedInclusiveRealTime() {
- return mElapsedInclusiveRealTime;
- }
-
- public void setFadedColor(Color fadedColor) {
- mFadedColor = fadedColor;
- }
-
- public Color getFadedColor() {
- return mFadedColor;
- }
-
- public void setFadedImage(Image fadedImage) {
- mFadedImage = fadedImage;
- }
-
- public Image getFadedImage() {
- return mFadedImage;
- }
-
- public void setPathname(String pathname) {
- mPathname = pathname;
- }
-
- public String getPathname() {
- return mPathname;
- }
-
- public void setLineNumber(int lineNumber) {
- mLineNumber = lineNumber;
- }
-
- public int getLineNumber() {
- return mLineNumber;
- }
-
- public ProfileNode[] getProfileNodes() {
- return mProfileNodes;
- }
-
- public static class Sorter implements Comparator<MethodData> {
- @Override
- public int compare(MethodData md1, MethodData md2) {
- if (mColumn == Column.BY_NAME) {
- int result = md1.getName().compareTo(md2.getName());
- return (mDirection == Direction.INCREASING) ? result : -result;
- }
- if (mColumn == Column.BY_INCLUSIVE_CPU_TIME) {
- if (md2.getElapsedInclusiveCpuTime() > md1.getElapsedInclusiveCpuTime())
- return (mDirection == Direction.INCREASING) ? -1 : 1;
- if (md2.getElapsedInclusiveCpuTime() < md1.getElapsedInclusiveCpuTime())
- return (mDirection == Direction.INCREASING) ? 1 : -1;
- return md1.getName().compareTo(md2.getName());
- }
- if (mColumn == Column.BY_EXCLUSIVE_CPU_TIME) {
- if (md2.getElapsedExclusiveCpuTime() > md1.getElapsedExclusiveCpuTime())
- return (mDirection == Direction.INCREASING) ? -1 : 1;
- if (md2.getElapsedExclusiveCpuTime() < md1.getElapsedExclusiveCpuTime())
- return (mDirection == Direction.INCREASING) ? 1 : -1;
- return md1.getName().compareTo(md2.getName());
- }
- if (mColumn == Column.BY_INCLUSIVE_REAL_TIME) {
- if (md2.getElapsedInclusiveRealTime() > md1.getElapsedInclusiveRealTime())
- return (mDirection == Direction.INCREASING) ? -1 : 1;
- if (md2.getElapsedInclusiveRealTime() < md1.getElapsedInclusiveRealTime())
- return (mDirection == Direction.INCREASING) ? 1 : -1;
- return md1.getName().compareTo(md2.getName());
- }
- if (mColumn == Column.BY_EXCLUSIVE_REAL_TIME) {
- if (md2.getElapsedExclusiveRealTime() > md1.getElapsedExclusiveRealTime())
- return (mDirection == Direction.INCREASING) ? -1 : 1;
- if (md2.getElapsedExclusiveRealTime() < md1.getElapsedExclusiveRealTime())
- return (mDirection == Direction.INCREASING) ? 1 : -1;
- return md1.getName().compareTo(md2.getName());
- }
- if (mColumn == Column.BY_CALLS) {
- int result = md1.getTotalCalls() - md2.getTotalCalls();
- if (result == 0)
- return md1.getName().compareTo(md2.getName());
- return (mDirection == Direction.INCREASING) ? result : -result;
- }
- if (mColumn == Column.BY_CPU_TIME_PER_CALL) {
- double time1 = md1.getElapsedInclusiveCpuTime();
- time1 = time1 / md1.getTotalCalls();
- double time2 = md2.getElapsedInclusiveCpuTime();
- time2 = time2 / md2.getTotalCalls();
- double diff = time1 - time2;
- int result = 0;
- if (diff < 0)
- result = -1;
- else if (diff > 0)
- result = 1;
- if (result == 0)
- return md1.getName().compareTo(md2.getName());
- return (mDirection == Direction.INCREASING) ? result : -result;
- }
- if (mColumn == Column.BY_REAL_TIME_PER_CALL) {
- double time1 = md1.getElapsedInclusiveRealTime();
- time1 = time1 / md1.getTotalCalls();
- double time2 = md2.getElapsedInclusiveRealTime();
- time2 = time2 / md2.getTotalCalls();
- double diff = time1 - time2;
- int result = 0;
- if (diff < 0)
- result = -1;
- else if (diff > 0)
- result = 1;
- if (result == 0)
- return md1.getName().compareTo(md2.getName());
- return (mDirection == Direction.INCREASING) ? result : -result;
- }
- return 0;
- }
-
- public void setColumn(Column column) {
- // If the sort column specified is the same as last time,
- // then reverse the sort order.
- if (mColumn == column) {
- // Reverse the sort order
- if (mDirection == Direction.INCREASING)
- mDirection = Direction.DECREASING;
- else
- mDirection = Direction.INCREASING;
- } else {
- // Sort names into increasing order, data into decreasing order.
- if (column == Column.BY_NAME)
- mDirection = Direction.INCREASING;
- else
- mDirection = Direction.DECREASING;
- }
- mColumn = column;
- }
-
- public Column getColumn() {
- return mColumn;
- }
-
- public void setDirection(Direction direction) {
- mDirection = direction;
- }
-
- public Direction getDirection() {
- return mDirection;
- }
-
- public static enum Column {
- BY_NAME, BY_EXCLUSIVE_CPU_TIME, BY_EXCLUSIVE_REAL_TIME,
- BY_INCLUSIVE_CPU_TIME, BY_INCLUSIVE_REAL_TIME, BY_CALLS,
- BY_REAL_TIME_PER_CALL, BY_CPU_TIME_PER_CALL,
- };
-
- public static enum Direction {
- INCREASING, DECREASING
- };
-
- private Column mColumn;
- private Direction mDirection;
- }
-}
diff --git a/traceview/src/com/android/traceview/ProfileData.java b/traceview/src/com/android/traceview/ProfileData.java
deleted file mode 100644
index e3c47fb..0000000
--- a/traceview/src/com/android/traceview/ProfileData.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-
-public class ProfileData {
-
- protected MethodData mElement;
-
- /** mContext is either the parent or child of mElement */
- protected MethodData mContext;
- protected boolean mElementIsParent;
- protected long mElapsedInclusiveCpuTime;
- protected long mElapsedInclusiveRealTime;
- protected int mNumCalls;
-
- public ProfileData() {
- }
-
- public ProfileData(MethodData context, MethodData element,
- boolean elementIsParent) {
- mContext = context;
- mElement = element;
- mElementIsParent = elementIsParent;
- }
-
- public String getProfileName() {
- return mElement.getProfileName();
- }
-
- public MethodData getMethodData() {
- return mElement;
- }
-
- public void addElapsedInclusive(long cpuTime, long realTime) {
- mElapsedInclusiveCpuTime += cpuTime;
- mElapsedInclusiveRealTime += realTime;
- mNumCalls += 1;
- }
-
- public void setElapsedInclusive(long cpuTime, long realTime) {
- mElapsedInclusiveCpuTime = cpuTime;
- mElapsedInclusiveRealTime = realTime;
- }
-
- public long getElapsedInclusiveCpuTime() {
- return mElapsedInclusiveCpuTime;
- }
-
- public long getElapsedInclusiveRealTime() {
- return mElapsedInclusiveRealTime;
- }
-
- public void setNumCalls(int numCalls) {
- mNumCalls = numCalls;
- }
-
- public String getNumCalls() {
- int totalCalls;
- if (mElementIsParent)
- totalCalls = mContext.getTotalCalls();
- else
- totalCalls = mElement.getTotalCalls();
- return String.format("%d/%d", mNumCalls, totalCalls);
- }
-
- public boolean isParent() {
- return mElementIsParent;
- }
-
- public MethodData getContext() {
- return mContext;
- }
-}
diff --git a/traceview/src/com/android/traceview/ProfileNode.java b/traceview/src/com/android/traceview/ProfileNode.java
deleted file mode 100644
index 7cb0b5d..0000000
--- a/traceview/src/com/android/traceview/ProfileNode.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-public class ProfileNode {
-
- private String mLabel;
- private MethodData mMethodData;
- private ProfileData[] mChildren;
- private boolean mIsParent;
- private boolean mIsRecursive;
-
- public ProfileNode(String label, MethodData methodData,
- ProfileData[] children, boolean isParent, boolean isRecursive) {
- mLabel = label;
- mMethodData = methodData;
- mChildren = children;
- mIsParent = isParent;
- mIsRecursive = isRecursive;
- }
-
- public String getLabel() {
- return mLabel;
- }
-
- public ProfileData[] getChildren() {
- return mChildren;
- }
-
- public boolean isParent() {
- return mIsParent;
- }
-
- public boolean isRecursive() {
- return mIsRecursive;
- }
-}
diff --git a/traceview/src/com/android/traceview/ProfileProvider.java b/traceview/src/com/android/traceview/ProfileProvider.java
deleted file mode 100644
index 995e606..0000000
--- a/traceview/src/com/android/traceview/ProfileProvider.java
+++ /dev/null
@@ -1,467 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-import com.android.utils.SdkUtils;
-
-import org.eclipse.jface.viewers.IColorProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.swt.widgets.TreeItem;
-
-import java.io.InputStream;
-import java.util.Arrays;
-
-class ProfileProvider implements ITreeContentProvider {
-
- private MethodData[] mRoots;
- private SelectionAdapter mListener;
- private TreeViewer mTreeViewer;
- private TraceReader mReader;
- private Image mSortUp;
- private Image mSortDown;
- private String mColumnNames[] = { "Name",
- "Incl Cpu Time %", "Incl Cpu Time", "Excl Cpu Time %", "Excl Cpu Time",
- "Incl Real Time %", "Incl Real Time", "Excl Real Time %", "Excl Real Time",
- "Calls+Recur\nCalls/Total", "Cpu Time/Call", "Real Time/Call" };
- private int mColumnWidths[] = { 370,
- 100, 100, 100, 100,
- 100, 100, 100, 100,
- 100, 100, 100 };
- private int mColumnAlignments[] = { SWT.LEFT,
- SWT.RIGHT, SWT.RIGHT, SWT.RIGHT, SWT.RIGHT,
- SWT.RIGHT, SWT.RIGHT, SWT.RIGHT, SWT.RIGHT,
- SWT.CENTER, SWT.RIGHT, SWT.RIGHT };
- private static final int COL_NAME = 0;
- private static final int COL_INCLUSIVE_CPU_TIME_PER = 1;
- private static final int COL_INCLUSIVE_CPU_TIME = 2;
- private static final int COL_EXCLUSIVE_CPU_TIME_PER = 3;
- private static final int COL_EXCLUSIVE_CPU_TIME = 4;
- private static final int COL_INCLUSIVE_REAL_TIME_PER = 5;
- private static final int COL_INCLUSIVE_REAL_TIME = 6;
- private static final int COL_EXCLUSIVE_REAL_TIME_PER = 7;
- private static final int COL_EXCLUSIVE_REAL_TIME = 8;
- private static final int COL_CALLS = 9;
- private static final int COL_CPU_TIME_PER_CALL = 10;
- private static final int COL_REAL_TIME_PER_CALL = 11;
- private long mTotalCpuTime;
- private long mTotalRealTime;
- private int mPrevMatchIndex = -1;
-
- public ProfileProvider(TraceReader reader) {
- mRoots = reader.getMethods();
- mReader = reader;
- mTotalCpuTime = reader.getTotalCpuTime();
- mTotalRealTime = reader.getTotalRealTime();
- Display display = Display.getCurrent();
- InputStream in = getClass().getClassLoader().getResourceAsStream(
- "icons/sort_up.png");
- mSortUp = new Image(display, in);
- in = getClass().getClassLoader().getResourceAsStream(
- "icons/sort_down.png");
- mSortDown = new Image(display, in);
- }
-
- private MethodData doMatchName(String name, int startIndex) {
- // Check if the given "name" has any uppercase letters
- boolean hasUpper = SdkUtils.hasUpperCaseCharacter(name);
- for (int ii = startIndex; ii < mRoots.length; ++ii) {
- MethodData md = mRoots[ii];
- String fullName = md.getName();
- // If there were no upper case letters in the given name,
- // then ignore case when matching.
- if (!hasUpper)
- fullName = fullName.toLowerCase();
- if (fullName.indexOf(name) != -1) {
- mPrevMatchIndex = ii;
- return md;
- }
- }
- mPrevMatchIndex = -1;
- return null;
- }
-
- public MethodData findMatchingName(String name) {
- return doMatchName(name, 0);
- }
-
- public MethodData findNextMatchingName(String name) {
- return doMatchName(name, mPrevMatchIndex + 1);
- }
-
- public MethodData findMatchingTreeItem(TreeItem item) {
- if (item == null)
- return null;
- String text = item.getText();
- if (Character.isDigit(text.charAt(0)) == false)
- return null;
- int spaceIndex = text.indexOf(' ');
- String numstr = text.substring(0, spaceIndex);
- int rank = Integer.valueOf(numstr);
- for (MethodData md : mRoots) {
- if (md.getRank() == rank)
- return md;
- }
- return null;
- }
-
- public void setTreeViewer(TreeViewer treeViewer) {
- mTreeViewer = treeViewer;
- }
-
- public String[] getColumnNames() {
- return mColumnNames;
- }
-
- public int[] getColumnWidths() {
- int[] widths = Arrays.copyOf(mColumnWidths, mColumnWidths.length);
- if (!mReader.haveCpuTime()) {
- widths[COL_EXCLUSIVE_CPU_TIME] = 0;
- widths[COL_EXCLUSIVE_CPU_TIME_PER] = 0;
- widths[COL_INCLUSIVE_CPU_TIME] = 0;
- widths[COL_INCLUSIVE_CPU_TIME_PER] = 0;
- widths[COL_CPU_TIME_PER_CALL] = 0;
- }
- if (!mReader.haveRealTime()) {
- widths[COL_EXCLUSIVE_REAL_TIME] = 0;
- widths[COL_EXCLUSIVE_REAL_TIME_PER] = 0;
- widths[COL_INCLUSIVE_REAL_TIME] = 0;
- widths[COL_INCLUSIVE_REAL_TIME_PER] = 0;
- widths[COL_REAL_TIME_PER_CALL] = 0;
- }
- return widths;
- }
-
- public int[] getColumnAlignments() {
- return mColumnAlignments;
- }
-
- @Override
- public Object[] getChildren(Object element) {
- if (element instanceof MethodData) {
- MethodData md = (MethodData) element;
- return md.getProfileNodes();
- }
- if (element instanceof ProfileNode) {
- ProfileNode pn = (ProfileNode) element;
- return pn.getChildren();
- }
- return new Object[0];
- }
-
- @Override
- public Object getParent(Object element) {
- return null;
- }
-
- @Override
- public boolean hasChildren(Object element) {
- if (element instanceof MethodData)
- return true;
- if (element instanceof ProfileNode)
- return true;
- return false;
- }
-
- @Override
- public Object[] getElements(Object element) {
- return mRoots;
- }
-
- @Override
- public void dispose() {
- }
-
- @Override
- public void inputChanged(Viewer arg0, Object arg1, Object arg2) {
- }
-
- public Object getRoot() {
- return "root";
- }
-
- public SelectionAdapter getColumnListener() {
- if (mListener == null)
- mListener = new ColumnListener();
- return mListener;
- }
-
- public LabelProvider getLabelProvider() {
- return new ProfileLabelProvider();
- }
-
- class ProfileLabelProvider extends LabelProvider implements
- ITableLabelProvider, IColorProvider {
- Color colorRed;
- Color colorParentsBack;
- Color colorChildrenBack;
- TraceUnits traceUnits;
-
- public ProfileLabelProvider() {
- Display display = Display.getCurrent();
- colorRed = display.getSystemColor(SWT.COLOR_RED);
- colorParentsBack = new Color(display, 230, 230, 255); // blue
- colorChildrenBack = new Color(display, 255, 255, 210); // yellow
- traceUnits = mReader.getTraceUnits();
- }
-
- @Override
- public String getColumnText(Object element, int col) {
- if (element instanceof MethodData) {
- MethodData md = (MethodData) element;
- if (col == COL_NAME)
- return md.getProfileName();
- if (col == COL_EXCLUSIVE_CPU_TIME) {
- double val = md.getElapsedExclusiveCpuTime();
- val = traceUnits.getScaledValue(val);
- return String.format("%.3f", val);
- }
- if (col == COL_EXCLUSIVE_CPU_TIME_PER) {
- double val = md.getElapsedExclusiveCpuTime();
- double per = val * 100.0 / mTotalCpuTime;
- return String.format("%.1f%%", per);
- }
- if (col == COL_INCLUSIVE_CPU_TIME) {
- double val = md.getElapsedInclusiveCpuTime();
- val = traceUnits.getScaledValue(val);
- return String.format("%.3f", val);
- }
- if (col == COL_INCLUSIVE_CPU_TIME_PER) {
- double val = md.getElapsedInclusiveCpuTime();
- double per = val * 100.0 / mTotalCpuTime;
- return String.format("%.1f%%", per);
- }
- if (col == COL_EXCLUSIVE_REAL_TIME) {
- double val = md.getElapsedExclusiveRealTime();
- val = traceUnits.getScaledValue(val);
- return String.format("%.3f", val);
- }
- if (col == COL_EXCLUSIVE_REAL_TIME_PER) {
- double val = md.getElapsedExclusiveRealTime();
- double per = val * 100.0 / mTotalRealTime;
- return String.format("%.1f%%", per);
- }
- if (col == COL_INCLUSIVE_REAL_TIME) {
- double val = md.getElapsedInclusiveRealTime();
- val = traceUnits.getScaledValue(val);
- return String.format("%.3f", val);
- }
- if (col == COL_INCLUSIVE_REAL_TIME_PER) {
- double val = md.getElapsedInclusiveRealTime();
- double per = val * 100.0 / mTotalRealTime;
- return String.format("%.1f%%", per);
- }
- if (col == COL_CALLS)
- return md.getCalls();
- if (col == COL_CPU_TIME_PER_CALL) {
- int numCalls = md.getTotalCalls();
- double val = md.getElapsedInclusiveCpuTime();
- val = val / numCalls;
- val = traceUnits.getScaledValue(val);
- return String.format("%.3f", val);
- }
- if (col == COL_REAL_TIME_PER_CALL) {
- int numCalls = md.getTotalCalls();
- double val = md.getElapsedInclusiveRealTime();
- val = val / numCalls;
- val = traceUnits.getScaledValue(val);
- return String.format("%.3f", val);
- }
- } else if (element instanceof ProfileSelf) {
- ProfileSelf ps = (ProfileSelf) element;
- if (col == COL_NAME)
- return ps.getProfileName();
- if (col == COL_INCLUSIVE_CPU_TIME) {
- double val = ps.getElapsedInclusiveCpuTime();
- val = traceUnits.getScaledValue(val);
- return String.format("%.3f", val);
- }
- if (col == COL_INCLUSIVE_CPU_TIME_PER) {
- double total;
- double val = ps.getElapsedInclusiveCpuTime();
- MethodData context = ps.getContext();
- total = context.getElapsedInclusiveCpuTime();
- double per = val * 100.0 / total;
- return String.format("%.1f%%", per);
- }
- if (col == COL_INCLUSIVE_REAL_TIME) {
- double val = ps.getElapsedInclusiveRealTime();
- val = traceUnits.getScaledValue(val);
- return String.format("%.3f", val);
- }
- if (col == COL_INCLUSIVE_REAL_TIME_PER) {
- double total;
- double val = ps.getElapsedInclusiveRealTime();
- MethodData context = ps.getContext();
- total = context.getElapsedInclusiveRealTime();
- double per = val * 100.0 / total;
- return String.format("%.1f%%", per);
- }
- return "";
- } else if (element instanceof ProfileData) {
- ProfileData pd = (ProfileData) element;
- if (col == COL_NAME)
- return pd.getProfileName();
- if (col == COL_INCLUSIVE_CPU_TIME) {
- double val = pd.getElapsedInclusiveCpuTime();
- val = traceUnits.getScaledValue(val);
- return String.format("%.3f", val);
- }
- if (col == COL_INCLUSIVE_CPU_TIME_PER) {
- double total;
- double val = pd.getElapsedInclusiveCpuTime();
- MethodData context = pd.getContext();
- total = context.getElapsedInclusiveCpuTime();
- double per = val * 100.0 / total;
- return String.format("%.1f%%", per);
- }
- if (col == COL_INCLUSIVE_REAL_TIME) {
- double val = pd.getElapsedInclusiveRealTime();
- val = traceUnits.getScaledValue(val);
- return String.format("%.3f", val);
- }
- if (col == COL_INCLUSIVE_REAL_TIME_PER) {
- double total;
- double val = pd.getElapsedInclusiveRealTime();
- MethodData context = pd.getContext();
- total = context.getElapsedInclusiveRealTime();
- double per = val * 100.0 / total;
- return String.format("%.1f%%", per);
- }
- if (col == COL_CALLS)
- return pd.getNumCalls();
- return "";
- } else if (element instanceof ProfileNode) {
- ProfileNode pn = (ProfileNode) element;
- if (col == COL_NAME)
- return pn.getLabel();
- return "";
- }
- return "col" + col;
- }
-
- @Override
- public Image getColumnImage(Object element, int col) {
- if (col != COL_NAME)
- return null;
- if (element instanceof MethodData) {
- MethodData md = (MethodData) element;
- return md.getImage();
- }
- if (element instanceof ProfileData) {
- ProfileData pd = (ProfileData) element;
- MethodData md = pd.getMethodData();
- return md.getImage();
- }
- return null;
- }
-
- @Override
- public Color getForeground(Object element) {
- return null;
- }
-
- @Override
- public Color getBackground(Object element) {
- if (element instanceof ProfileData) {
- ProfileData pd = (ProfileData) element;
- if (pd.isParent())
- return colorParentsBack;
- return colorChildrenBack;
- }
- if (element instanceof ProfileNode) {
- ProfileNode pn = (ProfileNode) element;
- if (pn.isParent())
- return colorParentsBack;
- return colorChildrenBack;
- }
- return null;
- }
- }
-
- class ColumnListener extends SelectionAdapter {
- MethodData.Sorter sorter = new MethodData.Sorter();
-
- @Override
- public void widgetSelected(SelectionEvent event) {
- TreeColumn column = (TreeColumn) event.widget;
- String name = column.getText();
- Tree tree = column.getParent();
- tree.setRedraw(false);
- TreeColumn[] columns = tree.getColumns();
- for (TreeColumn col : columns) {
- col.setImage(null);
- }
- if (name == mColumnNames[COL_NAME]) {
- // Sort names alphabetically
- sorter.setColumn(MethodData.Sorter.Column.BY_NAME);
- Arrays.sort(mRoots, sorter);
- } else if (name == mColumnNames[COL_EXCLUSIVE_CPU_TIME]) {
- sorter.setColumn(MethodData.Sorter.Column.BY_EXCLUSIVE_CPU_TIME);
- Arrays.sort(mRoots, sorter);
- } else if (name == mColumnNames[COL_EXCLUSIVE_CPU_TIME_PER]) {
- sorter.setColumn(MethodData.Sorter.Column.BY_EXCLUSIVE_CPU_TIME);
- Arrays.sort(mRoots, sorter);
- } else if (name == mColumnNames[COL_INCLUSIVE_CPU_TIME]) {
- sorter.setColumn(MethodData.Sorter.Column.BY_INCLUSIVE_CPU_TIME);
- Arrays.sort(mRoots, sorter);
- } else if (name == mColumnNames[COL_INCLUSIVE_CPU_TIME_PER]) {
- sorter.setColumn(MethodData.Sorter.Column.BY_INCLUSIVE_CPU_TIME);
- Arrays.sort(mRoots, sorter);
- } else if (name == mColumnNames[COL_EXCLUSIVE_REAL_TIME]) {
- sorter.setColumn(MethodData.Sorter.Column.BY_EXCLUSIVE_REAL_TIME);
- Arrays.sort(mRoots, sorter);
- } else if (name == mColumnNames[COL_EXCLUSIVE_REAL_TIME_PER]) {
- sorter.setColumn(MethodData.Sorter.Column.BY_EXCLUSIVE_REAL_TIME);
- Arrays.sort(mRoots, sorter);
- } else if (name == mColumnNames[COL_INCLUSIVE_REAL_TIME]) {
- sorter.setColumn(MethodData.Sorter.Column.BY_INCLUSIVE_REAL_TIME);
- Arrays.sort(mRoots, sorter);
- } else if (name == mColumnNames[COL_INCLUSIVE_REAL_TIME_PER]) {
- sorter.setColumn(MethodData.Sorter.Column.BY_INCLUSIVE_REAL_TIME);
- Arrays.sort(mRoots, sorter);
- } else if (name == mColumnNames[COL_CALLS]) {
- sorter.setColumn(MethodData.Sorter.Column.BY_CALLS);
- Arrays.sort(mRoots, sorter);
- } else if (name == mColumnNames[COL_CPU_TIME_PER_CALL]) {
- sorter.setColumn(MethodData.Sorter.Column.BY_CPU_TIME_PER_CALL);
- Arrays.sort(mRoots, sorter);
- } else if (name == mColumnNames[COL_REAL_TIME_PER_CALL]) {
- sorter.setColumn(MethodData.Sorter.Column.BY_REAL_TIME_PER_CALL);
- Arrays.sort(mRoots, sorter);
- }
- MethodData.Sorter.Direction direction = sorter.getDirection();
- if (direction == MethodData.Sorter.Direction.INCREASING)
- column.setImage(mSortDown);
- else
- column.setImage(mSortUp);
- tree.setRedraw(true);
- mTreeViewer.refresh();
- }
- }
-}
diff --git a/traceview/src/com/android/traceview/ProfileSelf.java b/traceview/src/com/android/traceview/ProfileSelf.java
deleted file mode 100644
index 45543b2..0000000
--- a/traceview/src/com/android/traceview/ProfileSelf.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-public class ProfileSelf extends ProfileData {
- public ProfileSelf(MethodData methodData) {
- mElement = methodData;
- mContext = methodData;
- }
-
- @Override
- public String getProfileName() {
- return "self";
- }
-
- @Override
- public long getElapsedInclusiveCpuTime() {
- return mElement.getTopExclusiveCpuTime();
- }
-
- @Override
- public long getElapsedInclusiveRealTime() {
- return mElement.getTopExclusiveRealTime();
- }
-}
diff --git a/traceview/src/com/android/traceview/ProfileView.java b/traceview/src/com/android/traceview/ProfileView.java
deleted file mode 100644
index 683a2c7..0000000
--- a/traceview/src/com/android/traceview/ProfileView.java
+++ /dev/null
@@ -1,332 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeViewerListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeExpansionEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyAdapter;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeColumn;
-import org.eclipse.swt.widgets.TreeItem;
-
-import java.util.ArrayList;
-import java.util.Observable;
-import java.util.Observer;
-
-public class ProfileView extends Composite implements Observer {
-
- private TreeViewer mTreeViewer;
- private Text mSearchBox;
- private SelectionController mSelectionController;
- private ProfileProvider mProfileProvider;
- private Color mColorNoMatch;
- private Color mColorMatch;
- private MethodData mCurrentHighlightedMethod;
- private MethodHandler mMethodHandler;
-
- public interface MethodHandler {
- void handleMethod(MethodData method);
- }
-
- public ProfileView(Composite parent, TraceReader reader,
- SelectionController selectController) {
- super(parent, SWT.NONE);
- setLayout(new GridLayout(1, false));
- this.mSelectionController = selectController;
- mSelectionController.addObserver(this);
-
- // Add a tree viewer at the top
- mTreeViewer = new TreeViewer(this, SWT.MULTI | SWT.NONE);
- mTreeViewer.setUseHashlookup(true);
- mProfileProvider = reader.getProfileProvider();
- mProfileProvider.setTreeViewer(mTreeViewer);
- SelectionAdapter listener = mProfileProvider.getColumnListener();
- final Tree tree = mTreeViewer.getTree();
- tree.setHeaderVisible(true);
- tree.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- // Get the column names from the ProfileProvider
- String[] columnNames = mProfileProvider.getColumnNames();
- int[] columnWidths = mProfileProvider.getColumnWidths();
- int[] columnAlignments = mProfileProvider.getColumnAlignments();
- for (int ii = 0; ii < columnWidths.length; ++ii) {
- TreeColumn column = new TreeColumn(tree, SWT.LEFT);
- column.setText(columnNames[ii]);
- column.setWidth(columnWidths[ii]);
- column.setMoveable(true);
- column.addSelectionListener(listener);
- column.setAlignment(columnAlignments[ii]);
- }
-
- // Add a listener to the tree so that we can make the row
- // height smaller.
- tree.addListener(SWT.MeasureItem, new Listener() {
- @Override
- public void handleEvent(Event event) {
- int fontHeight = event.gc.getFontMetrics().getHeight();
- event.height = fontHeight;
- }
- });
-
- mTreeViewer.setContentProvider(mProfileProvider);
- mTreeViewer.setLabelProvider(mProfileProvider.getLabelProvider());
- mTreeViewer.setInput(mProfileProvider.getRoot());
-
- // Create another composite to hold the label and text box
- Composite composite = new Composite(this, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Add a label for the search box
- Label label = new Label(composite, SWT.NONE);
- label.setText("Find:");
-
- // Add a text box for searching for method names
- mSearchBox = new Text(composite, SWT.BORDER);
- mSearchBox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- Display display = getDisplay();
- mColorNoMatch = new Color(display, 255, 200, 200);
- mColorMatch = mSearchBox.getBackground();
-
- mSearchBox.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent ev) {
- String query = mSearchBox.getText();
- if (query.length() == 0)
- return;
- findName(query);
- }
- });
-
- // Add a key listener to the text box so that we can clear
- // the text box if the user presses <ESC>.
- mSearchBox.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent event) {
- if (event.keyCode == SWT.ESC) {
- mSearchBox.setText("");
- } else if (event.keyCode == SWT.CR) {
- String query = mSearchBox.getText();
- if (query.length() == 0)
- return;
- findNextName(query);
- }
- }
- });
-
- // Also add a key listener to the tree viewer so that the
- // user can just start typing anywhere in the tree view.
- tree.addKeyListener(new KeyAdapter() {
- @Override
- public void keyPressed(KeyEvent event) {
- if (event.keyCode == SWT.ESC) {
- mSearchBox.setText("");
- } else if (event.keyCode == SWT.BS) {
- // Erase the last character from the search box
- String text = mSearchBox.getText();
- int len = text.length();
- String chopped;
- if (len <= 1)
- chopped = "";
- else
- chopped = text.substring(0, len - 1);
- mSearchBox.setText(chopped);
- } else if (event.keyCode == SWT.CR) {
- String query = mSearchBox.getText();
- if (query.length() == 0)
- return;
- findNextName(query);
- } else {
- // Append the given character to the search box
- String str = String.valueOf(event.character);
- mSearchBox.append(str);
- }
- event.doit = false;
- }
- });
-
- // Add a selection listener to the tree so that the user can click
- // on a method that is a child or parent and jump to that method.
- mTreeViewer
- .addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent ev) {
- ISelection sel = ev.getSelection();
- if (sel.isEmpty())
- return;
- if (sel instanceof IStructuredSelection) {
- IStructuredSelection selection = (IStructuredSelection) sel;
- Object element = selection.getFirstElement();
- if (element == null)
- return;
- if (element instanceof MethodData) {
- MethodData md = (MethodData) element;
- highlightMethod(md, true);
- }
- if (element instanceof ProfileData) {
- MethodData md = ((ProfileData) element)
- .getMethodData();
- highlightMethod(md, true);
- }
- }
- }
- });
-
- // Add a tree listener so that we can expand the parents and children
- // of a method when a method is expanded.
- mTreeViewer.addTreeListener(new ITreeViewerListener() {
- @Override
- public void treeExpanded(TreeExpansionEvent event) {
- Object element = event.getElement();
- if (element instanceof MethodData) {
- MethodData md = (MethodData) element;
- expandNode(md);
- }
- }
- @Override
- public void treeCollapsed(TreeExpansionEvent event) {
- }
- });
-
- tree.addListener(SWT.MouseDown, new Listener() {
- @Override
- public void handleEvent(Event event) {
- Point point = new Point(event.x, event.y);
- TreeItem treeItem = tree.getItem(point);
- MethodData md = mProfileProvider.findMatchingTreeItem(treeItem);
- if (md == null)
- return;
- ArrayList<Selection> selections = new ArrayList<Selection>();
- selections.add(Selection.highlight("MethodData", md));
- mSelectionController.change(selections, "ProfileView");
-
- if (mMethodHandler != null && (event.stateMask & SWT.MOD1) != 0) {
- mMethodHandler.handleMethod(md);
- }
- }
- });
- }
-
- public void setMethodHandler(MethodHandler handler) {
- mMethodHandler = handler;
- }
-
- private void findName(String query) {
- MethodData md = mProfileProvider.findMatchingName(query);
- selectMethod(md);
- }
-
- private void findNextName(String query) {
- MethodData md = mProfileProvider.findNextMatchingName(query);
- selectMethod(md);
- }
-
- private void selectMethod(MethodData md) {
- if (md == null) {
- mSearchBox.setBackground(mColorNoMatch);
- return;
- }
- mSearchBox.setBackground(mColorMatch);
- highlightMethod(md, false);
- }
-
- @Override
- public void update(Observable objservable, Object arg) {
- // Ignore updates from myself
- if (arg == "ProfileView")
- return;
- // System.out.printf("profileview update from %s\n", arg);
- ArrayList<Selection> selections;
- selections = mSelectionController.getSelections();
- for (Selection selection : selections) {
- Selection.Action action = selection.getAction();
- if (action != Selection.Action.Highlight)
- continue;
- String name = selection.getName();
- if (name == "MethodData") {
- MethodData md = (MethodData) selection.getValue();
- highlightMethod(md, true);
- return;
- }
- if (name == "Call") {
- Call call = (Call) selection.getValue();
- MethodData md = call.getMethodData();
- highlightMethod(md, true);
- return;
- }
- }
- }
-
- private void highlightMethod(MethodData md, boolean clearSearch) {
- if (md == null)
- return;
- // Avoid an infinite recursion
- if (md == mCurrentHighlightedMethod)
- return;
- if (clearSearch) {
- mSearchBox.setText("");
- mSearchBox.setBackground(mColorMatch);
- }
- mCurrentHighlightedMethod = md;
- mTreeViewer.collapseAll();
- // Expand this node and its children
- expandNode(md);
- StructuredSelection sel = new StructuredSelection(md);
- mTreeViewer.setSelection(sel, true);
- Tree tree = mTreeViewer.getTree();
- TreeItem[] items = tree.getSelection();
- if (items.length != 0) {
- tree.setTopItem(items[0]);
- // workaround a Mac bug by adding showItem().
- tree.showItem(items[0]);
- }
- }
-
- private void expandNode(MethodData md) {
- ProfileNode[] nodes = md.getProfileNodes();
- mTreeViewer.setExpandedState(md, true);
- // Also expand the "Parents" and "Children" nodes.
- if (nodes != null) {
- for (ProfileNode node : nodes) {
- if (node.isRecursive() == false)
- mTreeViewer.setExpandedState(node, true);
- }
- }
- }
-}
diff --git a/traceview/src/com/android/traceview/PropertiesDialog.java b/traceview/src/com/android/traceview/PropertiesDialog.java
deleted file mode 100644
index 9f5eff9..0000000
--- a/traceview/src/com/android/traceview/PropertiesDialog.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-import java.util.HashMap;
-import java.util.Map.Entry;
-
-public class PropertiesDialog extends Dialog {
- private HashMap<String, String> mProperties;
-
- public PropertiesDialog(Shell parent) {
- super(parent);
-
- setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE);
- }
-
- public void setProperties(HashMap<String, String> properties) {
- mProperties = properties;
- }
-
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- }
-
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite container = (Composite) super.createDialogArea(parent);
- GridLayout gridLayout = new GridLayout(1, false);
- gridLayout.marginWidth = 0;
- gridLayout.marginHeight = 0;
- gridLayout.horizontalSpacing = 0;
- gridLayout.verticalSpacing = 0;
- container.setLayout(gridLayout);
-
- TableViewer tableViewer = new TableViewer(container, SWT.HIDE_SELECTION
- | SWT.V_SCROLL | SWT.BORDER);
- tableViewer.getTable().setLinesVisible(true);
- tableViewer.getTable().setHeaderVisible(true);
-
- TableViewerColumn propertyColumn = new TableViewerColumn(tableViewer, SWT.NONE);
- propertyColumn.getColumn().setText("Property");
- propertyColumn.setLabelProvider(new ColumnLabelProvider() {
- @Override
- @SuppressWarnings("unchecked")
- public String getText(Object element) {
- Entry<String, String> entry = (Entry<String, String>) element;
- return entry.getKey();
- }
- });
- propertyColumn.getColumn().setWidth(400);
-
- TableViewerColumn valueColumn = new TableViewerColumn(tableViewer, SWT.NONE);
- valueColumn.getColumn().setText("Value");
- valueColumn.setLabelProvider(new ColumnLabelProvider() {
- @Override
- @SuppressWarnings("unchecked")
- public String getText(Object element) {
- Entry<String, String> entry = (Entry<String, String>) element;
- return entry.getValue();
- }
- });
- valueColumn.getColumn().setWidth(200);
-
- tableViewer.setContentProvider(new ArrayContentProvider());
- tableViewer.setInput(mProperties.entrySet().toArray());
-
- GridData gridData = new GridData();
- gridData.verticalAlignment = GridData.FILL;
- gridData.horizontalAlignment = GridData.FILL;
- gridData.grabExcessHorizontalSpace = true;
- gridData.grabExcessVerticalSpace = true;
- tableViewer.getControl().setLayoutData(gridData);
-
- return container;
- }
-}
diff --git a/traceview/src/com/android/traceview/Selection.java b/traceview/src/com/android/traceview/Selection.java
deleted file mode 100644
index 3764619..0000000
--- a/traceview/src/com/android/traceview/Selection.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-public class Selection {
-
- private Action mAction;
- private String mName;
- private Object mValue;
-
- public Selection(Action action, String name, Object value) {
- mAction = action;
- mName = name;
- mValue = value;
- }
-
- public static Selection highlight(String name, Object value) {
- return new Selection(Action.Highlight, name, value);
- }
-
- public static Selection include(String name, Object value) {
- return new Selection(Action.Include, name, value);
- }
-
- public static Selection exclude(String name, Object value) {
- return new Selection(Action.Exclude, name, value);
- }
-
- public void setName(String name) {
- mName = name;
- }
-
- public String getName() {
- return mName;
- }
-
- public void setValue(Object value) {
- mValue = value;
- }
-
- public Object getValue() {
- return mValue;
- }
-
- public void setAction(Action action) {
- mAction = action;
- }
-
- public Action getAction() {
- return mAction;
- }
-
- public static enum Action {
- Highlight, Include, Exclude, Aggregate
- };
-}
diff --git a/traceview/src/com/android/traceview/SelectionController.java b/traceview/src/com/android/traceview/SelectionController.java
deleted file mode 100644
index 4c930ea..0000000
--- a/traceview/src/com/android/traceview/SelectionController.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-import java.util.ArrayList;
-import java.util.Observable;
-
-public class SelectionController extends Observable {
-
- private ArrayList<Selection> mSelections;
-
- public void change(ArrayList<Selection> selections, Object arg) {
- this.mSelections = selections;
- setChanged();
- notifyObservers(arg);
- }
-
- public ArrayList<Selection> getSelections() {
- return mSelections;
- }
-}
diff --git a/traceview/src/com/android/traceview/ThreadData.java b/traceview/src/com/android/traceview/ThreadData.java
deleted file mode 100644
index 05e54e8..0000000
--- a/traceview/src/com/android/traceview/ThreadData.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-class ThreadData implements TimeLineView.Row {
-
- private int mId;
- private String mName;
- private boolean mIsEmpty;
-
- private Call mRootCall;
- private ArrayList<Call> mStack = new ArrayList<Call>();
-
- // This is a hash of all the methods that are currently on the stack.
- private HashMap<MethodData, Integer> mStackMethods = new HashMap<MethodData, Integer>();
-
- boolean mHaveGlobalTime;
- long mGlobalStartTime;
- long mGlobalEndTime;
-
- boolean mHaveThreadTime;
- long mThreadStartTime;
- long mThreadEndTime;
-
- long mThreadCurrentTime; // only used while parsing thread-cpu clock
-
- ThreadData(int id, String name, MethodData topLevel) {
- mId = id;
- mName = String.format("[%d] %s", id, name);
- mIsEmpty = true;
- mRootCall = new Call(this, topLevel, null);
- mRootCall.setName(mName);
- mStack.add(mRootCall);
- }
-
- @Override
- public String getName() {
- return mName;
- }
-
- public Call getRootCall() {
- return mRootCall;
- }
-
- /**
- * Returns true if no calls have ever been recorded for this thread.
- */
- public boolean isEmpty() {
- return mIsEmpty;
- }
-
- Call enter(MethodData method, ArrayList<TraceAction> trace) {
- if (mIsEmpty) {
- mIsEmpty = false;
- if (trace != null) {
- trace.add(new TraceAction(TraceAction.ACTION_ENTER, mRootCall));
- }
- }
-
- Call caller = top();
- Call call = new Call(this, method, caller);
- mStack.add(call);
-
- if (trace != null) {
- trace.add(new TraceAction(TraceAction.ACTION_ENTER, call));
- }
-
- Integer num = mStackMethods.get(method);
- if (num == null) {
- num = 0;
- } else if (num > 0) {
- call.setRecursive(true);
- }
- mStackMethods.put(method, num + 1);
-
- return call;
- }
-
- Call exit(MethodData method, ArrayList<TraceAction> trace) {
- Call call = top();
- if (call.mCaller == null) {
- return null;
- }
-
- if (call.getMethodData() != method) {
- String error = "Method exit (" + method.getName()
- + ") does not match current method (" + call.getMethodData().getName()
- + ")";
- throw new RuntimeException(error);
- }
-
- mStack.remove(mStack.size() - 1);
-
- if (trace != null) {
- trace.add(new TraceAction(TraceAction.ACTION_EXIT, call));
- }
-
- Integer num = mStackMethods.get(method);
- if (num != null) {
- if (num == 1) {
- mStackMethods.remove(method);
- } else {
- mStackMethods.put(method, num - 1);
- }
- }
-
- return call;
- }
-
- Call top() {
- return mStack.get(mStack.size() - 1);
- }
-
- void endTrace(ArrayList<TraceAction> trace) {
- for (int i = mStack.size() - 1; i >= 1; i--) {
- Call call = mStack.get(i);
- call.mGlobalEndTime = mGlobalEndTime;
- call.mThreadEndTime = mThreadEndTime;
- if (trace != null) {
- trace.add(new TraceAction(TraceAction.ACTION_INCOMPLETE, call));
- }
- }
- mStack.clear();
- mStackMethods.clear();
- }
-
- void updateRootCallTimeBounds() {
- if (!mIsEmpty) {
- mRootCall.mGlobalStartTime = mGlobalStartTime;
- mRootCall.mGlobalEndTime = mGlobalEndTime;
- mRootCall.mThreadStartTime = mThreadStartTime;
- mRootCall.mThreadEndTime = mThreadEndTime;
- }
- }
-
- @Override
- public String toString() {
- return mName;
- }
-
- @Override
- public int getId() {
- return mId;
- }
-
- public long getCpuTime() {
- return mRootCall.mInclusiveCpuTime;
- }
-
- public long getRealTime() {
- return mRootCall.mInclusiveRealTime;
- }
-}
diff --git a/traceview/src/com/android/traceview/TickScaler.java b/traceview/src/com/android/traceview/TickScaler.java
deleted file mode 100644
index 79fa160..0000000
--- a/traceview/src/com/android/traceview/TickScaler.java
+++ /dev/null
@@ -1,148 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-class TickScaler {
-
- private double mMinVal; // required input
- private double mMaxVal; // required input
- private double mRangeVal;
- private int mNumPixels; // required input
- private int mPixelsPerTick; // required input
- private double mPixelsPerRange;
- private double mTickIncrement;
- private double mMinMajorTick;
-
- TickScaler(double minVal, double maxVal, int numPixels, int pixelsPerTick) {
- mMinVal = minVal;
- mMaxVal = maxVal;
- mNumPixels = numPixels;
- mPixelsPerTick = pixelsPerTick;
- }
-
- public void setMinVal(double minVal) {
- mMinVal = minVal;
- }
-
- public double getMinVal() {
- return mMinVal;
- }
-
- public void setMaxVal(double maxVal) {
- mMaxVal = maxVal;
- }
-
- public double getMaxVal() {
- return mMaxVal;
- }
-
- public void setNumPixels(int numPixels) {
- mNumPixels = numPixels;
- }
-
- public int getNumPixels() {
- return mNumPixels;
- }
-
- public void setPixelsPerTick(int pixelsPerTick) {
- mPixelsPerTick = pixelsPerTick;
- }
-
- public int getPixelsPerTick() {
- return mPixelsPerTick;
- }
-
- public void setPixelsPerRange(double pixelsPerRange) {
- mPixelsPerRange = pixelsPerRange;
- }
-
- public double getPixelsPerRange() {
- return mPixelsPerRange;
- }
-
- public void setTickIncrement(double tickIncrement) {
- mTickIncrement = tickIncrement;
- }
-
- public double getTickIncrement() {
- return mTickIncrement;
- }
-
- public void setMinMajorTick(double minMajorTick) {
- mMinMajorTick = minMajorTick;
- }
-
- public double getMinMajorTick() {
- return mMinMajorTick;
- }
-
- // Convert a time value to a 0-based pixel value
- public int valueToPixel(double value) {
- return (int) Math.ceil(mPixelsPerRange * (value - mMinVal) - 0.5);
- }
-
- // Convert a time value to a 0-based fractional pixel
- public double valueToPixelFraction(double value) {
- return mPixelsPerRange * (value - mMinVal);
- }
-
- // Convert a 0-based pixel value to a time value
- public double pixelToValue(int pixel) {
- return mMinVal + (pixel / mPixelsPerRange);
- }
-
- public void computeTicks(boolean useGivenEndPoints) {
- int numTicks = mNumPixels / mPixelsPerTick;
- mRangeVal = mMaxVal - mMinVal;
- mTickIncrement = mRangeVal / numTicks;
- double dlogTickIncrement = Math.log10(mTickIncrement);
- int logTickIncrement = (int) Math.floor(dlogTickIncrement);
- double scale = Math.pow(10, logTickIncrement);
- double scaledTickIncr = mTickIncrement / scale;
- if (scaledTickIncr > 5.0)
- scaledTickIncr = 10;
- else if (scaledTickIncr > 2)
- scaledTickIncr = 5;
- else if (scaledTickIncr > 1)
- scaledTickIncr = 2;
- else
- scaledTickIncr = 1;
- mTickIncrement = scaledTickIncr * scale;
-
- if (!useGivenEndPoints) {
- // Round up the max val to the next minor tick
- double minorTickIncrement = mTickIncrement / 5;
- double dval = mMaxVal / minorTickIncrement;
- int ival = (int) dval;
- if (ival != dval)
- mMaxVal = (ival + 1) * minorTickIncrement;
-
- // Round down the min val to a multiple of tickIncrement
- ival = (int) (mMinVal / mTickIncrement);
- mMinVal = ival * mTickIncrement;
- mMinMajorTick = mMinVal;
- } else {
- int ival = (int) (mMinVal / mTickIncrement);
- mMinMajorTick = ival * mTickIncrement;
- if (mMinMajorTick < mMinVal)
- mMinMajorTick = mMinMajorTick + mTickIncrement;
- }
-
- mRangeVal = mMaxVal - mMinVal;
- mPixelsPerRange = (double) mNumPixels / mRangeVal;
- }
-}
diff --git a/traceview/src/com/android/traceview/TimeBase.java b/traceview/src/com/android/traceview/TimeBase.java
deleted file mode 100644
index b6b23cb..0000000
--- a/traceview/src/com/android/traceview/TimeBase.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-interface TimeBase {
- public static final TimeBase CPU_TIME = new CpuTimeBase();
- public static final TimeBase REAL_TIME = new RealTimeBase();
-
- public long getTime(ThreadData threadData);
- public long getElapsedInclusiveTime(MethodData methodData);
- public long getElapsedExclusiveTime(MethodData methodData);
- public long getElapsedInclusiveTime(ProfileData profileData);
-
- public static final class CpuTimeBase implements TimeBase {
- @Override
- public long getTime(ThreadData threadData) {
- return threadData.getCpuTime();
- }
-
- @Override
- public long getElapsedInclusiveTime(MethodData methodData) {
- return methodData.getElapsedInclusiveCpuTime();
- }
-
- @Override
- public long getElapsedExclusiveTime(MethodData methodData) {
- return methodData.getElapsedExclusiveCpuTime();
- }
-
- @Override
- public long getElapsedInclusiveTime(ProfileData profileData) {
- return profileData.getElapsedInclusiveCpuTime();
- }
- }
-
- public static final class RealTimeBase implements TimeBase {
- @Override
- public long getTime(ThreadData threadData) {
- return threadData.getRealTime();
- }
-
- @Override
- public long getElapsedInclusiveTime(MethodData methodData) {
- return methodData.getElapsedInclusiveRealTime();
- }
-
- @Override
- public long getElapsedExclusiveTime(MethodData methodData) {
- return methodData.getElapsedExclusiveRealTime();
- }
-
- @Override
- public long getElapsedInclusiveTime(ProfileData profileData) {
- return profileData.getElapsedInclusiveRealTime();
- }
- }
-}
diff --git a/traceview/src/com/android/traceview/TimeLineView.java b/traceview/src/com/android/traceview/TimeLineView.java
deleted file mode 100644
index cc9613a..0000000
--- a/traceview/src/com/android/traceview/TimeLineView.java
+++ /dev/null
@@ -1,2154 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-import org.eclipse.jface.resource.FontRegistry;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseWheelListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.ScrollBar;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Observable;
-import java.util.Observer;
-
-public class TimeLineView extends Composite implements Observer {
-
- private HashMap<String, RowData> mRowByName;
- private RowData[] mRows;
- private Segment[] mSegments;
- private HashMap<Integer, String> mThreadLabels;
- private Timescale mTimescale;
- private Surface mSurface;
- private RowLabels mLabels;
- private SashForm mSashForm;
- private int mScrollOffsetY;
-
- public static final int PixelsPerTick = 50;
- private TickScaler mScaleInfo = new TickScaler(0, 0, 0, PixelsPerTick);
- private static final int LeftMargin = 10; // blank space on left
- private static final int RightMargin = 60; // blank space on right
-
- private Color mColorBlack;
- private Color mColorGray;
- private Color mColorDarkGray;
- private Color mColorForeground;
- private Color mColorRowBack;
- private Color mColorZoomSelection;
- private FontRegistry mFontRegistry;
-
- /** vertical height of drawn blocks in each row */
- private static final int rowHeight = 20;
-
- /** the blank space between rows */
- private static final int rowYMargin = 12;
- private static final int rowYMarginHalf = rowYMargin / 2;
-
- /** total vertical space for row */
- private static final int rowYSpace = rowHeight + rowYMargin;
- private static final int majorTickLength = 8;
- private static final int minorTickLength = 4;
- private static final int timeLineOffsetY = 58;
- private static final int tickToFontSpacing = 2;
-
- /** start of first row */
- private static final int topMargin = 90;
- private int mMouseRow = -1;
- private int mNumRows;
- private int mStartRow;
- private int mEndRow;
- private TraceUnits mUnits;
- private String mClockSource;
- private boolean mHaveCpuTime;
- private boolean mHaveRealTime;
- private int mSmallFontWidth;
- private int mSmallFontHeight;
- private SelectionController mSelectionController;
- private MethodData mHighlightMethodData;
- private Call mHighlightCall;
- private static final int MinInclusiveRange = 3;
-
- /** Setting the fonts looks good on Linux but bad on Macs */
- private boolean mSetFonts = false;
-
- public static interface Block {
- public String getName();
- public MethodData getMethodData();
- public long getStartTime();
- public long getEndTime();
- public Color getColor();
- public double addWeight(int x, int y, double weight);
- public void clearWeight();
- public long getExclusiveCpuTime();
- public long getInclusiveCpuTime();
- public long getExclusiveRealTime();
- public long getInclusiveRealTime();
- public boolean isContextSwitch();
- public boolean isIgnoredBlock();
- public Block getParentBlock();
- }
-
- public static interface Row {
- public int getId();
- public String getName();
- }
-
- public static class Record {
- Row row;
- Block block;
-
- public Record(Row row, Block block) {
- this.row = row;
- this.block = block;
- }
- }
-
- public TimeLineView(Composite parent, TraceReader reader,
- SelectionController selectionController) {
- super(parent, SWT.NONE);
- mRowByName = new HashMap<String, RowData>();
- this.mSelectionController = selectionController;
- selectionController.addObserver(this);
- mUnits = reader.getTraceUnits();
- mClockSource = reader.getClockSource();
- mHaveCpuTime = reader.haveCpuTime();
- mHaveRealTime = reader.haveRealTime();
- mThreadLabels = reader.getThreadLabels();
-
- Display display = getDisplay();
- mColorGray = display.getSystemColor(SWT.COLOR_GRAY);
- mColorDarkGray = display.getSystemColor(SWT.COLOR_DARK_GRAY);
- mColorBlack = display.getSystemColor(SWT.COLOR_BLACK);
- // mColorBackground = display.getSystemColor(SWT.COLOR_WHITE);
- mColorForeground = display.getSystemColor(SWT.COLOR_BLACK);
- mColorRowBack = new Color(display, 240, 240, 255);
- mColorZoomSelection = new Color(display, 230, 230, 230);
-
- mFontRegistry = new FontRegistry(display);
- mFontRegistry.put("small", //$NON-NLS-1$
- new FontData[] { new FontData("Arial", 8, SWT.NORMAL) }); //$NON-NLS-1$
- mFontRegistry.put("courier8", //$NON-NLS-1$
- new FontData[] { new FontData("Courier New", 8, SWT.BOLD) }); //$NON-NLS-1$
- mFontRegistry.put("medium", //$NON-NLS-1$
- new FontData[] { new FontData("Courier New", 10, SWT.NORMAL) }); //$NON-NLS-1$
-
- Image image = new Image(display, new Rectangle(100, 100, 100, 100));
- GC gc = new GC(image);
- if (mSetFonts) {
- gc.setFont(mFontRegistry.get("small")); //$NON-NLS-1$
- }
- mSmallFontWidth = gc.getFontMetrics().getAverageCharWidth();
- mSmallFontHeight = gc.getFontMetrics().getHeight();
-
- image.dispose();
- gc.dispose();
-
- setLayout(new FillLayout());
-
- // Create a sash form for holding two canvas views, one for the
- // thread labels and one for the thread timeline.
- mSashForm = new SashForm(this, SWT.HORIZONTAL);
- mSashForm.setBackground(mColorGray);
- mSashForm.SASH_WIDTH = 3;
-
- // Create a composite for the left side of the sash
- Composite composite = new Composite(mSashForm, SWT.NONE);
- GridLayout layout = new GridLayout(1, true /* make columns equal width */);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.verticalSpacing = 1;
- composite.setLayout(layout);
-
- // Create a blank corner space in the upper left corner
- BlankCorner corner = new BlankCorner(composite);
- GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.heightHint = topMargin;
- corner.setLayoutData(gridData);
-
- // Add the thread labels below the blank corner.
- mLabels = new RowLabels(composite);
- gridData = new GridData(GridData.FILL_BOTH);
- mLabels.setLayoutData(gridData);
-
- // Create another composite for the right side of the sash
- composite = new Composite(mSashForm, SWT.NONE);
- layout = new GridLayout(1, true /* make columns equal width */);
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.verticalSpacing = 1;
- composite.setLayout(layout);
-
- mTimescale = new Timescale(composite);
- gridData = new GridData(GridData.FILL_HORIZONTAL);
- gridData.heightHint = topMargin;
- mTimescale.setLayoutData(gridData);
-
- mSurface = new Surface(composite);
- gridData = new GridData(GridData.FILL_BOTH);
- mSurface.setLayoutData(gridData);
- mSashForm.setWeights(new int[] { 1, 5 });
-
- final ScrollBar vBar = mSurface.getVerticalBar();
- vBar.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event e) {
- mScrollOffsetY = vBar.getSelection();
- Point dim = mSurface.getSize();
- int newScrollOffsetY = computeVisibleRows(dim.y);
- if (newScrollOffsetY != mScrollOffsetY) {
- mScrollOffsetY = newScrollOffsetY;
- vBar.setSelection(newScrollOffsetY);
- }
- mLabels.redraw();
- mSurface.redraw();
- }
- });
-
- final ScrollBar hBar = mSurface.getHorizontalBar();
- hBar.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event e) {
- mSurface.setScaleFromHorizontalScrollBar(hBar.getSelection());
- mSurface.redraw();
- }
- });
-
- mSurface.addListener(SWT.Resize, new Listener() {
- @Override
- public void handleEvent(Event e) {
- Point dim = mSurface.getSize();
-
- // If we don't need the scroll bar then don't display it.
- if (dim.y >= mNumRows * rowYSpace) {
- vBar.setVisible(false);
- } else {
- vBar.setVisible(true);
- }
- int newScrollOffsetY = computeVisibleRows(dim.y);
- if (newScrollOffsetY != mScrollOffsetY) {
- mScrollOffsetY = newScrollOffsetY;
- vBar.setSelection(newScrollOffsetY);
- }
-
- int spaceNeeded = mNumRows * rowYSpace;
- vBar.setMaximum(spaceNeeded);
- vBar.setThumb(dim.y);
-
- mLabels.redraw();
- mSurface.redraw();
- }
- });
-
- mSurface.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseUp(MouseEvent me) {
- mSurface.mouseUp(me);
- }
-
- @Override
- public void mouseDown(MouseEvent me) {
- mSurface.mouseDown(me);
- }
-
- @Override
- public void mouseDoubleClick(MouseEvent me) {
- mSurface.mouseDoubleClick(me);
- }
- });
-
- mSurface.addMouseMoveListener(new MouseMoveListener() {
- @Override
- public void mouseMove(MouseEvent me) {
- mSurface.mouseMove(me);
- }
- });
-
- mSurface.addMouseWheelListener(new MouseWheelListener() {
- @Override
- public void mouseScrolled(MouseEvent me) {
- mSurface.mouseScrolled(me);
- }
- });
-
- mTimescale.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseUp(MouseEvent me) {
- mTimescale.mouseUp(me);
- }
-
- @Override
- public void mouseDown(MouseEvent me) {
- mTimescale.mouseDown(me);
- }
-
- @Override
- public void mouseDoubleClick(MouseEvent me) {
- mTimescale.mouseDoubleClick(me);
- }
- });
-
- mTimescale.addMouseMoveListener(new MouseMoveListener() {
- @Override
- public void mouseMove(MouseEvent me) {
- mTimescale.mouseMove(me);
- }
- });
-
- mLabels.addMouseMoveListener(new MouseMoveListener() {
- @Override
- public void mouseMove(MouseEvent me) {
- mLabels.mouseMove(me);
- }
- });
-
- setData(reader.getThreadTimeRecords());
- }
-
- @Override
- public void update(Observable objservable, Object arg) {
- // Ignore updates from myself
- if (arg == "TimeLineView") //$NON-NLS-1$
- return;
- // System.out.printf("timeline update from %s\n", arg);
- boolean foundHighlight = false;
- ArrayList<Selection> selections;
- selections = mSelectionController.getSelections();
- for (Selection selection : selections) {
- Selection.Action action = selection.getAction();
- if (action != Selection.Action.Highlight)
- continue;
- String name = selection.getName();
- // System.out.printf(" timeline highlight %s from %s\n", name, arg);
- if (name == "MethodData") { //$NON-NLS-1$
- foundHighlight = true;
- mHighlightMethodData = (MethodData) selection.getValue();
- // System.out.printf(" method %s\n",
- // highlightMethodData.getName());
- mHighlightCall = null;
- startHighlighting();
- } else if (name == "Call") { //$NON-NLS-1$
- foundHighlight = true;
- mHighlightCall = (Call) selection.getValue();
- // System.out.printf(" call %s\n", highlightCall.getName());
- mHighlightMethodData = null;
- startHighlighting();
- }
- }
- if (foundHighlight == false)
- mSurface.clearHighlights();
- }
-
- public void setData(ArrayList<Record> records) {
- if (records == null)
- records = new ArrayList<Record>();
-
- if (false) {
- System.out.println("TimelineView() list of records:"); //$NON-NLS-1$
- for (Record r : records) {
- System.out.printf("row '%s' block '%s' [%d, %d]\n", r.row //$NON-NLS-1$
- .getName(), r.block.getName(), r.block.getStartTime(),
- r.block.getEndTime());
- if (r.block.getStartTime() > r.block.getEndTime()) {
- System.err.printf("Error: block startTime > endTime\n"); //$NON-NLS-1$
- System.exit(1);
- }
- }
- }
-
- // Sort the records into increasing start time, and decreasing end time
- Collections.sort(records, new Comparator<Record>() {
- @Override
- public int compare(Record r1, Record r2) {
- long start1 = r1.block.getStartTime();
- long start2 = r2.block.getStartTime();
- if (start1 > start2)
- return 1;
- if (start1 < start2)
- return -1;
-
- // The start times are the same, so compare the end times
- long end1 = r1.block.getEndTime();
- long end2 = r2.block.getEndTime();
- if (end1 > end2)
- return -1;
- if (end1 < end2)
- return 1;
-
- return 0;
- }
- });
-
- ArrayList<Segment> segmentList = new ArrayList<Segment>();
-
- // The records are sorted into increasing start time,
- // so the minimum start time is the start time of the first record.
- double minVal = 0;
- if (records.size() > 0)
- minVal = records.get(0).block.getStartTime();
-
- // Sum the time spent in each row and block, and
- // keep track of the maximum end time.
- double maxVal = 0;
- for (Record rec : records) {
- Row row = rec.row;
- Block block = rec.block;
- if (block.isIgnoredBlock()) {
- continue;
- }
-
- String rowName = row.getName();
- RowData rd = mRowByName.get(rowName);
- if (rd == null) {
- rd = new RowData(row);
- mRowByName.put(rowName, rd);
- }
- long blockStartTime = block.getStartTime();
- long blockEndTime = block.getEndTime();
- if (blockEndTime > rd.mEndTime) {
- long start = Math.max(blockStartTime, rd.mEndTime);
- rd.mElapsed += blockEndTime - start;
- rd.mEndTime = blockEndTime;
- }
- if (blockEndTime > maxVal)
- maxVal = blockEndTime;
-
- // Keep track of nested blocks by using a stack (for each row).
- // Create a Segment object for each visible part of a block.
- Block top = rd.top();
- if (top == null) {
- rd.push(block);
- continue;
- }
-
- long topStartTime = top.getStartTime();
- long topEndTime = top.getEndTime();
- if (topEndTime >= blockStartTime) {
- // Add this segment if it has a non-zero elapsed time.
- if (topStartTime < blockStartTime) {
- Segment segment = new Segment(rd, top, topStartTime,
- blockStartTime);
- segmentList.add(segment);
- }
-
- // If this block starts where the previous (top) block ends,
- // then pop off the top block.
- if (topEndTime == blockStartTime)
- rd.pop();
- rd.push(block);
- } else {
- // We may have to pop several frames here.
- popFrames(rd, top, blockStartTime, segmentList);
- rd.push(block);
- }
- }
-
- // Clean up the stack of each row
- for (RowData rd : mRowByName.values()) {
- Block top = rd.top();
- popFrames(rd, top, Integer.MAX_VALUE, segmentList);
- }
-
- mSurface.setRange(minVal, maxVal);
- mSurface.setLimitRange(minVal, maxVal);
-
- // Sort the rows into decreasing elapsed time
- Collection<RowData> rv = mRowByName.values();
- mRows = rv.toArray(new RowData[rv.size()]);
- Arrays.sort(mRows, new Comparator<RowData>() {
- @Override
- public int compare(RowData rd1, RowData rd2) {
- return (int) (rd2.mElapsed - rd1.mElapsed);
- }
- });
-
- // Assign ranks to the sorted rows
- for (int ii = 0; ii < mRows.length; ++ii) {
- mRows[ii].mRank = ii;
- }
-
- // Compute the number of rows with data
- mNumRows = 0;
- for (int ii = 0; ii < mRows.length; ++ii) {
- if (mRows[ii].mElapsed == 0)
- break;
- mNumRows += 1;
- }
-
- // Sort the blocks into increasing rows, and within rows into
- // increasing start values.
- mSegments = segmentList.toArray(new Segment[segmentList.size()]);
- Arrays.sort(mSegments, new Comparator<Segment>() {
- @Override
- public int compare(Segment bd1, Segment bd2) {
- RowData rd1 = bd1.mRowData;
- RowData rd2 = bd2.mRowData;
- int diff = rd1.mRank - rd2.mRank;
- if (diff == 0) {
- long timeDiff = bd1.mStartTime - bd2.mStartTime;
- if (timeDiff == 0)
- timeDiff = bd1.mEndTime - bd2.mEndTime;
- return (int) timeDiff;
- }
- return diff;
- }
- });
-
- if (false) {
- for (Segment segment : mSegments) {
- System.out.printf("seg '%s' [%6d, %6d] %s\n",
- segment.mRowData.mName, segment.mStartTime,
- segment.mEndTime, segment.mBlock.getName());
- if (segment.mStartTime > segment.mEndTime) {
- System.err.printf("Error: segment startTime > endTime\n");
- System.exit(1);
- }
- }
- }
- }
-
- private static void popFrames(RowData rd, Block top, long startTime,
- ArrayList<Segment> segmentList) {
- long topEndTime = top.getEndTime();
- long lastEndTime = top.getStartTime();
- while (topEndTime <= startTime) {
- if (topEndTime > lastEndTime) {
- Segment segment = new Segment(rd, top, lastEndTime, topEndTime);
- segmentList.add(segment);
- lastEndTime = topEndTime;
- }
- rd.pop();
- top = rd.top();
- if (top == null)
- return;
- topEndTime = top.getEndTime();
- }
-
- // If we get here, then topEndTime > startTime
- if (lastEndTime < startTime) {
- Segment bd = new Segment(rd, top, lastEndTime, startTime);
- segmentList.add(bd);
- }
- }
-
- private class RowLabels extends Canvas {
-
- /** The space between the row label and the sash line */
- private static final int labelMarginX = 2;
-
- public RowLabels(Composite parent) {
- super(parent, SWT.NO_BACKGROUND);
- addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent pe) {
- draw(pe.display, pe.gc);
- }
- });
- }
-
- private void mouseMove(MouseEvent me) {
- int rownum = (me.y + mScrollOffsetY) / rowYSpace;
- if (mMouseRow != rownum) {
- mMouseRow = rownum;
- redraw();
- mSurface.redraw();
- }
- }
-
- private void draw(Display display, GC gc) {
- if (mSegments.length == 0) {
- // gc.setBackground(colorBackground);
- // gc.fillRectangle(getBounds());
- return;
- }
- Point dim = getSize();
-
- // Create an image for double-buffering
- Image image = new Image(display, getBounds());
-
- // Set up the off-screen gc
- GC gcImage = new GC(image);
- if (mSetFonts)
- gcImage.setFont(mFontRegistry.get("medium")); //$NON-NLS-1$
-
- if (mNumRows > 2) {
- // Draw the row background stripes
- gcImage.setBackground(mColorRowBack);
- for (int ii = 1; ii < mNumRows; ii += 2) {
- RowData rd = mRows[ii];
- int y1 = rd.mRank * rowYSpace - mScrollOffsetY;
- gcImage.fillRectangle(0, y1, dim.x, rowYSpace);
- }
- }
-
- // Draw the row labels
- int offsetY = rowYMarginHalf - mScrollOffsetY;
- for (int ii = mStartRow; ii <= mEndRow; ++ii) {
- RowData rd = mRows[ii];
- int y1 = rd.mRank * rowYSpace + offsetY;
- Point extent = gcImage.stringExtent(rd.mName);
- int x1 = dim.x - extent.x - labelMarginX;
- gcImage.drawString(rd.mName, x1, y1, true);
- }
-
- // Draw a highlight box on the row where the mouse is.
- if (mMouseRow >= mStartRow && mMouseRow <= mEndRow) {
- gcImage.setForeground(mColorGray);
- int y1 = mMouseRow * rowYSpace - mScrollOffsetY;
- gcImage.drawRectangle(0, y1, dim.x, rowYSpace);
- }
-
- // Draw the off-screen buffer to the screen
- gc.drawImage(image, 0, 0);
-
- // Clean up
- image.dispose();
- gcImage.dispose();
- }
- }
-
- private class BlankCorner extends Canvas {
- public BlankCorner(Composite parent) {
- //super(parent, SWT.NO_BACKGROUND);
- super(parent, SWT.NONE);
- addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent pe) {
- draw(pe.display, pe.gc);
- }
- });
- }
-
- private void draw(Display display, GC gc) {
- // Create a blank image and draw it to the canvas
- Image image = new Image(display, getBounds());
- gc.drawImage(image, 0, 0);
-
- // Clean up
- image.dispose();
- }
- }
-
- private class Timescale extends Canvas {
- private Point mMouse = new Point(LeftMargin, 0);
- private Cursor mZoomCursor;
- private String mMethodName = null;
- private Color mMethodColor = null;
- private String mDetails;
- private int mMethodStartY;
- private int mDetailsStartY;
- private int mMarkStartX;
- private int mMarkEndX;
-
- /** The space between the colored block and the method name */
- private static final int METHOD_BLOCK_MARGIN = 10;
-
- public Timescale(Composite parent) {
- //super(parent, SWT.NO_BACKGROUND);
- super(parent, SWT.NONE);
- Display display = getDisplay();
- mZoomCursor = new Cursor(display, SWT.CURSOR_SIZEWE);
- setCursor(mZoomCursor);
- mMethodStartY = mSmallFontHeight + 1;
- mDetailsStartY = mMethodStartY + mSmallFontHeight + 1;
- addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent pe) {
- draw(pe.display, pe.gc);
- }
- });
- }
-
- public void setVbarPosition(int x) {
- mMouse.x = x;
- }
-
- public void setMarkStart(int x) {
- mMarkStartX = x;
- }
-
- public void setMarkEnd(int x) {
- mMarkEndX = x;
- }
-
- public void setMethodName(String name) {
- mMethodName = name;
- }
-
- public void setMethodColor(Color color) {
- mMethodColor = color;
- }
-
- public void setDetails(String details) {
- mDetails = details;
- }
-
- private void mouseMove(MouseEvent me) {
- me.y = -1;
- mSurface.mouseMove(me);
- }
-
- private void mouseDown(MouseEvent me) {
- mSurface.startScaling(me.x);
- mSurface.redraw();
- }
-
- private void mouseUp(MouseEvent me) {
- mSurface.stopScaling(me.x);
- }
-
- private void mouseDoubleClick(MouseEvent me) {
- mSurface.resetScale();
- mSurface.redraw();
- }
-
- private void draw(Display display, GC gc) {
- Point dim = getSize();
-
- // Create an image for double-buffering
- Image image = new Image(display, getBounds());
-
- // Set up the off-screen gc
- GC gcImage = new GC(image);
- if (mSetFonts)
- gcImage.setFont(mFontRegistry.get("medium")); //$NON-NLS-1$
-
- if (mSurface.drawingSelection()) {
- drawSelection(display, gcImage);
- }
-
- drawTicks(display, gcImage);
-
- // Draw the vertical bar where the mouse is
- gcImage.setForeground(mColorDarkGray);
- gcImage.drawLine(mMouse.x, timeLineOffsetY, mMouse.x, dim.y);
-
- // Draw the current millseconds
- drawTickLegend(display, gcImage);
-
- // Draw the method name and color, if needed
- drawMethod(display, gcImage);
-
- // Draw the details, if needed
- drawDetails(display, gcImage);
-
- // Draw the off-screen buffer to the screen
- gc.drawImage(image, 0, 0);
-
- // Clean up
- image.dispose();
- gcImage.dispose();
- }
-
- private void drawSelection(Display display, GC gc) {
- Point dim = getSize();
- gc.setForeground(mColorGray);
- gc.drawLine(mMarkStartX, timeLineOffsetY, mMarkStartX, dim.y);
- gc.setBackground(mColorZoomSelection);
- int x, width;
- if (mMarkStartX < mMarkEndX) {
- x = mMarkStartX;
- width = mMarkEndX - mMarkStartX;
- } else {
- x = mMarkEndX;
- width = mMarkStartX - mMarkEndX;
- }
- if (width > 1) {
- gc.fillRectangle(x, timeLineOffsetY, width, dim.y);
- }
- }
-
- private void drawTickLegend(Display display, GC gc) {
- int mouseX = mMouse.x - LeftMargin;
- double mouseXval = mScaleInfo.pixelToValue(mouseX);
- String info = mUnits.labelledString(mouseXval);
- gc.setForeground(mColorForeground);
- gc.drawString(info, LeftMargin + 2, 1, true);
-
- // Display the maximum data value
- double maxVal = mScaleInfo.getMaxVal();
- info = mUnits.labelledString(maxVal);
- if (mClockSource != null) {
- info = String.format(" max %s (%s)", info, mClockSource); //$NON-NLS-1$
- } else {
- info = String.format(" max %s ", info); //$NON-NLS-1$
- }
- Point extent = gc.stringExtent(info);
- Point dim = getSize();
- int x1 = dim.x - RightMargin - extent.x;
- gc.drawString(info, x1, 1, true);
- }
-
- private void drawMethod(Display display, GC gc) {
- if (mMethodName == null) {
- return;
- }
-
- int x1 = LeftMargin;
- int y1 = mMethodStartY;
- gc.setBackground(mMethodColor);
- int width = 2 * mSmallFontWidth;
- gc.fillRectangle(x1, y1, width, mSmallFontHeight);
- x1 += width + METHOD_BLOCK_MARGIN;
- gc.drawString(mMethodName, x1, y1, true);
- }
-
- private void drawDetails(Display display, GC gc) {
- if (mDetails == null) {
- return;
- }
-
- int x1 = LeftMargin + 2 * mSmallFontWidth + METHOD_BLOCK_MARGIN;
- int y1 = mDetailsStartY;
- gc.drawString(mDetails, x1, y1, true);
- }
-
- private void drawTicks(Display display, GC gc) {
- Point dim = getSize();
- int y2 = majorTickLength + timeLineOffsetY;
- int y3 = minorTickLength + timeLineOffsetY;
- int y4 = y2 + tickToFontSpacing;
- gc.setForeground(mColorForeground);
- gc.drawLine(LeftMargin, timeLineOffsetY, dim.x - RightMargin,
- timeLineOffsetY);
- double minVal = mScaleInfo.getMinVal();
- double maxVal = mScaleInfo.getMaxVal();
- double minMajorTick = mScaleInfo.getMinMajorTick();
- double tickIncrement = mScaleInfo.getTickIncrement();
- double minorTickIncrement = tickIncrement / 5;
- double pixelsPerRange = mScaleInfo.getPixelsPerRange();
-
- // Draw the initial minor ticks, if any
- if (minVal < minMajorTick) {
- gc.setForeground(mColorGray);
- double xMinor = minMajorTick;
- for (int ii = 1; ii <= 4; ++ii) {
- xMinor -= minorTickIncrement;
- if (xMinor < minVal)
- break;
- int x1 = LeftMargin
- + (int) (0.5 + (xMinor - minVal) * pixelsPerRange);
- gc.drawLine(x1, timeLineOffsetY, x1, y3);
- }
- }
-
- if (tickIncrement <= 10) {
- // TODO avoid rendering the loop when tickIncrement is invalid. It can be zero
- // or too small.
- // System.out.println(String.format("Timescale.drawTicks error: tickIncrement=%1f", tickIncrement));
- return;
- }
- for (double x = minMajorTick; x <= maxVal; x += tickIncrement) {
- int x1 = LeftMargin
- + (int) (0.5 + (x - minVal) * pixelsPerRange);
-
- // Draw a major tick
- gc.setForeground(mColorForeground);
- gc.drawLine(x1, timeLineOffsetY, x1, y2);
- if (x > maxVal)
- break;
-
- // Draw the tick text
- String tickString = mUnits.valueOf(x);
- gc.drawString(tickString, x1, y4, true);
-
- // Draw 4 minor ticks between major ticks
- gc.setForeground(mColorGray);
- double xMinor = x;
- for (int ii = 1; ii <= 4; ii++) {
- xMinor += minorTickIncrement;
- if (xMinor > maxVal)
- break;
- x1 = LeftMargin
- + (int) (0.5 + (xMinor - minVal) * pixelsPerRange);
- gc.drawLine(x1, timeLineOffsetY, x1, y3);
- }
- }
- }
- }
-
- private static enum GraphicsState {
- Normal, Marking, Scaling, Animating, Scrolling
- };
-
- private class Surface extends Canvas {
-
- public Surface(Composite parent) {
- super(parent, SWT.NO_BACKGROUND | SWT.V_SCROLL | SWT.H_SCROLL);
- Display display = getDisplay();
- mNormalCursor = new Cursor(display, SWT.CURSOR_CROSS);
- mIncreasingCursor = new Cursor(display, SWT.CURSOR_SIZEE);
- mDecreasingCursor = new Cursor(display, SWT.CURSOR_SIZEW);
-
- initZoomFractionsWithExp();
-
- addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent pe) {
- draw(pe.display, pe.gc);
- }
- });
-
- mZoomAnimator = new Runnable() {
- @Override
- public void run() {
- animateZoom();
- }
- };
-
- mHighlightAnimator = new Runnable() {
- @Override
- public void run() {
- animateHighlight();
- }
- };
- }
-
- private void initZoomFractionsWithExp() {
- mZoomFractions = new double[ZOOM_STEPS];
- int next = 0;
- for (int ii = 0; ii < ZOOM_STEPS / 2; ++ii, ++next) {
- mZoomFractions[next] = (double) (1 << ii)
- / (double) (1 << (ZOOM_STEPS / 2));
- // System.out.printf("%d %f\n", next, zoomFractions[next]);
- }
- for (int ii = 2; ii < 2 + ZOOM_STEPS / 2; ++ii, ++next) {
- mZoomFractions[next] = (double) ((1 << ii) - 1)
- / (double) (1 << ii);
- // System.out.printf("%d %f\n", next, zoomFractions[next]);
- }
- }
-
- @SuppressWarnings("unused")
- private void initZoomFractionsWithSinWave() {
- mZoomFractions = new double[ZOOM_STEPS];
- for (int ii = 0; ii < ZOOM_STEPS; ++ii) {
- double offset = Math.PI * ii / ZOOM_STEPS;
- mZoomFractions[ii] = (Math.sin((1.5 * Math.PI + offset)) + 1.0) / 2.0;
- // System.out.printf("%d %f\n", ii, zoomFractions[ii]);
- }
- }
-
- public void setRange(double minVal, double maxVal) {
- mMinDataVal = minVal;
- mMaxDataVal = maxVal;
- mScaleInfo.setMinVal(minVal);
- mScaleInfo.setMaxVal(maxVal);
- }
-
- public void setLimitRange(double minVal, double maxVal) {
- mLimitMinVal = minVal;
- mLimitMaxVal = maxVal;
- }
-
- public void resetScale() {
- mScaleInfo.setMinVal(mLimitMinVal);
- mScaleInfo.setMaxVal(mLimitMaxVal);
- }
-
- public void setScaleFromHorizontalScrollBar(int selection) {
- double minVal = mScaleInfo.getMinVal();
- double maxVal = mScaleInfo.getMaxVal();
- double visibleRange = maxVal - minVal;
-
- minVal = mLimitMinVal + selection;
- maxVal = minVal + visibleRange;
- if (maxVal > mLimitMaxVal) {
- maxVal = mLimitMaxVal;
- minVal = maxVal - visibleRange;
- }
- mScaleInfo.setMinVal(minVal);
- mScaleInfo.setMaxVal(maxVal);
-
- mGraphicsState = GraphicsState.Scrolling;
- }
-
- private void updateHorizontalScrollBar() {
- double minVal = mScaleInfo.getMinVal();
- double maxVal = mScaleInfo.getMaxVal();
- double visibleRange = maxVal - minVal;
- double fullRange = mLimitMaxVal - mLimitMinVal;
-
- ScrollBar hBar = getHorizontalBar();
- if (fullRange > visibleRange) {
- hBar.setVisible(true);
- hBar.setMinimum(0);
- hBar.setMaximum((int)Math.ceil(fullRange));
- hBar.setThumb((int)Math.ceil(visibleRange));
- hBar.setSelection((int)Math.floor(minVal - mLimitMinVal));
- } else {
- hBar.setVisible(false);
- }
- }
-
- private void draw(Display display, GC gc) {
- if (mSegments.length == 0) {
- // gc.setBackground(colorBackground);
- // gc.fillRectangle(getBounds());
- return;
- }
-
- // Create an image for double-buffering
- Image image = new Image(display, getBounds());
-
- // Set up the off-screen gc
- GC gcImage = new GC(image);
- if (mSetFonts)
- gcImage.setFont(mFontRegistry.get("small")); //$NON-NLS-1$
-
- // Draw the background
- // gcImage.setBackground(colorBackground);
- // gcImage.fillRectangle(image.getBounds());
-
- if (mGraphicsState == GraphicsState.Scaling) {
- double diff = mMouse.x - mMouseMarkStartX;
- if (diff > 0) {
- double newMinVal = mScaleMinVal - diff / mScalePixelsPerRange;
- if (newMinVal < mLimitMinVal)
- newMinVal = mLimitMinVal;
- mScaleInfo.setMinVal(newMinVal);
- // System.out.printf("diff %f scaleMin %f newMin %f\n",
- // diff, scaleMinVal, newMinVal);
- } else if (diff < 0) {
- double newMaxVal = mScaleMaxVal - diff / mScalePixelsPerRange;
- if (newMaxVal > mLimitMaxVal)
- newMaxVal = mLimitMaxVal;
- mScaleInfo.setMaxVal(newMaxVal);
- // System.out.printf("diff %f scaleMax %f newMax %f\n",
- // diff, scaleMaxVal, newMaxVal);
- }
- }
-
- // Recompute the ticks and strips only if the size has changed,
- // or we scrolled so that a new row is visible.
- Point dim = getSize();
- if (mStartRow != mCachedStartRow || mEndRow != mCachedEndRow
- || mScaleInfo.getMinVal() != mCachedMinVal
- || mScaleInfo.getMaxVal() != mCachedMaxVal) {
- mCachedStartRow = mStartRow;
- mCachedEndRow = mEndRow;
- int xdim = dim.x - TotalXMargin;
- mScaleInfo.setNumPixels(xdim);
- boolean forceEndPoints = (mGraphicsState == GraphicsState.Scaling
- || mGraphicsState == GraphicsState.Animating
- || mGraphicsState == GraphicsState.Scrolling);
- mScaleInfo.computeTicks(forceEndPoints);
- mCachedMinVal = mScaleInfo.getMinVal();
- mCachedMaxVal = mScaleInfo.getMaxVal();
- if (mLimitMinVal > mScaleInfo.getMinVal())
- mLimitMinVal = mScaleInfo.getMinVal();
- if (mLimitMaxVal < mScaleInfo.getMaxVal())
- mLimitMaxVal = mScaleInfo.getMaxVal();
-
- // Compute the strips
- computeStrips();
-
- // Update the horizontal scrollbar.
- updateHorizontalScrollBar();
- }
-
- if (mNumRows > 2) {
- // Draw the row background stripes
- gcImage.setBackground(mColorRowBack);
- for (int ii = 1; ii < mNumRows; ii += 2) {
- RowData rd = mRows[ii];
- int y1 = rd.mRank * rowYSpace - mScrollOffsetY;
- gcImage.fillRectangle(0, y1, dim.x, rowYSpace);
- }
- }
-
- if (drawingSelection()) {
- drawSelection(display, gcImage);
- }
-
- String blockName = null;
- Color blockColor = null;
- String blockDetails = null;
-
- if (mDebug) {
- double pixelsPerRange = mScaleInfo.getPixelsPerRange();
- System.out
- .printf(
- "dim.x %d pixels %d minVal %f, maxVal %f ppr %f rpp %f\n",
- dim.x, dim.x - TotalXMargin, mScaleInfo
- .getMinVal(), mScaleInfo.getMaxVal(),
- pixelsPerRange, 1.0 / pixelsPerRange);
- }
-
- // Draw the strips
- Block selectBlock = null;
- for (Strip strip : mStripList) {
- if (strip.mColor == null) {
- // System.out.printf("strip.color is null\n");
- continue;
- }
- gcImage.setBackground(strip.mColor);
- gcImage.fillRectangle(strip.mX, strip.mY - mScrollOffsetY, strip.mWidth,
- strip.mHeight);
- if (mMouseRow == strip.mRowData.mRank) {
- if (mMouse.x >= strip.mX
- && mMouse.x < strip.mX + strip.mWidth) {
- Block block = strip.mSegment.mBlock;
- blockName = block.getName();
- blockColor = strip.mColor;
- if (mHaveCpuTime) {
- if (mHaveRealTime) {
- blockDetails = String.format(
- "excl cpu %s, incl cpu %s, "
- + "excl real %s, incl real %s",
- mUnits.labelledString(block.getExclusiveCpuTime()),
- mUnits.labelledString(block.getInclusiveCpuTime()),
- mUnits.labelledString(block.getExclusiveRealTime()),
- mUnits.labelledString(block.getInclusiveRealTime()));
- } else {
- blockDetails = String.format(
- "excl cpu %s, incl cpu %s",
- mUnits.labelledString(block.getExclusiveCpuTime()),
- mUnits.labelledString(block.getInclusiveCpuTime()));
- }
- } else {
- blockDetails = String.format(
- "excl real %s, incl real %s",
- mUnits.labelledString(block.getExclusiveRealTime()),
- mUnits.labelledString(block.getInclusiveRealTime()));
- }
- }
- if (mMouseSelect.x >= strip.mX
- && mMouseSelect.x < strip.mX + strip.mWidth) {
- selectBlock = strip.mSegment.mBlock;
- }
- }
- }
- mMouseSelect.x = 0;
- mMouseSelect.y = 0;
-
- if (selectBlock != null) {
- ArrayList<Selection> selections = new ArrayList<Selection>();
- // Get the row label
- RowData rd = mRows[mMouseRow];
- selections.add(Selection.highlight("Thread", rd.mName)); //$NON-NLS-1$
- selections.add(Selection.highlight("Call", selectBlock)); //$NON-NLS-1$
-
- int mouseX = mMouse.x - LeftMargin;
- double mouseXval = mScaleInfo.pixelToValue(mouseX);
- selections.add(Selection.highlight("Time", mouseXval)); //$NON-NLS-1$
-
- mSelectionController.change(selections, "TimeLineView"); //$NON-NLS-1$
- mHighlightMethodData = null;
- mHighlightCall = (Call) selectBlock;
- startHighlighting();
- }
-
- // Draw a highlight box on the row where the mouse is.
- // Except don't draw the box if we are animating the
- // highlighing of a call or method because the inclusive
- // highlight bar passes through the highlight box and
- // causes an annoying flashing artifact.
- if (mMouseRow >= 0 && mMouseRow < mNumRows && mHighlightStep == 0) {
- gcImage.setForeground(mColorGray);
- int y1 = mMouseRow * rowYSpace - mScrollOffsetY;
- gcImage.drawLine(0, y1, dim.x, y1);
- gcImage.drawLine(0, y1 + rowYSpace, dim.x, y1 + rowYSpace);
- }
-
- // Highlight a selected method, if any
- drawHighlights(gcImage, dim);
-
- // Draw a vertical line where the mouse is.
- gcImage.setForeground(mColorDarkGray);
- int lineEnd = Math.min(dim.y, mNumRows * rowYSpace);
- gcImage.drawLine(mMouse.x, 0, mMouse.x, lineEnd);
-
- if (blockName != null) {
- mTimescale.setMethodName(blockName);
- mTimescale.setMethodColor(blockColor);
- mTimescale.setDetails(blockDetails);
- mShowHighlightName = false;
- } else if (mShowHighlightName) {
- // Draw the highlighted method name
- MethodData md = mHighlightMethodData;
- if (md == null && mHighlightCall != null)
- md = mHighlightCall.getMethodData();
- if (md == null)
- System.out.printf("null highlight?\n"); //$NON-NLS-1$
- if (md != null) {
- mTimescale.setMethodName(md.getProfileName());
- mTimescale.setMethodColor(md.getColor());
- mTimescale.setDetails(null);
- }
- } else {
- mTimescale.setMethodName(null);
- mTimescale.setMethodColor(null);
- mTimescale.setDetails(null);
- }
- mTimescale.redraw();
-
- // Draw the off-screen buffer to the screen
- gc.drawImage(image, 0, 0);
-
- // Clean up
- image.dispose();
- gcImage.dispose();
- }
-
- private void drawHighlights(GC gc, Point dim) {
- int height = mHighlightHeight;
- if (height <= 0)
- return;
- for (Range range : mHighlightExclusive) {
- gc.setBackground(range.mColor);
- int xStart = range.mXdim.x;
- int width = range.mXdim.y;
- gc.fillRectangle(xStart, range.mY - height - mScrollOffsetY, width, height);
- }
-
- // Draw the inclusive lines a bit shorter
- height -= 1;
- if (height <= 0)
- height = 1;
-
- // Highlight the inclusive ranges
- gc.setForeground(mColorDarkGray);
- gc.setBackground(mColorDarkGray);
- for (Range range : mHighlightInclusive) {
- int x1 = range.mXdim.x;
- int x2 = range.mXdim.y;
- boolean drawLeftEnd = false;
- boolean drawRightEnd = false;
- if (x1 >= LeftMargin)
- drawLeftEnd = true;
- else
- x1 = LeftMargin;
- if (x2 >= LeftMargin)
- drawRightEnd = true;
- else
- x2 = dim.x - RightMargin;
- int y1 = range.mY + rowHeight + 2 - mScrollOffsetY;
-
- // If the range is very narrow, then just draw a small
- // rectangle.
- if (x2 - x1 < MinInclusiveRange) {
- int width = x2 - x1;
- if (width < 2)
- width = 2;
- gc.fillRectangle(x1, y1, width, height);
- continue;
- }
- if (drawLeftEnd) {
- if (drawRightEnd) {
- // Draw both ends
- int[] points = { x1, y1, x1, y1 + height, x2,
- y1 + height, x2, y1 };
- gc.drawPolyline(points);
- } else {
- // Draw the left end
- int[] points = { x1, y1, x1, y1 + height, x2,
- y1 + height };
- gc.drawPolyline(points);
- }
- } else {
- if (drawRightEnd) {
- // Draw the right end
- int[] points = { x1, y1 + height, x2, y1 + height, x2,
- y1 };
- gc.drawPolyline(points);
- } else {
- // Draw neither end, just the line
- int[] points = { x1, y1 + height, x2, y1 + height };
- gc.drawPolyline(points);
- }
- }
-
- // Draw the arrowheads, if necessary
- if (drawLeftEnd == false) {
- int[] points = { x1 + 7, y1 + height - 4, x1, y1 + height,
- x1 + 7, y1 + height + 4 };
- gc.fillPolygon(points);
- }
- if (drawRightEnd == false) {
- int[] points = { x2 - 7, y1 + height - 4, x2, y1 + height,
- x2 - 7, y1 + height + 4 };
- gc.fillPolygon(points);
- }
- }
- }
-
- private boolean drawingSelection() {
- return mGraphicsState == GraphicsState.Marking
- || mGraphicsState == GraphicsState.Animating;
- }
-
- private void drawSelection(Display display, GC gc) {
- Point dim = getSize();
- gc.setForeground(mColorGray);
- gc.drawLine(mMouseMarkStartX, 0, mMouseMarkStartX, dim.y);
- gc.setBackground(mColorZoomSelection);
- int width;
- int mouseX = (mGraphicsState == GraphicsState.Animating) ? mMouseMarkEndX : mMouse.x;
- int x;
- if (mMouseMarkStartX < mouseX) {
- x = mMouseMarkStartX;
- width = mouseX - mMouseMarkStartX;
- } else {
- x = mouseX;
- width = mMouseMarkStartX - mouseX;
- }
- gc.fillRectangle(x, 0, width, dim.y);
- }
-
- private void computeStrips() {
- double minVal = mScaleInfo.getMinVal();
- double maxVal = mScaleInfo.getMaxVal();
-
- // Allocate space for the pixel data
- Pixel[] pixels = new Pixel[mNumRows];
- for (int ii = 0; ii < mNumRows; ++ii)
- pixels[ii] = new Pixel();
-
- // Clear the per-block pixel data
- for (int ii = 0; ii < mSegments.length; ++ii) {
- mSegments[ii].mBlock.clearWeight();
- }
-
- mStripList.clear();
- mHighlightExclusive.clear();
- mHighlightInclusive.clear();
- MethodData callMethod = null;
- long callStart = 0;
- long callEnd = -1;
- RowData callRowData = null;
- int prevMethodStart = -1;
- int prevMethodEnd = -1;
- int prevCallStart = -1;
- int prevCallEnd = -1;
- if (mHighlightCall != null) {
- int callPixelStart = -1;
- int callPixelEnd = -1;
- callStart = mHighlightCall.getStartTime();
- callEnd = mHighlightCall.getEndTime();
- callMethod = mHighlightCall.getMethodData();
- if (callStart >= minVal)
- callPixelStart = mScaleInfo.valueToPixel(callStart);
- if (callEnd <= maxVal)
- callPixelEnd = mScaleInfo.valueToPixel(callEnd);
- // System.out.printf("callStart,End %d,%d minVal,maxVal %f,%f
- // callPixelStart,End %d,%d\n",
- // callStart, callEnd, minVal, maxVal, callPixelStart,
- // callPixelEnd);
- int threadId = mHighlightCall.getThreadId();
- String threadName = mThreadLabels.get(threadId);
- callRowData = mRowByName.get(threadName);
- int y1 = callRowData.mRank * rowYSpace + rowYMarginHalf;
- Color color = callMethod.getColor();
- mHighlightInclusive.add(new Range(callPixelStart + LeftMargin,
- callPixelEnd + LeftMargin, y1, color));
- }
- for (Segment segment : mSegments) {
- if (segment.mEndTime <= minVal)
- continue;
- if (segment.mStartTime >= maxVal)
- continue;
-
- Block block = segment.mBlock;
-
- // Skip over blocks that were not assigned a color, including the
- // top level block and others that have zero inclusive time.
- Color color = block.getColor();
- if (color == null)
- continue;
-
- double recordStart = Math.max(segment.mStartTime, minVal);
- double recordEnd = Math.min(segment.mEndTime, maxVal);
- if (recordStart == recordEnd)
- continue;
- int pixelStart = mScaleInfo.valueToPixel(recordStart);
- int pixelEnd = mScaleInfo.valueToPixel(recordEnd);
- int width = pixelEnd - pixelStart;
- boolean isContextSwitch = segment.mIsContextSwitch;
-
- RowData rd = segment.mRowData;
- MethodData md = block.getMethodData();
-
- // We will add the scroll offset later when we draw the strips
- int y1 = rd.mRank * rowYSpace + rowYMarginHalf;
-
- // If we can't display any more rows, then quit
- if (rd.mRank > mEndRow)
- break;
-
- // System.out.printf("segment %s val: [%.1f, %.1f] frac [%f, %f]
- // pixel: [%d, %d] pix.start %d weight %.2f %s\n",
- // block.getName(), recordStart, recordEnd,
- // scaleInfo.valueToPixelFraction(recordStart),
- // scaleInfo.valueToPixelFraction(recordEnd),
- // pixelStart, pixelEnd, pixels[rd.rank].start,
- // pixels[rd.rank].maxWeight,
- // pixels[rd.rank].segment != null
- // ? pixels[rd.rank].segment.block.getName()
- // : "null");
-
- if (mHighlightMethodData != null) {
- if (mHighlightMethodData == md) {
- if (prevMethodStart != pixelStart || prevMethodEnd != pixelEnd) {
- prevMethodStart = pixelStart;
- prevMethodEnd = pixelEnd;
- int rangeWidth = width;
- if (rangeWidth == 0)
- rangeWidth = 1;
- mHighlightExclusive.add(new Range(pixelStart
- + LeftMargin, rangeWidth, y1, color));
- callStart = block.getStartTime();
- int callPixelStart = -1;
- if (callStart >= minVal)
- callPixelStart = mScaleInfo.valueToPixel(callStart);
- int callPixelEnd = -1;
- callEnd = block.getEndTime();
- if (callEnd <= maxVal)
- callPixelEnd = mScaleInfo.valueToPixel(callEnd);
- if (prevCallStart != callPixelStart || prevCallEnd != callPixelEnd) {
- prevCallStart = callPixelStart;
- prevCallEnd = callPixelEnd;
- mHighlightInclusive.add(new Range(
- callPixelStart + LeftMargin,
- callPixelEnd + LeftMargin, y1, color));
- }
- }
- } else if (mFadeColors) {
- color = md.getFadedColor();
- }
- } else if (mHighlightCall != null) {
- if (segment.mStartTime >= callStart
- && segment.mEndTime <= callEnd && callMethod == md
- && callRowData == rd) {
- if (prevMethodStart != pixelStart || prevMethodEnd != pixelEnd) {
- prevMethodStart = pixelStart;
- prevMethodEnd = pixelEnd;
- int rangeWidth = width;
- if (rangeWidth == 0)
- rangeWidth = 1;
- mHighlightExclusive.add(new Range(pixelStart
- + LeftMargin, rangeWidth, y1, color));
- }
- } else if (mFadeColors) {
- color = md.getFadedColor();
- }
- }
-
- // Cases:
- // 1. This segment starts on a different pixel than the
- // previous segment started on. In this case, emit
- // the pixel strip, if any, and:
- // A. If the width is 0, then add this segment's
- // weight to the Pixel.
- // B. If the width > 0, then emit a strip for this
- // segment (no partial Pixel data).
- //
- // 2. Otherwise (the new segment starts on the same
- // pixel as the previous segment): add its "weight"
- // to the current pixel, and:
- // A. If the new segment has width 1,
- // then emit the pixel strip and then
- // add the segment's weight to the pixel.
- // B. If the new segment has width > 1,
- // then emit the pixel strip, and emit the rest
- // of the strip for this segment (no partial Pixel
- // data).
-
- Pixel pix = pixels[rd.mRank];
- if (pix.mStart != pixelStart) {
- if (pix.mSegment != null) {
- // Emit the pixel strip. This also clears the pixel.
- emitPixelStrip(rd, y1, pix);
- }
-
- if (width == 0) {
- // Compute the "weight" of this segment for the first
- // pixel. For a pixel N, the "weight" of a segment is
- // how much of the region [N - 0.5, N + 0.5] is covered
- // by the segment.
- double weight = computeWeight(recordStart, recordEnd,
- isContextSwitch, pixelStart);
- weight = block.addWeight(pixelStart, rd.mRank, weight);
- if (weight > pix.mMaxWeight) {
- pix.setFields(pixelStart, weight, segment, color,
- rd);
- }
- } else {
- int x1 = pixelStart + LeftMargin;
- Strip strip = new Strip(
- x1, isContextSwitch ? y1 + rowHeight - 1 : y1,
- width, isContextSwitch ? 1 : rowHeight,
- rd, segment, color);
- mStripList.add(strip);
- }
- } else {
- double weight = computeWeight(recordStart, recordEnd,
- isContextSwitch, pixelStart);
- weight = block.addWeight(pixelStart, rd.mRank, weight);
- if (weight > pix.mMaxWeight) {
- pix.setFields(pixelStart, weight, segment, color, rd);
- }
- if (width == 1) {
- // Emit the pixel strip. This also clears the pixel.
- emitPixelStrip(rd, y1, pix);
-
- // Compute the weight for the next pixel
- pixelStart += 1;
- weight = computeWeight(recordStart, recordEnd,
- isContextSwitch, pixelStart);
- weight = block.addWeight(pixelStart, rd.mRank, weight);
- pix.setFields(pixelStart, weight, segment, color, rd);
- } else if (width > 1) {
- // Emit the pixel strip. This also clears the pixel.
- emitPixelStrip(rd, y1, pix);
-
- // Emit a strip for the rest of the segment.
- pixelStart += 1;
- width -= 1;
- int x1 = pixelStart + LeftMargin;
- Strip strip = new Strip(
- x1, isContextSwitch ? y1 + rowHeight - 1 : y1,
- width, isContextSwitch ? 1 : rowHeight,
- rd,segment, color);
- mStripList.add(strip);
- }
- }
- }
-
- // Emit the last pixels of each row, if any
- for (int ii = 0; ii < mNumRows; ++ii) {
- Pixel pix = pixels[ii];
- if (pix.mSegment != null) {
- RowData rd = pix.mRowData;
- int y1 = rd.mRank * rowYSpace + rowYMarginHalf;
- // Emit the pixel strip. This also clears the pixel.
- emitPixelStrip(rd, y1, pix);
- }
- }
-
- if (false) {
- System.out.printf("computeStrips()\n");
- for (Strip strip : mStripList) {
- System.out.printf("%3d, %3d width %3d height %d %s\n",
- strip.mX, strip.mY, strip.mWidth, strip.mHeight,
- strip.mSegment.mBlock.getName());
- }
- }
- }
-
- private double computeWeight(double start, double end,
- boolean isContextSwitch, int pixel) {
- if (isContextSwitch) {
- return 0;
- }
- double pixelStartFraction = mScaleInfo.valueToPixelFraction(start);
- double pixelEndFraction = mScaleInfo.valueToPixelFraction(end);
- double leftEndPoint = Math.max(pixelStartFraction, pixel - 0.5);
- double rightEndPoint = Math.min(pixelEndFraction, pixel + 0.5);
- double weight = rightEndPoint - leftEndPoint;
- return weight;
- }
-
- private void emitPixelStrip(RowData rd, int y, Pixel pixel) {
- Strip strip;
-
- if (pixel.mSegment == null)
- return;
-
- int x = pixel.mStart + LeftMargin;
- // Compute the percentage of the row height proportional to
- // the weight of this pixel. But don't let the proportion
- // exceed 3/4 of the row height so that we can easily see
- // if a given time range includes more than one method.
- int height = (int) (pixel.mMaxWeight * rowHeight * 0.75);
- if (height < mMinStripHeight)
- height = mMinStripHeight;
- int remainder = rowHeight - height;
- if (remainder > 0) {
- strip = new Strip(x, y, 1, remainder, rd, pixel.mSegment,
- mFadeColors ? mColorGray : mColorBlack);
- mStripList.add(strip);
- // System.out.printf("emitPixel (%d, %d) height %d black\n",
- // x, y, remainder);
- }
- strip = new Strip(x, y + remainder, 1, height, rd, pixel.mSegment,
- pixel.mColor);
- mStripList.add(strip);
- // System.out.printf("emitPixel (%d, %d) height %d %s\n",
- // x, y + remainder, height, pixel.segment.block.getName());
- pixel.mSegment = null;
- pixel.mMaxWeight = 0.0;
- }
-
- private void mouseMove(MouseEvent me) {
- if (false) {
- if (mHighlightMethodData != null) {
- mHighlightMethodData = null;
- // Force a recomputation of the strip colors
- mCachedEndRow = -1;
- }
- }
- Point dim = mSurface.getSize();
- int x = me.x;
- if (x < LeftMargin)
- x = LeftMargin;
- if (x > dim.x - RightMargin)
- x = dim.x - RightMargin;
- mMouse.x = x;
- mMouse.y = me.y;
- mTimescale.setVbarPosition(x);
- if (mGraphicsState == GraphicsState.Marking) {
- mTimescale.setMarkEnd(x);
- }
-
- if (mGraphicsState == GraphicsState.Normal) {
- // Set the cursor to the normal state.
- mSurface.setCursor(mNormalCursor);
- } else if (mGraphicsState == GraphicsState.Marking) {
- // Make the cursor point in the direction of the sweep
- if (mMouse.x >= mMouseMarkStartX)
- mSurface.setCursor(mIncreasingCursor);
- else
- mSurface.setCursor(mDecreasingCursor);
- }
- int rownum = (mMouse.y + mScrollOffsetY) / rowYSpace;
- if (me.y < 0 || me.y >= dim.y) {
- rownum = -1;
- }
- if (mMouseRow != rownum) {
- mMouseRow = rownum;
- mLabels.redraw();
- }
- redraw();
- }
-
- private void mouseDown(MouseEvent me) {
- Point dim = mSurface.getSize();
- int x = me.x;
- if (x < LeftMargin)
- x = LeftMargin;
- if (x > dim.x - RightMargin)
- x = dim.x - RightMargin;
- mMouseMarkStartX = x;
- mGraphicsState = GraphicsState.Marking;
- mSurface.setCursor(mIncreasingCursor);
- mTimescale.setMarkStart(mMouseMarkStartX);
- mTimescale.setMarkEnd(mMouseMarkStartX);
- redraw();
- }
-
- private void mouseUp(MouseEvent me) {
- mSurface.setCursor(mNormalCursor);
- if (mGraphicsState != GraphicsState.Marking) {
- mGraphicsState = GraphicsState.Normal;
- return;
- }
- mGraphicsState = GraphicsState.Animating;
- Point dim = mSurface.getSize();
-
- // If the user released the mouse outside the drawing area then
- // cancel the zoom.
- if (me.y <= 0 || me.y >= dim.y) {
- mGraphicsState = GraphicsState.Normal;
- redraw();
- return;
- }
-
- int x = me.x;
- if (x < LeftMargin)
- x = LeftMargin;
- if (x > dim.x - RightMargin)
- x = dim.x - RightMargin;
- mMouseMarkEndX = x;
-
- // If the user clicked and released the mouse at the same point
- // (+/- a pixel or two) then cancel the zoom (but select the
- // method).
- int dist = mMouseMarkEndX - mMouseMarkStartX;
- if (dist < 0)
- dist = -dist;
- if (dist <= 2) {
- mGraphicsState = GraphicsState.Normal;
-
- // Select the method underneath the mouse
- mMouseSelect.x = mMouseMarkStartX;
- mMouseSelect.y = me.y;
- redraw();
- return;
- }
-
- // Make mouseEndX be the higher end point
- if (mMouseMarkEndX < mMouseMarkStartX) {
- int temp = mMouseMarkEndX;
- mMouseMarkEndX = mMouseMarkStartX;
- mMouseMarkStartX = temp;
- }
-
- // If the zoom area is the whole window (or nearly the whole
- // window) then cancel the zoom.
- if (mMouseMarkStartX <= LeftMargin + MinZoomPixelMargin
- && mMouseMarkEndX >= dim.x - RightMargin - MinZoomPixelMargin) {
- mGraphicsState = GraphicsState.Normal;
- redraw();
- return;
- }
-
- // Compute some variables needed for zooming.
- // It's probably easiest to explain by an example. There
- // are two scales (or dimensions) involved: one for the pixels
- // and one for the values (microseconds). To keep the example
- // simple, suppose we have pixels in the range [0,16] and
- // values in the range [100, 260], and suppose the user
- // selects a zoom window from pixel 4 to pixel 8.
- //
- // usec: 100 140 180 260
- // |-------|ZZZZZZZ|---------------|
- // pixel: 0 4 8 16
- //
- // I've drawn the pixels starting at zero for simplicity, but
- // in fact the drawable area is offset from the left margin
- // by the value of "LeftMargin".
- //
- // The "pixels-per-range" (ppr) in this case is 0.1 (a tenth of
- // a pixel per usec). What we want is to redraw the screen in
- // several steps, each time increasing the zoom window until the
- // zoom window fills the screen. For simplicity, assume that
- // we want to zoom in four equal steps. Then the snapshots
- // of the screen at each step would look something like this:
- //
- // usec: 100 140 180 260
- // |-------|ZZZZZZZ|---------------|
- // pixel: 0 4 8 16
- //
- // usec: ? 140 180 ?
- // |-----|ZZZZZZZZZZZZZ|-----------|
- // pixel: 0 3 10 16
- //
- // usec: ? 140 180 ?
- // |---|ZZZZZZZZZZZZZZZZZZZ|-------|
- // pixel: 0 2 12 16
- //
- // usec: ?140 180 ?
- // |-|ZZZZZZZZZZZZZZZZZZZZZZZZZ|---|
- // pixel: 0 1 14 16
- //
- // usec: 140 180
- // |ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ|
- // pixel: 0 16
- //
- // The problem is how to compute the endpoints (denoted by ?)
- // for each step. This is a little tricky. We first need to
- // compute the "fixed point": this is the point in the selection
- // that doesn't move left or right. Then we can recompute the
- // "ppr" (pixels per range) at each step and then find the
- // endpoints. The computation of the end points is done
- // in animateZoom(). This method computes the fixed point
- // and some other variables needed in animateZoom().
-
- double minVal = mScaleInfo.getMinVal();
- double maxVal = mScaleInfo.getMaxVal();
- double ppr = mScaleInfo.getPixelsPerRange();
- mZoomMin = minVal + ((mMouseMarkStartX - LeftMargin) / ppr);
- mZoomMax = minVal + ((mMouseMarkEndX - LeftMargin) / ppr);
-
- // Clamp the min and max values to the actual data min and max
- if (mZoomMin < mMinDataVal)
- mZoomMin = mMinDataVal;
- if (mZoomMax > mMaxDataVal)
- mZoomMax = mMaxDataVal;
-
- // Snap the min and max points to the grid determined by the
- // TickScaler
- // before we zoom.
- int xdim = dim.x - TotalXMargin;
- TickScaler scaler = new TickScaler(mZoomMin, mZoomMax, xdim,
- PixelsPerTick);
- scaler.computeTicks(false);
- mZoomMin = scaler.getMinVal();
- mZoomMax = scaler.getMaxVal();
-
- // Also snap the mouse points (in pixel space) to be consistent with
- // zoomMin and zoomMax (in value space).
- mMouseMarkStartX = (int) ((mZoomMin - minVal) * ppr + LeftMargin);
- mMouseMarkEndX = (int) ((mZoomMax - minVal) * ppr + LeftMargin);
- mTimescale.setMarkStart(mMouseMarkStartX);
- mTimescale.setMarkEnd(mMouseMarkEndX);
-
- // Compute the mouse selection end point distances
- mMouseEndDistance = dim.x - RightMargin - mMouseMarkEndX;
- mMouseStartDistance = mMouseMarkStartX - LeftMargin;
- mZoomMouseStart = mMouseMarkStartX;
- mZoomMouseEnd = mMouseMarkEndX;
- mZoomStep = 0;
-
- // Compute the fixed point in both value space and pixel space.
- mMin2ZoomMin = mZoomMin - minVal;
- mZoomMax2Max = maxVal - mZoomMax;
- mZoomFixed = mZoomMin + (mZoomMax - mZoomMin) * mMin2ZoomMin
- / (mMin2ZoomMin + mZoomMax2Max);
- mZoomFixedPixel = (mZoomFixed - minVal) * ppr + LeftMargin;
- mFixedPixelStartDistance = mZoomFixedPixel - LeftMargin;
- mFixedPixelEndDistance = dim.x - RightMargin - mZoomFixedPixel;
-
- mZoomMin2Fixed = mZoomFixed - mZoomMin;
- mFixed2ZoomMax = mZoomMax - mZoomFixed;
-
- getDisplay().timerExec(ZOOM_TIMER_INTERVAL, mZoomAnimator);
- redraw();
- update();
- }
-
- private void mouseScrolled(MouseEvent me) {
- mGraphicsState = GraphicsState.Scrolling;
- double tMin = mScaleInfo.getMinVal();
- double tMax = mScaleInfo.getMaxVal();
- double zoomFactor = 2;
- double tMinRef = mLimitMinVal;
- double tMaxRef = mLimitMaxVal;
- double t; // the fixed point
- double tMinNew;
- double tMaxNew;
- if (me.count > 0) {
- // we zoom in
- Point dim = mSurface.getSize();
- int x = me.x;
- if (x < LeftMargin)
- x = LeftMargin;
- if (x > dim.x - RightMargin)
- x = dim.x - RightMargin;
- double ppr = mScaleInfo.getPixelsPerRange();
- t = tMin + ((x - LeftMargin) / ppr);
- tMinNew = Math.max(tMinRef, t - (t - tMin) / zoomFactor);
- tMaxNew = Math.min(tMaxRef, t + (tMax - t) / zoomFactor);
- } else {
- // we zoom out
- double factor = (tMax - tMin) / (tMaxRef - tMinRef);
- if (factor < 1) {
- t = (factor * tMinRef - tMin) / (factor - 1);
- tMinNew = Math.max(tMinRef, t - zoomFactor * (t - tMin));
- tMaxNew = Math.min(tMaxRef, t + zoomFactor * (tMax - t));
- } else {
- return;
- }
- }
- mScaleInfo.setMinVal(tMinNew);
- mScaleInfo.setMaxVal(tMaxNew);
- mSurface.redraw();
- }
-
- // No defined behavior yet for double-click.
- private void mouseDoubleClick(MouseEvent me) {
- }
-
- public void startScaling(int mouseX) {
- Point dim = mSurface.getSize();
- int x = mouseX;
- if (x < LeftMargin)
- x = LeftMargin;
- if (x > dim.x - RightMargin)
- x = dim.x - RightMargin;
- mMouseMarkStartX = x;
- mGraphicsState = GraphicsState.Scaling;
- mScalePixelsPerRange = mScaleInfo.getPixelsPerRange();
- mScaleMinVal = mScaleInfo.getMinVal();
- mScaleMaxVal = mScaleInfo.getMaxVal();
- }
-
- public void stopScaling(int mouseX) {
- mGraphicsState = GraphicsState.Normal;
- }
-
- private void animateHighlight() {
- mHighlightStep += 1;
- if (mHighlightStep >= HIGHLIGHT_STEPS) {
- mFadeColors = false;
- mHighlightStep = 0;
- // Force a recomputation of the strip colors
- mCachedEndRow = -1;
- } else {
- mFadeColors = true;
- mShowHighlightName = true;
- mHighlightHeight = highlightHeights[mHighlightStep];
- getDisplay().timerExec(HIGHLIGHT_TIMER_INTERVAL, mHighlightAnimator);
- }
- redraw();
- }
-
- private void clearHighlights() {
- // System.out.printf("clearHighlights()\n");
- mShowHighlightName = false;
- mHighlightHeight = 0;
- mHighlightMethodData = null;
- mHighlightCall = null;
- mFadeColors = false;
- mHighlightStep = 0;
- // Force a recomputation of the strip colors
- mCachedEndRow = -1;
- redraw();
- }
-
- private void animateZoom() {
- mZoomStep += 1;
- if (mZoomStep > ZOOM_STEPS) {
- mGraphicsState = GraphicsState.Normal;
- // Force a normal recomputation
- mCachedMinVal = mScaleInfo.getMinVal() + 1;
- } else if (mZoomStep == ZOOM_STEPS) {
- mScaleInfo.setMinVal(mZoomMin);
- mScaleInfo.setMaxVal(mZoomMax);
- mMouseMarkStartX = LeftMargin;
- Point dim = getSize();
- mMouseMarkEndX = dim.x - RightMargin;
- mTimescale.setMarkStart(mMouseMarkStartX);
- mTimescale.setMarkEnd(mMouseMarkEndX);
- getDisplay().timerExec(ZOOM_TIMER_INTERVAL, mZoomAnimator);
- } else {
- // Zoom in slowly at first, then speed up, then slow down.
- // The zoom fractions are precomputed to save time.
- double fraction = mZoomFractions[mZoomStep];
- mMouseMarkStartX = (int) (mZoomMouseStart - fraction * mMouseStartDistance);
- mMouseMarkEndX = (int) (mZoomMouseEnd + fraction * mMouseEndDistance);
- mTimescale.setMarkStart(mMouseMarkStartX);
- mTimescale.setMarkEnd(mMouseMarkEndX);
-
- // Compute the new pixels-per-range. Avoid division by zero.
- double ppr;
- if (mZoomMin2Fixed >= mFixed2ZoomMax)
- ppr = (mZoomFixedPixel - mMouseMarkStartX) / mZoomMin2Fixed;
- else
- ppr = (mMouseMarkEndX - mZoomFixedPixel) / mFixed2ZoomMax;
- double newMin = mZoomFixed - mFixedPixelStartDistance / ppr;
- double newMax = mZoomFixed + mFixedPixelEndDistance / ppr;
- mScaleInfo.setMinVal(newMin);
- mScaleInfo.setMaxVal(newMax);
-
- getDisplay().timerExec(ZOOM_TIMER_INTERVAL, mZoomAnimator);
- }
- redraw();
- }
-
- private static final int TotalXMargin = LeftMargin + RightMargin;
- private static final int yMargin = 1; // blank space on top
- // The minimum margin on each side of the zoom window, in pixels.
- private static final int MinZoomPixelMargin = 10;
- private GraphicsState mGraphicsState = GraphicsState.Normal;
- private Point mMouse = new Point(LeftMargin, 0);
- private int mMouseMarkStartX;
- private int mMouseMarkEndX;
- private boolean mDebug = false;
- private ArrayList<Strip> mStripList = new ArrayList<Strip>();
- private ArrayList<Range> mHighlightExclusive = new ArrayList<Range>();
- private ArrayList<Range> mHighlightInclusive = new ArrayList<Range>();
- private int mMinStripHeight = 2;
- private double mCachedMinVal;
- private double mCachedMaxVal;
- private int mCachedStartRow;
- private int mCachedEndRow;
- private double mScalePixelsPerRange;
- private double mScaleMinVal;
- private double mScaleMaxVal;
- private double mLimitMinVal;
- private double mLimitMaxVal;
- private double mMinDataVal;
- private double mMaxDataVal;
- private Cursor mNormalCursor;
- private Cursor mIncreasingCursor;
- private Cursor mDecreasingCursor;
- private static final int ZOOM_TIMER_INTERVAL = 10;
- private static final int HIGHLIGHT_TIMER_INTERVAL = 50;
- private static final int ZOOM_STEPS = 8; // must be even
- private int mHighlightHeight = 4;
- private final int[] highlightHeights = { 0, 2, 4, 5, 6, 5, 4, 2, 4, 5,
- 6 };
- private final int HIGHLIGHT_STEPS = highlightHeights.length;
- private boolean mFadeColors;
- private boolean mShowHighlightName;
- private double[] mZoomFractions;
- private int mZoomStep;
- private int mZoomMouseStart;
- private int mZoomMouseEnd;
- private int mMouseStartDistance;
- private int mMouseEndDistance;
- private Point mMouseSelect = new Point(0, 0);
- private double mZoomFixed;
- private double mZoomFixedPixel;
- private double mFixedPixelStartDistance;
- private double mFixedPixelEndDistance;
- private double mZoomMin2Fixed;
- private double mMin2ZoomMin;
- private double mFixed2ZoomMax;
- private double mZoomMax2Max;
- private double mZoomMin;
- private double mZoomMax;
- private Runnable mZoomAnimator;
- private Runnable mHighlightAnimator;
- private int mHighlightStep;
- }
-
- private int computeVisibleRows(int ydim) {
- // If we resize, then move the bottom row down. Don't allow the scroll
- // to waste space at the bottom.
- int offsetY = mScrollOffsetY;
- int spaceNeeded = mNumRows * rowYSpace;
- if (offsetY + ydim > spaceNeeded) {
- offsetY = spaceNeeded - ydim;
- if (offsetY < 0) {
- offsetY = 0;
- }
- }
- mStartRow = offsetY / rowYSpace;
- mEndRow = (offsetY + ydim) / rowYSpace;
- if (mEndRow >= mNumRows) {
- mEndRow = mNumRows - 1;
- }
-
- return offsetY;
- }
-
- private void startHighlighting() {
- // System.out.printf("startHighlighting()\n");
- mSurface.mHighlightStep = 0;
- mSurface.mFadeColors = true;
- // Force a recomputation of the color strips
- mSurface.mCachedEndRow = -1;
- getDisplay().timerExec(0, mSurface.mHighlightAnimator);
- }
-
- private static class RowData {
- RowData(Row row) {
- mName = row.getName();
- mStack = new ArrayList<Block>();
- }
-
- public void push(Block block) {
- mStack.add(block);
- }
-
- public Block top() {
- if (mStack.size() == 0)
- return null;
- return mStack.get(mStack.size() - 1);
- }
-
- public void pop() {
- if (mStack.size() == 0)
- return;
- mStack.remove(mStack.size() - 1);
- }
-
- private String mName;
- private int mRank;
- private long mElapsed;
- private long mEndTime;
- private ArrayList<Block> mStack;
- }
-
- private static class Segment {
- Segment(RowData rowData, Block block, long startTime, long endTime) {
- mRowData = rowData;
- if (block.isContextSwitch()) {
- mBlock = block.getParentBlock();
- mIsContextSwitch = true;
- } else {
- mBlock = block;
- }
- mStartTime = startTime;
- mEndTime = endTime;
- }
-
- private RowData mRowData;
- private Block mBlock;
- private long mStartTime;
- private long mEndTime;
- private boolean mIsContextSwitch;
- }
-
- private static class Strip {
- Strip(int x, int y, int width, int height, RowData rowData,
- Segment segment, Color color) {
- mX = x;
- mY = y;
- mWidth = width;
- mHeight = height;
- mRowData = rowData;
- mSegment = segment;
- mColor = color;
- }
-
- int mX;
- int mY;
- int mWidth;
- int mHeight;
- RowData mRowData;
- Segment mSegment;
- Color mColor;
- }
-
- private static class Pixel {
- public void setFields(int start, double weight, Segment segment,
- Color color, RowData rowData) {
- mStart = start;
- mMaxWeight = weight;
- mSegment = segment;
- mColor = color;
- mRowData = rowData;
- }
-
- int mStart = -2; // some value that won't match another pixel
- double mMaxWeight;
- Segment mSegment;
- Color mColor; // we need the color here because it may be faded
- RowData mRowData;
- }
-
- private static class Range {
- Range(int xStart, int width, int y, Color color) {
- mXdim.x = xStart;
- mXdim.y = width;
- mY = y;
- mColor = color;
- }
-
- Point mXdim = new Point(0, 0);
- int mY;
- Color mColor;
- }
-}
diff --git a/traceview/src/com/android/traceview/TraceAction.java b/traceview/src/com/android/traceview/TraceAction.java
deleted file mode 100644
index 6717300..0000000
--- a/traceview/src/com/android/traceview/TraceAction.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-final class TraceAction {
- public static final int ACTION_ENTER = 0;
- public static final int ACTION_EXIT = 1;
- public static final int ACTION_INCOMPLETE = 2;
-
- public final int mAction;
- public final Call mCall;
-
- public TraceAction(int action, Call call) {
- mAction = action;
- mCall = call;
- }
-}
diff --git a/traceview/src/com/android/traceview/TraceReader.java b/traceview/src/com/android/traceview/TraceReader.java
deleted file mode 100644
index fa76d27..0000000
--- a/traceview/src/com/android/traceview/TraceReader.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-public abstract class TraceReader {
-
- private TraceUnits mTraceUnits;
-
- public TraceUnits getTraceUnits() {
- if (mTraceUnits == null)
- mTraceUnits = new TraceUnits();
- return mTraceUnits;
- }
-
- public ArrayList<TimeLineView.Record> getThreadTimeRecords() {
- return null;
- }
-
- public HashMap<Integer, String> getThreadLabels() {
- return null;
- }
-
- public MethodData[] getMethods() {
- return null;
- }
-
- public ThreadData[] getThreads() {
- return null;
- }
-
- public long getTotalCpuTime() {
- return 0;
- }
-
- public long getTotalRealTime() {
- return 0;
- }
-
- public boolean haveCpuTime() {
- return false;
- }
-
- public boolean haveRealTime() {
- return false;
- }
-
- public HashMap<String, String> getProperties() {
- return null;
- }
-
- public ProfileProvider getProfileProvider() {
- return null;
- }
-
- public TimeBase getPreferredTimeBase() {
- return TimeBase.CPU_TIME;
- }
-
- public String getClockSource() {
- return null;
- }
-}
diff --git a/traceview/src/com/android/traceview/TraceUnits.java b/traceview/src/com/android/traceview/TraceUnits.java
deleted file mode 100644
index 20938f5..0000000
--- a/traceview/src/com/android/traceview/TraceUnits.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * Copyright (C) 2006 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.traceview;
-
-import java.text.DecimalFormat;
-
-// This should be a singleton.
-public class TraceUnits {
-
- private TimeScale mTimeScale = TimeScale.MicroSeconds;
- private double mScale = 1.0;
- DecimalFormat mFormatter = new DecimalFormat();
-
- public double getScaledValue(long value) {
- return value * mScale;
- }
-
- public double getScaledValue(double value) {
- return value * mScale;
- }
-
- public String valueOf(long value) {
- return valueOf((double) value);
- }
-
- public String valueOf(double value) {
- String pattern;
- double scaled = value * mScale;
- if ((int) scaled == scaled)
- pattern = "###,###";
- else
- pattern = "###,###.###";
- mFormatter.applyPattern(pattern);
- return mFormatter.format(scaled);
- }
-
- public String labelledString(double value) {
- String units = label();
- String num = valueOf(value);
- return String.format("%s: %s", units, num);
- }
-
- public String labelledString(long value) {
- return labelledString((double) value);
- }
-
- public String label() {
- if (mScale == 1.0)
- return "usec";
- if (mScale == 0.001)
- return "msec";
- if (mScale == 0.000001)
- return "sec";
- return null;
- }
-
- public void setTimeScale(TimeScale val) {
- mTimeScale = val;
- switch (val) {
- case Seconds:
- mScale = 0.000001;
- break;
- case MilliSeconds:
- mScale = 0.001;
- break;
- case MicroSeconds:
- mScale = 1.0;
- break;
- }
- }
-
- public TimeScale getTimeScale() {
- return mTimeScale;
- }
-
- public enum TimeScale {
- Seconds, MilliSeconds, MicroSeconds
- };
-}
diff --git a/traceview/src/resources/icons/sort_down.png b/traceview/src/resources/icons/sort_down.png
deleted file mode 100644
index 2d4ccc1..0000000
--- a/traceview/src/resources/icons/sort_down.png
+++ /dev/null
Binary files differ
diff --git a/traceview/src/resources/icons/sort_up.png b/traceview/src/resources/icons/sort_up.png
deleted file mode 100644
index 3a0bc3c..0000000
--- a/traceview/src/resources/icons/sort_up.png
+++ /dev/null
Binary files differ
diff --git a/traceview/src/resources/icons/traceview-128.png b/traceview/src/resources/icons/traceview-128.png
deleted file mode 100644
index 5b4eff1..0000000
--- a/traceview/src/resources/icons/traceview-128.png
+++ /dev/null
Binary files differ
diff --git a/uiautomatorviewer/.classpath b/uiautomatorviewer/.classpath
deleted file mode 100644
index 5da1fab..0000000
--- a/uiautomatorviewer/.classpath
+++ /dev/null
@@ -1,12 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry excluding="images" kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry combineaccessrules="false" kind="src" path="/ddmlib"/>
- <classpathentry kind="var" path="ANDROID_OUT_FRAMEWORK/swt.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.core.commands_3.6.0.I20100512-1500.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.equinox.common_3.6.0.v20100503.jar"/>
- <classpathentry kind="var" path="ANDROID_SRC/prebuilts/tools/common/eclipse/org.eclipse.jface_3.6.2.M20110210-1200.jar"/>
- <classpathentry combineaccessrules="false" kind="src" path="/common"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/uiautomatorviewer/.gitignore b/uiautomatorviewer/.gitignore
deleted file mode 100644
index ba077a4..0000000
--- a/uiautomatorviewer/.gitignore
+++ /dev/null
@@ -1 +0,0 @@
-bin
diff --git a/uiautomatorviewer/.project b/uiautomatorviewer/.project
deleted file mode 100644
index d5a1115..0000000
--- a/uiautomatorviewer/.project
+++ /dev/null
@@ -1,17 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>uiautomatorviewer</name>
- <comment></comment>
- <projects>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/uiautomatorviewer/.settings/org.eclipse.jdt.core.prefs b/uiautomatorviewer/.settings/org.eclipse.jdt.core.prefs
deleted file mode 100644
index 9dbff07..0000000
--- a/uiautomatorviewer/.settings/org.eclipse.jdt.core.prefs
+++ /dev/null
@@ -1,98 +0,0 @@
-eclipse.preferences.version=1
-org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
-org.eclipse.jdt.core.compiler.annotation.nonnull=com.android.annotations.NonNull
-org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=com.android.annotations.NonNullByDefault
-org.eclipse.jdt.core.compiler.annotation.nonnullisdefault=disabled
-org.eclipse.jdt.core.compiler.annotation.nullable=com.android.annotations.Nullable
-org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
-org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
-org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
-org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
-org.eclipse.jdt.core.compiler.compliance=1.6
-org.eclipse.jdt.core.compiler.debug.lineNumber=generate
-org.eclipse.jdt.core.compiler.debug.localVariable=generate
-org.eclipse.jdt.core.compiler.debug.sourceFile=generate
-org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
-org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
-org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
-org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
-org.eclipse.jdt.core.compiler.problem.deadCode=warning
-org.eclipse.jdt.core.compiler.problem.deprecation=warning
-org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
-org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
-org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
-org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
-org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
-org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore
-org.eclipse.jdt.core.compiler.problem.fallthroughCase=warning
-org.eclipse.jdt.core.compiler.problem.fatalOptionalError=enabled
-org.eclipse.jdt.core.compiler.problem.fieldHiding=warning
-org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
-org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
-org.eclipse.jdt.core.compiler.problem.forbiddenReference=error
-org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
-org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=enabled
-org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
-org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning
-org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
-org.eclipse.jdt.core.compiler.problem.localVariableHiding=warning
-org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
-org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
-org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
-org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=warning
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=error
-org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
-org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
-org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
-org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
-org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
-org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
-org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
-org.eclipse.jdt.core.compiler.problem.nullReference=error
-org.eclipse.jdt.core.compiler.problem.nullSpecInsufficientInfo=warning
-org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=ignore
-org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
-org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
-org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullReference=warning
-org.eclipse.jdt.core.compiler.problem.potentialNullSpecViolation=error
-org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=warning
-org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
-org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore
-org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
-org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
-org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
-org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
-org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=enabled
-org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
-org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
-org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
-org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
-org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
-org.eclipse.jdt.core.compiler.problem.unclosedCloseable=error
-org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
-org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
-org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
-org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
-org.eclipse.jdt.core.compiler.problem.unusedImport=warning
-org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
-org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
-org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=warning
-org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
-org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
-org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
-org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
-org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
-org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
-org.eclipse.jdt.core.compiler.source=1.6
diff --git a/uiautomatorviewer/Android.mk b/uiautomatorviewer/Android.mk
deleted file mode 100644
index f4c488a..0000000
--- a/uiautomatorviewer/Android.mk
+++ /dev/null
@@ -1,38 +0,0 @@
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_SRC_FILES := $(call all-java-files-under, src)
-LOCAL_JAVA_RESOURCE_DIRS := src
-
-LOCAL_JAR_MANIFEST := etc/manifest.txt
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_JAVA_LIBRARIES := \
- swt \
- common \
- ddmlib \
- org.eclipse.jface_3.6.2.M20110210-1200 \
- org.eclipse.core.commands_3.6.0.I20100512-1500 \
- org.eclipse.equinox.common_3.6.0.v20100503
-
-LOCAL_MODULE := uiautomatorviewer
-
-include $(BUILD_HOST_JAVA_LIBRARY)
-
-# Build all sub-directories
-include $(call all-makefiles-under,$(LOCAL_PATH))
diff --git a/uiautomatorviewer/MODULE_LICENSE_APACHE2 b/uiautomatorviewer/MODULE_LICENSE_APACHE2
deleted file mode 100644
index e69de29..0000000
--- a/uiautomatorviewer/MODULE_LICENSE_APACHE2
+++ /dev/null
diff --git a/uiautomatorviewer/etc/Android.mk b/uiautomatorviewer/etc/Android.mk
deleted file mode 100644
index 55f326d..0000000
--- a/uiautomatorviewer/etc/Android.mk
+++ /dev/null
@@ -1,21 +0,0 @@
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-LOCAL_PATH := $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE_TAGS := optional
-
-LOCAL_PREBUILT_EXECUTABLES := uiautomatorviewer
-include $(BUILD_HOST_PREBUILT)
diff --git a/uiautomatorviewer/etc/manifest.txt b/uiautomatorviewer/etc/manifest.txt
deleted file mode 100644
index 1ca57cc..0000000
--- a/uiautomatorviewer/etc/manifest.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Main-Class: com.android.uiautomator.UiAutomatorViewer
-Class-Path: org.eclipse.jface_3.6.2.M20110210-1200.jar org.eclipse.core.commands_3.6.0.I20100512-1500.jar org.eclipse.equinox.common_3.6.0.v20100503.jar
diff --git a/uiautomatorviewer/etc/uiautomatorviewer b/uiautomatorviewer/etc/uiautomatorviewer
deleted file mode 100755
index 79faf5a..0000000
--- a/uiautomatorviewer/etc/uiautomatorviewer
+++ /dev/null
@@ -1,104 +0,0 @@
-#!/bin/bash
-#
-# Copyright 2012, The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-# Set up prog to be the path of this script, including following symlinks,
-# and set up progdir to be the fully-qualified pathname of its directory.
-prog="$0"
-while [ -h "${prog}" ]; do
- newProg=`/bin/ls -ld "${prog}"`
- newProg=`expr "${newProg}" : ".* -> \(.*\)$"`
- if expr "x${newProg}" : 'x/' >/dev/null; then
- prog="${newProg}"
- else
- progdir=`dirname "${prog}"`
- prog="${progdir}/${newProg}"
- fi
-done
-oldwd=`pwd`
-progdir=`dirname "${prog}"`
-progname=`basename "${prog}"`
-cd "${progdir}"
-progdir=`pwd`
-prog="${progdir}"/"${progname}"
-cd "${oldwd}"
-
-jarfile=uiautomatorviewer.jar
-frameworkdir="$progdir"
-libdir="$progdir"
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/tools/lib
- libdir=`dirname "$progdir"`/tools/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- frameworkdir=`dirname "$progdir"`/framework
- libdir=`dirname "$progdir"`/lib
-fi
-if [ ! -r "$frameworkdir/$jarfile" ]
-then
- echo "${progname}: can't find $jarfile"
- exit 1
-fi
-
-javaCmd="java"
-
-os=`uname`
-if [ $os == 'Darwin' ]; then
- javaOpts="-Xmx1600M -XstartOnFirstThread"
-else
- javaOpts="-Xmx1600M"
-fi
-
-if [ `uname` = "Linux" ]; then
- export GDK_NATIVE_WINDOWS=true
-fi
-
-while expr "x$1" : 'x-J' >/dev/null; do
- opt=`expr "x$1" : 'x-J\(.*\)'`
- javaOpts="${javaOpts} -${opt}"
- shift
-done
-
-jarpath="$frameworkdir/$jarfile"
-
-# Figure out the path to the swt.jar for the current architecture.
-# if ANDROID_SWT is defined, then just use this.
-# else, if running in the Android source tree, then look for the correct swt folder in prebuilt
-# else, look for the correct swt folder in the SDK under tools/lib/
-swtpath=""
-if [ -n "$ANDROID_SWT" ]; then
- swtpath="$ANDROID_SWT"
-else
- vmarch=`${javaCmd} -jar "${frameworkdir}"/archquery.jar`
- if [ -n "$ANDROID_BUILD_TOP" ]; then
- osname=`uname -s | tr A-Z a-z`
- swtpath="${ANDROID_BUILD_TOP}/prebuilts/tools/${osname}-${vmarch}/swt"
- else
- swtpath="${frameworkdir}/${vmarch}"
- fi
-fi
-
-# Combine the swtpath and the framework dir path.
-if [ -d "$swtpath" ]; then
- frameworkdir="${swtpath}:${frameworkdir}"
-else
- echo "SWT folder '${swtpath}' does not exist."
- echo "Please export ANDROID_SWT to point to the folder containing swt.jar for your platform."
- exit 1
-fi
-
-exec "${javaCmd}" $javaOpts -Djava.ext.dirs="$frameworkdir" -Dcom.android.uiautomator.bindir="$progdir" -jar "$jarpath" "$@"
diff --git a/uiautomatorviewer/etc/uiautomatorviewer.bat b/uiautomatorviewer/etc/uiautomatorviewer.bat
deleted file mode 100755
index f3f5d47..0000000
--- a/uiautomatorviewer/etc/uiautomatorviewer.bat
+++ /dev/null
@@ -1,66 +0,0 @@
-@echo off
-rem Copyright (C) 2012 The Android Open Source Project
-rem
-rem Licensed under the Apache License, Version 2.0 (the "License");
-rem you may not use this file except in compliance with the License.
-rem You may obtain a copy of the License at
-rem
-rem http://www.apache.org/licenses/LICENSE-2.0
-rem
-rem Unless required by applicable law or agreed to in writing, software
-rem distributed under the License is distributed on an "AS IS" BASIS,
-rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-rem See the License for the specific language governing permissions and
-rem limitations under the License.
-
-rem don't modify the caller's environment
-setlocal
-
-rem Set up prog to be the path of this script, including following symlinks,
-rem and set up progdir to be the fully-qualified pathname of its directory.
-set prog=%~f0
-
-rem Change current directory and drive to where the script is, to avoid
-rem issues with directories containing whitespaces.
-cd /d %~dp0
-
-rem Get the CWD as a full path with short names only (without spaces)
-for %%i in ("%cd%") do set prog_dir=%%~fsi
-
-rem Check we have a valid Java.exe in the path.
-set java_exe=
-call lib\find_java.bat
-if not defined java_exe goto :EOF
-
-set jarfile=uiautomatorviewer.jar
-set frameworkdir=
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=lib\
-
-if exist %frameworkdir%%jarfile% goto JarFileOk
- set frameworkdir=..\framework\
-
-:JarFileOk
-
-set jarpath=%frameworkdir%%jarfile%
-
-if not defined ANDROID_SWT goto QueryArch
- set swt_path=%ANDROID_SWT%
- goto SwtDone
-
-:QueryArch
-
- for /f %%a in ('%java_exe% -jar %frameworkdir%archquery.jar') do set swt_path=%frameworkdir%%%a
-
-:SwtDone
-
-if exist %swt_path% goto SetPath
- echo SWT folder '%swt_path%' does not exist.
- echo Please set ANDROID_SWT to point to the folder containing swt.jar for your platform.
- exit /B
-
-:SetPath
-set javaextdirs=%swt_path%;%frameworkdir%
-
-call %java_exe% -Djava.ext.dirs=%javaextdirs% -Dcom.android.uiautomator.bindir=%prog_dir% -jar %jarpath% %*
diff --git a/uiautomatorviewer/src/com/android/uiautomator/DebugBridge.java b/uiautomatorviewer/src/com/android/uiautomator/DebugBridge.java
deleted file mode 100644
index 89ffb00..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/DebugBridge.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator;
-
-import com.android.SdkConstants;
-import com.android.ddmlib.AndroidDebugBridge;
-import com.android.ddmlib.IDevice;
-
-import java.io.File;
-import java.util.Arrays;
-import java.util.List;
-
-public class DebugBridge {
- private static AndroidDebugBridge sDebugBridge;
-
- private static String getAdbLocation() {
- String toolsDir = System.getProperty("com.android.uiautomator.bindir"); //$NON-NLS-1$
- if (toolsDir == null) {
- return null;
- }
-
- File sdk = new File(toolsDir).getParentFile();
-
- // check if adb is present in platform-tools
- File platformTools = new File(sdk, "platform-tools");
- File adb = new File(platformTools, SdkConstants.FN_ADB);
- if (adb.exists()) {
- return adb.getAbsolutePath();
- }
-
- // check if adb is present in the tools directory
- adb = new File(toolsDir, SdkConstants.FN_ADB);
- if (adb.exists()) {
- return adb.getAbsolutePath();
- }
-
- return null;
- }
-
- public static void init() {
- String adbLocation = getAdbLocation();
- if (adbLocation != null) {
- AndroidDebugBridge.init(false /* debugger support */);
- sDebugBridge = AndroidDebugBridge.createBridge(adbLocation, false);
- }
- }
-
- public static void terminate() {
- if (sDebugBridge != null) {
- sDebugBridge = null;
- AndroidDebugBridge.terminate();
- }
- }
-
- public static boolean isInitialized() {
- return sDebugBridge != null;
- }
-
- public static List<IDevice> getDevices() {
- return Arrays.asList(sDebugBridge.getDevices());
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/OpenDialog.java b/uiautomatorviewer/src/com/android/uiautomator/OpenDialog.java
deleted file mode 100644
index 97a437b..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/OpenDialog.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-import java.io.File;
-
-/**
- * Implements a file selection dialog for both screen shot and xml dump file
- *
- * "OK" button won't be enabled unless both files are selected
- * It also has a convenience feature such that if one file has been picked, and the other
- * file path is empty, then selection for the other file will start from the same base folder
- *
- */
-public class OpenDialog extends Dialog {
- private static final int FIXED_TEXT_FIELD_WIDTH = 300;
- private static final int DEFAULT_LAYOUT_SPACING = 10;
- private Text mScreenshotText;
- private Text mXmlText;
- private boolean mFileChanged = false;
- private Button mOkButton;
-
- private static File sScreenshotFile;
- private static File sXmlDumpFile;
-
- /**
- * Create the dialog.
- * @param parentShell
- */
- public OpenDialog(Shell parentShell) {
- super(parentShell);
- setShellStyle(SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
- }
-
- /**
- * Create contents of the dialog.
- * @param parent
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite container = (Composite) super.createDialogArea(parent);
- GridLayout gl_container = new GridLayout(1, false);
- gl_container.verticalSpacing = DEFAULT_LAYOUT_SPACING;
- gl_container.horizontalSpacing = DEFAULT_LAYOUT_SPACING;
- gl_container.marginWidth = DEFAULT_LAYOUT_SPACING;
- gl_container.marginHeight = DEFAULT_LAYOUT_SPACING;
- container.setLayout(gl_container);
-
- Group openScreenshotGroup = new Group(container, SWT.NONE);
- openScreenshotGroup.setLayout(new GridLayout(2, false));
- openScreenshotGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- openScreenshotGroup.setText("Screenshot");
-
- mScreenshotText = new Text(openScreenshotGroup, SWT.BORDER | SWT.READ_ONLY);
- if (sScreenshotFile != null) {
- mScreenshotText.setText(sScreenshotFile.getAbsolutePath());
- }
- GridData gd_screenShotText = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
- gd_screenShotText.minimumWidth = FIXED_TEXT_FIELD_WIDTH;
- gd_screenShotText.widthHint = FIXED_TEXT_FIELD_WIDTH;
- mScreenshotText.setLayoutData(gd_screenShotText);
-
- Button openScreenshotButton = new Button(openScreenshotGroup, SWT.NONE);
- openScreenshotButton.setText("...");
- openScreenshotButton.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- handleOpenScreenshotFile();
- }
- });
-
- Group openXmlGroup = new Group(container, SWT.NONE);
- openXmlGroup.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
- openXmlGroup.setText("UI XML Dump");
- openXmlGroup.setLayout(new GridLayout(2, false));
-
- mXmlText = new Text(openXmlGroup, SWT.BORDER | SWT.READ_ONLY);
- mXmlText.setEditable(false);
- if (sXmlDumpFile != null) {
- mXmlText.setText(sXmlDumpFile.getAbsolutePath());
- }
- GridData gd_xmlText = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
- gd_xmlText.minimumWidth = FIXED_TEXT_FIELD_WIDTH;
- gd_xmlText.widthHint = FIXED_TEXT_FIELD_WIDTH;
- mXmlText.setLayoutData(gd_xmlText);
-
- Button openXmlButton = new Button(openXmlGroup, SWT.NONE);
- openXmlButton.setText("...");
- openXmlButton.addListener(SWT.Selection, new Listener() {
- @Override
- public void handleEvent(Event event) {
- handleOpenXmlDumpFile();
- }
- });
-
- return container;
- }
-
- /**
- * Create contents of the button bar.
- * @param parent
- */
- @Override
- protected void createButtonsForButtonBar(Composite parent) {
- mOkButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- updateButtonState();
- }
-
- /**
- * Return the initial size of the dialog.
- */
- @Override
- protected Point getInitialSize() {
- return new Point(368, 233);
- }
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText("Open UI Dump Files");
- }
-
- private void handleOpenScreenshotFile() {
- FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
- fd.setText("Open Screenshot File");
- File initialFile = sScreenshotFile;
- // if file has never been selected before, try to base initial path on the mXmlDumpFile
- if (initialFile == null && sXmlDumpFile != null && sXmlDumpFile.isFile()) {
- initialFile = sXmlDumpFile.getParentFile();
- }
- if (initialFile != null) {
- if (initialFile.isFile()) {
- fd.setFileName(initialFile.getAbsolutePath());
- } else if (initialFile.isDirectory()) {
- fd.setFilterPath(initialFile.getAbsolutePath());
- }
- }
- String[] filter = {"*.png"};
- fd.setFilterExtensions(filter);
- String selected = fd.open();
- if (selected != null) {
- sScreenshotFile = new File(selected);
- mScreenshotText.setText(selected);
- mFileChanged = true;
- }
- updateButtonState();
- }
-
- private void handleOpenXmlDumpFile() {
- FileDialog fd = new FileDialog(getShell(), SWT.OPEN);
- fd.setText("Open UI Dump XML File");
- File initialFile = sXmlDumpFile;
- // if file has never been selected before, try to base initial path on the mScreenshotFile
- if (initialFile == null && sScreenshotFile != null && sScreenshotFile.isFile()) {
- initialFile = sScreenshotFile.getParentFile();
- }
- if (initialFile != null) {
- if (initialFile.isFile()) {
- fd.setFileName(initialFile.getAbsolutePath());
- } else if (initialFile.isDirectory()) {
- fd.setFilterPath(initialFile.getAbsolutePath());
- }
- }
- String initialPath = mXmlText.getText();
- if (initialPath.isEmpty() && sScreenshotFile != null && sScreenshotFile.isFile()) {
- initialPath = sScreenshotFile.getParentFile().getAbsolutePath();
- }
- String[] filter = {"*.uix"};
- fd.setFilterExtensions(filter);
- String selected = fd.open();
- if (selected != null) {
- sXmlDumpFile = new File(selected);
- mXmlText.setText(selected);
- mFileChanged = true;
- }
- updateButtonState();
- }
-
- private void updateButtonState() {
- mOkButton.setEnabled(sXmlDumpFile != null && sXmlDumpFile.isFile());
- }
-
- public boolean hasFileChanged() {
- return mFileChanged;
- }
-
- public File getScreenshotFile() {
- return sScreenshotFile;
- }
-
- public File getXmlDumpFile() {
- return sXmlDumpFile;
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/UiAutomatorHelper.java b/uiautomatorviewer/src/com/android/uiautomator/UiAutomatorHelper.java
deleted file mode 100644
index 8ead9de..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/UiAutomatorHelper.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator;
-
-import com.android.ddmlib.CollectingOutputReceiver;
-import com.android.ddmlib.IDevice;
-import com.android.ddmlib.RawImage;
-import com.android.ddmlib.SyncService;
-import com.android.uiautomator.tree.BasicTreeNode;
-import com.android.uiautomator.tree.RootWindowNode;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.ImageLoader;
-import org.eclipse.swt.graphics.PaletteData;
-import org.eclipse.swt.widgets.Display;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-
-public class UiAutomatorHelper {
- public static final int UIAUTOMATOR_MIN_API_LEVEL = 16;
-
- private static final String UIAUTOMATOR = "/system/bin/uiautomator"; //$NON-NLS-1$
- private static final String UIAUTOMATOR_DUMP_COMMAND = "dump"; //$NON-NLS-1$
- private static final String UIDUMP_DEVICE_PATH = "/data/local/tmp/uidump.xml"; //$NON-NLS-1$
- private static final int XML_CAPTURE_TIMEOUT_SEC = 40;
-
- private static boolean supportsUiAutomator(IDevice device) {
- String apiLevelString = device.getProperty(IDevice.PROP_BUILD_API_LEVEL);
- int apiLevel;
- try {
- apiLevel = Integer.parseInt(apiLevelString);
- } catch (NumberFormatException e) {
- apiLevel = UIAUTOMATOR_MIN_API_LEVEL;
- }
-
- return apiLevel >= UIAUTOMATOR_MIN_API_LEVEL;
- }
-
- private static void getUiHierarchyFile(IDevice device, File dst, IProgressMonitor monitor) {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
-
- monitor.subTask("Deleting old UI XML snapshot ...");
- String command = "rm " + UIDUMP_DEVICE_PATH;
-
- try {
- CountDownLatch commandCompleteLatch = new CountDownLatch(1);
- device.executeShellCommand(command,
- new CollectingOutputReceiver(commandCompleteLatch));
- commandCompleteLatch.await(5, TimeUnit.SECONDS);
- } catch (Exception e1) {
- // ignore exceptions while deleting stale files
- }
-
- monitor.subTask("Taking UI XML snapshot...");
- command = String.format("%s %s %s", UIAUTOMATOR,
- UIAUTOMATOR_DUMP_COMMAND,
- UIDUMP_DEVICE_PATH);
- CountDownLatch commandCompleteLatch = new CountDownLatch(1);
-
- try {
- device.executeShellCommand(
- command,
- new CollectingOutputReceiver(commandCompleteLatch),
- XML_CAPTURE_TIMEOUT_SEC * 1000);
- commandCompleteLatch.await(XML_CAPTURE_TIMEOUT_SEC, TimeUnit.SECONDS);
-
- monitor.subTask("Pull UI XML snapshot from device...");
- device.getSyncService().pullFile(UIDUMP_DEVICE_PATH,
- dst.getAbsolutePath(), SyncService.getNullProgressMonitor());
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- }
-
- public static UiAutomatorResult takeSnapshot(IDevice device, IProgressMonitor monitor)
- throws UiAutomatorException {
- if (monitor == null) {
- monitor = new NullProgressMonitor();
- }
-
- monitor.subTask("Checking if device support UI Automator");
- if (!supportsUiAutomator(device)) {
- String msg = "UI Automator requires a device with API Level "
- + UIAUTOMATOR_MIN_API_LEVEL;
- throw new UiAutomatorException(msg, null);
- }
-
- monitor.subTask("Creating temporary files for uiautomator results.");
- File tmpDir = null;
- File xmlDumpFile = null;
- File screenshotFile = null;
- try {
- tmpDir = File.createTempFile("uiautomatorviewer_", "");
- tmpDir.delete();
- if (!tmpDir.mkdirs())
- throw new IOException("Failed to mkdir");
- xmlDumpFile = File.createTempFile("dump_", ".uix", tmpDir);
- screenshotFile = File.createTempFile("screenshot_", ".png", tmpDir);
- } catch (Exception e) {
- String msg = "Error while creating temporary file to save snapshot: "
- + e.getMessage();
- throw new UiAutomatorException(msg, e);
- }
-
- tmpDir.deleteOnExit();
- xmlDumpFile.deleteOnExit();
- screenshotFile.deleteOnExit();
-
- monitor.subTask("Obtaining UI hierarchy");
- try {
- UiAutomatorHelper.getUiHierarchyFile(device, xmlDumpFile, monitor);
- } catch (Exception e) {
- String msg = "Error while obtaining UI hierarchy XML file: " + e.getMessage();
- throw new UiAutomatorException(msg, e);
- }
-
- UiAutomatorModel model;
- try {
- model = new UiAutomatorModel(xmlDumpFile);
- } catch (Exception e) {
- String msg = "Error while parsing UI hierarchy XML file: " + e.getMessage();
- throw new UiAutomatorException(msg, e);
- }
-
- monitor.subTask("Obtaining device screenshot");
- RawImage rawImage;
- try {
- rawImage = device.getScreenshot();
- } catch (Exception e) {
- String msg = "Error taking device screenshot: " + e.getMessage();
- throw new UiAutomatorException(msg, e);
- }
-
- // rotate the screen shot per device rotation
- BasicTreeNode root = model.getXmlRootNode();
- if (root instanceof RootWindowNode) {
- for (int i = 0; i < ((RootWindowNode)root).getRotation(); i++) {
- rawImage = rawImage.getRotated();
- }
- }
- PaletteData palette = new PaletteData(
- rawImage.getRedMask(),
- rawImage.getGreenMask(),
- rawImage.getBlueMask());
- ImageData imageData = new ImageData(rawImage.width, rawImage.height,
- rawImage.bpp, palette, 1, rawImage.data);
- ImageLoader loader = new ImageLoader();
- loader.data = new ImageData[] { imageData };
- loader.save(screenshotFile.getAbsolutePath(), SWT.IMAGE_PNG);
- Image screenshot = new Image(Display.getDefault(), imageData);
-
- return new UiAutomatorResult(xmlDumpFile, model, screenshot);
- }
-
- @SuppressWarnings("serial")
- public static class UiAutomatorException extends Exception {
- public UiAutomatorException(String msg, Throwable t) {
- super(msg, t);
- }
- }
-
- public static class UiAutomatorResult {
- public final File uiHierarchy;
- public final UiAutomatorModel model;
- public final Image screenshot;
-
- public UiAutomatorResult(File uiXml, UiAutomatorModel m, Image s) {
- uiHierarchy = uiXml;
- model = m;
- screenshot = s;
- }
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/UiAutomatorModel.java b/uiautomatorviewer/src/com/android/uiautomator/UiAutomatorModel.java
deleted file mode 100644
index c724f8b..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/UiAutomatorModel.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator;
-
-import com.android.uiautomator.tree.BasicTreeNode;
-import com.android.uiautomator.tree.BasicTreeNode.IFindNodeListener;
-import com.android.uiautomator.tree.UiHierarchyXmlLoader;
-import com.android.uiautomator.tree.UiNode;
-
-import org.eclipse.swt.graphics.Rectangle;
-
-import java.io.File;
-import java.util.List;
-
-public class UiAutomatorModel {
- private BasicTreeNode mRootNode;
- private BasicTreeNode mSelectedNode;
- private Rectangle mCurrentDrawingRect;
- private List<Rectangle> mNafNodes;
-
- // determines whether we lookup the leaf UI node on mouse move of screenshot image
- private boolean mExploreMode = true;
-
- private boolean mShowNafNodes = false;
-
- public UiAutomatorModel(File xmlDumpFile) {
- UiHierarchyXmlLoader loader = new UiHierarchyXmlLoader();
- BasicTreeNode rootNode = loader.parseXml(xmlDumpFile.getAbsolutePath());
- if (rootNode == null) {
- System.err.println("null rootnode after parsing.");
- throw new IllegalArgumentException("Invalid ui automator hierarchy file.");
- }
-
- mNafNodes = loader.getNafNodes();
- if (mRootNode != null) {
- mRootNode.clearAllChildren();
- }
-
- mRootNode = rootNode;
- mExploreMode = true;
- }
-
- public BasicTreeNode getXmlRootNode() {
- return mRootNode;
- }
-
- public BasicTreeNode getSelectedNode() {
- return mSelectedNode;
- }
-
- /**
- * change node selection in the Model recalculate the rect to highlight,
- * also notifies the View to refresh accordingly
- *
- * @param node
- */
- public void setSelectedNode(BasicTreeNode node) {
- mSelectedNode = node;
- if (mSelectedNode instanceof UiNode) {
- UiNode uiNode = (UiNode) mSelectedNode;
- mCurrentDrawingRect = new Rectangle(uiNode.x, uiNode.y, uiNode.width, uiNode.height);
- } else {
- mCurrentDrawingRect = null;
- }
- }
-
- public Rectangle getCurrentDrawingRect() {
- return mCurrentDrawingRect;
- }
-
- /**
- * Do a search in tree to find a leaf node or deepest parent node containing the coordinate
- *
- * @param x
- * @param y
- * @return
- */
- public BasicTreeNode updateSelectionForCoordinates(int x, int y) {
- BasicTreeNode node = null;
-
- if (mRootNode != null) {
- MinAreaFindNodeListener listener = new MinAreaFindNodeListener();
- boolean found = mRootNode.findLeafMostNodesAtPoint(x, y, listener);
- if (found && listener.mNode != null && !listener.mNode.equals(mSelectedNode)) {
- node = listener.mNode;
- }
- }
-
- return node;
- }
-
- public boolean isExploreMode() {
- return mExploreMode;
- }
-
- public void toggleExploreMode() {
- mExploreMode = !mExploreMode;
- }
-
- public void setExploreMode(boolean exploreMode) {
- mExploreMode = exploreMode;
- }
-
- private static class MinAreaFindNodeListener implements IFindNodeListener {
- BasicTreeNode mNode = null;
- @Override
- public void onFoundNode(BasicTreeNode node) {
- if (mNode == null) {
- mNode = node;
- } else {
- if ((node.height * node.width) < (mNode.height * mNode.width)) {
- mNode = node;
- }
- }
- }
- }
-
- public List<Rectangle> getNafNodes() {
- return mNafNodes;
- }
-
- public void toggleShowNaf() {
- mShowNafNodes = !mShowNafNodes;
- }
-
- public boolean shouldShowNafNodes() {
- return mShowNafNodes;
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/UiAutomatorView.java b/uiautomatorviewer/src/com/android/uiautomator/UiAutomatorView.java
deleted file mode 100644
index c5f3e59..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/UiAutomatorView.java
+++ /dev/null
@@ -1,436 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator;
-
-import com.android.uiautomator.actions.ExpandAllAction;
-import com.android.uiautomator.actions.ToggleNafAction;
-import com.android.uiautomator.tree.AttributePair;
-import com.android.uiautomator.tree.BasicTreeNode;
-import com.android.uiautomator.tree.BasicTreeNodeContentProvider;
-
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.layout.TableColumnLayout;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.EditingSupport;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TableViewerColumn;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.custom.StackLayout;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.ImageLoader;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.graphics.Transform;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Tree;
-
-import java.io.File;
-
-public class UiAutomatorView extends Composite {
- private static final int IMG_BORDER = 2;
-
- // The screenshot area is made of a stack layout of two components: screenshot canvas and
- // a "specify screenshot" button. If a screenshot is already available, then that is displayed
- // on the canvas. If it is not availble, then the "specify screenshot" button is displayed.
- private Composite mScreenshotComposite;
- private StackLayout mStackLayout;
- private Composite mSetScreenshotComposite;
- private Canvas mScreenshotCanvas;
-
- private TreeViewer mTreeViewer;
- private TableViewer mTableViewer;
-
- private float mScale = 1.0f;
- private int mDx, mDy;
-
- private UiAutomatorModel mModel;
- private File mModelFile;
- private Image mScreenshot;
-
- public UiAutomatorView(Composite parent, int style) {
- super(parent, SWT.NONE);
- setLayout(new FillLayout());
-
- SashForm baseSash = new SashForm(this, SWT.HORIZONTAL);
-
- mScreenshotComposite = new Composite(baseSash, SWT.BORDER);
- mStackLayout = new StackLayout();
- mScreenshotComposite.setLayout(mStackLayout);
-
- // draw the canvas with border, so the divider area for sash form can be highlighted
- mScreenshotCanvas = new Canvas(mScreenshotComposite, SWT.BORDER);
- mStackLayout.topControl = mScreenshotCanvas;
- mScreenshotComposite.layout();
-
- mScreenshotCanvas.addMouseListener(new MouseAdapter() {
- @Override
- public void mouseUp(MouseEvent e) {
- if (mModel != null) {
- mModel.toggleExploreMode();
- redrawScreenshot();
- }
- }
- });
- mScreenshotCanvas.setBackground(
- getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
- mScreenshotCanvas.addPaintListener(new PaintListener() {
- @Override
- public void paintControl(PaintEvent e) {
- if (mScreenshot != null) {
- updateScreenshotTransformation();
- // shifting the image here, so that there's a border around screen shot
- // this makes highlighting red rectangles on the screen shot edges more visible
- Transform t = new Transform(e.gc.getDevice());
- t.translate(mDx, mDy);
- t.scale(mScale, mScale);
- e.gc.setTransform(t);
- e.gc.drawImage(mScreenshot, 0, 0);
- // this resets the transformation to identity transform, i.e. no change
- // we don't use transformation here because it will cause the line pattern
- // and line width of highlight rect to be scaled, causing to appear to be blurry
- e.gc.setTransform(null);
- if (mModel.shouldShowNafNodes()) {
- // highlight the "Not Accessibility Friendly" nodes
- e.gc.setForeground(e.gc.getDevice().getSystemColor(SWT.COLOR_YELLOW));
- e.gc.setBackground(e.gc.getDevice().getSystemColor(SWT.COLOR_YELLOW));
- for (Rectangle r : mModel.getNafNodes()) {
- e.gc.setAlpha(50);
- e.gc.fillRectangle(mDx + getScaledSize(r.x), mDy + getScaledSize(r.y),
- getScaledSize(r.width), getScaledSize(r.height));
- e.gc.setAlpha(255);
- e.gc.setLineStyle(SWT.LINE_SOLID);
- e.gc.setLineWidth(2);
- e.gc.drawRectangle(mDx + getScaledSize(r.x), mDy + getScaledSize(r.y),
- getScaledSize(r.width), getScaledSize(r.height));
- }
- }
- // draw the mouseover rects
- Rectangle rect = mModel.getCurrentDrawingRect();
- if (rect != null) {
- e.gc.setForeground(e.gc.getDevice().getSystemColor(SWT.COLOR_RED));
- if (mModel.isExploreMode()) {
- // when we highlight nodes dynamically on mouse move,
- // use dashed borders
- e.gc.setLineStyle(SWT.LINE_DASH);
- e.gc.setLineWidth(1);
- } else {
- // when highlighting nodes on tree node selection,
- // use solid borders
- e.gc.setLineStyle(SWT.LINE_SOLID);
- e.gc.setLineWidth(2);
- }
- e.gc.drawRectangle(mDx + getScaledSize(rect.x), mDy + getScaledSize(rect.y),
- getScaledSize(rect.width), getScaledSize(rect.height));
- }
- }
- }
- });
- mScreenshotCanvas.addMouseMoveListener(new MouseMoveListener() {
- @Override
- public void mouseMove(MouseEvent e) {
- if (mModel != null && mModel.isExploreMode()) {
- BasicTreeNode node = mModel.updateSelectionForCoordinates(
- getInverseScaledSize(e.x - mDx),
- getInverseScaledSize(e.y - mDy));
- if (node != null) {
- updateTreeSelection(node);
- }
- }
- }
- });
-
- mSetScreenshotComposite = new Composite(mScreenshotComposite, SWT.NONE);
- mSetScreenshotComposite.setLayout(new GridLayout());
-
- final Button setScreenshotButton = new Button(mSetScreenshotComposite, SWT.PUSH);
- setScreenshotButton.setText("Specify Screenshot...");
- setScreenshotButton.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- FileDialog fd = new FileDialog(setScreenshotButton.getShell());
- fd.setFilterExtensions(new String[] { "*.png" });
- if (mModelFile != null) {
- fd.setFilterPath(mModelFile.getParent());
- }
- String screenshotPath = fd.open();
- if (screenshotPath == null) {
- return;
- }
-
- ImageData[] data;
- try {
- data = new ImageLoader().load(screenshotPath);
- } catch (Exception e) {
- return;
- }
-
- // "data" is an array, probably used to handle images that has multiple frames
- // i.e. gifs or icons, we just care if it has at least one here
- if (data.length < 1) {
- return;
- }
-
- mScreenshot = new Image(Display.getDefault(), data[0]);
- redrawScreenshot();
- }
- });
-
-
- // right sash is split into 2 parts: upper-right and lower-right
- // both are composites with borders, so that the horizontal divider can be highlighted by
- // the borders
- SashForm rightSash = new SashForm(baseSash, SWT.VERTICAL);
-
- // upper-right base contains the toolbar and the tree
- Composite upperRightBase = new Composite(rightSash, SWT.BORDER);
- upperRightBase.setLayout(new GridLayout(1, false));
-
- ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
- toolBarManager.add(new ExpandAllAction(this));
- toolBarManager.add(new ToggleNafAction(this));
- toolBarManager.createControl(upperRightBase);
-
- mTreeViewer = new TreeViewer(upperRightBase, SWT.NONE);
- mTreeViewer.setContentProvider(new BasicTreeNodeContentProvider());
- // default LabelProvider uses toString() to generate text to display
- mTreeViewer.setLabelProvider(new LabelProvider());
- mTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- @Override
- public void selectionChanged(SelectionChangedEvent event) {
- BasicTreeNode selectedNode = null;
- if (event.getSelection() instanceof IStructuredSelection) {
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- Object o = selection.getFirstElement();
- if (o instanceof BasicTreeNode) {
- selectedNode = (BasicTreeNode) o;
- }
- }
-
- mModel.setSelectedNode(selectedNode);
- redrawScreenshot();
- if (selectedNode != null) {
- loadAttributeTable();
- }
- }
- });
- Tree tree = mTreeViewer.getTree();
- tree.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
- // move focus so that it's not on tool bar (looks weird)
- tree.setFocus();
-
- // lower-right base contains the detail group
- Composite lowerRightBase = new Composite(rightSash, SWT.BORDER);
- lowerRightBase.setLayout(new FillLayout());
- Group grpNodeDetail = new Group(lowerRightBase, SWT.NONE);
- grpNodeDetail.setLayout(new FillLayout(SWT.HORIZONTAL));
- grpNodeDetail.setText("Node Detail");
-
- Composite tableContainer = new Composite(grpNodeDetail, SWT.NONE);
-
- TableColumnLayout columnLayout = new TableColumnLayout();
- tableContainer.setLayout(columnLayout);
-
- mTableViewer = new TableViewer(tableContainer, SWT.NONE | SWT.FULL_SELECTION);
- Table table = mTableViewer.getTable();
- table.setLinesVisible(true);
- // use ArrayContentProvider here, it assumes the input to the TableViewer
- // is an array, where each element represents a row in the table
- mTableViewer.setContentProvider(new ArrayContentProvider());
-
- TableViewerColumn tableViewerColumnKey = new TableViewerColumn(mTableViewer, SWT.NONE);
- TableColumn tblclmnKey = tableViewerColumnKey.getColumn();
- tableViewerColumnKey.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- if (element instanceof AttributePair) {
- // first column, shows the attribute name
- return ((AttributePair)element).key;
- }
- return super.getText(element);
- }
- });
- columnLayout.setColumnData(tblclmnKey,
- new ColumnWeightData(1, ColumnWeightData.MINIMUM_WIDTH, true));
-
- TableViewerColumn tableViewerColumnValue = new TableViewerColumn(mTableViewer, SWT.NONE);
- tableViewerColumnValue.setEditingSupport(new AttributeTableEditingSupport(mTableViewer));
- TableColumn tblclmnValue = tableViewerColumnValue.getColumn();
- columnLayout.setColumnData(tblclmnValue,
- new ColumnWeightData(2, ColumnWeightData.MINIMUM_WIDTH, true));
- tableViewerColumnValue.setLabelProvider(new ColumnLabelProvider() {
- @Override
- public String getText(Object element) {
- if (element instanceof AttributePair) {
- // second column, shows the attribute value
- return ((AttributePair)element).value;
- }
- return super.getText(element);
- }
- });
- // sets the ratio of the vertical split: left 5 vs right 3
- baseSash.setWeights(new int[]{5, 3});
- }
-
- private int getScaledSize(int size) {
- if (mScale == 1.0f) {
- return size;
- } else {
- return new Double(Math.floor((size * mScale))).intValue();
- }
- }
-
- private int getInverseScaledSize(int size) {
- if (mScale == 1.0f) {
- return size;
- } else {
- return new Double(Math.floor((size / mScale))).intValue();
- }
- }
-
- private void updateScreenshotTransformation() {
- Rectangle canvas = mScreenshotCanvas.getBounds();
- Rectangle image = mScreenshot.getBounds();
- float scaleX = (canvas.width - 2 * IMG_BORDER - 1) / (float)image.width;
- float scaleY = (canvas.height - 2 * IMG_BORDER - 1) / (float)image.height;
- // use the smaller scale here so that we can fit the entire screenshot
- mScale = Math.min(scaleX, scaleY);
- // calculate translation values to center the image on the canvas
- mDx = (canvas.width - getScaledSize(image.width) - IMG_BORDER * 2) / 2 + IMG_BORDER;
- mDy = (canvas.height - getScaledSize(image.height) - IMG_BORDER * 2) / 2 + IMG_BORDER;
- }
-
- private class AttributeTableEditingSupport extends EditingSupport {
-
- private TableViewer mViewer;
-
- public AttributeTableEditingSupport(TableViewer viewer) {
- super(viewer);
- mViewer = viewer;
- }
-
- @Override
- protected boolean canEdit(Object arg0) {
- return true;
- }
-
- @Override
- protected CellEditor getCellEditor(Object arg0) {
- return new TextCellEditor(mViewer.getTable());
- }
-
- @Override
- protected Object getValue(Object o) {
- return ((AttributePair)o).value;
- }
-
- @Override
- protected void setValue(Object arg0, Object arg1) {
- }
- }
-
- /**
- * Causes a redraw of the canvas.
- *
- * The drawing code of canvas will handle highlighted nodes and etc based on data
- * retrieved from Model
- */
- public void redrawScreenshot() {
- if (mScreenshot == null) {
- mStackLayout.topControl = mSetScreenshotComposite;
- } else {
- mStackLayout.topControl = mScreenshotCanvas;
- }
- mScreenshotComposite.layout();
-
- mScreenshotCanvas.redraw();
- }
-
- public void setInputHierarchy(Object input) {
- mTreeViewer.setInput(input);
- }
-
- public void loadAttributeTable() {
- // udpate the lower right corner table to show the attributes of the node
- mTableViewer.setInput(mModel.getSelectedNode().getAttributesArray());
- }
-
- public void expandAll() {
- mTreeViewer.expandAll();
- }
-
- public void updateTreeSelection(BasicTreeNode node) {
- mTreeViewer.setSelection(new StructuredSelection(node), true);
- }
-
- public void setModel(UiAutomatorModel model, File modelBackingFile, Image screenshot) {
- mModel = model;
- mModelFile = modelBackingFile;
-
- if (mScreenshot != null) {
- mScreenshot.dispose();
- }
- mScreenshot = screenshot;
-
- redrawScreenshot();
- // load xml into tree
- BasicTreeNode wrapper = new BasicTreeNode();
- // putting another root node on top of existing root node
- // because Tree seems to like to hide the root node
- wrapper.addChild(mModel.getXmlRootNode());
- setInputHierarchy(wrapper);
- mTreeViewer.getTree().setFocus();
-
- }
-
- public boolean shouldShowNafNodes() {
- return mModel != null ? mModel.shouldShowNafNodes() : false;
- }
-
- public void toggleShowNaf() {
- if (mModel != null) {
- mModel.toggleShowNaf();
- }
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/UiAutomatorViewer.java b/uiautomatorviewer/src/com/android/uiautomator/UiAutomatorViewer.java
deleted file mode 100644
index 37018b4..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/UiAutomatorViewer.java
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator;
-
-import com.android.uiautomator.actions.OpenFilesAction;
-import com.android.uiautomator.actions.ScreenshotAction;
-
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.window.ApplicationWindow;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.ToolBar;
-
-import java.io.File;
-
-public class UiAutomatorViewer extends ApplicationWindow {
- private UiAutomatorView mUiAutomatorView;
-
- public UiAutomatorViewer() {
- super(null);
- }
-
- @Override
- protected Control createContents(Composite parent) {
- Composite c = new Composite(parent, SWT.BORDER);
-
- GridLayout gridLayout = new GridLayout(1, false);
- gridLayout.marginWidth = 0;
- gridLayout.marginHeight = 0;
- gridLayout.horizontalSpacing = 0;
- gridLayout.verticalSpacing = 0;
- c.setLayout(gridLayout);
-
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- c.setLayoutData(gd);
-
- ToolBarManager toolBarManager = new ToolBarManager(SWT.FLAT);
- toolBarManager.add(new OpenFilesAction(this));
- toolBarManager.add(new ScreenshotAction(this));
- ToolBar tb = toolBarManager.createControl(c);
- tb.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- mUiAutomatorView = new UiAutomatorView(c, SWT.BORDER);
- mUiAutomatorView.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- return parent;
- }
-
- public static void main(String args[]) {
- DebugBridge.init();
-
- try {
- UiAutomatorViewer window = new UiAutomatorViewer();
- window.setBlockOnOpen(true);
- window.open();
- } catch (Exception e) {
- e.printStackTrace();
- } finally {
- DebugBridge.terminate();
- }
- }
-
- @Override
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText("UI Automator Viewer");
- }
-
- @Override
- protected Point getInitialSize() {
- return new Point(800, 600);
- }
-
- public void setModel(final UiAutomatorModel model, final File modelFile,
- final Image screenshot) {
- if (Display.getDefault().getThread() != Thread.currentThread()) {
- Display.getDefault().syncExec(new Runnable() {
- @Override
- public void run() {
- mUiAutomatorView.setModel(model, modelFile, screenshot);
- }
- });
- } else {
- mUiAutomatorView.setModel(model, modelFile, screenshot);
- }
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/actions/ExpandAllAction.java b/uiautomatorviewer/src/com/android/uiautomator/actions/ExpandAllAction.java
deleted file mode 100644
index a37539b..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/actions/ExpandAllAction.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator.actions;
-
-import com.android.uiautomator.UiAutomatorView;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-public class ExpandAllAction extends Action {
-
- UiAutomatorView mView;
-
- public ExpandAllAction(UiAutomatorView view) {
- super("&Expand All");
- mView = view;;
- }
-
- @Override
- public ImageDescriptor getImageDescriptor() {
- return ImageHelper.loadImageDescriptorFromResource("images/expandall.png");
- }
-
- @Override
- public void run() {
- mView.expandAll();
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/actions/ImageHelper.java b/uiautomatorviewer/src/com/android/uiautomator/actions/ImageHelper.java
deleted file mode 100644
index 603b226..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/actions/ImageHelper.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator.actions;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.ImageLoader;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-public class ImageHelper {
-
- public static ImageDescriptor loadImageDescriptorFromResource(String path) {
- InputStream is = ImageHelper.class.getClassLoader().getResourceAsStream(path);
- if (is != null) {
- ImageData[] data = null;
- try {
- data = new ImageLoader().load(is);
- } catch (SWTException e) {
- } finally {
- try {
- is.close();
- } catch (IOException e) {
- }
- }
- if (data != null && data.length > 0) {
- return ImageDescriptor.createFromImageData(data[0]);
- }
- }
- return null;
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/actions/OpenFilesAction.java b/uiautomatorviewer/src/com/android/uiautomator/actions/OpenFilesAction.java
deleted file mode 100644
index 46ee9b6..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/actions/OpenFilesAction.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator.actions;
-
-import com.android.uiautomator.OpenDialog;
-import com.android.uiautomator.UiAutomatorModel;
-import com.android.uiautomator.UiAutomatorViewer;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.ImageLoader;
-import org.eclipse.swt.widgets.Display;
-
-import java.io.File;
-
-public class OpenFilesAction extends Action {
- private UiAutomatorViewer mViewer;
-
- public OpenFilesAction(UiAutomatorViewer viewer) {
- super("&Open");
-
- mViewer = viewer;
- }
-
- @Override
- public ImageDescriptor getImageDescriptor() {
- return ImageHelper.loadImageDescriptorFromResource("images/open-folder.png");
- }
-
- @Override
- public void run() {
- OpenDialog d = new OpenDialog(Display.getDefault().getActiveShell());
- if (d.open() != OpenDialog.OK) {
- return;
- }
-
- UiAutomatorModel model;
- try {
- model = new UiAutomatorModel(d.getXmlDumpFile());
- } catch (Exception e) {
- // FIXME: show error
- return;
- }
-
- Image img = null;
- File screenshot = d.getScreenshotFile();
- if (screenshot != null) {
- try {
- ImageData[] data = new ImageLoader().load(screenshot.getAbsolutePath());
-
- // "data" is an array, probably used to handle images that has multiple frames
- // i.e. gifs or icons, we just care if it has at least one here
- if (data.length < 1) {
- throw new RuntimeException("Unable to load image: "
- + screenshot.getAbsolutePath());
- }
-
- img = new Image(Display.getDefault(), data[0]);
- } catch (Exception e) {
- // FIXME: show error
- return;
- }
- }
-
- mViewer.setModel(model, d.getXmlDumpFile(), img);
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/actions/ScreenshotAction.java b/uiautomatorviewer/src/com/android/uiautomator/actions/ScreenshotAction.java
deleted file mode 100644
index 700b041..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/actions/ScreenshotAction.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator.actions;
-
-import com.android.ddmlib.IDevice;
-import com.android.uiautomator.DebugBridge;
-import com.android.uiautomator.UiAutomatorHelper;
-import com.android.uiautomator.UiAutomatorHelper.UiAutomatorException;
-import com.android.uiautomator.UiAutomatorHelper.UiAutomatorResult;
-import com.android.uiautomator.UiAutomatorViewer;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-
-public class ScreenshotAction extends Action {
- UiAutomatorViewer mViewer;
-
- public ScreenshotAction(UiAutomatorViewer viewer) {
- super("&Device Screenshot");
- mViewer = viewer;
- }
-
- @Override
- public ImageDescriptor getImageDescriptor() {
- return ImageHelper.loadImageDescriptorFromResource("images/screenshot.png");
- }
-
- @Override
- public void run() {
- if (!DebugBridge.isInitialized()) {
- MessageDialog.openError(mViewer.getShell(),
- "Error obtaining Device Screenshot",
- "Unable to connect to adb. Check if adb is installed correctly.");
- return;
- }
-
- final IDevice device = pickDevice();
- if (device == null) {
- return;
- }
-
- ProgressMonitorDialog dialog = new ProgressMonitorDialog(mViewer.getShell());
- try {
- dialog.run(true, false, new IRunnableWithProgress() {
- @Override
- public void run(IProgressMonitor monitor) throws InvocationTargetException,
- InterruptedException {
- UiAutomatorResult result = null;
- try {
- result = UiAutomatorHelper.takeSnapshot(device, monitor);
- } catch (UiAutomatorException e) {
- monitor.done();
- showError(e.getMessage(), e);
- return;
- }
-
- mViewer.setModel(result.model, result.uiHierarchy, result.screenshot);
- monitor.done();
- }
- });
- } catch (Exception e) {
- showError("Unexpected error while obtaining UI hierarchy", e);
- }
- }
-
- private void showError(final String msg, final Throwable t) {
- mViewer.getShell().getDisplay().syncExec(new Runnable() {
- @Override
- public void run() {
- Status s = new Status(IStatus.ERROR, "Screenshot", msg, t);
- ErrorDialog.openError(
- mViewer.getShell(), "Error", "Error obtaining UI hierarchy", s);
- }
- });
- }
-
- private IDevice pickDevice() {
- List<IDevice> devices = DebugBridge.getDevices();
- if (devices.size() == 0) {
- MessageDialog.openError(mViewer.getShell(),
- "Error obtaining Device Screenshot",
- "No Android devices were detected by adb.");
- return null;
- } else if (devices.size() == 1) {
- return devices.get(0);
- } else {
- DevicePickerDialog dlg = new DevicePickerDialog(mViewer.getShell(), devices);
- if (dlg.open() != Window.OK) {
- return null;
- }
- return dlg.getSelectedDevice();
- }
- }
-
- private static class DevicePickerDialog extends Dialog {
- private final List<IDevice> mDevices;
- private final String[] mDeviceNames;
- private static int sSelectedDeviceIndex;
-
- public DevicePickerDialog(Shell parentShell, List<IDevice> devices) {
- super(parentShell);
-
- mDevices = devices;
- mDeviceNames = new String[mDevices.size()];
- for (int i = 0; i < devices.size(); i++) {
- mDeviceNames[i] = devices.get(i).getName();
- }
- }
-
- @Override
- protected Control createDialogArea(Composite parentShell) {
- Composite parent = (Composite) super.createDialogArea(parentShell);
- Composite c = new Composite(parent, SWT.NONE);
-
- c.setLayout(new GridLayout(2, false));
-
- Label l = new Label(c, SWT.NONE);
- l.setText("Select device: ");
-
- final Combo combo = new Combo(c, SWT.BORDER | SWT.READ_ONLY);
- combo.setItems(mDeviceNames);
- int defaultSelection =
- sSelectedDeviceIndex < mDevices.size() ? sSelectedDeviceIndex : 0;
- combo.select(defaultSelection);
- sSelectedDeviceIndex = defaultSelection;
-
- combo.addSelectionListener(new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent arg0) {
- sSelectedDeviceIndex = combo.getSelectionIndex();
- }
- });
-
- return parent;
- }
-
- public IDevice getSelectedDevice() {
- return mDevices.get(sSelectedDeviceIndex);
- }
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/actions/ToggleNafAction.java b/uiautomatorviewer/src/com/android/uiautomator/actions/ToggleNafAction.java
deleted file mode 100644
index fe4cbfa..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/actions/ToggleNafAction.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator.actions;
-
-import com.android.uiautomator.UiAutomatorView;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-public class ToggleNafAction extends Action {
- private UiAutomatorView mView;
-
- public ToggleNafAction(UiAutomatorView view) {
- super("&Toggle NAF Nodes", IAction.AS_CHECK_BOX);
- setChecked(view.shouldShowNafNodes());
-
- mView = view;
- }
-
- @Override
- public ImageDescriptor getImageDescriptor() {
- return ImageHelper.loadImageDescriptorFromResource("images/warning.png");
- }
-
- @Override
- public void run() {
- mView.toggleShowNaf();
- mView.redrawScreenshot();
- setChecked(mView.shouldShowNafNodes());
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/tree/AttributePair.java b/uiautomatorviewer/src/com/android/uiautomator/tree/AttributePair.java
deleted file mode 100644
index ef59544..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/tree/AttributePair.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator.tree;
-
-public class AttributePair {
- public String key, value;
-
- public AttributePair(String key, String value) {
- this.key = key;
- this.value = value;
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/tree/BasicTreeNode.java b/uiautomatorviewer/src/com/android/uiautomator/tree/BasicTreeNode.java
deleted file mode 100644
index 99434d1..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/tree/BasicTreeNode.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator.tree;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-public class BasicTreeNode {
-
- private static final BasicTreeNode[] CHILDREN_TEMPLATE = new BasicTreeNode[] {};
-
- protected BasicTreeNode mParent;
-
- protected final List<BasicTreeNode> mChildren = new ArrayList<BasicTreeNode>();
-
- public int x, y, width, height;
-
- // whether the boundary fields are applicable for the node or not
- // RootWindowNode has no bounds, but UiNodes should
- protected boolean mHasBounds = false;
-
- public void addChild(BasicTreeNode child) {
- if (child == null) {
- throw new NullPointerException("Cannot add null child");
- }
- if (mChildren.contains(child)) {
- throw new IllegalArgumentException("node already a child");
- }
- mChildren.add(child);
- child.mParent = this;
- }
-
- public List<BasicTreeNode> getChildrenList() {
- return Collections.unmodifiableList(mChildren);
- }
-
- public BasicTreeNode[] getChildren() {
- return mChildren.toArray(CHILDREN_TEMPLATE);
- }
-
- public BasicTreeNode getParent() {
- return mParent;
- }
-
- public boolean hasChild() {
- return mChildren.size() != 0;
- }
-
- public int getChildCount() {
- return mChildren.size();
- }
-
- public void clearAllChildren() {
- for (BasicTreeNode child : mChildren) {
- child.clearAllChildren();
- }
- mChildren.clear();
- }
-
- /**
- *
- * Find nodes in the tree containing the coordinate
- *
- * The found node should have bounds covering the coordinate, and none of its children's
- * bounds covers it. Depending on the layout, some app may have multiple nodes matching it,
- * the caller must provide a {@link IFindNodeListener} to receive all found nodes
- *
- * @param px
- * @param py
- * @return
- */
- public boolean findLeafMostNodesAtPoint(int px, int py, IFindNodeListener listener) {
- boolean foundInChild = false;
- for (BasicTreeNode node : mChildren) {
- foundInChild |= node.findLeafMostNodesAtPoint(px, py, listener);
- }
- // checked all children, if at least one child covers the point, return directly
- if (foundInChild) return true;
- // check self if the node has no children, or no child nodes covers the point
- if (mHasBounds) {
- if (x <= px && px <= x + width && y <= py && py <= y + height) {
- listener.onFoundNode(this);
- return true;
- } else {
- return false;
- }
- } else {
- return false;
- }
- }
-
- public Object[] getAttributesArray () {
- return null;
- };
-
- public static interface IFindNodeListener {
- void onFoundNode(BasicTreeNode node);
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/tree/BasicTreeNodeContentProvider.java b/uiautomatorviewer/src/com/android/uiautomator/tree/BasicTreeNodeContentProvider.java
deleted file mode 100644
index d78ceea..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/tree/BasicTreeNodeContentProvider.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator.tree;
-
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-
-public class BasicTreeNodeContentProvider implements ITreeContentProvider {
-
- private static final Object[] EMPTY_ARRAY = {};
-
- @Override
- public void dispose() {
- }
-
- @Override
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- @Override
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- @Override
- public Object[] getChildren(Object parentElement) {
- if (parentElement instanceof BasicTreeNode) {
- return ((BasicTreeNode)parentElement).getChildren();
- }
- return EMPTY_ARRAY;
- }
-
- @Override
- public Object getParent(Object element) {
- if (element instanceof BasicTreeNode) {
- return ((BasicTreeNode)element).getParent();
- }
- return null;
- }
-
- @Override
- public boolean hasChildren(Object element) {
- if (element instanceof BasicTreeNode) {
- return ((BasicTreeNode) element).hasChild();
- }
- return false;
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/tree/RootWindowNode.java b/uiautomatorviewer/src/com/android/uiautomator/tree/RootWindowNode.java
deleted file mode 100644
index d0e27c9..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/tree/RootWindowNode.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator.tree;
-
-
-
-public class RootWindowNode extends BasicTreeNode {
-
- private final String mWindowName;
- private Object[] mCachedAttributesArray;
- private int mRotation;
-
- public RootWindowNode(String windowName) {
- this(windowName, 0);
- }
-
- public RootWindowNode(String windowName, int rotation) {
- mWindowName = windowName;
- mRotation = rotation;
- }
-
- @Override
- public String toString() {
- return mWindowName;
- }
-
- @Override
- public Object[] getAttributesArray() {
- if (mCachedAttributesArray == null) {
- mCachedAttributesArray = new Object[]{new AttributePair("window-name", mWindowName)};
- }
- return mCachedAttributesArray;
- }
-
- public int getRotation() {
- return mRotation;
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/tree/UiHierarchyXmlLoader.java b/uiautomatorviewer/src/com/android/uiautomator/tree/UiHierarchyXmlLoader.java
deleted file mode 100644
index 2e897d9..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/tree/UiHierarchyXmlLoader.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator.tree;
-
-import org.eclipse.swt.graphics.Rectangle;
-import org.xml.sax.Attributes;
-import org.xml.sax.SAXException;
-import org.xml.sax.helpers.DefaultHandler;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
-
-public class UiHierarchyXmlLoader {
-
- private BasicTreeNode mRootNode;
- private List<Rectangle> mNafNodes;
-
- public UiHierarchyXmlLoader() {
- }
-
- /**
- * Uses a SAX parser to process XML dump
- * @param xmlPath
- * @return
- */
- public BasicTreeNode parseXml(String xmlPath) {
- mRootNode = null;
- mNafNodes = new ArrayList<Rectangle>();
- // standard boilerplate to get a SAX parser
- SAXParserFactory factory = SAXParserFactory.newInstance();
- SAXParser parser = null;
- try {
- parser = factory.newSAXParser();
- } catch (ParserConfigurationException e) {
- e.printStackTrace();
- return null;
- } catch (SAXException e) {
- e.printStackTrace();
- return null;
- }
- // handler class for SAX parser to receiver standard parsing events:
- // e.g. on reading "<foo>", startElement is called, on reading "</foo>",
- // endElement is called
- DefaultHandler handler = new DefaultHandler(){
- BasicTreeNode mParentNode;
- BasicTreeNode mWorkingNode;
- @Override
- public void startElement(String uri, String localName, String qName,
- Attributes attributes) throws SAXException {
- boolean nodeCreated = false;
- // starting an element implies that the element that has not yet been closed
- // will be the parent of the element that is being started here
- mParentNode = mWorkingNode;
- if ("hierarchy".equals(qName)) {
- int rotation = 0;
- for (int i = 0; i < attributes.getLength(); i++) {
- if ("rotation".equals(attributes.getQName(i))) {
- try {
- rotation = Integer.parseInt(attributes.getValue(i));
- } catch (NumberFormatException nfe) {
- // do nothing
- }
- }
- }
- mWorkingNode = new RootWindowNode(attributes.getValue("windowName"), rotation);
- nodeCreated = true;
- } else if ("node".equals(qName)) {
- UiNode tmpNode = new UiNode();
- for (int i = 0; i < attributes.getLength(); i++) {
- tmpNode.addAtrribute(attributes.getQName(i), attributes.getValue(i));
- }
- mWorkingNode = tmpNode;
- nodeCreated = true;
- // check if current node is NAF
- String naf = tmpNode.getAttribute("NAF");
- if ("true".equals(naf)) {
- mNafNodes.add(new Rectangle(tmpNode.x, tmpNode.y,
- tmpNode.width, tmpNode.height));
- }
- }
- // nodeCreated will be false if the element started is neither
- // "hierarchy" nor "node"
- if (nodeCreated) {
- if (mRootNode == null) {
- // this will only happen once
- mRootNode = mWorkingNode;
- }
- if (mParentNode != null) {
- mParentNode.addChild(mWorkingNode);
- }
- }
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- //mParentNode should never be null here in a well formed XML
- if (mParentNode != null) {
- // closing an element implies that we are back to working on
- // the parent node of the element just closed, i.e. continue to
- // parse more child nodes
- mWorkingNode = mParentNode;
- mParentNode = mParentNode.getParent();
- }
- }
- };
- try {
- parser.parse(new File(xmlPath), handler);
- } catch (SAXException e) {
- e.printStackTrace();
- return null;
- } catch (IOException e) {
- e.printStackTrace();
- return null;
- }
- return mRootNode;
- }
-
- /**
- * Returns the list of "Not Accessibility Friendly" nodes found during parsing.
- *
- * Call this function after parsing
- *
- * @return
- */
- public List<Rectangle> getNafNodes() {
- return Collections.unmodifiableList(mNafNodes);
- }
-}
diff --git a/uiautomatorviewer/src/com/android/uiautomator/tree/UiNode.java b/uiautomatorviewer/src/com/android/uiautomator/tree/UiNode.java
deleted file mode 100644
index 4adebf4..0000000
--- a/uiautomatorviewer/src/com/android/uiautomator/tree/UiNode.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2012 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.uiautomator.tree;
-
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class UiNode extends BasicTreeNode {
- private static final Pattern BOUNDS_PATTERN = Pattern
- .compile("\\[-?(\\d+),-?(\\d+)\\]\\[-?(\\d+),-?(\\d+)\\]");
- // use LinkedHashMap to preserve the order of the attributes
- private final Map<String, String> mAttributes = new LinkedHashMap<String, String>();
- private String mDisplayName = "ShouldNotSeeMe";
- private Object[] mCachedAttributesArray;
-
- public void addAtrribute(String key, String value) {
- mAttributes.put(key, value);
- updateDisplayName();
- if ("bounds".equals(key)) {
- updateBounds(value);
- }
- }
-
- public Map<String, String> getAttributes() {
- return Collections.unmodifiableMap(mAttributes);
- }
-
- /**
- * Builds the display name based on attributes of the node
- */
- private void updateDisplayName() {
- String className = mAttributes.get("class");
- if (className == null)
- return;
- String text = mAttributes.get("text");
- if (text == null)
- return;
- String contentDescription = mAttributes.get("content-desc");
- if (contentDescription == null)
- return;
- String index = mAttributes.get("index");
- if (index == null)
- return;
- String bounds = mAttributes.get("bounds");
- if (bounds == null) {
- return;
- }
- // shorten the standard class names, otherwise it takes up too much space on UI
- className = className.replace("android.widget.", "");
- className = className.replace("android.view.", "");
- StringBuilder builder = new StringBuilder();
- builder.append('(');
- builder.append(index);
- builder.append(") ");
- builder.append(className);
- if (!text.isEmpty()) {
- builder.append(':');
- builder.append(text);
- }
- if (!contentDescription.isEmpty()) {
- builder.append(" {");
- builder.append(contentDescription);
- builder.append('}');
- }
- builder.append(' ');
- builder.append(bounds);
- mDisplayName = builder.toString();
- }
-
- private void updateBounds(String bounds) {
- Matcher m = BOUNDS_PATTERN.matcher(bounds);
- if (m.matches()) {
- x = Integer.parseInt(m.group(1));
- y = Integer.parseInt(m.group(2));
- width = Integer.parseInt(m.group(3)) - x;
- height = Integer.parseInt(m.group(4)) - y;
- mHasBounds = true;
- } else {
- throw new RuntimeException("Invalid bounds: " + bounds);
- }
- }
-
- @Override
- public String toString() {
- return mDisplayName;
- }
-
- public String getAttribute(String key) {
- return mAttributes.get(key);
- }
-
- @Override
- public Object[] getAttributesArray() {
- // this approach means we do not handle the situation where an attribute is added
- // after this function is first called. This is currently not a concern because the
- // tree is supposed to be readonly
- if (mCachedAttributesArray == null) {
- mCachedAttributesArray = new Object[mAttributes.size()];
- int i = 0;
- for (String attr : mAttributes.keySet()) {
- mCachedAttributesArray[i++] = new AttributePair(attr, mAttributes.get(attr));
- }
- }
- return mCachedAttributesArray;
- }
-}
diff --git a/uiautomatorviewer/src/images/expandall.png b/uiautomatorviewer/src/images/expandall.png
deleted file mode 100644
index 7bdf83d..0000000
--- a/uiautomatorviewer/src/images/expandall.png
+++ /dev/null
Binary files differ
diff --git a/uiautomatorviewer/src/images/open-folder.png b/uiautomatorviewer/src/images/open-folder.png
deleted file mode 100644
index 8c4a2e1..0000000
--- a/uiautomatorviewer/src/images/open-folder.png
+++ /dev/null
Binary files differ
diff --git a/uiautomatorviewer/src/images/screenshot.png b/uiautomatorviewer/src/images/screenshot.png
deleted file mode 100644
index 423f781..0000000
--- a/uiautomatorviewer/src/images/screenshot.png
+++ /dev/null
Binary files differ
diff --git a/uiautomatorviewer/src/images/warning.png b/uiautomatorviewer/src/images/warning.png
deleted file mode 100644
index ca3b6ed..0000000
--- a/uiautomatorviewer/src/images/warning.png
+++ /dev/null
Binary files differ