Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Side by Side Diff: chrome/browser/chromeos/arc/arc_util.cc

Issue 2788383003: ChromeOS: Disable ARC when incompatible filesystem is detected. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/arc/arc_util.h" 5 #include "chrome/browser/chromeos/arc/arc_util.h"
6 6
7 #include <linux/magic.h>
8 #include <sys/statfs.h>
9
10 #include "base/files/file_path.h"
11 #include "base/files/file_util.h"
7 #include "base/logging.h" 12 #include "base/logging.h"
13 #include "base/strings/string_split.h"
8 #include "chrome/browser/chromeos/arc/arc_session_manager.h" 14 #include "chrome/browser/chromeos/arc/arc_session_manager.h"
9 #include "chrome/browser/chromeos/login/user_flow.h" 15 #include "chrome/browser/chromeos/login/user_flow.h"
10 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h" 16 #include "chrome/browser/chromeos/login/users/chrome_user_manager.h"
11 #include "chrome/browser/chromeos/profiles/profile_helper.h" 17 #include "chrome/browser/chromeos/profiles/profile_helper.h"
12 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
13 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
14 #include "components/arc/arc_util.h" 20 #include "components/arc/arc_util.h"
15 #include "components/prefs/pref_service.h" 21 #include "components/prefs/pref_service.h"
16 #include "components/user_manager/user.h" 22 #include "components/user_manager/user.h"
17 #include "components/user_manager/user_manager.h" 23 #include "components/user_manager/user_manager.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 return false; 91 return false;
86 } 92 }
87 93
88 // Do not allow for Ephemeral data user. cf) b/26402681 94 // Do not allow for Ephemeral data user. cf) b/26402681
89 if (user_manager::UserManager::Get() 95 if (user_manager::UserManager::Get()
90 ->IsCurrentUserCryptohomeDataEphemeral()) { 96 ->IsCurrentUserCryptohomeDataEphemeral()) {
91 VLOG(1) << "Users with ephemeral data are not supported in ARC."; 97 VLOG(1) << "Users with ephemeral data are not supported in ARC.";
92 return false; 98 return false;
93 } 99 }
94 100
101 if (!profile->GetPrefs()->GetBoolean(
102 prefs::kArcCompatibleFilesystemChosen)) {
103 VLOG(1) << "Users who postponed to migrate to dircrypto are not supported.";
104 return false;
105 }
106
95 return true; 107 return true;
96 } 108 }
97 109
98 void DisallowArcForTesting() { 110 void DisallowArcForTesting() {
99 g_disallow_for_testing = true; 111 g_disallow_for_testing = true;
100 } 112 }
101 113
102 bool IsArcPlayStoreEnabledForProfile(const Profile* profile) { 114 bool IsArcPlayStoreEnabledForProfile(const Profile* profile) {
103 return IsArcAllowedForProfile(profile) && 115 return IsArcAllowedForProfile(profile) &&
104 profile->GetPrefs()->GetBoolean(prefs::kArcEnabled); 116 profile->GetPrefs()->GetBoolean(prefs::kArcEnabled);
(...skipping 29 matching lines...) Expand all
134 profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, enabled); 146 profile->GetPrefs()->SetBoolean(prefs::kArcEnabled, enabled);
135 } 147 }
136 148
137 bool AreArcAllOptInPreferencesManagedForProfile(const Profile* profile) { 149 bool AreArcAllOptInPreferencesManagedForProfile(const Profile* profile) {
138 return profile->GetPrefs()->IsManagedPreference( 150 return profile->GetPrefs()->IsManagedPreference(
139 prefs::kArcBackupRestoreEnabled) && 151 prefs::kArcBackupRestoreEnabled) &&
140 profile->GetPrefs()->IsManagedPreference( 152 profile->GetPrefs()->IsManagedPreference(
141 prefs::kArcLocationServiceEnabled); 153 prefs::kArcLocationServiceEnabled);
142 } 154 }
143 155
156 bool IsArcCompatibleFilesystem(const base::FilePath& path) {
157 // If it can be verified it is not on ecryptfs, then it is ok.
158 struct statfs statfs_buf;
159 if (statfs(path.value().c_str(), &statfs_buf) < 0)
160 return false;
161 if (statfs_buf.f_type != ECRYPTFS_SUPER_MAGIC)
162 return true;
163
164 // Otherwise, it is ok if and only if we are running Android M.
165 std::string lsb_release;
166 if (!base::ReadFileToString(
xiyuan 2017/04/03 16:20:49 Think lsb release info is loaded and parsed early
kinaba 2017/04/04 04:13:56 Thanks! That's very nice to know. Replaced the who
167 base::FilePath(FILE_PATH_LITERAL("/etc/lsb-release")),
168 &lsb_release)) {
169 return false;
170 }
171 base::StringPairs pairs;
172 base::SplitStringIntoKeyValuePairs(lsb_release, '=', '\n', &pairs);
173 for (const auto& pair : pairs) {
174 if (pair.first == "CHROMEOS_ARC_ANDROID_SDK_VERSION")
175 return pair.second == "23";
176 }
177 return false;
178 }
179
144 } // namespace arc 180 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698