Skip to content

Commit

Permalink
release 1.0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins committed Sep 5, 2024
1 parent da60835 commit 4696d59
Show file tree
Hide file tree
Showing 67 changed files with 2,841 additions and 0 deletions.
3 changes: 3 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Licensed under the Zscaler End User Subscription Agreement available at https://www.zscaler.com/legal or as otherwise indicated on a written order form, purchase order, or similar ordering document for Zscaler SaaS, Software, Hardware, Deployment Services, and Support Services, including all Upgrades.

Copyright 2024 Zscaler Inc. All rights reserved.
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# Zscaler Android SDK

Zscaler Development Kit (Zscaler SDK), part of the Zscaler Zero Trust Exchange™ platform, combines a set of robust capabilities to protect the integrity of your intellectual property, secure network communications from your mobile application, and prevent breaches against your APIs and core backend services.


## Integration
1. Add the Github repository to the dependencyResolutionManagement repositories in settings.gradle.
```
dependencyResolutionManagement {
repositories {
maven {
name = "ZscalerSDKAndroid"
url = uri("https://maven.pkg.github.com/zscaler/zscaler-sdk-android")
}
}
}
```

2. Install Zscaler SDK in the dependencies section of build.gradle.
```
dependencies {
implementation("com.zscaler.sdk:zscalersdk-android:latest.release")
}
```

181 changes: 181 additions & 0 deletions sample-app/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
import com.android.build.gradle.internal.tasks.MergeNativeLibsTask
import com.google.firebase.crashlytics.buildtools.gradle.CrashlyticsExtension
import com.github.triplet.gradle.androidpublisher.ReleaseStatus
import com.github.triplet.gradle.androidpublisher.ResolutionStrategy
import com.google.firebase.crashlytics.buildtools.gradle.tasks.GenerateSymbolFileTask

plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
id("maven-publish")
id("com.github.triplet.play") version "3.9.1"
id("com.google.gms.google-services")
id("com.google.firebase.crashlytics")
}

var versionNameVal = "x.x-dev"
var versionCodeVal = 1

if (project.hasProperty("buildVersionName")) {
versionNameVal = project.ext.get("buildVersionName").toString()
rootProject.version = versionNameVal
// calculate version code from version name
val parts = versionNameVal.split("-")[0].split(".") // handles SNAPSHOT also
val versionCodeInt = parts[0].toInt() * 10000 + parts[1].toInt() * 100 + (parts.getOrNull(2)?.toInt() ?: 0) // handles 0...99 for each major,minor,patch/build
if (versionCodeInt > versionCodeVal) {
versionCodeVal = versionCodeInt
}
println("versionNameVal " + versionNameVal)
println("versionCodeVal " + versionCodeVal)
}

