Skip to content

Commit

Permalink
Internal change
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 719173779
  • Loading branch information
DeviceInfra authored and copybara-github committed Jan 24, 2025
1 parent 946f66a commit c8d7a81
Show file tree
Hide file tree
Showing 19 changed files with 19 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1212,13 +1212,10 @@ protected abstract void prependedRealDeviceAfterTestProcess(TestInfo testInfo)

/** Returns {@code true} if skip the default operations after the test. */
protected abstract boolean skipRealDeviceDefaultAfterTestProcess()
throws com.google.devtools.mobileharness.api.model.error.MobileHarnessException,
InterruptedException;
throws MobileHarnessException, InterruptedException;

/** Reboots the Android real device. */
public void reboot()
throws com.google.devtools.mobileharness.api.model.error.MobileHarnessException,
InterruptedException {
public void reboot() throws MobileHarnessException, InterruptedException {
if (Flags.instance().disableDeviceReboot.getNonNull()) {
logger.atInfo().log("Device reboot is disabled, skip rebooting device %s.", deviceId);
return;
Expand Down Expand Up @@ -1262,9 +1259,7 @@ public void reboot()
}

/** Takes device screenshot and returns the screenshot local path in the host machine. */
public String takeScreenshot()
throws com.google.devtools.mobileharness.api.model.error.MobileHarnessException,
InterruptedException {
public String takeScreenshot() throws MobileHarnessException, InterruptedException {
String screensShotFilePathOnDevice =
PathUtil.join(AndroidRealDeviceConstants.TEMP_SCREEN_SHOT_PATH, UUID.randomUUID() + ".png");
String desFilePathOnHost = BaseDeviceHelper.getGenScreenshotPathWithDate(device);
Expand Down Expand Up @@ -1633,8 +1628,7 @@ static ReadOnlyPropertySetting of(
*/
private void connectToWifi(
String serial, int sdkVersion, String ssid, String pwd, boolean scanSsid)
throws com.google.wireless.qa.mobileharness.shared.MobileHarnessException,
InterruptedException {
throws MobileHarnessException, InterruptedException {
if (Flags.instance().disableWifiUtilFunc.getNonNull()) {
logger.atInfo().log(
"Wifi util functionality is disabled. Skip connecting device %s to wifi.", serial);
Expand Down Expand Up @@ -1687,7 +1681,7 @@ boolean checkNetwork() throws InterruptedException {
// device. {@link b/197480620#comment6}.
.build(),
null);
} catch (com.google.wireless.qa.mobileharness.shared.MobileHarnessException e) {
} catch (MobileHarnessException e) {
logger.atWarning().log(
"Failed to install WiFi apk: %s", MoreThrowables.shortDebugString(e));
}
Expand Down Expand Up @@ -1778,7 +1772,7 @@ private Optional<String> checkNetworkSsid() throws InterruptedException {
defaultWifi.getSsid(),
defaultWifi.getPsk(),
defaultWifi.getScanSsid());
} catch (com.google.wireless.qa.mobileharness.shared.MobileHarnessException e) {
} catch (MobileHarnessException e) {
logger.atWarning().log(
"Failed to connect device %s to WIFI %s with psk %s, scan_ssid %s: %s",
deviceId,
Expand Down Expand Up @@ -2470,8 +2464,7 @@ private boolean isTestHarnessRecoveryDevice() {
* @param startChargeLevel battery level at which charging should be started
*/
private void toggleChargingForSafeDischarge(int stopChargeLevel, int startChargeLevel)
throws com.google.wireless.qa.mobileharness.shared.MobileHarnessException,
InterruptedException {
throws MobileHarnessException, InterruptedException {
int batteryLevel = systemSettingUtil.getBatteryLevel(deviceId);
boolean enableCharging;
if (batteryLevel <= startChargeLevel) {
Expand Down Expand Up @@ -2501,13 +2494,13 @@ private void enforceSafeDischargeLevelIfNeeded() throws InterruptedException {
Integer startChargeLevelInt = Flags.instance().startChargeLevel.getNonNull();
try {
chargingUtil.setFullChargeLevel(device, safeChargeLevelInt);
} catch (com.google.wireless.qa.mobileharness.shared.MobileHarnessException e) {
} catch (MobileHarnessException e) {
logger.atWarning().log(
"Error setting full charge level for device %s: %s",
deviceId, MoreThrowables.shortDebugString(e));
try {
toggleChargingForSafeDischarge(stopChargeLevelInt, startChargeLevelInt);
} catch (com.google.wireless.qa.mobileharness.shared.MobileHarnessException e2) {
} catch (MobileHarnessException e2) {
logger.atWarning().log(
"Failed to enforce device %s safe discharge level: %s",
deviceId, MoreThrowables.shortDebugString(e2));
Expand Down Expand Up @@ -2548,7 +2541,7 @@ private void enableDeviceChargeBeforeTest(TestInfo testInfo) throws InterruptedE
.atInfo()
.alsoTo(logger)
.log("Turn on charging on device %s before test %s", deviceId, testId);
} catch (com.google.wireless.qa.mobileharness.shared.MobileHarnessException e) {
} catch (MobileHarnessException e) {
logger.atWarning().log(
"Error when enabling charge for device %s before test %s: %s",
deviceId, testInfo.locator().getId(), MoreThrowables.shortDebugString(e));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ java_library(
"//src/java/com/google/devtools/mobileharness/shared/util/logging:google_logger",
"//src/java/com/google/devtools/mobileharness/shared/util/network",
"//src/java/com/google/devtools/mobileharness/shared/util/path",
"//src/java/com/google/wireless/qa/mobileharness/shared:exception",
"//src/java/com/google/wireless/qa/mobileharness/shared/android:runtime_charging_util",
"//src/java/com/google/wireless/qa/mobileharness/shared/android:wifi_util",
"//src/java/com/google/wireless/qa/mobileharness/shared/api/device:android_device",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ java_library(
"//src/java/com/google/devtools/mobileharness/shared/util/error:more_throwables",
"//src/java/com/google/devtools/mobileharness/shared/util/flags",
"//src/java/com/google/devtools/mobileharness/shared/util/logging:google_logger",
"//src/java/com/google/wireless/qa/mobileharness/shared:exception",
"@maven//:com_google_guava_guava",
"@maven//:com_google_inject_guice",
"@maven//:javax_inject_jsr330_api",
Expand Down Expand Up @@ -155,7 +154,6 @@ java_library(
"//src/java/com/google/devtools/mobileharness/shared/util/flags",
"//src/java/com/google/devtools/mobileharness/shared/util/jobconfig:job_info_creator",
"//src/java/com/google/devtools/mobileharness/shared/util/logging:google_logger",
"//src/java/com/google/wireless/qa/mobileharness/shared:exception",
"//src/java/com/google/wireless/qa/mobileharness/shared/constant:dimension",
"//src/java/com/google/wireless/qa/mobileharness/shared/model/job",
"//src/java/com/google/wireless/qa/mobileharness/shared/proto:job_config_java_proto",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private ImmutableMap<String, DeviceDetails> getAllAndroidDevicesFromMaster()
DeviceQueryResult queryResult;
try {
queryResult = deviceQuerier.queryDevice(DeviceQueryFilter.getDefaultInstance());
} catch (com.google.wireless.qa.mobileharness.shared.MobileHarnessException e) {
} catch (MobileHarnessException e) {
throw new MobileHarnessException(
InfraErrorId.ATSC_RUN_COMMAND_QUERY_DEVICE_ERROR, "Failed to query device", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ private Optional<DeviceInfo> getDeviceInfoFromMaster(SessionRequestInfo sessionR
DeviceQueryResult queryResult;
try {
queryResult = deviceQuerier.queryDevice(DeviceQueryFilter.getDefaultInstance());
} catch (com.google.wireless.qa.mobileharness.shared.MobileHarnessException e) {
} catch (MobileHarnessException e) {
throw new MobileHarnessException(
InfraErrorId.ATSC_RUN_COMMAND_QUERY_DEVICE_ERROR, "Failed to query device", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,6 @@ java_library(
"//src/java/com/google/devtools/mobileharness/shared/util/concurrent:more_futures",
"//src/java/com/google/devtools/mobileharness/shared/util/flags",
"//src/java/com/google/devtools/mobileharness/shared/util/logging:google_logger",
"//src/java/com/google/wireless/qa/mobileharness/shared:exception",
"//src/java/com/google/wireless/qa/mobileharness/shared/constant:dimension",
"@maven//:com_google_code_findbugs_jsr305",
"@maven//:com_google_guava_guava",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ private static String convertDeviceStateFromAdb(DeviceState state) {
private DeviceQueryResult queryDevice() throws MobileHarnessException, InterruptedException {
try {
return deviceQuerier.queryDevice(DeviceQueryFilter.getDefaultInstance());
} catch (com.google.wireless.qa.mobileharness.shared.MobileHarnessException e) {
} catch (MobileHarnessException e) {
throw new MobileHarnessException(
InfraErrorId.ATSC_LIST_DEVICES_QUERY_DEVICE_ERROR, "Failed to query device", e);
}
Expand Down
1 change: 0 additions & 1 deletion src/java/com/google/devtools/mobileharness/infra/lab/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ java_library(
"//src/java/com/google/devtools/mobileharness/shared/version:version_util",
"//src/java/com/google/devtools/mobileharness/shared/version/rpc/service",
"//src/java/com/google/devtools/mobileharness/shared/version/rpc/service/grpc",
"//src/java/com/google/wireless/qa/mobileharness/shared:exception",
"//src/java/com/google/wireless/qa/mobileharness/shared:log",
"//src/java/com/google/wireless/qa/mobileharness/shared/api/device:base_device",
"//src/java/com/google/wireless/qa/mobileharness/shared/comm/message:test_message_manager",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,10 +323,7 @@ protected void configure() {

logger.atInfo().log("Lab server successfully started");
startingFuture.set(TestServices.of(testManager, deviceManager));
} catch (com.google.wireless.qa.mobileharness.shared.MobileHarnessException
| IOException
| RuntimeException
| Error e) {
} catch (MobileHarnessException | IOException | RuntimeException | Error e) {
MobileHarnessException exception =
new MobileHarnessException(
InfraErrorId.LAB_UTRS_SERVER_START_ERROR, "Failed to run lab server", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ java_library(
"//src/java/com/google/devtools/mobileharness/shared/util/time:time_utils",
"//src/java/com/google/devtools/mobileharness/shared/version",
"//src/java/com/google/devtools/mobileharness/shared/version/checker",
"//src/java/com/google/wireless/qa/mobileharness/shared:exception",
"//src/java/com/google/wireless/qa/mobileharness/shared/api",
"//src/java/com/google/wireless/qa/mobileharness/shared/proto:job_java_proto",
"//src/java/com/google/wireless/qa/mobileharness/shared/util:base",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public CreateTestResponse createTest(CreateTestRequest req)
"Skip duplicated CreateTest request for the allocation %s. "
+ "See b/38099373 for more detail.",
allocation);
} catch (com.google.wireless.qa.mobileharness.shared.MobileHarnessException e) {
} catch (MobileHarnessException e) {
throw new MobileHarnessException(
InfraErrorId.LAB_RPC_PREPARE_TEST_TEST_RUNNER_START_ERROR,
String.format("Failed to start test %s", testExecutionUnit.locator().id()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ java_library(
"//src/java/com/google/devtools/mobileharness/shared/util/file/local",
"//src/java/com/google/devtools/mobileharness/shared/util/message:str_pair",
"//src/java/com/google/wireless/qa/mobileharness/lab/proto:exec_test_serv_java_proto",
"//src/java/com/google/wireless/qa/mobileharness/shared:exception",
"//src/java/com/google/wireless/qa/mobileharness/shared/model/job",
"//src/java/com/google/wireless/qa/mobileharness/shared/model/job/out:timing",
"//src/java/com/google/wireless/qa/mobileharness/shared/proto:job_java_proto",
"@maven//:com_google_guava_guava",
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public TestInfo create(KickOffTestRequest req)
jobInfo.protoSpec().setProto(req.getJob().getJobSpec()).tryResolveUnknownExtension();
try {
jobInfo.scopedSpecs().addJson(req.getJob().getJobScopedSpecsJson());
} catch (com.google.wireless.qa.mobileharness.shared.MobileHarnessException e) {
} catch (MobileHarnessException e) {
throw new MobileHarnessException(
BasicErrorId.JOB_SET_JOB_SCOPED_SPECS_ERROR_IN_LAB,
"Failed to set job scoped specs: " + req.getJob().getJobScopedSpecsJson(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ java_library(
"//src/java/com/google/devtools/mobileharness/platform/android/systemsetting:system_setting_util",
"//src/java/com/google/devtools/mobileharness/shared/util/base",
"//src/java/com/google/devtools/mobileharness/shared/util/logging:google_logger",
"//src/java/com/google/wireless/qa/mobileharness/shared:exception",
"//src/java/com/google/wireless/qa/mobileharness/shared/api",
"//src/java/com/google/wireless/qa/mobileharness/shared/log",
"@maven//:com_google_code_findbugs_jsr305",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ private ImmutableMap<String, String> prepareDeviceDaemonExtras(
if (sdkVersion >= 28 && systemSettingUtil.isLocationServiceDisabled(deviceId)) {
try {
ssid = connectivityUtil.getNetworkSsid(deviceId, sdkVersion);
} catch (com.google.wireless.qa.mobileharness.shared.MobileHarnessException e) {
} catch (MobileHarnessException e) {
throw new MobileHarnessException(
AndroidErrorId.ANDROID_DEVICE_DAEMON_HELPER_GET_NETWORK_SSID_ERROR, e.getMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ public ImmutableList<String> getBuildApks(TestInfo testInfo)
try {
androidInstrumentationSpec =
testInfo.jobInfo().combinedSpecOfClass(AndroidInstrumentationSpec.class);
} catch (com.google.wireless.qa.mobileharness.shared.MobileHarnessException e) {
} catch (MobileHarnessException e) {
throw new MobileHarnessException(
AndroidErrorId.ANDROID_INSTRUMENTATION_SPEC_PARSE_ERROR,
"Failed to parse Android Instrumentation Spec",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ java_library(
"//src/java/com/google/devtools/mobileharness/shared/util/file/local:res_util",
"//src/java/com/google/devtools/mobileharness/shared/util/logging:google_logger",
"//src/java/com/google/devtools/mobileharness/shared/util/path",
"//src/java/com/google/wireless/qa/mobileharness/shared:exception",
"//src/java/com/google/wireless/qa/mobileharness/shared/android:aapt",
"//src/java/com/google/wireless/qa/mobileharness/shared/api/device",
"//src/java/com/google/wireless/qa/mobileharness/shared/api/spec:android_instrumentation_driver_spec",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ java_library(
"//src/java/com/google/devtools/mobileharness/platform/android/sdktool/adb:enums",
"//src/java/com/google/devtools/mobileharness/platform/android/systemstate:system_state_util",
"//src/java/com/google/devtools/mobileharness/shared/util/logging:google_logger",
"//src/java/com/google/wireless/qa/mobileharness/shared:exception",
"//src/java/com/google/wireless/qa/mobileharness/shared/api",
"//src/java/com/google/wireless/qa/mobileharness/shared/log",
"//src/java/com/google/wireless/qa/mobileharness/shared/util:device",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ public void reboot(
systemStateUtil.waitForDevice(deviceId, deviceReadyTimeout);
}
systemStateUtil.waitUntilReady(deviceId, deviceReadyTimeout);
} catch (com.google.wireless.qa.mobileharness.shared.MobileHarnessException e) {
} catch (MobileHarnessException e) {
throw new MobileHarnessException(
AndroidErrorId.SYSTEM_STATE_MANAGER_REBOOT_DEVICE_ERROR, e.getMessage(), e);
} finally {
Expand Down

0 comments on commit c8d7a81

Please sign in to comment.