[CrOS Hotspot] Notify users about hotspot internal error.
When hotspot is disabled due to an internal error, users are notified and are given an option to turn on the hotspot. This CL introduces changes to enable this functionality. Screenshot: https://screenshot.googleplex.com/7RVGm9GrTp6aKW3 Bug: b/269354043 Change-Id: If177467152521d598a311f1f0189b5d61f9280c0 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4332814 Reviewed-by: Jason Zhang <jiajunz@google.com> Commit-Queue: Nikhil Nayunigari <nikhilcn@google.com> Cr-Commit-Position: refs/heads/main@{#1128120}
This commit is contained in:

committed by
Chromium LUCI CQ

parent
822a924d11
commit
4aff05ae18
@ -2593,6 +2593,9 @@ Connect your device to power.
|
||||
<message name="IDS_ASH_HOTSPOT_AUTO_DISABLED_MESSAGE" desc="Message displayed in the system notification shown when the hotspot is turned off due to inactivity.">
|
||||
Due to inactivity, hotspot has been turned off.
|
||||
</message>
|
||||
<message name="IDS_ASH_HOTSPOT_INTERNAL_ERROR_MESSAGE" desc="Message displayed in the system notification shown when the hotspot is turned off due to internal error.">
|
||||
Due to internal error, hotspot has been turned off. Try reconnecting in a few minutes.
|
||||
</message>
|
||||
<message name="IDS_ASH_NETWORK_AUTOCONNECT" desc="Text used for the toast shown when a network has been auto-connected (e.g., when an enterprise policy is applied which initiates a connection to a corporate network like Google-A).">
|
||||
We've switched you to a better network
|
||||
</message>
|
||||
|
@ -0,0 +1 @@
|
||||
749c8fea4e637e6de7ec69a4217dee634efae194
|
@ -25,6 +25,9 @@ const char HotspotNotifier::kWiFiTurnedOnNotificationId[] =
|
||||
const char HotspotNotifier::kAutoDisabledNotificationId[] =
|
||||
"cros_hotspot_notifier_ids.auto_disabled";
|
||||
|
||||
const char HotspotNotifier::kInternalErrorNotificationId[] =
|
||||
"cros_hotspot_notifier_ids.internal_error";
|
||||
|
||||
const char kNotifierHotspot[] = "ash.hotspot";
|
||||
|
||||
HotspotNotifier::HotspotNotifier() {
|
||||
@ -83,6 +86,19 @@ void HotspotNotifier::OnHotspotTurnedOff(
|
||||
message_center::ButtonInfo(l10n_util::GetStringUTF16(
|
||||
IDS_ASH_HOTSPOT_NOTIFICATION_TURN_ON_BUTTON)));
|
||||
break;
|
||||
case hotspot_config::mojom::DisableReason::kInternalError:
|
||||
title_id = IDS_ASH_HOTSPOT_OFF_TITLE;
|
||||
message_id = IDS_ASH_HOTSPOT_INTERNAL_ERROR_MESSAGE;
|
||||
notification_id = kInternalErrorNotificationId;
|
||||
delegate =
|
||||
base::MakeRefCounted<message_center::HandleNotificationClickDelegate>(
|
||||
base::BindRepeating(&HotspotNotifier::EnableHotspotHandler,
|
||||
weak_ptr_factory_.GetWeakPtr(),
|
||||
notification_id));
|
||||
notification_actions.push_back(
|
||||
message_center::ButtonInfo(l10n_util::GetStringUTF16(
|
||||
IDS_ASH_HOTSPOT_NOTIFICATION_TURN_ON_BUTTON)));
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
@ -116,6 +132,8 @@ void HotspotNotifier::EnableHotspotHandler(const char* notification_id,
|
||||
message_center::MessageCenter::Get();
|
||||
message_center->RemoveNotification(kAutoDisabledNotificationId,
|
||||
/*by_user=*/false);
|
||||
message_center->RemoveNotification(kInternalErrorNotificationId,
|
||||
/*by_user=*/false);
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ class ASH_EXPORT HotspotNotifier
|
||||
static const char kAdminRestrictedNotificationId[];
|
||||
static const char kWiFiTurnedOnNotificationId[];
|
||||
static const char kAutoDisabledNotificationId[];
|
||||
static const char kInternalErrorNotificationId[];
|
||||
|
||||
private:
|
||||
friend class HotspotNotifierTest;
|
||||
|
@ -193,4 +193,22 @@ TEST_F(HotspotNotifierTest, AutoDisabled) {
|
||||
HotspotNotifier::kAutoDisabledNotificationId));
|
||||
}
|
||||
|
||||
TEST_F(HotspotNotifierTest, InternalError) {
|
||||
SetValidHotspotCapabilities();
|
||||
SetReadinessCheckResultReady();
|
||||
AddActiveCellularService();
|
||||
helper()->manager_test()->SetSimulateTetheringEnableResult(
|
||||
FakeShillSimulatedResult::kSuccess, shill::kTetheringEnableResultSuccess);
|
||||
base::RunLoop().RunUntilIdle();
|
||||
|
||||
EnableHotspot();
|
||||
EXPECT_TRUE(message_center::MessageCenter::Get()->FindVisibleNotificationById(
|
||||
HotspotNotifier::kWiFiTurnedOffNotificationId));
|
||||
|
||||
NotifyHotspotTurnedOff(hotspot_config::mojom::DisableReason::kInternalError);
|
||||
base::RunLoop().RunUntilIdle();
|
||||
EXPECT_TRUE(message_center::MessageCenter::Get()->FindVisibleNotificationById(
|
||||
HotspotNotifier::kInternalErrorNotificationId));
|
||||
}
|
||||
|
||||
} // namespace ash
|
||||
|
Reference in New Issue
Block a user