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

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

@ -1,9 +1,13 @@
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:permission_handler/permission_handler.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_bottom.dart';
import 'package:project_telephony/utils/headers.dart';
import 'package:telephony/telephony.dart';
// import 'package:telephony/telephony.dart';
class PrivacyRightsPage extends StatefulWidget {
final String name;
@ -13,15 +17,32 @@ class PrivacyRightsPage extends StatefulWidget {
_PrivacyRightsPageState createState() => _PrivacyRightsPageState();
}
final Telephony telephony = Telephony.instance;
// final Telephony telephony = Telephony.instance;
// late final bool permissionsGranted;
// String body = "";
// @override
// void initState() async {
// initPlatformState();
// initState() async {
// // initPlatformState();
// }
bool? pd;
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
Widget build(BuildContext context) {
return Scaffold(
@ -38,8 +59,13 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
leading: const CloudBackButton(isSpecial: true),
backgroundColor: kForeGroundColor),
backgroundColor: Colors.white,
body: widget.name == "隐私政策" ? null : _getRights(true),
);
body: widget.name == "隐私政策"
? null
: Column(
children: [
_getRights(pd),
],
));
}
// onMessage(SmsMessage message) async {
@ -87,7 +113,7 @@ class _PrivacyRightsPageState extends State<PrivacyRightsPage> {
fontWeight: FontWeight.bold),
),
16.hb,
Text('用于获取设备1',
Text('用于获取设备',
style: TextStyle(
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/utils/headers.dart';
import 'package:project_telephony/utils/permissionutils.dart';
import 'package:telephony/telephony.dart';
// import 'package:telephony/telephony.dart';
import '../../permission.dart';
@ -23,7 +23,7 @@ class UserPage extends StatefulWidget {
_UserPageState createState() => _UserPageState();
}
final Telephony telephony = Telephony.instance;
// final Telephony telephony = Telephony.instance;
@override
void initState() {}
@ -54,7 +54,7 @@ class _UserPageState extends State<UserPage> {
PloneBottom(
border: false,
onTap: () {
PermissionUtils.requestAllPermission()
// PermissionUtils.requestAllPermission();
// Get.to(() => const HomePage());
},
textColor: const Color(0xFF1890FF),
@ -250,8 +250,7 @@ class _UserPageState extends State<UserPage> {
Permission.sms,
Permission.phone,
];
PermissionHelper.check(permissions,
onSuccess: () {
PermissionHelper.check(permissions, onSuccess: () {
print('onSuccess');
}, onFailed: () {
print('onFailed');

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

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

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

Loading…
Cancel
Save