android {
namespace = "com.zscaler.sdk.demoapp"
compileSdk = 34

defaultConfig {
applicationId = "com.zscaler.sdk.android.testapp"
minSdk = 26
targetSdk = 34
versionCode = versionCodeVal
versionName = versionNameVal

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}

signingConfigs {
register("release") {
if (System.getenv("KEYSTORE_FILENAME") != null && file(System.getenv("KEYSTORE_FILENAME")).exists()) {
storeFile = file(System.getenv("KEYSTORE_FILENAME"))
storePassword = System.getenv("KEYSTORE_PASSWORD")
keyAlias = "key0" //System.getenv("KEY_ALIAS")
keyPassword = System.getenv("KEYSTORE_PASSWORD") // System.getenv("KEY_PASSWORD")
// Enable Signing Versions
enableV1Signing = true
enableV2Signing = true
enableV3Signing = true
enableV4Signing = true
}
}
}

buildTypes {
getByName("release") {
isDebuggable = false
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
signingConfig = signingConfigs.getByName("release")
// Add this extension
configure<CrashlyticsExtension> {
nativeSymbolUploadEnabled = true
unstrippedNativeLibsDir = file("../../../zdklibrary/app/build/intermediates/merged_native_libs/")
}
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = "1.8"
}
buildFeatures {
viewBinding = true
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
}
ndkVersion = "25.2.9519653"
buildToolsVersion = "34.0.0"

publishing {
singleVariant("release") {
publishApk()
}
}

if (System.getenv("API_PRIVATE_KEY_FILENAME") != null) {
play {
val keyfile: String =
System.getenv("API_PRIVATE_KEY_FILENAME") ?: "Missing API_PRIVATE_KEY_FILENAME"
serviceAccountCredentials.set(file(keyfile))
track.set("internal")
releaseStatus.set(ReleaseStatus.DRAFT)
resolutionStrategy.set(ResolutionStrategy.AUTO)
}
}
}

afterEvaluate {
// This provides a workaround for https://github.com/firebase/firebase-android-sdk/issues/5629
tasks.withType<GenerateSymbolFileTask>().configureEach {
mustRunAfter(tasks.withType<MergeNativeLibsTask>())
}
}

publishing {
publications {
register<MavenPublication>("release") {
groupId = (System.getenv("ARTIFACT_GROUP_ID") ?: "com.zscaler.sdk") + ".zscalersdk-android"
artifactId = "testapp"
version = versionNameVal
pom {
packaging = "apk"
}
afterEvaluate {
from(components["release"])
}
}
}
}

dependencies {
implementation("androidx.appcompat:appcompat:1.3.1")
implementation("com.google.android.material:material:1.3.0")
implementation("androidx.activity:activity:1.2.4")
implementation("androidx.constraintlayout:constraintlayout:2.0.4")
implementation("androidx.core:core-ktx:1.6.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1")
implementation("androidx.lifecycle:lifecycle-process:2.3.1")
implementation("com.google.code.gson:gson:2.8.2")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0")
implementation ("androidx.compose.runtime:runtime-livedata:1.1.1")

// ViewModel
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1")
implementation("androidx.compose.runtime:runtime-livedata:1.0.0")
// ViewModel utilities for Compose
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0")
implementation("androidx.webkit:webkit:1.4.0")

//retrofit
implementation ("com.squareup.retrofit2:retrofit:2.11.0")
implementation("com.squareup.retrofit2:converter-gson:2.11.0")
implementation("com.squareup.okhttp3:logging-interceptor:4.12.0")

// zdk dependency
implementation("com.zscaler.sdk:zscalersdk-android:latest.release")

implementation("androidx.security:security-crypto:1.1.0-alpha06")

implementation(platform("com.google.firebase:firebase-bom:31.1.0"))
implementation("com.google.firebase:firebase-analytics")
implementation("com.google.firebase:firebase-crashlytics")
implementation("com.google.firebase:firebase-crashlytics-ktx")
implementation("com.google.firebase:firebase-crashlytics-ndk")

// test dependencies
testImplementation("junit:junit:4.13.2")
testImplementation("org.mockito:mockito-core:5.1.0")
testImplementation("org.mockito.kotlin:mockito-kotlin:5.1.0")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")

}
29 changes: 29 additions & 0 deletions sample-app/app/google-services.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"project_info": {
"project_number": "",
"project_id": "",
"storage_bucket": ""
},
"client": [
{
"client_info": {
"mobilesdk_app_id": "",
"android_client_info": {
"package_name": ""
}
},
"oauth_client": [],
"api_key": [
{
"current_key": ""
}
],
"services": {
"appinvite_service": {
"other_platform_oauth_client": []
}
}
}
],
"configuration_version": ""
}
33 changes: 33 additions & 0 deletions sample-app/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
-renamesourcefileattribute SourceFile

-dontwarn com.google.errorprone.annotations.CanIgnoreReturnValue
-dontwarn com.google.errorprone.annotations.CheckReturnValue
-dontwarn com.google.errorprone.annotations.Immutable
-dontwarn com.google.errorprone.annotations.RestrictedApi

-keep public class com.zscaler.sdk.android.ZscalerSDK {
@kotlin.jvm.JvmStatic <methods>;
}
-keep public class com.zscaler.sdk.android.ZscalerSDK$* {
public <fields>;
}
57 changes: 57 additions & 0 deletions sample-app/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">

<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/>
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_SPECIAL_USE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28"
tools:ignore="ScopedStorage" />

<application
android:name=".MainApplication"
android:dataExtractionRules="@xml/data_extraction_rules"
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.MyApplication"
tools:targetApi="31">
<activity
android:name=".SettingActivity"
android:theme="@style/Theme.AppCompat.Light"
android:exported="false" />

<service
android:name=".NotificationCancellationService"
android:enabled="true"
android:exported="false"
android:foregroundServiceType="specialUse"/>

<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleInstance"
android:theme="@style/Theme.AppCompat.Light"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.file-provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
</application>

</manifest>
Binary file added sample-app/app/src/main/ic_launcher-playstore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.zscaler.sdk.demoapp

import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import com.zscaler.sdk.android.ZscalerSDK

class AppLifecycleObserver : LifecycleObserver {
@OnLifecycleEvent(Lifecycle.Event.ON_START)
fun onAppForeground() {
// Call this as soon as app comes to foreground or network requests are going to be resumed, whichever is earlier.
ZscalerSDK.resume()
}

@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
fun onAppBackground() {
// Call this when app goes to background or when ongoing network requests are finished, whichever is later.
ZscalerSDK.suspend()
}

}
Loading

0 comments on commit 4696d59

Please sign in to comment.