Skip to content

Commit

Permalink
Merge pull request #1608 from microsoft/develop
Browse files Browse the repository at this point in the history
Version 4.4.3
  • Loading branch information
DmitriyKirakosyan authored Mar 11, 2022
2 parents be622be + 536c684 commit 7d3b05b
Show file tree
Hide file tree
Showing 26 changed files with 222 additions and 121 deletions.
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# App Center SDK for Android Change Log

## Version 4.4.3

### App Center Crashes

* **[Fix]** Add exception null check for `Crashes.trackError` API.

### App Center Distribute

* **[Fix]** Fix checking a new release if the application was already updated before.
* **[Fix]** Fix superfluous register/unregister receiver for installing new release.
* **[Fix]** Fix show custom in-app update dialog after opening release details.

### App Center Distribute Play

* **[Fix]** Add missing `Distribute.addStores` API.

___

## Version 4.4.2

### App Center
Expand All @@ -10,6 +28,7 @@
### App Center Distribute

* **[Fix]** Fix missing required flag on Android 31 API for `PendingIntent` which is used for starting the process of installing a new release.
* **[Known issue]** After the first in-app update App Center doesn't indicate the next releases. Use a [workaround](https://github.com/microsoft/appcenter-sdk-android/issues/1594#issuecomment-1006313019) to avoid this issue.

___

