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

Commit 55d16810 authored by David Luhmer's avatar David Luhmer
Browse files

throw NetworkOnMainThread exception when trying to make requests on the main thread

parent fbe050cd
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.Intent;
import android.content.ServiceConnection;
import android.os.IBinder;
import android.os.Looper;
import android.os.NetworkOnMainThreadException;
import android.os.ParcelFileDescriptor;
import android.os.RemoteException;
import android.util.Log;
@@ -273,6 +274,13 @@ public class NextcloudAPI {
     */
    private ParcelFileDescriptor performAidlNetworkRequest(NextcloudRequest request)
            throws IOException, RemoteException, NextcloudApiNotRespondingException {

        // Check if we are on the main thread
        if(Looper.myLooper() == Looper.getMainLooper()) {
            throw new NetworkOnMainThreadException();
        }

        // Wait for api to be initialized
        waitForApi();

        // Log.d(TAG, request.url);