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

Commit 4ff28cab authored by Oluwarotimi Adesina's avatar Oluwarotimi Adesina
Browse files

Fix error codes

Flag: android.app.appfunctions.flags.enable_app_function_manager
Test: manual
Bug: 357551503
Change-Id: I30a80299058e642144180cd99820e61d7acafa04
parent 5cdcf519
Loading
Loading
Loading
Loading
+7 −3
Original line number Diff line number Diff line
@@ -16,10 +16,10 @@

package android.app.appfunctions;

import static android.Manifest.permission.BIND_APP_FUNCTION_SERVICE;
import static android.app.appfunctions.ExecuteAppFunctionResponse.getResultCode;
import static android.app.appfunctions.flags.Flags.FLAG_ENABLE_APP_FUNCTION_MANAGER;
import static android.content.pm.PackageManager.PERMISSION_DENIED;
import static android.Manifest.permission.BIND_APP_FUNCTION_SERVICE;

import android.annotation.FlaggedApi;
import android.annotation.MainThread;
@@ -82,7 +82,7 @@ public abstract class AppFunctionService extends Service {
                        // behalf of them.
                        safeCallback.onResult(
                                new ExecuteAppFunctionResponse.Builder(
                                        getResultCode(ex), ex.getMessage()).build());
                                        getResultCode(ex), getExceptionMessage(ex)).build());
                    }
                }
            };
@@ -117,4 +117,8 @@ public abstract class AppFunctionService extends Service {
    public abstract void onExecuteFunction(
            @NonNull ExecuteAppFunctionRequest request,
            @NonNull Consumer<ExecuteAppFunctionResponse> callback);

    private String getExceptionMessage(Exception exception) {
        return exception.getMessage() == null ? "" : exception.getMessage();
    }
}
+8 −4
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub {
        } catch (SecurityException exception) {
            safeExecuteAppFunctionCallback.onResult(new ExecuteAppFunctionResponse
                    .Builder(ExecuteAppFunctionResponse.RESULT_DENIED,
                    exception.getMessage()).build());
                    getExceptionMessage(exception)).build());
            return;
        }

@@ -171,8 +171,8 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub {
                            );
                        } catch (Exception e) {
                            safeExecuteAppFunctionCallback.onResult(new ExecuteAppFunctionResponse
                                    .Builder(ExecuteAppFunctionResponse.RESULT_INTERNAL_ERROR,
                                    e.getMessage()).build());
                                    .Builder(ExecuteAppFunctionResponse.RESULT_APP_UNKNOWN_ERROR,
                                    getExceptionMessage(e)).build());
                            serviceUsageCompleteListener.onCompleted();
                        }
                    }
@@ -181,7 +181,7 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub {
                    public void onFailedToConnect() {
                        Slog.e(TAG, "Failed to connect to service");
                        safeExecuteAppFunctionCallback.onResult(new ExecuteAppFunctionResponse
                                .Builder(ExecuteAppFunctionResponse.RESULT_INTERNAL_ERROR,
                                .Builder(ExecuteAppFunctionResponse.RESULT_APP_UNKNOWN_ERROR,
                                "Failed to connect to AppFunctionService").build());
                    }

@@ -205,4 +205,8 @@ public class AppFunctionManagerServiceImpl extends IAppFunctionManager.Stub {
            ).build());
        }
    }

    private String getExceptionMessage(Exception exception) {
        return exception.getMessage() == null ? "" : exception.getMessage();
    }
}