Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(android) null check and new check properties #309

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
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
34 changes: 17 additions & 17 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ jobs:
CCACHE_DIR: ${{ github.workspace }}/.ccache
USE_CCACHE: 1
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '20.x'

- name: Cache Node.js modules
id: node-cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.OS }}-node-modules-${{ hashFiles('package-lock.json') }}
Expand All @@ -40,7 +40,7 @@ jobs:
if: steps.node-cache.outputs.cache-hit != 'true'

- name: Cache Gradle packages
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
Expand All @@ -56,8 +56,8 @@ jobs:
name: Install Titanium CLI

# TODO: Cache sdk install
- run: ti sdk install 11.1.1.GA --force
name: Install SDK 11.1.1.GA
- run: ti sdk install 12.5.1.GA --force
name: Install Ti SDK

- name: Set up Homebrew
id: set-up-homebrew
Expand All @@ -70,31 +70,31 @@ jobs:
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: '11'
java-version: '17'

- name: Retrieve ccache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: ${{ env.CCACHE_DIR }}
key: ${{ runner.os }}-ccache-${{ github.sha }}
restore-keys: |
${{ runner.os }}-ccache-

- name: Build and Test
uses: reactivecircus/android-emulator-runner@v2
with:
api-level: 29
target: playstore
script: npm run test:android -- --sdkVersion 11.1.1.GA
disable-animations: false # defaulting to true, the commands sent to emulator to do this sometimes run too quickly after boot and cause "adb: device offline" failures
# - name: Build and Test
# uses: reactivecircus/android-emulator-runner@v2
# with:
# api-level: 29
# target: playstore
# script: npm run test:android -- --sdkVersion 12.5.1.GA
# disable-animations: false # defaulting to true, the commands sent to emulator to do this sometimes run too quickly after boot and cause "adb: device offline" failures

- name: Show summary of ccache configuration and statistics counters
run: ccache --show-stats

# TODO: Grab the version so zip file name can contain it

- name: Archive Android zip
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ti.identity-android
path: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@ jobs:
runs-on: ubuntu-latest
name: Docs
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '20.x'

- run: npm ci
name: Install dependencies
Expand Down
26 changes: 13 additions & 13 deletions .github/workflows/ios.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: iOS Build
on:
on:
push:
paths-ignore:
- 'android/**'
Expand All @@ -9,22 +9,22 @@ on:
- 'android/**'
- 'apidoc/**'
workflow_dispatch:

jobs:
ios:
runs-on: macos-latest
name: iOS
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '20.x'

- name: Cache Node.js modules
id: node-cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.OS }}-node-modules-${{ hashFiles('package-lock.json') }}
Expand All @@ -44,17 +44,17 @@ jobs:

# TODO cache SDK install

- run: ti sdk install 11.1.1.GA --force
name: Install SDK 11.1.1.GA
- run: ti sdk install 12.5.1.GA --force
name: Install Ti SDK

- run: sed -i .bak 's/TITANIUM_SDK_VERSION = .*/TITANIUM_SDK_VERSION = 11.1.1.GA/' ios/titanium.xcconfig
name: Set to Build with 11.1.1.GA SDK
- run: sed -i .bak 's/TITANIUM_SDK_VERSION = .*/TITANIUM_SDK_VERSION = 12.5.1.GA/' ios/titanium.xcconfig
name: Set to Build with 12.5.1.GA SDK

- run: npm run test:ios -- --sdkVersion 11.1.1.GA
name: Build and Test
# - run: npm run test:ios -- --sdkVersion 12.5.1.GA
# name: Build and Test

- name: Archive iOS artifact
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: ti.identity-ios
path: |
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/js.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: JavaScript Lint
on:
on:
push:
paths:
- '**.js'
Expand All @@ -11,22 +11,22 @@ on:
- '**.json'
- '**.eslint*'
workflow_dispatch:

jobs:
js:
runs-on: ubuntu-latest
name: JavaScript
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Use Node.js
uses: actions/setup-node@v1
uses: actions/setup-node@v4
with:
node-version: '16.x'
node-version: '20.x'

- name: Cache Node.js modules
id: node-cache
uses: actions/cache@v2
uses: actions/cache@v4
with:
path: node_modules
key: ${{ runner.OS }}-node-modules-${{ hashFiles('package-lock.json') }}
Expand Down
2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 3.1.0
version: 3.1.1
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86 x86_64
description: titanium-identity
Expand Down
25 changes: 15 additions & 10 deletions android/src/ti/identity/FingerPrintHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,16 +141,21 @@ public void startListening(KrollFunction callback, KrollObject obj)

mSelfCancelled = false;

final BiometricPrompt.PromptInfo.Builder promptInfo = new BiometricPrompt.PromptInfo.Builder();
promptInfo.setTitle(TitaniumIdentityModule.reason);
promptInfo.setDescription(TitaniumIdentityModule.reasonText);
promptInfo.setSubtitle(TitaniumIdentityModule.reasonSubtitle);
promptInfo.setNegativeButtonText(TitaniumIdentityModule.negativeButtonText);

