File: phone_status_processor.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (141 lines) | stat: -rw-r--r-- 5,707 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROMEOS_ASH_COMPONENTS_PHONEHUB_PHONE_STATUS_PROCESSOR_H_
#define CHROMEOS_ASH_COMPONENTS_PHONEHUB_PHONE_STATUS_PROCESSOR_H_

#include <google/protobuf/repeated_field.h>

#include "base/memory/raw_ptr.h"
#include "base/timer/timer.h"
#include "chromeos/ash/components/phonehub/app_stream_launcher_data_model.h"
#include "chromeos/ash/components/phonehub/feature_status_provider.h"
#include "chromeos/ash/components/phonehub/icon_decoder.h"
#include "chromeos/ash/components/phonehub/message_receiver.h"
#include "chromeos/ash/components/phonehub/phone_hub_structured_metrics_logger.h"
#include "chromeos/ash/components/phonehub/proto/phonehub_api.pb.h"
#include "chromeos/ash/services/multidevice_setup/public/cpp/multidevice_setup_client.h"

class PrefService;

namespace ash::phonehub {

using ::google::protobuf::RepeatedPtrField;

class DoNotDisturbController;
class FindMyDeviceController;
class MutablePhoneModel;
class MultideviceFeatureAccessManager;
class NotificationProcessor;
class ScreenLockManager;
class RecentAppsInteractionHandler;
class AppStreamManager;
class PhoneHubUiReadinessRecorder;

// Responsible for receiving incoming protos and calling on clients to update
// their models.
class PhoneStatusProcessor
    : public MessageReceiver::Observer,
      public FeatureStatusProvider::Observer,
      public multidevice_setup::MultiDeviceSetupClient::Observer {
 public:
  enum class AppListUpdateType {
    kOnlyRecentApps = 0,
    kOnlyLauncherApps,
    kBoth,
    kIncrementalAppUpdate,
    kMaxValue = kIncrementalAppUpdate
  };

  PhoneStatusProcessor(
      DoNotDisturbController* do_not_disturb_controller,
      FeatureStatusProvider* feature_status_provider,
      MessageReceiver* message_receiver,
      FindMyDeviceController* find_my_device_controller,
      MultideviceFeatureAccessManager* multidevice_feature_access_manager,
      ScreenLockManager* screen_lock_manager,
      NotificationProcessor* notification_processor_,
      multidevice_setup::MultiDeviceSetupClient* multidevice_setup_client,
      MutablePhoneModel* phone_model,
      RecentAppsInteractionHandler* recent_apps_interaction_handler,
      PrefService* pref_service,
      AppStreamManager* app_stream_manager,
      AppStreamLauncherDataModel* app_stream_launcher_data_model,
      IconDecoder* icon_decoder_,
      PhoneHubUiReadinessRecorder* phone_hub_ui_readiness_recorder,
      PhoneHubStructuredMetricsLogger* phone_hub_structured_metrics_logger);
  ~PhoneStatusProcessor() override;

  PhoneStatusProcessor(const PhoneStatusProcessor&) = delete;
  PhoneStatusProcessor& operator=(const PhoneStatusProcessor&) = delete;

 private:
  friend class PhoneStatusProcessorTest;

  // FeatureStatusProvider::Observer:
  void OnFeatureStatusChanged() override;

  // MessageReceiver::Observer:
  void OnPhoneStatusSnapshotReceived(
      proto::PhoneStatusSnapshot phone_status_snapshot) override;
  void OnPhoneStatusUpdateReceived(
      proto::PhoneStatusUpdate phone_status_update) override;
  void OnAppStreamUpdateReceived(
      const proto::AppStreamUpdate app_stream_update) override;
  void OnAppListUpdateReceived(
      const proto::AppListUpdate app_list_update) override;
  void OnAppListIncrementalUpdateReceived(
      const proto::AppListIncrementalUpdate app_list_incremental_update)
      override;

  // MultiDeviceSetupClient::Observer:
  void OnHostStatusChanged(
      const multidevice_setup::MultiDeviceSetupClient::HostStatusWithDevice&
          host_device_with_status) override;

  void ProcessReceivedNotifications(
      const RepeatedPtrField<proto::Notification>& notification_protos);

  void SetReceivedPhoneStatusModelStates(
      const proto::PhoneProperties& phone_properties);

  void MaybeSetPhoneModelName(
      const std::optional<multidevice::RemoteDeviceRef>& remote_device);

  void SetEcheFeatureStatusReceivedFromPhoneHub(
      proto::FeatureStatus eche_feature_status);

  void GenerateAppListWithIcons(const proto::StreamableApps& streamable_apps,
                                AppListUpdateType app_list_update_type);

  void IconsDecoded(
      std::vector<Notification::AppMetadata>& apps_list,
      AppListUpdateType app_list_update_type,
      std::unique_ptr<std::vector<IconDecoder::DecodingData>> decode_items);

  raw_ptr<DoNotDisturbController> do_not_disturb_controller_;
  raw_ptr<FeatureStatusProvider> feature_status_provider_;
  raw_ptr<MessageReceiver> message_receiver_;
  raw_ptr<FindMyDeviceController> find_my_device_controller_;
  raw_ptr<MultideviceFeatureAccessManager> multidevice_feature_access_manager_;
  raw_ptr<ScreenLockManager> screen_lock_manager_;
  raw_ptr<NotificationProcessor> notification_processor_;
  raw_ptr<multidevice_setup::MultiDeviceSetupClient> multidevice_setup_client_;
  raw_ptr<MutablePhoneModel> phone_model_;
  raw_ptr<RecentAppsInteractionHandler> recent_apps_interaction_handler_;
  raw_ptr<PrefService> pref_service_;
  raw_ptr<AppStreamManager> app_stream_manager_;
  raw_ptr<AppStreamLauncherDataModel> app_stream_launcher_data_model_;
  raw_ptr<IconDecoder> icon_decoder_;
  raw_ptr<PhoneHubUiReadinessRecorder> phone_hub_ui_readiness_recorder_;
  raw_ptr<PhoneHubStructuredMetricsLogger> phone_hub_structured_metrics_logger_;
  base::TimeTicks connection_initialized_timestamp_ = base::TimeTicks();
  bool has_received_first_app_list_update_ = false;

  base::WeakPtrFactory<PhoneStatusProcessor> weak_ptr_factory_{this};
};

}  // namespace ash::phonehub

#endif  // CHROMEOS_ASH_COMPONENTS_PHONEHUB_PHONE_STATUS_PROCESSOR_H_