Skip to content

Commit

Permalink
Merge pull request #31 from infinum/develop
Browse files Browse the repository at this point in the history
Public release 1.1.8
  • Loading branch information
bojankoma authored Jan 5, 2022
2 parents 2d34b1d + f72b0ed commit 18efb06
Show file tree
Hide file tree
Showing 95 changed files with 3,390 additions and 213 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
Change Log
==========

## Version 1.1.8

_2022-01-10_

* Implement root check row in Device tab.
* Implement crash monitor for uncaught exceptions and ANRs.

## Version 1.1.7

_2021-12-31_
Expand Down
200 changes: 137 additions & 63 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,39 +1,48 @@
![Download](https://img.shields.io/maven-central/v/com.infinum.sentinel/sentinel) ![Validate Gradle Wrapper](https://github.com/infinum/android-sentinel/workflows/Validate%20Gradle%20Wrapper/badge.svg) ![Code analysis](https://github.com/infinum/android-sentinel/workflows/Code%20analysis/badge.svg) [![CodeFactor](https://www.codefactor.io/repository/github/infinum/android-sentinel/badge/master)](https://www.codefactor.io/repository/github/infinum/android-sentinel/overview/master)

### <img align="left" src="logo.svg" width="48">

# Sentinel

![UI](ui.png)

_Sentinel_ is a simple one screen UI that provides standardised entry point for tools used in development and QA alongside device, application and permissions data.
It's designed to be easily configured and expanded depending on needs and requirements of developers and QA testers.
_Sentinel_ is a simple one screen UI that provides standardised entry point for tools used in
development and QA alongside device, application and permissions data.
It's designed to be easily configured and expanded depending on needs and requirements of developers
and QA testers.

The project is organized in the following modules:

- `sentinel` - contains a single screen UI that provides visual information about device, application, permissions and tools
- `sentinel-no-op` - contains stubs for easy release implementation of UI package and any Tools included
- `sentinel` - contains a single screen UI that provides visual information about device,
application, permissions and tools
- `sentinel-no-op` - contains stubs for easy release implementation of UI package and any Tools
included
- `tool-chucker` - contains a class wrapper for Chucker
- `tool-collar` - contains a class wrapper for Collar
- `tool-dbinspector` - contains a class wrapper for DbInspector
- `tool-leakcanary` - contains a class wrapper for LeakCanary
- `tool-appgallery` - contains a class wrapper for Huawei AppGallery
- `tool-appgallery` - contains a class wrapper for Huawei AppGallery
- `tool-googleplay` - contains a class wrapper for Google Play
- `tool-thimble` - contains a class wrapper for Thimble
- `sample` - a sample app for testing and developing

## Usage

To include _Sentinel_ in your project, you have to add buildscript dependencies in your project level `build.gradle` or `build.gradle.kts`:
To include _Sentinel_ in your project, you have to add buildscript dependencies in your project
level `build.gradle` or `build.gradle.kts`:

**Groovy**

```groovy
buildscript {
repositories {
mavenCentral()
}
}
```

**KotlinDSL**

```kotlin
buildscript {
repositories {
Expand All @@ -45,57 +54,65 @@ buildscript {
Then add the following dependencies in your app `build.gradle` or `build.gradle.kts` :

**Groovy**

```groovy
debugImplementation "com.infinum.sentinel:sentinel:1.1.7"
releaseImplementation "com.infinum.sentinel:sentinel-no-op:1.1.7"
debugImplementation "com.infinum.sentinel:sentinel:1.1.8"
releaseImplementation "com.infinum.sentinel:sentinel-no-op:1.1.8"
```

**KotlinDSL**

```kotlin
debugImplementation("com.infinum.sentinel:sentinel:1.1.7")
releaseImplementation("com.infinum.sentinel:sentinel-no-op:1.1.7")
debugImplementation("com.infinum.sentinel:sentinel:1.1.8")
releaseImplementation("com.infinum.sentinel:sentinel-no-op:1.1.8")
```

Basic tools are provided inside the main package but depending on requirements you might want to add specific tools:
Basic tools are provided inside the main package but depending on requirements you might want to add
specific tools:

**Groovy**

```groovy
debugImplementation "com.infinum.sentinel:tool-chucker:1.1.7"
debugImplementation "com.infinum.sentinel:tool-collar:1.1.7"
debugImplementation "com.infinum.sentinel:tool-dbinspector:1.1.7"
debugImplementation "com.infinum.sentinel:tool-leakcanary:1.1.7"
debugImplementation "com.infinum.sentinel:tool-appgallery:1.1.7"
debugImplementation "com.infinum.sentinel:tool-googleplay:1.1.7"
debugImplementation "com.infinum.sentinel:tool-thimble:1.1.7"
debugImplementation "com.infinum.sentinel:tool-chucker:1.1.8"
debugImplementation "com.infinum.sentinel:tool-collar:1.1.8"
debugImplementation "com.infinum.sentinel:tool-dbinspector:1.1.8"
debugImplementation "com.infinum.sentinel:tool-leakcanary:1.1.8"
debugImplementation "com.infinum.sentinel:tool-appgallery:1.1.8"
debugImplementation "com.infinum.sentinel:tool-googleplay:1.1.8"
debugImplementation "com.infinum.sentinel:tool-thimble:1.1.8"
```

**KotlinDSL**

```kotlin
debugImplementation("com.infinum.sentinel:tool-chucker:1.1.7")
debugImplementation("com.infinum.sentinel:tool-collar:1.1.7")
debugImplementation("com.infinum.sentinel:tool-dbinspector:1.1.7")
debugImplementation("com.infinum.sentinel:tool-leakcanary:1.1.7")
debugImplementation("com.infinum.sentinel:tool-appgallery:1.1.7")
debugImplementation("com.infinum.sentinel:tool-googleplay:1.1.7")
debugImplementation("com.infinum.sentinel:tool-thimble:1.1.7")
debugImplementation("com.infinum.sentinel:tool-chucker:1.1.8")
debugImplementation("com.infinum.sentinel:tool-collar:1.1.8")
debugImplementation("com.infinum.sentinel:tool-dbinspector:1.1.8")
debugImplementation("com.infinum.sentinel:tool-leakcanary:1.1.8")
debugImplementation("com.infinum.sentinel:tool-appgallery:1.1.8")
debugImplementation("com.infinum.sentinel:tool-googleplay:1.1.8")
debugImplementation("com.infinum.sentinel:tool-thimble:1.1.8")
```

Now you can sync your project.

### Getting started

Create or inject an instance of _Sentinel_ in your Application class and start watching for triggers:
Create or inject an instance of _Sentinel_ in your Application class and start watching for
triggers:

```kotlin
Sentinel.watch(
setOf(
ChuckerTool(),
CollarTool(),
DbInspectorTool(),
LeakCanaryTool(),
AppGalleryTool(appId = "123456789"),
GooglePlayTool(),
ThimbleTool()
)
Sentinel.watch(
setOf(
ChuckerTool(),
CollarTool(),
DbInspectorTool(),
LeakCanaryTool(),
AppGalleryTool(appId = "123456789"),
GooglePlayTool(),
ThimbleTool()
)
)
```

A set of tools should be provided as a _watch_ parameter. This set of tools can be empty.
Expand All @@ -106,57 +123,72 @@ _Sentinel_ provides several different levels of tools for a developer to impleme

#### Built in

- `AppInfoTool` - opens Android OS Settings page of the application in which _Sentinel_ was implemented
- `BundleMonitorTool` - monitors Bundle objects passed around the application mostly for size avoiding _TransactionTooLarge_ exceptions
- `Preference Editor` - by tapping any preference _Sentinel_ opens a screen where you can edit current value
- `AppInfoTool` - opens Android OS Settings page of the application in which _Sentinel_ was
implemented
- `CrashMonitorTool` - monitors exceptions and ANR crashes of the application in which _Sentinel_
was implemented
- `BundleMonitorTool` - monitors Bundle objects passed around the application mostly for size
avoiding _TransactionTooLarge_ exceptions
- `Preference Editor` - by tapping any preference _Sentinel_ opens a screen where you can edit
current value

#### Dependency wrappers

Depending of what you include as module dependencies, very specific tools are provided.

- `ChuckerTool` - a wrapper class that opens [Chucker](https://github.com/ChuckerTeam/chucker)
- `CollarTool` - a wrapper class that opens [Collar](https://github.com/infinum/android-collar)
- `DbInspectorTool` - a wrapper class that opens [DbInspector](https://github.com/infinum/android_dbinspector)
- `LeakCanaryTool` - a wrapper class that opens [LeakCanary](https://github.com/square/leakcanary)
- `DbInspectorTool` - a wrapper class that
opens [DbInspector](https://github.com/infinum/android_dbinspector)
- `LeakCanaryTool` - a wrapper class that opens [LeakCanary](https://github.com/square/leakcanary)
- `ThimbleTool` - a wrapper class that opens [Thimble](https://github.com/infinum/android-thimble)
- `AppGalleryTool` - a wrapper class that opens Huawei AppGallery of a published application or a web page of the application if Huawei AppGallery is not found
- `GooglePlayTool` - a wrapper class that opens Google Play of a published application or a web page of the application if Google Play is not found
- `AppGalleryTool` - a wrapper class that opens Huawei AppGallery of a published application or a
web page of the application if Huawei AppGallery is not found
- `GooglePlayTool` - a wrapper class that opens Google Play of a published application or a web page
of the application if Google Play is not found

#### Source abstractions

If you want to implement a different tool other than already packaged with a predefined type and name, several are available.
If you want to implement a different tool other than already packaged with a predefined type and
name, several are available.

- `NetworkTool` - a wrapper interface with a name *Network* for any network interceptors
- `MemoryTool` - a wrapper interface with a name *Memory* for any memory management tools
- `AnalyticsTool` - a wrapper interface with a name *Analytics* for any analytics collectors
- `DatabaseTool` - a wrapper interface with a name *Database* for any database viewers
- `ReportTool` - a wrapper interface with a name *Report* for any crash reporting tools
- `BluetoothTool` - a wrapper interface with a name *Bluetooth* for any Bluetooth loggers
- `DistributionTool` - a wrapper interface with a name *Distribution* for any release distribution channels
- `DistributionTool` - a wrapper interface with a name *Distribution* for any release distribution
channels
- `DesignTool` - a wrapper interface with a name *Design* for any design utilities

#### Independent implementations

An interface is provided named _Sentinel.Tool_ that requires implementation of a *String resource* for a name and a _View.OnClickListener_.
An optional icon *Drawable resource* can be supplied.
An interface is provided named _Sentinel.Tool_ that requires implementation of a *String resource*
for a name and a _View.OnClickListener_. An optional icon *Drawable resource* can be supplied.
Implementing this interface enables any class to be provided as a tool in _Sentinel_.

```kotlin
interface Tool {
interface Tool {

@DrawableRes
fun icon(): Int? = null
@DrawableRes
fun icon(): Int? = null

@StringRes
fun name(): Int
@StringRes
fun name(): Int

fun listener(): View.OnClickListener
}
fun listener(): View.OnClickListener
}
```

### Triggers

_Sentinel_ observes several different trigger events, determining when to show up.
*Manual* and *Shake* triggers cannot be turned off but rest are configurable through _Sentinel_ settings except *Foreground* trigger when running on emulators.
Trigger states will be persisted between sessions.
*Manual* and *Shake* triggers cannot be turned off but rest are configurable through _Sentinel_
settings except *Foreground* trigger when running on emulators. Trigger states will be persisted
between sessions.
*Upon first run, all triggers are enabled.*

- `Manual` - used for manually triggering UI with _show()_
- `Shake` - default trigger to show UI, shake device to invoke
- `Foreground` - shows UI every time application goes into foreground
Expand All @@ -165,27 +197,69 @@ Trigger states will be persisted between sessions.

### Formatters

Data gathered and presented by _Sentinel_ can be shared to any text compliant recipient applications.
Data gathered and presented by _Sentinel_ can be shared to any text compliant recipient
applications.
_Sentinel_ provides a few simple text formatters for easy integrations into other systems.
_Plain_ formatter is selected by default, but selecting any other is persisted between sessions.

- `Plain`
- `Markdown`
- `JSON`
- `XML`
- `HTML`

## Crash monitor

_Sentinel_ has a built in default uncaught exception handler and ANR observer. If switched on in
settings, it will notify both in a form of a notification.
Once tapped on this notification, a screen with details is shown. A complete list of crashes is
persisted between sessions and available on demand.
Methods to react on these crashes in a graceful way are provided in _Sentinel_.

```kotlin
Sentinel.setExceptionHandler { _, exception ->
println("Exception happened: ${exception.message}")
exitProcess(exception.hashCode())
}

Sentinel.setAnrListener { exception ->
println("ANR happened: ${exception.message}")
exitProcess(exception.hashCode())
}
```

## Bundle monitor

_Sentinel_ monitors Bundle objects passed around the application mostly for size limit of 500kB,
thus avoiding _TransactionTooLarge_ exceptions.
In settings there are options to notify inside a running session, toggle specific variants or set
the limit of Bundle size.
This monitor feature runs automatically for every _Activity_ but if you wish to disable monitoring
for a specific screen, you can do so in the _AndroidManifest.xml_ by adding a _meta-data_ node.
```xml
<activity
android:name="com.example.ui.main.MainActivity"
android:exported="false">
<meta-data
android:name="@string/sentinel_infinum_monitored"
android:value="false" />
</activity>
```

## Requirements

This plugin has been written in Kotlin but works both inside Kotlin and Java projects.
Minimum required API level to use _Sentinel_ is *21* known as [Android 5.0, Lollipop](https://www.android.com/versions/lollipop-5-0/).
This plugin has been written in Kotlin but works both inside Kotlin and Java projects. Minimum
required API level to use _Sentinel_ is *21* known
as [Android 5.0, Lollipop](https://www.android.com/versions/lollipop-5-0/).
_Sentinel_ is built with and for AndroidX projects.

## Contributing

Feedback and code contributions are very much welcome. Just make a pull request with a short description of your changes. By making contributions to this project you give permission for your code to be used under the same [license](LICENSE).
For easier developing a `sample` application with proper implementations is provided.
If you wish to add a new specific dependency wrapper tool, create a new module and set it up like the ones already provided.
Then create a pull request.
Feedback and code contributions are very much welcome. Just make a pull request with a short
description of your changes. By making contributions to this project you give permission for your
code to be used under the same [license](LICENSE). For easier developing a `sample` application with
proper implementations is provided. If you wish to add a new specific dependency wrapper tool,
create a new module and set it up like the ones already provided. Then create a pull request.

## License

Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ buildscript {
dependencies {
classpath libs.tools.gradle
classpath libs.kotlin.gradle
classpath libs.kotlin.serialization
classpath libs.cpd
classpath libs.detekt.gradle
classpath libs.ktlint
Expand Down
4 changes: 2 additions & 2 deletions config.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ext {
]
releaseConfig = [
"group" : "com.infinum.sentinel",
"version" : "1.1.7",
"versionCode": 1 * 100 * 100 + 1 * 100 + 7
"version" : "1.1.8",
"versionCode": 1 * 100 * 100 + 1 * 100 + 8
]
}
5 changes: 4 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
[versions]
sentinel = "1.1.7"
sentinel = "1.1.8"
gradle = "7.0.4"
kotlin = "1.6.10"
coroutines = "1.6.0"
json = "1.3.2"
core = "1.7.0"
appcompat = "1.4.0"
activity = "1.4.0"
Expand Down Expand Up @@ -43,6 +44,8 @@ tools-gradle = { module = "com.android.tools.build:gradle", version.ref = "gradl

kotlin-gradle = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
kotlin-core = { module = "org.jetbrains.kotlin:kotlin-stdlib-jdk8", version.ref = "kotlin" }
kotlin-serialization = { module = "org.jetbrains.kotlin:kotlin-serialization", version.ref = "kotlin" }
kotlin-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "json" }

coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "coroutines" }

Expand Down
Loading

0 comments on commit 18efb06

Please sign in to comment.