Commit 65d14692 authored by Mahmoud Gawad's avatar Mahmoud Gawad Committed by Commit Bot

[Telemetry SWX] Remove paramters from routines

cros_healthd had removed two paramters from two battery routines:
- |low_mah| and |high_mah| from 'BatteryCapacityRoutine'.
- |maximum_cycle_count| and |percent_battery_wear_allowed| from
'BatteryHealthRoutine'.

This CL removes the corresponding parameters from the corresponding
routines found in TelemetryExtension in both:
- Mojo interface exposed to Telemetry SWXs.
- WebIDL interface exposed to third-party code.
Also removes the dependency on the removed parameters from
browser_tests.

Bug: b:171327161
Change-Id: Idaa57d0a05986883c26337a151f0c0adfb5f5272
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2507698Reviewed-by: default avatarTom Sepez <tsepez@chromium.org>
Reviewed-by: default avatarOleh Lamzin <lamzin@google.com>
Commit-Queue: Mahmoud Gawad <mgawad@google.com>
Cr-Commit-Position: refs/heads/master@{#823534}
parent 048aae96
...@@ -64,10 +64,7 @@ void DiagnosticsService::GetRoutineUpdate( ...@@ -64,10 +64,7 @@ void DiagnosticsService::GetRoutineUpdate(
std::move(callback))); std::move(callback)));
} }
// TODO(b/171327161): Remove |low_mah| and |high_mah| from this routine.
void DiagnosticsService::RunBatteryCapacityRoutine( void DiagnosticsService::RunBatteryCapacityRoutine(
uint32_t low_mah,
uint32_t high_mah,
RunBatteryCapacityRoutineCallback callback) { RunBatteryCapacityRoutineCallback callback) {
GetService()->RunBatteryCapacityRoutine( GetService()->RunBatteryCapacityRoutine(
base::BindOnce( base::BindOnce(
...@@ -79,11 +76,7 @@ void DiagnosticsService::RunBatteryCapacityRoutine( ...@@ -79,11 +76,7 @@ void DiagnosticsService::RunBatteryCapacityRoutine(
std::move(callback))); std::move(callback)));
} }
// TODO(b/171327161): Remove |maximum_cycle_count| and
// |percent_battery_wear_allowed| from this routine.
void DiagnosticsService::RunBatteryHealthRoutine( void DiagnosticsService::RunBatteryHealthRoutine(
uint32_t maximum_cycle_count,
uint32_t percent_battery_wear_allowed,
RunBatteryHealthRoutineCallback callback) { RunBatteryHealthRoutineCallback callback) {
GetService()->RunBatteryHealthRoutine( GetService()->RunBatteryHealthRoutine(
base::BindOnce( base::BindOnce(
......
...@@ -38,12 +38,8 @@ class DiagnosticsService : public health::mojom::DiagnosticsService { ...@@ -38,12 +38,8 @@ class DiagnosticsService : public health::mojom::DiagnosticsService {
bool include_output, bool include_output,
GetRoutineUpdateCallback callback) override; GetRoutineUpdateCallback callback) override;
void RunBatteryCapacityRoutine( void RunBatteryCapacityRoutine(
uint32_t low_mah,
uint32_t high_mah,
RunBatteryCapacityRoutineCallback callback) override; RunBatteryCapacityRoutineCallback callback) override;
void RunBatteryHealthRoutine( void RunBatteryHealthRoutine(
uint32_t maximum_cycle_count,
uint32_t percent_battery_wear_allowed,
RunBatteryHealthRoutineCallback callback) override; RunBatteryHealthRoutineCallback callback) override;
void RunSmartctlCheckRoutine( void RunSmartctlCheckRoutine(
RunSmartctlCheckRoutineCallback callback) override; RunSmartctlCheckRoutineCallback callback) override;
......
...@@ -42,38 +42,29 @@ interface DiagnosticsService { ...@@ -42,38 +42,29 @@ interface DiagnosticsService {
=> (RoutineUpdate routine_update); => (RoutineUpdate routine_update);
// Requests that the BatteryCapacity routine is created and started on the // Requests that the BatteryCapacity routine is created and started on the
// platform. This routine checks the battery's design capacity against the // platform. This routine checks the battery's design capacity against inputs
// inputs. The routine will pass iff the design capacity of the battery read // configured in cros_config. If no configuration data is present in
// from the platform is inclusively within these bounds. This routine is only // cros_config, the routine will fall back to fleet-wide default values of
// available if GetAvailableRoutines returned kBatteryCapactity. // [1000, 10000]. The routine will pass iff the design capacity of the battery
// // read from the platform is inclusively within these bounds. This routine is
// The request: // only available if GetAvailableRoutines returned kBatteryCapactity.
// * |low_mah| - lower bound for the battery's design capacity (mAh).
// * |high_mah| - upper bound for the battery's design capacity (mAh).
// //
// The response: // The response:
// * |response| - contains a unique identifier and status for the created // * |response| - contains a unique identifier and status for the created
// routine. // routine.
RunBatteryCapacityRoutine(uint32 low_mah, uint32 high_mah) RunBatteryCapacityRoutine() => (RunRoutineResponse response);
=> (RunRoutineResponse response);
// Requests that the BatteryHealth routine is created and started on the // Requests that the BatteryHealth routine is created and started on the
// platform. This routine checks the cycle count and percent wear of the // battery against inputs configured in cros_config. If no configuration data
// battery. This routine is only available if GetAvailableRoutines returned // is present in cros_config, the routine will fall back to fleet-wide default
// kBatteryHealth. // values of 1000 for the maximum allowable cycle count and 50% for maximum
// // battery wear percentage allowed. This routine is only available if
// The request: // GetAvailableRoutines returned kBatteryHealth.
// * |maximum_cycle_count| - maximum cycle count allowed for the routine to
// pass.
// * |percent_battery_wear_allowed| - maximum percent battery wear allowed for
// the routine to pass.
// //
// The response: // The response:
// * |response| - contains a unique identifier and status for the created // * |response| - contains a unique identifier and status for the created
// routine. // routine.
RunBatteryHealthRoutine(uint32 maximum_cycle_count, RunBatteryHealthRoutine() => (RunRoutineResponse response);
uint32 percent_battery_wear_allowed)
=> (RunRoutineResponse response);
// Requests that the SmartctlCheck routine is created and started on the // Requests that the SmartctlCheck routine is created and started on the
// platform. This routine checks available spare NVMe capacity against the // platform. This routine checks available spare NVMe capacity against the
......
...@@ -80,18 +80,14 @@ dpsl_internal.DiagnosticsGetRoutineUpdateResponse; ...@@ -80,18 +80,14 @@ dpsl_internal.DiagnosticsGetRoutineUpdateResponse;
/** /**
* Request message sent by the unprivileged context to the privileged * Request message sent by the unprivileged context to the privileged
* context to run battery capacity routine. * context to run battery capacity routine.
* @typedef {{ * @typedef { null }
* lowMah: !number,
* highMah: !number}}
*/ */
dpsl_internal.DiagnosticsRunBatteryCapacityRoutineRequest; dpsl_internal.DiagnosticsRunBatteryCapacityRoutineRequest;
/** /**
* Request message sent by the unprivileged context to the privileged * Request message sent by the unprivileged context to the privileged
* context to run battery health routine. * context to run battery health routine.
* @typedef {{ * @typedef { null }
* maximumCycleCount: !number,
* percentBatteryWearAllowed: !number}}
*/ */
dpsl_internal.DiagnosticsRunBatteryHealthRoutineRequest; dpsl_internal.DiagnosticsRunBatteryHealthRoutineRequest;
......
...@@ -354,32 +354,18 @@ class DiagnosticsProxy { ...@@ -354,32 +354,18 @@ class DiagnosticsProxy {
/** /**
* Runs battery capacity routine. * Runs battery capacity routine.
* @param { !Object } message
* @return { !RunRoutineResponsePromise } * @return { !RunRoutineResponsePromise }
*/ */
async handleRunBatteryCapacityRoutine(message) { async handleRunBatteryCapacityRoutine() {
const request = return await getOrCreateDiagnosticsService().runBatteryCapacityRoutine();
/**
* @type {!dpsl_internal.DiagnosticsRunBatteryCapacityRoutineRequest}
*/
(message);
return await getOrCreateDiagnosticsService().runBatteryCapacityRoutine(
request.lowMah, request.highMah);
}; };
/** /**
* Runs battery health routine. * Runs battery health routine.
* @param { !Object } message
* @return { !RunRoutineResponsePromise } * @return { !RunRoutineResponsePromise }
*/ */
async handleRunBatteryHealthRoutine(message) { async handleRunBatteryHealthRoutine() {
const request = return await getOrCreateDiagnosticsService().runBatteryHealthRoutine();
/**
* @type {!dpsl_internal.DiagnosticsRunBatteryHealthRoutineRequest}
*/
(message);
return await getOrCreateDiagnosticsService().runBatteryHealthRoutine(
request.maximumCycleCount, request.percentBatteryWearAllowed);
}; };
/** /**
...@@ -973,14 +959,12 @@ untrustedMessagePipe.registerHandler( ...@@ -973,14 +959,12 @@ untrustedMessagePipe.registerHandler(
untrustedMessagePipe.registerHandler( untrustedMessagePipe.registerHandler(
dpsl_internal.Message.DIAGNOSTICS_RUN_BATTERY_CAPACITY_ROUTINE, dpsl_internal.Message.DIAGNOSTICS_RUN_BATTERY_CAPACITY_ROUTINE,
(message) => diagnosticsProxy.genericRunRoutineHandler( (message) => diagnosticsProxy.genericRunRoutineHandler(
(message) => diagnosticsProxy.handleRunBatteryCapacityRoutine(message), () => diagnosticsProxy.handleRunBatteryCapacityRoutine(), message));
message));
untrustedMessagePipe.registerHandler( untrustedMessagePipe.registerHandler(
dpsl_internal.Message.DIAGNOSTICS_RUN_BATTERY_HEALTH_ROUTINE, dpsl_internal.Message.DIAGNOSTICS_RUN_BATTERY_HEALTH_ROUTINE,
(message) => diagnosticsProxy.genericRunRoutineHandler( (message) => diagnosticsProxy.genericRunRoutineHandler(
(message) => diagnosticsProxy.handleRunBatteryHealthRoutine(message), () => diagnosticsProxy.handleRunBatteryHealthRoutine(), message));
message));
untrustedMessagePipe.registerHandler( untrustedMessagePipe.registerHandler(
dpsl_internal.Message.DIAGNOSTICS_RUN_SMARTCTL_CHECK_ROUTINE, dpsl_internal.Message.DIAGNOSTICS_RUN_SMARTCTL_CHECK_ROUTINE,
......
...@@ -77,21 +77,13 @@ chromeos.test_support = {}; ...@@ -77,21 +77,13 @@ chromeos.test_support = {};
/** /**
* Requests battery capacity routine to be run. * Requests battery capacity routine to be run.
* @param { !number } lowMah
* @param { !number } highMah
* @return { !Promise<!Object> } * @return { !Promise<!Object> }
* @public * @public
*/ */
async runBatteryCapacityRoutine(lowMah, highMah) { async runBatteryCapacityRoutine() {
const message =
/**
@type {!dpsl_internal.DiagnosticsRunBatteryCapacityRoutineRequest}
*/
({lowMah: lowMah, highMah: highMah});
const response = const response =
/** @type {!Object} */ (await messagePipe.sendMessage( /** @type {!Object} */ (await messagePipe.sendMessage(
dpsl_internal.Message.DIAGNOSTICS_RUN_BATTERY_CAPACITY_ROUTINE, dpsl_internal.Message.DIAGNOSTICS_RUN_BATTERY_CAPACITY_ROUTINE));
message));
if (response instanceof Error) { if (response instanceof Error) {
throw response; throw response;
} }
...@@ -100,25 +92,13 @@ chromeos.test_support = {}; ...@@ -100,25 +92,13 @@ chromeos.test_support = {};
/** /**
* Requests battery health routine to be run. * Requests battery health routine to be run.
* @param { !number } maximumCycleCount
* @param { !number } percentBatteryWearAllowed
* @return { !Promise<!Object> } * @return { !Promise<!Object> }
* @public * @public
*/ */
async runBatteryHealthRoutine( async runBatteryHealthRoutine() {
maximumCycleCount, percentBatteryWearAllowed) {
const message =
/**
@type {!dpsl_internal.DiagnosticsRunBatteryCapacityRoutineRequest}
*/
({
maximumCycleCount: maximumCycleCount,
percentBatteryWearAllowed: percentBatteryWearAllowed
});
const response = const response =
/** @type {!Object} */ (await messagePipe.sendMessage( /** @type {!Object} */ (await messagePipe.sendMessage(
dpsl_internal.Message.DIAGNOSTICS_RUN_BATTERY_HEALTH_ROUTINE, dpsl_internal.Message.DIAGNOSTICS_RUN_BATTERY_HEALTH_ROUTINE));
message));
if (response instanceof Error) { if (response instanceof Error) {
throw response; throw response;
} }
......
...@@ -117,7 +117,7 @@ UNTRUSTED_TEST( ...@@ -117,7 +117,7 @@ UNTRUSTED_TEST(
UNTRUSTED_TEST( UNTRUSTED_TEST(
'UntrustedDiagnosticsRequestRunBatteryCapacityRoutine', async () => { 'UntrustedDiagnosticsRequestRunBatteryCapacityRoutine', async () => {
const response = const response =
await chromeos.diagnostics.runBatteryCapacityRoutine(3000, 4000); await chromeos.diagnostics.runBatteryCapacityRoutine();
assertDeepEquals(response, {id: 123456789, status: 'ready'}); assertDeepEquals(response, {id: 123456789, status: 'ready'});
}); });
...@@ -125,7 +125,7 @@ UNTRUSTED_TEST( ...@@ -125,7 +125,7 @@ UNTRUSTED_TEST(
UNTRUSTED_TEST( UNTRUSTED_TEST(
'UntrustedDiagnosticsRequestRunBatteryHealthRoutine', async () => { 'UntrustedDiagnosticsRequestRunBatteryHealthRoutine', async () => {
const response = const response =
await chromeos.diagnostics.runBatteryHealthRoutine(10, 5); await chromeos.diagnostics.runBatteryHealthRoutine();
assertDeepEquals(response, {id: 123456789, status: 'ready'}); assertDeepEquals(response, {id: 123456789, status: 'ready'});
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment