Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified android/AndroidPerfServerFW.dex
Binary file not shown.
Binary file modified android/arm64-v8a/AndroidPerfServer
Binary file not shown.
Binary file modified android/armeabi-v7a/AndroidPerfServer
Binary file not shown.
6 changes: 1 addition & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@
<artifactId>commons-lang3</artifactId>
<version>3.12.0</version>
</dependency>
<dependency>
<groupId>com.github.vidstige</groupId>
<artifactId>jadb</artifactId>
<version>v1.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
Expand All @@ -72,6 +67,7 @@
</dependencies>

<build>
<defaultGoal>compile</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
69 changes: 49 additions & 20 deletions src/main/java/com/android/androidperf/AppController.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class AppController implements Initializable {
@FXML
private ComboBox<String> deviceListBox;
@FXML
private ComboBox<String> packageListBox;
private ComboBox<String> AppListBox;
@FXML
private TableView<DeviceProp> propTable;
@FXML
Expand All @@ -49,6 +49,11 @@ public class AppController implements Initializable {
private final HashMap<String, Device> deviceMap = new HashMap<>();
private final ScheduledExecutorService executorService = Executors.newScheduledThreadPool(1);

private ObservableList<String> packageList;
private ObservableList<String> AppList = FXCollections.observableArrayList();
private HashMap<String, String> packageToApp = new HashMap<>();
private HashMap<String, String> AppToPackage = new HashMap<>();

@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
// initialize the device list
Expand Down Expand Up @@ -77,7 +82,7 @@ public void initialize(URL url, ResourceBundle resourceBundle) {

// UI update
updateUIOnStateChanges();
packageListBox.setDisable(true);
AppListBox.setDisable(true);

// activate auto refresh task
executorService.scheduleAtFixedRate(this::refreshTask, 500, 500, TimeUnit.MILLISECONDS);
Expand Down Expand Up @@ -197,6 +202,27 @@ public final void addDataToChart(String chartName, XYChart.Data<Number, Number>.
}
}

public void updateConversionHashMap() {
packageToApp.clear();
AppToPackage.clear();
for (String packageName: packageList
) {
String AppName = new String(selectedDevice.sendMSG("convert "+packageName));
LOGGER.debug(AppName);
packageToApp.put(packageName, AppName);
AppToPackage.put(AppName, packageName);
}
}

public void updateAppList() {
AppList.clear();
updateConversionHashMap();
for (String packageName: packageList
) {
AppList.add(packageToApp.get(packageName));
}
}

public void handleDeviceListBox() {
if (selectedDevice != null)
selectedDevice.endPerf();
Expand All @@ -222,8 +248,10 @@ public void handleDeviceListBox() {
dialog.close();
propTable.getItems().clear();

// initialize the package list
packageListBox.setItems(selectedDevice.getPackageList());
// initialize the package list and the App list
packageList = selectedDevice.getPackageList();
updateAppList();
AppListBox.setItems(AppList);

// initialize basic properties of the device
ArrayList<DeviceProp> props = selectedDevice.getProps();
Expand All @@ -232,7 +260,7 @@ public void handleDeviceListBox() {

// UI update
updateUIOnStateChanges();
packageListBox.setDisable(false);
AppListBox.setDisable(false);
});
});
task.setOnFailed((e) -> {
Expand All @@ -250,27 +278,28 @@ private void refreshTask() {
}
}

public void movePackageToFront(String packageName) {
EventHandler<ActionEvent> handler = packageListBox.getOnAction();
packageListBox.setOnAction(null);
String selected = packageListBox.getSelectionModel().getSelectedItem();
var packageList = selectedDevice.getPackageList();
public void moveAppToFront(String packageName) {
EventHandler<ActionEvent> handler = AppListBox.getOnAction();
AppListBox.setOnAction(null);
String selectedApp = AppListBox.getSelectionModel().getSelectedItem();
packageList = selectedDevice.getPackageList();
packageList.remove(packageName);
packageList.add(0, packageName);
if (selected != null) {
packageListBox.getSelectionModel().select(selected);
packageListBox.setValue(selected);
updateAppList();
if (selectedApp != null) {
AppListBox.getSelectionModel().select(selectedApp);
AppListBox.setValue(selectedApp);
}
packageListBox.setOnAction(handler);
AppListBox.setOnAction(handler);
}

public void handlePackageListBox() {
String packageName = packageListBox.getSelectionModel().getSelectedItem();
if (packageName == null || packageName.length() == 0) {
public void handleAppListBox() {
String AppName = AppListBox.getSelectionModel().getSelectedItem();
if (AppName == null || AppName.length() == 0) {
selectedDevice.endPerf();
return;
}
selectedDevice.setTargetPackage(packageName);
selectedDevice.setTargetPackage(AppToPackage.get(AppName));

// UI update
updateUIOnStateChanges();
Expand All @@ -290,7 +319,7 @@ public void handleUpdateBtn() {
if (selectedDevice != null) {
selectedDevice.updatePackageList();
} else {
packageListBox.getItems().clear();
AppListBox.getItems().clear();
propTable.getItems().clear();
}
}
Expand All @@ -300,7 +329,7 @@ public void updateUIOnStateChanges() {
if (selectedDevice == null) {
deviceListBox.setPromptText("Select connected devices");
}
packageListBox.setPromptText("Select target package");
AppListBox.setPromptText("Select target App");
perfBtn.setDisable(true);
perfBtn.setText("Start");
return;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/android/androidperf/Device.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public void checkCurrentPackage() {
String packageName = packageInfo[0];
if (packageInfo.length == 2 && !packageList.get(0).equals(packageName)) {
Platform.runLater(() -> {
controller.movePackageToFront(packageName);
controller.moveAppToFront(packageName);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/com/android/androidperf/main-view.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<VBox.margin>
<Insets left="10.0" right="10.0" top="40.0" />
</VBox.margin></ComboBox>
<ComboBox fx:id="packageListBox" maxWidth="1.7976931348623157E308" onAction="#handlePackageListBox" prefWidth="150.0">
<ComboBox fx:id="AppListBox" maxWidth="1.7976931348623157E308" onAction="#handleAppListBox" prefWidth="150.0">
<VBox.margin>
<Insets left="10.0" right="10.0" top="40.0" />
</VBox.margin></ComboBox>
Expand Down