├── binocle
├── .gitignore
├── src
│ ├── main
│ │ ├── res
│ │ │ ├── values
│ │ │ │ ├── colors.xml
│ │ │ │ ├── styles.xml
│ │ │ │ └── strings.xml
│ │ │ ├── drawable-hdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_action_refresh.png
│ │ │ ├── drawable-mdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_action_refresh.png
│ │ │ ├── drawable-xhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── ic_action_refresh.png
│ │ │ ├── drawable-xxhdpi
│ │ │ │ └── ic_launcher.png
│ │ │ ├── drawable-xxxhdpi
│ │ │ │ ├── ic_launcher.png
│ │ │ │ └── phone_activated.png
│ │ │ ├── layout
│ │ │ │ ├── activity_apicall_detail.xml
│ │ │ │ ├── activity_apicall_list.xml
│ │ │ │ ├── fragment_diskio_sample.xml
│ │ │ │ ├── fragment_battery_sample.xml
│ │ │ │ ├── fragment_radio_sample.xml
│ │ │ │ ├── fragment_phone_sample.xml
│ │ │ │ ├── fragment_id_sample.xml
│ │ │ │ ├── activity_apicall_twopane.xml
│ │ │ │ └── fragment_gps_sample.xml
│ │ │ ├── menu
│ │ │ │ └── binocle.xml
│ │ │ ├── values-large
│ │ │ │ └── refs.xml
│ │ │ └── values-sw600dp
│ │ │ │ └── refs.xml
│ │ ├── AndroidManifest.xml
│ │ └── java
│ │ │ └── com
│ │ │ └── genymotion
│ │ │ └── binocle
│ │ │ ├── apicalls
│ │ │ └── ApiCallSamples.java
│ │ │ ├── RadioSampleFragment.java
│ │ │ ├── PhoneSampleFragment.java
│ │ │ ├── BatterySampleFragment.java
│ │ │ ├── ApiCallListActivity.java
│ │ │ ├── DiskIOSampleFragment.java
│ │ │ ├── SampleActivity.java
│ │ │ ├── ApiCallListFragment.java
│ │ │ ├── IdSampleFragment.java
│ │ │ └── GpsSampleFragment.java
│ └── androidTest
│ │ └── java
│ │ └── com
│ │ └── genymotion
│ │ └── binocle
│ │ └── test
│ │ ├── TestRadio.java
│ │ ├── TestPhone.java
│ │ ├── TestBattery.java
│ │ ├── TestGps.java
│ │ ├── TestDiskIO.java
│ │ └── TestId.java
├── proguard-rules.txt
└── build.gradle
├── settings.gradle
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── .gitignore
├── ci
├── create_diskio_test_file
└── run_tests
├── gradle.properties
├── gradlew.bat
├── README.md
├── gradlew
└── LICENSE
/binocle/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':binocle'
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Genymobile/genymotion-binocle/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/binocle/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #E6195E
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # OS
2 | .DS_Store
3 | *~
4 |
5 | # IDE
6 | .gradle
7 | local.properties
8 | .idea
9 | *.iml
10 |
11 | # Build
12 | tmp
13 | out
14 | build
15 |
--------------------------------------------------------------------------------
/binocle/src/main/res/drawable-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Genymobile/genymotion-binocle/HEAD/binocle/src/main/res/drawable-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/binocle/src/main/res/drawable-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Genymobile/genymotion-binocle/HEAD/binocle/src/main/res/drawable-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/binocle/src/main/res/drawable-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Genymobile/genymotion-binocle/HEAD/binocle/src/main/res/drawable-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/binocle/src/main/res/drawable-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Genymobile/genymotion-binocle/HEAD/binocle/src/main/res/drawable-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/binocle/src/main/res/drawable-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Genymobile/genymotion-binocle/HEAD/binocle/src/main/res/drawable-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/binocle/src/main/res/drawable-hdpi/ic_action_refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Genymobile/genymotion-binocle/HEAD/binocle/src/main/res/drawable-hdpi/ic_action_refresh.png
--------------------------------------------------------------------------------
/binocle/src/main/res/drawable-mdpi/ic_action_refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Genymobile/genymotion-binocle/HEAD/binocle/src/main/res/drawable-mdpi/ic_action_refresh.png
--------------------------------------------------------------------------------
/binocle/src/main/res/drawable-xhdpi/ic_action_refresh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Genymobile/genymotion-binocle/HEAD/binocle/src/main/res/drawable-xhdpi/ic_action_refresh.png
--------------------------------------------------------------------------------
/binocle/src/main/res/drawable-xxxhdpi/phone_activated.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Genymobile/genymotion-binocle/HEAD/binocle/src/main/res/drawable-xxxhdpi/phone_activated.png
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Apr 12 10:47:45 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
7 |
--------------------------------------------------------------------------------
/binocle/src/main/res/layout/activity_apicall_detail.xml:
--------------------------------------------------------------------------------
1 |
8 |
--------------------------------------------------------------------------------
/binocle/src/main/res/menu/binocle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/binocle/src/main/res/values-large/refs.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 | - @layout/activity_apicall_twopane
10 |
11 |
--------------------------------------------------------------------------------
/binocle/src/main/res/values-sw600dp/refs.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 | - @layout/activity_apicall_twopane
10 |
11 |
--------------------------------------------------------------------------------
/binocle/src/main/res/layout/activity_apicall_list.xml:
--------------------------------------------------------------------------------
1 |
11 |
--------------------------------------------------------------------------------
/binocle/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
7 |
8 |
11 |
12 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/ci/create_diskio_test_file:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 | # This script creates the test file required by the DiskIOSampleFragment.
4 | # The file has to be created from the outside for the DiskIO test to pass: if
5 | # we let the fragment create it manually, then the file content remains cached
6 | # by the OS and we don't hit the DiskIO limitation.
7 |
8 | # Must be kept in sync with DiskIOSampleFragment
9 | TEST_FILE=diskio_test
10 | TEST_FILE_SIZE_MB=200
11 | ONE_MB=1048576
12 |
13 | echo "Creating DiskIO test file"
14 |
15 | # Escape the $ in front of EXTERNAL_STORAGE because this environment variable
16 | # is defined *inside* the device
17 | adb shell "dd if=/dev/zero of=\$EXTERNAL_STORAGE/Download/$TEST_FILE bs=$ONE_MB count=$TEST_FILE_SIZE_MB"
18 |
--------------------------------------------------------------------------------
/binocle/proguard-rules.txt:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in /home/pascal/bin/android-studio/sdk/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the ProGuard
5 | # include property in project.properties.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
--------------------------------------------------------------------------------
/binocle/src/main/res/layout/fragment_diskio_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
15 |
20 |
21 |
--------------------------------------------------------------------------------
/binocle/src/main/res/layout/fragment_battery_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
16 |
17 |
18 |
22 |
23 |
24 |
--------------------------------------------------------------------------------
/binocle/src/main/res/layout/fragment_radio_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
16 |
17 |
22 |
23 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Settings specified in this file will override any Gradle settings
5 | # configured through the IDE.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m
13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14 |
15 | # When configured, Gradle will run in incubating parallel mode.
16 | # This option should only be used with decoupled projects. More details, visit
17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18 | # org.gradle.parallel=true
--------------------------------------------------------------------------------
/binocle/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories {
3 | jcenter()
4 | mavenCentral()
5 | }
6 | dependencies {
7 | classpath 'com.android.tools.build:gradle:2.2.3'
8 | }
9 | }
10 | apply plugin: 'com.android.application'
11 | repositories {
12 | mavenLocal()
13 | maven{
14 | url "http://api.genymotion.com/repositories/releases/"
15 | }
16 | mavenCentral()
17 | }
18 |
19 | android {
20 | compileSdkVersion 22
21 | buildToolsVersion "24.0.3"
22 |
23 | defaultConfig {
24 | minSdkVersion 9
25 | targetSdkVersion 22
26 | versionCode 1
27 | versionName "1.0"
28 | }
29 |
30 | buildTypes {
31 | release {
32 | minifyEnabled false
33 | zipAlignEnabled false
34 | }
35 | }
36 | compileOptions {
37 | sourceCompatibility JavaVersion.VERSION_1_7
38 | targetCompatibility JavaVersion.VERSION_1_7
39 | }
40 | }
41 |
42 | dependencies {
43 | compile 'com.android.support:appcompat-v7:22.2.0'
44 | compile 'com.android.support:support-v4:22.2.0'
45 | androidTestCompile 'com.genymotion.api:genymotion-api:1.1.0'
46 | }
47 |
--------------------------------------------------------------------------------
/binocle/src/main/res/layout/fragment_phone_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
14 |
15 |
22 |
23 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/binocle/src/main/res/layout/fragment_id_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
19 |
20 |
28 |
29 |
37 |
38 |
--------------------------------------------------------------------------------
/binocle/src/main/res/layout/activity_apicall_twopane.xml:
--------------------------------------------------------------------------------
1 |
13 |
14 |
24 |
25 |
32 |
33 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/binocle/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
18 |
19 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
33 |
36 |
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/binocle/src/main/java/com/genymotion/binocle/apicalls/ApiCallSamples.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle.apicalls;
2 |
3 | import com.genymotion.binocle.BatterySampleFragment;
4 | import com.genymotion.binocle.DiskIOSampleFragment;
5 | import com.genymotion.binocle.GpsSampleFragment;
6 | import com.genymotion.binocle.IdSampleFragment;
7 | import com.genymotion.binocle.PhoneSampleFragment;
8 | import com.genymotion.binocle.RadioSampleFragment;
9 |
10 | import java.util.ArrayList;
11 | import java.util.List;
12 |
13 | /**
14 | * Helper class for providing api calls sample title
15 | */
16 | public class ApiCallSamples {
17 |
18 | /**
19 | * An array of sample (apiCalls) items.
20 | */
21 | public static final List ITEMS = new ArrayList<>(5);
22 |
23 | static {
24 | // Add all api calls sample items.
25 | addItem(new ApiCallSamplesItem(BatterySampleFragment.TAG, "Battery"));
26 | addItem(new ApiCallSamplesItem(GpsSampleFragment.TAG, "Gps"));
27 | addItem(new ApiCallSamplesItem(RadioSampleFragment.TAG, "Radio"));
28 | addItem(new ApiCallSamplesItem(IdSampleFragment.TAG, "Id"));
29 | addItem(new ApiCallSamplesItem(PhoneSampleFragment.TAG, "Phone"));
30 | addItem(new ApiCallSamplesItem(DiskIOSampleFragment.TAG, "DiskIO"));
31 | }
32 |
33 | private static void addItem(ApiCallSamplesItem item) {
34 | ITEMS.add(item);
35 | }
36 |
37 | /**
38 | * A apiCallsSample item representing a piece of title.
39 | */
40 | public static class ApiCallSamplesItem {
41 | public final String id;
42 | public final String title;
43 |
44 | public ApiCallSamplesItem(String id, String title) {
45 | this.id = id;
46 | this.title = title;
47 | }
48 |
49 | @Override
50 | public String toString() {
51 | return title;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/binocle/src/main/java/com/genymotion/binocle/RadioSampleFragment.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle;
2 |
3 | import android.content.Context;
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.telephony.TelephonyManager;
7 | import android.view.LayoutInflater;
8 | import android.view.View;
9 | import android.view.ViewGroup;
10 | import android.widget.TextView;
11 |
12 |
13 | public class RadioSampleFragment extends Fragment {
14 |
15 | public static final String TAG = "Radio";
16 |
17 | private static final String NEXUS_4_TAC = "35391805";
18 | private static final String NEXUS_5_TAC = "35824005";
19 |
20 | private TextView tvRadioDeviceType = null;
21 | private TextView tvRadioDeviceImei = null;
22 |
23 | @Override
24 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
25 | View rootView = inflater.inflate(R.layout.fragment_radio_sample, container, false);
26 |
27 | //retrieve widgets
28 | tvRadioDeviceType = (TextView) rootView.findViewById(R.id.tv_radioDeviceType);
29 | tvRadioDeviceImei = (TextView) rootView.findViewById(R.id.tv_radioDeviceImei);
30 |
31 | return rootView;
32 | }
33 |
34 | @Override
35 | public void onStart() {
36 | super.onStart();
37 |
38 | TelephonyManager tm = (TelephonyManager) getActivity().getSystemService(Context.TELEPHONY_SERVICE);
39 | String imei = tm.getDeviceId();
40 | String deviceType = getDeviceType(imei);
41 |
42 | tvRadioDeviceType.setText(getResources().getString(R.string.radio_device_type, deviceType));
43 | tvRadioDeviceImei.setText(getResources().getString(R.string.radio_device_imei, imei));
44 | }
45 |
46 | private String getDeviceType(String imei) {
47 | if (imei.startsWith(NEXUS_4_TAC)) {
48 | return "Nexus 4";
49 | } else if (imei.startsWith(NEXUS_5_TAC)) {
50 | return "Nexus 5";
51 | } else {
52 | return "Unknown";
53 | }
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/binocle/src/main/res/layout/fragment_gps_sample.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
10 |
11 |
17 |
18 |
22 |
23 |
28 |
29 |
34 |
35 |
40 |
41 |
46 |
47 |
52 |
53 |
58 |
59 |
60 |
--------------------------------------------------------------------------------
/binocle/src/androidTest/java/com/genymotion/binocle/test/TestRadio.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle.test;
2 |
3 | import android.content.Intent;
4 | import android.support.v4.app.FragmentManager;
5 | import android.test.ActivityInstrumentationTestCase2;
6 | import android.widget.TextView;
7 |
8 | import com.genymotion.api.GenymotionManager;
9 | import com.genymotion.binocle.R;
10 | import com.genymotion.binocle.RadioSampleFragment;
11 | import com.genymotion.binocle.SampleActivity;
12 |
13 | import junit.framework.Assert;
14 |
15 |
16 | public class TestRadio extends ActivityInstrumentationTestCase2 {
17 |
18 | private RadioSampleFragment fragmentRadio;
19 |
20 | public TestRadio() {
21 | super(SampleActivity.class);
22 | }
23 |
24 | @Override
25 | protected void setUp() throws Exception {
26 | super.setUp();
27 |
28 | if (!GenymotionManager.isGenymotionDevice()) {
29 | // Avoid test on non Genymotion devices.
30 | return;
31 | }
32 |
33 | // Change IMEI before creating activity as the imei is read inside onStart()
34 | GenymotionManager genymotion;
35 | genymotion = GenymotionManager.getGenymotionManager(getInstrumentation().getTargetContext());
36 | // Faking a Google Nexus 4
37 | genymotion.getRadio().setDeviceId("353918050000000");
38 |
39 | // Add parameter to allow activity to start and create fragment RadioSampleFragment.
40 | Intent radioIntent;
41 | radioIntent = new Intent(getInstrumentation().getTargetContext(), SampleActivity.class);
42 | radioIntent.putExtra(SampleActivity.ARG_ITEM_ID, RadioSampleFragment.TAG);
43 | setActivityIntent(radioIntent);
44 |
45 | // Create activity and get fragment back
46 | FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
47 | fragmentRadio = (RadioSampleFragment) fragmentManager.findFragmentByTag(RadioSampleFragment.TAG);
48 | }
49 |
50 | public void testDeviceId() {
51 |
52 | if (!GenymotionManager.isGenymotionDevice()) {
53 | // Avoid test on non Genymotion devices.
54 | return;
55 | }
56 |
57 | TextView tvDeviceType = (TextView) fragmentRadio.getView().findViewById(R.id.tv_radioDeviceType);
58 | String text = tvDeviceType.getText().toString();
59 | Assert.assertTrue(text.endsWith("Nexus 4"));
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/binocle/src/androidTest/java/com/genymotion/binocle/test/TestPhone.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle.test;
2 |
3 | import android.content.Intent;
4 | import android.support.v4.app.FragmentManager;
5 | import android.test.ActivityInstrumentationTestCase2;
6 | import android.view.View;
7 | import android.widget.ImageView;
8 |
9 | import com.genymotion.api.GenymotionManager;
10 | import com.genymotion.binocle.PhoneSampleFragment;
11 | import com.genymotion.binocle.R;
12 | import com.genymotion.binocle.SampleActivity;
13 |
14 | import junit.framework.Assert;
15 |
16 |
17 | public class TestPhone extends ActivityInstrumentationTestCase2 {
18 |
19 | private PhoneSampleFragment fragmentPhone;
20 |
21 | public TestPhone() {
22 | super(SampleActivity.class);
23 | }
24 |
25 | @Override
26 | protected void setUp() throws Exception {
27 | super.setUp();
28 |
29 | if (!GenymotionManager.isGenymotionDevice()) {
30 | // Avoid test on non Genymotion devices.
31 | return;
32 | }
33 |
34 | // Add parameter to allow activity to start and create fragment PhoneSampleFragment.
35 | Intent phoneIntent;
36 | phoneIntent = new Intent(getInstrumentation().getTargetContext(), SampleActivity.class);
37 | phoneIntent.putExtra(SampleActivity.ARG_ITEM_ID, PhoneSampleFragment.TAG);
38 | setActivityIntent(phoneIntent);
39 |
40 | // Create activity and get fragment back
41 | FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
42 | fragmentPhone = (PhoneSampleFragment) fragmentManager.findFragmentByTag(PhoneSampleFragment.TAG);
43 | }
44 |
45 | public void testSmsReception() {
46 |
47 | if (!GenymotionManager.isGenymotionDevice()) {
48 | // Avoid test on non Genymotion devices.
49 | return;
50 | }
51 |
52 | GenymotionManager genymotion;
53 | genymotion = GenymotionManager.getGenymotionManager(getInstrumentation().getTargetContext());
54 |
55 | // Send an SMS containing the 666 string
56 | genymotion.getRadio().sendSms("123456", "666");
57 | ImageView picto = (ImageView) fragmentPhone.getView().findViewById(R.id.phone_activation_picto);
58 |
59 | // Check that the image is now visible
60 | Assert.assertEquals(View.VISIBLE, picto.getVisibility());
61 |
62 | // Send an SMS that doesnot contain "666" string
63 | genymotion.getRadio().sendSms("123456", "123");
64 |
65 | // Check that the image is now gone
66 | Assert.assertEquals(View.GONE, picto.getVisibility());
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/binocle/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Binocle
5 | ApiCall Detail
6 | Refresh
7 |
8 |
9 | Warning! there is less than 10% power left!
10 | This activity will display a warning if the device is not plugged and if there is less than 10percent power left in battery.
11 |
12 |
13 | The force is strong here, as Dalvik is near.
14 | This activity will display a warning if the device is localised near (100 km) Dalvik.
15 | Current latitude is %f
16 | Current longitude is %f
17 | Current altitude is %f
18 | Current bearing is %f
19 | Current accuracy is %f
20 | Dalvik is %d km away
21 |
22 |
23 | Your device is recognized as a: %s
24 | Your device imei is: %s
25 |
26 |
27 | Secret file can only be decoded on the device it has been created on. Current ANDROID_ID is %s.
28 | Encrypt secret
29 | Decrypt secret
30 | Secret have been encrypted on disk using ANDROID_ID. Current ANDROID_ID is %s.
31 | An error occurred when encrypting secret!
32 | Secret have been correctly decrypted from disk! secret message was:\n %s
33 | An error occurred when decrypting secret!
34 |
35 |
36 | This activity is waiting for an activation code over SMS. To activate it, you need to send
37 | an SMS containing the string "666".
38 | Waiting for SMS with activation code…
39 | SMS received, activation code is valid!
40 | Validation SMS received
41 | Bench
42 |
43 |
44 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/binocle/src/main/java/com/genymotion/binocle/PhoneSampleFragment.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.IntentFilter;
7 | import android.os.Bundle;
8 | import android.support.v4.app.Fragment;
9 | import android.telephony.SmsMessage;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.ImageView;
14 | import android.widget.TextView;
15 |
16 | public class PhoneSampleFragment extends Fragment {
17 |
18 | public static final String TAG = "Phone";
19 |
20 | private final BroadcastReceiver smsReceivedReceiver = new BroadcastReceiver() {
21 | @Override
22 | public void onReceive(Context context, Intent intent) {
23 | Bundle extras = intent.getExtras();
24 |
25 | if (extras == null) {
26 | return;
27 | }
28 |
29 | Object[] rawMessages = (Object[])extras.get("pdus");
30 |
31 | for (Object rawMessage : rawMessages) {
32 | SmsMessage message = SmsMessage.createFromPdu((byte[])rawMessage);
33 |
34 | checkSMS(message.getMessageBody());
35 | }
36 | }
37 | };
38 |
39 | private TextView activation_label = null;
40 | private ImageView activation_picto = null;
41 |
42 | @Override
43 | public void onResume() {
44 | super.onResume();
45 |
46 | // Register sms listener
47 | IntentFilter filter = new IntentFilter();
48 | filter.addAction("android.provider.Telephony.SMS_RECEIVED");
49 | getActivity().registerReceiver(smsReceivedReceiver, filter);
50 | }
51 |
52 | @Override
53 | public void onPause() {
54 | getActivity().unregisterReceiver(smsReceivedReceiver);
55 |
56 | super.onPause();
57 | }
58 |
59 | @Override
60 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
61 | View rootView = inflater.inflate(R.layout.fragment_phone_sample, container, false);
62 |
63 | activation_label = (TextView)rootView.findViewById(R.id.phone_activation_label);
64 | activation_picto = (ImageView)rootView.findViewById(R.id.phone_activation_picto);
65 |
66 | return rootView;
67 | }
68 |
69 | private void checkSMS(String message) {
70 | if (message.contains("666")) {
71 | activation_label.setText(R.string.phone_received);
72 | activation_picto.setVisibility(View.VISIBLE);
73 | } else {
74 | activation_label.setText(R.string.phone_waiting);
75 | activation_picto.setVisibility(View.GONE);
76 | }
77 | }
78 |
79 | }
80 |
--------------------------------------------------------------------------------
/binocle/src/androidTest/java/com/genymotion/binocle/test/TestBattery.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle.test;
2 |
3 | import android.content.Intent;
4 | import android.support.v4.app.FragmentManager;
5 | import android.test.ActivityInstrumentationTestCase2;
6 | import android.util.Log;
7 | import android.view.View;
8 | import android.widget.TextView;
9 |
10 | import com.genymotion.api.Battery;
11 | import com.genymotion.api.GenymotionManager;
12 | import com.genymotion.binocle.BatterySampleFragment;
13 | import com.genymotion.binocle.R;
14 | import com.genymotion.binocle.SampleActivity;
15 |
16 | import junit.framework.Assert;
17 |
18 | public class TestBattery extends ActivityInstrumentationTestCase2 {
19 |
20 | private BatterySampleFragment fragmentBattery;
21 |
22 | public TestBattery() {
23 | super(SampleActivity.class);
24 | }
25 |
26 | @Override
27 | protected void setUp() throws Exception {
28 | super.setUp();
29 |
30 | // Add parameter to allow activity to start and create fragment BatterySampleFragment.
31 | Intent batteryIntent;
32 | batteryIntent = new Intent(getInstrumentation().getTargetContext(), SampleActivity.class);
33 | batteryIntent.putExtra(SampleActivity.ARG_ITEM_ID, BatterySampleFragment.TAG);
34 | setActivityIntent(batteryIntent);
35 |
36 | // Create activity and get fragment back
37 | FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
38 | fragmentBattery = (BatterySampleFragment) fragmentManager.findFragmentByTag(BatterySampleFragment.TAG);
39 | }
40 |
41 | public void testBatteryWarning() {
42 |
43 | if (!GenymotionManager.isGenymotionDevice()) {
44 | // Avoid test on non Genymotion devices.
45 | return;
46 | }
47 |
48 | TextView tvWarning = (TextView) fragmentBattery.getView().findViewById(R.id.tv_batteryWarning);
49 | GenymotionManager genymotion = GenymotionManager.getGenymotionManager(getActivity());
50 |
51 | // Change battery level and charging status
52 | Log.d(BatterySampleFragment.TAG, "Force full battery + charging");
53 | genymotion.getBattery()
54 | .setLevel(100)
55 | .setStatus(Battery.Status.CHARGING);
56 | // Then ensure warning is hidden
57 | Assert.assertEquals(View.GONE, tvWarning.getVisibility());
58 |
59 | // Change battery level and charging status
60 | Log.d(BatterySampleFragment.TAG, "Force low battery");
61 | genymotion.getBattery()
62 | .setLevel(3)
63 | .setStatus(Battery.Status.DISCHARGING);
64 | // Then ensure warning is visible
65 | Assert.assertEquals(View.VISIBLE, tvWarning.getVisibility());
66 |
67 | // set battery mode back to HOST
68 | genymotion.getBattery().setMode(Battery.Mode.HOST);
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/binocle/src/androidTest/java/com/genymotion/binocle/test/TestGps.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle.test;
2 |
3 | import android.content.Context;
4 | import android.content.Intent;
5 | import android.support.v4.app.FragmentManager;
6 | import android.test.ActivityInstrumentationTestCase2;
7 | import android.util.Log;
8 | import android.view.View;
9 | import android.widget.TextView;
10 |
11 | import com.genymotion.api.GenymotionManager;
12 | import com.genymotion.api.LocationParams;
13 | import com.genymotion.binocle.GpsSampleFragment;
14 | import com.genymotion.binocle.R;
15 | import com.genymotion.binocle.SampleActivity;
16 |
17 | import junit.framework.Assert;
18 |
19 | public class TestGps extends ActivityInstrumentationTestCase2 {
20 |
21 | private GpsSampleFragment fragmentGps;
22 |
23 | public TestGps() {
24 | super(SampleActivity.class);
25 | }
26 |
27 | @Override
28 | protected void setUp() throws Exception {
29 | super.setUp();
30 |
31 | // Add parameter to allow activity to start and create fragment GpsSampleFragment.
32 | Intent gpsIntent;
33 | gpsIntent = new Intent(getInstrumentation().getTargetContext(), SampleActivity.class);
34 | gpsIntent.putExtra(SampleActivity.ARG_ITEM_ID, GpsSampleFragment.TAG);
35 | setActivityIntent(gpsIntent);
36 |
37 | // Create activity and get fragment back
38 | FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
39 | fragmentGps = (GpsSampleFragment) fragmentManager.findFragmentByTag(GpsSampleFragment.TAG);
40 | }
41 |
42 | public void testGpsWarning() {
43 |
44 | if (!GenymotionManager.isGenymotionDevice()) {
45 | // Avoid test on non Genymotion devices.
46 | return;
47 | }
48 |
49 | TextView tvWarning = (TextView) fragmentGps.getView().findViewById(R.id.tv_gpsWarning);
50 | Context ctx = getActivity();
51 | GenymotionManager genymotion = GenymotionManager.getGenymotionManager(ctx);
52 |
53 | // Position to reykjavik (257km away))
54 | Log.d(GpsSampleFragment.TAG, "Force position to Reykjavik");
55 | LocationParams params = new LocationParams.Builder()
56 | .setLatitude(64.13367829)
57 | .setLongitude(-21.8964386)
58 | .build();
59 | genymotion.getGps().setLocation(params);
60 | // Then ensure warning is hidden
61 | Assert.assertEquals(View.GONE, tvWarning.getVisibility());
62 |
63 | // Position near Dalvik
64 | Log.d(GpsSampleFragment.TAG, "Force position near Dalvik");
65 | params = new LocationParams.Builder()
66 | .setLatitude(65.9446)
67 | .setLongitude(-18.35744619)
68 | .build();
69 | genymotion.getGps().setLocation(params);
70 |
71 | // Ensure warning is shown
72 | Assert.assertEquals(View.VISIBLE, tvWarning.getVisibility());
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/binocle/src/main/java/com/genymotion/binocle/BatterySampleFragment.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle;
2 |
3 | import android.content.BroadcastReceiver;
4 | import android.content.Context;
5 | import android.content.Intent;
6 | import android.content.IntentFilter;
7 | import android.os.BatteryManager;
8 | import android.os.Bundle;
9 | import android.support.v4.app.Fragment;
10 | import android.util.Log;
11 | import android.view.LayoutInflater;
12 | import android.view.View;
13 | import android.view.ViewGroup;
14 | import android.widget.TextView;
15 |
16 |
17 | public class BatterySampleFragment extends Fragment {
18 |
19 | public static final String TAG = "Battery";
20 | private final BroadcastReceiver batteryChangeReceiver = new BroadcastReceiver() {
21 | @Override
22 | public void onReceive(Context context, Intent intent) {
23 | Log.d(BatterySampleFragment.TAG, "Battery value changed");
24 | handleBatteryStatus(intent);
25 | }
26 | };
27 | private TextView tvBatteryWarning;
28 |
29 | @Override
30 | public void onResume() {
31 | super.onResume();
32 |
33 | //register battery listener
34 | IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
35 | getActivity().registerReceiver(batteryChangeReceiver, ifilter);
36 | }
37 |
38 | @Override
39 | public void onPause() {
40 | getActivity().unregisterReceiver(batteryChangeReceiver);
41 |
42 | super.onPause();
43 | }
44 |
45 | @Override
46 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
47 |
48 | View rootView = inflater.inflate(R.layout.fragment_battery_sample, container, false);
49 |
50 | //retrieve widgets
51 | tvBatteryWarning = (TextView) rootView.findViewById(R.id.tv_batteryWarning);
52 |
53 | //default values
54 | tvBatteryWarning.setVisibility(View.GONE);
55 |
56 | return rootView;
57 | }
58 |
59 | private void handleBatteryStatus(Intent batteryStatus) {
60 |
61 | // Are we charging / charged yet?
62 | int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1);
63 | boolean isCharging = ( (status == BatteryManager.BATTERY_STATUS_CHARGING)
64 | || (status == BatteryManager.BATTERY_STATUS_FULL) );
65 |
66 | // How much power?
67 | int level = batteryStatus.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
68 | int scale = batteryStatus.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
69 | float batteryPct = level / (float) scale;
70 |
71 | if (!isCharging && batteryPct < 0.10f) {
72 | Log.d(BatterySampleFragment.TAG, "Show battery warning");
73 | tvBatteryWarning.setVisibility(View.VISIBLE);
74 | } else {
75 | Log.d(BatterySampleFragment.TAG, "Hide battery warning");
76 | tvBatteryWarning.setVisibility(View.GONE);
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/binocle/src/androidTest/java/com/genymotion/binocle/test/TestDiskIO.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle.test;
2 |
3 |
4 | import android.content.Intent;
5 | import android.os.SystemClock;
6 | import android.support.v4.app.FragmentManager;
7 | import android.test.ActivityInstrumentationTestCase2;
8 | import android.widget.Button;
9 | import android.widget.TextView;
10 |
11 | import com.genymotion.api.GenymotionManager;
12 | import com.genymotion.binocle.DiskIOSampleFragment;
13 | import com.genymotion.binocle.R;
14 | import com.genymotion.binocle.SampleActivity;
15 |
16 | import junit.framework.Assert;
17 |
18 | public class TestDiskIO extends ActivityInstrumentationTestCase2 {
19 | private static final float TOLERANCE_PERCENT = 0.15f;
20 |
21 | private DiskIOSampleFragment fragmentDiskIO;
22 |
23 | public TestDiskIO() {
24 | super(SampleActivity.class);
25 | }
26 |
27 | @Override
28 | protected void setUp() throws Exception {
29 | super.setUp();
30 |
31 | Intent diskIOIntent;
32 | diskIOIntent = new Intent(getInstrumentation().getTargetContext(), SampleActivity.class);
33 | diskIOIntent.putExtra(SampleActivity.ARG_ITEM_ID, DiskIOSampleFragment.TAG);
34 | setActivityIntent(diskIOIntent);
35 |
36 | FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
37 | fragmentDiskIO = (DiskIOSampleFragment) fragmentManager.findFragmentByTag(DiskIOSampleFragment.TAG);
38 | }
39 |
40 | public void testDiskIOLowEnd() {
41 | diskIOTest(25 * 1024);
42 | }
43 |
44 | private void diskIOTest(int byteRateKB) {
45 | if (!GenymotionManager.isGenymotionDevice()) {
46 | // Avoid test on non Genymotion devices.
47 | return;
48 | }
49 |
50 | GenymotionManager genymotion = GenymotionManager.getGenymotionManager(getActivity());
51 | genymotion.getDiskIO().setReadRateLimit(byteRateKB);
52 | float activityByteRate = getActivityByteRateKBs();
53 |
54 | Assert.assertTrue((1 - TOLERANCE_PERCENT) * activityByteRate < byteRateKB);
55 | Assert.assertTrue(byteRateKB < (1 + TOLERANCE_PERCENT) * activityByteRate);
56 | Assert.assertEquals(byteRateKB, genymotion.getDiskIO().getReadRateLimit());
57 | }
58 |
59 | private float getActivityByteRateKBs() {
60 | final Button bench = (Button) fragmentDiskIO.getView().findViewById(R.id.bench);
61 |
62 | getActivity().runOnUiThread(new Runnable() {
63 | @Override
64 | public void run() {
65 | bench.performClick();
66 | }
67 | });
68 |
69 | return waitForSpeedKBs();
70 | }
71 |
72 | private float waitForSpeedKBs() {
73 | for (int attempt = 0; attempt < 30; ++attempt) {
74 | float speed = fragmentDiskIO.getSpeedKBs();
75 | if (speed > 0) {
76 | return speed;
77 | }
78 | SystemClock.sleep(1000);
79 | }
80 | Assert.fail("Could not read speed, waited 30s");
81 | return -1;
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/binocle/src/androidTest/java/com/genymotion/binocle/test/TestId.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle.test;
2 |
3 | import android.content.Intent;
4 | import android.support.v4.app.FragmentManager;
5 | import android.test.ActivityInstrumentationTestCase2;
6 | import android.test.UiThreadTest;
7 | import android.widget.Button;
8 | import android.widget.TextView;
9 |
10 | import com.genymotion.api.GenymotionManager;
11 | import com.genymotion.binocle.IdSampleFragment;
12 | import com.genymotion.binocle.R;
13 | import com.genymotion.binocle.SampleActivity;
14 |
15 | import junit.framework.Assert;
16 |
17 | public class TestId extends ActivityInstrumentationTestCase2 {
18 |
19 | private IdSampleFragment fragmentAndroidID;
20 |
21 | public TestId() {
22 | super(SampleActivity.class);
23 | }
24 |
25 | @Override
26 | protected void setUp() throws Exception {
27 | super.setUp();
28 |
29 | // Add parameter to allow activity to start and create fragment GpsSampleFragment.
30 | Intent androidIdIntent;
31 | androidIdIntent = new Intent(getInstrumentation().getTargetContext(), SampleActivity.class);
32 | androidIdIntent.putExtra(SampleActivity.ARG_ITEM_ID, IdSampleFragment.TAG);
33 | setActivityIntent(androidIdIntent);
34 |
35 | // Create activity and get fragment back
36 | FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
37 | fragmentAndroidID = (IdSampleFragment) fragmentManager.findFragmentByTag(IdSampleFragment.TAG);
38 | }
39 |
40 | @UiThreadTest
41 | public void testAndroidId() {
42 |
43 | if (!GenymotionManager.isGenymotionDevice()) {
44 | // Avoid test on non Genymotion devices.
45 | return;
46 | }
47 |
48 | TextView tvAndroidId = (TextView) fragmentAndroidID.getView().findViewById(R.id.tv_androidId);
49 | Button btnEncode = (Button) fragmentAndroidID.getView().findViewById(R.id.btn_encode);
50 | Button btnDecode = (Button) fragmentAndroidID.getView().findViewById(R.id.btn_decode);
51 |
52 | GenymotionManager genymotion;
53 | genymotion = GenymotionManager.getGenymotionManager(getInstrumentation().getTargetContext());
54 |
55 | // Encoding with android id = deadbeefdeadbeef
56 | genymotion.getId().setAndroidId("deadbeefdeadbeef");
57 | btnEncode.performClick();
58 |
59 | // Decoding with android id = deadbeefdeadbeef
60 | btnDecode.performClick();
61 |
62 | // Must have been correctly decoded
63 | String text = tvAndroidId.getText().toString();
64 | Assert.assertTrue(text.endsWith(IdSampleFragment.SECRET_MESSAGE));
65 |
66 | // Decoding with android id = baadcafebaadcafe
67 | genymotion.getId().setAndroidId("baadcafebaadcafe");
68 | try {
69 | Thread.sleep(1000); //Android needs time to poll sensors and broadcast event.
70 | } catch (InterruptedException ignored) {}
71 | btnDecode.performClick();
72 |
73 | // Must NOT been correctly decoded
74 | text = tvAndroidId.getText().toString();
75 | Assert.assertFalse(text.endsWith(IdSampleFragment.SECRET_MESSAGE));
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/ci/run_tests:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 | set -e
3 |
4 | PROGNAME=$(basename $0)
5 |
6 | OLD_PWD=$PWD
7 | cd "$(dirname $0)"
8 | SCRIPT_DIR=$PWD
9 | cd "$OLD_PWD"
10 |
11 | DEFAULT_TEMPLATE="Google Nexus 5X - 6.0.0 - API 23 - 1080x1920"
12 |
13 | GRADLE_OPTIONS="--stacktrace --debug"
14 |
15 | die() {
16 | echo "$PROGNAME: $*" >&2
17 | exit 1
18 | }
19 |
20 | usage() {
21 | if [ "$*" != "" ] ; then
22 | echo "Error: $*"
23 | fi
24 |
25 | cat << EOF
26 | Usage: $PROGNAME [OPTION ...] [device]
27 | Run Binocle tests.
28 |
29 | Options:
30 | -h, --help display this usage message and exit
31 | -u, --user [USERNAME] username to use
32 | -p, --password [PASSWORD] password to use
33 | -l, --license [LICENSE] license to use
34 | -i, --install-dir [DIR] Genymotion install dir, looks in \$PATH if not set
35 | -t, --template [TEMPLATE] template to use, defaults to "$DEFAULT_TEMPLATE"
36 | EOF
37 |
38 | exit 1
39 | }
40 |
41 | username=""
42 | password=""
43 | license=""
44 | install_dir=""
45 | template=$DEFAULT_TEMPLATE
46 | device=""
47 |
48 | parse_args() {
49 | while [ $# -gt 0 ] ; do
50 | case "$1" in
51 | -h|--help)
52 | usage
53 | ;;
54 | -u|--user)
55 | username="$2"
56 | shift
57 | ;;
58 | -p|--password)
59 | password="$2"
60 | shift
61 | ;;
62 | -l|--license)
63 | license="$2"
64 | shift
65 | ;;
66 | -i|--install-dir)
67 | install_dir="$2"
68 | shift
69 | ;;
70 | -t|--template)
71 | template="$2"
72 | shift
73 | ;;
74 | -*)
75 | usage "Unknown option '$1'"
76 | ;;
77 | *)
78 | if [ -z "$device" ] ; then
79 | device="$1"
80 | else
81 | usage "Too many arguments"
82 | fi
83 | ;;
84 | esac
85 | shift
86 | done
87 |
88 | if [ -z "$device" ] ; then
89 | usage "Not enough arguments"
90 | fi
91 | }
92 |
93 | find_tools() {
94 | if [ -n "$install_dir" ] ; then
95 | export PATH=$install_dir:$install_dir/tools:$PATH
96 | fi
97 | for tool in gmtool adb ; do
98 | echo -n "gmtool="
99 | if ! which $tool ; then
100 | die "Could not find $tool"
101 | fi
102 | done
103 | }
104 |
105 | setup_account() {
106 | if [ -n "$username" ] ; then
107 | gmtool config "username=$username" "password=$password"
108 | fi
109 | if [ -n "$license" ] ; then
110 | gmtool license register "$license"
111 | fi
112 | }
113 |
114 | create_device() {
115 | gmtool admin create "$template" "$device"
116 | echo "Starting $device"
117 | gmtool admin start "$device"
118 | echo "$device started"
119 |
120 | # Set ANDROID_SERIAL to make sure create_diskio_test_file and gradle talk
121 | # to the correct device
122 | # Format of the line we are looking for :
123 | # IP : 12.34.56.78
124 | local ip=$(gmtool admin details "$device" | awk '$1 ~ "IP" { print $3}')
125 | export ANDROID_SERIAL=$ip:5555
126 | echo "ANDROID_SERIAL=$ANDROID_SERIAL"
127 | }
128 |
129 | cleanup() {
130 | gmtool admin stop "$device" || true
131 | gmtool admin delete "$device"
132 | }
133 |
134 | do_run_tests() {
135 | (
136 | cd "$SCRIPT_DIR/.."
137 | ./gradlew cAT $GRADLE_OPTIONS
138 | )
139 | }
140 |
141 | parse_args "$@"
142 | find_tools
143 | setup_account
144 | trap cleanup EXIT
145 | create_device
146 | "$SCRIPT_DIR/create_diskio_test_file"
147 | do_run_tests
148 |
--------------------------------------------------------------------------------
/binocle/src/main/java/com/genymotion/binocle/ApiCallListActivity.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v7.app.AppCompatActivity;
6 | import android.view.Menu;
7 | import android.view.MenuInflater;
8 | import android.view.MenuItem;
9 |
10 |
11 | /**
12 | * An activity representing a list of ApiCalls. This activity
13 | * has different presentations for handset and tablet-size devices. On
14 | * handsets, the activity presents a list of items, which when touched,
15 | * lead to a {@link SampleActivity} representing
16 | * item details. On tablets, the activity presents the list of items and
17 | * item details side-by-side using two vertical panes.
18 | *
19 | * The activity makes heavy use of fragments. The list of items is a
20 | * {@link ApiCallListFragment} and the item details
21 | * (if present) is a *SampleFragment.
22 | *
23 | * This activity also implements the required
24 | * {@link ApiCallListFragment.Callbacks} interface
25 | * to listen for item selections.
26 | */
27 | public class ApiCallListActivity extends AppCompatActivity implements ApiCallListFragment.Callbacks {
28 |
29 | private static String currentTag;
30 | /**
31 | * Whether or not the activity is in two-pane mode, i.e. running on a tablet
32 | * device.
33 | */
34 | private boolean mTwoPane;
35 |
36 | @Override
37 | protected void onCreate(Bundle savedInstanceState) {
38 | super.onCreate(savedInstanceState);
39 | setContentView(R.layout.activity_apicall_list);
40 |
41 | if (findViewById(R.id.apicall_detail_container) != null) {
42 | // The detail container view will be present only in the
43 | // large-screen layouts (res/values-large and
44 | // res/values-sw600dp). If this view is present, then the
45 | // activity should be in two-pane mode.
46 | mTwoPane = true;
47 |
48 | // In two-pane mode, list items should be given the
49 | // 'activated' state when touched.
50 | ((ApiCallListFragment) getSupportFragmentManager()
51 | .findFragmentById(R.id.apicall_list))
52 | .setActivateOnItemClick(true);
53 | }
54 | }
55 |
56 | @Override
57 | public boolean onCreateOptionsMenu(Menu menu) {
58 | MenuInflater inflater = getMenuInflater();
59 | inflater.inflate(R.menu.binocle, menu);
60 | return true;
61 | }
62 |
63 | @Override
64 | public boolean onOptionsItemSelected(MenuItem item) {
65 | int id = item.getItemId();
66 | if (id == R.id.menu_refresh) {
67 | if (currentTag != null) {
68 | SampleActivity.createAndReplaceFragment(currentTag, getSupportFragmentManager());
69 | }
70 | }
71 | return super.onOptionsItemSelected(item);
72 | }
73 |
74 | /**
75 | * Callback method from {@link ApiCallListFragment.Callbacks}
76 | * indicating that the item with the given ID was selected.
77 | */
78 | @Override
79 | public void onItemSelected(String id) {
80 | if (mTwoPane) {
81 | // In two-pane mode, show the detail view in this activity by
82 | // adding or replacing the detail fragment using a
83 | // fragment transaction.
84 | currentTag = id;
85 | SampleActivity.createAndReplaceFragment(id, getSupportFragmentManager());
86 |
87 | } else {
88 | // In single-pane mode, simply start the detail activity
89 | // for the selected item ID.
90 | Intent detailIntent;
91 | detailIntent = new Intent(this, SampleActivity.class);
92 | detailIntent.putExtra(SampleActivity.ARG_ITEM_ID, id);
93 | startActivity(detailIntent);
94 | }
95 | }
96 | }
--------------------------------------------------------------------------------
/binocle/src/main/java/com/genymotion/binocle/DiskIOSampleFragment.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle;
2 |
3 | import android.os.AsyncTask;
4 | import android.os.Bundle;
5 | import android.os.Environment;
6 | import android.support.v4.app.Fragment;
7 | import android.util.Log;
8 | import android.view.LayoutInflater;
9 | import android.view.View;
10 | import android.view.ViewGroup;
11 | import android.widget.Button;
12 | import android.widget.TextView;
13 |
14 | import java.io.File;
15 | import java.io.FileInputStream;
16 | import java.io.FileOutputStream;
17 | import java.io.IOException;
18 |
19 | public class DiskIOSampleFragment extends Fragment {
20 | public static final String TAG = "DiskIO";
21 | private Button createFileBtn;
22 |
23 | // Must be kept in sync with ci/create_diskio_test_file
24 | private static final long FILESIZE_MB = 200;
25 | private static final File testFile = new File(
26 | Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS),
27 | "diskio_test");
28 |
29 | private static final long FILESIZE_KB = FILESIZE_MB * 1024;
30 | private static final int ONE_MB = 1024 * 1024;
31 | private float speedKBs = 0;
32 |
33 | @Override
34 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
35 | View rootView = inflater.inflate(R.layout.fragment_diskio_sample, container, false);
36 |
37 | createFileBtn = (Button) rootView.findViewById(R.id.bench);
38 | createFileBtn.setOnClickListener(new View.OnClickListener() {
39 | @Override
40 | public void onClick(View view) {
41 | TextView tv = (TextView)getActivity().findViewById(R.id.result);
42 | tv.setText("reading...");
43 | new BenchDiskIO().execute();
44 | }
45 | });
46 |
47 | return rootView;
48 | }
49 |
50 | public float getSpeedKBs() {
51 | return speedKBs;
52 | }
53 |
54 | private class BenchDiskIO extends AsyncTask {
55 | @Override
56 | protected Long doInBackground(Void... voids) {
57 | long ms = -1;
58 | try {
59 | createFileIfNeeded();
60 | ms = benchRead();
61 | } catch (IOException e) {
62 | Log.e(TAG, "IO error ");
63 | e.printStackTrace();
64 | }
65 |
66 | return ms;
67 | }
68 |
69 | @Override
70 | protected void onPostExecute(Long ms) {
71 | TextView tv = (TextView)getActivity().findViewById(R.id.result);
72 | float seconds = ms / 1000f;
73 | speedKBs = FILESIZE_KB / seconds;
74 | tv.setText(String.format("%.2f KB/s", speedKBs));
75 |
76 | }
77 | }
78 |
79 | private void createFileIfNeeded() throws IOException {
80 | if (!testFile.exists() || testFile.length() != FILESIZE_MB * ONE_MB) {
81 | createFile();
82 | }
83 | }
84 |
85 | private void createFile() throws IOException {
86 | Log.d(TAG, "creating file...");
87 | FileOutputStream fo = new FileOutputStream(testFile);
88 | byte[] buff = new byte[ONE_MB];
89 | for (int i = 0; i < FILESIZE_MB; ++i) {
90 | fo.write(buff);
91 | }
92 | fo.flush();
93 | fo.close();
94 | }
95 |
96 | private long benchRead() throws IOException {
97 | FileInputStream fi = new FileInputStream(testFile);
98 | byte[] buff = new byte[ONE_MB];
99 | long before = System.currentTimeMillis();
100 | while (fi.read(buff) > 0) {
101 | }
102 | long after = System.currentTimeMillis();
103 | long time = after - before;
104 | Log.d(TAG, "time: " + time);
105 |
106 | return time;
107 | }
108 | }
109 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | genymotion-binocle
2 | ==================
3 |
4 | *An Android app showing Genymotion Java API usage.*
5 | 
6 |
7 |
8 | Binocle is a simple application showcasing Genymotion Java API use.
9 | In this application, you can find activities for which the behavior depends on sensor values.
10 | Below are some Android test examples built with Genymotion Java API to manipulate sensor values and check activity behaviors.
11 |
12 | [Genymotion Java Api documentation](https://cloud.genymotion.com/page/api/)
13 | [Genymotion Java Api Javadoc](https://cloud.genymotion.com/static/external/javadoc/index.html)
14 |
15 | ### Battery
16 | This part of the application displays a warning if the device is not plugged to a power source and has less than 10% of charge left.
17 | * Here is the fragment showing it: [BatterySampleFragment.java](https://github.com/Genymobile/genymotion-binocle/blob/master/binocle/src/main/java/com/genymotion/binocle/BatterySampleFragment.java)
18 | * Here is an Android test of the behavior: [TestBattery.java](https://github.com/Genymobile/genymotion-binocle/blob/master/binocle/src/androidTest/java/com/genymotion/binocle/test/TestBattery.java)
19 |
20 | ### GPS
21 | This part of the application displays a message if the device is localized near a specific place.
22 | * Here is the fragment showing it: [GpsSampleFragment.java](https://github.com/Genymobile/genymotion-binocle/blob/master/binocle/src/main/java/com/genymotion/binocle/GpsSampleFragment.java)
23 | * Here is an Android test of the behavior: [TestGps.java](https://github.com/Genymobile/genymotion-binocle/blob/master/binocle/src/androidTest/java/com/genymotion/binocle/test/TestGps.java)
24 |
25 | ### Radio
26 | This part of the application displays a message if the device is a Nexus 4, as recognized by its IMEI number.
27 | * Here is the fragment showing it: [RadioSampleFragment.java](https://github.com/Genymobile/genymotion-binocle/blob/master/binocle/src/main/java/com/genymotion/binocle/RadioSampleFragment.java)
28 | * Here is an Android test of the behavior: [TestRadio.java](https://github.com/Genymobile/genymotion-binocle/blob/master/binocle/src/androidTest/java/com/genymotion/binocle/test/TestRadio.java)
29 |
30 | ### Id
31 | This part of the application encrypts data using ANDROID_ID to avoid the backed up data to be moved on another Android device.
32 | * Here is the fragment showing it: [IdSampleFragment.java](https://github.com/Genymobile/genymotion-binocle/blob/master/binocle/src/main/java/com/genymotion/binocle/IdSampleFragment.java)
33 | * Here is an Android test of the behavior: [TestId.java](https://github.com/Genymobile/genymotion-binocle/blob/master/binocle/src/androidTest/java/com/genymotion/binocle/test/TestId.java)
34 |
35 | ### Phone
36 | This part of the application displays a green check when the device receives an SMS containing "666".
37 | * Here is the fragment showing it: [PhoneSampleFragment.java](https://github.com/Genymobile/genymotion-binocle/blob/master/binocle/src/main/java/com/genymotion/binocle/PhoneSampleFragment.java)
38 | * Here is an Android test of the behavior: [TestPhone.java](https://github.com/Genymobile/genymotion-binocle/blob/master/binocle/src/androidTest/java/com/genymotion/binocle/test/TestPhone.java)
39 |
40 | ### DiskIO
41 | This part of the application shows a button to compute the read byterate of a file.
42 | * Here is the fragment showing it: [DiskIOSampleFragment.java](https://github.com/Genymobile/genymotion-binocle/blob/master/binocle/src/main/java/com/genymotion/binocle/DiskIOSampleFragment.java)
43 | * Here is an Android test of the behavior: [TestDiskIO.java](https://github.com/Genymobile/genymotion-binocle/blob/master/binocle/src/androidTest/java/com/genymotion/binocle/test/TestDiskIO.java)
44 |
45 | # License
46 | ```
47 | Copyright 2015 Genymotion
48 |
49 | Licensed under the Apache License, Version 2.0 (the "License");
50 | you may not use this file except in compliance with the License.
51 | You may obtain a copy of the License at
52 |
53 | http://www.apache.org/licenses/LICENSE-2.0
54 |
55 | Unless required by applicable law or agreed to in writing, software
56 | distributed under the License is distributed on an "AS IS" BASIS,
57 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
58 | See the License for the specific language governing permissions and
59 | limitations under the License.
60 | ```
61 |
--------------------------------------------------------------------------------
/binocle/src/main/java/com/genymotion/binocle/SampleActivity.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle;
2 |
3 | import android.content.Intent;
4 | import android.os.Bundle;
5 | import android.support.v4.app.Fragment;
6 | import android.support.v4.app.FragmentManager;
7 | import android.support.v4.app.FragmentTransaction;
8 | import android.support.v4.app.NavUtils;
9 | import android.support.v7.app.AppCompatActivity;
10 | import android.view.Menu;
11 | import android.view.MenuInflater;
12 | import android.view.MenuItem;
13 |
14 | /**
15 | * An activity representing a single ApiCall detail screen. This
16 | * activity is only used on handset devices. On tablet-size devices,
17 | * item details are presented side-by-side with a list of items
18 | * in a {@link ApiCallListActivity}.
19 | */
20 | public class SampleActivity extends AppCompatActivity {
21 |
22 | public static final String ARG_ITEM_ID = "item_id";
23 |
24 | public static void createAndReplaceFragment(String tag, FragmentManager fm) {
25 |
26 | Fragment fragment = fm.findFragmentByTag(tag);
27 |
28 | // Create fragment if it does not already exists
29 | if (fragment == null) {
30 | switch (tag) {
31 | case BatterySampleFragment.TAG:
32 | fragment = new BatterySampleFragment();
33 | break;
34 | case GpsSampleFragment.TAG:
35 | fragment = new GpsSampleFragment();
36 | break;
37 | case RadioSampleFragment.TAG:
38 | fragment = new RadioSampleFragment();
39 | break;
40 | case IdSampleFragment.TAG:
41 | fragment = new IdSampleFragment();
42 | break;
43 | case PhoneSampleFragment.TAG:
44 | fragment = new PhoneSampleFragment();
45 | break;
46 | case DiskIOSampleFragment.TAG:
47 | fragment = new DiskIOSampleFragment();
48 | break;
49 | default:
50 | break;
51 | }
52 | }
53 |
54 | if (fragment != null) {
55 | // Replace current fragment by new one
56 | FragmentTransaction ft = fm.beginTransaction();
57 | ft.replace(R.id.apicall_detail_container, fragment, tag);
58 | ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
59 | ft.commit();
60 | }
61 | }
62 |
63 | @Override
64 | protected void onCreate(Bundle savedInstanceState) {
65 | super.onCreate(savedInstanceState);
66 | setContentView(R.layout.activity_apicall_detail);
67 |
68 | // Show the Up button in the action bar.
69 | getSupportActionBar().setDisplayHomeAsUpEnabled(true);
70 |
71 | // savedInstanceState is non-null when there is fragment state
72 | // saved from previous configurations of this activity
73 | // (e.g. when rotating the screen from portrait to landscape).
74 | // In this case, the fragment will automatically be re-added
75 | // to its container so we don't need to manually add it.
76 | // For more information, see the Fragments API guide at:
77 | //
78 | // http://developer.android.com/guide/components/fragments.html
79 | //
80 | if (savedInstanceState == null) {
81 | // Create the detail fragment and add it to the activity
82 | // using a fragment transaction.
83 | String tag = getIntent().getStringExtra(ARG_ITEM_ID);
84 | createAndReplaceFragment(tag, getSupportFragmentManager());
85 | }
86 | }
87 |
88 | @Override
89 | public boolean onCreateOptionsMenu(Menu menu) {
90 | MenuInflater inflater = getMenuInflater();
91 | inflater.inflate(R.menu.binocle, menu);
92 | return true;
93 | }
94 |
95 | @Override
96 | public boolean onOptionsItemSelected(MenuItem item) {
97 | int id = item.getItemId();
98 | if (id == android.R.id.home) {
99 | // This ID represents the Home or Up button. In the case of this
100 | // activity, the Up button is shown. Use NavUtils to allow users
101 | // to navigate up one level in the application structure. For
102 | // more details, see the Navigation pattern on Android Design:
103 | //
104 | // http://developer.android.com/design/patterns/navigation.html#up-vs-back
105 | //
106 | NavUtils.navigateUpTo(this, new Intent(this, ApiCallListActivity.class));
107 | return true;
108 | } else if (id == R.id.menu_refresh) {
109 | String tag = getIntent().getStringExtra(ARG_ITEM_ID);
110 | createAndReplaceFragment(tag, getSupportFragmentManager());
111 | }
112 | return super.onOptionsItemSelected(item);
113 | }
114 | }
115 |
--------------------------------------------------------------------------------
/binocle/src/main/java/com/genymotion/binocle/ApiCallListFragment.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle;
2 |
3 | import android.app.Activity;
4 | import android.os.Bundle;
5 | import android.support.v4.app.ListFragment;
6 | import android.view.View;
7 | import android.widget.ArrayAdapter;
8 | import android.widget.ListView;
9 |
10 | import com.genymotion.binocle.apicalls.ApiCallSamples;
11 |
12 | /**
13 | * A list fragment representing a list of ApiCalls. This fragment
14 | * also supports tablet devices by allowing list items to be given an
15 | * 'activated' state upon selection.
16 | *
17 | * Activities containing this fragment MUST implement the {@link Callbacks}
18 | * interface.
19 | */
20 | public class ApiCallListFragment extends ListFragment {
21 |
22 | /**
23 | * The serialization (saved instance state) Bundle key representing the
24 | * activated item position. Only used on tablets.
25 | */
26 | private static final String STATE_ACTIVATED_POSITION = "activated_position";
27 | /**
28 | * A dummy implementation of the {@link Callbacks} interface that does
29 | * nothing. Used only when this fragment is not attached to an activity.
30 | */
31 | private static final Callbacks sDummyCallbacks = new Callbacks() {
32 | @Override
33 | public void onItemSelected(String id) {
34 | }
35 | };
36 | /**
37 | * The fragment's current callback object, which is notified of list item
38 | * clicks.
39 | */
40 | private Callbacks mCallbacks = sDummyCallbacks;
41 | /**
42 | * The current activated item position. Only used on tablets.
43 | */
44 | private int mActivatedPosition = ListView.INVALID_POSITION;
45 |
46 | @Override
47 | public void onCreate(Bundle savedInstanceState) {
48 | super.onCreate(savedInstanceState);
49 |
50 | setListAdapter(new ArrayAdapter<>(
51 | getActivity(),
52 | android.R.layout.simple_list_item_1,
53 | android.R.id.text1,
54 | ApiCallSamples.ITEMS));
55 | }
56 |
57 | @Override
58 | public void onViewCreated(View view, Bundle savedInstanceState) {
59 | super.onViewCreated(view, savedInstanceState);
60 |
61 | // Restore the previously serialized activated item position.
62 | if (savedInstanceState != null
63 | && savedInstanceState.containsKey(STATE_ACTIVATED_POSITION)) {
64 | setActivatedPosition(savedInstanceState.getInt(STATE_ACTIVATED_POSITION));
65 | }
66 | }
67 |
68 | @Override
69 | public void onAttach(Activity activity) {
70 | super.onAttach(activity);
71 |
72 | // Activities containing this fragment must implement its callbacks.
73 | if (!(activity instanceof Callbacks)) {
74 | throw new IllegalStateException("Activity must implement fragment's callbacks.");
75 | }
76 |
77 | mCallbacks = (Callbacks) activity;
78 | }
79 |
80 | @Override
81 | public void onDetach() {
82 | super.onDetach();
83 |
84 | // Reset the active callbacks interface to the dummy implementation.
85 | mCallbacks = sDummyCallbacks;
86 | }
87 |
88 | @Override
89 | public void onListItemClick(ListView listView, View view, int position, long id) {
90 | super.onListItemClick(listView, view, position, id);
91 |
92 | // Notify the active callbacks interface (the activity, if the
93 | // fragment is attached to one) that an item has been selected.
94 | mCallbacks.onItemSelected(ApiCallSamples.ITEMS.get(position).id);
95 | }
96 |
97 | @Override
98 | public void onSaveInstanceState(Bundle outState) {
99 | super.onSaveInstanceState(outState);
100 | if (mActivatedPosition != ListView.INVALID_POSITION) {
101 | // Serialize and persist the activated item position.
102 | outState.putInt(STATE_ACTIVATED_POSITION, mActivatedPosition);
103 | }
104 | }
105 |
106 | /**
107 | * Turns on activate-on-click mode. When this mode is on, list items will be
108 | * given the 'activated' state when touched.
109 | */
110 | public void setActivateOnItemClick(boolean activateOnItemClick) {
111 | // When setting CHOICE_MODE_SINGLE, ListView will automatically
112 | // give items the 'activated' state when touched.
113 | getListView().setChoiceMode(activateOnItemClick
114 | ? ListView.CHOICE_MODE_SINGLE
115 | : ListView.CHOICE_MODE_NONE);
116 | }
117 |
118 | private void setActivatedPosition(int position) {
119 | if (position == ListView.INVALID_POSITION) {
120 | getListView().setItemChecked(mActivatedPosition, false);
121 | } else {
122 | getListView().setItemChecked(position, true);
123 | }
124 |
125 | mActivatedPosition = position;
126 | }
127 |
128 | /**
129 | * A callback interface that all activities containing this fragment must
130 | * implement. This mechanism allows activities to be notified of item
131 | * selections.
132 | */
133 | public interface Callbacks {
134 | /**
135 | * Callback for when an item has been selected.
136 | */
137 | void onItemSelected(String id);
138 | }
139 | }
140 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/binocle/src/main/java/com/genymotion/binocle/IdSampleFragment.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle;
2 |
3 |
4 | import android.app.Activity;
5 | import android.os.Bundle;
6 | import android.provider.Settings.Secure;
7 | import android.support.v4.app.Fragment;
8 | import android.util.Log;
9 | import android.view.LayoutInflater;
10 | import android.view.View;
11 | import android.view.ViewGroup;
12 | import android.widget.TextView;
13 |
14 | import java.io.*;
15 | import java.nio.charset.Charset;
16 | import java.security.InvalidKeyException;
17 | import java.security.NoSuchAlgorithmException;
18 | import java.security.spec.InvalidKeySpecException;
19 | import java.security.spec.KeySpec;
20 |
21 | import javax.crypto.Cipher;
22 | import javax.crypto.CipherInputStream;
23 | import javax.crypto.CipherOutputStream;
24 | import javax.crypto.NoSuchPaddingException;
25 | import javax.crypto.SecretKeyFactory;
26 | import javax.crypto.spec.PBEKeySpec;
27 | import javax.crypto.spec.SecretKeySpec;
28 |
29 | public class IdSampleFragment extends Fragment implements View.OnClickListener{
30 | public static final String TAG = "Id";
31 |
32 | public static final String SECRET_MESSAGE = "Genymotion ♥ developpers!";
33 | private static final String FILE_NAME = "encrypted_data";
34 | private final Charset UTF8_CHARSET = Charset.forName("UTF-8");
35 |
36 | private TextView tvAndroidId;
37 |
38 | private final byte[] salt = {
39 | (byte) 0xde, (byte) 0xad, (byte) 0xbe, (byte) 0xef,
40 | (byte) 0xba, (byte) 0xad, (byte) 0xca, (byte) 0xfe
41 | };
42 |
43 | @Override
44 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
45 | View rootView = inflater.inflate(R.layout.fragment_id_sample, container, false);
46 |
47 | tvAndroidId = (TextView) rootView.findViewById(R.id.tv_androidId);
48 | String androidId = Secure.getString(getActivity().getContentResolver(), Secure.ANDROID_ID);
49 | tvAndroidId.setText(getActivity().getResources().getString(R.string.android_id, androidId));
50 | View btnEncode = rootView.findViewById(R.id.btn_encode);
51 | btnEncode.setOnClickListener(this);
52 | View btnDecode = rootView.findViewById(R.id.btn_decode);
53 | btnDecode.setOnClickListener(this);
54 |
55 | return rootView;
56 | }
57 |
58 | @Override
59 | public void onClick(View view) {
60 | if (view.getId() == R.id.btn_encode) {
61 | doEncode();
62 | } else if (view.getId() == R.id.btn_decode) {
63 | doDecode();
64 | }
65 | }
66 |
67 | private void doEncode() {
68 | try {
69 | // Set up secret key spec for 128-bit AES encryption
70 | String androidId = Secure.getString(getActivity().getContentResolver(), Secure.ANDROID_ID);
71 | SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
72 | KeySpec spec = new PBEKeySpec(androidId.toCharArray(), salt, 45, 128);
73 | SecretKeySpec sks = new SecretKeySpec(factory.generateSecret(spec).getEncoded(), "AES");
74 |
75 | // Create AES cipher
76 | Cipher cipher = Cipher.getInstance("AES");
77 | cipher.init(Cipher.ENCRYPT_MODE, sks);
78 |
79 | // This stream write the encrypted text.
80 | FileOutputStream fos = getActivity().openFileOutput(FILE_NAME, Activity.MODE_PRIVATE);
81 | // Wrap the output stream
82 | CipherOutputStream cos = new CipherOutputStream(fos, cipher);
83 |
84 | // Write bytes
85 | cos.write(SECRET_MESSAGE.getBytes(UTF8_CHARSET));
86 |
87 | // Flush and close streams.
88 | cos.flush();
89 | cos.close();
90 | fos.close();
91 |
92 | tvAndroidId.setText(getActivity().getResources().getString(R.string.encoding_done, androidId));
93 |
94 | } catch (NoSuchPaddingException
95 | |NoSuchAlgorithmException
96 | |IOException
97 | |InvalidKeyException
98 | |InvalidKeySpecException e) {
99 | Log.e(TAG, "Unable to encrypt secret", e);
100 | tvAndroidId.setText(R.string.encoding_failed);
101 | }
102 | }
103 |
104 | private void doDecode(){
105 | try {
106 | // Set up secret key spec for 128-bit AES decryption
107 | String androidId = Secure.getString(getActivity().getContentResolver(), Secure.ANDROID_ID);
108 | SecretKeyFactory factory = SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1");
109 | KeySpec spec = new PBEKeySpec(androidId.toCharArray(), salt, 45, 128);
110 | SecretKeySpec sks = new SecretKeySpec(factory.generateSecret(spec).getEncoded(), "AES");
111 |
112 | // Create AES cipher
113 | Cipher cipher = Cipher.getInstance("AES");
114 | cipher.init(Cipher.DECRYPT_MODE, sks);
115 |
116 | // This stream read the encrypted text.
117 | FileInputStream fis = getActivity().openFileInput(FILE_NAME);
118 |
119 | // Wrap the input stream
120 | CipherInputStream cis = new CipherInputStream(fis, cipher);
121 |
122 | // Read and decrypt file
123 | int size = SECRET_MESSAGE.getBytes(UTF8_CHARSET).length;
124 | byte[] message = new byte[size];
125 | int pos = 0;
126 | int read;
127 | do {
128 | read = cis.read(message, pos, size);
129 | pos += read;
130 | size -= read;
131 | } while (read > 0);
132 | String secret = new String(message, UTF8_CHARSET);
133 | String label = getActivity().getResources().getString(R.string.decoding_done, secret);
134 | tvAndroidId.setText(label);
135 |
136 | } catch (NoSuchPaddingException
137 | | NoSuchAlgorithmException
138 | | IOException
139 | | InvalidKeyException
140 | | InvalidKeySpecException e) {
141 | Log.e(TAG, "Unable to decrypt secret", e);
142 | tvAndroidId.setText(R.string.decoding_failed);
143 | }
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/binocle/src/main/java/com/genymotion/binocle/GpsSampleFragment.java:
--------------------------------------------------------------------------------
1 | package com.genymotion.binocle;
2 |
3 | import android.content.Context;
4 | import android.location.Location;
5 | import android.location.LocationListener;
6 | import android.location.LocationManager;
7 | import android.os.Bundle;
8 | import android.support.v4.app.Fragment;
9 | import android.util.Log;
10 | import android.view.LayoutInflater;
11 | import android.view.View;
12 | import android.view.ViewGroup;
13 | import android.widget.TextView;
14 |
15 | public class GpsSampleFragment extends Fragment {
16 |
17 | public static final String TAG = "Gps";
18 | private static final int EARTH_R = 6371; //km
19 | private TextView tvGpsWarning;
20 | private TextView tvGpsCurrentLat;
21 | private TextView tvGpsCurrentLng;
22 | private TextView tvGpsCurrentAlt;
23 | private TextView tvGpsCurrentBearing;
24 | private TextView tvGpsCurrentAccuracy;
25 | private TextView tvGpsDistanceToDalvik;
26 | private LocationManager locationManager;
27 | private LocationListener locationListener;
28 |
29 | /*
30 | Calculate distance in km between two coordinates using HaverSine method.
31 | */
32 | private static double getHaverSineDistance(double latSrc, double lngSrc, double latDst, double lngDst) {
33 | double dLat = Math.toRadians(latDst - latSrc);
34 | double dLon = Math.toRadians(lngDst - lngSrc);
35 | double latSrcRad = Math.toRadians(latSrc);
36 | double latDstRad = Math.toRadians(latDst);
37 |
38 | double a = Math.sin(dLat / 2) * Math.sin(dLat / 2) + Math.sin(dLon / 2) * Math.sin(dLon / 2) * Math.cos(latSrcRad) * Math.cos(latDstRad);
39 | double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
40 | return EARTH_R * c;
41 | }
42 |
43 | @Override
44 | public void onCreate(Bundle savedInstanceState) {
45 | super.onCreate(savedInstanceState);
46 |
47 | locationManager = (LocationManager) this.getActivity().getSystemService(Context.LOCATION_SERVICE);
48 | locationListener = new MyLocationListener();
49 | }
50 |
51 | @Override
52 | public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
53 | View rootView = inflater.inflate(R.layout.fragment_gps_sample, container, false);
54 |
55 | //retrieve widgets
56 | tvGpsWarning = (TextView) rootView.findViewById(R.id.tv_gpsWarning);
57 | tvGpsCurrentLat = (TextView) rootView.findViewById(R.id.tv_gpsCurrentLat);
58 | tvGpsCurrentLng = (TextView) rootView.findViewById(R.id.tv_gpsCurrentLng);
59 | tvGpsCurrentAlt = (TextView) rootView.findViewById(R.id.tv_gpsCurrentAlt);
60 | tvGpsCurrentBearing = (TextView) rootView.findViewById(R.id.tv_gpsCurrentBearing);
61 | tvGpsCurrentAccuracy = (TextView) rootView.findViewById(R.id.tv_gpsCurrentAccuracy);
62 | tvGpsDistanceToDalvik = (TextView) rootView.findViewById(R.id.tv_gpsDistanceToDalvik);
63 |
64 | //default values
65 | tvGpsWarning.setVisibility(View.GONE);
66 | tvGpsCurrentLat.setVisibility(View.INVISIBLE);
67 | tvGpsCurrentLng.setVisibility(View.INVISIBLE);
68 | tvGpsDistanceToDalvik.setVisibility(View.INVISIBLE);
69 | tvGpsCurrentAlt.setVisibility(View.INVISIBLE);
70 | tvGpsCurrentBearing.setVisibility(View.INVISIBLE);
71 | tvGpsCurrentAccuracy.setVisibility(View.INVISIBLE);
72 |
73 | return rootView;
74 | }
75 |
76 | @Override
77 | public void onResume() {
78 | super.onResume();
79 |
80 | // Register the listener with the Location Manager to receive location updates
81 | locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
82 | }
83 |
84 | @Override
85 | public void onPause() {
86 | // Unregister
87 | locationManager.removeUpdates(locationListener);
88 |
89 | super.onPause();
90 | }
91 |
92 | public class MyLocationListener implements LocationListener {
93 |
94 | static final double DALVIK_LAT = 65.966667;
95 | static final double DALVIK_LNG = -18.533327;
96 |
97 | @Override
98 | public void onLocationChanged(Location loc) {
99 | final double latitude = loc.getLatitude();
100 | final double longitude = loc.getLongitude();
101 | final double altitude = loc.getAltitude();
102 | final float bearing = loc.getBearing();
103 | final float accuracy = loc.getAccuracy();
104 |
105 | tvGpsCurrentLat.setText(getResources().getString(R.string.gps_currentLat, latitude));
106 | tvGpsCurrentLng.setText(getResources().getString(R.string.gps_currentLng, longitude));
107 | tvGpsCurrentAlt.setText(getResources().getString(R.string.gps_currentAltitude, altitude));
108 | tvGpsCurrentBearing.setText(getResources().getString(R.string.gps_currentBearing, bearing));
109 | tvGpsCurrentAccuracy.setText(getResources().getString(R.string.gps_currentAccuracy, accuracy));
110 |
111 | // Calculate distance using haversine
112 | double distance = GpsSampleFragment.getHaverSineDistance(latitude, longitude, DALVIK_LAT, DALVIK_LNG);
113 | tvGpsDistanceToDalvik.setText(getResources().getString(R.string.gps_distanceToDalvik, (int) distance));
114 |
115 | // Ensure labels are shown
116 | tvGpsCurrentLat.setVisibility(View.VISIBLE);
117 | tvGpsCurrentLng.setVisibility(View.VISIBLE);
118 | tvGpsDistanceToDalvik.setVisibility(View.VISIBLE);
119 | tvGpsCurrentAlt.setVisibility(View.VISIBLE);
120 | tvGpsCurrentBearing.setVisibility(View.VISIBLE);
121 | tvGpsCurrentAccuracy.setVisibility(View.VISIBLE);
122 |
123 | if (distance <= 100) {
124 | Log.d(GpsSampleFragment.TAG, "Show location warning");
125 | tvGpsWarning.setVisibility(View.VISIBLE);
126 | } else {
127 | Log.d(GpsSampleFragment.TAG, "Hide location warning");
128 | tvGpsWarning.setVisibility(View.GONE);
129 | }
130 |
131 | }
132 |
133 | @Override
134 | public void onProviderDisabled(String provider) {
135 | }
136 |
137 | @Override
138 | public void onProviderEnabled(String provider) {
139 | }
140 |
141 | @Override
142 | public void onStatusChanged(String provider, int status, Bundle extras) {
143 | }
144 |
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright [yyyy] [name of copyright owner]
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------