blob: d2e9c8d4e2208f50f25c96c70ce0a29b3682fb01 [file] [log] [blame]
Keun Soo Yimb293fdb2016-09-21 16:03:44 -07001#!/usr/bin/env python
2#
3# Copyright 2016 - The Android Open Source Project
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17"""This module defines an AVD instance.
18
19TODO(fdeng):
20 The current implementation only initialize an object
21 with IP and instance name. A complete implementation
22 will include the following features.
23 - Connect
24 - Disconnect
25 - HasApp
26 - InstallApp
27 - UninstallApp
28 - GrantAppPermission
29 Merge cloud/android/platform/devinfra/caci/framework/app_manager.py
30 with this module and updated any callers.
31"""
32
33import logging
34
35logger = logging.getLogger(__name__)
36
37
38class AndroidVirtualDevice(object):
39 """Represent an Android device."""
40
41 def __init__(self, instance_name, ip=None):
42 """Initialize.
43
44 Args:
45 instance_name: Name of the gce instance, e.g. "instance-1"
46 ip: Ip address of the gce instance, e.g. "140.110.20.1"
47 """
48 self._ip = ip
49 self._instance_name = instance_name
50
51 @property
52 def ip(self):
53 if not self._ip:
54 raise ValueError("IP of instance %s is unknown yet." %
55 self._instance_name)
56 return self._ip
57
58 @ip.setter
59 def ip(self, value):
60 self._ip = value
61
62 @property
63 def instance_name(self):
64 return self._instance_name
65
66 def __str__(self):
67 """Return a string representation."""
68 return "<ip: %s, instance_name: %s >" % (self._ip, self._instance_name)