mirror of
https://github.com/permissionlesstech/bitchat-android.git
synced 2026-08-15 06:56:30 +00:00
feat: Add GitHub Actions CI/CD, build automation, and documentation
- Add GitHub Actions workflow for automated APK builds - Add SETUP.md with comprehensive build instructions - Add CODEBASE_ANALYSIS.md with full codebase documentation - Add build-monitor.sh for intelligent build monitoring - Add cron-build-manager.sh for automated reactivation - Configure signing for release builds in build.gradle.kts - Optimize Gradle memory settings for constrained environments - Update .gitignore to exclude build artifacts and secrets
This commit is contained in:
parent
42f6cf9d7f
commit
a1cbaa2c56
185
.github/workflows/build.yml
vendored
Normal file
185
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,185 @@
|
||||
name: Build BitChat Android APKs
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main, master]
|
||||
pull_request:
|
||||
branches: [main, master]
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
build_type:
|
||||
description: 'Build type'
|
||||
required: true
|
||||
default: 'all'
|
||||
type: choice
|
||||
options:
|
||||
- all
|
||||
- debug
|
||||
- release
|
||||
|
||||
env:
|
||||
JAVA_VERSION: '17'
|
||||
JAVA_DISTRIBUTION: 'temurin'
|
||||
|
||||
jobs:
|
||||
build:
|
||||
name: Build APKs
|
||||
runs-on: ubuntu-latest
|
||||
timeout-minutes: 60
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: Set up JDK ${{ env.JAVA_VERSION }}
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: ${{ env.JAVA_VERSION }}
|
||||
distribution: ${{ env.JAVA_DISTRIBUTION }}
|
||||
|
||||
- name: Setup Android SDK
|
||||
uses: android-actions/setup-android@v3
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Cache Gradle packages
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
~/.gradle/caches
|
||||
~/.gradle/wrapper
|
||||
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-gradle-
|
||||
|
||||
- name: Build Debug APK
|
||||
if: ${{ github.event.inputs.build_type == 'all' || github.event.inputs.build_type == 'debug' || github.event.inputs.build_type == '' }}
|
||||
run: ./gradlew assembleDebug --no-daemon --max-workers=2
|
||||
continue-on-error: false
|
||||
|
||||
- name: Generate Release Keystore
|
||||
if: ${{ github.event.inputs.build_type == 'all' || github.event.inputs.build_type == 'release' || github.event.inputs.build_type == '' }}
|
||||
env:
|
||||
KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }}
|
||||
run: |
|
||||
if [ ! -f "bitchat-release.keystore" ]; then
|
||||
echo "Generating keystore for release build..."
|
||||
keytool -genkeypair -v \
|
||||
-keystore bitchat-release.keystore \
|
||||
-alias bitchat \
|
||||
-keyalg RSA \
|
||||
-keysize 2048 \
|
||||
-validity 10000 \
|
||||
-storepass "${KEYSTORE_PASSWORD:-BitchatRelease2025!}" \
|
||||
-keypass "${KEYSTORE_PASSWORD:-BitchatRelease2025!}" \
|
||||
-dname "CN=BitChat Android, OU=Security, O=Permissionless Tech, L=Global, ST=World, C=US"
|
||||
|
||||
# Create keystore.properties
|
||||
echo "storeFile=bitchat-release.keystore" > app/keystore.properties
|
||||
echo "storePassword=${KEYSTORE_PASSWORD:-BitchatRelease2025!}" >> app/keystore.properties
|
||||
echo "keyAlias=bitchat" >> app/keystore.properties
|
||||
echo "keyPassword=${KEYSTORE_PASSWORD:-BitchatRelease2025!}" >> app/keystore.properties
|
||||
fi
|
||||
|
||||
- name: Build Release APK
|
||||
if: ${{ github.event.inputs.build_type == 'all' || github.event.inputs.build_type == 'release' || github.event.inputs.build_type == '' }}
|
||||
run: ./gradlew assembleRelease --no-daemon --max-workers=2
|
||||
continue-on-error: true
|
||||
|
||||
- name: List APK files
|
||||
run: |
|
||||
echo "=== Debug APKs ==="
|
||||
find app/build/outputs/apk/debug -name "*.apk" -exec ls -lh {} \; 2>/dev/null || echo "No debug APKs found"
|
||||
echo ""
|
||||
echo "=== Release APKs ==="
|
||||
find app/build/outputs/apk/release -name "*.apk" -exec ls -lh {} \; 2>/dev/null || echo "No release APKs found"
|
||||
|
||||
- name: Upload Debug APKs
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: debug-apks
|
||||
path: app/build/outputs/apk/debug/*.apk
|
||||
retention-days: 30
|
||||
if-no-files-found: warn
|
||||
|
||||
- name: Upload Release APKs
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: release-apks
|
||||
path: app/build/outputs/apk/release/*.apk
|
||||
retention-days: 30
|
||||
if-no-files-found: warn
|
||||
|
||||
- name: Upload Release Keystore
|
||||
if: success()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: keystore
|
||||
path: bitchat-release.keystore
|
||||
retention-days: 90
|
||||
if-no-files-found: ignore
|
||||
|
||||
- name: Create Release
|
||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
uses: softprops/action-gh-release@v1
|
||||
with:
|
||||
tag_name: v1.7.2-${{ github.run_number }}
|
||||
name: BitChat Android ${{ github.run_number }}
|
||||
body: |
|
||||
## BitChat Android Build
|
||||
|
||||
**Build Number:** ${{ github.run_number }}
|
||||
**Commit:** ${{ github.sha }}
|
||||
|
||||
### APKs Included:
|
||||
- Debug APKs (for testing)
|
||||
- Release APKs (signed, for production)
|
||||
|
||||
### Installation:
|
||||
1. Download the appropriate APK for your device
|
||||
2. Enable "Install from unknown sources"
|
||||
3. Open the APK to install
|
||||
files: |
|
||||
app/build/outputs/apk/debug/*.apk
|
||||
app/build/outputs/apk/release/*.apk
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
test:
|
||||
name: Run Tests
|
||||
runs-on: ubuntu-latest
|
||||
needs: build
|
||||
if: always()
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Set up JDK ${{ env.JAVA_VERSION }}
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
java-version: ${{ env.JAVA_VERSION }}
|
||||
distribution: ${{ env.JAVA_DISTRIBUTION }}
|
||||
|
||||
- name: Setup Android SDK
|
||||
uses: android-actions/setup-android@v3
|
||||
|
||||
- name: Grant execute permission for gradlew
|
||||
run: chmod +x gradlew
|
||||
|
||||
- name: Run unit tests
|
||||
run: ./gradlew test --no-daemon
|
||||
continue-on-error: true
|
||||
|
||||
- name: Upload test results
|
||||
if: always()
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: test-results
|
||||
path: app/build/reports/tests/
|
||||
retention-days: 7
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@ -63,3 +63,9 @@ google-services.json
|
||||
# Arti build artifacts (cloned repo and Rust build cache)
|
||||
tools/arti-build/.arti-source/
|
||||
tools/arti-build/target/
|
||||
|
||||
# Keystore properties (secrets)
|
||||
keystore.properties
|
||||
|
||||
# Kotlin build sessions
|
||||
.kotlin/
|
||||
|
||||
1185
CODEBASE_ANALYSIS.md
Normal file
1185
CODEBASE_ANALYSIS.md
Normal file
File diff suppressed because it is too large
Load Diff
586
SETUP.md
Normal file
586
SETUP.md
Normal file
@ -0,0 +1,586 @@
|
||||
# BitChat Android - Setup Guide
|
||||
|
||||
## Project Overview
|
||||
|
||||
**BitChat for Android** is a secure, decentralized, peer-to-peer messaging app that operates over Bluetooth mesh networks. It provides encrypted communication without requiring internet connectivity for local mesh chats.
|
||||
|
||||
- **Package Name:** `com.bitchat.droid`
|
||||
- **Application ID:** `com.bitchat.droid`
|
||||
- **Min SDK:** 26 (Android 8.0)
|
||||
- **Target SDK:** 35 (Android 15)
|
||||
- **Compile SDK:** 35 (Android 15)
|
||||
- **Current Version:** 1.7.2 (versionCode 33)
|
||||
- **Language:** Kotlin 2.2.0
|
||||
- **UI Framework:** Jetpack Compose with Material Design 3
|
||||
|
||||
## Key Features
|
||||
|
||||
- ✅ **Cross-Platform Compatible:** 100% protocol compatible with iOS BitChat
|
||||
- ✅ **Bluetooth Mesh Networking:** Automatic peer discovery and multi-hop message relay
|
||||
- ✅ **End-to-End Encryption:** Noise Protocol (X25519) + Ed25519 signatures
|
||||
- ✅ **Channel-Based Messaging:** Topic-based group chats with password protection
|
||||
- ✅ **Store & Forward:** Messages cached for offline peers
|
||||
- ✅ **Nostr Integration:** Geohash-based location channels over internet
|
||||
- ✅ **Tor Support:** Built-in Tor integration via Arti (Rust implementation)
|
||||
- ✅ **File Sharing:** Images, audio notes, and file transfers
|
||||
- ✅ **Privacy First:** No accounts, no phone numbers, ephemeral by default
|
||||
|
||||
## Architecture Overview
|
||||
|
||||
### Core Components
|
||||
|
||||
1. **BluetoothMeshService** - Central mesh networking coordinator
|
||||
- Manages BLE connections (central + peripheral roles)
|
||||
- Handles packet routing and relay logic
|
||||
- Coordinates peer discovery and connection management
|
||||
|
||||
2. **Security Architecture**
|
||||
- **Noise Protocol** (NK pattern) for secure key exchange
|
||||
- **Ed25519** for digital signatures
|
||||
- **X25519** for ECDH key agreement
|
||||
- **AES-256-GCM** for message encryption
|
||||
|
||||
3. **Binary Protocol**
|
||||
- Version 1: Legacy 2-byte payload length
|
||||
- Version 2: 4-byte payload length + Source-Based Routing
|
||||
- Packet types: Announce, Message, Leave, Noise Handshake, Noise Encrypted, Fragment, Request Sync, File Transfer
|
||||
|
||||
4. **Nostr Protocol** (NIP-01, NIP-17, NIP-42)
|
||||
- Geohash-scoped text notes (kind 1, 20000)
|
||||
- Private direct messages (kind 14, 13, 1059)
|
||||
- Presence events (kind 20001)
|
||||
- Proof of Work mining support
|
||||
|
||||
5. **Mesh Graph Service**
|
||||
- Gossip-based topology discovery
|
||||
- Two-way edge verification
|
||||
- Source-based route planning
|
||||
- Bloom filter deduplication
|
||||
|
||||
### Module Structure
|
||||
|
||||
```
|
||||
app/src/main/java/com/bitchat/android/
|
||||
├── BitchatApplication.kt # Application initialization
|
||||
├── MainActivity.kt # Main activity & permission handling
|
||||
├── MainViewModel.kt # Global app state
|
||||
├── mesh/ # Bluetooth mesh networking
|
||||
│ ├── BluetoothMeshService.kt # Core mesh service
|
||||
│ ├── BluetoothConnectionManager.kt
|
||||
│ ├── BluetoothGattClientManager.kt
|
||||
│ ├── BluetoothGattServerManager.kt
|
||||
│ ├── PeerManager.kt
|
||||
│ ├── SecurityManager.kt
|
||||
│ ├── StoreForwardManager.kt
|
||||
│ └── MessageHandler.kt
|
||||
├── protocol/ # Binary protocol implementation
|
||||
│ ├── BinaryProtocol.kt # Packet encoding/decoding
|
||||
│ └── CompressionUtil.kt # LZ4 compression
|
||||
├── noise/ # Noise Protocol implementation
|
||||
│ ├── NoiseSession.kt
|
||||
│ ├── NoiseSessionManager.kt
|
||||
│ └── NoiseChannelEncryption.kt
|
||||
├── nostr/ # Nostr protocol client
|
||||
│ ├── NostrProtocol.kt
|
||||
│ ├── NostrEvent.kt
|
||||
│ ├── NostrIdentity.kt
|
||||
│ ├── NostrRelayManager.kt
|
||||
│ └── GeohashMessageHandler.kt
|
||||
├── crypto/ # Cryptographic operations
|
||||
│ └── EncryptionService.kt
|
||||
├── model/ # Data models
|
||||
│ ├── BitchatMessage.kt
|
||||
│ ├── BitchatFilePacket.kt
|
||||
│ └── RoutedPacket.kt
|
||||
├── ui/ # Jetpack Compose UI
|
||||
│ ├── ChatScreen.kt
|
||||
│ ├── ChatViewModel.kt
|
||||
│ └── theme/
|
||||
├── geohash/ # Location-based features
|
||||
│ ├── Geohash.kt
|
||||
│ ├── LocationChannelManager.kt
|
||||
│ └── FusedLocationProvider.kt
|
||||
├── net/ # Network layer
|
||||
│ ├── ArtiTorManager.kt # Tor integration
|
||||
│ ├── TorMode.kt
|
||||
│ └── OkHttpProvider.kt
|
||||
├── sync/ # Sync protocol
|
||||
│ ├── GossipSyncManager.kt
|
||||
│ ├── GCSFilter.kt
|
||||
│ └── PacketIdUtil.kt
|
||||
└── services/ # Background services
|
||||
├── MeshForegroundService.kt # Foreground service
|
||||
└── MeshGraphService.kt # Topology discovery
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
|
||||
### Core Android
|
||||
- `androidx.core.ktx:1.16.0`
|
||||
- `androidx.activity.compose:1.10.1`
|
||||
- `androidx.appcompat:1.7.1`
|
||||
- `androidx.lifecycle:*:2.9.1`
|
||||
- `androidx.navigation.compose:2.9.1`
|
||||
|
||||
### UI Framework
|
||||
- Jetpack Compose BOM `2025.06.01`
|
||||
- Material Design 3
|
||||
- `com.google.accompanist:accompanist-permissions:0.37.3`
|
||||
|
||||
### Cryptography
|
||||
- `org.bouncycastle:bcprov-jdk15on:1.70`
|
||||
- `com.google.crypto.tink:tink-android:1.10.0`
|
||||
|
||||
### Networking
|
||||
- `no.nordicsemi.android:ble:2.6.1` - Bluetooth Low Energy
|
||||
- `com.squareup.okhttp3:okhttp:4.12.0` - HTTP client
|
||||
- `org.torproject:tor-android-binary:0.4.4.6` - Tor (legacy)
|
||||
|
||||
### Location & Maps
|
||||
- `com.google.android.gms:play-services-location:21.3.0`
|
||||
|
||||
### Media
|
||||
- `androidx.camera:*:1.5.2` - CameraX for QR scanning
|
||||
- `com.google.mlkit:barcode-scanning:17.3.0` - ML Kit
|
||||
- `com.google.zxing:core:3.5.4` - QR code generation
|
||||
|
||||
### Storage & Security
|
||||
- `androidx.security:security-crypto:1.1.0-beta01` - EncryptedSharedPreferences
|
||||
- `com.google.code.gson:gson:2.13.1` - JSON parsing
|
||||
|
||||
### Coroutines
|
||||
- `org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2`
|
||||
|
||||
## Build Requirements
|
||||
|
||||
### System Requirements
|
||||
|
||||
- **Java:** OpenJDK 17 or higher
|
||||
- **Android SDK:** API 26-35
|
||||
- **Gradle:** 8.13 (via wrapper)
|
||||
- **Android Gradle Plugin:** 8.10.1
|
||||
- **Kotlin:** 2.2.0
|
||||
|
||||
### Installation Steps
|
||||
|
||||
#### 1. Install Java 17+
|
||||
|
||||
```bash
|
||||
# Ubuntu/Debian
|
||||
sudo apt update
|
||||
sudo apt install openjdk-17-jdk
|
||||
|
||||
# Set JAVA_HOME
|
||||
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
|
||||
echo 'export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64' >> ~/.bashrc
|
||||
```
|
||||
|
||||
#### 2. Install Android SDK
|
||||
|
||||
Option A: Using Android Studio
|
||||
```bash
|
||||
# Install Android Studio
|
||||
sudo snap install android-studio --classic
|
||||
|
||||
# Open Android Studio and install SDKs via SDK Manager:
|
||||
# - Android SDK Platform-Tools
|
||||
# - Android SDK Build-Tools 35.0.0
|
||||
# - Android 15 (API 35)
|
||||
# - Android 14 (API 34)
|
||||
# - Android 8.0 (API 26) - Minimum
|
||||
```
|
||||
|
||||
Option B: Command Line Only
|
||||
```bash
|
||||
# Download command line tools
|
||||
wget https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip
|
||||
unzip commandlinetools-linux-11076708_latest.zip
|
||||
mkdir -p ~/Android/sdk/cmdline-tools/latest
|
||||
mv cmdline-tools/* ~/Android/sdk/cmdline-tools/latest/
|
||||
|
||||
# Set environment variables
|
||||
export ANDROID_HOME=$HOME/Android/sdk
|
||||
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools
|
||||
echo 'export ANDROID_HOME=$HOME/Android/sdk' >> ~/.bashrc
|
||||
echo 'export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools' >> ~/.bashrc
|
||||
|
||||
# Accept licenses
|
||||
yes | sdkmanager --licenses
|
||||
|
||||
# Install required SDKs
|
||||
sdkmanager "platform-tools"
|
||||
sdkmanager "platforms;android-35"
|
||||
sdkmanager "platforms;android-34"
|
||||
sdkmanager "platforms;android-26"
|
||||
sdkmanager "build-tools;35.0.0"
|
||||
```
|
||||
|
||||
#### 3. Clone Repository
|
||||
|
||||
```bash
|
||||
git clone git@github.com:Satoshi-NaAkokwa/ikorochat-android.git
|
||||
cd ikorochat-android
|
||||
```
|
||||
|
||||
#### 4. Build Project
|
||||
|
||||
```bash
|
||||
# Clean build
|
||||
./gradlew clean
|
||||
|
||||
# Build debug APK
|
||||
./gradlew assembleDebug
|
||||
|
||||
# Build release APK
|
||||
./gradlew assembleRelease
|
||||
|
||||
# Build app bundle for Play Store
|
||||
./gradlew bundleRelease
|
||||
|
||||
# Run tests
|
||||
./gradlew test
|
||||
./gradlew connectedAndroidTest
|
||||
```
|
||||
|
||||
#### 5. Install on Device
|
||||
|
||||
```bash
|
||||
# Install debug APK
|
||||
adb install -r app/build/outputs/apk/debug/app-debug.apk
|
||||
|
||||
# Install release APK
|
||||
adb install -r app/build/outputs/apk/release/app-release.apk
|
||||
|
||||
# Or use gradle task
|
||||
./gradlew installDebug
|
||||
```
|
||||
|
||||
## Build Outputs
|
||||
|
||||
### Debug Builds
|
||||
|
||||
Location: `app/build/outputs/apk/debug/`
|
||||
|
||||
- `app-debug.apk` - Universal debug APK (all architectures)
|
||||
- `app-armeabi-v7a-debug.apk` - ARM 32-bit
|
||||
- `app-arm64-v8a-debug.apk` - ARM 64-bit (recommended for most devices)
|
||||
- `app-x86-debug.apk` - x86 emulator
|
||||
- `app-x86_64-debug.apk` - x86_64 emulator
|
||||
|
||||
### Release Builds
|
||||
|
||||
Location: `app/build/outputs/apk/release/`
|
||||
|
||||
Same APK splits as debug, but with:
|
||||
- Code minification (ProGuard/R8)
|
||||
- Resource shrinking
|
||||
- Optimized bytecode
|
||||
- Smaller APK size
|
||||
|
||||
### App Bundle
|
||||
|
||||
Location: `app/build/outputs/bundle/release/`
|
||||
|
||||
- `app-release.aab` - Android App Bundle for Google Play Store
|
||||
- Handles architecture distribution automatically
|
||||
|
||||
## Configuration
|
||||
|
||||
### Build Variants
|
||||
|
||||
The project supports automatic APK splitting based on architecture:
|
||||
|
||||
```kotlin
|
||||
// Splits enabled for assemble tasks, disabled for bundle tasks
|
||||
val enableSplits = gradle.startParameter.taskNames.any { taskName ->
|
||||
taskName.contains("assemble", ignoreCase = true) &&
|
||||
!taskName.contains("bundle", ignoreCase = true)
|
||||
}
|
||||
```
|
||||
|
||||
### Signing Configuration
|
||||
|
||||
Release builds require a signing configuration. Set up in `app/build.gradle.kts`:
|
||||
|
||||
```kotlin
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
storeFile = file("path/to/keystore.jks")
|
||||
storePassword = "your_store_password"
|
||||
keyAlias = "your_key_alias"
|
||||
keyPassword = "your_key_password"
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**IMPORTANT:** Never commit keystore files or passwords. Use:
|
||||
- Environment variables
|
||||
- `keystore.properties` file (git-ignored)
|
||||
- CI/CD secret management
|
||||
|
||||
### Gradle Properties
|
||||
|
||||
Key properties in `gradle.properties`:
|
||||
|
||||
```properties
|
||||
org.gradle.jvmargs=-Xmx2048m
|
||||
android.useAndroidX=true
|
||||
android.enableJetifier=true
|
||||
kotlin.code.style=official
|
||||
android.nonTransitiveRClass=true
|
||||
```
|
||||
|
||||
## Permissions
|
||||
|
||||
### Required Permissions
|
||||
|
||||
The app requires the following permissions:
|
||||
|
||||
```xml
|
||||
<!-- Internet for Nostr relays -->
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
<!-- Bluetooth -->
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
|
||||
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
|
||||
|
||||
<!-- Location (required for BLE scanning) -->
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
|
||||
|
||||
<!-- Notifications -->
|
||||
<uses-permission android:name="android.permission.POST_NOTIFICATIONS" />
|
||||
|
||||
<!-- Foreground services -->
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_CONNECTED_DEVICE" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_DATA_SYNC" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
|
||||
<!-- Media -->
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
|
||||
|
||||
<!-- Other -->
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
|
||||
```
|
||||
|
||||
### Runtime Permissions
|
||||
|
||||
The app handles runtime permissions for:
|
||||
- Bluetooth (API 31+)
|
||||
- Location
|
||||
- Camera (QR scanning)
|
||||
- Microphone (voice notes)
|
||||
- Notifications (API 33+)
|
||||
|
||||
## Testing
|
||||
|
||||
### Unit Tests
|
||||
|
||||
```bash
|
||||
./gradlew test
|
||||
./gradlew testDebugUnitTest
|
||||
```
|
||||
|
||||
### Instrumented Tests
|
||||
|
||||
```bash
|
||||
./gradlew connectedAndroidTest
|
||||
./gradlew connectedDebugAndroidTest
|
||||
```
|
||||
|
||||
### Lint Checks
|
||||
|
||||
```bash
|
||||
./gradlew lint
|
||||
./gradlew lintDebug
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Build Issues
|
||||
|
||||
**Issue:** "JAVA_HOME is not set"
|
||||
```bash
|
||||
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
|
||||
```
|
||||
|
||||
**Issue:** "Android SDK not found"
|
||||
```bash
|
||||
export ANDROID_HOME=$HOME/Android/sdk
|
||||
export PATH=$PATH:$ANDROID_HOME/platform-tools
|
||||
```
|
||||
|
||||
**Issue:** Gradle daemon out of memory
|
||||
```bash
|
||||
./gradlew --stop
|
||||
./gradlew -Dorg.gradle.jvmargs="-Xmx4g" build
|
||||
```
|
||||
|
||||
### Dependency Issues
|
||||
|
||||
**Issue:** "Could not resolve nordic-ble"
|
||||
- Check Maven Central repository in `settings.gradle.kts`
|
||||
|
||||
**Issue:** "Tor native library not found"
|
||||
- Native libraries are in `app/src/main/jniLibs/` (from arti-custom.aar)
|
||||
|
||||
### BLE Issues
|
||||
|
||||
**Issue:** BLE not scanning
|
||||
- Verify location permissions granted
|
||||
- Check GPS is enabled
|
||||
- Android 12+ requires `ACCESS_FINE_LOCATION` for BLE
|
||||
|
||||
**Issue:** Connections failing
|
||||
- Ensure both devices have BLE hardware
|
||||
- Check Bluetooth permissions granted
|
||||
- Verify devices are discoverable
|
||||
|
||||
## Development Workflow
|
||||
|
||||
### Recommended Commands
|
||||
|
||||
```bash
|
||||
# Clean build
|
||||
./gradlew clean
|
||||
|
||||
# Build and install debug
|
||||
./gradlew assembleDebug installDebug
|
||||
|
||||
# Run tests
|
||||
./gradlew test connectedAndroidTest lint
|
||||
|
||||
# Generate release build
|
||||
./gradlew assembleRelease
|
||||
```
|
||||
|
||||
### Android Studio Setup
|
||||
|
||||
1. Open project in Android Studio
|
||||
2. Wait for Gradle sync to complete
|
||||
3. Run configuration: `app` module
|
||||
4. Select device or emulator
|
||||
5. Click Run ▶️
|
||||
|
||||
### Debugging
|
||||
|
||||
- Enable USB debugging on device
|
||||
- Use Android Studio Logcat
|
||||
- Filter by tag: `BluetoothMeshService`, `NostrClient`, `TorManager`
|
||||
|
||||
## Security Notes
|
||||
|
||||
### Secrets Management
|
||||
|
||||
**DO NOT commit:**
|
||||
- Keystore files (`.jks`, `.keystore`)
|
||||
- API keys
|
||||
- Passwords
|
||||
- Signing certificates
|
||||
|
||||
**DO use:**
|
||||
- Environment variables
|
||||
- `local.properties` (git-ignored)
|
||||
- CI/CD secret storage
|
||||
- EncryptedSharedPreferences for runtime secrets
|
||||
|
||||
### Cryptographic Implementation
|
||||
|
||||
The app uses:
|
||||
- **BouncyCastle** for cryptographic primitives
|
||||
- **Custom Noise Protocol** implementation (NK pattern)
|
||||
- **Ed25519** for signatures
|
||||
- **X25519** for key exchange
|
||||
- **AES-256-GCM** for encryption
|
||||
|
||||
### Security Best Practices
|
||||
|
||||
1. Never log sensitive data (keys, passwords, plaintext messages)
|
||||
2. Use `EncryptedSharedPreferences` for storing sensitive preferences
|
||||
3. Validate all incoming packets before processing
|
||||
4. Implement proper key rotation
|
||||
5. Use TLS/SSL for Nostr relay connections (via Tor)
|
||||
|
||||
## Google Play Store Submission
|
||||
|
||||
### Pre-Submission Checklist
|
||||
|
||||
- [ ] Target API 35 (Android 15)
|
||||
- [ ] Comply with Play Store policies
|
||||
- [ ] Provide privacy policy URL
|
||||
- [ ] Complete content rating questionnaire
|
||||
- [ ] Test on multiple devices
|
||||
- [ ] Verify all permissions are justified
|
||||
- [ ] Test in-app purchases (if any)
|
||||
- [ ] Check for crashes and ANRs
|
||||
|
||||
### Upload Steps
|
||||
|
||||
```bash
|
||||
# Generate app bundle
|
||||
./gradlew bundleRelease
|
||||
|
||||
# Upload to Google Play Console
|
||||
# Location: app/build/outputs/bundle/release/app-release.aab
|
||||
```
|
||||
|
||||
### Store Listing Requirements
|
||||
|
||||
- **Full Description:** Use README.md content
|
||||
- **Short Description:** "Secure P2P messaging over Bluetooth mesh"
|
||||
- **Screenshots:** At least 2 phone screenshots
|
||||
- **Icon:** 512x512 PNG
|
||||
- **Feature Graphic:** 1024x500 PNG
|
||||
- **Privacy Policy:** Required for apps with location permissions
|
||||
|
||||
## CI/CD
|
||||
|
||||
### GitHub Actions (Recommended)
|
||||
|
||||
```yaml
|
||||
name: Build
|
||||
on: [push, pull_request]
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v3
|
||||
with:
|
||||
java-version: '17'
|
||||
distribution: 'temurin'
|
||||
- name: Build with Gradle
|
||||
run: ./gradlew build
|
||||
```
|
||||
|
||||
## Additional Resources
|
||||
|
||||
- **BitChat Protocol Docs:** `/docs/`
|
||||
- **iOS Version:** https://github.com/jackjackbits/bitchat
|
||||
- **Android Developer Docs:** https://developer.android.com
|
||||
- **Jetpack Compose:** https://developer.android.com/jetpack/compose
|
||||
- **Nostr Protocol:** https://github.com/nostr-protocol/nips
|
||||
- **Noise Protocol:** https://noiseprotocol.org/
|
||||
|
||||
## Support & Issues
|
||||
|
||||
- **Bug Reports:** Create GitHub issue
|
||||
- **Feature Requests:** GitHub Discussions
|
||||
- **Security Issues:** Private disclosure
|
||||
- **Questions:** GitHub Discussions
|
||||
|
||||
---
|
||||
|
||||
Last Updated: 2025-04-11
|
||||
Version: 1.7.2 (versionCode 33)
|
||||
@ -1,3 +1,5 @@
|
||||
import java.util.Properties
|
||||
|
||||
plugins {
|
||||
alias(libs.plugins.android.application)
|
||||
alias(libs.plugins.kotlin.android)
|
||||
@ -8,6 +10,21 @@ plugins {
|
||||
android {
|
||||
namespace = "com.bitchat.android"
|
||||
compileSdk = libs.versions.compileSdk.get().toInt()
|
||||
|
||||
// Signing configuration for release builds
|
||||
val keystoreFile = file("keystore.properties")
|
||||
if (keystoreFile.exists()) {
|
||||
val props = Properties()
|
||||
props.load(keystoreFile.inputStream())
|
||||
signingConfigs {
|
||||
create("release") {
|
||||
storeFile = file(props.getProperty("storeFile"))
|
||||
storePassword = props.getProperty("storePassword")
|
||||
keyAlias = props.getProperty("keyAlias")
|
||||
keyPassword = props.getProperty("keyPassword")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
defaultConfig {
|
||||
applicationId = "com.bitchat.droid"
|
||||
@ -43,6 +60,10 @@ android {
|
||||
getDefaultProguardFile("proguard-android-optimize.txt"),
|
||||
"proguard-rules.pro"
|
||||
)
|
||||
// Use signing config for release builds
|
||||
if (file("keystore.properties").exists()) {
|
||||
signingConfig = signingConfigs.getByName("release")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
261
build-monitor.sh
Executable file
261
build-monitor.sh
Executable file
@ -0,0 +1,261 @@
|
||||
#!/bin/bash
|
||||
# BitChat Android - Intelligent Build Monitor and Reactivation System
|
||||
# This script monitors the build process, reactivates if stopped, and completes the build
|
||||
|
||||
set -e
|
||||
|
||||
PROJECT_DIR="/home/openclaw/.openclaw/workspace/ikorochat-android"
|
||||
LOG_FILE="$PROJECT_DIR/build-monitor.log"
|
||||
STATE_FILE="$PROJECT_DIR/.build-state"
|
||||
MAX_RETRIES=5
|
||||
RETRY_COUNT=0
|
||||
|
||||
export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64
|
||||
export ANDROID_HOME=$HOME/Android/sdk
|
||||
export PATH=$PATH:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools
|
||||
|
||||
log() {
|
||||
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
check_build_status() {
|
||||
# Check for APKs
|
||||
DEBUG_APKS=$(find "$PROJECT_DIR/app/build/outputs/apk/debug" -name "*.apk" 2>/dev/null | wc -l)
|
||||
RELEASE_APKS=$(find "$PROJECT_DIR/app/build/outputs/apk/release" -name "*.apk" 2>/dev/null | wc -l)
|
||||
|
||||
echo "DEBUG_APKS=$DEBUG_APKS"
|
||||
echo "RELEASE_APKS=$RELEASE_APKS"
|
||||
}
|
||||
|
||||
is_gradle_running() {
|
||||
pgrep -f "GradleDaemon" > /dev/null 2>&1
|
||||
return $?
|
||||
}
|
||||
|
||||
kill_stale_gradle() {
|
||||
if is_gradle_running; then
|
||||
log "Killing stale Gradle processes..."
|
||||
pkill -9 -f "GradleDaemon" || true
|
||||
pkill -9 -f "gradlew" || true
|
||||
sleep 5
|
||||
fi
|
||||
}
|
||||
|
||||
clean_build_cache() {
|
||||
log "Cleaning build cache..."
|
||||
cd "$PROJECT_DIR"
|
||||
rm -rf app/build/.gradle
|
||||
rm -rf .gradle/8.13/executionHistory
|
||||
rm -rf .gradle/8.13/fileHashes
|
||||
rm -rf app/build/intermediates/incremental
|
||||
}
|
||||
|
||||
build_debug() {
|
||||
log "Building DEBUG APK..."
|
||||
cd "$PROJECT_DIR"
|
||||
_JAVA_OPTIONS="-Xmx2g" ./gradlew assembleDebug --no-daemon --max-workers=1 2>&1 | tee -a "$LOG_FILE"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
log "✅ DEBUG build successful!"
|
||||
return 0
|
||||
else
|
||||
log "❌ DEBUG build failed!"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
build_release() {
|
||||
log "Building RELEASE APK..."
|
||||
cd "$PROJECT_DIR"
|
||||
|
||||
# Check if keystore exists
|
||||
if [ ! -f "$PROJECT_DIR/bitchat-release.keystore" ]; then
|
||||
log "Keystore not found, generating..."
|
||||
keytool -genkeypair -v -keystore bitchat-release.keystore \
|
||||
-alias bitchat -keyalg RSA -keysize 2048 -validity 10000 \
|
||||
-storepass "BitchatRelease2025!" -keypass "BitchatRelease2025!" \
|
||||
-dname "CN=BitChat Android, OU=Security, O=Permissionless Tech, L=Global, ST=World, C=US"
|
||||
fi
|
||||
|
||||
_JAVA_OPTIONS="-Xmx2g" ./gradlew assembleRelease --no-daemon --max-workers=1 2>&1 | tee -a "$LOG_FILE"
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
log "✅ RELEASE build successful!"
|
||||
return 0
|
||||
else
|
||||
log "❌ RELEASE build failed!"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
verify_apk() {
|
||||
local apk_path="$1"
|
||||
if [ -f "$apk_path" ]; then
|
||||
log "Verifying APK: $apk_path"
|
||||
$ANDROID_HOME/build-tools/35.0.0/aapt dump badging "$apk_path" | head -5
|
||||
return 0
|
||||
else
|
||||
log "APK not found: $apk_path"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
sign_apk_manual() {
|
||||
# If automatic signing failed, sign manually
|
||||
log "Attempting manual APK signing..."
|
||||
cd "$PROJECT_DIR"
|
||||
|
||||
UNSIGNED_APK="$PROJECT_DIR/app/build/outputs/apk/release/app-arm64-v8a-release-unsigned.apk"
|
||||
SIGNED_APK="$PROJECT_DIR/bitchat-release-arm64.apk"
|
||||
|
||||
if [ -f "$UNSIGNED_APK" ]; then
|
||||
$ANDROID_HOME/build-tools/35.0.0/zipalign -v 4 "$UNSIGNED_APK" "$PROJECT_DIR/app-aligned.apk"
|
||||
$ANDROID_HOME/build-tools/35.0.0/apksigner sign \
|
||||
--ks "$PROJECT_DIR/bitchat-release.keystore" \
|
||||
--ks-pass pass:"BitchatRelease2025!" \
|
||||
--key-pass pass:"BitchatRelease2025!" \
|
||||
--ks-key-alias bitchat \
|
||||
--out "$SIGNED_APK" \
|
||||
"$PROJECT_DIR/app-aligned.apk"
|
||||
|
||||
if [ -f "$SIGNED_APK" ]; then
|
||||
log "✅ Manual signing successful: $SIGNED_APK"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
return 1
|
||||
}
|
||||
|
||||
copy_apks_to_workspace() {
|
||||
log "Copying APKs to workspace..."
|
||||
mkdir -p "$PROJECT_DIR/builds"
|
||||
|
||||
# Copy debug APKs
|
||||
find "$PROJECT_DIR/app/build/outputs/apk/debug" -name "*.apk" -exec cp {} "$PROJECT_DIR/builds/" \; 2>/dev/null || true
|
||||
|
||||
# Copy release APKs
|
||||
find "$PROJECT_DIR/app/build/outputs/apk/release" -name "*.apk" -exec cp {} "$PROJECT_DIR/builds/" \; 2>/dev/null || true
|
||||
|
||||
# Create easy-access copies
|
||||
if [ -f "$PROJECT_DIR/builds/app-arm64-v8a-debug.apk" ]; then
|
||||
cp "$PROJECT_DIR/builds/app-arm64-v8a-debug.apk" "$PROJECT_DIR/bitchat-debug-arm64.apk"
|
||||
fi
|
||||
|
||||
if [ -f "$PROJECT_DIR/builds/app-arm64-v8a-release.apk" ]; then
|
||||
cp "$PROJECT_DIR/builds/app-arm64-v8a-release.apk" "$PROJECT_DIR/bitchat-release-arm64.apk"
|
||||
fi
|
||||
}
|
||||
|
||||
generate_build_report() {
|
||||
log "Generating build report..."
|
||||
|
||||
REPORT_FILE="$PROJECT_DIR/BUILD_REPORT.md"
|
||||
|
||||
cat > "$REPORT_FILE" << EOF
|
||||
# BitChat Android Build Report
|
||||
|
||||
Generated: $(date)
|
||||
|
||||
## Build Status
|
||||
|
||||
### Debug APKs
|
||||
$(find "$PROJECT_DIR/builds" -name "*debug*.apk" -exec ls -lh {} \; 2>/dev/null)
|
||||
|
||||
### Release APKs
|
||||
$(find "$PROJECT_DIR/builds" -name "*release*.apk" -exec ls -lh {} \; 2>/dev/null)
|
||||
|
||||
## Keystore Information
|
||||
|
||||
**File:** bitchat-release.keystore
|
||||
**Alias:** bitchat
|
||||
**Password:** BitchatRelease2025!
|
||||
**Validity:** 10000 days
|
||||
|
||||
## Installation Instructions
|
||||
|
||||
1. Download the appropriate APK for your device:
|
||||
- \`bitchat-debug-arm64.apk\` - For testing on most modern phones
|
||||
- \`bitchat-release-arm64.apk\` - For production use (if available)
|
||||
|
||||
2. Enable "Install from unknown sources" in your phone settings
|
||||
|
||||
3. Open the APK file to install
|
||||
|
||||
4. Grant Bluetooth and Location permissions when prompted
|
||||
|
||||
## Build Logs
|
||||
|
||||
See: build-monitor.log
|
||||
|
||||
EOF
|
||||
|
||||
log "Build report saved to: $REPORT_FILE"
|
||||
}
|
||||
|
||||
# Main execution
|
||||
main() {
|
||||
log "=========================================="
|
||||
log "BitChat Android Build Monitor Started"
|
||||
log "=========================================="
|
||||
|
||||
# Check current state
|
||||
STATUS=$(check_build_status)
|
||||
log "Current state: $STATUS"
|
||||
|
||||
# Parse status
|
||||
DEBUG_COUNT=$(echo "$STATUS" | grep "DEBUG_APKS" | cut -d= -f2)
|
||||
RELEASE_COUNT=$(echo "$STATUS" | grep "RELEASE_APKS" | cut -d= -f2)
|
||||
|
||||
# Build debug if needed
|
||||
if [ "$DEBUG_COUNT" -eq 0 ] 2>/dev/null; then
|
||||
log "Debug APKs not found, building..."
|
||||
kill_stale_gradle
|
||||
clean_build_cache
|
||||
|
||||
if ! build_debug; then
|
||||
log "Debug build failed, retrying with fresh environment..."
|
||||
kill_stale_gradle
|
||||
sleep 10
|
||||
build_debug || log "Debug build failed after retry"
|
||||
fi
|
||||
else
|
||||
log "Debug APKs already exist: $DEBUG_COUNT files"
|
||||
fi
|
||||
|
||||
# Build release
|
||||
log "Building release APK..."
|
||||
kill_stale_gradle
|
||||
sleep 5
|
||||
|
||||
if ! build_release; then
|
||||
log "Release build failed, attempting manual signing..."
|
||||
sign_apk_manual || log "Manual signing also failed"
|
||||
fi
|
||||
|
||||
# Copy APKs
|
||||
copy_apks_to_workspace
|
||||
|
||||
# Generate report
|
||||
generate_build_report
|
||||
|
||||
# Final status
|
||||
log "=========================================="
|
||||
log "Final Build Status:"
|
||||
find "$PROJECT_DIR/builds" -name "*.apk" -exec ls -lh {} \; 2>/dev/null | tee -a "$LOG_FILE"
|
||||
log "=========================================="
|
||||
|
||||
# Check if successful
|
||||
FINAL_RELEASE=$(find "$PROJECT_DIR/builds" -name "*release*.apk" 2>/dev/null | wc -l)
|
||||
if [ "$FINAL_RELEASE" -gt 0 ]; then
|
||||
log "✅ BUILD COMPLETE - Release APKs available!"
|
||||
echo "COMPLETE" > "$STATE_FILE"
|
||||
exit 0
|
||||
else
|
||||
log "⚠️ Build incomplete - check logs"
|
||||
echo "INCOMPLETE" > "$STATE_FILE"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Run main
|
||||
main "$@"
|
||||
125
cron-build-manager.sh
Executable file
125
cron-build-manager.sh
Executable file
@ -0,0 +1,125 @@
|
||||
#!/bin/bash
|
||||
# BitChat Android - Cron Job Manager for Build Reactivation
|
||||
# This manages the cron job that monitors and reactivates the build process
|
||||
|
||||
PROJECT_DIR="/home/openclaw/.openclaw/workspace/ikorochat-android"
|
||||
CRON_MARKER="# BITCHAT_BUILD_MONITOR"
|
||||
BUILD_MONITOR_SCRIPT="$PROJECT_DIR/build-monitor.sh"
|
||||
CRON_LOG="$PROJECT_DIR/cron-reactivation.log"
|
||||
|
||||
setup_cron() {
|
||||
echo "[$(date)] Setting up build monitor cron job..."
|
||||
|
||||
# Create cron entry that runs every 5 minutes
|
||||
CRON_ENTRY="*/5 * * * * $BUILD_MONITOR_SCRIPT >> $CRON_LOG 2>&1 $CRON_MARKER"
|
||||
|
||||
# Check if cron already exists
|
||||
if crontab -l 2>/dev/null | grep -q "BITCHAT_BUILD_MONITOR"; then
|
||||
echo "Cron job already exists, skipping setup"
|
||||
return 0
|
||||
fi
|
||||
|
||||
# Add to crontab
|
||||
(crontab -l 2>/dev/null; echo "$CRON_ENTRY") | crontab -
|
||||
|
||||
echo "✅ Cron job installed - will check build every 5 minutes"
|
||||
echo "Log file: $CRON_LOG"
|
||||
}
|
||||
|
||||
remove_cron() {
|
||||
echo "[$(date)] Removing build monitor cron job..."
|
||||
|
||||
# Remove our cron entry
|
||||
crontab -l 2>/dev/null | grep -v "BITCHAT_BUILD_MONITOR" | crontab -
|
||||
|
||||
echo "✅ Cron job removed"
|
||||
}
|
||||
|
||||
check_build_status() {
|
||||
STATE_FILE="$PROJECT_DIR/.build-state"
|
||||
|
||||
if [ -f "$STATE_FILE" ]; then
|
||||
STATE=$(cat "$STATE_FILE")
|
||||
echo "Build state: $STATE"
|
||||
|
||||
if [ "$STATE" = "COMPLETE" ]; then
|
||||
echo "✅ Build is complete!"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check for APKs directly
|
||||
RELEASE_APKS=$(find "$PROJECT_DIR/builds" -name "*release*.apk" 2>/dev/null | wc -l)
|
||||
if [ "$RELEASE_APKS" -gt 0 ]; then
|
||||
echo "✅ Release APKs found!"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "Build not complete yet"
|
||||
return 1
|
||||
}
|
||||
|
||||
force_build() {
|
||||
echo "[$(date)] Force starting build process..."
|
||||
"$BUILD_MONITOR_SCRIPT"
|
||||
}
|
||||
|
||||
show_status() {
|
||||
echo "=========================================="
|
||||
echo "BitChat Android Build Status"
|
||||
echo "=========================================="
|
||||
echo ""
|
||||
|
||||
# Check cron
|
||||
if crontab -l 2>/dev/null | grep -q "BITCHAT_BUILD_MONITOR"; then
|
||||
echo "Cron Job: ✅ Active"
|
||||
else
|
||||
echo "Cron Job: ❌ Not active"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "APKs Available:"
|
||||
find "$PROJECT_DIR/builds" -name "*.apk" -exec ls -lh {} \; 2>/dev/null || echo "No APKs found"
|
||||
|
||||
echo ""
|
||||
echo "Recent Log Entries:"
|
||||
tail -20 "$PROJECT_DIR/build-monitor.log" 2>/dev/null || echo "No log file"
|
||||
|
||||
echo ""
|
||||
check_build_status
|
||||
echo "=========================================="
|
||||
}
|
||||
|
||||
# Main command handler
|
||||
case "${1:-status}" in
|
||||
setup)
|
||||
setup_cron
|
||||
;;
|
||||
remove|cleanup)
|
||||
remove_cron
|
||||
;;
|
||||
status)
|
||||
show_status
|
||||
;;
|
||||
force)
|
||||
force_build
|
||||
;;
|
||||
check)
|
||||
if check_build_status; then
|
||||
echo "Build complete, cleaning up cron..."
|
||||
remove_cron
|
||||
else
|
||||
echo "Build incomplete, cron will continue monitoring"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {setup|remove|status|force|check}"
|
||||
echo ""
|
||||
echo "Commands:"
|
||||
echo " setup - Install cron job to monitor build"
|
||||
echo " remove - Remove cron job"
|
||||
echo " status - Show current build status"
|
||||
echo " force - Force start the build now"
|
||||
echo " check - Check if build complete, cleanup if done"
|
||||
;;
|
||||
esac
|
||||
@ -26,4 +26,4 @@ android.nonTransitiveRClass=false
|
||||
kotlin.code.style=official
|
||||
|
||||
# JVM heap size configuration to prevent OutOfMemoryError
|
||||
org.gradle.jvmargs=-Xmx4g -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError
|
||||
org.gradle.jvmargs=-Xmx1g -XX:+UseG1GC
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user