Bug 1335110 - Catch security exceptions while getting a GCM token to fail gracefully r=eoger

Exception handling upstream is already in place, and will ensure that we degrade gracefully.
Push won't work, but we won't crash either.

MozReview-Commit-ID: EfDNoJu46zg

--HG--
extra : rebase_source : fab5546108b8da29b3b2e3c8ee02e6459e6fc6dc
This commit is contained in:
Grigory Kruglov 2017-09-08 13:56:31 -04:00
parent 96f846e8fb
commit bbd1d078dd

View File

@ -84,7 +84,13 @@ public class GcmTokenClient {
Log.i(LOG_TAG, "Cached GCM token does not exist; requesting new token with sender ID: " + senderID);
final InstanceID instanceID = InstanceID.getInstance(context);
token = instanceID.getToken(senderID, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
try {
token = instanceID.getToken(senderID, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null);
} catch (SecurityException e) {
// Degrade gracefully (see upstream exception handling) if we couldn't get the token.
// See Bug 1335110.
throw new IOException("Could not get token due to a security exception", e);
}
timestamp = System.currentTimeMillis();
if (debug) {