Skip to content

Commit

Permalink
First release (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sami Väntti authored Jan 17, 2022
1 parent d5ab9b5 commit 11df2bd
Show file tree
Hide file tree
Showing 47 changed files with 1,224 additions and 1 deletion.
36 changes: 36 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Build release

on:
push:
branches:
- main
tags:
- v*

pull_request:
branches:
- '**'

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 12
uses: actions/setup-java@v2
with:
java-version: '12'
distribution: 'adopt'
cache: gradle
- name: Build with Gradle
run: |
gradle --version
gradle wrapper
./gradlew clean assembleDebug
- run: tree
- name: Archive builds
uses: actions/upload-artifact@v2
with:
name: app-debug-apk
path: '**/apk-debug.apk'
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,20 @@

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

# Android specific files
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

123 changes: 123 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions .idea/gradle.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 78 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,78 @@
# android_automaton_app
# ClearBluetooth
Simple app that will remove all bluetooth pairings with a push of a button or from command line using `adb`
<br><br/>
## Building and installation for Android 11 or lower
Application can be installed by building it in Android Studio or from command line

Building from command line. This will build and install the application to connected device
```bash
./gradlew installDebug
> BUILD SUCCESSFUL
```

Build application without installing
```bash
./gradlew assembleDebug
> BUILD SUCCESSFUL
```

Both command will build application. Built `.apk` is located in
```bash
app/build/outputs/apk/debug/app-debug.apk
```
<br><br/>
## Building and installation for Android 12
Download the `apk` from the releases or build it by using ide or gradle
```bash
./gradlew assembleDebug
> BUILD SUCCESSFUL
```
Android 12 has stricter permission control. Either install with `-g` flag:
```bash
adb install -g path/to/apk
```
- `-g` will allow all the run time permissions

### `If installed without -g user has to allow bluetooth permissions. The permission is asked only once on the initial launch of the app. If denied, uninstall the application and reinstall to have permissions asked again`
<br><br/>
## Possible problems

```bash
Error: Could not find or load main class org.gradle.wrapper.GradleWrapperMain
Caused by: java.lang.ClassNotFoundException: org.gradle.wrapper.GradleWrapperMain
```

Run
```bash
gradle wrapper
```
<br><br/>
## Using the application
The application has two activities:
- MainActivity
- UnpairWithoutUI

`MainActivity` is the one that has the UI and opens up when application is launched from the phone. `UnpairWithoutUI` will
run without UI and close after pairings are removed.

To clear the bluetooth pairings from the command line. Install the application and run the `UnpairWithoutUI`
```bash
adb shell am start -n com.automationdev.clearbluetooth/.UnpairWithoutUI
```

To enable/disable devices's bluetooth connection
```bash
adb shell am start -n com.automationdev.clearbluetooth/.ToggleBluetooth -e bluetooth enable/disable
```
<br><br/>
## Logging
When running unpairing from command line the application will output how many devices were paired and how many the app was able to unpair.
These prints can be found from log. Grep with the name of the activity `W UnpairWithoutUI`
```bash
adb logcat | grep "W UnpairWithoutUI"
> ... W UnpairWithoutUI: There is currently 7 paired bluetooth devices.
> ... W UnpairWithoutUI: 7 of 7 devices un-paired.
```
<br><br/>
## Release
Create a Github release and use `v` at the beginning of tag (for example `v1.0`). `.apk` is added to the release artefacts automatically.
1 change: 1 addition & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
39 changes: 39 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
plugins {
id 'com.android.application'
id 'kotlin-android'
}

android {
compileSdk 31

defaultConfig {
applicationId "com.automationdev.clearbluetooth"
minSdk 24
targetSdk 31
versionCode 1
versionName "1.0.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}

dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
}
21 changes: 21 additions & 0 deletions app/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
Loading

0 comments on commit 11df2bd

Please sign in to comment.