refactor: start building an Android package (#205)

* refactor: start building an Android package

Part of https://github.com/ooni/probe/issues/1335.

This seems also a good moment to move some packages out of the
engine, e.g., oonimkall. This package, for example, is a consumer
of the engine, so it makes sense it's not _inside_ it.

* fix: committed some stuff I didn't need to commit

* fix: oonimkall needs to be public to build

The side effect is that we will probably need to bump the major
version number every time we change one of these APIs.

(We can also of course choose to violate the basic guidelines of Go
software, but I believe this is bad form.)

I have no problem in bumping the major quite frequently and in
any case this monorepo solution is convinving me more than continuing
to keep a split between engine and cli. The need to embed assets to
make the probe more reliable trumps the negative effects of having to
~frequently bump major because we expose a public API.

* fix: let's not forget about libooniffi

Honestly, I don't know what to do with this library. I added it
to provide a drop in replacement for MK but I have no idea whether
it's used and useful. I would not feel comfortable exposing it,
unlike oonimkall, since we're not using it.

It may be that the right thing to do here is just to delete the
package and reduce the amount of code we're maintaining?

* woops, we're still missing the publish android script

* fix(publish-android.bash): add proper API key

* ouch fix another place where the name changed
This commit is contained in:
Simone Basso 2021-02-03 10:51:14 +01:00 committed by GitHub
parent 6714b79f97
commit 99b28c1d95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
61 changed files with 40 additions and 39 deletions

View File

@ -20,4 +20,4 @@ jobs:
ANDROID_HOME: /usr/local/Caskroom/android-sdk/4333796 ANDROID_HOME: /usr/local/Caskroom/android-sdk/4333796
- run: ./publish-android.bash - run: ./publish-android.bash
env: env:
BINTRAY_API_KEY: ${{ secrets.BINTRAY_API_KEY }} MOBILE_BINTRAY_API_KEY: ${{ secrets.MOBILE_BINTRAY_API_KEY }}

2
MOBILE/android/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/oonimkall-sources.jar
/oonimkall.aar

View File

@ -52,4 +52,4 @@ go get -u golang.org/x/mobile/cmd/gomobile
gomobile init gomobile init
export GO111MODULE=on export GO111MODULE=on
output=MOBILE/android/oonimkall.aar output=MOBILE/android/oonimkall.aar
gomobile bind -target=android -o $output -ldflags="-s -w" ./oonimkall gomobile bind -target=android -o $output -ldflags="-s -w" ./pkg/oonimkall

View File

@ -1 +0,0 @@

View File

@ -4,7 +4,7 @@
package iptables package iptables
import ( import (
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
) )
type shell interface { type shell interface {

View File

@ -4,7 +4,7 @@ package iptables
import ( import (
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/shellx" "github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/shellx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
) )
type linuxShell struct{} type linuxShell struct{}

View File

@ -26,7 +26,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/shellx" "github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/shellx"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/tlsproxy" "github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/tlsproxy"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/uncensored" "github.com/ooni/probe-cli/v3/internal/engine/cmd/jafar/uncensored"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
) )
var ( var (

View File

@ -9,7 +9,7 @@ import (
"github.com/apex/log" "github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter" "github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/netx" "github.com/ooni/probe-cli/v3/internal/engine/netx"
) )

View File

@ -14,7 +14,7 @@ import (
"github.com/apex/log" "github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity" "github.com/ooni/probe-cli/v3/internal/engine/experiment/webconnectivity"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader" "github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/netx" "github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/engine/version" "github.com/ooni/probe-cli/v3/internal/engine/version"
) )

View File

@ -11,7 +11,7 @@ import (
"github.com/apex/log" "github.com/apex/log"
"github.com/ooni/probe-cli/v3/internal/engine/cmd/oohelper/internal" "github.com/ooni/probe-cli/v3/internal/engine/cmd/oohelper/internal"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/netx" "github.com/ooni/probe-cli/v3/internal/engine/netx"
) )

View File

