Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
package io.appium.java_client.android;

import com.google.common.collect.ImmutableMap;
import io.appium.java_client.CanRememberExtensionPresence;
import io.appium.java_client.CommandExecutionHelper;
import io.appium.java_client.ExecutesMethod;
import org.openqa.selenium.UnsupportedCommandException;

import java.util.List;

import static io.appium.java_client.android.AndroidMobileCommandHelper.getPerformanceDataCommand;
import static io.appium.java_client.android.AndroidMobileCommandHelper.getSupportedPerformanceDataTypesCommand;

public interface HasSupportedPerformanceDataType extends ExecutesMethod {
public interface HasSupportedPerformanceDataType extends ExecutesMethod, CanRememberExtensionPresence {

/**
* returns the information type of the system state which is supported to read
Expand All @@ -18,7 +21,15 @@ public interface HasSupportedPerformanceDataType extends ExecutesMethod {
*
*/
default List<String> getSupportedPerformanceDataTypes() {
return CommandExecutionHelper.execute(this, getSupportedPerformanceDataTypesCommand());
final String extName = "mobile: getPerformanceDataTypes";
try {
return CommandExecutionHelper.executeScript(assertExtensionExists(extName), extName);
} catch (UnsupportedCommandException e) {
// TODO: Remove the fallback
return CommandExecutionHelper.execute(
markExtensionAbsence(extName), getSupportedPerformanceDataTypesCommand()
);
}
}

/**
Expand Down Expand Up @@ -50,7 +61,17 @@ default List<String> getSupportedPerformanceDataTypes() {
* in case of cpu info : [[user, kernel], [0.9, 1.3]]
*/
default List<List<Object>> getPerformanceData(String packageName, String dataType, int dataReadTimeout) {
return CommandExecutionHelper.execute(this,
getPerformanceDataCommand(packageName, dataType, dataReadTimeout));
final String extName = "mobile: getPerformanceData";
try {
return CommandExecutionHelper.executeScript(assertExtensionExists(extName), extName, ImmutableMap.of(
"packageName", packageName,
"dataType", dataType
));
} catch (UnsupportedCommandException e) {
// TODO: Remove the fallback
return CommandExecutionHelper.execute(
markExtensionAbsence(extName), getPerformanceDataCommand(packageName, dataType, dataReadTimeout)
);
}
}
}