Skip to content

Commit a818570

Browse files
authored
Merge pull request #1444 from microsoft/develop
Version 3.3.0
2 parents 7c4a7a0 + bf2705d commit a818570

File tree

28 files changed

+1003
-155
lines changed

28 files changed

+1003
-155
lines changed

.github/workflows/codeql.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
3939
- run: |
4040
echo "Assemble modules"
41-
./gradlew :sdk:appcenter:assemble :sdk:appcenter-analytics:assemble :sdk:appcenter-crashes:assemble :sdk:appcenter-distribute:assemble :sdk:appcenter-push:assemble
41+
./gradlew :sdk:appcenter:assemble :sdk:appcenter-analytics:assemble :sdk:appcenter-crashes:assemble :sdk:appcenter-distribute:assemble :sdk:appcenter-distribute-play:assemble :sdk:appcenter-push:assemble
4242
4343
- name: Perform CodeQL Analysis
4444
uses: github/codeql-action/analyze@v1

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
# App Center SDK for Android Change Log
22

3+
## Version 3.3.0
4+
5+
### App Center
6+
7+
* **[Fix]** Fix an `IncorrectContextUseViolation` warning when calculating screen size on Android 11.
8+
* **[Fix]** All SQL commands used in SDK are presented as raw strings to avoid any possible static analyzer's SQL injection false alarms.
9+
* **[Fix]** Fix Distribute can't get updates for Realme devices which use Realme UI.
10+
11+
### App Center Distribute Play
12+
13+
App Center Distribute Play is a package with stubbed APIs for Distribute module to avoid Google Play flagging the application for malicious behavior. It must be used only for build variants which are going to be published on Google Play. See the [public documentation](https://docs.microsoft.com/en-us/appcenter/sdk/distribute/android) for more details about this change.
14+
15+
___
16+
317
## Version 3.2.2
418

519
### App Center

apps/sasquatch/build.gradle

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ evaluationDependsOn(':apps')
1111

1212
android {
1313

14-
flavorDimensions "dependency", "pushLibrary"
14+
flavorDimensions "dependency", "distribute"
1515

1616
defaultConfig {
1717
externalNativeBuild {
@@ -31,11 +31,11 @@ android {
3131
dimension "dependency"
3232
applicationIdSuffix ".jcenter"
3333
}
34-
vanilla {
35-
dimension "pushLibrary"
34+
appCenter {
35+
dimension "distribute"
3636
}
37-
firebase {
38-
dimension "pushLibrary"
37+
googlePlay {
38+
dimension "distribute"
3939
}
4040
}
4141

@@ -68,25 +68,28 @@ dependencies {
6868

6969
projectDependencyImplementation project(':sdk:appcenter-analytics')
7070
projectDependencyImplementation project(':sdk:appcenter-crashes')
71-
projectDependencyImplementation project(':sdk:appcenter-distribute')
7271
projectDependencyImplementation project(':sdk:appcenter-push')
7372

7473
def appCenterSdkVersion = "3.2.2"
7574
jcenterDependencyImplementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}"
7675
jcenterDependencyImplementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}"
77-
jcenterDependencyImplementation "com.microsoft.appcenter:appcenter-distribute:${appCenterSdkVersion}"
7876
jcenterDependencyImplementation "com.microsoft.appcenter:appcenter-push:${appCenterSdkVersion}"
7977

78+
def taskRequests = getGradle().getStartParameter().getTaskRequests().toString()
79+
if (taskRequests.contains("GooglePlay")) {
80+
projectDependencyImplementation project(':sdk:appcenter-distribute-play')
81+
jcenterDependencyImplementation "com.microsoft.appcenter:appcenter-distribute-play:${appCenterSdkVersion}"
82+
} else {
83+
projectDependencyImplementation project(':sdk:appcenter-distribute')
84+
jcenterDependencyImplementation "com.microsoft.appcenter:appcenter-distribute:${appCenterSdkVersion}"
85+
}
86+
8087
androidTestImplementation 'com.android.support.test:rules:1.0.2'
8188
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
8289
implementation 'com.android.support.test.espresso:espresso-idling-resource:3.0.2'
8390
}
8491

85-
// We are interested in excluding the plugin only for the vanilla sasquatch build variant.
86-
def taskRequests = getGradle().getStartParameter().getTaskRequests().toString()
87-
if (!taskRequests.contains("sasquatch") || taskRequests.contains("Firebase")) {
88-
apply plugin: 'com.google.gms.google-services'
89-
}
92+
apply plugin: 'com.google.gms.google-services'
9093

9194
/*
9295
* Project and jcenter conflict since they are not using same version of Push and
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License.
4+
*/
5+
6+
project.description = 'This package contains functionalities to get in-app updates for your application.'
7+
evaluationDependsOn(':sdk')
8+
9+
dependencies {
10+
api project(':sdk:appcenter')
11+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# The following options are set by default.
2+
# Make sure they are always set, even if the default proguard config changes.
3+
-dontskipnonpubliclibraryclasses
4+
-verbose
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
~ Copyright (c) Microsoft Corporation. All rights reserved.
4+
~ Licensed under the MIT License.
5+
-->
6+
7+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
8+
package="com.microsoft.appcenter.distribute">
9+
<application>
10+
</application>
11+
</manifest>
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License.
4+
*/
5+
6+
package com.microsoft.appcenter.distribute;
7+
8+
import android.app.Activity;
9+
import android.content.Context;
10+
import android.support.annotation.NonNull;
11+
import android.support.annotation.VisibleForTesting;
12+
13+
import com.microsoft.appcenter.AbstractAppCenterService;
14+
import com.microsoft.appcenter.channel.Channel;
15+
import com.microsoft.appcenter.ingestion.models.json.LogFactory;
16+
import com.microsoft.appcenter.utils.AppCenterLog;
17+
import com.microsoft.appcenter.utils.async.AppCenterFuture;
18+
import com.microsoft.appcenter.utils.async.DefaultAppCenterFuture;
19+
import java.util.HashMap;
20+
import java.util.Map;
21+
22+
import static com.microsoft.appcenter.distribute.DistributeConstants.LOG_TAG;
23+
import static com.microsoft.appcenter.distribute.DistributeConstants.SERVICE_NAME;
24+
25+
/**
26+
* Distribute service.
27+
*/
28+
public class Distribute extends AbstractAppCenterService {
29+
30+
private static Distribute sInstance;
31+
32+
private static final String DISTRIBUTE_GROUP = "group_distribute";
33+
34+
/**
35+
* Get shared instance.
36+
*
37+
* @return shared instance.
38+
*/
39+
public static synchronized Distribute getInstance() {
40+
if (sInstance == null) {
41+
sInstance = new Distribute();
42+
}
43+
return sInstance;
44+
}
45+
46+
/**
47+
* Check whether Distribute service is enabled or not.
48+
*
49+
* @return future with result being <code>true</code> if enabled, <code>false</code> otherwise.
50+
* @see AppCenterFuture
51+
*/
52+
public static AppCenterFuture<Boolean> isEnabled() {
53+
DefaultAppCenterFuture appCenterFuture = new DefaultAppCenterFuture<>();
54+
appCenterFuture.complete(true);
55+
return appCenterFuture;
56+
}
57+
58+
/**
59+
* Enable or disable Distribute service.
60+
*
61+
* The state is persisted in the device's storage across application launches.
62+
*
63+
* @param enabled <code>true</code> to enable, <code>false</code> to disable.
64+
* @return future with null result to monitor when the operation completes.
65+
*/
66+
public static AppCenterFuture<Void> setEnabled(boolean enabled) {
67+
DefaultAppCenterFuture appCenterFuture = new DefaultAppCenterFuture<>();
68+
appCenterFuture.complete(true);
69+
return appCenterFuture;
70+
}
71+
72+
/**
73+
* Change the base URL opened in the browser to get update token from user login information.
74+
*
75+
* @param installUrl install base URL.
76+
*/
77+
public static void setInstallUrl(String installUrl) {
78+
}
79+
80+
/**
81+
* Change the base URL used to make API calls.
82+
*
83+
* @param apiUrl API base URL.
84+
*/
85+
public static void setApiUrl(String apiUrl) {
86+
}
87+
88+
/**
89+
* Get the current update track (public vs private).
90+
*/
91+
public static int getUpdateTrack() {
92+
return UpdateTrack.PUBLIC;
93+
}
94+
95+
/**
96+
* Set the update track (public vs private).
97+
*
98+
* @param updateTrack update track.
99+
*/
100+
public static void setUpdateTrack(@UpdateTrack int updateTrack) {
101+
}
102+
103+
/**
104+
* Sets a distribute listener.
105+
*
106+
* @param listener The custom distribute listener.
107+
*/
108+
public static void setListener(DistributeListener listener) {
109+
}
110+
111+
/**
112+
* Set whether the distribute service can be used within a debuggable build.
113+
*
114+
* @param enabled <code>true</code> to enable, <code>false</code> to disable.
115+
*/
116+
public static void setEnabledForDebuggableBuild(boolean enabled) {
117+
}
118+
119+
/**
120+
* If update dialog is customized by returning <code>true</code> in {@link DistributeListener#onReleaseAvailable(Activity, ReleaseDetails)},
121+
* You need to tell the distribute SDK using this function what is the user action.
122+
*
123+
* @param updateAction one of {@link UpdateAction} actions.
124+
* For mandatory updates, only {@link UpdateAction#UPDATE} is allowed.
125+
*/
126+
public static void notifyUpdateAction(@UpdateAction int updateAction) {
127+
}
128+
129+
/**
130+
* Implements {@link #notifyUpdateAction(int)}.
131+
*/
132+
synchronized void handleUpdateAction(final int updateAction) {
133+
}
134+
135+
/**
136+
* Trigger a check for update.
137+
* If the application is in background, it will delay the check for update until the application is in foreground.
138+
* This call has no effect if there is already an ongoing check.
139+
*/
140+
public static void checkForUpdate() {
141+
}
142+
143+
/**
144+
* Disable automatic check for update before the service starts.
145+
*/
146+
public static void disableAutomaticCheckForUpdate() {
147+
}
148+
149+
@Override
150+
protected String getGroupName() {
151+
return DISTRIBUTE_GROUP;
152+
}
153+
154+
@Override
155+
public String getServiceName() {
156+
return SERVICE_NAME;
157+
}
158+
159+
@Override
160+
protected String getLoggerTag() {
161+
return LOG_TAG;
162+
}
163+
164+
@Override
165+
protected int getTriggerCount() {
166+
return 1;
167+
}
168+
169+
@Override
170+
public Map<String, LogFactory> getLogFactories() {
171+
return new HashMap<>();
172+
}
173+
174+
@Override
175+
public synchronized void onStarted(@NonNull Context context, @NonNull Channel channel, String appSecret, String transmissionTargetToken, boolean startedFromApp) {
176+
}
177+
178+
@Override
179+
public synchronized void onActivityResumed(Activity activity) {
180+
}
181+
182+
@Override
183+
public synchronized void onActivityPaused(Activity activity) {
184+
}
185+
186+
@Override
187+
public void onApplicationEnterForeground() {
188+
}
189+
190+
@Override
191+
protected synchronized void applyEnabledState(boolean enabled) {
192+
}
193+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License.
4+
*/
5+
6+
package com.microsoft.appcenter.distribute;
7+
8+
import android.support.annotation.VisibleForTesting;
9+
10+
import com.microsoft.appcenter.AppCenter;
11+
12+
/**
13+
* Distribute constants.
14+
*/
15+
public final class DistributeConstants {
16+
17+
/**
18+
* Distribute service name.
19+
*/
20+
static final String SERVICE_NAME = "DistributePlay";
21+
22+
/**
23+
* Log tag for this service.
24+
*/
25+
public static final String LOG_TAG = AppCenter.LOG_TAG + SERVICE_NAME;
26+
27+
/**
28+
* Invalid download identifier.
29+
*/
30+
public static final long INVALID_DOWNLOAD_IDENTIFIER = -1;
31+
32+
/**
33+
* Token used for handler callbacks to check download progress.
34+
*/
35+
public static final String HANDLER_TOKEN_CHECK_PROGRESS = SERVICE_NAME + ".handler_token_check_progress";
36+
37+
/**
38+
* The download progress will be reported after loading this number of bytes.
39+
*/
40+
public static final long UPDATE_PROGRESS_BYTES_THRESHOLD = 512 * 1024;
41+
42+
/**
43+
* The download progress will be reported not more often than this number of milliseconds.
44+
*/
45+
public static final long UPDATE_PROGRESS_TIME_THRESHOLD = 500;
46+
47+
/**
48+
* 1 KiB in bytes (this not a kilobyte).
49+
*/
50+
public static final long KIBIBYTE_IN_BYTES = 1024;
51+
52+
/**
53+
* Base key for stored preferences.
54+
*/
55+
private static final String PREFERENCE_PREFIX = SERVICE_NAME + ".";
56+
57+
/**
58+
* Preference key to store the current/last download identifier (we keep download until a next
59+
* one is scheduled as the file can be opened from device downloads U.I.).
60+
*/
61+
public static final String PREFERENCE_KEY_DOWNLOAD_ID = PREFERENCE_PREFIX + "download_id";
62+
63+
/**
64+
* Preference key to store the downloading release file path.
65+
*/
66+
public static final String PREFERENCE_KEY_DOWNLOADED_RELEASE_FILE = PREFERENCE_PREFIX + "downloaded_release_file";
67+
68+
@VisibleForTesting
69+
DistributeConstants() {
70+
71+
/* Hide constructor as it's just a constant class. */
72+
}
73+
}

0 commit comments

Comments
 (0)