Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot Determine list of permissions used by an installed application in Android , permission is always null #4

Closed
mzulfaas opened this issue Jan 26, 2023 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@mzulfaas
Copy link

mzulfaas commented Jan 26, 2023

import 'package:android_package_manager/android_package_manager.dart';
import 'package:flutter/material.dart';

void main() => runApp(App());

class App extends MaterialApp {
  @override
  Widget get home => MyApp();
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {

  List<PackageInfo> _appsWithCallPermission = [];

  Future<List<PackageInfo>> getAppsWithCallPermission() async {
    List<PackageInfo> apps =  (await AndroidPackageManager().getInstalledPackages(flags:PackageInfoFlags({PMFlag.getPermissions,PMFlag.getReceivers,PMFlag.getServices,PMFlag.getProviders}))) ?? [];
    print("apps : ${apps}");
    List<PackageInfo> appsWithCallPermission = [];

    for (PackageInfo app in apps) {
      if (app.requestedPermissions!.contains("android.permission.CALL_PHONE")) {
        appsWithCallPermission.add(app);
        print(appsWithCallPermission);
      }
    }
    return appsWithCallPermission;
  }

  @override
  void initState() {
    super.initState();
    getAppsWithCallPermission().then((value) {
      setState(() {
        _appsWithCallPermission = value;
      });
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: ListView.builder(
        itemCount: _appsWithCallPermission.length,
        itemBuilder: (context, index) {
          return ListTile(
            title: Text("${_appsWithCallPermission[index].packageName}",style: TextStyle(color: Colors.red)),
          );
        },
      ),
    );
  }
}

How do I get permission used by each application?

@nsNeruno nsNeruno self-assigned this Jan 28, 2023
@nsNeruno
Copy link
Owner

Thank you for reporting an issue

Given your attempts on applying those PM Flags, especially the getPermissions one,
I noticed a failure to parse the requestedPermissions from my end

I updated my integration test.
Is this the type of information what you're looking for? Here's the updated log

lab.neruno.android_package_manager_example | (true)
	AppInfo.name: android.app.Application
	Requested Permissions: [android.permission.INTERNET]
com.asus.zenmotion | (true)
	AppInfo.name: com.asus.zenmotion.ZenMotionApp
	Requested Permissions: [android.permission.RECEIVE_BOOT_COMPLETED, android.permission.READ_SEARCH_INDEXABLES, android.permission.INTERNET, android.permission.ACCESS_NETWORK_STATE]

I will apply this fix for now

@nsNeruno
Copy link
Owner

I have updated the plugin to v0.4.0. Please kindly recheck if it actually solves your needs, thanks @mzulfaas.

@nsNeruno nsNeruno added the bug Something isn't working label Jan 28, 2023
@nsNeruno nsNeruno pinned this issue Jan 28, 2023
@mzulfaas
Copy link
Author

I already update to v0.4.0 but i still face the issue

image

@sanjaibalajee
Copy link

is it working now ?

@nsNeruno
Copy link
Owner

@sanjaibalajee
Please give v0.7.0 a try.

@nsNeruno
Copy link
Owner

nsNeruno commented Feb 2, 2024

Closing this issue for a while.
Looking for any feedbacks or any issues

Thank you for reporting.
Will re-open if necessary

@nsNeruno nsNeruno closed this as completed Feb 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants