Skip to content

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 20 commits into from
Jul 24, 2019
Merged
Show file tree
Hide file tree
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 Jul 22, 2019
2ec4aef
Adding Firebase Installations module
ankitaj224 Jul 22, 2019
dca81d0
Adding Firebase Installations module.
ankitaj224 Jul 22, 2019
7b4ebcf
Readding .idea files that were deleted in previous commit
ankitaj224 Jul 22, 2019
a7696e7
Revert "Adding Firebase Installations module"
ankitaj224 Jul 22, 2019
1c50283
Revert "Readding .idea files that were deleted in previous commit"
ankitaj224 Jul 22, 2019
c77acd2
Add firebase installations project path
ankitaj224 Jul 22, 2019
a32c394
Adding Firebase Installations module.
ankitaj224 Jul 22, 2019
73c9e39
Readding .idea files that were deleted in previous commit
ankitaj224 Jul 22, 2019
0e8b286
Revert "Adding Firebase Installations module"
ankitaj224 Jul 22, 2019
cf37dde
Revert "Readding .idea files that were deleted in previous commit"
ankitaj224 Jul 22, 2019
896c748
Add firebase installations project path
ankitaj224 Jul 22, 2019
e179da7
Merge branch 'ankita_fis' of github.com:firebase/firebase-android-sdk…
ankitaj224 Jul 22, 2019
370b862
Fixing formattinf issues.
ankitaj224 Jul 22, 2019
b7b90c5
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
ankitaj224 Jul 22, 2019
d0ce8fa
Revert "Adding Firebase Installations module" with hidden files
ankitaj224 Jul 22, 2019
095296b
Addressing review comments.
ankitaj224 Jul 23, 2019
ce22251
Making InstallationTokenResult an AutoValue class.
ankitaj224 Jul 23, 2019
83d7652
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
ankitaj224 Jul 23, 2019
47cba01
Merge branch 'master' of github.com:firebase/firebase-android-sdk int…
ankitaj224 Jul 24, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
1 change: 1 addition & 0 deletions firebase-installations-interop/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=17.1.1
17 changes: 17 additions & 0 deletions firebase-installations-interop/src/main/AndroidManifest.xml
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" />
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();
}
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);
}
}
54 changes: 54 additions & 0 deletions firebase-installations/firebase-installations.gradle
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'
}

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'
testImplementation 'junit:junit:4.12'
testImplementation "org.robolectric:robolectric:$robolectricVersion"

androidTestImplementation 'androidx.test:runner:1.2.0'
implementation 'com.google.guava:guava:16.0.+'
}
1 change: 1 addition & 0 deletions firebase-installations/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
version=17.1.1
11 changes: 11 additions & 0 deletions firebase-installations/lint.xml
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>
14 changes: 14 additions & 0 deletions firebase-installations/src/main/AndroidManifest.xml
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>
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 {

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();
}
}
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));
}
}
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 {}
Loading