Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 19 additions & 31 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,28 @@
language: java
jdk: oraclejdk7
env: ANDROID_SDK=android-16 ANDROID_ABI=armeabi-v7a
language: android
android:
components:
# The SDK version used to compile your project
- $ANDROID_SDK

before_install:
# Install ia32-libs (necessary for Android SDK to run on 64-bit linux)
# - sudo apt-get clean && sudo apt-get update
- sudo apt-get update -qq
- sudo apt-get install -qq --force-yes libgd2-xpm ia32-libs ia32-libs-multiarch
# Additional components
- extra-google-m2repository
- extra-android-m2repository
- extra-android-support

# Install Android SDK
- wget http://dl.google.com/android/android-sdk_r22.6.2-linux.tgz
- tar -zxf android-sdk_r22.6.2-linux.tgz
- ls
- export ANDROID_HOME=`pwd`/android-sdk-linux
- export PATH=${PATH}:${ANDROID_HOME}/tools:${ANDROID_HOME}/platform-tools
# Specify at least one system image,
# if you need to run emulator(s) during your tests
- sys-img-$ANDROID_ABI-$ANDROID_SDK

# Install build-tools
- wget https://dl-ssl.google.com/android/repository/build-tools_r19.0.3-linux.zip
- unzip build-tools_r19.0.3-linux.zip -d $ANDROID_HOME
- mkdir -p $ANDROID_HOME/build-tools/
- mv $ANDROID_HOME/android-4.4.2 $ANDROID_HOME/build-tools/19.0.1
licenses:
- 'android-sdk-license-.+'

# Install required Android components
- android list sdk --extended
# Do you accept the license 'android-sdk-license-bcbbd656' [y/n]:
- echo -ne "y\n" | android update sdk --filter system-image,platform-tools,extra-android-support,$ANDROID_SDK --no-ui --force

# Create and start emulator
before_script:
- echo no | android create avd --force -n test -t $ANDROID_SDK --abi $ANDROID_ABI
- android list avds
- emulator -avd test -no-skin -no-audio -no-window &
- android-wait-for-emulator
- adb shell input keyevent 82 &
- mvn --version

before_script:
# Make sure the emulator has started before running tests
- chmod +x ./wait_for_emulator
- ./wait_for_emulator

script:
- mvn clean install -e
script: mvn clean install
25 changes: 25 additions & 0 deletions android-wait-for-emulator
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

# Originally written by Ralf Kistner <[email protected]>, but placed in the public domain

set +e

bootanim=""
failcounter=0
timeout_in_sec=360

until [[ "$bootanim" =~ "stopped" ]]; do
bootanim=`adb -e shell getprop init.svc.bootanim 2>&1 &`
if [[ "$bootanim" =~ "device not found" || "$bootanim" =~ "device offline"
|| "$bootanim" =~ "running" ]]; then
let "failcounter += 1"
echo "Waiting for emulator to start"
if [[ $failcounter -gt timeout_in_sec ]]; then
echo "Timeout ($timeout_in_sec seconds) reached; failed to start emulator"
exit 1
fi
fi
sleep 1
done

echo "Emulator is ready"
11 changes: 10 additions & 1 deletion src/com/activeandroid/ActiveAndroid.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.database.sqlite.SQLiteDatabase;

import com.activeandroid.util.Log;
import android.os.Build;

public final class ActiveAndroid {
//////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -60,8 +61,16 @@ public static SQLiteDatabase getDatabase() {
return Cache.openDatabase();
}

/**
* Non-exclusive transactions allows BEGIN IMMEDIATE
* blocks, allowing better read concurrency.
*/
public static void beginTransaction() {
Cache.openDatabase().beginTransaction();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
Cache.openDatabase().beginTransaction();
} else {
Cache.openDatabase().beginTransactionNonExclusive();
}
}

public static void endTransaction() {
Expand Down
20 changes: 20 additions & 0 deletions src/com/activeandroid/DatabaseHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import com.activeandroid.util.NaturalOrderComparator;
import com.activeandroid.util.SQLiteUtils;
import com.activeandroid.util.SqlParser;
import android.os.Build;

public final class DatabaseHelper extends SQLiteOpenHelper {
//////////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -65,6 +66,25 @@ public DatabaseHelper(Configuration configuration) {
// OVERRIDEN METHODS
//////////////////////////////////////////////////////////////////////////////////////

/**
* onConfigure is called when the db connection
* is being configured. It's the right place
* to enable write-ahead logging or foreign
* key support.
*
* Available for API level 16 (JellyBean) and above.
*/
@Override
public void onConfigure(SQLiteDatabase db) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
db.enableWriteAheadLogging();
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
db.setForeignKeyConstraintsEnabled(true);
}
executePragmas(db);
}

@Override
public void onOpen(SQLiteDatabase db) {
executePragmas(db);
Expand Down
18 changes: 0 additions & 18 deletions wait_for_emulator

This file was deleted.