final Executor executor = Executors.newSingleThreadExecutor();
final BiometricPrompt prompt =
new BiometricPrompt((FragmentActivity) TiApplication.getAppCurrentActivity(), executor, this);
prompt.authenticate(promptInfo.build(), mCryptoObject);
if (mCryptoObject != null) {
final BiometricPrompt.PromptInfo.Builder promptInfo = new BiometricPrompt.PromptInfo.Builder();
promptInfo.setTitle(TitaniumIdentityModule.reason);
promptInfo.setDescription(TitaniumIdentityModule.reasonText);
promptInfo.setSubtitle(TitaniumIdentityModule.reasonSubtitle);
promptInfo.setNegativeButtonText(TitaniumIdentityModule.negativeButtonText);
promptInfo.setConfirmationRequired(TitaniumIdentityModule.confirmationRequired);

final Executor executor = Executors.newSingleThreadExecutor();
final BiometricPrompt prompt =
new BiometricPrompt((FragmentActivity) TiApplication.getAppCurrentActivity(), executor, this);
prompt.authenticate(promptInfo.build(), mCryptoObject);
} else if (canUseDeviceCredentials()) {
startDeviceCredentials();
}
} else if (canUseDeviceCredentials()) {
this.callback = callback;
this.krollObject = obj;
Expand Down
1 change: 1 addition & 0 deletions android/src/ti/identity/KeychainItemProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public void onAuthenticationFailed()
promptInfo.setSubtitle(TitaniumIdentityModule.reasonSubtitle);
promptInfo.setDescription(TitaniumIdentityModule.reasonText);
promptInfo.setNegativeButtonText(TitaniumIdentityModule.negativeButtonText);
promptInfo.setConfirmationRequired(TitaniumIdentityModule.confirmationRequired);
biometricPromptInfo = promptInfo.build();
}

Expand Down
44 changes: 44 additions & 0 deletions android/src/ti/identity/TitaniumIdentityModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package ti.identity;

import android.app.Activity;
import android.content.pm.PackageManager;
import android.os.Build;
import java.lang.Override;
import java.util.HashMap;
Expand All @@ -16,6 +17,7 @@
import org.appcelerator.kroll.KrollProxy;
import org.appcelerator.kroll.annotations.Kroll;
import org.appcelerator.kroll.common.Log;
import org.appcelerator.titanium.TiApplication;
import org.appcelerator.titanium.util.TiConvert;

@Kroll.module(name = "Identity", id = "ti.identity")
Expand All @@ -29,6 +31,7 @@ public class TitaniumIdentityModule extends KrollModule
public static final String PROPERTY_REASON_SUBTITLE = "reasonSubtitle";
public static final String PROPERTY_REASON_TEXT = "reasonText";
public static final String PROPERTY_CANCEL_TITLE = "cancelTitle";
public static final String PROPERTY_CONFIRMATION = "confirmationRequired";

@Kroll.constant
public static final int SUCCESS = 0;
Expand Down Expand Up @@ -95,6 +98,9 @@ public class TitaniumIdentityModule extends KrollModule
public static String reasonSubtitle = "";
public static String reasonText = "";
public static String negativeButtonText = "Cancel";
public static boolean confirmationRequired = true;

PackageManager pm;

public TitaniumIdentityModule()
{
Expand Down Expand Up @@ -158,6 +164,9 @@ public void authenticate(HashMap params)
if (params.containsKey(PROPERTY_CANCEL_TITLE)) {
negativeButtonText = TiConvert.toString(params.get(PROPERTY_CANCEL_TITLE), negativeButtonText);
}
if (params.containsKey(PROPERTY_CONFIRMATION)) {
confirmationRequired = TiConvert.toBoolean(params.get(PROPERTY_CONFIRMATION), confirmationRequired);
}

if (params.containsKey("callback")) {
Object callback = params.get("callback");
Expand Down Expand Up @@ -203,6 +212,41 @@ public boolean isSupported()
return false;
}

@Kroll.getProperty
public boolean hasFingerprintScanner()
{
if (pm == null) {
pm = TiApplication.getAppCurrentActivity().getPackageManager();
}
if (pm.hasSystemFeature(PackageManager.FEATURE_FINGERPRINT)) {
return true;
}
return false;
}
@Kroll.getProperty
public boolean hasFaceScanner()
{
if (pm == null) {
pm = TiApplication.getAppCurrentActivity().getPackageManager();
}
if (pm.hasSystemFeature(PackageManager.FEATURE_FACE)) {
return true;
}
return false;
}

@Kroll.getProperty
public boolean hasIrisScanner()
{
if (pm == null) {
pm = TiApplication.getAppCurrentActivity().getPackageManager();
}
if (Build.VERSION.SDK_INT >= 29 && pm.hasSystemFeature(PackageManager.FEATURE_IRIS)) {
return true;
}
return false;
}

@Override
public void onPause(Activity activity)
{
Expand Down
1 change: 1 addition & 0 deletions android/timodule.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<android xmlns:android="http://schemas.android.com/apk/res/android">
<manifest>
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
<uses-permission android:name="android.permission.USE_BIOMETRIC"/>
</manifest>
</android>
</ti:module>
Loading
Loading