diff --git a/android/app/src/main/java/com/example/project_telephony/MainActivity.java b/android/app/src/main/java/com/example/project_telephony/MainActivity.java index 8641dc1..519534f 100644 --- a/android/app/src/main/java/com/example/project_telephony/MainActivity.java +++ b/android/app/src/main/java/com/example/project_telephony/MainActivity.java @@ -1,7 +1,105 @@ package com.example.project_telephony; +import android.content.ComponentName; +import android.content.Context; +import android.content.Intent; +import android.net.Uri; +import android.os.Build; +import android.os.Bundle; +import android.provider.Settings; +import android.util.Log; + +import androidx.annotation.NonNull; + +import javax.xml.transform.Result; + import io.flutter.embedding.android.FlutterActivity; +import io.flutter.embedding.engine.FlutterEngine; +import io.flutter.plugin.common.MethodCall; +import io.flutter.plugin.common.MethodChannel; + public class MainActivity extends FlutterActivity { + private static final String CHANNEL = "com.jump/setting"; + public void configureFlutterEngine(@NonNull FlutterEngine flutterEngine){ + super.configureFlutterEngine(flutterEngine); + new MethodChannel(flutterEngine.getDartExecutor().getBinaryMessenger(), CHANNEL) + .setMethodCallHandler( + (call, result) -> { + jumpStartInterface(MainActivity.this); +// if(call.method.equals('jumpStartInterface')){ +// +// } + } + ); + } + public void jumpStartInterface(Context context) { + String brandName= Build.MANUFACTURER; + Intent intent = new Intent(); + try { + intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + Log.e("HLQ_Struggle", "******************当前手机型号为:" + brandName); + ComponentName componentName = null; + if (brandName.equals("Xiaomi")) { // 红米Note4测试通过 + componentName = new ComponentName("com.miui.securitycenter", "com.miui.permcenter.autostart.AutoStartManagementActivity"); + } else if (brandName.equals("Letv")) { // 乐视2测试通过 + intent.setAction("com.letv.android.permissionautoboot"); + } else if (brandName.equals("samsung")) { // 三星Note5测试通过 + componentName = new ComponentName("com.samsung.android.sm_cn", "com.samsung.android.sm.ui.ram.AutoRunActivity"); + } else if (brandName.equals("HUAWEI")) { // 华为测试通过 + componentName = new ComponentName("com.huawei.systemmanager", "com.huawei.systemmanager/.startupmgr.ui.StartupNormalAppListActivity"); + } else if (brandName.equals("vivo")) { // VIVO测试通过 + componentName = ComponentName.unflattenFromString("com.iqoo.secure/.safeguard.PurviewTabActivity"); + } else if (brandName.equals("Meizu")) { //万恶的魅族 + // 通过测试,发现魅族是真恶心,也是够了,之前版本还能查看到关于设置自启动这一界面,系统更新之后,完全找不到了,心里默默Fuck! + // 针对魅族,我们只能通过魅族内置手机管家去设置自启动,所以我在这里直接跳转到魅族内置手机管家界面,具体结果请看图 + componentName = ComponentName.unflattenFromString("com.meizu.safe/.permission.PermissionMainActivity"); + } else if (brandName.equals("OPPO")) { // OPPO R8205测试通过 + componentName = ComponentName.unflattenFromString("com.oppo.safe/.permission.startup.StartupAppListActivity"); + } else if (brandName.equals("ulong")) { // 360手机 未测试 + componentName = new ComponentName("com.yulong.android.coolsafe", ".ui.activity.autorun.AutoRunListActivity"); + } + + else { // 以上只是市面上主流机型,由于公司你懂的,所以很不容易才凑齐以上设备 + // 针对于其他设备,我们只能调整当前系统app查看详情界面 + // 在此根据用户手机当前版本跳转系统设置界面 + if (Build.VERSION.SDK_INT >= 9) { + intent.setAction("android.settings.APPLICATION_DETAILS_SETTINGS"); + intent.setData(Uri.fromParts("package", context.getPackageName(), null)); + } else if (Build.VERSION.SDK_INT <= 8) { + intent.setAction(Intent.ACTION_VIEW); + intent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); + intent.putExtra("com.android.settings.ApplicationPkgName", context.getPackageName()); + } + } + intent.setComponent(componentName); + context.startActivity(intent); + } catch (Exception e) {//抛出异常就直接打开设置页面 + intent = new Intent(Settings.ACTION_SETTINGS); + context.startActivity(intent); + } + } +// public void onCreate(Bundle savedInstanceState) { +// +// super.onCreate(savedInstanceState); +// new MethodChannel(getFlutterView(),CHANNEL).MethodCallHandler( +// new MethodCallHandler(){ +// public void onMethodCall(MethodCall call, Result result){ +// new MobileInfoUtils(); +// } +// } +// ); +// new MobileInfoUtils(); +// +// } + } + +//class MobileInfoUtils { +//// private static String getMobileType() { +//// return Build.MANUFACTURER; +//// } +// +// +//} \ No newline at end of file diff --git a/lib/main.dart b/lib/main.dart index fcdd5d0..342cd62 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -11,6 +11,7 @@ import 'package:permission_handler/permission_handler.dart'; import 'package:project_telephony/providers/phone_num_provider.dart'; import 'package:project_telephony/providers/user_provider.dart'; import 'package:project_telephony/ui/home/call.dart'; +import 'package:project_telephony/ui/home/home_page.dart'; import 'package:project_telephony/ui/loading.dart'; import 'package:project_telephony/ui/tab_navigator.dart'; import 'package:project_telephony/utils/developer_util.dart'; @@ -24,10 +25,14 @@ void main() async { const buildType = String.fromEnvironment('BUILD_TYPE'); DeveloperUtil.setDev(!(buildType.contains('PRODUCT'))); WidgetsFlutterBinding.ensureInitialized(); - initializeService(); + // initializeService(); + initializeService(); + Future.delayed(const Duration(seconds: 1),(){ + service.invoke("stopService"); + }); + // service.invoke("stopService"); // UserTool.userProvider.viewLoading(); await HiveStore.init(); - // await initializeService(); // Workmanager().initialize( // callbackDispatcher, // The top level function, aka callbackDispatcher // isInDebugMode: true // If enabled it will post a notification whenever the task is running. Handy for debugging tasks diff --git a/lib/ui/home/set/phone_set_page.dart b/lib/ui/home/set/phone_set_page.dart index 1f874be..e6fd194 100644 --- a/lib/ui/home/set/phone_set_page.dart +++ b/lib/ui/home/set/phone_set_page.dart @@ -1,11 +1,9 @@ - import 'package:bot_toast/bot_toast.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_contacts/flutter_contacts.dart'; import 'package:flutter_easyrefresh/easy_refresh.dart'; -import 'package:device_info_plus/device_info_plus.dart'; import 'package:project_telephony/ui/home/set/specify_phone_page.dart'; import 'package:project_telephony/utils/headers.dart'; import 'package:project_telephony/utils/user_tool.dart'; @@ -98,7 +96,7 @@ class _PhoneSetPageState extends State { _easyRefreshController.dispose(); super.dispose(); } - // static const platform= MethodChannel('com.jump/setting'); + static const platform= MethodChannel('com.jump/setting'); @override Widget build(BuildContext context) { return Scaffold( @@ -127,6 +125,7 @@ class _PhoneSetPageState extends State { select = (prefs.getInt("numIndex")) ?? 0; cycleText = prefs.getString("cycle") ?? "每天发送"; UserTool.userProvider.viewLoading(); + _getRequests(); // _viewLoading(); @@ -180,7 +179,10 @@ class _PhoneSetPageState extends State { ), GestureDetector( onTap: () async{ - // try{ + // print("12"); + await platform. invokeMethod("MobileInfoUtils"); + print("34"); + // try // // await platform.invokeMethod("jumpSetting"); // }catch (e){ // BotToast.showText(text: e.toString());