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

Wrapping related to PackageManager does not work properly. #100

Open
JosephNK opened this issue Apr 18, 2024 · 2 comments
Open

Wrapping related to PackageManager does not work properly. #100

JosephNK opened this issue Apr 18, 2024 · 2 comments
Assignees

Comments

@JosephNK
Copy link

JosephNK commented Apr 18, 2024

Questions to Ask Before Submission

  1. Does you app launch successfully without wrapping? yes
  2. Have you reviewed the prerequisites for App Wrapping? yes
  3. Does your issue have a solution in the Troubleshooting Guide? yes
  4. Have you checked the Microsoft Intune App SDK for Android repository for similar issues? yes
  5. Are you using the latest version of the App Wrapper? yes

Describe the bug:
We are using flutter_inappwebview library. What we've seen here is that before wrapping, in debug and release, function values usually return a non-null value, which works fine. However, after wrapping it returns Null, which doesn't work properly.

To Reproduce
Steps to reproduce the behavior:

  • Call the function
  • Return value Null

Expected behavior:
The function must return a non-Null value.

Screenshots and logs:

https://github.com/pichillilorenzo/flutter_inappwebview/blob/4c58653113573558ea5be880aca931e85b23da7e/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/chrome_custom_tabs/CustomTabsHelper.java#L50

...
... ... 

public static String getPackageNameToUse(Context context) {
    if (sPackageNameToUse != null) return sPackageNameToUse;

    PackageManager pm = context.getPackageManager();
    // Get default VIEW intent handler.
    Intent activityIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.example.com"));
    activityIntent.addCategory(Intent.CATEGORY_BROWSABLE);
    ResolveInfo defaultViewHandlerInfo = pm.resolveActivity(activityIntent, 0);
    String defaultViewHandlerPackageName = null;
    if (defaultViewHandlerInfo != null) {
        defaultViewHandlerPackageName = defaultViewHandlerInfo.activityInfo.packageName;
    }

    // Get all apps that can handle VIEW intents.
    int flags = 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
        flags |= PackageManager.MATCH_ALL;
    }
    List<ResolveInfo> resolvedActivityList = pm.queryIntentActivities(activityIntent, flags);
    List<String> packagesSupportingCustomTabs = new ArrayList<>();
    for (ResolveInfo info : resolvedActivityList) {
        Intent serviceIntent = new Intent();
        serviceIntent.setAction(CustomTabsService.ACTION_CUSTOM_TABS_CONNECTION);
        serviceIntent.setPackage(info.activityInfo.packageName);
        if (pm.resolveService(serviceIntent, 0) != null) {
            packagesSupportingCustomTabs.add(info.activityInfo.packageName);
        }
    }

    // Now packagesSupportingCustomTabs contains all apps that can handle both VIEW intents
    // and service calls.
    if (packagesSupportingCustomTabs.isEmpty()) {
        sPackageNameToUse = null;
    } else if (packagesSupportingCustomTabs.size() == 1) {
        sPackageNameToUse = packagesSupportingCustomTabs.get(0);
    } else if (!TextUtils.isEmpty(defaultViewHandlerPackageName)
            && !hasSpecializedHandlerIntents(context, activityIntent)
            && packagesSupportingCustomTabs.contains(defaultViewHandlerPackageName)) {
        sPackageNameToUse = defaultViewHandlerPackageName;
    } else if (packagesSupportingCustomTabs.contains(STABLE_PACKAGE)) {
        sPackageNameToUse = STABLE_PACKAGE;
    } else if (packagesSupportingCustomTabs.contains(BETA_PACKAGE)) {
        sPackageNameToUse = BETA_PACKAGE;
    } else if (packagesSupportingCustomTabs.contains(DEV_PACKAGE)) {
        sPackageNameToUse = DEV_PACKAGE;
    } else if (packagesSupportingCustomTabs.contains(LOCAL_PACKAGE)) {
        sPackageNameToUse = LOCAL_PACKAGE;
    }
    return sPackageNameToUse;
}

... ...
...

Smartphone (please complete the following information):

  • Device: Galaxy S20
  • OS Version: Android 12

Intune app wrapping tool (please complete the following information):

  • What version of the wrapper are you using? Are you using the latest version? 1.0.4214.3
  • What platform is your app based in (Java, Xamarin based, Cordova, etc)? Flutter, Native Android
  • For pre-wrapping errors, does the app build without being wrapped? N/A
  • For post-wrapping errors, does the app launch without being wrapped? yes
  • Who is the customer? Company Employee
  • Do you see a trend with it only being reproduced on a specific device? no

Additional context:
No

@mukeshk-ms mukeshk-ms self-assigned this Apr 23, 2024
@mukeshk-ms
Copy link

I am looking into this

@JosephNK
Copy link
Author

I added an library link, but the issue is not a library issue.
After creating a new Android project and writing only the code above, the return value is equally incorrect when wrapping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants