-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1248429
Showing
54 changed files
with
3,819 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#built application files | ||
*.apk | ||
*.ap_ | ||
|
||
# files for the dex VM | ||
*.dex | ||
|
||
# Java class files | ||
*.class | ||
|
||
# generated files | ||
bin/ | ||
gen/ | ||
|
||
# Local configuration file (sdk path, etc) | ||
local.properties | ||
|
||
# Windows thumbnail db | ||
Thumbs.db | ||
|
||
# OSX files | ||
.DS_Store | ||
|
||
# Android Studio | ||
*.iml | ||
.idea | ||
.gradle | ||
build/ | ||
.navigation | ||
captures/ | ||
output.json | ||
|
||
#NDK | ||
obj/ | ||
.externalNativeBuild |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Jorrit "Chainfire" Jongma |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
Copyright (C) 2019 Jorrit "Chainfire" Jongma | ||
|
||
This program is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
|
||
This program is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
|
||
You should have received a copy of the GNU General Public License | ||
along with this program. If not, see <https://www.gnu.org/licenses/>. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,165 @@ | ||
This is the sauce for the [Holey Light](https://play.google.com/store/apps/details?id=eu.chainfire.holeylight) app. | ||
|
||
[LICENSE](./LICENSE) is GPLv3. | ||
|
||
--- | ||
|
||
Holey Light is an S10 Notification LED emulation app. It animates the | ||
edges of the camera cut-out as replacement for the sadly missing LED. | ||
|
||
It will only light up for notifications that would have lit up the LED | ||
if the S10 had one. | ||
|
||
This is for S10/S10e/S10+ only! It will crash (wont-fix) on any other | ||
device! | ||
|
||
My personal test devices is the *plain* S10, if things are out of | ||
whack on the other models, let me know. | ||
|
||
### Features | ||
|
||
- Emulates notification LED | ||
|
||
It really is a one-trick pony :) | ||
|
||
### Questions you could and/or should ask | ||
|
||
#### Can I get this or that feature? | ||
|
||
Maybe. I am building this for me, and you get to use it if you want. | ||
If I want your feature for myself, I may add it. If not, you could | ||
always **pull request** :) | ||
|
||
The issue tracker is the TODO list, you might ask for it there. | ||
|
||
#### Aren't there other apps that do this? | ||
|
||
Maybe, yeah. But I got the idea for this the day I got the device, and | ||
started soon after. Maybe I'm not first to finish, but finish it I will. | ||
|
||
I am building this primarily for me, it will be running on my device | ||
every day all day. So I want to know and control exactly what it does, | ||
since anything untoward in the handling of this will drain your battery | ||
quite quickly (6-8 hours). | ||
|
||
Someone pointed me at another app but it was a monstrous ad-fest so | ||
I uninstalled before even trying. Nope! | ||
|
||
This is free, and you get teh sauce. | ||
|
||
#### I heard you built this entire thing just so you could call an app "Holey Light"? | ||
|
||
That is absurd. Who would even do such a thing. Certainly not me. /s | ||
|
||
#### Something something ETA? | ||
|
||
No. | ||
|
||
#### Why doesn't the animation show in the lockscreen? | ||
|
||
It is currently not possible to arbitrarily draw over the lockscreen | ||
for a standard third-party app, unless we replace the lockscreen in | ||
its entirety. | ||
|
||
It *may* be possible to do this with root. | ||
|
||
#### When I'm using the Screen off feature, my lockscreen behaves weirdly | ||
|
||
Please describe exactly what happens and what you expected to happen. | ||
As we're *faking* the screen being off, various events of the devices | ||
turning on and off have to be faked as well. It might not always work | ||
so well. | ||
|
||
#### So what about LED emulation when the device is on battery power? | ||
|
||
This isn't done yet. I've been trying different things to see their | ||
effects, but I'm not quite satisfied with how things have worked out. | ||
|
||
Currently, the animation is only shown when the screen is on, or when | ||
the screen is off and the device is charging. | ||
|
||
See the battery use section below. | ||
|
||
### Battery use | ||
|
||
To display an animation like the one we're doing, we obviously need | ||
the screen to be in some sort of ON state, or we'd just be staring | ||
at a blank screen. | ||
|
||
During normal (screen on) phone operation, this is not a problem. What | ||
follows is precisely about the situation where the screen is "off" and | ||
Android is not displayed. | ||
|
||
Ideally, we would be operating in the *doze* or one of the *suspended* | ||
states. These are power saving states, that reduce power used by the | ||
CPU and/or display directly. Aside from that, code running in the | ||
background is restricted. Unfortunately, it is not possible for | ||
third-party apps such as these to attain these power-saving states, | ||
at least not without root. | ||
|
||
The *Always On Display* mode (which is just Samsung-speak for | ||
Android's *Ambient Display* feature) does run in this mode, but | ||
decompiling AOD and several of it's plugins, I did not find a way | ||
to hook into it (or overlay it) properly. | ||
|
||
For the devs among us, if you were unaware, *Ambient Display* is quite | ||
literally just a Dream (with a few extra hidden methods to trigger *doze* | ||
mode). The path to the Dream that runs as *Ambient Display* is hardcoded | ||
in an xml in framework-res. With root and an rro overlay (or something | ||
similar) we might be able to replace it. I am not currently planning on | ||
rooting my S10, but it seems doable in theory. Typical Google to lock | ||
something like this down while it could so easily be used for nice | ||
things. | ||
|
||
Since we are not able to run in or trigger any of the power saving | ||
states we want to, we are left only with the standard wakelocks | ||
(and equivalent flags/attrs) to keep the CPU and/or screen awake. | ||
|
||
While those methods are tested and true, implementing as an *Ambient | ||
Dream* would be simpler logic (if it worked). And aside from not | ||
running the CPU and display in a lower power state, other code running | ||
in the background is not particularly restricted either. For all | ||
intents and purposes, the device is *fully* awake, even though it's | ||
showing a black screen with only a small animation it. | ||
|
||
Of course, since it's an AMOLED screen, the black pixels themselves | ||
use practically no power, but the chips are still in full power mode. | ||
We're still drawing relatively large amounts of power compared to | ||
full sleep or even the *doze*/*suspended* states. Enough so that it | ||
can drain your battery from full straight to zero overnight. | ||
|
||
None of this really matters while the device is charging, but it does | ||
when it's on battery power. | ||
|
||
I'm still thinking about and testing how to handle that case. The | ||
most obvious solution would be to run only for a while after a new | ||
notification comes in, or show the animation periodically. The best | ||
parameters for that take some testing, and that is slow going when | ||
you need to wait many hours each round to be able to compare the | ||
results. | ||
|
||
Of course, you can recompile it yourself, enable the feature, and | ||
see what happens. | ||
|
||
### Freedom! | ||
|
||
This app is free, without in-app purchases (there may be a donate button at some point), without ads, without tracking, but *with* GPLv3 [sauce](https://github.com/Chainfire/HoleyLight). | ||
|
||
### Download | ||
|
||
You can grab it from [Google Play](https://play.google.com/store/apps/details?id=eu.chainfire.holeylight). | ||
|
||
[Screenshot#1](https://lh3.googleusercontent.com/jzDVR2wFkO8rd9dgEP_Pg6PKo5EjlL-O8fjLR5Widw5b-M5sxBujj_gh8QEBcaxMfBk) | ||
|
||
### Feedback | ||
|
||
It puts it in the [XDA thread](https://forum.xda-developers.com/galaxy-s10/themes/app-holey-light-t3917675) or in the [GitHub issue tracker](https://github.com/Chainfire/HoleyLight/issues). | ||
|
||
The workings of the app are quite intricate, so describe what is happening in minute detail. | ||
|
||
### TODO | ||
|
||
You can find the TODO list in the [issue tracker](https://github.com/Chainfire/HoleyLight/issues?utf8=%E2%9C%93&q=is%3Aissue). | ||
|
||
### Enjoy! | ||
Or not. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 28 | ||
defaultConfig { | ||
applicationId "eu.chainfire.holeylight" | ||
minSdkVersion 28 | ||
targetSdkVersion 28 | ||
versionCode 10 | ||
versionName "0.10" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
applicationVariants.all { variant -> | ||
variant.outputs.all { output -> | ||
if (variant.buildType.name == 'release') { | ||
outputFileName = "HoleyLight" + "-v" + android.defaultConfig.versionName + "-" + (new Date()).format('yyyyMMddHHmmss') + ".apk" | ||
//TODO the line below warns about deprecation, fix. Bloody Gradle and their breakage every other week. | ||
variant.assemble.doLast { | ||
copy { | ||
from 'build/outputs/mapping/release' | ||
into 'proguard' | ||
include '**/mapping.txt' | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation fileTree(include: ['*.jar'], dir: 'libs') | ||
implementation 'androidx.appcompat:appcompat:1.1.0-alpha03' | ||
implementation 'androidx.preference:preference:1.1.0-alpha03' | ||
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3' | ||
implementation 'com.airbnb.android:lottie:3.0.0' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?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.chainfire.holeylight"> | ||
|
||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE"/> | ||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> | ||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/> | ||
<uses-permission android:name="android.permission.WAKE_LOCK" /> | ||
<uses-permission android:name="android.permission.DISABLE_KEYGUARD" /> | ||
|
||
<!-- TODO temporarily disabled, we might not actually need this ? | ||
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" /> | ||
--> | ||
|
||
<uses-feature android:name="android.software.companion_device_setup"/> | ||
|
||
<application | ||
android:allowBackup="false" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:roundIcon="@mipmap/ic_launcher_round" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme" | ||
tools:ignore="GoogleAppIndexingWarning"> | ||
<activity | ||
android:name=".ui.MainActivity" | ||
android:screenOrientation="portrait"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN"/> | ||
|
||
<category android:name="android.intent.category.LAUNCHER"/> | ||
</intent-filter> | ||
</activity> | ||
<activity | ||
android:name=".ui.DebugActivity" | ||
android:exported="false" | ||
android:screenOrientation="portrait"> | ||
</activity> | ||
<activity | ||
android:name=".ui.DetectCutoutActivity" | ||
android:exported="false" | ||
android:screenOrientation="portrait" | ||
android:theme="@style/AppThemeInvisible"> | ||
</activity> | ||
<activity | ||
android:name=".ui.LockscreenActivity" | ||
android:launchMode="singleInstance" | ||
android:exported="false" | ||
android:screenOrientation="portrait" | ||
android:theme="@style/AppThemeLockscreen"> | ||
</activity> | ||
|
||
<service | ||
android:name=".service.NotificationListenerService" | ||
android:label="@string/app_name" | ||
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"> | ||
<intent-filter> | ||
<action android:name="android.service.notification.NotificationListenerService"/> | ||
</intent-filter> | ||
</service> | ||
</application> | ||
|
||
</manifest> |
36 changes: 36 additions & 0 deletions
36
app/src/main/java/eu/chainfire/holeylight/misc/Battery.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright (C) 2019 Jorrit "Chainfire" Jongma | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
package eu.chainfire.holeylight.misc; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.content.IntentFilter; | ||
import android.os.BatteryManager; | ||
|
||
public class Battery { | ||
public static boolean isCharging(Context context) { | ||
Intent batteryStatus = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); | ||
if (batteryStatus != null) { | ||
int status = batteryStatus.getIntExtra(BatteryManager.EXTRA_STATUS, -1); | ||
return (status == BatteryManager.BATTERY_STATUS_CHARGING) || (status == BatteryManager.BATTERY_STATUS_FULL); | ||
} else { | ||
return false; | ||
} | ||
} | ||
} |
Oops, something went wrong.