// Path: src/com/eldorado/remoteresources/android/common/Keys.java
// public enum Keys {
// 	/** */
// 	HOME,
// 	/** */
// 	BACK,
// 	/** */
// 	VOLUME_UP,
// 	/** */
// 	VOLUME_DOWN,
// 	/** */
// 	POWER,
// 	/** */
// 	CAMERA,
// 	/** */
// 	CLEAR,
// 	/** */
// 	DEL,
// 	/** */
// 	FOCUS,
// 	/** */
// 	MENU,
// 	/** */
// 	SEARCH;
// 
// 	@Override
// 	public String toString() {
// 		return "KEYCODE_" + super.toString();
// 	}
// }
// 
// Path: src/com/eldorado/remoteresources/utils/StringUtils.java
// public class StringUtils {
// 	/**
// 	 * 
// 	 * @param str
// 	 * @return
// 	 */
// 	public static boolean isEmpty(String str) {
// 		if (str == null) {
// 			return true;
// 		}
// 
// 		return str.isEmpty();
// 	}
// 
// 	public static byte[] compress(String log) throws IOException {
// 		ByteArrayOutputStream xzOutput = new ByteArrayOutputStream();
// 		XZOutputStream xzStream = new XZOutputStream(xzOutput,
// 				new LZMA2Options(LZMA2Options.PRESET_MAX));
// 		xzStream.write(log.getBytes());
// 		xzStream.close();
// 		return xzOutput.toByteArray();
// 	}
// 
// 	public static String decompress(byte[] log) throws IOException {
// 		XZInputStream xzInputStream = new XZInputStream(
// 				new ByteArrayInputStream(log));
// 		byte firstByte = (byte) xzInputStream.read();
// 		byte[] buffer = new byte[xzInputStream.available()];
// 		buffer[0] = firstByte;
// 		xzInputStream.read(buffer, 1, buffer.length - 2);
// 		xzInputStream.close();
// 		return new String(buffer);
// 	}
// 
// }


import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.android.chimpchat.adb.AdbChimpDevice;
import com.android.chimpchat.core.TouchPressType;
import com.android.ddmlib.IDevice;
import com.eldorado.remoteresources.android.common.Keys;
import com.eldorado.remoteresources.utils.StringUtils;
/*
 * (C) Copyright 2014 Instituto de Pesquisas Eldorado (http://www.eldorado.org.br/).
 *
 * This file is part of the software Remote Resources
 *
 * All rights reserved. This file and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 3.0 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl.html
 *
 * This file is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 */

package com.eldorado.remoteresources.android.server;



/**
 * 
 * 
 *
 */
public class AndroidDevice {
	/**
	 * 
	 */
	private IDevice device;

	/**
	 * 
	 */
	private AdbChimpDevice chimpDevice;

	/**
	 * 
	 */
	private final String serialNumber;

	/**
	 * 
	 */
	private String deviceModel;

	/**
	 * 
	 */
	private Dimension screenSize;

	/**
	 * 
	 */
	private static final String KEYCODE_SPACE = String.valueOf(62);

	/**
	 * 
	 */
	private static final Pattern[] DISPLAY_SIZE_PATTERNS = {
			Pattern.compile("\\scur=(?<width>\\d+)x(?<height>\\d+)\\s",
					Pattern.CASE_INSENSITIVE),
			Pattern.compile(
					"displaywidth\\s*\\=\\s*(?<width>\\d+).*displayheight\\s*\\=\\s*(?<height>\\d+)",
					Pattern.CASE_INSENSITIVE) };

	/**
	 * 
	 * @param device
	 */
	public AndroidDevice(IDevice device) {
		this.device = device;
		serialNumber = device.getSerialNumber();
		chimpDevice = new AdbChimpDevice(device);
		getScreenSize();
	}

	public IDevice getDevice() {
		return device;
	}

	public void setDevice(IDevice device) {
		this.device = device;
	}

