-
Notifications
You must be signed in to change notification settings - Fork 616
Initial Code structure for FIS Android SDK #648
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 19 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
553bf70
Adding an interface library for Firebase Installations SDK
ankitaj224 2ec4aef
Adding Firebase Installations module
ankitaj224 dca81d0
Adding Firebase Installations module.
ankitaj224 7b4ebcf
Readding .idea files that were deleted in previous commit
ankitaj224 a7696e7
Revert "Adding Firebase Installations module"
ankitaj224 1c50283
Revert "Readding .idea files that were deleted in previous commit"
ankitaj224 c77acd2
Add firebase installations project path
ankitaj224 a32c394
Adding Firebase Installations module.
ankitaj224 73c9e39
Readding .idea files that were deleted in previous commit
ankitaj224 0e8b286
Revert "Adding Firebase Installations module"
ankitaj224 cf37dde
Revert "Readding .idea files that were deleted in previous commit"
ankitaj224 896c748
Add firebase installations project path
ankitaj224 e179da7
Merge branch 'ankita_fis' of github.com:firebase/firebase-android-sdk…
ankitaj224 370b862
Fixing formattinf issues.
ankitaj224 b7b90c5
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
ankitaj224 d0ce8fa
Revert "Adding Firebase Installations module" with hidden files
ankitaj224 095296b
Addressing review comments.
ankitaj224 ce22251
Making InstallationTokenResult an AutoValue class.
ankitaj224 83d7652
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
ankitaj224 47cba01
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
ankitaj224 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
46 changes: 46 additions & 0 deletions
46
firebase-installations-interop/firebase-installations-interop.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,46 @@ | ||
// Copyright 2018 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' | ||
} | ||
|
||
firebaseLibrary.publishJavadoc = false | ||
|
||
android { | ||
compileSdkVersion project.targetSdkVersion | ||
defaultConfig { | ||
minSdkVersion project.minSdkVersion | ||
targetSdkVersion project.targetSdkVersion | ||
versionName version | ||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
} | ||
compileOptions { | ||
sourceCompatibility JavaVersion.VERSION_1_8 | ||
targetCompatibility JavaVersion.VERSION_1_8 | ||
} | ||
testOptions { | ||
unitTests { | ||
includeAndroidResources = true | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
implementation 'com.google.android.gms:play-services-tasks:17.0.0' | ||
|
||
compileOnly "com.google.auto.value:auto-value-annotations:1.6.5" | ||
annotationProcessor "com.google.auto.value:auto-value:1.6.2" | ||
} |
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 @@ | ||
version=17.1.1 |
17 changes: 17 additions & 0 deletions
17
firebase-installations-interop/src/main/AndroidManifest.xml
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,17 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<!-- Copyright 2019 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.installations.interop" /> |
42 changes: 42 additions & 0 deletions
42
...ons-interop/src/main/java/com/google/firebase/installations/FirebaseInstallationsApi.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 2019 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.installations; | ||
|
||
import com.google.android.gms.tasks.Task; | ||
|
||
/** | ||
* This is an interface of {@code FirebaseInstallations} that is only exposed to 2p via component | ||
* injection. | ||
* | ||
* @hide | ||
*/ | ||
public interface FirebaseInstallationsApi { | ||
|
||
/** | ||
* Async function that returns a globally unique identifier of this Firebase app installation. | ||
* This is a url-safe base64 string of a 128-bit integer. | ||
*/ | ||
Task<String> getId(); | ||
|
||
/** Async function that returns a auth token(public key) of this Firebase app installation. */ | ||
Task<InstallationTokenResult> getAuthToken(boolean forceRefresh); | ||
|
||
/** | ||
* Async function that deletes this Firebase app installation from Firebase backend. This call | ||
* would possibly lead Firebase Notification, Firebase RemoteConfig, Firebase Predictions or | ||
* Firebase In-App Messaging not function properly. | ||
*/ | ||
Task<Void> delete(); | ||
} |
38 changes: 38 additions & 0 deletions
38
...ions-interop/src/main/java/com/google/firebase/installations/InstallationTokenResult.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,38 @@ | ||
// Copyright 2019 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.installations; | ||
|
||
import androidx.annotation.NonNull; | ||
import com.google.auto.value.AutoValue; | ||
|
||
/** This class represents a set of values describing a FIS Auth Token Result. */ | ||
@AutoValue | ||
public abstract class InstallationTokenResult { | ||
|
||
/** A new FIS Auth-Token, created for this firebase installation. */ | ||
@NonNull | ||
public abstract String getAuthToken(); | ||
/** | ||
* The amount of time, in milliseconds, before the auth-token expires for this firebase | ||
* installation. | ||
*/ | ||
public abstract long getTokenExpirationTimestampMillis(); | ||
|
||
@NonNull | ||
public static InstallationTokenResult create( | ||
@NonNull String authToken, long tokenExpirationTimestampMillis) { | ||
return new AutoValue_InstallationTokenResult(authToken, tokenExpirationTimestampMillis); | ||
} | ||
} |
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,54 @@ | ||
// Copyright 2018 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' | ||
} | ||
ankitaj224 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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 project(':firebase-common') | ||
implementation project(':firebase-installations-interop') | ||
|
||
implementation 'androidx.appcompat:appcompat:1.0.2' | ||
implementation 'androidx.multidex:multidex:2.0.1' | ||
implementation 'com.google.android.gms:play-services-tasks:17.0.0' | ||
|
||
testImplementation 'androidx.test:core:1.2.0' | ||
ankitaj224 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
testImplementation 'junit:junit:4.12' | ||
testImplementation "org.robolectric:robolectric:$robolectricVersion" | ||
|
||
androidTestImplementation 'androidx.test:runner:1.2.0' | ||
implementation 'com.google.guava:guava:16.0.+' | ||
} |
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 @@ | ||
version=17.1.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,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<lint> | ||
<!--gRPC's DNS name resolver checks for javax.naming at runtime to determine if it can be used, but fails gracefullt without it. This lint error is safe to ignore.--> | ||
<!--See : https://github.com/grpc/grpc-java/blob/b0f423295b4674cb5247a6143fd211b050ef0065/core/src/main/java/io/grpc/internal/JndiResourceResolverFactory.java#L73--> | ||
<issue id="InvalidPackage"> | ||
<ignore path="*/io.grpc/grpc-core/*"/> | ||
</issue> | ||
|
||
<!-- Disable the given check in this project --> | ||
<issue id="GradleCompatible" severity="ignore" /> | ||
</lint> |
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,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.google.firebase.installations"> | ||
|
||
<application> | ||
<service | ||
android:name="com.google.firebase.components.ComponentDiscoveryService" | ||
android:exported="false"> | ||
<meta-data | ||
android:name="com.google.firebase.components:com.google.firebase.installations.FirebaseInstallationsRegistrar" | ||
android:value="com.google.firebase.components.ComponentRegistrar" /> | ||
</service> | ||
</application> | ||
</manifest> |
106 changes: 106 additions & 0 deletions
106
...-installations/src/main/java/com/google/firebase/installations/FirebaseInstallations.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,106 @@ | ||
// Copyright 2019 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.installations; | ||
|
||
import androidx.annotation.NonNull; | ||
import com.google.android.gms.common.internal.Preconditions; | ||
import com.google.android.gms.tasks.Task; | ||
import com.google.android.gms.tasks.Tasks; | ||
import com.google.common.annotations.VisibleForTesting; | ||
import com.google.firebase.FirebaseApp; | ||
|
||
/** | ||
* Entry point for Firebase Installations. | ||
* | ||
* <p>Firebase Installations does | ||
* | ||
* <ul> | ||
* <li>provide unique identifier for a Firebase installation | ||
* <li>provide auth token of a Firebase installation | ||
* <li>provide a API to GDPR-delete a Firebase installation | ||
* </ul> | ||
*/ | ||
public class FirebaseInstallations implements FirebaseInstallationsApi { | ||
|
||
ankitaj224 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
private final FirebaseApp firebaseApp; | ||
|
||
/** package private constructor. */ | ||
FirebaseInstallations(FirebaseApp firebaseApp) { | ||
this.firebaseApp = firebaseApp; | ||
} | ||
|
||
/** | ||
* Returns the {@link FirebaseInstallationsApi} initialized with the default {@link FirebaseApp}. | ||
* | ||
* @return a {@link FirebaseInstallationsApi} instance | ||
*/ | ||
@NonNull | ||
public static FirebaseInstallations getInstance() { | ||
FirebaseApp defaultFirebaseApp = FirebaseApp.getInstance(); | ||
return getInstance(defaultFirebaseApp); | ||
} | ||
|
||
/** | ||
* Returns the {@link FirebaseInstallations} initialized with a custom {@link FirebaseApp}. | ||
* | ||
* @param app a custom {@link FirebaseApp} | ||
* @return a {@link FirebaseInstallations} instance | ||
*/ | ||
@NonNull | ||
public static FirebaseInstallations getInstance(@NonNull FirebaseApp app) { | ||
Preconditions.checkArgument(app != null, "Null is not a valid value of FirebaseApp."); | ||
return (FirebaseInstallations) app.get(FirebaseInstallationsApi.class); | ||
} | ||
|
||
/** | ||
* Returns a globally unique identifier of this Firebase app installation. This is a url-safe | ||
* base64 string of a 128-bit integer. | ||
*/ | ||
@NonNull | ||
@Override | ||
public Task<String> getId() { | ||
return Tasks.forResult("fid-is-better-than-iid"); | ||
} | ||
|
||
/** Returns a auth token(public key) of this Firebase app installation. */ | ||
@NonNull | ||
@Override | ||
public Task<InstallationTokenResult> getAuthToken(boolean forceRefresh) { | ||
return Tasks.forResult(InstallationTokenResult.create("dummy_auth_token", 1000l)); | ||
} | ||
|
||
/** | ||
* Call to delete this Firebase app installation from Firebase backend. This call would possibly | ||
* lead Firebase Notification, Firebase RemoteConfig, Firebase Predictions or Firebase In-App | ||
* Messaging not function properly. | ||
*/ | ||
@NonNull | ||
@Override | ||
public Task<Void> delete() { | ||
return Tasks.forResult(null); | ||
} | ||
|
||
/** Returns the application id of the {@link FirebaseApp} of this {@link FirebaseInstallations} */ | ||
@VisibleForTesting | ||
String getApplicationId() { | ||
return firebaseApp.getOptions().getApplicationId(); | ||
} | ||
|
||
/** Returns the nick name of the {@link FirebaseApp} of this {@link FirebaseInstallations} */ | ||
@VisibleForTesting | ||
String getName() { | ||
return firebaseApp.getName(); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...tions/src/main/java/com/google/firebase/installations/FirebaseInstallationsRegistrar.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,39 @@ | ||
// Copyright 2019 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.installations; | ||
|
||
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; | ||
|
||
/** @hide */ | ||
@Keep | ||
public class FirebaseInstallationsRegistrar implements ComponentRegistrar { | ||
|
||
@Override | ||
public List<Component<?>> getComponents() { | ||
return Arrays.asList( | ||
Component.builder(FirebaseInstallationsApi.class) | ||
.add(Dependency.required(FirebaseApp.class)) | ||
.factory(c -> new FirebaseInstallations(c.get(FirebaseApp.class))) | ||
.build(), | ||
LibraryVersionComponent.create("fire-installations", BuildConfig.VERSION_NAME)); | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
...s/src/test/java/com/google/firebase/installations/FirebaseInstallationsRegistrarTest.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,18 @@ | ||
// Copyright 2019 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.installations; | ||
|
||
/** Tests for {@link FirebaseInstallationsRegistrar}. */ | ||
public class FirebaseInstallationsRegistrarTest {} |
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.
Uh oh!
There was an error while loading. Please reload this page.