-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
threadnetwork: Add stub implementation
- Loading branch information
Showing
20 changed files
with
682 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'signing' | ||
|
||
android { | ||
namespace "com.google.android.gms.threadnetwork" | ||
|
||
compileSdkVersion androidCompileSdk | ||
buildToolsVersion "$androidBuildVersionTools" | ||
|
||
buildFeatures { | ||
aidl = true | ||
} | ||
|
||
defaultConfig { | ||
versionName version | ||
minSdkVersion androidMinSdk | ||
targetSdkVersion androidTargetSdk | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = 1.8 | ||
targetCompatibility = 1.8 | ||
} | ||
} | ||
|
||
// Nothing to publish yet | ||
//apply from: '../gradle/publish-android.gradle' | ||
|
||
description = 'microG implementation of play-services-threadnetwork' | ||
|
||
dependencies { | ||
// Dependencies from play-services-threadnetwork:16.2.1 | ||
api project(':play-services-base') | ||
api project(':play-services-basement') | ||
api project(':play-services-tasks') | ||
|
||
annotationProcessor project(':safe-parcel-processor') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
apply plugin: 'com.android.library' | ||
apply plugin: 'kotlin-android' | ||
apply plugin: 'maven-publish' | ||
apply plugin: 'signing' | ||
|
||
dependencies { | ||
api project(':play-services-threadnetwork') | ||
|
||
implementation project(':play-services-base-core') | ||
implementation "androidx.annotation:annotation:$annotationVersion" | ||
} | ||
|
||
android { | ||
namespace "org.microg.gms.threadnetwork.core" | ||
|
||
compileSdkVersion androidCompileSdk | ||
buildToolsVersion "$androidBuildVersionTools" | ||
|
||
defaultConfig { | ||
versionName version | ||
minSdkVersion androidMinSdk | ||
targetSdkVersion androidTargetSdk | ||
} | ||
|
||
sourceSets { | ||
main { | ||
java.srcDirs += 'src/main/kotlin' | ||
} | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = 1.8 | ||
targetCompatibility = 1.8 | ||
} | ||
|
||
kotlinOptions { | ||
jvmTarget = 1.8 | ||
} | ||
} | ||
|
||
// Nothing to publish yet | ||
//apply from: '../../gradle/publish-android.gradle' | ||
|
||
description = 'microG service implementation for play-services-threadnetwork' |
16 changes: 16 additions & 0 deletions
16
play-services-threadnetwork/core/src/main/AndroidManifest.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="utf-8"?><!-- | ||
~ SPDX-FileCopyrightText: 2024 microG Project Team | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<application> | ||
<service | ||
android:name="org.microg.gms.threadnetwork.ThreadNetworkService" | ||
android:exported="true"> | ||
<intent-filter> | ||
<action android:name="com.google.android.gms.threadnetwork.service.START" /> | ||
</intent-filter> | ||
</service> | ||
</application> | ||
</manifest> |
95 changes: 95 additions & 0 deletions
95
...s-threadnetwork/core/src/main/kotlin/org/microg/gms/threadnetwork/ThreadNetworkService.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.microg.gms.threadnetwork | ||
|
||
import android.content.Context | ||
import android.util.Log | ||
import com.google.android.gms.common.ConnectionResult | ||
import com.google.android.gms.common.Feature | ||
import com.google.android.gms.common.api.CommonStatusCodes | ||
import com.google.android.gms.common.api.Status | ||
import com.google.android.gms.common.api.internal.IStatusCallback | ||
import com.google.android.gms.common.internal.ConnectionInfo | ||
import com.google.android.gms.common.internal.GetServiceRequest | ||
import com.google.android.gms.common.internal.IGmsCallbacks | ||
import com.google.android.gms.threadnetwork.ThreadBorderAgent | ||
import com.google.android.gms.threadnetwork.ThreadNetworkCredentials | ||
import com.google.android.gms.threadnetwork.ThreadNetworkStatusCodes | ||
import com.google.android.gms.threadnetwork.internal.* | ||
import org.microg.gms.BaseService | ||
import org.microg.gms.common.GmsService | ||
|
||
private const val TAG = "ThreadNetworkService" | ||
|
||
class ThreadNetworkService : BaseService(TAG, GmsService.THREAD_NETWORK) { | ||
override fun handleServiceRequest(callback: IGmsCallbacks, request: GetServiceRequest, service: GmsService) { | ||
val connectionInfo = ConnectionInfo() | ||
connectionInfo.features = arrayOf(Feature("threadnetwork", 8)) | ||
callback.onPostInitCompleteWithConnectionInfo( | ||
ConnectionResult.SUCCESS, ThreadNetworkServiceImpl(this, request.packageName).asBinder(), connectionInfo | ||
) | ||
} | ||
} | ||
|
||
class ThreadNetworkServiceImpl(private val context: Context, private val packageName: String) : IThreadNetworkService.Stub() { | ||
private val THREAD_NETWORK_NOT_FOUND = Status(ThreadNetworkStatusCodes.THREAD_NETWORK_NOT_FOUND, "THREAD_NETWORK_NOT_FOUND") | ||
|
||
override fun addCredentials(callback: IStatusCallback?, borderAgent: ThreadBorderAgent?, credentials: ThreadNetworkCredentials?) { | ||
if (borderAgent == null || credentials == null) { | ||
runCatching { callback?.onResult(Status(CommonStatusCodes.DEVELOPER_ERROR, "Illegal arguments")) } | ||
return | ||
} | ||
Log.d(TAG, "Not yet implemented: addCredentials") | ||
runCatching { callback?.onResult(Status.SUCCESS) } | ||
} | ||
|
||
override fun removeCredentials(callback: IStatusCallback?, borderAgent: ThreadBorderAgent?) { | ||
if (borderAgent == null) { | ||
runCatching { callback?.onResult(Status(CommonStatusCodes.DEVELOPER_ERROR, "Illegal arguments")) } | ||
return | ||
} | ||
Log.d(TAG, "Not yet implemented: removeCredentials") | ||
runCatching { callback?.onResult(Status.SUCCESS) } | ||
} | ||
|
||
override fun getAllCredentials(callbacks: IThreadNetworkServiceCallbacks?) { | ||
Log.d(TAG, "Not yet implemented: getAllCredentials") | ||
runCatching { callbacks?.onCredentials(Status.SUCCESS, emptyList()) } | ||
} | ||
|
||
override fun getCredentialsByExtendedPanId(callback: IGetCredentialsByExtendedPanIdCallback?, extendedPanId: ByteArray?) { | ||
if (extendedPanId == null) { | ||
runCatching { callback?.onCredentials(Status(CommonStatusCodes.DEVELOPER_ERROR, "Illegal arguments"), null) } | ||
return | ||
} | ||
Log.d(TAG, "Not yet implemented: getCredentialsByExtendedPanId") | ||
runCatching { callback?.onCredentials(THREAD_NETWORK_NOT_FOUND, null) } | ||
} | ||
|
||
override fun getCredentialsByBorderAgent(callbacks: IThreadNetworkServiceCallbacks?, borderAgent: ThreadBorderAgent?) { | ||
if (borderAgent == null) { | ||
runCatching { callbacks?.onCredentials(Status(CommonStatusCodes.DEVELOPER_ERROR, "Illegal arguments"), emptyList()) } | ||
return | ||
} | ||
Log.d(TAG, "Not yet implemented: getCredentialsByBorderAgent: $borderAgent") | ||
runCatching { callbacks?.onCredentials(Status.SUCCESS, emptyList()) } | ||
} | ||
|
||
override fun getPreferredCredentials(callback: IGetPreferredCredentialsCallback?) { | ||
Log.d(TAG, "Not yet implemented: getPreferredCredentials") | ||
runCatching { callback?.onPreferredCredentials(THREAD_NETWORK_NOT_FOUND, null) } | ||
} | ||
|
||
override fun isPreferredCredentials(callback: IIsPreferredCredentialsCallback?, credentials: ThreadNetworkCredentials?) { | ||
if (credentials == null) { | ||
runCatching { callback?.onIsPreferredCredentials(Status(CommonStatusCodes.DEVELOPER_ERROR, "Illegal arguments"), false) } | ||
return | ||
} | ||
Log.d(TAG, "Not yet implemented: isPreferredCredentials: $credentials") | ||
runCatching { callback?.onIsPreferredCredentials(THREAD_NETWORK_NOT_FOUND, false) } | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- | ||
~ SPDX-FileCopyrightText: 2024 microG Project Team | ||
~ SPDX-License-Identifier: Apache-2.0 | ||
--> | ||
<manifest /> |
8 changes: 8 additions & 0 deletions
8
...s-threadnetwork/src/main/aidl/com/google/android/gms/threadnetwork/ThreadBorderAgent.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.threadnetwork; | ||
|
||
parcelable ThreadBorderAgent; |
8 changes: 8 additions & 0 deletions
8
...dnetwork/src/main/aidl/com/google/android/gms/threadnetwork/ThreadNetworkCredentials.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.threadnetwork; | ||
|
||
parcelable ThreadNetworkCredentials; |
13 changes: 13 additions & 0 deletions
13
...com/google/android/gms/threadnetwork/internal/IGetCredentialsByExtendedPanIdCallback.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.threadnetwork.internal; | ||
|
||
import android.content.IntentSender; | ||
import com.google.android.gms.common.api.Status; | ||
|
||
interface IGetCredentialsByExtendedPanIdCallback { | ||
void onCredentials(in Status status, in @nullable IntentSender intentSender) = 0; | ||
} |
13 changes: 13 additions & 0 deletions
13
.../aidl/com/google/android/gms/threadnetwork/internal/IGetPreferredCredentialsCallback.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.threadnetwork.internal; | ||
|
||
import android.content.IntentSender; | ||
import com.google.android.gms.common.api.Status; | ||
|
||
interface IGetPreferredCredentialsCallback { | ||
void onPreferredCredentials(in Status status, in @nullable IntentSender intentSender) = 0; | ||
} |
12 changes: 12 additions & 0 deletions
12
...n/aidl/com/google/android/gms/threadnetwork/internal/IIsPreferredCredentialsCallback.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.threadnetwork.internal; | ||
|
||
import com.google.android.gms.common.api.Status; | ||
|
||
interface IIsPreferredCredentialsCallback { | ||
void onIsPreferredCredentials(in Status status, boolean isPreferred) = 0; | ||
} |
26 changes: 26 additions & 0 deletions
26
...rk/src/main/aidl/com/google/android/gms/threadnetwork/internal/IThreadNetworkService.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.threadnetwork.internal; | ||
|
||
import com.google.android.gms.common.api.internal.IStatusCallback; | ||
|
||
import com.google.android.gms.threadnetwork.ThreadBorderAgent; | ||
import com.google.android.gms.threadnetwork.ThreadNetworkCredentials; | ||
|
||
import com.google.android.gms.threadnetwork.internal.IGetCredentialsByExtendedPanIdCallback; | ||
import com.google.android.gms.threadnetwork.internal.IGetPreferredCredentialsCallback; | ||
import com.google.android.gms.threadnetwork.internal.IIsPreferredCredentialsCallback; | ||
import com.google.android.gms.threadnetwork.internal.IThreadNetworkServiceCallbacks; | ||
|
||
interface IThreadNetworkService { | ||
void addCredentials(IStatusCallback callback, in ThreadBorderAgent borderAgent, in ThreadNetworkCredentials credentials) = 0; | ||
void removeCredentials(IStatusCallback callback, in ThreadBorderAgent borderAgent) = 1; | ||
void getAllCredentials(IThreadNetworkServiceCallbacks callbacks) = 3; | ||
void getCredentialsByExtendedPanId(IGetCredentialsByExtendedPanIdCallback callback, in byte[] extendedPanId) = 4; | ||
void getCredentialsByBorderAgent(IThreadNetworkServiceCallbacks callbacks, in ThreadBorderAgent borderAgent) = 5; | ||
void getPreferredCredentials(IGetPreferredCredentialsCallback callback) = 7; | ||
void isPreferredCredentials(IIsPreferredCredentialsCallback callback, in ThreadNetworkCredentials credentials) = 8; | ||
} |
14 changes: 14 additions & 0 deletions
14
...in/aidl/com/google/android/gms/threadnetwork/internal/IThreadNetworkServiceCallbacks.aidl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package com.google.android.gms.threadnetwork.internal; | ||
|
||
import com.google.android.gms.common.api.Status; | ||
|
||
import com.google.android.gms.threadnetwork.ThreadNetworkCredentials; | ||
|
||
interface IThreadNetworkServiceCallbacks { | ||
void onCredentials(in Status status, in List<ThreadNetworkCredentials> credentials) = 0; | ||
} |
37 changes: 37 additions & 0 deletions
37
...work/src/main/java/com/google/android/gms/threadnetwork/IsPreferredCredentialsResult.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2024 microG Project Team | ||
* SPDX-License-Identifier: Apache-2.0 | ||
* Notice: Portions of this file are reproduced from work created and shared by Google and used | ||
* according to terms described in the Creative Commons 4.0 Attribution License. | ||
* See https://developers.google.com/readme/policies for details. | ||
*/ | ||
|
||
package com.google.android.gms.threadnetwork; | ||
|
||
import androidx.annotation.IntDef; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Marks the result of {@link ThreadNetworkClient#isPreferredCredentials(ThreadNetworkCredentials)}. | ||
*/ | ||
@Target({ElementType.TYPE_PARAMETER, ElementType.TYPE_USE}) | ||
@Retention(RetentionPolicy.SOURCE) | ||
@IntDef({IsPreferredCredentialsResult.PREFERRED_CREDENTIALS_NOT_FOUND, IsPreferredCredentialsResult.PREFERRED_CREDENTIALS_NOT_MATCHED, IsPreferredCredentialsResult.PREFERRED_CREDENTIALS_MATCHED}) | ||
public @interface IsPreferredCredentialsResult { | ||
/** | ||
* The preferred Thread network credentials don't exist. | ||
*/ | ||
int PREFERRED_CREDENTIALS_NOT_FOUND = -1; | ||
/** | ||
* The preferred Thread network credentials don't match given credentials. | ||
*/ | ||
int PREFERRED_CREDENTIALS_NOT_MATCHED = 0; | ||
/** | ||
* The preferred Thread network credentials match given credentials. | ||
*/ | ||
int PREFERRED_CREDENTIALS_MATCHED = 1; | ||
} |
Oops, something went wrong.