王亚玲 2 years ago
parent 5e53e777f5
commit 85d42b345e

@ -3,5 +3,6 @@
<!-- Flutter needs it to communicate with the running application <!-- Flutter needs it to communicate with the running application
to allow setting breakpoints, to provide hot reload, etc. to allow setting breakpoints, to provide hot reload, etc.
--> -->
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET" />
</manifest> </manifest>

@ -11,82 +11,82 @@ import 'package:project_telephony/permission.dart';
import 'package:project_telephony/ui/login/login_page.dart'; import 'package:project_telephony/ui/login/login_page.dart';
import 'package:project_telephony/ui/tab_navigator.dart'; import 'package:project_telephony/ui/tab_navigator.dart';
import 'package:telephony/telephony.dart'; // import 'package:telephony/telephony.dart';
onBackgroundMessage(SmsMessage message) { // onBackgroundMessage(SmsMessage message) {
debugPrint("onBackgroundMessage called"); // debugPrint("onBackgroundMessage called");
} // }
void main() async { void main() async {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
await initializeService(); // await initializeService();
runApp(const MyApp()); runApp(const MyApp());
// SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle( // SystemUiOverlayStyle systemUiOverlayStyle = const SystemUiOverlayStyle(
// statusBarColor: Colors.transparent, // // statusBarColor: Colors.transparent, //
// statusBarIconBrightness: Brightness.dark); // // statusBarIconBrightness: Brightness.dark); //
} }
Future<void> initializeService() async { // Future<void> initializeService() async {
final service = FlutterBackgroundService(); // final service = FlutterBackgroundService();
service.setNotificationInfo(title: '短信助手', content: '正在后台运行'); // service.setNotificationInfo(title: '短信助手', content: '正在后台运行');
await service.configure( // await service.configure(
androidConfiguration: AndroidConfiguration( // androidConfiguration: AndroidConfiguration(
onStart: onStart, // onStart: onStart,
autoStart: true, // autoStart: true,
isForegroundMode: true, // isForegroundMode: true,
), // ),
iosConfiguration: IosConfiguration( // iosConfiguration: IosConfiguration(
autoStart: true, // autoStart: true,
onForeground: onStart, // onForeground: onStart,
onBackground: onIosBackground, // onBackground: onIosBackground,
), // ),
); // );
} // }
void onIosBackground() { void onIosBackground() {
WidgetsFlutterBinding.ensureInitialized(); WidgetsFlutterBinding.ensureInitialized();
// print('FLUTTER BACKGROUND FETCH'); // print('FLUTTER BACKGROUND FETCH');
} }
void onStart() { // void onStart() {
int flag = 0; // int flag = 0;
String? phoneNum, callState; // String? phoneNum, callState;
WidgetsFlutterBinding.ensureInitialized(); // WidgetsFlutterBinding.ensureInitialized();
//
Timer.periodic(const Duration(seconds: 1), (timer) async { // Timer.periodic(const Duration(seconds: 1), (timer) async {
CallState state = await Telephony.instance.callState; // CallState state = await Telephony.instance.callState;
callState = state.name; // callState = state.name;
// print(callState!+"$flag"); // // print(callState!+"$flag");
if (callState == "IDLE") { // if (callState == "IDLE") {
if (flag != 0) { // if (flag != 0) {
flag = 0; // flag = 0;
final Iterable<CallLogEntry> result = await CallLog.query(); // final Iterable<CallLogEntry> result = await CallLog.query();
phoneNum = result.first.number; // phoneNum = result.first.number;
print(phoneNum); // print(phoneNum);
Phone.telephony.sendSms( // Phone.telephony.sendSms(
to: phoneNum!, // to: phoneNum!,
message: "hello", // message: "hello",
isMultipart: true, // isMultipart: true,
); // );
phoneNum = result.first.number; // phoneNum = result.first.number;
// print(phoneNum); // // print(phoneNum);
Phone.telephony.sendSms( // Phone.telephony.sendSms(
to: phoneNum!, // to: phoneNum!,
message: "hello", // message: "hello",
isMultipart: true, // isMultipart: true,
); // );
} // }
} else if (callState == "RINGING") { // } else if (callState == "RINGING") {
flag++; // flag++;
} else if (callState == "OFFHOOK") { // } else if (callState == "OFFHOOK") {
flag++; // flag++;
} // }
}); // });
} // }
class Phone { // class Phone {
static Telephony telephony = Telephony.instance; // static Telephony telephony = Telephony.instance;
} // }
class MyApp extends StatefulWidget { class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key); const MyApp({Key? key}) : super(key: key);
@ -124,26 +124,26 @@ class _MyAppState extends State<MyApp> {
}); });
} }
onMessage(SmsMessage message) async { // onMessage(SmsMessage message) async {
setState(() { // setState(() {
_message = message.body ?? "Error reading message body."; // _message = message.body ?? "Error reading message body.";
}); // });
} // }
onSendStatus(SendStatus status) { // onSendStatus(SendStatus status) {
setState(() { // setState(() {
_message = status == SendStatus.SENT ? "sent" : "delivered"; // _message = status == SendStatus.SENT ? "sent" : "delivered";
}); // });
} // }
Future<void> initPlatformState() async { // Future<void> initPlatformState() async {
final bool? result = await Phone.telephony.requestPhoneAndSmsPermissions; // final bool? result = await Phone.telephony.requestPhoneAndSmsPermissions;
if (result != null && result) { // if (result != null && result) {
Phone.telephony.listenIncomingSms( // Phone.telephony.listenIncomingSms(
onNewMessage: onMessage, onBackgroundMessage: onBackgroundMessage); // onNewMessage: onMessage, onBackgroundMessage: onBackgroundMessage);
} // }
if (!mounted) return; // if (!mounted) return;
} // }
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {

@ -1,9 +1,13 @@
import 'dart:math';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:project_telephony/base/base_style.dart'; import 'package:project_telephony/base/base_style.dart';
import 'package:project_telephony/main.dart'; // import 'package:project_telephony/main.dart';
import 'package:project_telephony/ui/widget/plone_back_button.dart'; import 'package:project_telephony/ui/widget/plone_back_button.dart';
import 'package:project_telephony/ui/widget/plone_bottom.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:telephony/telephony.dart'; // import 'package:telephony/telephony.dart';
class PrivacyRightsPage extends StatefulWidget { class PrivacyRightsPage extends StatefulWidget {
final String name; final String name;
@ -13,15 +17,32 @@ class PrivacyRightsPage extends StatefulWidget {
_PrivacyRightsPageState createState() => _PrivacyRightsPageState(); _PrivacyRightsPageState createState() => _PrivacyRightsPageState();
} }
final Telephony telephony = Telephony.instance; // final Telephony telephony = Telephony.instance;
// late final bool permissionsGranted; // late final bool permissionsGranted;
// String body = ""; // String body = "";
// @override // @override
// void initState() async { // initState() async {
// initPlatformState();
// // initPlatformState();
// } // }
bool? pd;
class _PrivacyRightsPageState extends State<PrivacyRightsPage> { class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
@override
void initState() {
Future.delayed(const Duration(seconds: 2), () async {
await _refresh();
});
setState(() {});
super.initState();
}
_refresh() async {
var status = await Permission.camera.status;
pd = status.isDenied;
setState(() {});
}
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
@ -38,8 +59,13 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
leading: const CloudBackButton(isSpecial: true), leading: const CloudBackButton(isSpecial: true),
backgroundColor: kForeGroundColor), backgroundColor: kForeGroundColor),
backgroundColor: Colors.white, backgroundColor: Colors.white,
body: widget.name == "隐私政策" ? null : _getRights(true), body: widget.name == "隐私政策"
); ? null
: Column(
children: [
_getRights(pd),
],
));
} }
// onMessage(SmsMessage message) async { // onMessage(SmsMessage message) async {
@ -87,7 +113,7 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
fontWeight: FontWeight.bold), fontWeight: FontWeight.bold),
), ),
16.hb, 16.hb,
Text('用于获取设备1', Text('用于获取设备',
style: TextStyle( style: TextStyle(
fontSize: 28.sp, color: BaseStyle.color999999)), fontSize: 28.sp, color: BaseStyle.color999999)),
], ],
@ -110,4 +136,25 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
)), )),
); );
} }
_getA() {
return PloneBottom(
onTap: () async {
var status = await Permission.camera.status;
if (status.isDenied) {
// openAppSettings();//
// print(status.isDenied);
// print("已允许");
} else {
print("未允许");
}
},
);
// var status = await Permission.camera.status;
// if (status.isDenied) {
// return Text("已允许");
// } else {
// return Text("未允许");
// }
}
} }

