Skip to content

Commit

Permalink
POC, decoding works.
Browse files Browse the repository at this point in the history
  • Loading branch information
d4rken committed Dec 28, 2021
1 parent 19ab34d commit 443af25
Show file tree
Hide file tree
Showing 160 changed files with 6,875 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.idea
.gradle
build/
38 changes: 37 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,37 @@
# android-airpods-companion
# Companion App for AirPods (CAP)

A companion app that adds support for AirPod specific features to Android.

Supported models:

* AirPods Gen1
* AirPods Gen2
* AirPods Pro

## Support the project

* Buy the CAP Pro In-App purchase on [Google Play](https://play.google.com/store/apps/details?id=eu.darken.cap)
* [Buy me a coffee](https://www.buymeacoffee.com/tydarken)
* Help translate CAP [on Crowdin](https://crowdin.com/project/airpod-companion)

## Download

* [Google Play](https://play.google.com/store/apps/details?id=eu.darken.cap)
* [GitHub](https://github.com/d4rken/android-airpods-companion/releases/latest)

## Get help

* [Github Issues](https://github.com/d4rken/android-airpods-companion/issues)
* [Discord](https://discord.gg/vHubYPp)

## Screenshots

## License

CAP's code is available under a GPL v3 license, this excludes:

* CAP icons, logos, mascots and marketing materials.
* CAP animations and videos.
* CAP documentation.
* Google Play store screenshots.
* Google Play store texts & descriptions.
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
230 changes: 230 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,230 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-parcelize'
id 'androidx.navigation.safeargs.kotlin'
id 'com.bugsnag.android.gradle'
id 'dagger.hilt.android.plugin'
}

def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def buildTime = new Date().format("yyyy-MM-dd'T'HH:mm:ss'Z'", TimeZone.getTimeZone("GMT+1"))

android {
def packageName = "eu.darken.cap"

compileSdkVersion buildConfig.compileSdk

defaultConfig {
applicationId "${packageName}"

minSdkVersion buildConfig.minSdk
targetSdkVersion buildConfig.targetSdk

versionCode buildConfig.version.code
versionName buildConfig.version.name

testInstrumentationRunner "eu.darken.cap.HiltTestRunner"

buildConfigField "String", "GITSHA", "\"${gitSha}\""
buildConfigField "String", "BUILDTIME", "\"${buildTime}\""
}

signingConfigs {
release {}
}
def signingPropFile = new File(System.properties['user.home'], ".appconfig/${packageName}/signing.properties")
if (signingPropFile.canRead()) {
Properties signingProps = new Properties()
signingProps.load(new FileInputStream(signingPropFile))
signingConfigs {
release {
storeFile new File(signingProps['release.storePath'])
keyAlias signingProps['release.keyAlias']
storePassword signingProps['release.storePassword']
keyPassword signingProps['release.keyPassword']
}
}
}

buildTypes {
def proguardRulesRelease = fileTree(dir: "../proguard", include: ["*.pro"]).asList().toArray()
debug {
ext.enableBugsnag = false
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
proguardFiles proguardRulesRelease
proguardFiles 'proguard-rules-debug.pro'
}
release {
signingConfig signingConfigs.release
lintOptions {
abortOnError true
fatal 'StopShip'
}
ext.enableBugsnag = true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt')
proguardFiles proguardRulesRelease
}
applicationVariants.all { variant ->
if (variant.buildType.name == "debug") {
variant.mergedFlavor.resourceConfigurations.clear()
variant.mergedFlavor.resourceConfigurations.add("en")
variant.mergedFlavor.resourceConfigurations.add("de")
} else if (variant.buildType.name != "debug") {
variant.outputs.each { output ->
output.outputFileName = "${packageName}-v" + defaultConfig.versionName + "(" + defaultConfig.versionCode + ")-" + variant.buildType.name.toUpperCase() + "-" + gitSha + ".apk"
}
}
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

kotlinOptions {
jvmTarget = '1.8'
}

buildFeatures {
viewBinding true
}

tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"

freeCompilerArgs += [
"-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi",
"-Xuse-experimental=kotlinx.coroutines.FlowPreview",
"-Xuse-experimental=kotlin.time.ExperimentalTime",
"-Xuse-experimental=kotlin.ExperimentalUnsignedTypes",
"-Xopt-in=kotlin.RequiresOptIn"
]
}
}

testOptions {
unitTests.all {
useJUnitPlatform()
}
unitTests {
includeAndroidResources = true
}
}

sourceSets {
test {
java.srcDirs += "$projectDir/src/testShared/java"
}
androidTest {
java.srcDirs += "$projectDir/src/testShared/java"
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
}
}

dependencies {
// Kotlin
implementation "org.jetbrains.kotlin:kotlin-stdlib:${versions.kotlin.core}"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:${versions.kotlin.coroutines}"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${versions.kotlin.coroutines}"

testImplementation "org.jetbrains.kotlin:kotlin-reflect:${versions.kotlin.core}"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:${versions.kotlin.coroutines}"
androidTestImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:${versions.kotlin.coroutines}") {
// conflicts with mockito due to direct inclusion of byte buddy
exclude group: "org.jetbrains.kotlinx", module: "kotlinx-coroutines-debug"
}

// Debugging
implementation ('com.bugsnag:bugsnag-android:5.9.2')
implementation 'com.getkeepsafe.relinker:relinker:1.4.3'

// DI
implementation "com.google.dagger:dagger:${versions.dagger.core}"
implementation "com.google.dagger:dagger-android:${versions.dagger.core}"

kapt "com.google.dagger:dagger-compiler:${versions.dagger.core}"
kapt "com.google.dagger:dagger-android-processor:${versions.dagger.core}"

implementation "com.google.dagger:hilt-android:${versions.dagger.core}"
kapt "com.google.dagger:hilt-android-compiler:${versions.dagger.core}"

testImplementation "com.google.dagger:hilt-android-testing:${versions.dagger.core}"
kaptTest "com.google.dagger:hilt-android-compiler:${versions.dagger.core}"

androidTestImplementation "com.google.dagger:hilt-android-testing:${versions.dagger.core}"
kaptAndroidTest "com.google.dagger:hilt-android-compiler:${versions.dagger.core}"

kapt "androidx.hilt:hilt-compiler:1.0.0"
implementation 'androidx.hilt:hilt-common:1.0.0'

// Support libs
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'androidx.annotation:annotation:1.3.0'

implementation 'androidx.activity:activity-ktx:1.4.0'
implementation 'androidx.fragment:fragment-ktx:1.4.0'

implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-savedstate:2.4.0'
implementation 'androidx.lifecycle:lifecycle-common-java8:2.4.0'
implementation 'androidx.lifecycle:lifecycle-process:2.4.0'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'

implementation "androidx.navigation:navigation-fragment-ktx:2.3.5"
implementation "androidx.navigation:navigation-ui-ktx:2.3.5"

def work_version = "2.7.1"
implementation "androidx.work:work-runtime:${work_version}"
testImplementation "androidx.work:work-testing:${work_version}"
implementation "androidx.work:work-runtime-ktx:${work_version}"
implementation 'androidx.hilt:hilt-work:1.0.0'

// UI
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation 'com.google.android.material:material:1.6.0-alpha01'

// Testing
testImplementation 'junit:junit:4.13.2'
testImplementation "org.junit.vintage:junit-vintage-engine:5.7.1"
testImplementation "androidx.test:core-ktx:1.4.0"

testImplementation "io.mockk:mockk:1.12.1"
androidTestImplementation "io.mockk:mockk-android:1.11.0"

testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.7.1"
testImplementation "org.junit.jupiter:junit-jupiter-api:5.7.1"
testImplementation "org.junit.jupiter:junit-jupiter-params:5.7.1"

androidTestImplementation "androidx.navigation:navigation-testing:2.3.5"

testImplementation "io.kotest:kotest-runner-junit5:4.6.2"
testImplementation "io.kotest:kotest-assertions-core-jvm:4.6.2"
testImplementation "io.kotest:kotest-property-jvm:4.6.2"
androidTestImplementation "io.kotest:kotest-assertions-core-jvm:4.6.2"
androidTestImplementation "io.kotest:kotest-property-jvm:4.6.2"

testImplementation 'android.arch.core:core-testing:1.1.1'
androidTestImplementation 'android.arch.core:core-testing:1.1.1'
debugImplementation 'androidx.test:core-ktx:1.4.0'

androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestImplementation 'androidx.test:rules:1.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-contrib:3.4.0'
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.4.0'
androidTestImplementation 'androidx.test.espresso.idling:idling-concurrent:3.4.0'
}
1 change: 1 addition & 0 deletions app/proguard-rules-debug.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
-dontobfuscate
21 changes: 21 additions & 0 deletions app/proguard/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# 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
57 changes: 57 additions & 0 deletions 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"
package="eu.darken.cap">

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:name="eu.darken.cap.App"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">

<activity
android:name="eu.darken.cap.main.ui.MainActivity"
android:label="@string/app_name"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

<receiver
android:name="eu.darken.cap.monitor.core.receiver.BluetoothEventReceiver"
android:enabled="true"
android:exported="true"
android:label="Service trigger">
<intent-filter>
<action android:name="android.bluetooth.device.action.ACL_CONNECTED" />
<!-- <action android:name="android.bluetooth.device.action.ACL_DISCONNECTED" />-->
<!-- <action android:name="android.bluetooth.a2dp.profile.action.CONNECTION_STATE_CHANGED" />-->
<!-- <action android:name="android.bluetooth.headset.profile.action.CONNECTION_STATE_CHANGED" />-->
</intent-filter>
</receiver>

<service
android:name="androidx.work.impl.foreground.SystemForegroundService"
android:foregroundServiceType="connectedDevice"
tools:node="merge" />

<provider
android:name="androidx.startup.InitializationProvider"
android:authorities="${applicationId}.androidx-startup"
tools:node="remove"></provider>
</application>

</manifest>
Loading

0 comments on commit 443af25

Please sign in to comment.