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

Commit 89876517 authored by Paul Hu's avatar Paul Hu Committed by Automerger Merge Worker
Browse files

Merge "Add AppFuseMountException" am: fdedcbd6

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1894965

Change-Id: I75c9498a26f8ca69e514c4529a301aa3906c8d57
parents 37c71286 fdedcbd6
Loading
Loading
Loading
Loading
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.android.server;

import android.os.Parcel;

/**
 * An exception that indicates there was an error with a
 * app fuse mount operation.
 */
public class AppFuseMountException extends Exception {
    public AppFuseMountException(String detailMessage) {
        super(detailMessage);
    }

    public AppFuseMountException(String detailMessage, Throwable throwable) {
        super(detailMessage, throwable);
    }

    /**
     * Rethrow as a {@link RuntimeException} subclass that is handled by
     * {@link Parcel#writeException(Exception)}.
     */
    public IllegalArgumentException rethrowAsParcelableException() {
        throw new IllegalStateException(getMessage(), this);
    }
}
+5 −5
Original line number Diff line number Diff line
@@ -3563,24 +3563,24 @@ class StorageManagerService extends IStorageManager.Stub
        }

        @Override
        public ParcelFileDescriptor open() throws NativeDaemonConnectorException {
        public ParcelFileDescriptor open() throws AppFuseMountException {
            try {
                final FileDescriptor fd = mVold.mountAppFuse(uid, mountId);
                mMounted = true;
                return new ParcelFileDescriptor(fd);
            } catch (Exception e) {
                throw new NativeDaemonConnectorException("Failed to mount", e);
                throw new AppFuseMountException("Failed to mount", e);
            }
        }

        @Override
        public ParcelFileDescriptor openFile(int mountId, int fileId, int flags)
                throws NativeDaemonConnectorException {
                throws AppFuseMountException {
            try {
                return new ParcelFileDescriptor(
                        mVold.openAppFuseFile(uid, mountId, fileId, flags));
            } catch (Exception e) {
                throw new NativeDaemonConnectorException("Failed to open", e);
                throw new AppFuseMountException("Failed to open", e);
            }
        }

@@ -3620,7 +3620,7 @@ class StorageManagerService extends IStorageManager.Stub
                        // It seems the thread of mAppFuseBridge has already been terminated.
                        mAppFuseBridge = null;
                    }
                } catch (NativeDaemonConnectorException e) {
                } catch (AppFuseMountException e) {
                    throw e.rethrowAsParcelableException();
                }
            }
+5 −5
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ import android.util.SparseArray;
import com.android.internal.annotations.GuardedBy;
import com.android.internal.os.FuseUnavailableMountException;
import com.android.internal.util.Preconditions;
import com.android.server.NativeDaemonConnectorException;
import com.android.server.AppFuseMountException;
import libcore.io.IoUtils;
import java.util.concurrent.CountDownLatch;

@@ -55,7 +55,7 @@ public class AppFuseBridge implements Runnable {
    }

    public ParcelFileDescriptor addBridge(MountScope mountScope)
            throws FuseUnavailableMountException, NativeDaemonConnectorException {
            throws FuseUnavailableMountException, AppFuseMountException {
        /*
        ** Dead Lock between Java lock (AppFuseBridge.java) and Native lock (FuseBridgeLoop.cc)
        **
@@ -112,7 +112,7 @@ public class AppFuseBridge implements Runnable {
        try {
            int flags = FileUtils.translateModePfdToPosix(mode);
            return scope.openFile(mountId, fileId, flags);
        } catch (NativeDaemonConnectorException error) {
        } catch (AppFuseMountException error) {
            throw new FuseUnavailableMountException(mountId);
        }
    }
@@ -160,9 +160,9 @@ public class AppFuseBridge implements Runnable {
            return mMountResult;
        }

        public abstract ParcelFileDescriptor open() throws NativeDaemonConnectorException;
        public abstract ParcelFileDescriptor open() throws AppFuseMountException;
        public abstract ParcelFileDescriptor openFile(int mountId, int fileId, int flags)
                throws NativeDaemonConnectorException;
                throws AppFuseMountException;
    }

    private native long native_new();