@ -12,7 +12,7 @@ import 'package:project_telephony/ui/widget/plone_bottom.dart';
import 'package:project_telephony/ui/widget/plone_image_picker.dart'; import 'package:project_telephony/ui/widget/plone_image_picker.dart';
import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/headers.dart';
import 'package:project_telephony/utils/permissionutils.dart'; import 'package:project_telephony/utils/permissionutils.dart';
import 'package:telephony/telephony.dart'; // import 'package:telephony/telephony.dart';
import '../../permission.dart'; import '../../permission.dart';
@ -23,7 +23,7 @@ class UserPage extends StatefulWidget {
_UserPageState createState() => _UserPageState(); _UserPageState createState() => _UserPageState();
} }
final Telephony telephony = Telephony.instance; // final Telephony telephony = Telephony.instance;
@override @override
void initState() {} void initState() {}
@ -54,7 +54,7 @@ class _UserPageState extends State<UserPage> {
PloneBottom( PloneBottom(
border: false, border: false,
onTap: () { onTap: () {
PermissionUtils.requestAllPermission() // PermissionUtils.requestAllPermission();
// Get.to(() => const HomePage()); // Get.to(() => const HomePage());
}, },
textColor: const Color(0xFF1890FF), textColor: const Color(0xFF1890FF),
@ -250,8 +250,7 @@ class _UserPageState extends State<UserPage> {
Permission.sms, Permission.sms,
Permission.phone, Permission.phone,
]; ];
PermissionHelper.check(permissions, PermissionHelper.check(permissions, onSuccess: () {
onSuccess: () {
print('onSuccess'); print('onSuccess');
}, onFailed: () { }, onFailed: () {
print('onFailed'); print('onFailed');

@ -168,7 +168,7 @@ packages:
name: collection name: collection
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.15.0" version: "1.16.0"
color: color:
dependency: transitive dependency: transitive
description: description:
@ -280,7 +280,7 @@ packages:
name: fake_async name: fake_async
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.2.0" version: "1.3.0"
ffi: ffi:
dependency: transitive dependency: transitive
description: description:
@ -533,7 +533,7 @@ packages:
name: js name: js
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.6.3" version: "0.6.4"
json_annotation: json_annotation:
dependency: "direct main" dependency: "direct main"
description: description:
@ -582,7 +582,7 @@ packages:
name: material_color_utilities name: material_color_utilities
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.1.3" version: "0.1.4"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -617,7 +617,7 @@ packages:
name: path name: path
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.0" version: "1.8.1"
path_provider: path_provider:
dependency: transitive dependency: transitive
description: description:
@ -853,7 +853,7 @@ packages:
name: source_span name: source_span
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "1.8.1" version: "1.8.2"
sp_util: sp_util:
dependency: transitive dependency: transitive
description: description:
@ -896,13 +896,6 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "3.0.0+2" version: "3.0.0+2"
telephony:
dependency: "direct main"
description:
name: telephony
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.4"
term_glyph: term_glyph:
dependency: transitive dependency: transitive
description: description:
@ -916,7 +909,7 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.8" version: "0.4.9"
time: time:
dependency: transitive dependency: transitive
description: description:
@ -958,7 +951,7 @@ packages:
name: vector_math name: vector_math
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "2.1.1" version: "2.1.2"
velocity_x: velocity_x:
dependency: "direct main" dependency: "direct main"
description: description:
@ -1016,5 +1009,5 @@ packages:
source: hosted source: hosted
version: "3.1.1" version: "3.1.1"
sdks: sdks:
dart: ">=2.16.1 <3.0.0" dart: ">=2.17.0-0 <3.0.0"
flutter: ">=2.8.1" flutter: ">=2.8.1"

@ -34,7 +34,7 @@ dependencies:
# The following adds the Cupertino Icons font to your application. # The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons. # Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2 cupertino_icons: ^1.0.2
telephony: ^0.1.4 # telephony: any
## 获取来电状态 ## 获取来电状态
# provider: ^6.0.3 # provider: ^6.0.3
# 获取通话记录 # 获取通话记录
@ -82,6 +82,7 @@ dev_dependencies:
# activated in the `analysis_options.yaml` file located at the root of your # activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint # package. See that file for information about deactivating specific lint
# rules and activating additional ones. # rules and activating additional ones.
# test: ^1.21.4
flutter_lints: ^1.0.0 flutter_lints: ^1.0.0
#model自动生成 #model自动生成
json_serializable: ^6.1.3 json_serializable: ^6.1.3

@ -7,6 +7,7 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart'; import 'package:flutter_test/flutter_test.dart';
// import 'package:test/test.dart';
import 'package:project_telephony/main.dart'; import 'package:project_telephony/main.dart';

Loading…
Cancel
Save