• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 The Chromium OS 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.
4from autotest_lib.client.common_lib import error
5from autotest_lib.client.common_lib import utils
6
7from autotest_lib.client.common_lib.cros import arc
8from autotest_lib.client.cros.enterprise import enterprise_policy_base
9
10
11class policy_ArcBackupRestoreServiceEnabled(
12        enterprise_policy_base.EnterprisePolicyTest):
13    """
14    Test effect of policy_ArcBackupRestoreServiceEnabled policy on the
15    ARC++ container within ChromeOS.
16
17    """
18    version = 1
19
20    def verify_policy(self, case):
21        """
22        Verify the policy was properly set
23
24        @param case: integer, value of the policy setting
25
26        """
27        if case:
28            e_msg = 'Backup manager is disabled and should be enabled.'
29        else:
30            e_msg = 'Backup manager is enabled and should be disabled.'
31
32        # Give the ARC container time to setup and configure its policy.
33        utils.poll_for_condition(
34            lambda: self.check_bmgr(case),
35            exception=error.TestFail(e_msg),
36            timeout=45,
37            sleep_interval=5,
38            desc='Checking bmgr status')
39
40    def check_bmgr(self, case):
41        """
42        Check if Android backup and recovery is accessible.
43
44        @param case: integer, value of the policy setting
45
46        @Returns True if accessible and set correctly, False otherwise.
47
48        """
49        b_and_r_status = arc.adb_shell('bmgr enabled')
50
51        if case:
52            if "Backup Manager currently enabled" not in b_and_r_status:
53                return False
54
55        else:
56            if "Backup Manager currently disabled" not in b_and_r_status:
57                return False
58
59        return True
60
61    def run_once(self, case):
62        """
63        @param case: integer, value of the policy setting
64
65        """
66        pol = {'ArcEnabled': True,
67               'ArcBackupRestoreServiceEnabled': case}
68        self.setup_case(user_policies=pol,
69                        arc_mode='enabled',
70                        use_clouddpc_test=False)
71        self.verify_policy(case)
72