API 參考
應用程式
透過 app.capabilities 判斷功能支援,透過 app.access 和主機權限判斷存取授權。範例使用合成值;呼叫前請替換路徑、ID、輸入和篩選條件。
型別定義
graphql
type Mutation {
clearAppCache: Boolean!
restartHttpServer(httpPort: Int, httpsPort: Int): HttpServerState!
relaunchApp: Boolean!
requestAccess(feature: AccessFeature!): Boolean!
setTempValue(key: String!, value: String!): KeyValuePair!
updateDeviceName(name: String!): Boolean!
}
type Query {
appCacheSize: Long!
appUpdate: AppUpdate!
httpServer: HttpServer!
app: App!
}
type Subscription {
httpServerChanged: HttpServer!
deviceNameUpdated: String!
accessUpdated: Boolean!
contentChanged: Boolean!
}
enum AccessFeature {
IMAGES
VIDEOS
AUDIO
DOCS
FILES
CONTACTS
SMS
CALLS
CALL_PHONE
PHONE_NUMBER
APPS
NOTIFICATIONS
CLIPBOARD
ADB
}
type App {
clientId: ID!
httpPort: Int!
httpsPort: Int!
deviceName: String!
developerMode: Boolean!
urlToken: String!
tlsCertificateSha256: String
appDir: String!
deviceType: DeviceType!
capabilities: [Capability!]!
buildChannel: AppChannelType!
access: [AccessFeature!]!
downloadsDir: String!
debug: Boolean!
}
enum AppChannelType {
GITHUB
GOOGLE
FDROID
}
type AppUpdate {
currentVersion: String!
latestVersion: String
releaseName: String!
publishedAt: Instant
hasUpdate: Boolean!
url: String
}
enum Capability {
ADB
BLE
WIFI_AWARE
APP_RELAUNCH
MEDIA_TRASH
MEDIA_DELETE
MEDIA_MOVE
MEDIA_FAVORITE
APP_UPDATES
MIRROR_AUDIO
MEDIA_SCAN
TELEPHONY
PACKAGES
SCREEN_MIRROR
NOTIFICATIONS
CLIPBOARD
DISK_MANAGER
HTTP_SERVER
}
enum DeviceType {
COMPUTER
PHONE
TABLET
TV
NAS
OTHER
}
type HttpServer {
state: HttpServerState!
addresses: [String!]!
onlineClients: [ID!]!
remoteAccess: Boolean!
mdnsHostname: String!
}
type HttpServerState {
revision: Long!
restarting: Boolean!
httpPort: Int!
httpsPort: Int!
error: String!
}
scalar Instant
type KeyValuePair {
key: String!
value: String!
}
scalar Long操作
mutation
clearAppCache
刪除可隨時重建的應用程式快取檔案。
graphql
mutation clearAppCache {
clearAppCache
}mutation
restartHttpServer
修改 HTTP/HTTPS 連接埠並等待新接聽程式就緒。需要 HTTP_SERVER 能力。傳回實際連接埠;目前位址變更後請重新連線。
graphql
mutation restartHttpServer($httpPort: Int, $httpsPort: Int) {
restartHttpServer(httpPort: $httpPort, httpsPort: $httpsPort) { revision restarting httpPort httpsPort error }
}query
appCacheSize
回傳應用程式快取佔用的位元組數。
graphql
query appCacheSize {
appCacheSize
}query
appUpdate
讀取可用的應用程式更新資訊。
graphql
query appUpdate {
appUpdate { currentVersion latestVersion releaseName publishedAt hasUpdate url }
}query
httpServer
讀取 HTTP/HTTPS 服務狀態、區域網路位址、線上用戶端與遠端存取狀態。需要已驗證的呼叫端及 HTTP_SERVER 能力。
graphql
query httpServer {
httpServer { addresses onlineClients remoteAccess mdnsHostname }
}subscription
httpServerChanged
訂閱接入時,以及監聽器、網路、線上用戶端或設定變更後,接收 HTTP 服務的目前快照。需要已驗證的呼叫者與 HTTP_SERVER 支援。離開頁面時取消訂閱,返回時重新訂閱。
graphql
subscription httpServerChanged {
httpServerChanged { addresses onlineClients remoteAccess mdnsHostname }
}subscription
deviceNameUpdated
接收更新後的裝置顯示名稱。
graphql
subscription deviceNameUpdated {
deviceNameUpdated
}subscription
accessUpdated
接收裝置功能授權變更訊號。
graphql
subscription accessUpdated {
accessUpdated
}subscription
contentChanged
接收已儲存內容的變更訊號。
graphql
subscription contentChanged {
contentChanged
}mutation
relaunchApp
重啟裝置上的 PlainApp 進程。
graphql
# The app restarts itself; the response only acknowledges that the
# request was accepted, since the connection dies with the process.
mutation relaunchApp {
relaunchApp
}mutation
requestAccess
為支援的功能申請裝置授權;可能需要使用者在裝置上操作。
graphql
mutation requestAccess($feature: AccessFeature!) {
requestAccess(feature: $feature)
}mutation
setTempValue
設定並回傳臨時記憶體鍵值對,不寫入持久化 Key Value 資料。
graphql
mutation setTempValue($key: String!, $value: String!) {
setTempValue(key: $key, value: $value) { key value }
}mutation
updateDeviceName
修改 Web 介面顯示的裝置名稱,並向已配對裝置廣播。
graphql
# Renaming the device also re-publishes the mDNS advertisement, so a
# client that waits for the new name to appear does see it.
mutation updateDeviceName($name: String!) {
updateDeviceName(name: $name)
}query
app
讀取應用程式識別、設定、能力與授權資訊。app.urlToken 屬於目前呼叫的工作階段,用於加密資源連結,不是 GraphQL 認證 token。
graphql
# Everything a client needs to reach this device: its identity, the
# port it listens on and the token that authorises it.
query app {
app { clientId httpPort httpsPort deviceName developerMode urlToken tlsCertificateSha256 appDir }
}