intune-app-wrapping-tool-android
intune-app-wrapping-tool-android copied to clipboard
Wrapping related to PackageManager does not work properly.
Questions to Ask Before Submission
- Does you app launch successfully without wrapping? yes
- Have you reviewed the prerequisites for App Wrapping? yes
- Does your issue have a solution in the Troubleshooting Guide? yes
- Have you checked the Microsoft Intune App SDK for Android repository for similar issues? yes
- 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