-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5bad6fd
commit 20db236
Showing
38 changed files
with
10,141 additions
and
638 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
37 changes: 0 additions & 37 deletions
37
Sources/sdk/src/androidTest/java/com/batch/android/AdvertisingIDTest.java
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
111 changes: 22 additions & 89 deletions
111
Sources/sdk/src/main/java/com/batch/android/AdvertisingID.java
This file contains 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 |
---|---|---|
@@ -1,134 +1,67 @@ | ||
package com.batch.android; | ||
|
||
import android.content.Context; | ||
import androidx.annotation.Nullable; | ||
import com.batch.android.core.Logger; | ||
import com.batch.android.di.providers.PushModuleProvider; | ||
import com.batch.android.processor.Module; | ||
import com.batch.android.processor.Singleton; | ||
|
||
/** | ||
* Object that encapsulate advertising ID | ||
* | ||
* @deprecated Batch doesn't collects the Android Advertising Identifier anymore. | ||
* @hide | ||
*/ | ||
@Module | ||
@Singleton | ||
@Deprecated | ||
public final class AdvertisingID { | ||
|
||
private static final String TAG = "AdvertisingID"; | ||
|
||
/** | ||
* Advertising ID value return when not available : | ||
* | ||
* - For Apps with target API level set to 31 (Android 12) or later must declare the normal | ||
* permission com.google.android.gms.AD_ID in the AndroidManifest.xml in order to use | ||
* the getId API | ||
* | ||
* - For all users who have opted out of ads personalization in their device settings | ||
*/ | ||
private static final String UNAVAILABLE_AD_ID = "00000000-0000-0000-0000-000000000000"; | ||
|
||
/** | ||
* Advertising ID | ||
*/ | ||
private String advertisingID; | ||
|
||
/** | ||
* Is use of advertising id limited | ||
*/ | ||
private boolean limited; | ||
|
||
/** | ||
* Is advertising ID already available | ||
*/ | ||
private boolean advertisingIdReady = false; | ||
|
||
// -------------------------------------------------> | ||
|
||
public AdvertisingID() { | ||
// Start Advertising ID async get | ||
initAdvertisingID(); | ||
} | ||
|
||
/** | ||
* Start the thread to retrieve the advertising ID asynchronously | ||
*/ | ||
private void initAdvertisingID() { | ||
AdsIdentifierProvider provider = PushModuleProvider.get().getAdsIdentifierProvider(); | ||
if (provider != null) { | ||
try { | ||
provider.checkAvailability(); | ||
} catch (AdsIdentifierProviderAvailabilityException e) { | ||
Logger.error(TAG, "Could not get Advertising Id: " + e.getMessage()); | ||
return; | ||
} | ||
|
||
provider.getAdsIdentifier( | ||
new AdsIdentifierProvider.AdsIdentifierListener() { | ||
@Override | ||
public void onSuccess(String id, boolean limited) { | ||
advertisingID = UNAVAILABLE_AD_ID.equals(id) ? null : id; | ||
AdvertisingID.this.limited = limited; | ||
advertisingIdReady = true; | ||
Logger.internal(TAG, "Advertising ID retrieved"); | ||
} | ||
|
||
@Override | ||
public void onError(Exception e) { | ||
Logger.error(TAG, "Error while retrieving Advertising ID", e); | ||
advertisingIdReady = true; | ||
} | ||
} | ||
); | ||
} | ||
} | ||
|
||
// ---------------------------------------------> | ||
public AdvertisingID() {} | ||
|
||
/** | ||
* Tell if the process to retrieve advertising ID is already complete | ||
* | ||
* @return true if the process is completed | ||
* @return This method always return false. | ||
* @deprecated Batch doesn't support advertising id anymore. | ||
*/ | ||
@Deprecated | ||
public boolean isReady() { | ||
return advertisingIdReady; | ||
return false; | ||
} | ||
|
||
/** | ||
* Get the advertising ID | ||
* | ||
* @return The advertising ID if available, null otherwise | ||
* @throws IllegalStateException if the advertising id is not available yet (check {@link #isReady()}) | ||
* @return This method always return null. | ||
* @throws IllegalStateException Cannot throw | ||
* @deprecated Batch doesn't support advertising id anymore. | ||
*/ | ||
@Deprecated | ||
@Nullable | ||
public String get() throws IllegalStateException { | ||
if (!advertisingIdReady) { | ||
throw new IllegalStateException("Advertising ID is not ready yet"); | ||
} | ||
|
||
return advertisingID; | ||
return null; | ||
} | ||
|
||
/** | ||
* Is the use of the advertising ID limited | ||
* | ||
* @return true if the advertising ID limited | ||
* @throws IllegalStateException if the advertising id is not available yet (check {@link #isReady()}) | ||
* @return This method always return false. | ||
* @throws IllegalStateException Cannot throw | ||
* @deprecated Batch doesn't support advertising id anymore. | ||
*/ | ||
@Deprecated | ||
public boolean isLimited() throws IllegalStateException { | ||
if (!advertisingIdReady) { | ||
throw new IllegalStateException("Advertising ID is not ready yet"); | ||
} | ||
|
||
return limited; | ||
return false; | ||
} | ||
|
||
/** | ||
* Is the advertising ID not null | ||
* | ||
* @return true if its not | ||
* @return This method always return false. | ||
* @deprecated Batch doesn't support advertising id anymore. | ||
*/ | ||
@Deprecated | ||
public boolean isNotNull() { | ||
return advertisingID != null; | ||
return false; | ||
} | ||
} |
Oops, something went wrong.