Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-7185

Automatically unlock the emulator

    XMLWordPrintable

Details

    Description

      Right now when automating JUnit testing with Android, I have to find a way to programmatically unlock the emulator. It would be great if the Hudson android emulator plugin would take care of this for the users!

      Attachments

        Activity

          This is fixed in version 1.4.

          • Newly-created or newly-wiped emulators start up unlocked, so nothing is done in this case.
          • For already-existing emulators created via parameters, they are unlocked five seconds after the "device is ready" signal is received.
          • For named emulators which are not being wiped at startup, we cannot tell if they are new or not, so we attempt to unlock the screen anyway, then press the Back button once to ensure the Menu isn't showing.

          So in all cases, once the plugin has finished executing, the screen should be unlocked and ready for use.

          orrc Christopher Orr added a comment - This is fixed in version 1.4. Newly-created or newly-wiped emulators start up unlocked, so nothing is done in this case. For already-existing emulators created via parameters, they are unlocked five seconds after the "device is ready" signal is received. For named emulators which are not being wiped at startup, we cannot tell if they are new or not, so we attempt to unlock the screen anyway, then press the Back button once to ensure the Menu isn't showing. So in all cases, once the plugin has finished executing, the screen should be unlocked and ready for use.

          I've actually developed and tested this feature; I should release a new version of the plugin soon!

          orrc Christopher Orr added a comment - I've actually developed and tested this feature; I should release a new version of the plugin soon!
          mfriedenhagen Mirko Friedenhagen added a comment - - edited

          Same command during maven execution:

              <profiles>
                  <profile>
                      <id>pre-integration-test-unlock-screen</id>
                      <activation>
                          <property>
                              <name>env.ANDROID_AVD_USER_PORT</name>
                          </property>
                      </activation>
                      <build>
                          <plugins>
                              <plugin>
                                  <groupId>org.apache.maven.plugins</groupId>
                                  <artifactId>maven-antrun-plugin</artifactId>
                                  <version>1.5</version>
                                  <dependencies>
                                      <dependency>
                                          <groupId>org.apache.ant</groupId>
                                          <artifactId>ant-commons-net</artifactId>
                                          <version>1.8.1</version>
                                      </dependency>
                                  </dependencies>
                                  <executions>
                                      <execution>
                                          <phase>pre-integration-test</phase>
                                          <configuration>
                                              <target>
                                                  <echo>
                                                      Using: ANDROID_AVD_USER_PORT=${env.ANDROID_AVD_USER_PORT}
                                                  </echo>
                                                  <telnet
                                                      server="localhost"
                                                      port="${env.ANDROID_AVD_USER_PORT}">
                                                      <read>OK</read>
                                                      <write>event send EV_KEY:KEY_MENU:1 EV_KEY:KEY_MENU:0</write>
                                                      <read>OK</read>
                                                      <write>quit</write>
                                                  </telnet>
                                              </target>
                                          </configuration>
                                          <goals>
                                              <goal>run</goal>
                                          </goals>
                                      </execution>
                                  </executions>
                              </plugin>
                          </plugins>
                      </build>
                  </profile>
              </profiles>
          
          mfriedenhagen Mirko Friedenhagen added a comment - - edited Same command during maven execution: <profiles> <profile> <id> pre-integration-test-unlock-screen </id> <activation> <property> <name> env.ANDROID_AVD_USER_PORT </name> </property> </activation> <build> <plugins> <plugin> <groupId> org.apache.maven.plugins </groupId> <artifactId> maven-antrun-plugin </artifactId> <version> 1.5 </version> <dependencies> <dependency> <groupId> org.apache.ant </groupId> <artifactId> ant-commons-net </artifactId> <version> 1.8.1 </version> </dependency> </dependencies> <executions> <execution> <phase> pre-integration-test </phase> <configuration> <target> <echo> Using: ANDROID_AVD_USER_PORT=${env.ANDROID_AVD_USER_PORT} </echo> <telnet server= "localhost" port= "${env.ANDROID_AVD_USER_PORT}" > <read> OK </read> <write> event send EV_KEY:KEY_MENU:1 EV_KEY:KEY_MENU:0 </write> <read> OK </read> <write> quit </write> </telnet> </target> </configuration> <goals> <goal> run </goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles>

          Yes, this would be a nice feature indeed. I'll add it to the TODO list!

          For now, I just use the following in a script at the start of the build:

          echo "event send EV_KEY:KEY_MENU:1 EV_KEY:KEY_MENU:0" | nc -q1 localhost $ANDROID_AVD_USER_PORT
          orrc Christopher Orr added a comment - Yes, this would be a nice feature indeed. I'll add it to the TODO list! For now, I just use the following in a script at the start of the build: echo "event send EV_KEY:KEY_MENU:1 EV_KEY:KEY_MENU:0" | nc -q1 localhost $ANDROID_AVD_USER_PORT

          People

            orrc Christopher Orr
            doingit doingit
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: