Commit 1cd4c68b authored by Fred Mello's avatar Fred Mello Committed by Commit Bot

Add more descriptive messages to DFM's Request and Install errors.

Bug: 958152

Change-Id: I5ad52e1829c6698fa0042ef1ab9e4588d45c6e1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1596839Reviewed-by: default avatarTibor Goldschwendt <tiborg@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Commit-Queue: Fred Mello <fredmello@chromium.org>
Cr-Commit-Position: refs/heads/master@{#657427}
parent 1dc115f2
...@@ -7,11 +7,13 @@ package org.chromium.components.module_installer; ...@@ -7,11 +7,13 @@ package org.chromium.components.module_installer;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.util.Pair; import android.util.Pair;
import com.google.android.play.core.splitinstall.SplitInstallException;
import com.google.android.play.core.splitinstall.SplitInstallManager; import com.google.android.play.core.splitinstall.SplitInstallManager;
import com.google.android.play.core.splitinstall.SplitInstallManagerFactory; import com.google.android.play.core.splitinstall.SplitInstallManagerFactory;
import com.google.android.play.core.splitinstall.SplitInstallRequest; import com.google.android.play.core.splitinstall.SplitInstallRequest;
import com.google.android.play.core.splitinstall.SplitInstallSessionState; import com.google.android.play.core.splitinstall.SplitInstallSessionState;
import com.google.android.play.core.splitinstall.SplitInstallStateUpdatedListener; import com.google.android.play.core.splitinstall.SplitInstallStateUpdatedListener;
import com.google.android.play.core.splitinstall.model.SplitInstallErrorCode;
import com.google.android.play.core.splitinstall.model.SplitInstallSessionStatus; import com.google.android.play.core.splitinstall.model.SplitInstallSessionStatus;
import org.chromium.base.ContextUtils; import org.chromium.base.ContextUtils;
...@@ -42,11 +44,29 @@ import java.util.Set; ...@@ -42,11 +44,29 @@ import java.util.Set;
// These values are persisted to logs. Entries should not be renumbered and numeric values // These values are persisted to logs. Entries should not be renumbered and numeric values
// should never be reused. // should never be reused.
private static final int INSTALL_STATUS_SUCCESS = 0; private static final int INSTALL_STATUS_SUCCESS = 0;
private static final int INSTALL_STATUS_FAILURE = 1; // private static final int INSTALL_STATUS_FAILURE = 1; [DEPRECATED]
private static final int INSTALL_STATUS_REQUEST_ERROR = 2; // private static final int INSTALL_STATUS_REQUEST_ERROR = 2; [DEPRECATED]
private static final int INSTALL_STATUS_CANCELLATION = 3; private static final int INSTALL_STATUS_CANCELLATION = 3;
private static final int INSTALL_STATUS_ACCESS_DENIED = 4;
private static final int INSTALL_STATUS_ACTIVE_SESSIONS_LIMIT_EXCEEDED = 5;
private static final int INSTALL_STATUS_API_NOT_AVAILABLE = 6;
private static final int INSTALL_STATUS_INCOMPATIBLE_WITH_EXISTING_SESSION = 7;
private static final int INSTALL_STATUS_INSUFFICIENT_STORAGE = 8;
private static final int INSTALL_STATUS_INVALID_REQUEST = 9;
private static final int INSTALL_STATUS_MODULE_UNAVAILABLE = 10;
private static final int INSTALL_STATUS_NETWORK_ERROR = 11;
private static final int INSTALL_STATUS_NO_ERROR = 12;
private static final int INSTALL_STATUS_SERVICE_DIED = 13;
private static final int INSTALL_STATUS_SESSION_NOT_FOUND = 14;
private static final int INSTALL_STATUS_SPLITCOMPAT_COPY_ERROR = 15;
private static final int INSTALL_STATUS_SPLITCOMPAT_EMULATION_ERROR = 16;
private static final int INSTALL_STATUS_SPLITCOMPAT_VERIFICATION_ERROR = 17;
private static final int INSTALL_STATUS_INTERNAL_ERROR = 18;
private static final int INSTALL_STATUS_UNKNOWN_SPLITINSTALL_ERROR = 19;
private static final int INSTALL_STATUS_UNKNOWN_REQUEST_ERROR = 20;
// Keep this one at the end and increment appropriately when adding new status. // Keep this one at the end and increment appropriately when adding new status.
private static final int INSTALL_STATUS_COUNT = 4; private static final int INSTALL_STATUS_COUNT = 21;
public PlayCoreModuleInstallerBackend(OnFinishedListener listener) { public PlayCoreModuleInstallerBackend(OnFinishedListener listener) {
super(listener); super(listener);
...@@ -78,11 +98,15 @@ import java.util.Set; ...@@ -78,11 +98,15 @@ import java.util.Set;
SplitInstallRequest request = SplitInstallRequest request =
SplitInstallRequest.newBuilder().addModule(moduleName).build(); SplitInstallRequest.newBuilder().addModule(moduleName).build();
mManager.startInstall(request).addOnFailureListener(errorCode -> {
Log.e(TAG, "Failed to request module '%s': error code %s", moduleName, errorCode); mManager.startInstall(request).addOnFailureListener(exception -> {
int status = exception instanceof SplitInstallException
? getHistogramCode(((SplitInstallException) exception).getErrorCode())
: INSTALL_STATUS_UNKNOWN_REQUEST_ERROR;
Log.e(TAG, "Failed to request module '%s': error code %s", moduleName, status);
// If we reach this error condition |onStateUpdate| won't be called. Thus, call // If we reach this error condition |onStateUpdate| won't be called. Thus, call
// |onFinished| here. // |onFinished| here.
finish(false, Collections.singletonList(moduleName), INSTALL_STATUS_REQUEST_ERROR); finish(false, Collections.singletonList(moduleName), status);
}); });
} }
...@@ -108,11 +132,11 @@ import java.util.Set; ...@@ -108,11 +132,11 @@ import java.util.Set;
break; break;
case SplitInstallSessionStatus.CANCELED: case SplitInstallSessionStatus.CANCELED:
case SplitInstallSessionStatus.FAILED: case SplitInstallSessionStatus.FAILED:
Log.e(TAG, "Failed to install modules '%s': error code %s", state.moduleNames(),
state.status());
int status = state.status() == SplitInstallSessionStatus.CANCELED int status = state.status() == SplitInstallSessionStatus.CANCELED
? INSTALL_STATUS_CANCELLATION ? INSTALL_STATUS_CANCELLATION
: INSTALL_STATUS_FAILURE; : getHistogramCode(state.errorCode());
Log.e(TAG, "Failed to install modules '%s': error code %s", state.moduleNames(),
status);
finish(false, state.moduleNames(), status); finish(false, state.moduleNames(), status);
break; break;
} }
...@@ -136,4 +160,46 @@ import java.util.Set; ...@@ -136,4 +160,46 @@ import java.util.Set;
} }
onFinished(success, moduleNames); onFinished(success, moduleNames);
} }
/**
* Gets the UMA code based on a SplitInstall error code
* @param errorCode The error code
* @return int The User Metric Analysis code
*/
private int getHistogramCode(@SplitInstallErrorCode int errorCode) {
switch (errorCode) {
case SplitInstallErrorCode.ACCESS_DENIED:
return INSTALL_STATUS_ACCESS_DENIED;
case SplitInstallErrorCode.ACTIVE_SESSIONS_LIMIT_EXCEEDED:
return INSTALL_STATUS_ACTIVE_SESSIONS_LIMIT_EXCEEDED;
case SplitInstallErrorCode.API_NOT_AVAILABLE:
return INSTALL_STATUS_API_NOT_AVAILABLE;
case SplitInstallErrorCode.INCOMPATIBLE_WITH_EXISTING_SESSION:
return INSTALL_STATUS_INCOMPATIBLE_WITH_EXISTING_SESSION;
case SplitInstallErrorCode.INSUFFICIENT_STORAGE:
return INSTALL_STATUS_INSUFFICIENT_STORAGE;
case SplitInstallErrorCode.INVALID_REQUEST:
return INSTALL_STATUS_INVALID_REQUEST;
case SplitInstallErrorCode.MODULE_UNAVAILABLE:
return INSTALL_STATUS_MODULE_UNAVAILABLE;
case SplitInstallErrorCode.NETWORK_ERROR:
return INSTALL_STATUS_NETWORK_ERROR;
case SplitInstallErrorCode.NO_ERROR:
return INSTALL_STATUS_NO_ERROR;
case SplitInstallErrorCode.SERVICE_DIED:
return INSTALL_STATUS_SERVICE_DIED;
case SplitInstallErrorCode.SESSION_NOT_FOUND:
return INSTALL_STATUS_SESSION_NOT_FOUND;
case SplitInstallErrorCode.SPLITCOMPAT_COPY_ERROR:
return INSTALL_STATUS_SPLITCOMPAT_COPY_ERROR;
case SplitInstallErrorCode.SPLITCOMPAT_EMULATION_ERROR:
return INSTALL_STATUS_SPLITCOMPAT_EMULATION_ERROR;
case SplitInstallErrorCode.SPLITCOMPAT_VERIFICATION_ERROR:
return INSTALL_STATUS_SPLITCOMPAT_VERIFICATION_ERROR;
case SplitInstallErrorCode.INTERNAL_ERROR:
return INSTALL_STATUS_INTERNAL_ERROR;
default:
return INSTALL_STATUS_UNKNOWN_SPLITINSTALL_ERROR;
}
}
} }
...@@ -20073,10 +20073,65 @@ Called by update_net_error_codes.py.--> ...@@ -20073,10 +20073,65 @@ Called by update_net_error_codes.py.-->
</enum> </enum>
<enum name="FeatureModuleInstallStatus"> <enum name="FeatureModuleInstallStatus">
<int value="0" label="Success"/> <int value="0" label="Success">Installation succeeded.</int>
<int value="1" label="Failure"/> <int value="1" label="Failure (deprecated)">
<int value="2" label="Request Error"/> (deprecated) Catch-all for install failures.
<int value="3" label="Cancellation"/> </int>
<int value="2" label="Request Error (deprecated)">
(deprecated) Catch-all for request failures.
</int>
<int value="3" label="Cancellation">The installation has been cancelled.</int>
<int value="4" label="Access Denied">
Download not permitted under current device circumstances (e.g. in
background).
</int>
<int value="5" label="Active Sessions Limit Exceeded">
Too many sessions are running for current app, existing sessions must be
resolved first.
</int>
<int value="6" label="API Not Available">
Split Install API is not available.
</int>
<int value="7" label="Incompatible with Existing Session">
Requested session contains modules from an existing active session and also
new modules.
</int>
<int value="8" label="Insufficient Storage">
Install failed due to insufficient storage.
</int>
<int value="9" label="Invalid Request">Request is otherwise invalid.</int>
<int value="10" label="Module Unavailable">
A requested module is not available (to this user/device, for the installed
apk).
</int>
<int value="11" label="Network Error">
Network error: unable to obtain split details
</int>
<int value="12" label="No Error"/>
<int value="13" label="Service Died">
Service handling split install has died.
</int>
<int value="14" label="Session Not Found">
Requested session is not found.
</int>
<int value="15" label="Splitcompat Copy Error">
Error in copying files for SplitCompat.
</int>
<int value="16" label="Splitcompat Emulation Error">
Error in SplitCompat emulation.
</int>
<int value="17" label="Splitcompat Verification Error">
Signature verification error when invoking SplitCompat.
</int>
<int value="18" label="Internal Error">
Unknown error processing split install.
</int>
<int value="19" label="Split Install Unknown Error">
Unmapped error processing split install error code.
</int>
<int value="20" label="Unknown Request Error">
Catch-all for unknown request failures.
</int>
</enum> </enum>
<enum name="FeatureObserver"> <enum name="FeatureObserver">
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment