A lightweight tool that simplifies testing of the process death scenario.

Overview

Venom

Venom is a lightweight tool that simplifies testing of the process death scenario for your android application.

Why Venom?

The Android Run Time aggressively manages its resources and occasionally terminates background applications while the user is away interacting with other apps. In such a case, all the activities are destroyed along with application scope objects and background tasks.

When the user relaunches the app, the top stack activity is restored from the saved instance state. Knowing this, your applications should always present a consistent interface and be tested against the process death scenario.

Venom makes it possible to kill the app process from the notification drawer making the testing easier and more straightforward versus the traditional ways like setting the background processes limit in Developer Options or using the stop process button in Android Studio, especially for a QA team.

Setup

The setup is pretty simple:

  1. Initialize the library in Application.onCreate:
val venom = Venom.createInstance(this)
venom.initialize()
  1. Call start/stop whenever you need:
venom.start()
// or
venom.stop()

See the sample app for an example.

Customize the notification

Use the builder to customize the notification:

val notification = NotificationConfig.Builder(this)
    .buttonCancel(R.string.venom_notification_button_cancel_override)
    .buttonKill(getString(R.string.venom_notification_button_kill_override))
    .build()   
venom.initialize(notification)

Download

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    debugImplementation "com.github.YarikSOffice.Venom:venom:0.5.0"
    releaseImplementation "com.github.YarikSOffice.Venom:venom-no-op:0.5.0"
}

License

The MIT License (MIT)

