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

Commit 22047a39 authored by Ashish Kumar's avatar Ashish Kumar Committed by Ashish Kumar Gaurav
Browse files

Fixing tests failure due to unhandled exceptions

Bug: b/270035611, b/270097730
Test: CtsAppEnumerationTestCases, ContactsProviderTests
Change-Id: I32fad70110477fc2376eb15d4843b86a2245edd4
parent b62d832a
Loading
Loading
Loading
Loading
+9 −8
Original line number Diff line number Diff line
@@ -342,15 +342,16 @@ public abstract class ContentProvider implements ContentInterface, ComponentCall
            final int enumCheckUriPermission =
                    GET_TYPE_ACCESSED_WITHOUT_PERMISSION__LOCATION__PROVIDER_CHECK_URI_PERMISSION;
            if (permissionCheckPassed) {
                try {
                    // Just for logging for mediaProvider cases
                    final ProviderInfo cpi = mContext.getPackageManager()
                            .resolveContentProvider(uri.getAuthority(),
                                PackageManager.ComponentInfoFlags.of(PackageManager.GET_META_DATA));
                                    PackageManager.ComponentInfoFlags.of(
                                            PackageManager.GET_META_DATA));
                    final int callingUserId = UserHandle.getUserId(callingUid);
                    final Uri userUri = (mSingleUser
                            && !UserHandle.isSameUser(mMyUid, callingUid))
                            ? maybeAddUserId(uri, callingUserId) : uri;
                try {
                    if (cpi.forceUriPermissions
                            && mInterface.checkUriPermission(uri,
                            callingUid, Intent.FLAG_GRANT_READ_URI_PERMISSION)
+7 −2
Original line number Diff line number Diff line
@@ -930,7 +930,8 @@ public abstract class ContentResolver implements ContentInterface {
        if (provider != null) {
            try {
                final StringResultListener resultListener = new StringResultListener();
                provider.getTypeAsync(url, new RemoteCallback(resultListener));
                provider.getTypeAsync(mContext.getAttributionSource(),
                        url, new RemoteCallback(resultListener));
                resultListener.waitForResult(CONTENT_PROVIDER_TIMEOUT_MILLIS);
                if (resultListener.exception != null) {
                    throw resultListener.exception;
@@ -944,7 +945,11 @@ public abstract class ContentResolver implements ContentInterface {
                Log.w(TAG, "Failed to get type for: " + url + " (" + e.getMessage() + ")");
                return null;
            } finally {
                try {
                    releaseProvider(provider);
                } catch (java.lang.NullPointerException e) {
                    // does nothing, Binder connection already null
                }
            }
        }