	/**
	 * 
	 * @return
	 */
	public String getDeviceModel() {
// Path: src/com/eldorado/remoteresources/android/common/Keys.java
// public enum Keys {
// 	/** */
// 	HOME,
// 	/** */
// 	BACK,
// 	/** */
// 	VOLUME_UP,
// 	/** */
// 	VOLUME_DOWN,
// 	/** */
// 	POWER,
// 	/** */
// 	CAMERA,
// 	/** */
// 	CLEAR,
// 	/** */
// 	DEL,
// 	/** */
// 	FOCUS,
// 	/** */
// 	MENU,
// 	/** */
// 	SEARCH;
// 
// 	@Override
// 	public String toString() {
// 		return "KEYCODE_" + super.toString();
// 	}
// }
// 
// Path: src/com/eldorado/remoteresources/utils/StringUtils.java
// public class StringUtils {
// 	/**
// 	 * 
// 	 * @param str
// 	 * @return
// 	 */
// 	public static boolean isEmpty(String str) {
// 		if (str == null) {
// 			return true;
// 		}
// 
// 		return str.isEmpty();
// 	}
// 
// 	public static byte[] compress(String log) throws IOException {
// 		ByteArrayOutputStream xzOutput = new ByteArrayOutputStream();
// 		XZOutputStream xzStream = new XZOutputStream(xzOutput,
// 				new LZMA2Options(LZMA2Options.PRESET_MAX));
// 		xzStream.write(log.getBytes());
// 		xzStream.close();
// 		return xzOutput.toByteArray();
// 	}
// 
// 	public static String decompress(byte[] log) throws IOException {
// 		XZInputStream xzInputStream = new XZInputStream(
// 				new ByteArrayInputStream(log));
// 		byte firstByte = (byte) xzInputStream.read();
// 		byte[] buffer = new byte[xzInputStream.available()];
// 		buffer[0] = firstByte;
// 		xzInputStream.read(buffer, 1, buffer.length - 2);
// 		xzInputStream.close();
// 		return new String(buffer);
// 	}
// 
// }


// Path: src/com/eldorado/remoteresources/android/server/AndroidDevice.java
import java.awt.Dimension;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.android.chimpchat.adb.AdbChimpDevice;
import com.android.chimpchat.core.TouchPressType;
import com.android.ddmlib.IDevice;
import com.eldorado.remoteresources.android.common.Keys;
import com.eldorado.remoteresources.utils.StringUtils;

/*
 * (C) Copyright 2014 Instituto de Pesquisas Eldorado (http://www.eldorado.org.br/).
 *
 * This file is part of the software Remote Resources
 *
 * All rights reserved. This file and the accompanying materials
 * are made available under the terms of the GNU Lesser General Public License
 * (LGPL) version 3.0 which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/lgpl.html
 *
 * This file is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 */

package com.eldorado.remoteresources.android.server;



/**
 * 
 * 
 *
 */
public class AndroidDevice {
	/**
	 * 
	 */
	private IDevice device;

	/**
	 * 
	 */
	private AdbChimpDevice chimpDevice;

	/**
	 * 
	 */
	private final String serialNumber;

	/**
	 * 
	 */
	private String deviceModel;

	/**
	 * 
	 */
	private Dimension screenSize;

	/**
	 * 
	 */
	private static final String KEYCODE_SPACE = String.valueOf(62);

	/**
	 * 
	 */
	private static final Pattern[] DISPLAY_SIZE_PATTERNS = {
			Pattern.compile("\\scur=(?<width>\\d+)x(?<height>\\d+)\\s",
					Pattern.CASE_INSENSITIVE),
			Pattern.compile(
					"displaywidth\\s*\\=\\s*(?<width>\\d+).*displayheight\\s*\\=\\s*(?<height>\\d+)",
					Pattern.CASE_INSENSITIVE) };

	/**
	 * 
	 * @param device
	 */
	public AndroidDevice(IDevice device) {
		this.device = device;
		serialNumber = device.getSerialNumber();
		chimpDevice = new AdbChimpDevice(device);
		getScreenSize();
	}

	public IDevice getDevice() {
		return device;
	}

	public void setDevice(IDevice device) {
		this.device = device;
	}

	/**
	 * 
	 * @return
	 */
	public String getDeviceModel() {
		if (StringUtils.isEmpty(deviceModel)) {