feat:参照研听的基础工程

This commit is contained in:
jingyun
2026-06-18 15:02:28 +08:00
commit 364fc837b3
367 changed files with 16495 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/
.vscode/
# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/
+3
View File
@@ -0,0 +1,3 @@
## 0.0.1
* Initial release.
+29
View File
@@ -0,0 +1,29 @@
BSD 3-Clause License
Copyright (c) 2022, Joachim Nohl
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+15
View File
@@ -0,0 +1,15 @@
# flutter_oaid
A new Flutter plugin project.
## Getting Started
This project is a starting point for a Flutter
[plug-in package](https://flutter.dev/developing-packages/),
a specialized package that includes platform-specific implementation code for
Android and/or iOS.
For help getting started with Flutter development, view the
[online documentation](https://flutter.dev/docs), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
@@ -0,0 +1 @@
include: package:flutter_lints/flutter.yaml
+9
View File
@@ -0,0 +1,9 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/captures
.cxx
@@ -0,0 +1,74 @@
group = "dev.fluttercommunity.android_oaid"
version = "1.0-SNAPSHOT"
buildscript {
ext.kotlin_version = "2.0.0"
repositories {
google()
mavenCentral()
maven{url'https://repo1.maven.org/maven2/'}
}
dependencies {
classpath("com.android.tools.build:gradle:8.1.4")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version")
}
}
allprojects {
repositories {
google()
mavenCentral()
maven{url'https://repo1.maven.org/maven2/'}
}
}
apply plugin: "com.android.library"
apply plugin: "kotlin-android"
android {
if (project.android.hasProperty("namespace")) {
namespace = "dev.fluttercommunity.android_oaid"
}
compileSdk = 34
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = "17"
}
sourceSets {
main.java.srcDirs += "src/main/kotlin"
test.java.srcDirs += "src/test/kotlin"
}
defaultConfig {
minSdk = 21
}
dependencies {
testImplementation("org.jetbrains.kotlin:kotlin-test")
testImplementation("org.mockito:mockito-core:5.12.0")
}
testOptions {
unitTests.all {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
showStandardStreams = true
}
}
}
}
dependencies {
implementation 'com.umeng.umsdk:common:9.7.7'// 必选
implementation 'com.umeng.umsdk:asms:1.8.3'// 必选
}
@@ -0,0 +1 @@
rootProject.name = 'android_oaid'
@@ -0,0 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="dev.fluttercommunity.android_oaid">
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
@@ -0,0 +1,59 @@
package dev.fluttercommunity.android_oaid
import android.content.ContentResolver
import io.flutter.embedding.engine.plugins.FlutterPlugin
import io.flutter.plugin.common.MethodCall
import io.flutter.plugin.common.MethodChannel
import io.flutter.plugin.common.MethodChannel.MethodCallHandler
import io.flutter.plugin.common.MethodChannel.Result
import android.content.Context
import android.os.Handler
import android.os.Looper
import com.umeng.commonsdk.UMConfigure
/** AndroidOaidPlugin */
class AndroidOaidPlugin : FlutterPlugin, MethodCallHandler {
private lateinit var channel: MethodChannel
private lateinit var contentResolver: ContentResolver
private lateinit var context: Context
override fun onAttachedToEngine(flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) {
contentResolver = flutterPluginBinding.applicationContext.contentResolver
channel = MethodChannel(flutterPluginBinding.binaryMessenger, "android_oaid")
channel.setMethodCallHandler(this)
context = flutterPluginBinding.getApplicationContext()
}
override fun onMethodCall(call: MethodCall, result: Result) {
when (call.method) {
"getOaid" -> {
try {
UMConfigure.getOaid(context) { p0 ->
Handler(Looper.getMainLooper()).post {
if (p0 != null) {
result.success(p0)
} else {
result.success("")
}
}
}
} catch (e: Exception) {
Handler(Looper.getMainLooper()).post {
result.success("")
}
}
}
else -> result.notImplemented()
}
}
override fun onDetachedFromEngine(binding: FlutterPlugin.FlutterPluginBinding) {
channel.setMethodCallHandler(null)
}
}
@@ -0,0 +1,18 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
class AndroidOaidId {
const AndroidOaidId();
static const _methodChannel = MethodChannel('android_oaid');
Future<String?> getOaid() async {
final isAndroid =
!kIsWeb && defaultTargetPlatform == TargetPlatform.android;
if (!isAndroid) return null;
return _methodChannel.invokeMethod<String?>('getOaid');
}
}
+26
View File
@@ -0,0 +1,26 @@
name: android_oaid
description: A Flutter plugin for getting the Android OAID. Only for Android.
maintainer: Joachim Nohl (@nohli)
version: 0.4.0
environment:
sdk: '>=2.12.0 <4.0.0'
flutter: '>=2.0.0'
dependencies:
flutter:
sdk: flutter
dev_dependencies:
flutter_lints: '>=2.0.0 <4.0.0'
flutter_test:
sdk: flutter
flutter:
plugin:
platforms:
android:
package: dev.fluttercommunity.android_oaid
pluginClass: AndroidOaidPlugin
@@ -0,0 +1,26 @@
import 'package:android_oaid/android_oaid.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
const plugin = AndroidOaidId();
const channel = MethodChannel('android_oaid');
TestWidgetsFlutterBinding.ensureInitialized();
debugDefaultTargetPlatformOverride = TargetPlatform.android;
setUp(() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, (methodCall) async => '42');
});
tearDown(() {
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
.setMockMethodCallHandler(channel, null);
});
test('getAndroidId', () async {
expect(await plugin.getOaid(), '42');
});
}