Skip to content

Commit

Permalink
feat(storage): move Storage to use Pigeon for platform channels (#11521)
Browse files Browse the repository at this point in the history
* pigeon template setup

* make storage macOS running

* method channel implementation update

* android compilable

* android emulator upload succeed

* add more task listener

* Get event channel working

* pause iOS for now

* update message.dart async

* Implement more Storage for iOS functionality

* make ios e2e test build

* more e2e test fix

* make e2e test pass (android)

* android e2e test

* make storage iOS pass e2e

* Add license header

* code format

* Update unit test, remove ones that's not work with pigeon

* add symbolic link for macos files

* make pigeon generated compatible with both iOS and macOS

* fix for analyze check

* add missing analyze fix

* more touch

* address part of review comments, majorly android ones

* format changes

* addressing the iOS feedback

* update with cleanup

* address the analyze check

* add retry to flaky pause/resume test

* clean up the android task destroy logic

* need to address the flakiness of this specific task

* format

---------

Co-authored-by: Cynthia Jiang <cynthiajiang@google.com>
Co-authored-by: a-maurice <amaurice@google.com>
  • Loading branch information
3 people committed Oct 22, 2023
1 parent f54ff7c commit edddc1d
Show file tree
Hide file tree
Showing 34 changed files with 5,993 additions and 1,824 deletions.
Expand Up @@ -6,22 +6,31 @@

package io.flutter.plugins.firebase.storage;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.google.firebase.storage.StorageException;

class FlutterFirebaseStorageException extends Exception {
private int code;

FlutterFirebaseStorageException(@NonNull Exception nativeException, Throwable cause) {
super(nativeException.getMessage(), cause);
class FlutterFirebaseStorageException {
static GeneratedAndroidFirebaseStorage.FlutterError parserExceptionToFlutter(
@Nullable Exception nativeException) {
if (nativeException == null) {
return new GeneratedAndroidFirebaseStorage.FlutterError(
"UNKNOWN", "An unknown error occurred", null);
}
String code = "UNKNOWN";
String message = "An unknown error occurred:" + nativeException.getMessage();
int codeNumber;

if (nativeException instanceof StorageException) {
code = ((StorageException) nativeException).getErrorCode();
codeNumber = ((StorageException) nativeException).getErrorCode();
code = getCode(codeNumber);
message = getMessage(codeNumber);
}

return new GeneratedAndroidFirebaseStorage.FlutterError(code, message, null);
}

public String getCode() {
switch (code) {
public static String getCode(int codeNumber) {
switch (codeNumber) {
case StorageException.ERROR_OBJECT_NOT_FOUND:
return "object-not-found";
case StorageException.ERROR_BUCKET_NOT_FOUND:
Expand All @@ -48,9 +57,8 @@ public String getCode() {
}
}

@Override
public String getMessage() {
switch (code) {
public static String getMessage(int codeNumber) {
switch (codeNumber) {
case StorageException.ERROR_OBJECT_NOT_FOUND:
return "No object exists at the desired reference.";
case StorageException.ERROR_BUCKET_NOT_FOUND:
Expand Down

0 comments on commit edddc1d

Please sign in to comment.