Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f6f64e59 authored by Helen Qin's avatar Helen Qin
Browse files

Support the mdoc component name format.

Since the mdoc provider doesn't need to register a CredMan service and
can solely rely on the registration api, its component format will be
"packagename/packagename".

Bug: 274007049
Test: local deployment
Change-Id: I3dcf44eb4e6ffd4dca9d8f0a38395abe9bcf2fd0
parent 143eb5c5
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ private fun getServiceLabelAndIcon(
                ).toString()
            providerIcon = pkgInfo.applicationInfo.loadIcon(pm)
        } catch (e: PackageManager.NameNotFoundException) {
            Log.e(Constants.LOG_TAG, "Provider info not found", e)
            Log.e(Constants.LOG_TAG, "Provider package info not found", e)
        }
    } else {
        try {
@@ -113,7 +113,23 @@ private fun getServiceLabelAndIcon(
            ).toString()
            providerIcon = si.loadIcon(pm)
        } catch (e: PackageManager.NameNotFoundException) {
            Log.e(Constants.LOG_TAG, "Provider info not found", e)
            Log.e(Constants.LOG_TAG, "Provider service info not found", e)
            // Added for mdoc use case where the provider may not need to register a service and
            // instead only relies on the registration api.
            try {
                val pkgInfo = pm.getPackageInfo(
                    component.packageName,
                    PackageManager.PackageInfoFlags.of(0)
                )
                providerLabel =
                    pkgInfo.applicationInfo.loadSafeLabel(
                        pm, 0f,
                        TextUtils.SAFE_STRING_FLAG_FIRST_LINE or TextUtils.SAFE_STRING_FLAG_TRIM
                    ).toString()
                providerIcon = pkgInfo.applicationInfo.loadIcon(pm)
            } catch (e: PackageManager.NameNotFoundException) {
                Log.e(Constants.LOG_TAG, "Provider package info not found", e)
            }
        }
    }
    return if (providerLabel == null || providerIcon == null) {