Skip to content
This repository has been archived by the owner on Apr 15, 2021. It is now read-only.

Commit

Permalink
Merge pull request #271 from aliascash/develop_android
Browse files Browse the repository at this point in the history
Develop android
  • Loading branch information
HLXEasy authored Dec 22, 2020
2 parents 01bd21d + fa3b157 commit ecdbe1d
Show file tree
Hide file tree
Showing 24 changed files with 603 additions and 78 deletions.
8 changes: 3 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,11 @@ Checksum-Aliaswallet-*
# Mac
*.dmg
.qmake.stash

src/android/.gradle/

src/android/gradle/wrapper/

src/android/local.properties

src/android/gradlew.bat

src/android/gradlew

# CI-Build
AliasWalletAndroidKeyStore.jks
4 changes: 4 additions & 0 deletions .reuse/dep5
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ Files: src/qt/res/assets/plugins/pnglib/*
Copyright: 2010 Robert Eisele
License: BSD-2-Clause

Files: src/android/java/org/qtproject/qt5/android/bindings/Qt*.java
Copyright: 2016, BogDan Vatra <[email protected]>
License: BSD-2-Clause

# ############################################################################
# GPL-3.0-or-later Licenses
Files: external/berkeleydb-cmake/patches/config.guess external/berkeleydb-cmake/patches/config.sub
Expand Down
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ project(Alias
C
)

# ANDROID_VERSION_CODE must be increased with every PlayStore release!
set(ANDROID_VERSION_CODE 14)
set(ANDROID_SDK_VERSION 29)

# Alias version definition
set(CLIENT_VERSION_MAJOR 4)
set(CLIENT_VERSION_MINOR 3)
set(CLIENT_VERSION_REVISION 1)
set(CLIENT_VERSION_BUILD 0)

# ANDROID_VERSION_CODE must be increased with every PlayStore release!
set(ANDROID_VERSION_CODE 13)
if (ANDROID)
set(CLIENT_VERSION_BUILD ${ANDROID_VERSION_CODE})
else()
set(CLIENT_VERSION_BUILD 0)
endif()

set(CLIENT_VERSION_GIT_SHA1 "---")
set(VERSION_STRING "${CLIENT_VERSION_MAJOR}.${CLIENT_VERSION_MINOR}.${CLIENT_VERSION_REVISION}.${CLIENT_VERSION_BUILD}")
Expand Down
2 changes: 1 addition & 1 deletion Docker/Android/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: MIT

### At first perform source build ###
FROM aliascash/alias-wallet-builder-android:latest as build
FROM aliascash/alias-wallet-builder-android:platform29 as build
MAINTAINER HLXEasy <[email protected]>

# Build parameters
Expand Down
2 changes: 1 addition & 1 deletion Docker/Android/Dockerfile_noUpload
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# SPDX-License-Identifier: MIT

### At first perform source build ###
FROM aliascash/alias-wallet-builder-android:latest
FROM aliascash/alias-wallet-builder-android:platform29
MAINTAINER HLXEasy <[email protected]>

# Build parameters
Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile_Android
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ pipeline {
}
stage('Featurebranch') {
when {
branch 'android'
branch "android_*"
}
agent {
label "docker"
Expand Down
27 changes: 5 additions & 22 deletions LICENSES/BSD-2-Clause.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
LZ4 Library
Copyright (c) 2011-2014, Yann Collet
All rights reserved.
Copyright (c) <year> <owner>. All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
6 changes: 5 additions & 1 deletion ReleaseNotes_Android.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,11 @@ SPDX-License-Identifier: MIT
This releasenotes document covers only the Android relevant changes. For full
releasenotes please head over to [the latest release on Github](https://github.com/aliascash/alias-wallet/releases/latest).

#### 4.3.1 Android (released 2020-12-10)
#### 4.3.1.14 Android (released 2020-12-22)
- Support biometric (fingerprint) unlock
- Power saving mode with hourly sync when app is not staking

#### 4.3.1.12 Android (released 2020-12-10)
- Update to QT 5.15.2
- For leaving the app, back must be pressed twice
- Fix unintended 'back to camera app' by explicitly go to home
Expand Down
15 changes: 10 additions & 5 deletions scripts/android-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
# SPDX-License-Identifier: MIT

ownLocation="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
cd "${ownLocation}" || exit 1
. ./include/helpers_console.sh
_init
. ./include/handle_buildconfig.sh

cd "$ownLocation"/../cmake-build-cmdline-android-apk/ || exit 1

Expand All @@ -15,10 +19,11 @@ fi
/root/Qt/5.15.2/android/bin/androiddeployqt \
--input $(pwd)/android_deployment_settings.json \
--output $(pwd)/android-build \
--android-platform android-29 \
--android-platform android-${ANDROID_SDK_VERSION} \
--gradle \
--aab \
--jarsigner \
--sign /etc/ssl/certs/alias-sign-keystore.jks upload \
--storepass "${KEYSTORE_PASS}" \
| tee ../Android-Build-$(date +%Y-%m-%d_%H%M%S).log
--jarsigner \
--sign /etc/ssl/certs/alias-sign-keystore.jks upload \
--storepass "${KEYSTORE_PASS}" \
| tee ../Android-Build-$(date +%Y-%m-%d_%H%M%S).log ; \
exit "${PIPESTATUS[0]}"
1 change: 1 addition & 0 deletions scripts/include/handle_buildconfig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ ARCHIVES_ROOT_DIR=${HOME}/Archives
##### ### # Android # ### ###################################################
ANDROID_NDK_VERSION=r21d
ANDROID_SDK_VERSION=29
ANDROID_SDK_ROOT=${HOME}/Archives/Android/Sdk
##### ### # Boost # ### #####################################################
Expand Down
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,8 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
message(STATUS "No daemon build on Mac")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
message(STATUS "No daemon build on Windows")
elseif(ANDROID)
message(STATUS "No daemon build for Android")
else()
# The daemon
add_executable(Aliaswalletd ${CMAKE_CURRENT_LIST_DIR}/spectrecoind.cpp)
Expand Down
4 changes: 3 additions & 1 deletion src/android/AndroidManifest.in.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<!-- SPDX-FileCopyrightText: © 2020 Alias Developers -->
<!-- SPDX-License-Identifier: MIT -->
<manifest package="org.alias.wallet" xmlns:android="http://schemas.android.com/apk/res/android" android:versionName="@CLIENT_VERSION_MAJOR@.@CLIENT_VERSION_MINOR@.@CLIENT_VERSION_REVISION@.@ANDROID_VERSION_CODE@" android:versionCode="@ANDROID_VERSION_CODE@" android:installLocation="auto">
<uses-sdk android:targetSdkVersion="29"/>
<uses-sdk android:targetSdkVersion="@ANDROID_SDK_VERSION@"/>

<!-- The following comment will be replaced upon deployment with default features based on the dependencies of the application.
Remove the comment if you do not require these default features. -->
Expand Down Expand Up @@ -76,6 +76,8 @@
<meta-data android:name="android.app.extract_android_style" android:value="default"/>
<!-- extract android style -->
</activity>
<activity android:configChanges="orientation|uiMode|screenLayout|screenSize|smallestScreenSize|layoutDirection|locale|fontScale|keyboard|keyboardHidden|navigation|mcc|mnc|density" android:name="org.alias.wallet.BiometricActivity" android:label="-- %%INSERT_APP_NAME%% --" android:launchMode="standard" android:finishOnTaskLaunch="true" android:theme="@style/BiometricTheme">
</activity>
<!-- For adding service(s) please check: https://wiki.qt.io/AndroidServices -->
<service android:name=".AliasService" android:process=":AliasService" android:exported="false" android:foregroundServiceType="dataSync">
<!-- android:process=":qt" is needed to force the service to run on a separate process than the Activity -->
Expand Down
5 changes: 4 additions & 1 deletion src/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ apply plugin: 'com.android.application'

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'androidx.core:core:1.3.2'
implementation 'com.google.android.gms:play-services-cronet:17.0.0'
implementation 'org.chromium.net:cronet-fallback:76.3809.111'
implementation 'net.lingala.zip4j:zip4j:2.6.4'
implementation 'androidx.core:core:1.3.2'
implementation "androidx.biometric:biometric:1.0.1"
implementation "androidx.appcompat:appcompat:1.2.0"
implementation "androidx.appcompat:appcompat-resources:1.2.0"
}

android {
Expand Down
73 changes: 70 additions & 3 deletions src/android/java/org/alias/wallet/AliasActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import android.webkit.WebView;
import android.widget.Toast;

import java.util.Timer;
import java.util.TimerTask;
import org.qtproject.qt5.android.bindings.QtActivity;

public class AliasActivity extends org.qtproject.qt5.android.bindings.QtActivity {

public class AliasActivity extends QtActivity {

private static final String TAG = "AliasActivity";

Expand All @@ -35,9 +35,13 @@ public class AliasActivity extends org.qtproject.qt5.android.bindings.QtActivity

// native method to handle 'alias:' URIs
public static native void receiveURI(String url);

// native method to handle boostrap service events
public static native void updateBootstrapState(int state, int errorCode, int progress, int indexOfItem, int numOfItems, boolean indeterminate);

// native method to pass via biometric protected walletPassword
public static native void serveWalletPassword(String walletPassword);

private volatile boolean qtInitialized = false; // will be accessed from android UI and Qt thread
private boolean hasPendingIntent = false; // accessed only from android UI thread

Expand All @@ -46,6 +50,20 @@ public class AliasActivity extends org.qtproject.qt5.android.bindings.QtActivity
private long backPressedTime;
private Toast backToast;

private volatile ActivityResult lastActivityResult;

private class ActivityResult {
public ActivityResult(int requestCode, int resultCode, Intent data) {
this.requestCode = requestCode;
this.resultCode = resultCode;
this.data = data;
}
public int requestCode;
public int resultCode;
public Intent data;
}


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -69,6 +87,7 @@ public void onCreate(Bundle savedInstanceState) {
@Override
protected void onDestroy() {
super.onDestroy();
lastActivityResult = null;
unregisterReceiver(mBoostrapBroadcastReceiver);
}

Expand All @@ -94,6 +113,10 @@ protected void onResume() {
setRequestedOrientation(screenOrientation);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LOCKED);
}
if (lastActivityResult != null) {
handleOnActivityResult(lastActivityResult.requestCode, lastActivityResult.resultCode, lastActivityResult.data);
lastActivityResult = null;
}
}

@Override
Expand All @@ -106,6 +129,33 @@ protected void onNewIntent(Intent intent) {
}
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult() requestCode= " +requestCode);
lastActivityResult = new ActivityResult(requestCode, resultCode, data);
}

private void handleOnActivityResult(int requestCode, int resultCode, Intent data) {
Log.d(TAG, "handleOnActivityResult() requestCode=" + requestCode);
if (requestCode == BiometricActivity.BiometricAction.ACTION_SETUP.ordinal()) {
if (resultCode == RESULT_OK) {
Toast.makeText(this, "Biometric setup successful!", Toast.LENGTH_SHORT).show();
}
else if (resultCode == BiometricActivity.RESULT_ERROR) {
Toast.makeText(this, "Biometric setup failed: " + data.getStringExtra("error"), Toast.LENGTH_LONG).show();
}
}
else if (requestCode == BiometricActivity.BiometricAction.ACTION_UNLOCK.ordinal()) {
if (resultCode == RESULT_OK) {
serveWalletPassword(data.getStringExtra("walletPassword"));
}
else if (resultCode == BiometricActivity.RESULT_ERROR) {
Toast.makeText(this, "Biometric unlock failed: " + data.getStringExtra("error"), Toast.LENGTH_LONG).show();
}
}
}

public void onBackPressedQt() {
runOnUiThread(() -> {
if (backPressedTime + 2000 > System.currentTimeMillis()) {
Expand Down Expand Up @@ -253,4 +303,21 @@ public void onReceive(Context context, Intent intent) {
updateBootstrapState(state, errorCode, progress, indexOfItem, numOfItems, indeterminate);
}
}


// ---------------------------------------------------------------------------------------------
//
// Biometric Unlock Support
//
public boolean setupBiometricUnlock(String walletPassword) {
return BiometricActivity.setupBiometricUnlock(this, walletPassword);
}

public boolean startBiometricUnlock() {
return BiometricActivity.startBiometricUnlock(this);
}

public void clearBiometricUnlock() {
BiometricActivity.clearBiometricUnlock(this);
}
}
3 changes: 3 additions & 0 deletions src/android/java/org/alias/wallet/AliasService.java
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ public void updateNotification(String title, String text, int type) {
if (ServiceNotificationType.STAKING.ordinal() == type) {
notificationBuilder.setLargeIcon(Icon.createWithResource(this, R.drawable.ic_staking));
}
else if (ServiceNotificationType.SLEEP.ordinal() == type) {
notificationBuilder.setLargeIcon(Icon.createWithResource(this, R.drawable.ic_battery_on));
}
else if (ServiceNotificationType.REWINDCHAIN.ordinal() == type) {
notificationBuilder.setProgress(0, 0, true);
}
Expand Down
Loading

0 comments on commit ecdbe1d

Please sign in to comment.