Giter Site home page Giter Site logo

aware_appusage_plugin's Introduction

Aware_AppUsage_Plugin

https://jitpack.io/#KarasawaTakumi0621/aware_appusage_plugin/ver1.0

Overview

This plugin enables UsageStatsEvent data streaming, DB storage, storage on AWARE-micro server, etc. using AWARE Framework's Core infrastructure. This is an unofficial plugin of AWAREFramework. If you have any questions about this plugin, please contact the following Twitter account.

Requirement

  • Kotlin
  • Java16
  • Android 11

Usage

Install

We are using Jitpack, please add the following to the two files of Build.gradle.

(Root) Build.gradle

buildscript {
    repositories {
        google()
        mavenCentral()
        + maven { url 'https://jitpack.io' }
        + maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
    }
~~~
}

(App) Build.gradle

dependencies {
~~~
    + implementation 'com.github.KarasawaTakumi0621:aware_appusage_module:0.21'
}

Add the following to Setting.gradle.

dependencyResolutionManagement {
    repositories {
        google()
        mavenCentral()
        jcenter()
        + maven { url 'https://jitpack.io' }
        + maven { url "https://s3.amazonaws.com/repo.commonsware.com" }
    }
}

Example usage

// To start the service.
AppusageSensor.start(applicationContext, AppusageSensor.Config().apply {

    interval = 60000 //1min
    usageAppDisplaynames = mutableListOf("com.twitter.android", "com.facebook.orca", "com.facebook.katana", "com.instagram.android", "jp.naver.line.android", "com.ss.android.ugc.trill")
    usageAppEventTypes = mutableListOf(UsageEvents.Event.ACTIVITY_PAUSED, UsageEvents.Event.ACTIVITY_RESUMED)
    
    awareUsageAppNotificationTitle = "studying now"
    awareUsageAppNotificationDescription = "App usage history is being retrieved."
    awareUsageAppNoticationId = "appusage_notification"

    dbType = Engine.DatabaseType.ROOM

    sensorObserver = object : AppusageSensor.Observer {
        override fun onDataChanged(datas: MutableList<AppusageData>?) {
            println("ondatachanged in mainActivity ${datas}")
        }
    }
})

AppUsage Data

Contains the raw sensor data.

Field Type Description
eventTimestamp Long Unix Time for starting/stopping applications, etc.
appPackageName String Application name of the event that occurred
eventType Int Event ID of UsageEvent. https://developer.android.com/reference/kotlin/android/app/usage/UsageEvents.Event
label String Customizable label. Useful for data calibration or traceability
deviceId String AWARE device UUID
label String Customizable label. Useful for data calibration or traceability
timestamp Long unixtime milliseconds since 1970
timezone Int Raw timezone offset of the device
os String Operating system of the device (ex. android)

AppUsage.Config

Fields

  • usageAppDisplaynames: MutableList<String>: Array of Application Display Names to be obtained
  • usageAppEventTypes: MutableList<Int>: Array of UsageEvent.Event IDs to be obtained
  • awareUsageAppNotificationTitle: Title of the notification when the Foreground Service is activated
  • awareUsageAppNotificationDescription: Description of the notification when the Foreground Service is activated
  • awareUsageAppNoticationId: ID of the notification when the Foreground Service is activated
  • sensorObserver: AccelerometerSensor.Observer: Callback for live data updates.
  • interval: Int: Data samples to collect per msec (default = 60000)
  • debug: Boolean enable/disable logging to Logcat. (default = false)
  • label: String Label for the data. (default = "")
  • deviceId: String Id of the device that will be associated with the events and the sensor. (default = "")
  • dbEncryptionKey Encryption key for the database. (default = null)
  • dbType: Engine Which db engine to use for saving data. (default = Engine.DatabaseType.NONE)
  • dbPath: String Path of the database. (default = "aware_accelerometer")
  • dbHost: String Host for syncing the database. (default = null)

Reference

Author

twitter

aware_appusage_plugin's People

Contributors

karasawatakumi0621 avatar

Watchers

 avatar

aware_appusage_plugin's Issues

Add function to get obtainable ApplicationDisplayName

Currently, in order to use the plugin, you need to set the Application DisplayName you want to get from Config.
However, it is inconvenient to know the DisplayName, because you need to do some research or install a separate application to get the DisplayName.
It would be useful to be able to retrieve the available Application DisplayName from the function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.