-
Notifications
You must be signed in to change notification settings - Fork 627
Initial code structure for App Distribution Android SDK #2754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e53b09c
Init commit
andrewbibiloni b2a39c8
Fix formatting, add @NonNull in api, update SDK versions
andrewbibiloni add51b9
Reformat code, add more @NonNull
andrewbibiloni 7caa6d0
Add new line at end of files
andrewbibiloni 505f715
Remove optionals, address nits, remove Api from name
andrewbibiloni 38461a4
Change abstract to regular class
andrewbibiloni 4bc2e54
Implement registrar, add FirebaseApp as dependency
andrewbibiloni 720002b
Create seperate classes for interfaces and enums
andrewbibiloni 15bf950
Add comments
andrewbibiloni 371ed43
Fix comments
andrewbibiloni b304d11
Code clean up
013e422
Address API feedback
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
firebase-app-distribution/firebase-app-distribution.gradle
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2021 Google LLC | ||
// | ||
// 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. | ||
|
||
plugins { | ||
id 'firebase-library' | ||
} | ||
|
||
android { | ||
compileSdkVersion project.targetSdkVersion | ||
|
||
defaultConfig { | ||
minSdkVersion project.minSdkVersion | ||
targetSdkVersion project.targetSdkVersion | ||
multiDexEnabled true | ||
versionName version | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
testOptions { | ||
unitTests { | ||
includeAndroidResources = true | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation 'org.jetbrains:annotations:15.0' | ||
implementation project(path: ':firebase-components') | ||
implementation 'com.google.android.gms:play-services-tasks:17.0.0' | ||
implementation project(path: ':firebase-common') | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Copyright 2021 Google LLC | ||
# | ||
# 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. | ||
|
||
version=0.0.1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2021 Google LLC --> | ||
<!-- --> | ||
<!-- 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. --> | ||
|
||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.google.firebase.appdistribution"> | ||
|
||
<application> | ||
<service | ||
android:name="com.google.firebase.components.ComponentDiscoveryService" | ||
android:exported="false"> | ||
<meta-data | ||
android:name="com.google.firebase.components:com.google.firebase.appdistribution.FirebaseAppDistributionRegistrar" | ||
android:value="com.google.firebase.components.ComponentRegistrar" /> | ||
</service> | ||
</application> | ||
</manifest> |
60 changes: 60 additions & 0 deletions
60
...istribution/src/main/java/com/google/firebase/appdistribution/AppDistributionRelease.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
// Copyright 2021 Google LLC | ||
// | ||
// 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.google.firebase.appdistribution; | ||
|
||
import androidx.annotation.NonNull; | ||
|
||
/** | ||
* Data class for AppDistributionRelease object returned by checkForUpdate() and | ||
* updateToLatestRelease() | ||
*/ | ||
public final class AppDistributionRelease { | ||
private final String displayVersion; | ||
private final String buildVersion; | ||
private final String releaseNotes; | ||
private final BinaryType binaryType; | ||
|
||
AppDistributionRelease( | ||
String displayVersion, String buildVersion, String releaseNotes, BinaryType binaryType) { | ||
this.displayVersion = displayVersion; | ||
this.buildVersion = buildVersion; | ||
this.releaseNotes = releaseNotes; | ||
this.binaryType = binaryType; | ||
} | ||
|
||
/** The short bundle version of this build (example 1.0.0) */ | ||
@NonNull | ||
public String getDisplayVersion() { | ||
return displayVersion; | ||
} | ||
|
||
/** The bundle version of this build (example: 123) */ | ||
@NonNull | ||
public String getBuildVersion() { | ||
return buildVersion; | ||
} | ||
|
||
/** The release notes for this build */ | ||
@NonNull | ||
public String getReleaseNotes() { | ||
return releaseNotes; | ||
} | ||
|
||
/** The binary type for this build */ | ||
@NonNull | ||
public BinaryType getBinaryType() { | ||
return binaryType; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
firebase-app-distribution/src/main/java/com/google/firebase/appdistribution/BinaryType.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2021 Google LLC | ||
// | ||
// 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.google.firebase.appdistribution; | ||
|
||
/** Enum of Android App Binary types, used in AppDistributionRelease */ | ||
public enum BinaryType { | ||
AAB, | ||
APK | ||
} |
87 changes: 87 additions & 0 deletions
87
...stribution/src/main/java/com/google/firebase/appdistribution/FirebaseAppDistribution.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright 2021 Google LLC | ||
// | ||
// 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.google.firebase.appdistribution; | ||
|
||
import androidx.annotation.NonNull; | ||
import com.google.android.gms.tasks.Task; | ||
import com.google.android.gms.tasks.Tasks; | ||
import com.google.firebase.FirebaseApp; | ||
|
||
public class FirebaseAppDistribution { | ||
|
||
private final FirebaseApp firebaseApp; | ||
|
||
/** Constructor for FirebaseAppDistribution */ | ||
FirebaseAppDistribution(@NonNull FirebaseApp firebaseApp) { | ||
this.firebaseApp = firebaseApp; | ||
} | ||
|
||
/** @return a FirebaseInstallationsApi instance */ | ||
@NonNull | ||
public static FirebaseAppDistribution getInstance() { | ||
return new FirebaseAppDistribution(FirebaseApp.getInstance()); | ||
} | ||
|
||
/** | ||
* Updates the app to the latest release, if one is available. Returns the release information or | ||
* null if no update is found. Performs the following actions: 1. If tester is not signed in, | ||
* presents the tester with a Google sign in UI 2. Checks if a newer release is available. If so, | ||
* presents the tester with a confirmation dialog to begin the download. 3. For APKs, downloads | ||
* the binary and starts an installation intent. 4. For AABs, directs the tester to the Play app | ||
* to complete the download and installation. | ||
*/ | ||
@NonNull | ||
public Task<AppDistributionRelease> updateToLatestRelease() { | ||
return Tasks.forResult(null); | ||
} | ||
|
||
/** | ||
* Returns an AppDistributionRelease if one is available for the current signed in tester. If no | ||
* update is found, returns null. If tester is not signed in, presents the tester with a Google | ||
* sign in UI | ||
*/ | ||
@NonNull | ||
public Task<AppDistributionRelease> checkForUpdate() { | ||
return Tasks.forResult(null); | ||
} | ||
|
||
/** | ||
* Updates app to the latest release. If the latest release is an APK, downloads the binary and | ||
* starts an installation If the latest release is an AAB, directs the tester to the Play app to | ||
* complete the download and installation. | ||
* | ||
* @throws an {@link Status.UPDATE_NOT_AVAILABLE_ERROR} exception if no new release is cached from | ||
* checkForUpdate | ||
*/ | ||
@NonNull | ||
public UpdateTask updateApp() { | ||
return (UpdateTask) Tasks.forResult(new UpdateState(0, 0, UpdateStatus.PENDING)); | ||
} | ||
|
||
/** Signs in the App Distribution tester. Presents the tester with a Google sign in UI */ | ||
@NonNull | ||
public Task<Void> signInTester() { | ||
return Tasks.forResult(null); | ||
} | ||
|
||
/** Returns true if the App Distribution tester is signed in */ | ||
@NonNull | ||
public boolean isTesterSignedIn() { | ||
return false; | ||
} | ||
|
||
/** Signs out the App Distribution tester */ | ||
public void signOutTester() {} | ||
} |
76 changes: 76 additions & 0 deletions
76
...n/src/main/java/com/google/firebase/appdistribution/FirebaseAppDistributionException.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
// Copyright 2021 Google LLC | ||
// | ||
// 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.google.firebase.appdistribution; | ||
|
||
import androidx.annotation.NonNull; | ||
import com.google.firebase.FirebaseException; | ||
|
||
/** Possible exceptions thrown in FirebaseAppDistribution */ | ||
public class FirebaseAppDistributionException extends FirebaseException { | ||
public enum Status { | ||
/** Unknown error. */ | ||
UNKNOWN, | ||
|
||
/** Authentication failed */ | ||
AUTHENTICATION_FAILURE, | ||
|
||
/** Authentication canceled */ | ||
AUTHENTICATION_CANCELED, | ||
|
||
/** No Network available to make requests or the request timed out */ | ||
NETWORK_FAILURE, | ||
|
||
/** Download failed */ | ||
DOWNLOAD_FAILURE, | ||
|
||
/** Installation failed */ | ||
INSTALLATION_FAILURE, | ||
|
||
/** Installation canceled */ | ||
INSTALLATION_CANCELED, | ||
|
||
/** Update not available for the current tester and app */ | ||
UPDATE_NOT_AVAILABLE, | ||
|
||
/** Installation failed due to signature mismatch */ | ||
INSTALLATION_FAILURE_SIGNATURE_MISMATCH, | ||
|
||
/** App is in production */ | ||
APP_RUNNING_IN_PRODUCTION, | ||
|
||
/** Download URL for release expired */ | ||
RELEASE_URL_EXPIRED, | ||
} | ||
|
||
@NonNull private final Status status; | ||
@NonNull private final AppDistributionRelease release; | ||
|
||
FirebaseAppDistributionException( | ||
@NonNull Status status, @NonNull AppDistributionRelease release) { | ||
this.status = status; | ||
this.release = release; | ||
} | ||
|
||
/** Get cached release when error was thrown */ | ||
@NonNull | ||
public AppDistributionRelease getRelease() { | ||
return release; | ||
} | ||
|
||
@NonNull | ||
public Status getErrorCode() { | ||
return status; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...n/src/main/java/com/google/firebase/appdistribution/FirebaseAppDistributionRegistrar.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// Copyright 2021 Google LLC | ||
// | ||
// 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.google.firebase.appdistribution; | ||
|
||
import androidx.annotation.Keep; | ||
import com.google.firebase.FirebaseApp; | ||
import com.google.firebase.components.Component; | ||
import com.google.firebase.components.ComponentRegistrar; | ||
import com.google.firebase.components.Dependency; | ||
import com.google.firebase.platforminfo.LibraryVersionComponent; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
/** | ||
* Registers FirebaseAppDistribution | ||
* | ||
* @hide | ||
*/ | ||
@Keep | ||
public class FirebaseAppDistributionRegistrar implements ComponentRegistrar { | ||
@Override | ||
public List<Component<?>> getComponents() { | ||
return Arrays.asList( | ||
Component.builder(FirebaseAppDistribution.class) | ||
.add(Dependency.required(FirebaseApp.class)) | ||
.factory(c -> new FirebaseAppDistribution(c.get(FirebaseApp.class))) | ||
.build(), | ||
LibraryVersionComponent.create("fire-app-distribution", BuildConfig.VERSION_NAME)); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
non-blocking nit: you may want to add
equals()
andhashCode()
, or use an@AutoValue
altogether.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. We will add these in a follow-up PR