@ -15,7 +15,7 @@ import (
"time" "time"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter" "github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/model" "github.com/ooni/probe-cli/v3/internal/engine/model"
"github.com/ooni/probe-cli/v3/internal/engine/netx" "github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival" "github.com/ooni/probe-cli/v3/internal/engine/netx/archival"

View File

@ -16,7 +16,7 @@ import (
"time" "time"
"github.com/ooni/probe-cli/v3/internal/engine/experiment/tlstool/internal" "github.com/ooni/probe-cli/v3/internal/engine/experiment/tlstool/internal"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/model" "github.com/ooni/probe-cli/v3/internal/engine/model"
"github.com/ooni/probe-cli/v3/internal/engine/netx" "github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/archival" "github.com/ooni/probe-cli/v3/internal/engine/netx/archival"

View File

@ -14,7 +14,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/atomicx" "github.com/ooni/probe-cli/v3/internal/engine/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader" "github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netxlogger" "github.com/ooni/probe-cli/v3/internal/engine/legacy/netxlogger"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/oonidatamodel" "github.com/ooni/probe-cli/v3/internal/engine/legacy/oonidatamodel"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/oonitemplates" "github.com/ooni/probe-cli/v3/internal/engine/legacy/oonitemplates"

View File

@ -11,7 +11,7 @@ import (
"net/url" "net/url"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader" "github.com/ooni/probe-cli/v3/internal/engine/internal/httpheader"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/netx" "github.com/ooni/probe-cli/v3/internal/engine/netx"
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx" "github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
) )

View File

@ -4,7 +4,7 @@ import (
"net" "net"
"net/url" "net/url"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
) )
// EndpointInfo describes a TCP/TLS endpoint. // EndpointInfo describes a TCP/TLS endpoint.

View File

@ -14,7 +14,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter" "github.com/ooni/probe-cli/v3/internal/engine/experiment/urlgetter"
"github.com/ooni/probe-cli/v3/internal/engine/internal/httpfailure" "github.com/ooni/probe-cli/v3/internal/engine/internal/httpfailure"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/model" "github.com/ooni/probe-cli/v3/internal/engine/model"
) )

View File

@ -7,7 +7,7 @@ import (
"fmt" "fmt"
"net/http" "net/http"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/model" "github.com/ooni/probe-cli/v3/internal/engine/model"
"github.com/ooni/probe-cli/v3/internal/engine/version" "github.com/ooni/probe-cli/v3/internal/engine/version"
) )

View File

@ -8,7 +8,7 @@ import (
"github.com/ooni/probe-cli/v3/internal/engine/internal/kvstore" "github.com/ooni/probe-cli/v3/internal/engine/internal/kvstore"
"github.com/ooni/probe-cli/v3/internal/engine/internal/psiphonx" "github.com/ooni/probe-cli/v3/internal/engine/internal/psiphonx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/internal/torx" "github.com/ooni/probe-cli/v3/internal/engine/internal/torx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/tunnel" "github.com/ooni/probe-cli/v3/internal/engine/internal/tunnel"
"github.com/ooni/probe-cli/v3/internal/engine/model" "github.com/ooni/probe-cli/v3/internal/engine/model"

View File

@ -9,7 +9,7 @@ import (
"time" "time"
"github.com/ooni/probe-cli/v3/internal/engine/atomicx" "github.com/ooni/probe-cli/v3/internal/engine/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/netx" "github.com/ooni/probe-cli/v3/internal/engine/netx"
) )

View File

@ -6,7 +6,7 @@ import (
"fmt" "fmt"
"sync" "sync"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx" "github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx"
) )

View File

