arc_prefs.cc 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. // Copyright 2017 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "ash/components/arc/arc_prefs.h"
  5. #include "ash/components/arc/session/arc_management_transition.h"
  6. #include <string>
  7. #include "components/guest_os/guest_os_prefs.h"
  8. #include "components/prefs/pref_registry_simple.h"
  9. namespace arc {
  10. namespace prefs {
  11. // ======== PROFILE PREFS ========
  12. // See below for local state prefs.
  13. // A bool preference indicating whether traffic other than the VPN connection
  14. // set via kAlwaysOnVpnPackage should be blackholed.
  15. const char kAlwaysOnVpnLockdown[] = "arc.vpn.always_on.lockdown";
  16. // A string preference indicating the Android app that will be used for
  17. // "Always On VPN". Should be empty if "Always On VPN" is not enabled.
  18. const char kAlwaysOnVpnPackage[] = "arc.vpn.always_on.vpn_package";
  19. // Stores the user id received from DM Server when enrolling a Play user on an
  20. // Active Directory managed device. Used to report to DM Server that the account
  21. // is still used.
  22. const char kArcActiveDirectoryPlayUserId[] =
  23. "arc.active_directory_play_user_id";
  24. // A preference to keep list of Android apps and their state.
  25. const char kArcApps[] = "arc.apps";
  26. // A preference to store backup and restore state for Android apps.
  27. const char kArcBackupRestoreEnabled[] = "arc.backup_restore.enabled";
  28. // A preference to indicate that Android's data directory should be removed.
  29. const char kArcDataRemoveRequested[] = "arc.data.remove_requested";
  30. // A preference representing whether a user has opted in to use Google Play
  31. // Store on ARC.
  32. // TODO(hidehiko): For historical reason, now the preference name does not
  33. // directly reflect "Google Play Store". We should get and set the values via
  34. // utility methods (IsArcPlayStoreEnabledForProfile() and
  35. // SetArcPlayStoreEnabledForProfile()) in chrome/browser/ash/arc/arc_util.h.
  36. const char kArcEnabled[] = "arc.enabled";
  37. // A preference to control if ARC can access removable media on the host side.
  38. // TODO(fukino): Remove this pref once "Play Store applications can't access
  39. // this device" toast in Files app becomes aware of kArcVisibleExternalStorages.
  40. // crbug.com/998512.
  41. const char kArcHasAccessToRemovableMedia[] =
  42. "arc.has_access_to_removable_media";
  43. // A preference to keep list of external storages which are visible to Android
  44. // apps. (i.e. can be read/written by Android apps.)
  45. const char kArcVisibleExternalStorages[] = "arc.visible_external_storages";
  46. // A preference that indicates that initial settings need to be applied. Initial
  47. // settings are applied only once per new OptIn once mojo settings instance is
  48. // ready. Each OptOut resets this preference. Note, its sense is close to
  49. // |kArcSignedIn|, however due the asynchronous nature of initializing mojo
  50. // components, timing of triggering |kArcSignedIn| and
  51. // |kArcInitialSettingsPending| can be different and
  52. // |kArcInitialSettingsPending| may even be handled in the next user session.
  53. const char kArcInitialSettingsPending[] = "arc.initial.settings.pending";
  54. // A preference that indicates that a management transition is necessary, in
  55. // response to account management state change.
  56. const char kArcManagementTransition[] = "arc.management_transition";
  57. // A preference that indicated whether Android reported it's compliance status
  58. // with provided policies. This is used only as a signal to start Android kiosk.
  59. const char kArcPolicyComplianceReported[] = "arc.policy_compliance_reported";
  60. // A preference that indicates that user accepted PlayStore terms.
  61. const char kArcTermsAccepted[] = "arc.terms.accepted";
  62. // A preference that indicates that ToS was shown in OOBE flow.
  63. const char kArcTermsShownInOobe[] = "arc.terms.shown_in_oobe";
  64. // A preference to keep user's consent to use location service.
  65. const char kArcLocationServiceEnabled[] = "arc.location_service.enabled";
  66. // A preference to keep list of Android packages and their infomation.
  67. const char kArcPackages[] = "arc.packages";
  68. // A preference that indicates that Play Auto Install flow was already started.
  69. const char kArcPaiStarted[] = "arc.pai.started";
  70. // A preference that indicates that provisioning was initiated from OOBE. This
  71. // is preserved across Chrome restart.
  72. const char kArcProvisioningInitiatedFromOobe[] =
  73. "arc.provisioning.initiated.from.oobe";
  74. // A preference that indicates that Play Fast App Reinstall flow was already
  75. // started.
  76. const char kArcFastAppReinstallStarted[] = "arc.fast.app.reinstall.started";
  77. // A preference to keep list of Play Fast App Reinstall packages.
  78. const char kArcFastAppReinstallPackages[] = "arc.fast.app.reinstall.packages";
  79. // A preference to keep the current Android framework version. Note, that value
  80. // is only available after first packages update.
  81. const char kArcFrameworkVersion[] = "arc.framework.version";
  82. // A preference that holds the list of apps that the admin requested to be
  83. // push-installed.
  84. const char kArcPushInstallAppsRequested[] = "arc.push_install.requested";
  85. // A preference that holds the list of apps that the admin requested to be
  86. // push-installed, but which have not been successfully installed yet.
  87. const char kArcPushInstallAppsPending[] = "arc.push_install.pending";
  88. // A preference to keep deferred requests of setting notifications enabled flag.
  89. const char kArcSetNotificationsEnabledDeferred[] =
  90. "arc.set_notifications_enabled_deferred";
  91. // A preference that indicates status of Android sign-in.
  92. const char kArcSignedIn[] = "arc.signedin";
  93. // A preference that indicates that ARC skipped the setup UI flows that
  94. // contain a notice related to reporting of diagnostic information.
  95. const char kArcSkippedReportingNotice[] = "arc.skipped.reporting.notice";
  96. // A preference that indicates an ARC comaptible filesystem was chosen for
  97. // the user directory (i.e., the user finished required migration.)
  98. const char kArcCompatibleFilesystemChosen[] =
  99. "arc.compatible_filesystem.chosen";
  100. // Preferences for storing engagement time data, as per
  101. // GuestOsEngagementMetrics.
  102. const char kEngagementPrefsPrefix[] = "arc.metrics";
  103. // A boolean preference that indicates ARC management state.
  104. const char kArcIsManaged[] = "arc.is_managed";
  105. // A counter preference that indicates number of ARC resize-lock splash screen.
  106. const char kArcShowResizeLockSplashScreenLimits[] =
  107. "arc.show_resize_lock_splash_screen_limits";
  108. // A preference to know whether or not the Arc.PlayStoreLaunchWithinAWeek
  109. // metric can been recorded.
  110. const char kArcPlayStoreLaunchMetricCanBeRecorded[] =
  111. "arc.playstore_launched_by_user";
  112. // ======== LOCAL STATE PREFS ========
  113. // ANR count which is currently pending, not flashed to UMA.
  114. const char kAnrPendingCount[] = "arc.anr_pending_count";
  115. // Keeps the duration of the current ANR rate period.
  116. const char kAnrPendingDuration[] = "arc.anr_pending_duration";
  117. // A dictionary preference that keeps track of stability metric values, which is
  118. // maintained by StabilityMetricsManager. Persisting values in local state is
  119. // required to include these metrics in the initial stability log in case of a
  120. // crash.
  121. const char kStabilityMetrics[] = "arc.metrics.stability";
  122. // A preference to keep the salt for generating ro.serialno and ro.boot.serialno
  123. // Android properties. Used only in ARCVM.
  124. const char kArcSerialNumberSalt[] = "arc.serialno_salt";
  125. // A preference to keep time intervals when snapshotting is allowed.
  126. const char kArcSnapshotHours[] = "arc.snapshot_hours";
  127. // A preferece to keep ARC snapshot related info in dictionary.
  128. const char kArcSnapshotInfo[] = "arc.snapshot";
  129. void RegisterLocalStatePrefs(PrefRegistrySimple* registry) {
  130. // Sorted in lexicographical order.
  131. registry->RegisterStringPref(kArcSerialNumberSalt, std::string());
  132. registry->RegisterDictionaryPref(kArcSnapshotHours);
  133. registry->RegisterDictionaryPref(kArcSnapshotInfo);
  134. registry->RegisterDictionaryPref(kStabilityMetrics);
  135. registry->RegisterIntegerPref(kAnrPendingCount, 0);
  136. registry->RegisterTimeDeltaPref(kAnrPendingDuration, base::TimeDelta());
  137. }
  138. void RegisterProfilePrefs(PrefRegistrySimple* registry) {
  139. // TODO(dspaid): Implement a mechanism to allow this to sync on first boot
  140. // only.
  141. // This is used to delete the Play user ID if ARC is disabled for an
  142. // Active Directory managed device.
  143. registry->RegisterStringPref(kArcActiveDirectoryPlayUserId, std::string());
  144. // Note that ArcBackupRestoreEnabled and ArcLocationServiceEnabled prefs have
  145. // to be off by default, until an explicit gesture from the user to enable
  146. // them is received. This is crucial in the cases when these prefs transition
  147. // from a previous managed state to the unmanaged.
  148. registry->RegisterBooleanPref(kArcBackupRestoreEnabled, false);
  149. registry->RegisterBooleanPref(kArcLocationServiceEnabled, false);
  150. registry->RegisterIntegerPref(
  151. kArcManagementTransition,
  152. static_cast<int>(ArcManagementTransition::NO_TRANSITION));
  153. registry->RegisterBooleanPref(kArcIsManaged, false);
  154. guest_os::prefs::RegisterEngagementProfilePrefs(registry,
  155. kEngagementPrefsPrefix);
  156. // Sorted in lexicographical order.
  157. registry->RegisterBooleanPref(kAlwaysOnVpnLockdown, false);
  158. registry->RegisterStringPref(kAlwaysOnVpnPackage, std::string());
  159. registry->RegisterBooleanPref(kArcDataRemoveRequested, false);
  160. registry->RegisterBooleanPref(kArcEnabled, false);
  161. registry->RegisterBooleanPref(kArcHasAccessToRemovableMedia, false);
  162. registry->RegisterBooleanPref(kArcInitialSettingsPending, false);
  163. registry->RegisterBooleanPref(kArcPaiStarted, false);
  164. registry->RegisterBooleanPref(kArcFastAppReinstallStarted, false);
  165. registry->RegisterListPref(kArcFastAppReinstallPackages);
  166. registry->RegisterBooleanPref(kArcPolicyComplianceReported, false);
  167. registry->RegisterBooleanPref(kArcProvisioningInitiatedFromOobe, false);
  168. registry->RegisterBooleanPref(kArcSignedIn, false);
  169. registry->RegisterBooleanPref(kArcSkippedReportingNotice, false);
  170. registry->RegisterBooleanPref(kArcTermsAccepted, false);
  171. registry->RegisterBooleanPref(kArcTermsShownInOobe, false);
  172. registry->RegisterListPref(kArcVisibleExternalStorages);
  173. }
  174. } // namespace prefs
  175. } // namespace arc