{"id":28699999,"url":"https://github.com/Cap-go/capacitor-android-usagestatsmanager","last_synced_at":"2025-06-14T11:03:49.154Z","repository":{"id":286729790,"uuid":"962336539","full_name":"Cap-go/capacitor-android-usagestatsmanager","owner":"Cap-go","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-11T09:51:13.000Z","size":619,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-31T05:56:09.974Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Cap-go.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"Cap-go","patreon":null,"open_collective":"capgo","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2025-04-08T02:22:46.000Z","updated_at":"2025-04-11T09:51:16.000Z","dependencies_parsed_at":"2025-05-06T05:38:52.754Z","dependency_job_id":null,"html_url":"https://github.com/Cap-go/capacitor-android-usagestatsmanager","commit_stats":null,"previous_names":["cap-go/capacitor-android-usagestatsmanager"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-android-usagestatsmanager","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-android-usagestatsmanager/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-android-usagestatsmanager/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-android-usagestatsmanager/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Cap-go","download_url":"https://codeload.github.com/Cap-go/capacitor-android-usagestatsmanager/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Cap-go%2Fcapacitor-android-usagestatsmanager/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":258674927,"owners_count":22739593,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-14T11:01:32.695Z","updated_at":"2025-06-14T11:03:49.149Z","avatar_url":"https://github.com/Cap-go.png","language":"Java","funding_links":["https://github.com/sponsors/Cap-go","https://opencollective.com/capgo"],"categories":["Capgo Capacitor Plugins","[Capgo plugins](https://capgo.app/)"],"sub_categories":["Android Specific"],"readme":"# @capgo/capacitor-android-usagestatsmanager\n \u003ca href=\"https://capgo.app/\"\u003e\u003cimg src='https://raw.githubusercontent.com/Cap-go/capgo/main/assets/capgo_banner.png' alt='Capgo - Instant updates for capacitor'/\u003e\u003c/a\u003e\n\n\u003cdiv align=\"center\"\u003e\n  \u003ch2\u003e\u003ca href=\"https://capgo.app/?ref=plugin\"\u003e ➡️ Get Instant updates for your App with Capgo 🚀\u003c/a\u003e\u003c/h2\u003e\n  \u003ch2\u003e\u003ca href=\"https://capgo.app/consulting/?ref=plugin\"\u003e Fix your annoying bug now, Hire a Capacitor expert 💪\u003c/a\u003e\u003c/h2\u003e\n\u003c/div\u003e\n\n## Description\nExposes the Android's UsageStatsManager SDK to Capacitor\n\n## Usage\n\nRequires the following permissions in your `AndroidManifest.xml`:\n\n```xml\n\u003cuses-permission android:name=\"android.permission.PACKAGE_USAGE_STATS\"\n    tools:ignore=\"ProtectedPermissions\" /\u003e\n\u003cuses-permission android:name=\"android.permission.QUERY_ALL_PACKAGES\"\n    tools:ignore=\"QueryAllPackagesPermission\" /\u003e\n```\n\n\n\n## Install\n\n```bash\nnpm install @capgo/capacitor-android-usagestatsmanager\nnpx cap sync\n```\n\n## API\n\n\u003cdocgen-index\u003e\n\n* [`queryAndAggregateUsageStats(...)`](#queryandaggregateusagestats)\n* [`isUsageStatsPermissionGranted()`](#isusagestatspermissiongranted)\n* [`openUsageStatsSettings()`](#openusagestatssettings)\n* [`queryAllPackages()`](#queryallpackages)\n* [Interfaces](#interfaces)\n* [Type Aliases](#type-aliases)\n\n\u003c/docgen-index\u003e\n\n\u003cdocgen-api\u003e\n\u003c!--Update the source file JSDoc comments and rerun docgen to update the docs below--\u003e\n\n### queryAndAggregateUsageStats(...)\n\n```typescript\nqueryAndAggregateUsageStats(options: UsageStatsOptions) =\u003e Promise\u003cRecord\u003cstring, UsageStats\u003e\u003e\n```\n\nQueries and aggregates usage stats for the given options.\n\n| Param         | Type                                                            | Description                  |\n| ------------- | --------------------------------------------------------------- | ---------------------------- |\n| **`options`** | \u003ccode\u003e\u003ca href=\"#usagestatsoptions\"\u003eUsageStatsOptions\u003c/a\u003e\u003c/code\u003e | - The options for the query. |\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#record\"\u003eRecord\u003c/a\u003e\u0026lt;string, \u003ca href=\"#usagestats\"\u003eUsageStats\u003c/a\u003e\u0026gt;\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### isUsageStatsPermissionGranted()\n\n```typescript\nisUsageStatsPermissionGranted() =\u003e Promise\u003cUsageStatsPermissionResult\u003e\n```\n\nChecks if the usage stats permission is granted.\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;\u003ca href=\"#usagestatspermissionresult\"\u003eUsageStatsPermissionResult\u003c/a\u003e\u0026gt;\u003c/code\u003e\n\n--------------------\n\n\n### openUsageStatsSettings()\n\n```typescript\nopenUsageStatsSettings() =\u003e Promise\u003cvoid\u003e\n```\n\nOpen the usage stats settings screen.\nThis will open the usage stats settings screen, which allows the user to grant the usage stats permission.\nThis will always open the settings screen, even if the permission is already granted.\n\n--------------------\n\n\n### queryAllPackages()\n\n```typescript\nqueryAllPackages() =\u003e Promise\u003c{ packages: PackageInfo[]; }\u003e\n```\n\nQueries all installed packages on the device.\nRequires the QUERY_ALL_PACKAGES permission.\n\n**Returns:** \u003ccode\u003ePromise\u0026lt;{ packages: PackageInfo[]; }\u0026gt;\u003c/code\u003e\n\n**Since:** 1.2.0\n\n--------------------\n\n\n### Interfaces\n\n\n#### UsageStats\n\n| Prop                                | Type                | Description                                                                                        |\n| ----------------------------------- | ------------------- | -------------------------------------------------------------------------------------------------- |\n| **`firstTimeStamp`**                | \u003ccode\u003enumber\u003c/code\u003e | The first timestamp of the usage stats.                                                            |\n| **`lastTimeStamp`**                 | \u003ccode\u003enumber\u003c/code\u003e | The last timestamp of the usage stats.                                                             |\n| **`lastTimeForegroundServiceUsed`** | \u003ccode\u003enumber\u003c/code\u003e | Only available on Android Q (API level 29) and above. Will be undefined on lower Android versions. |\n| **`lastTimeUsed`**                  | \u003ccode\u003enumber\u003c/code\u003e | The last time the app was used.                                                                    |\n| **`lastTimeVisible`**               | \u003ccode\u003enumber\u003c/code\u003e | Only available on Android Q (API level 29) and above. Will be undefined on lower Android versions. |\n| **`packageName`**                   | \u003ccode\u003estring\u003c/code\u003e | The name of the package.                                                                           |\n| **`totalForegroundServiceUsed`**    | \u003ccode\u003enumber\u003c/code\u003e | Only available on Android Q (API level 29) and above. Will be undefined on lower Android versions. |\n| **`totalTimeInForeground`**         | \u003ccode\u003enumber\u003c/code\u003e | The total time the app was in the foreground.                                                      |\n| **`totalTimeVisible`**              | \u003ccode\u003enumber\u003c/code\u003e | Only available on Android Q (API level 29) and above. Will be undefined on lower Android versions. |\n\n\n#### UsageStatsOptions\n\n| Prop            | Type                | Description                                                                                              |\n| --------------- | ------------------- | -------------------------------------------------------------------------------------------------------- |\n| **`beginTime`** | \u003ccode\u003enumber\u003c/code\u003e | The inclusive beginning of the range of stats to include in the results. Defined in terms of \"Unix time\" |\n| **`endTime`**   | \u003ccode\u003enumber\u003c/code\u003e | The exclusive end of the range of stats to include in the results. Defined in terms of \"Unix time\"       |\n\n\n#### UsageStatsPermissionResult\n\n| Prop          | Type                 | Description                                    |\n| ------------- | -------------------- | ---------------------------------------------- |\n| **`granted`** | \u003ccode\u003eboolean\u003c/code\u003e | Whether the usage stats permission is granted. |\n\n\n#### PackageInfo\n\nRepresents basic information about an installed package.\n\n| Prop                   | Type                |\n| ---------------------- | ------------------- |\n| **`packageName`**      | \u003ccode\u003estring\u003c/code\u003e |\n| **`appName`**          | \u003ccode\u003estring\u003c/code\u003e |\n| **`versionName`**      | \u003ccode\u003estring\u003c/code\u003e |\n| **`versionCode`**      | \u003ccode\u003enumber\u003c/code\u003e |\n| **`firstInstallTime`** | \u003ccode\u003enumber\u003c/code\u003e |\n| **`lastUpdateTime`**   | \u003ccode\u003enumber\u003c/code\u003e |\n\n\n### Type Aliases\n\n\n#### Record\n\nConstruct a type with a set of properties K of type T\n\n\u003ccode\u003e{\r [P in K]: T;\r }\u003c/code\u003e\n\n\u003c/docgen-api\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCap-go%2Fcapacitor-android-usagestatsmanager","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FCap-go%2Fcapacitor-android-usagestatsmanager","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FCap-go%2Fcapacitor-android-usagestatsmanager/lists"}