@ -21,7 +21,7 @@ import (
goptlib "git.torproject.org/pluggable-transports/goptlib.git" goptlib "git.torproject.org/pluggable-transports/goptlib.git"
"github.com/ooni/probe-cli/v3/internal/engine/atomicx" "github.com/ooni/probe-cli/v3/internal/engine/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx" "github.com/ooni/probe-cli/v3/internal/engine/legacy/netx"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/handlers" "github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/handlers"
"github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx" "github.com/ooni/probe-cli/v3/internal/engine/legacy/netx/modelx"

View File

@ -31,7 +31,7 @@ import (
"net/url" "net/url"
"github.com/lucas-clemente/quic-go" "github.com/lucas-clemente/quic-go"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/netx/bytecounter" "github.com/ooni/probe-cli/v3/internal/engine/netx/bytecounter"
"github.com/ooni/probe-cli/v3/internal/engine/netx/dialer" "github.com/ooni/probe-cli/v3/internal/engine/netx/dialer"
"github.com/ooni/probe-cli/v3/internal/engine/netx/gocertifi" "github.com/ooni/probe-cli/v3/internal/engine/netx/gocertifi"

View File

@ -4,7 +4,7 @@ import (
"context" "context"
"net" "net"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/netx/errorx" "github.com/ooni/probe-cli/v3/internal/engine/netx/errorx"
) )

View File

@ -4,7 +4,7 @@ import (
"errors" "errors"
"testing" "testing"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
) )
func TestGood(t *testing.T) { func TestGood(t *testing.T) {

View File

@ -17,7 +17,7 @@ import (
"sync" "sync"
"unsafe" "unsafe"
"github.com/ooni/probe-cli/v3/internal/engine/oonimkall" "github.com/ooni/probe-cli/v3/pkg/oonimkall"
) )
var ( var (

View File

@ -1,4 +1,4 @@
# Package github.com/ooni/probe-engine/oonimkall # Package github.com/ooni/probe-cli/pkg/oonimkall
Package oonimkall implements APIs used by OONI mobile apps. We Package oonimkall implements APIs used by OONI mobile apps. We
expose these APIs to mobile apps using gomobile. expose these APIs to mobile apps using gomobile.

View File

@ -10,7 +10,7 @@ import (
engine "github.com/ooni/probe-cli/v3/internal/engine" engine "github.com/ooni/probe-cli/v3/internal/engine"
"github.com/ooni/probe-cli/v3/internal/engine/atomicx" "github.com/ooni/probe-cli/v3/internal/engine/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/model" "github.com/ooni/probe-cli/v3/internal/engine/model"
"github.com/ooni/probe-cli/v3/internal/engine/probeservices" "github.com/ooni/probe-cli/v3/internal/engine/probeservices"
) )

View File

@ -15,7 +15,7 @@ import (
engine "github.com/ooni/probe-cli/v3/internal/engine" engine "github.com/ooni/probe-cli/v3/internal/engine"
"github.com/ooni/probe-cli/v3/internal/engine/geolocate" "github.com/ooni/probe-cli/v3/internal/engine/geolocate"
"github.com/ooni/probe-cli/v3/internal/engine/model" "github.com/ooni/probe-cli/v3/internal/engine/model"
"github.com/ooni/probe-cli/v3/internal/engine/oonimkall" "github.com/ooni/probe-cli/v3/pkg/oonimkall"
) )
func NewSessionWithAssetsDir(assetsDir string) (*oonimkall.Session, error) { func NewSessionWithAssetsDir(assetsDir string) (*oonimkall.Session, error) {

View File

@ -44,8 +44,8 @@ import (
"encoding/json" "encoding/json"
"github.com/ooni/probe-cli/v3/internal/engine/atomicx" "github.com/ooni/probe-cli/v3/internal/engine/atomicx"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/oonimkall/tasks" "github.com/ooni/probe-cli/v3/pkg/oonimkall/tasks"
) )
// Task is an asynchronous task running an experiment. It mimics the // Task is an asynchronous task running an experiment. It mimics the

View File

@ -9,8 +9,8 @@ import (
"github.com/google/go-cmp/cmp" "github.com/google/go-cmp/cmp"
"github.com/ooni/probe-cli/v3/internal/engine/model" "github.com/ooni/probe-cli/v3/internal/engine/model"
"github.com/ooni/probe-cli/v3/internal/engine/oonimkall" "github.com/ooni/probe-cli/v3/pkg/oonimkall"
"github.com/ooni/probe-cli/v3/internal/engine/oonimkall/tasks" "github.com/ooni/probe-cli/v3/pkg/oonimkall/tasks"
) )
type eventlike struct { type eventlike struct {

View File

@ -3,7 +3,7 @@ package tasks_test
import ( import (
"testing" "testing"
"github.com/ooni/probe-cli/v3/internal/engine/oonimkall/tasks" "github.com/ooni/probe-cli/v3/pkg/oonimkall/tasks"
) )
func TestDisabledEvents(t *testing.T) { func TestDisabledEvents(t *testing.T) {

View File

@ -8,7 +8,7 @@ import (
"time" "time"
engine "github.com/ooni/probe-cli/v3/internal/engine" engine "github.com/ooni/probe-cli/v3/internal/engine"
"github.com/ooni/probe-cli/v3/internal/engine/internal/runtimex" "github.com/ooni/probe-cli/v3/internal/engine/runtimex"
"github.com/ooni/probe-cli/v3/internal/engine/model" "github.com/ooni/probe-cli/v3/internal/engine/model"
) )

View File

@ -9,7 +9,7 @@ import (
"testing" "testing"
"time" "time"
"github.com/ooni/probe-cli/v3/internal/engine/oonimkall/tasks" "github.com/ooni/probe-cli/v3/pkg/oonimkall/tasks"
) )
func TestRunnerMaybeLookupBackendsFailure(t *testing.T) { func TestRunnerMaybeLookupBackendsFailure(t *testing.T) {

View File

@ -3,7 +3,7 @@ package oonimkall_test
import ( import (
"testing" "testing"
"github.com/ooni/probe-cli/v3/internal/engine/oonimkall" "github.com/ooni/probe-cli/v3/pkg/oonimkall"
) )
func TestNewUUID4(t *testing.T) { func TestNewUUID4(t *testing.T) {

View File

@ -13,16 +13,16 @@ pomfile=./MOBILE/android/$pkgname-$version.pom
pomtemplate=./MOBILE/template.pom pomtemplate=./MOBILE/template.pom
user=bassosimone user=bassosimone
cat $pomtemplate|sed "s/@VERSION@/$version/g" > $pomfile cat $pomtemplate|sed "s/@VERSION@/$version/g" > $pomfile
if [ -z $BINTRAY_API_KEY ]; then if [ -z $MOBILE_BINTRAY_API_KEY ]; then
echo "FATAL: missing BINTRAY_API_KEY variable" 1>&2 echo "FATAL: missing MOBILE_BINTRAY_API_KEY variable" 1>&2
exit 1 exit 1
fi fi
# We currently publish the mobile-staging branch. To cleanup we can fetch all the versions using # We currently publish the mobile-staging branch. To cleanup we can fetch all the versions using
# the <curl -s $user:$BINTRAY_API_KEY https://api.bintray.com/packages/ooni/android/oonimkall> # the <curl -s $user:$MOBILE_BINTRAY_API_KEY https://api.bintray.com/packages/ooni/android/oonimkall>
# query, which returns a list of versions. From such list, we can delete the versions we # query, which returns a list of versions. From such list, we can delete the versions we
# don't need using <DELETE /packages/:subject/:repo/:package/versions/:version>. # don't need using <DELETE /packages/:subject/:repo/:package/versions/:version>.
for filename in $aarfile_version $sourcesfile_version $pomfile; do for filename in $aarfile_version $sourcesfile_version $pomfile; do
basefilename=$(basename $filename) basefilename=$(basename $filename)
curl -sT $filename -u $user:$BINTRAY_API_KEY $baseurl/$basefilename?publish=1 >/dev/null curl -sT $filename -u $user:$MOBILE_BINTRAY_API_KEY $baseurl/$basefilename?publish=1 >/dev/null
done done
echo "implementation 'org.ooni:oonimkall:$version'" echo "implementation 'org.ooni:oonimkall:$version'"