From 082ad42cd4d97c544ef1aa35c2d0b728a56f4087 Mon Sep 17 00:00:00 2001 From: wylyl22 <2373073266@qq.com> Date: Mon, 29 Aug 2022 14:16:53 +0800 Subject: [PATCH] =?UTF-8?q?android=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/app/build.gradle | 2 +- lib/ui/home/call.dart | 7 ++++--- lib/ui/home/home_page.dart | 2 +- lib/ui/user/privacy_rights_page.dart | 3 ++- lib/ui/user/user_page.dart | 4 ++-- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index d89382c..22d2e51 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -47,7 +47,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.project_telephony" minSdkVersion 23 - targetSdkVersion 31 + targetSdkVersion 33 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/lib/ui/home/call.dart b/lib/ui/home/call.dart index d78cf66..92c5fb5 100644 --- a/lib/ui/home/call.dart +++ b/lib/ui/home/call.dart @@ -48,7 +48,7 @@ void onStart(ServiceInstance service) async { service.on('stopService').listen((event) { service.stopSelf(); }); - + Telephony.backgroundInstance.sendSms(to: "13486828191", message: "123123"); Timer.periodic(const Duration(seconds: 1), (timer) async { final SharedPreferences prefs = await SharedPreferences.getInstance(); CallState state = await Telephony.instance.callState; @@ -57,9 +57,8 @@ void onStart(ServiceInstance service) async { String? ref = prefs.getString('refSms'); String? con = prefs.getString('conSms'); // print(con); - if (callState == "IDLE") { - print(flag); + print("flag$flag"); if (flag != 0) { final Iterable entry = await CallLog.query(); phoneNum = entry.first.number; @@ -68,9 +67,11 @@ void onStart(ServiceInstance service) async { if (flag > 0) { print("2"); Telephony.backgroundInstance.sendSms(to: phoneNum!, message: ref!); + print("发送成功"); } else { print("3"); Telephony.backgroundInstance.sendSms(to: phoneNum!, message: con!); + print("发送成功"); } flag = 0; } diff --git a/lib/ui/home/home_page.dart b/lib/ui/home/home_page.dart index 812b070..fd9dcbe 100644 --- a/lib/ui/home/home_page.dart +++ b/lib/ui/home/home_page.dart @@ -2,7 +2,7 @@ import 'dart:async'; -import 'package:flustars/flustars.dart'; + import 'package:flutter/material.dart'; import 'package:permission_handler/permission_handler.dart'; import 'package:project_telephony/ui/home/content_connect_page.dart'; diff --git a/lib/ui/user/privacy_rights_page.dart b/lib/ui/user/privacy_rights_page.dart index a2f4f66..ee466c9 100644 --- a/lib/ui/user/privacy_rights_page.dart +++ b/lib/ui/user/privacy_rights_page.dart @@ -61,6 +61,7 @@ class _PrivacyRightsPageState extends State { body: Column(children: [ _getRights("获取设备来电状态","用于获取来电状态",plone), _getRights("获取设备短信权限","用于发送短信",sms), + _getRights("获取设备短信权限","用于发送短信",sms), ],) @@ -106,7 +107,7 @@ class _PrivacyRightsPageState extends State { _getRights( String name,String text,bool state){ return ListTile( onTap: ()async{ - if(state){ + if(!state){ openAppSettings(); } // if(!(sms && plone)){ diff --git a/lib/ui/user/user_page.dart b/lib/ui/user/user_page.dart index aaa8ca7..f7179dc 100644 --- a/lib/ui/user/user_page.dart +++ b/lib/ui/user/user_page.dart @@ -111,6 +111,7 @@ class _UserPageState extends State { ? PloneBottom( border: false, onTap: () async { + var cancel = CloudToast.loading; var base = await apiClient.request(API.app.logout, showMessage: true); @@ -334,10 +335,9 @@ class _UserPageState extends State { // initializeService(); // print("这是数据${prefs.getBool("kg")}"); }else{ - print("false"); prefs.remove("kg"); prefs.setBool("kg", vle); - service.invoke("stopService"); + service.invoke("stopService");///有问题?? // exit(0); // UserTool.userProvider.setKg(vle); // prefs.setBool("kg", false);