Expand Down
10 changes: 10 additions & 0 deletions apps/sasquatch/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,20 @@ android {
projectDependency {
dimension "dependency"
applicationIdSuffix ".project"
buildConfigField "String", "APP_SECRET", "\"${System.getenv("ANDROID_INT")}\""
buildConfigField "String", "TARGET_TOKEN", "\"${System.getenv("ANDROID_TARGET_TOKEN_INT")}\""
buildConfigField "String", "TARGET_TOKEN1", "\"${System.getenv("ANDROID_TARGET_TOKEN1_INT")}\""
buildConfigField "String", "TARGET_TOKEN2", "\"${System.getenv("ANDROID_TARGET_TOKEN2_INT")}\""
buildConfigField "String", "TARGET_TOKEN3", "\"${System.getenv("ANDROID_TARGET_TOKEN3_INT")}\""
}
mavenCentralDependency {
dimension "dependency"
applicationIdSuffix ".mavenCentral"
buildConfigField "String", "APP_SECRET", "\"${System.getenv("ANDROID_PROD")}\""
buildConfigField "String", "TARGET_TOKEN", "\"${System.getenv("ANDROID_TARGET_TOKEN_PROD")}\""
buildConfigField "String", "TARGET_TOKEN1", "\"${System.getenv("ANDROID_TARGET_TOKEN1_PROD")}\""
buildConfigField "String", "TARGET_TOKEN2", "\"${System.getenv("ANDROID_TARGET_TOKEN2_PROD")}\""
buildConfigField "String", "TARGET_TOKEN3", "\"${System.getenv("ANDROID_TARGET_TOKEN3_PROD")}\""
}
appCenter {
dimension "distribute"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import com.microsoft.appcenter.crashes.CrashesListener;
import com.microsoft.appcenter.crashes.model.ErrorReport;
import com.microsoft.appcenter.distribute.Distribute;
import com.microsoft.appcenter.sasquatch.BuildConfig;
import com.microsoft.appcenter.sasquatch.MSAAuthenticationProvider;
import com.microsoft.appcenter.sasquatch.R;
import com.microsoft.appcenter.sasquatch.features.TestFeatures;
Expand All @@ -55,6 +56,12 @@ public class MainActivity extends AppCompatActivity {

public static final String LOG_TAG = "AppCenterSasquatch";

public static String[] mAppSecretsArray = {BuildConfig.APP_SECRET, "Custom"};

public static String mTargetToken = BuildConfig.TARGET_TOKEN;

public static String[] mTargetTokenArray = {BuildConfig.TARGET_TOKEN1, BuildConfig.TARGET_TOKEN2, BuildConfig.TARGET_TOKEN3};

static final String APP_SECRET_KEY = "appSecret";

static final String TARGET_KEY = "target";
Expand Down Expand Up @@ -153,7 +160,7 @@ static void startAppCenter(Application application, String startTypeString) {
return;
}
String appId = sSharedPreferences.getString(APP_SECRET_KEY, getDefaultAppSecret(application.getResources()));
String targetId = sSharedPreferences.getString(TARGET_KEY, application.getString(R.string.target_id));
String targetId = sSharedPreferences.getString(TARGET_KEY, MainActivity.mTargetToken);
String appIdArg = "";
switch (startType) {
case APP_SECRET:
Expand Down Expand Up @@ -355,13 +362,11 @@ public void accept(ErrorReport data) {

/* Get the default app secret from the app secret array. */
static String getDefaultAppSecret(Resources resources) {
final String[] secretValuesArray = resources.getStringArray(R.array.appcenter_secrets);
return secretValuesArray[0];
return mAppSecretsArray[0];
}

static String getCustomAppSecretString(Resources resources) {
final String[] secretValuesArray = resources.getStringArray(R.array.appcenter_secrets);
return secretValuesArray[secretValuesArray.length - 1];
return mAppSecretsArray[mAppSecretsArray.length - 1];
}

private void setDistributeEnabledForDebuggableBuild() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import android.os.Bundle;
import android.os.FileObserver;
import android.preference.CheckBoxPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;
Expand Down Expand Up @@ -479,6 +480,8 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
});
final String defaultAppSecret = MainActivity.getDefaultAppSecret(getActivity().getResources());
final String appSecret = MainActivity.sSharedPreferences.getString(APP_SECRET_KEY, defaultAppSecret);
final ListPreference listOfAppSecrets = (ListPreference) findPreference(getString(R.string.app_secret_key));
listOfAppSecrets.setEntryValues(MainActivity.mAppSecretsArray);
initChangeableSetting(R.string.app_secret_key, appSecret, new Preference.OnPreferenceChangeListener() {

@Override
Expand Down Expand Up @@ -556,7 +559,7 @@ public boolean onPreferenceChange(Preference preference, Object newValue) {
return true;
}
});
initEditText(R.string.target_id_key, R.string.target_id_title, TARGET_KEY, getString(R.string.target_id), new EditTextListener() {
initEditText(R.string.target_id_key, R.string.target_id_title, TARGET_KEY, MainActivity.mTargetToken, new EditTextListener() {

@Override
public void onSave(String value) {
Expand All @@ -570,7 +573,7 @@ public void onSave(String value) {

@Override
public void onReset() {
String defaultTargetId = getString(R.string.target_id);
String defaultTargetId = MainActivity.mTargetToken;
setKeyValue(TARGET_KEY, defaultTargetId);
Toast.makeText(getActivity(), String.format(getActivity().getString(R.string.target_id_changed_format), defaultTargetId), Toast.LENGTH_SHORT).show();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import android.app.Activity;
import android.content.DialogInterface;
import android.content.Intent;
import android.widget.Toast;

import androidx.appcompat.app.AlertDialog;
Expand All @@ -20,7 +21,7 @@
public class SasquatchDistributeListener implements DistributeListener {

@Override
public boolean onReleaseAvailable(Activity activity, ReleaseDetails releaseDetails) {
public boolean onReleaseAvailable(final Activity activity, final ReleaseDetails releaseDetails) {
final String releaseNotes = releaseDetails.getReleaseNotes();
boolean custom = releaseNotes != null && releaseNotes.toLowerCase().contains("custom");
if (custom) {
Expand All @@ -44,6 +45,12 @@ public void onClick(DialogInterface dialog, int which) {
}
});
}
dialogBuilder.setNeutralButton(R.string.appcenter_distribute_update_dialog_view_release_notes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
activity.startActivity(new Intent(Intent.ACTION_VIEW, releaseDetails.getReleaseNotesUrl()));
}
});
dialogBuilder.create().show();
}
return custom;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.microsoft.appcenter.analytics.Analytics;
import com.microsoft.appcenter.analytics.AnalyticsTransmissionTarget;
import com.microsoft.appcenter.sasquatch.R;
import com.microsoft.appcenter.sasquatch.activities.MainActivity;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -24,7 +25,7 @@ public static List<AnalyticsTransmissionTarget> getAnalyticTransmissionTargetLis
* The second one is the parent transmission target, the third one is a child,
* the forth is a grandchild, etc...
*/
String[] targetTokens = activity.getResources().getStringArray(R.array.target_id_values);
String[] targetTokens = MainActivity.mTargetTokenArray;
targets.add(null);
targets.add(Analytics.getTransmissionTarget(targetTokens[1]));
for (int i = 2; i < targetTokens.length; i++) {
Expand Down
5 changes: 0 additions & 5 deletions apps/sasquatch/src/main/res/values/env.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,4 @@
<string name="log_url_one_collector" tools:ignore="MissingTranslation" />
<string name="install_url" tools:ignore="MissingTranslation" />
<string name="api_url" tools:ignore="MissingTranslation" />

<string-array name="appcenter_secrets" tools:ignore="MissingTranslation">
<item>45d1d9f6-2492-4e68-bd44-7190351eb5f3</item>
<item>Custom</item>
</string-array>
</resources>
7 changes: 0 additions & 7 deletions apps/sasquatch/src/main/res/values/targets.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,6 @@
-->

<resources xmlns:tools="http://schemas.android.com/tools" tools:ignore="TypographyDashes">
<string name="target_id" tools:ignore="MissingTranslation">89e889ccbe864ad6b924246d7045d55f-2d2d17d9-184c-4749-84a2-3fd0b3856ee1-7620</string>
<string-array name="target_id_values" tools:ignore="InconsistentArrays,MissingTranslation">
<item />
<item>c86c1b0383d149f6969b80462b250e62-e3c516ac-ae36-4776-b3eb-9c21116a756c-7045</item>
<item>739fadd014d642809473cdde9d1177d1-4477e206-0087-4d70-b810-229652426c89-7219</item>
<item>518cb8157cb743be9f7a921a46fda15d-5c9111b6-2c0f-417e-95f9-2241235db0b6-6776</item>
</string-array>
<string-array name="target_id_names" tools:ignore="InconsistentArrays,MissingTranslation">
<item>Default transmission</item>
<item>Sasquatch Android 2</item>
Expand Down
1 change: 0 additions & 1 deletion apps/sasquatch/src/main/res/xml/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
android:title="@string/install_id_title" />
<ListPreference
android:entries="@array/appcenter_secret_values"
android:entryValues="@array/appcenter_secrets"
android:key="@string/app_secret_key"
android:title="@string/app_secret_title" />
</PreferenceCategory>
Expand Down
5 changes: 0 additions & 5 deletions apps/sasquatch/src/projectDependency/res/values/env.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,4 @@
<string name="log_url_one_collector" tools:ignore="MissingTranslation">https://mobile.events.data.microsoft.com/OneCollector/1.0</string>
<string name="install_url" tools:ignore="MissingTranslation">https://install.portal-server-core-integration.dev.avalanch.es</string>
<string name="api_url" tools:ignore="MissingTranslation">https://api-gateway-core-integration.dev.avalanch.es/v0.1</string>

<string-array name="appcenter_secrets" tools:ignore="MissingTranslation">
<item>9e0d97c1-7838-46d0-9dab-1a0ef66aec6e</item>
<item>Custom</item>
</string-array>
</resources>
15 changes: 0 additions & 15 deletions apps/sasquatch/src/projectDependency/res/values/targets.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public static AppCenterFuture<Void> setEnabled(boolean enabled) {
* @param throwable The throwable describing the handled error.
*/
@SuppressWarnings({"SameParameterValue", "WeakerAccess"})
public static void trackError(Throwable throwable) {
public static void trackError(@NonNull Throwable throwable) {
trackError(throwable, null, null);
}

Expand All @@ -282,7 +282,7 @@ public static void trackError(Throwable throwable) {
* @param properties Optional properties.
* @param attachments Optional attachments.
*/
public static void trackError(Throwable throwable, Map<String, String> properties, Iterable<ErrorAttachmentLog> attachments) {
public static void trackError(@NonNull Throwable throwable, Map<String, String> properties, Iterable<ErrorAttachmentLog> attachments) {
getInstance().queueException(throwable, properties, attachments);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.microsoft.appcenter.utils.async.DefaultAppCenterFuture;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import static com.microsoft.appcenter.distribute.DistributeConstants.LOG_TAG;
import static com.microsoft.appcenter.distribute.DistributeConstants.SERVICE_NAME;
Expand Down Expand Up @@ -146,6 +147,14 @@ public static void checkForUpdate() {
public static void disableAutomaticCheckForUpdate() {
}

/**
* Add stores allowed to perform in-app updates.
*
* @param stores list of stores allowed to perform in-app updates.
*/
public static void addStores(Set<String> stores) {
}

@Override
protected String getGroupName() {
return DISTRIBUTE_GROUP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,17 @@

import static com.microsoft.appcenter.distribute.DistributeConstants.LOG_TAG;

import android.app.Activity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageInstaller;
import android.os.Bundle;
import android.widget.Toast;

import androidx.annotation.NonNull;

import com.microsoft.appcenter.utils.AppCenterLog;

import java.util.Locale;
Expand All @@ -25,6 +29,7 @@ public class AppCenterPackageInstallerReceiver extends BroadcastReceiver {

public static final String START_ACTION = "com.microsoft.appcenter.action.START";
public static final String MY_PACKAGE_REPLACED_ACTION = "android.intent.action.MY_PACKAGE_REPLACED";
private boolean isReceiverRegistered;

@Override
public void onReceive(Context context, Intent intent) {
Expand Down Expand Up @@ -65,4 +70,22 @@ public void onReceive(Context context, Intent intent) {
AppCenterLog.debug(LOG_TAG, String.format(Locale.ENGLISH, "Unrecognized action %s - do nothing.", intent.getAction()));
}
}

public void tryRegisterReceiver(@NonNull Context context, @NonNull IntentFilter intentFilter) {
if (isReceiverRegistered) {
return;
}
isReceiverRegistered = true;
context.registerReceiver(this, intentFilter);
AppCenterLog.debug(LOG_TAG, "The receiver for installing a new release was registered.");
}

public void tryUnregisterReceiver(@NonNull Context context) {
if (!isReceiverRegistered) {
return;
}
isReceiverRegistered = false;
context.unregisterReceiver(this);
AppCenterLog.debug(LOG_TAG, "The receiver for installing a new release was unregistered.");
}
}
Loading

0 comments on commit 7d3b05b

Please sign in to comment.