Copyright 2020 Yaroslav Berezanskyi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Comments
  • Distinct kill and restart actions

    Distinct kill and restart actions

    • kill: simply kills the process
    • restart: kills the process and restarts it

    Reorder the notification actions to Restart > Kill > Cancel. This order feels more natural for what this library tries to achieve.

    Fixes #20

    16-25-46 6712562

    opened by SimonMarquis 17
  • Using venom results in

    Using venom results in "App keeps stopping" dialog

    I keep getting a "RollerToaster keeps stopping" dialog even though my app is closed. I also don't see venom in the notication tray. I believe I hit the "cancel" button in the notifaction tray.

    Now like every minute or so I get this dialog, so I looked in logout. I have this same stacktrace over and over and over.

    2022-01-26 22:46:51.785 17245-17245/com.rollertoaster.app.free E/AndroidRuntime: FATAL EXCEPTION: main
        Process: com.rollertoaster.app.free, PID: 17245
        java.lang.RuntimeException: Unable to create application com.rollertoaster.app.MyApplication: android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service com.rollertoaster.app.free/com.github.venom.service.VenomService
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6730)
            at android.app.ActivityThread.access$1500(ActivityThread.java:247)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2053)
            at android.os.Handler.dispatchMessage(Handler.java:106)
            at android.os.Looper.loopOnce(Looper.java:201)
            at android.os.Looper.loop(Looper.java:288)
            at android.app.ActivityThread.main(ActivityThread.java:7839)
            at java.lang.reflect.Method.invoke(Native Method)
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
         Caused by: android.app.ForegroundServiceStartNotAllowedException: startForegroundService() not allowed due to mAllowStartForeground false: service com.rollertoaster.app.free/com.github.venom.service.VenomService
            at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:54)
            at android.app.ForegroundServiceStartNotAllowedException$1.createFromParcel(ForegroundServiceStartNotAllowedException.java:50)
            at android.os.Parcel.readParcelable(Parcel.java:3333)
            at android.os.Parcel.createExceptionOrNull(Parcel.java:2420)
            at android.os.Parcel.createException(Parcel.java:2409)
            at android.os.Parcel.readException(Parcel.java:2392)
            at android.os.Parcel.readException(Parcel.java:2334)
            at android.app.IActivityManager$Stub$Proxy.startService(IActivityManager.java:5971)
            at android.app.ContextImpl.startServiceCommon(ContextImpl.java:1847)
            at android.app.ContextImpl.startForegroundService(ContextImpl.java:1823)
            at android.content.ContextWrapper.startForegroundService(ContextWrapper.java:779)
            at androidx.core.content.ContextCompat$Api26Impl.startForegroundService(ContextCompat.java:931)
            at androidx.core.content.ContextCompat.startForegroundService(ContextCompat.java:703)
            at com.github.venom.service.ServiceDelegate.startService(ServiceDelegate.kt:12)
            at com.github.venom.Venom.start(Venom.kt:61)
            at com.github.venom.Venom.initialize(Venom.kt:52)
            at com.github.venom.Venom.initialize$default(Venom.kt:49)
            at com.github.venom.Venom.initialize(Unknown Source:2)
            at com.rollertoaster.app.MyApplication.onCreate(MyApplication.java:388)
            at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1211)
            at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6725)
            at android.app.ActivityThread.access$1500(ActivityThread.java:247) 
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2053) 
            at android.os.Handler.dispatchMessage(Handler.java:106) 
            at android.os.Looper.loopOnce(Looper.java:201) 
            at android.os.Looper.loop(Looper.java:288) 
            at android.app.ActivityThread.main(ActivityThread.java:7839) 
            at java.lang.reflect.Method.invoke(Native Method) 
            at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548) 
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003) 
         Caused by: android.os.RemoteException: Remote stack trace:
            at com.android.server.am.ActiveServices.startServiceLocked(ActiveServices.java:691)
            at com.android.server.am.ActiveServices.startServiceLocked(ActiveServices.java:616)
            at com.android.server.am.ActivityManagerService.startService(ActivityManagerService.java:11850)
            at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2519)
            at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2498)
            ```
    
    Can we do anything about it?
    opened by ColtonIdle 5
  • Update README.md to match current release

    Update README.md to match current release

    And showcase the new kill vs restart feature.

    • notification screenshot (and gif)
    • code snippet for the configuration
    • detail effects of both actions

    Do you need some help to update those elements?

    opened by SimonMarquis 4
  • Expose isActive state

    Expose isActive state

    Venom uses its own SharedPreferences file to store its active state: VenomPreferenceManager.kt. Unfortunately this state is private and leads to some issues. For instance, suppose my app is bundled with a dedicated debug panel where you can toggle features. There is currently no way (other than hardcoding the same SharedPreferences file name and key) to sync with Venom internal state. Disabling Venom with the cancel notification action will not change the host setting, and vice-versa. Which means that, when the app is later re-started, my host will try to start Venom again. It would be great to allow the host to get, or even set this internal state. Maybe setActive/isActive isn't the right wording for that.

    opened by SimonMarquis 4
  • Possible to kill process but not auto restart?

    Possible to kill process but not auto restart?

    This would an ideal tool for our QA team for testing events that happen after the process has been destroyed. Things like handling push notifications that trigger a cold start for instance.

    When I kill process, it auto restarts. Is there a way to block the restart part of it?

    enhancement 
    opened by ConorGarry 2
  • Allow customizing notification content texts

    Allow customizing notification content texts

    I had no time to add tests. I'll do it if I have some time in the week. Great util, thanks you. I hope this customisation could be helpful for others.

    opened by crgarridos 2
  • Support Android 12

    Support Android 12

    Android 12 has changes with pending intents which requires declaration of mutability. https://developer.android.com/about/versions/12/behavior-changes-12#pending-intent-mutability

    opened by ColtonIdle 1
  • Add a proper LICENSE file

    Add a proper LICENSE file

    The library is currently shipping without a license, so plugins like Licensee will fail to identify the license of the library. I just thought it would make sense to include an actual LICENSE file so this gets fixed.

    opened by tfcporciuncula 1
  • Run AGP migration to use namespace and testNamespace

    Run AGP migration to use namespace and testNamespace

    Setting the namespace via a source AndroidManifest.xml's package attribute is deprecated.
    Please instead set the namespace (or testNamespace) in the module's build.gradle file, as described here: https://developer.android.com/studio/build/configure-app-module#set-namespace
    This migration can be done automatically using the AGP Upgrade Assistant, please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.
    
    opened by SimonMarquis 0
  • Bump versions of dependencies to fix lint errors

    Bump versions of dependencies to fix lint errors

    • Kotlin 1.6.21
    • Java 11
    • AppCompat 1.4.2
    • AndroidXCore 1.8.0
    • ConstraintLayout 2.1.4
    • MockK 1.12.2
    • AGP 7.2.1
    • Gradle wrapper 7.4.2 (./gradlew wrapper --gradle-version 7.4.2 --distribution-type bin)
    opened by SimonMarquis 0
  • Killing process from adb shell does not work if Venom is running

    Killing process from adb shell does not work if Venom is running

    Hey,

    I just wanted to inform, since Venom is running as a Foreground Service, calling: adb shell am kill <app-id> will not work, since that was the thing I was using usually, maybe we could make others aware as well by putting it into read me?

    Thanks

    opened by codefluencer 1
Releases(0.6.1)
Owner
Yaroslav Berezanskyi
Android Engineer
Yaroslav Berezanskyi
Android app for testing out various networking capabilities

Networking Tools Collection of handy networking tools for everyday development. Port Scanning Subnet Device Finder (discovers devices on local network

Akshat Tiwari 3 Dec 4, 2021
Dark-souls-overlay - Stream overlay for e.g. a death counter in dark souls

(Dark Souls) Text Overlay Stream-overlay to include in Dark-Souls sessions for e

Florian Mötz 0 Dec 15, 2022
Base on android-process-button this is the advanced version of the android-process-button.

Rock Button release log Base on android-process-button this is the advanced version of the android-process-button ##Main Features ActionProcessButton

MDCCLXXVI KPT 119 Nov 25, 2022
Text-array-process - A home assignment used during the recruitment process at Lumera

Rules to implement class={isogram|palindrome|semordnilap} maxlength=<INT> minl

Mầu Tiến Đoàn 0 Jan 27, 2022
A lightweight eventbus library for android, simplifies communication between Activities, Fragments, Threads, Services, etc.

AndroidEventBus This is an EventBus library for Android. It simplifies the communication between Activities, Fragments, Threads, Services, etc. and lo

Mr.Simple 1.6k Nov 30, 2022
Integration Testing Kotlin Multiplatform Kata for Kotlin Developers. The main goal is to practice integration testing using Ktor and Ktor Client Mock

This kata is a Kotlin multiplatform version of the kata KataTODOApiClientKotlin of Karumi. We are here to practice integration testing using HTTP stub

Jorge Sánchez Fernández 29 Oct 3, 2022
Powerful, elegant and flexible test framework for Kotlin with additional assertions, property testing and data driven testing

Kotest is a flexible and comprehensive testing tool for Kotlin with multiplatform support. To learn more about Kotest, visit kotest.io or see our quic

Kotest 3.8k Jan 3, 2023
MVVM + Kotlin + Jetpack Compose +Navigation Compose + Hilt + Retrofit + Unit Testing + Compose Testing + Coroutines + Kotlin Flow + Io mockK

MvvmKotlinJetpackCompose Why do we need an architecture even when you can make an app without it? let's say you created a project without any architec

Sayyed Rizwan 46 Nov 29, 2022
Registration validation testing, Room database testing using JUnit4

Notes app Registration details validation testing, Room database testing using JUnit4 ✨ Screenshots Authors Tridev Deka - LinkedIn - Tridev Deka MIT L

Tridev Deka 0 Mar 30, 2022
Selenium locators for Java/Kotlin that resemble the Testing Library (testing-library.com).

Selenium Testing Library Testing Library selectors available as Selenium locators for Kotlin/Java. Why? When I use Selenium, I don't want to depend on

Luís Soares 5 Dec 15, 2022
Event bus for Android and Java that simplifies communication between Activities, Fragments, Threads, Services, etc. Less code, better quality.

EventBus EventBus is a publish/subscribe event bus for Android and Java. EventBus... simplifies the communication between components decouples event s

Markus Junginger 24.2k Jan 7, 2023
Wrapper around the android Camera class that simplifies its usage

EasyCamera Wrapper around the android Camera class that simplifies its usage (read more about the process) Usage: // the surface where the preview wil

Bozhidar Bozhanov 642 Nov 27, 2022
This Repository simplifies working with RecyclerView Adapter

AutoAdapter This Repository simplifies working with RecyclerView Adapter Gradle: Add it in your root build.gradle at the end of repositories: allproj

George Dzotsenidze 151 Aug 15, 2021
Wrapper around the android Camera class that simplifies its usage

EasyCamera Wrapper around the android Camera class that simplifies its usage (read more about the process) Usage: // the surface where the preview wil

Bozhidar Bozhanov 641 Dec 29, 2022
Greatly simplifies the complexities of Kotlin's reflection of Java

CatReflect 这是一个可以极大简化 Java 反射的复杂操作的工具,适用于 Kotlin & Java This is a tool that grea

null 0 Dec 26, 2021
Multitask、MultiThread(MultiConnection)、Breakpoint-resume、High-concurrency、Simple to use、Single/NotSingle-process

FileDownloader Android multi-task file download engine. 中文文档 FileDownloader2 Now, FileDownloader2-OkDownload is released, okdownload will contain all

LAIX Inc. (formerly LingoChamp Inc.) 10.7k Jan 3, 2023
I was fed up with writing Java classes to mirror json models. So I wrote this Java app to automate the process.

Json2Java I was fed up with writing Java classes to mirror json models. So I wrote this Java app to automate the process. What this tool can do right

Jon F Hancock 303 Oct 8, 2022
Access and process various types of personal data in Android with a set of easy, uniform, and privacy-friendly APIs.

PrivacyStreams PrivacyStreams is an Android library for easy and privacy-friendly personal data access and processing. It offers a functional programm

null 269 Dec 1, 2022
Identify email addresses or domains names that belong to colleges or universities. Help automate the process of approving or rejecting academic discounts.

swot JetBrains uses this swot repository to grant free licenses for JetBrains tools to students and teachers worldwide. If your email is in one of the

JetBrains 1.4k Jan 5, 2023