add simple check to detect android tv
keypair34 committed
Aug 18, 2025 at 09:42 UTC
746fbae317a87fcb21df77e444b3940ec17c971a
18 files changed
+173
-237
Cargo.toml
+4
-4
@@ -1,12 +1,12 @@
1
[package]
2
-name = "tauri-plugin-android-tv-check"
2
+name = "tauri-plugin-androidtvcheck"
3
version = "0.1.0"
4
-authors = [ "You" ]
5
-description = ""
4
+authors = ["setoelkahfi@gmail.com"]
5
+description = "A Tauri plugin for checking Android TV devices."
6
edition = "2021"
7
rust-version = "1.77.2"
8
exclude = ["/examples", "/dist-js", "/guest-js", "/node_modules"]
9
-links = "tauri-plugin-android-tv-check"
9
+links = "tauri-plugin-androidtvcheck"
10
11
[dependencies]
12
tauri = { version = "2.6.2" }
android/local.properties
+2
-2
@@ -4,5 +4,5 @@
4
# Location of the SDK. This is only used by Gradle.
5
# For customization when using a Version Control System, please read the
6
# header note.
7
-#Fri Jul 18 19:37:59 CEST 2025
8
-sdk.dir=/Users/setoelka/Library/Android/sdk
7
+#Sun Aug 17 20:26:12 CEST 2025
8
+sdk.dir=/Users/setoelkahfi/Library/Android/sdk
android/src/main/java/AndroidTvCheckPlugin.kt
+8
-28
@@ -1,6 +1,7 @@
1
package com.plugin.androidTvCheck
2
3
import android.app.Activity
4
+import android.content.pm.PackageManager
5
import android.util.Log
6
import app.tauri.annotation.Command
7
import app.tauri.annotation.InvokeArg
@@ -9,39 +10,18 @@ import app.tauri.plugin.Invoke
10
import app.tauri.plugin.JSObject
11
import app.tauri.plugin.Plugin
12
12
-@InvokeArg
13
-class PingArgs {
14
- var value: String? = null
15
-}
16
-
13
@TauriPlugin
14
class AndroidTvCheckPlugin(private val activity: Activity) : Plugin(activity) {
19
- private val implementation = Example()
20
-
21
- @Command
22
- fun ping(invoke: Invoke) {
23
- val args = invoke.parseArgs(PingArgs::class.java)
24
-
25
- val ret = JSObject()
26
- ret.put("value", implementation.pong(args.value ?: "default value :("))
27
- invoke.resolve(ret)
28
- }
29
-
15
@Command
16
fun check(invoke: Invoke) {
17
val TAG = "DeviceTypeRuntimeCheck"
18
34
- val isTelevision = false
35
- if (isTelevision) {
36
- Log.d(TAG, "Running on a TV Device")
37
- val ret = JSObject()
38
- ret.put("value", implementation.pong("default value :("))
39
- invoke.resolve(ret)
40
- } else {
41
- Log.d(TAG, "Running on a non-TV Device")
42
- val ret = JSObject()
43
- ret.put("value", implementation.pong("default value :("))
44
- invoke.resolve(ret)
45
- }
19
+ val isTelevision = activity.packageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK)
20
+
21
+ Log.d(TAG, if (isTelevision) "Running on a TV Device" else "Running on a non-TV Device")
22
+
23
+ val ret = JSObject()
24
+ ret.put("is_android_tv", isTelevision)
25
+ invoke.resolve(ret)
26
}
27
}
android/src/main/java/Example.kt
deleted
-10
@@ -1,10 +0,0 @@
1
-package com.plugin.androidTvCheck
2
-
3
-import android.util.Log
4
-
5
-class Example {
6
- fun pong(value: String): String {
7
- Log.i("Pong", value)
8
- return value
9
- }
10
-}
build.rs
+5
-5
@@ -1,8 +1,8 @@
1
-const COMMANDS: &[&str] = &["ping"];
1
+const COMMANDS: &[&str] = &["check"];
2
3
fn main() {
4
- tauri_plugin::Builder::new(COMMANDS)
5
- .android_path("android")
6
- .ios_path("ios")
7
- .build();
4
+ tauri_plugin::Builder::new(COMMANDS)
5
+ .android_path("android")
6
+ .ios_path("ios")
7
+ .build();
8
}
guest-js/index.ts
+1
-9
@@ -1,15 +1,7 @@
1
import { invoke } from "@tauri-apps/api/core";
2
3
-export async function ping(value: string): Promise<string | null> {
4
- return await invoke<{ value?: string }>("plugin:android-tv-check|ping", {
5
- payload: {
6
- value,
7
- },
8
- }).then((r) => (r.value ? r.value : null));
9
-}
10
-
3
export async function check(): Promise<string | null> {
12
- return await invoke<{ value?: string }>("plugin:android-tv-check|check").then(
4
+ return await invoke<{ value?: string }>("plugin:androidtvcheck|check").then(
5
(r) => (r.value ? r.value : null),
6
);
7
}
package.json
+7
-7
@@ -1,7 +1,7 @@
1
{
2
- "name": "tauri-plugin-android-tv-check-api",
2
+ "name": "tauri-plugin-androidtvcheck-api",
3
"version": "0.1.0",
4
- "author": "You",
4
+ "author": "setoelkahfi@gmail.com",
5
"description": "",
6
"type": "module",
7
"types": "./dist-js/index.d.ts",
@@ -22,12 +22,12 @@
22
"pretest": "pnpm build"
23
},
24
"dependencies": {
25
- "@tauri-apps/api": ">=2.0.0-beta.6"
25
+ "@tauri-apps/api": "^2.7.0"
26
},
27
"devDependencies": {
28
- "@rollup/plugin-typescript": "^12.0.0",
29
- "rollup": "^4.9.6",
30
- "typescript": "^5.3.3",
31
- "tslib": "^2.6.2"
28
+ "@rollup/plugin-typescript": "^12.1.4",
29
+ "rollup": "^4.46.3",
30
+ "tslib": "^2.8.1",
31
+ "typescript": "^5.9.2"
32
}
33
}
permissions/autogenerated/commands/check.toml
new
+13
@@ -0,0 +1,13 @@
1
+# Automatically generated - DO NOT EDIT!
2
+
3
+"$schema" = "../../schemas/schema.json"
4
+
5
+[[permission]]
6
+identifier = "allow-check"
7
+description = "Enables the check command without any pre-configured scope."
8
+commands.allow = ["check"]
9
+
10
+[[permission]]
11
+identifier = "deny-check"
12
+description = "Denies the check command without any pre-configured scope."
13
+commands.deny = ["check"]
permissions/autogenerated/commands/ping.toml
deleted
-13
@@ -1,13 +0,0 @@
1
-# Automatically generated - DO NOT EDIT!
2
-
3
-"$schema" = "../../schemas/schema.json"
4
-
5
-[[permission]]
6
-identifier = "allow-ping"
7
-description = "Enables the ping command without any pre-configured scope."
8
-commands.allow = ["ping"]
9
-
10
-[[permission]]
11
-identifier = "deny-ping"
12
-description = "Denies the ping command without any pre-configured scope."
13
-commands.deny = ["ping"]
permissions/autogenerated/reference.md
+5
-5
@@ -4,7 +4,7 @@ Default permissions for the plugin
4
5
#### This default permission set includes the following:
6
7
-- `allow-ping`
7
+- `allow-check`
8
9
## Permission Table
10
@@ -18,12 +18,12 @@ Default permissions for the plugin
18
<tr>
19
<td>
20
21
-`android-tv-check:allow-ping`
21
+`androidtvcheck:allow-check`
22
23
</td>
24
<td>
25
26
-Enables the ping command without any pre-configured scope.
26
+Enables the check command without any pre-configured scope.
27
28
</td>
29
</tr>
@@ -31,12 +31,12 @@ Enables the ping command without any pre-configured scope.
31
<tr>
32
<td>
33
34
-`android-tv-check:deny-ping`
34
+`androidtvcheck:deny-check`
35
36
</td>
37
<td>
38
39
-Denies the ping command without any pre-configured scope.
39
+Denies the check command without any pre-configured scope.
40
41
</td>
42
</tr>
permissions/default.toml
+1
-1
@@ -1,3 +1,3 @@
1
[default]
2
description = "Default permissions for the plugin"
3
-permissions = ["allow-ping"]
3
+permissions = ["allow-check"]
permissions/schemas/schema.json
+8
-8
@@ -295,22 +295,22 @@
295
"type": "string",
296
"oneOf": [
297
{
298
- "description": "Enables the ping command without any pre-configured scope.",
298
+ "description": "Enables the check command without any pre-configured scope.",
299
"type": "string",
300
- "const": "allow-ping",
301
- "markdownDescription": "Enables the ping command without any pre-configured scope."
300
+ "const": "allow-check",
301
+ "markdownDescription": "Enables the check command without any pre-configured scope."
302
},
303
{
304
- "description": "Denies the ping command without any pre-configured scope.",
304
+ "description": "Denies the check command without any pre-configured scope.",
305
"type": "string",
306
- "const": "deny-ping",
307
- "markdownDescription": "Denies the ping command without any pre-configured scope."
306
+ "const": "deny-check",
307
+ "markdownDescription": "Denies the check command without any pre-configured scope."
308
},
309
{
310
- "description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-ping`",
310
+ "description": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-check`",
311
"type": "string",
312
"const": "default",
313
- "markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-ping`"
313
+ "markdownDescription": "Default permissions for the plugin\n#### This default permission set includes:\n\n- `allow-check`"
314
}
315
]
316
}
pnpm-lock.yaml
+104
-104
@@ -9,21 +9,21 @@ importers:
9
.:
10
dependencies:
11
'@tauri-apps/api':
12
- specifier: '>=2.0.0-beta.6'
13
- version: 2.6.0
12
+ specifier: ^2.7.0
13
+ version: 2.7.0
14
devDependencies:
15
'@rollup/plugin-typescript':
16
- specifier: ^12.0.0
17
- version: 12.1.4(rollup@4.45.1)(tslib@2.8.1)(typescript@5.8.3)
16
+ specifier: ^12.1.4
17
+ version: 12.1.4(rollup@4.46.3)(tslib@2.8.1)(typescript@5.9.2)
18
rollup:
19
- specifier: ^4.9.6
20
- version: 4.45.1
19
+ specifier: ^4.46.3
20
+ version: 4.46.3
21
tslib:
22
- specifier: ^2.6.2
22
+ specifier: ^2.8.1
23
version: 2.8.1
24
typescript:
25
- specifier: ^5.3.3
26
- version: 5.8.3
25
+ specifier: ^5.9.2
26
+ version: 5.9.2
27
28
packages:
29
@@ -49,108 +49,108 @@ packages:
49
rollup:
50
optional: true
51
52
- '@rollup/rollup-android-arm-eabi@4.45.1':
53
- resolution: {integrity: sha512-NEySIFvMY0ZQO+utJkgoMiCAjMrGvnbDLHvcmlA33UXJpYBCvlBEbMMtV837uCkS+plG2umfhn0T5mMAxGrlRA==}
52
+ '@rollup/rollup-android-arm-eabi@4.46.3':
53
+ resolution: {integrity: sha512-UmTdvXnLlqQNOCJnyksjPs1G4GqXNGW1LrzCe8+8QoaLhhDeTXYBgJ3k6x61WIhlHX2U+VzEJ55TtIjR/HTySA==}
54
cpu: [arm]
55
os: [android]
56
57
- '@rollup/rollup-android-arm64@4.45.1':
58
- resolution: {integrity: sha512-ujQ+sMXJkg4LRJaYreaVx7Z/VMgBBd89wGS4qMrdtfUFZ+TSY5Rs9asgjitLwzeIbhwdEhyj29zhst3L1lKsRQ==}
57
+ '@rollup/rollup-android-arm64@4.46.3':
58
+ resolution: {integrity: sha512-8NoxqLpXm7VyeI0ocidh335D6OKT0UJ6fHdnIxf3+6oOerZZc+O7r+UhvROji6OspyPm+rrIdb1gTXtVIqn+Sg==}
59
cpu: [arm64]
60
os: [android]
61
62
- '@rollup/rollup-darwin-arm64@4.45.1':
63
- resolution: {integrity: sha512-FSncqHvqTm3lC6Y13xncsdOYfxGSLnP+73k815EfNmpewPs+EyM49haPS105Rh4aF5mJKywk9X0ogzLXZzN9lA==}
62
+ '@rollup/rollup-darwin-arm64@4.46.3':
63
+ resolution: {integrity: sha512-csnNavqZVs1+7/hUKtgjMECsNG2cdB8F7XBHP6FfQjqhjF8rzMzb3SLyy/1BG7YSfQ+bG75Ph7DyedbUqwq1rA==}
64
cpu: [arm64]
65
os: [darwin]
66
67
- '@rollup/rollup-darwin-x64@4.45.1':
68
- resolution: {integrity: sha512-2/vVn/husP5XI7Fsf/RlhDaQJ7x9zjvC81anIVbr4b/f0xtSmXQTFcGIQ/B1cXIYM6h2nAhJkdMHTnD7OtQ9Og==}
67
+ '@rollup/rollup-darwin-x64@4.46.3':
68
+ resolution: {integrity: sha512-r2MXNjbuYabSIX5yQqnT8SGSQ26XQc8fmp6UhlYJd95PZJkQD1u82fWP7HqvGUf33IsOC6qsiV+vcuD4SDP6iw==}
69
cpu: [x64]
70
os: [darwin]
71
72
- '@rollup/rollup-freebsd-arm64@4.45.1':
73
- resolution: {integrity: sha512-4g1kaDxQItZsrkVTdYQ0bxu4ZIQ32cotoQbmsAnW1jAE4XCMbcBPDirX5fyUzdhVCKgPcrwWuucI8yrVRBw2+g==}
72
+ '@rollup/rollup-freebsd-arm64@4.46.3':
73
+ resolution: {integrity: sha512-uluObTmgPJDuJh9xqxyr7MV61Imq+0IvVsAlWyvxAaBSNzCcmZlhfYcRhCdMaCsy46ccZa7vtDDripgs9Jkqsw==}
74
cpu: [arm64]
75
os: [freebsd]
76
77
- '@rollup/rollup-freebsd-x64@4.45.1':
78
- resolution: {integrity: sha512-L/6JsfiL74i3uK1Ti2ZFSNsp5NMiM4/kbbGEcOCps99aZx3g8SJMO1/9Y0n/qKlWZfn6sScf98lEOUe2mBvW9A==}
77
+ '@rollup/rollup-freebsd-x64@4.46.3':
78
+ resolution: {integrity: sha512-AVJXEq9RVHQnejdbFvh1eWEoobohUYN3nqJIPI4mNTMpsyYN01VvcAClxflyk2HIxvLpRcRggpX1m9hkXkpC/A==}
79
cpu: [x64]
80
os: [freebsd]
81
82
- '@rollup/rollup-linux-arm-gnueabihf@4.45.1':
83
- resolution: {integrity: sha512-RkdOTu2jK7brlu+ZwjMIZfdV2sSYHK2qR08FUWcIoqJC2eywHbXr0L8T/pONFwkGukQqERDheaGTeedG+rra6Q==}
82
+ '@rollup/rollup-linux-arm-gnueabihf@4.46.3':
83
+ resolution: {integrity: sha512-byyflM+huiwHlKi7VHLAYTKr67X199+V+mt1iRgJenAI594vcmGGddWlu6eHujmcdl6TqSNnvqaXJqZdnEWRGA==}
84
cpu: [arm]
85
os: [linux]
86
87
- '@rollup/rollup-linux-arm-musleabihf@4.45.1':
88
- resolution: {integrity: sha512-3kJ8pgfBt6CIIr1o+HQA7OZ9mp/zDk3ctekGl9qn/pRBgrRgfwiffaUmqioUGN9hv0OHv2gxmvdKOkARCtRb8Q==}
87
+ '@rollup/rollup-linux-arm-musleabihf@4.46.3':
88
+ resolution: {integrity: sha512-aLm3NMIjr4Y9LklrH5cu7yybBqoVCdr4Nvnm8WB7PKCn34fMCGypVNpGK0JQWdPAzR/FnoEoFtlRqZbBBLhVoQ==}
89
cpu: [arm]
90
os: [linux]
91
92
- '@rollup/rollup-linux-arm64-gnu@4.45.1':
93
- resolution: {integrity: sha512-k3dOKCfIVixWjG7OXTCOmDfJj3vbdhN0QYEqB+OuGArOChek22hn7Uy5A/gTDNAcCy5v2YcXRJ/Qcnm4/ma1xw==}
92
+ '@rollup/rollup-linux-arm64-gnu@4.46.3':
93
+ resolution: {integrity: sha512-VtilE6eznJRDIoFOzaagQodUksTEfLIsvXymS+UdJiSXrPW7Ai+WG4uapAc3F7Hgs791TwdGh4xyOzbuzIZrnw==}
94
cpu: [arm64]
95
os: [linux]
96
97
- '@rollup/rollup-linux-arm64-musl@4.45.1':
98
- resolution: {integrity: sha512-PmI1vxQetnM58ZmDFl9/Uk2lpBBby6B6rF4muJc65uZbxCs0EA7hhKCk2PKlmZKuyVSHAyIw3+/SiuMLxKxWog==}
97
+ '@rollup/rollup-linux-arm64-musl@4.46.3':
98
+ resolution: {integrity: sha512-dG3JuS6+cRAL0GQ925Vppafi0qwZnkHdPeuZIxIPXqkCLP02l7ka+OCyBoDEv8S+nKHxfjvjW4OZ7hTdHkx8/w==}
99
cpu: [arm64]
100
os: [linux]
101
102
- '@rollup/rollup-linux-loongarch64-gnu@4.45.1':
103
- resolution: {integrity: sha512-9UmI0VzGmNJ28ibHW2GpE2nF0PBQqsyiS4kcJ5vK+wuwGnV5RlqdczVocDSUfGX/Na7/XINRVoUgJyFIgipoRg==}
102
+ '@rollup/rollup-linux-loongarch64-gnu@4.46.3':
103
+ resolution: {integrity: sha512-iU8DxnxEKJptf8Vcx4XvAUdpkZfaz0KWfRrnIRrOndL0SvzEte+MTM7nDH4A2Now4FvTZ01yFAgj6TX/mZl8hQ==}
104
cpu: [loong64]
105
os: [linux]
106
107
- '@rollup/rollup-linux-powerpc64le-gnu@4.45.1':
108
- resolution: {integrity: sha512-7nR2KY8oEOUTD3pBAxIBBbZr0U7U+R9HDTPNy+5nVVHDXI4ikYniH1oxQz9VoB5PbBU1CZuDGHkLJkd3zLMWsg==}
107
+ '@rollup/rollup-linux-ppc64-gnu@4.46.3':
108
+ resolution: {integrity: sha512-VrQZp9tkk0yozJoQvQcqlWiqaPnLM6uY1qPYXvukKePb0fqaiQtOdMJSxNFUZFsGw5oA5vvVokjHrx8a9Qsz2A==}
109
cpu: [ppc64]
110
os: [linux]
111
112
- '@rollup/rollup-linux-riscv64-gnu@4.45.1':
113
- resolution: {integrity: sha512-nlcl3jgUultKROfZijKjRQLUu9Ma0PeNv/VFHkZiKbXTBQXhpytS8CIj5/NfBeECZtY2FJQubm6ltIxm/ftxpw==}
112
+ '@rollup/rollup-linux-riscv64-gnu@4.46.3':
113
+ resolution: {integrity: sha512-uf2eucWSUb+M7b0poZ/08LsbcRgaDYL8NCGjUeFMwCWFwOuFcZ8D9ayPl25P3pl+D2FH45EbHdfyUesQ2Lt9wA==}
114
cpu: [riscv64]
115
os: [linux]
116
117
- '@rollup/rollup-linux-riscv64-musl@4.45.1':
118
- resolution: {integrity: sha512-HJV65KLS51rW0VY6rvZkiieiBnurSzpzore1bMKAhunQiECPuxsROvyeaot/tcK3A3aGnI+qTHqisrpSgQrpgA==}
117
+ '@rollup/rollup-linux-riscv64-musl@4.46.3':
118
+ resolution: {integrity: sha512-7tnUcDvN8DHm/9ra+/nF7lLzYHDeODKKKrh6JmZejbh1FnCNZS8zMkZY5J4sEipy2OW1d1Ncc4gNHUd0DLqkSg==}
119
cpu: [riscv64]
120
os: [linux]
121
122
- '@rollup/rollup-linux-s390x-gnu@4.45.1':
123
- resolution: {integrity: sha512-NITBOCv3Qqc6hhwFt7jLV78VEO/il4YcBzoMGGNxznLgRQf43VQDae0aAzKiBeEPIxnDrACiMgbqjuihx08OOw==}
122
+ '@rollup/rollup-linux-s390x-gnu@4.46.3':
123
+ resolution: {integrity: sha512-MUpAOallJim8CsJK+4Lc9tQzlfPbHxWDrGXZm2z6biaadNpvh3a5ewcdat478W+tXDoUiHwErX/dOql7ETcLqg==}
124
cpu: [s390x]
125
os: [linux]
126
127
- '@rollup/rollup-linux-x64-gnu@4.45.1':
128
- resolution: {integrity: sha512-+E/lYl6qu1zqgPEnTrs4WysQtvc/Sh4fC2nByfFExqgYrqkKWp1tWIbe+ELhixnenSpBbLXNi6vbEEJ8M7fiHw==}
127
+ '@rollup/rollup-linux-x64-gnu@4.46.3':
128
+ resolution: {integrity: sha512-F42IgZI4JicE2vM2PWCe0N5mR5vR0gIdORPqhGQ32/u1S1v3kLtbZ0C/mi9FFk7C5T0PgdeyWEPajPjaUpyoKg==}
129
cpu: [x64]
130
os: [linux]
131
132
- '@rollup/rollup-linux-x64-musl@4.45.1':
133
- resolution: {integrity: sha512-a6WIAp89p3kpNoYStITT9RbTbTnqarU7D8N8F2CV+4Cl9fwCOZraLVuVFvlpsW0SbIiYtEnhCZBPLoNdRkjQFw==}
132
+ '@rollup/rollup-linux-x64-musl@4.46.3':
133
+ resolution: {integrity: sha512-oLc+JrwwvbimJUInzx56Q3ujL3Kkhxehg7O1gWAYzm8hImCd5ld1F2Gry5YDjR21MNb5WCKhC9hXgU7rRlyegQ==}
134
cpu: [x64]
135
os: [linux]
136
137
- '@rollup/rollup-win32-arm64-msvc@4.45.1':
138
- resolution: {integrity: sha512-T5Bi/NS3fQiJeYdGvRpTAP5P02kqSOpqiopwhj0uaXB6nzs5JVi2XMJb18JUSKhCOX8+UE1UKQufyD6Or48dJg==}
137
+ '@rollup/rollup-win32-arm64-msvc@4.46.3':
138
+ resolution: {integrity: sha512-lOrQ+BVRstruD1fkWg9yjmumhowR0oLAAzavB7yFSaGltY8klttmZtCLvOXCmGE9mLIn8IBV/IFrQOWz5xbFPg==}
139
cpu: [arm64]
140
os: [win32]
141
142
- '@rollup/rollup-win32-ia32-msvc@4.45.1':
143
- resolution: {integrity: sha512-lxV2Pako3ujjuUe9jiU3/s7KSrDfH6IgTSQOnDWr9aJ92YsFd7EurmClK0ly/t8dzMkDtd04g60WX6yl0sGfdw==}
142
+ '@rollup/rollup-win32-ia32-msvc@4.46.3':
143
+ resolution: {integrity: sha512-vvrVKPRS4GduGR7VMH8EylCBqsDcw6U+/0nPDuIjXQRbHJc6xOBj+frx8ksfZAh6+Fptw5wHrN7etlMmQnPQVg==}
144
cpu: [ia32]
145
os: [win32]
146
147
- '@rollup/rollup-win32-x64-msvc@4.45.1':
148
- resolution: {integrity: sha512-M/fKi4sasCdM8i0aWJjCSFm2qEnYRR8AMLG2kxp6wD13+tMGA4Z1tVAuHkNRjud5SW2EM3naLuK35w9twvf6aA==}
147
+ '@rollup/rollup-win32-x64-msvc@4.46.3':
148
+ resolution: {integrity: sha512-fi3cPxCnu3ZeM3EwKZPgXbWoGzm2XHgB/WShKI81uj8wG0+laobmqy5wbgEwzstlbLu4MyO8C19FyhhWseYKNQ==}
149
cpu: [x64]
150
os: [win32]
151
152
- '@tauri-apps/api@2.6.0':
153
- resolution: {integrity: sha512-hRNcdercfgpzgFrMXWwNDBN0B7vNzOzRepy6ZAmhxi5mDLVPNrTpo9MGg2tN/F7JRugj4d2aF7E1rtPXAHaetg==}
152
+ '@tauri-apps/api@2.7.0':
153
+ resolution: {integrity: sha512-v7fVE8jqBl8xJFOcBafDzXFc8FnicoH3j8o8DNNs0tHuEBmXUDqrCOAzMRX0UkfpwqZLqvrvK0GNQ45DfnoVDg==}
154
155
'@types/estree@1.0.8':
156
resolution: {integrity: sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==}
@@ -186,8 +186,8 @@ packages:
186
engines: {node: '>= 0.4'}
187
hasBin: true
188
189
- rollup@4.45.1:
190
- resolution: {integrity: sha512-4iya7Jb76fVpQyLoiVpzUrsjQ12r3dM7fIVz+4NwoYvZOShknRmiv+iu9CClZml5ZLGb0XMcYLutK6w9tgxHDw==}
189
+ rollup@4.46.3:
190
+ resolution: {integrity: sha512-RZn2XTjXb8t5g13f5YclGoilU/kwT696DIkY3sywjdZidNSi3+vseaQov7D7BZXVJCPv3pDWUN69C78GGbXsKw==}
191
engines: {node: '>=18.0.0', npm: '>=8.0.0'}
192
hasBin: true
193
@@ -198,91 +198,91 @@ packages:
198
tslib@2.8.1:
199
resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==}
200
201
- typescript@5.8.3:
202
- resolution: {integrity: sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==}
201
+ typescript@5.9.2:
202
+ resolution: {integrity: sha512-CWBzXQrc/qOkhidw1OzBTQuYRbfyxDXJMVJ1XNwUHGROVmuaeiEm3OslpZ1RV96d7SKKjZKrSJu3+t/xlw3R9A==}
203
engines: {node: '>=14.17'}
204
hasBin: true
205
206
snapshots:
207
208
- '@rollup/plugin-typescript@12.1.4(rollup@4.45.1)(tslib@2.8.1)(typescript@5.8.3)':
208
+ '@rollup/plugin-typescript@12.1.4(rollup@4.46.3)(tslib@2.8.1)(typescript@5.9.2)':
209
dependencies:
210
- '@rollup/pluginutils': 5.2.0(rollup@4.45.1)
210
+ '@rollup/pluginutils': 5.2.0(rollup@4.46.3)
211
resolve: 1.22.10
212
- typescript: 5.8.3
212
+ typescript: 5.9.2
213
optionalDependencies:
214
- rollup: 4.45.1
214
+ rollup: 4.46.3
215
tslib: 2.8.1
216
217
- '@rollup/pluginutils@5.2.0(rollup@4.45.1)':
217
+ '@rollup/pluginutils@5.2.0(rollup@4.46.3)':
218
dependencies:
219
'@types/estree': 1.0.8
220
estree-walker: 2.0.2
221
picomatch: 4.0.3
222
optionalDependencies:
223
- rollup: 4.45.1
223
+ rollup: 4.46.3
224
225
- '@rollup/rollup-android-arm-eabi@4.45.1':
225
+ '@rollup/rollup-android-arm-eabi@4.46.3':
226
optional: true
227
228
- '@rollup/rollup-android-arm64@4.45.1':
228
+ '@rollup/rollup-android-arm64@4.46.3':
229
optional: true
230
231
- '@rollup/rollup-darwin-arm64@4.45.1':
231
+ '@rollup/rollup-darwin-arm64@4.46.3':
232
optional: true
233
234
- '@rollup/rollup-darwin-x64@4.45.1':
234
+ '@rollup/rollup-darwin-x64@4.46.3':
235
optional: true
236
237
- '@rollup/rollup-freebsd-arm64@4.45.1':
237
+ '@rollup/rollup-freebsd-arm64@4.46.3':
238
optional: true
239
240
- '@rollup/rollup-freebsd-x64@4.45.1':
240
+ '@rollup/rollup-freebsd-x64@4.46.3':
241
optional: true
242
243
- '@rollup/rollup-linux-arm-gnueabihf@4.45.1':
243
+ '@rollup/rollup-linux-arm-gnueabihf@4.46.3':
244
optional: true
245
246
- '@rollup/rollup-linux-arm-musleabihf@4.45.1':
246
+ '@rollup/rollup-linux-arm-musleabihf@4.46.3':
247
optional: true
248
249
- '@rollup/rollup-linux-arm64-gnu@4.45.1':
249
+ '@rollup/rollup-linux-arm64-gnu@4.46.3':
250
optional: true
251
252
- '@rollup/rollup-linux-arm64-musl@4.45.1':
252
+ '@rollup/rollup-linux-arm64-musl@4.46.3':
253
optional: true
254
255
- '@rollup/rollup-linux-loongarch64-gnu@4.45.1':
255
+ '@rollup/rollup-linux-loongarch64-gnu@4.46.3':
256
optional: true
257
258
- '@rollup/rollup-linux-powerpc64le-gnu@4.45.1':
258
+ '@rollup/rollup-linux-ppc64-gnu@4.46.3':
259
optional: true
260
261
- '@rollup/rollup-linux-riscv64-gnu@4.45.1':
261
+ '@rollup/rollup-linux-riscv64-gnu@4.46.3':
262
optional: true
263
264
- '@rollup/rollup-linux-riscv64-musl@4.45.1':
264
+ '@rollup/rollup-linux-riscv64-musl@4.46.3':
265
optional: true
266
267
- '@rollup/rollup-linux-s390x-gnu@4.45.1':
267
+ '@rollup/rollup-linux-s390x-gnu@4.46.3':
268
optional: true
269
270
- '@rollup/rollup-linux-x64-gnu@4.45.1':
270
+ '@rollup/rollup-linux-x64-gnu@4.46.3':
271
optional: true
272
273
- '@rollup/rollup-linux-x64-musl@4.45.1':
273
+ '@rollup/rollup-linux-x64-musl@4.46.3':
274
optional: true
275
276
- '@rollup/rollup-win32-arm64-msvc@4.45.1':
276
+ '@rollup/rollup-win32-arm64-msvc@4.46.3':
277
optional: true
278
279
- '@rollup/rollup-win32-ia32-msvc@4.45.1':
279
+ '@rollup/rollup-win32-ia32-msvc@4.46.3':
280
optional: true
281
282
- '@rollup/rollup-win32-x64-msvc@4.45.1':
282
+ '@rollup/rollup-win32-x64-msvc@4.46.3':
283
optional: true
284
285
- '@tauri-apps/api@2.6.0': {}
285
+ '@tauri-apps/api@2.7.0': {}
286
287
'@types/estree@1.0.8': {}
288
@@ -311,34 +311,34 @@ snapshots:
311
path-parse: 1.0.7
312
supports-preserve-symlinks-flag: 1.0.0
313
314
- rollup@4.45.1:
314
+ rollup@4.46.3:
315
dependencies:
316
'@types/estree': 1.0.8
317
optionalDependencies:
318
- '@rollup/rollup-android-arm-eabi': 4.45.1
319
- '@rollup/rollup-android-arm64': 4.45.1
320
- '@rollup/rollup-darwin-arm64': 4.45.1
321
- '@rollup/rollup-darwin-x64': 4.45.1
322
- '@rollup/rollup-freebsd-arm64': 4.45.1
323
- '@rollup/rollup-freebsd-x64': 4.45.1
324
- '@rollup/rollup-linux-arm-gnueabihf': 4.45.1
325
- '@rollup/rollup-linux-arm-musleabihf': 4.45.1
326
- '@rollup/rollup-linux-arm64-gnu': 4.45.1
327
- '@rollup/rollup-linux-arm64-musl': 4.45.1
328
- '@rollup/rollup-linux-loongarch64-gnu': 4.45.1
329
- '@rollup/rollup-linux-powerpc64le-gnu': 4.45.1
330
- '@rollup/rollup-linux-riscv64-gnu': 4.45.1
331
- '@rollup/rollup-linux-riscv64-musl': 4.45.1
332
- '@rollup/rollup-linux-s390x-gnu': 4.45.1
333
- '@rollup/rollup-linux-x64-gnu': 4.45.1
334
- '@rollup/rollup-linux-x64-musl': 4.45.1
335
- '@rollup/rollup-win32-arm64-msvc': 4.45.1
336
- '@rollup/rollup-win32-ia32-msvc': 4.45.1
337
- '@rollup/rollup-win32-x64-msvc': 4.45.1
318
+ '@rollup/rollup-android-arm-eabi': 4.46.3
319
+ '@rollup/rollup-android-arm64': 4.46.3
320
+ '@rollup/rollup-darwin-arm64': 4.46.3
321
+ '@rollup/rollup-darwin-x64': 4.46.3
322
+ '@rollup/rollup-freebsd-arm64': 4.46.3
323
+ '@rollup/rollup-freebsd-x64': 4.46.3
324
+ '@rollup/rollup-linux-arm-gnueabihf': 4.46.3
325
+ '@rollup/rollup-linux-arm-musleabihf': 4.46.3
326
+ '@rollup/rollup-linux-arm64-gnu': 4.46.3
327
+ '@rollup/rollup-linux-arm64-musl': 4.46.3
328
+ '@rollup/rollup-linux-loongarch64-gnu': 4.46.3
329
+ '@rollup/rollup-linux-ppc64-gnu': 4.46.3
330
+ '@rollup/rollup-linux-riscv64-gnu': 4.46.3
331
+ '@rollup/rollup-linux-riscv64-musl': 4.46.3
332
+ '@rollup/rollup-linux-s390x-gnu': 4.46.3
333
+ '@rollup/rollup-linux-x64-gnu': 4.46.3
334
+ '@rollup/rollup-linux-x64-musl': 4.46.3
335
+ '@rollup/rollup-win32-arm64-msvc': 4.46.3
336
+ '@rollup/rollup-win32-ia32-msvc': 4.46.3
337
+ '@rollup/rollup-win32-x64-msvc': 4.46.3
338
fsevents: 2.3.3
339
340
supports-preserve-symlinks-flag@1.0.0: {}
341
342
tslib@2.8.1: {}
343
344
- typescript@5.8.3: {}
344
+ typescript@5.9.2: {}
src/commands.rs
+7
-14
@@ -1,18 +1,11 @@
1
-use tauri::{command, AppHandle, Runtime};
2
-
3
-use crate::models::*;
4
-use crate::AndroidTvCheckExt;
5
-use crate::Result;
6
-
7
-#[command]
8
-pub(crate) async fn ping<R: Runtime>(
9
- app: AppHandle<R>,
10
- payload: PingRequest,
11
-) -> Result<PingResponse> {
12
- app.android_tv_check().ping(payload)
13
-}
1
+use {
2
+ crate::models::CheckResponse,
3
+ crate::AndroidTvCheckExt,
4
+ crate::Result,
5
+ tauri::{command, AppHandle, Runtime},
6
+};
7
8
#[command]
16
-pub(crate) async fn is_android_tv<R: Runtime>(app: AppHandle<R>) -> Result<bool> {
9
+pub(crate) async fn check<R: Runtime>(app: AppHandle<R>) -> Result<CheckResponse> {
10
app.android_tv_check().check()
11
}
src/desktop.rs
+3
-7
@@ -14,13 +14,9 @@ pub fn init<R: Runtime, C: DeserializeOwned>(
14
pub struct AndroidTvCheck<R: Runtime>(AppHandle<R>);
15
16
impl<R: Runtime> AndroidTvCheck<R> {
17
- pub fn ping(&self, payload: PingRequest) -> crate::Result<PingResponse> {
18
- Ok(PingResponse {
19
- value: payload.value,
17
+ pub fn check(&self) -> crate::Result<CheckResponse> {
18
+ Ok(CheckResponse {
19
+ is_android_tv: true,
20
})
21
}
22
-
23
- pub fn check(&self) -> crate::Result<bool> {
24
- Ok(true)
25
- }
22
}
src/lib.rs
+2
-5
@@ -34,11 +34,8 @@ impl<R: Runtime, T: Manager<R>> crate::AndroidTvCheckExt<R> for T {
34
35
/// Initializes the plugin.
36
pub fn init<R: Runtime>() -> TauriPlugin<R> {
37
- Builder::new("android-tv-check")
38
- .invoke_handler(tauri::generate_handler![
39
- commands::ping,
40
- commands::is_android_tv
41
- ])
37
+ Builder::new("androidtvcheck")
38
+ .invoke_handler(tauri::generate_handler![commands::check])
39
.setup(|app, api| {
40
#[cfg(mobile)]
41
let android_tv_check = mobile::init(app, api)?;
src/mobile.rs
+1
-7
@@ -25,13 +25,7 @@ pub fn init<R: Runtime, C: DeserializeOwned>(
25
pub struct AndroidTvCheck<R: Runtime>(PluginHandle<R>);
26
27
impl<R: Runtime> AndroidTvCheck<R> {
28
- pub fn ping(&self, payload: PingRequest) -> crate::Result<PingResponse> {
29
- self.0
30
- .run_mobile_plugin("ping", payload)
31
- .map_err(Into::into)
32
- }
33
-
34
- pub fn check(&self) -> crate::Result<bool> {
28
+ pub fn check(&self) -> crate::Result<CheckResponse> {
29
self.0.run_mobile_plugin("check", ()).map_err(Into::into)
30
}
31
}
src/models.rs
+2
-8
@@ -1,13 +1,7 @@
1
use serde::{Deserialize, Serialize};
2
3
-#[derive(Debug, Deserialize, Serialize)]
4
-#[serde(rename_all = "camelCase")]
5
-pub struct PingRequest {
6
- pub value: Option<String>,
7
-}
8
-
3
#[derive(Debug, Clone, Default, Deserialize, Serialize)]
4
#[serde(rename_all = "camelCase")]
11
-pub struct PingResponse {
12
- pub value: Option<String>,
5
+pub struct CheckResponse {
6
+ pub is_android_tv: bool,
7
}