Commit 35af9f7c authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

Listen to GooglePlayServices changes in SystemAccountManagerDelegate

This CL adds second BroadcastReceiver to SystemAccountManagerDelegate to listen
for GooglePlayServices package updates. These updates can change data returned
by getAccountsSync, so observers should be notified. This CL also suppresses
deprecation warning for SystemAccountManagerDelegate constructor
(LOGIN_ACCOUNTS_CHANGED_ACTION is deprecated).

Bug: 698258
Change-Id: I09c00c2527984fda36f606f332e8cf215a74eb4b
Reviewed-on: https://chromium-review.googlesource.com/594767Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#491339}
parent 4d10d214
...@@ -20,6 +20,7 @@ import android.content.IntentFilter; ...@@ -20,6 +20,7 @@ import android.content.IntentFilter;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.PatternMatcher;
import android.os.Process; import android.os.Process;
import android.os.SystemClock; import android.os.SystemClock;
...@@ -53,10 +54,12 @@ public class SystemAccountManagerDelegate implements AccountManagerDelegate { ...@@ -53,10 +54,12 @@ public class SystemAccountManagerDelegate implements AccountManagerDelegate {
private static final String TAG = "Auth"; private static final String TAG = "Auth";
@SuppressWarnings("deprecation")
public SystemAccountManagerDelegate() { public SystemAccountManagerDelegate() {
mAccountManager = AccountManager.get(ContextUtils.getApplicationContext()); Context context = ContextUtils.getApplicationContext();
mAccountManager = AccountManager.get(context);
BroadcastReceiver accountsChangedBroadcastReceiver = new BroadcastReceiver() { BroadcastReceiver receiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(final Context context, final Intent intent) { public void onReceive(final Context context, final Intent intent) {
fireOnAccountsChangedNotification(); fireOnAccountsChangedNotification();
...@@ -64,8 +67,15 @@ public class SystemAccountManagerDelegate implements AccountManagerDelegate { ...@@ -64,8 +67,15 @@ public class SystemAccountManagerDelegate implements AccountManagerDelegate {
}; };
IntentFilter accountsChangedIntentFilter = new IntentFilter(); IntentFilter accountsChangedIntentFilter = new IntentFilter();
accountsChangedIntentFilter.addAction(AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION); accountsChangedIntentFilter.addAction(AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION);
ContextUtils.getApplicationContext().registerReceiver( context.registerReceiver(receiver, accountsChangedIntentFilter);
accountsChangedBroadcastReceiver, accountsChangedIntentFilter);
IntentFilter gmsPackageReplacedFilter = new IntentFilter();
gmsPackageReplacedFilter.addAction(Intent.ACTION_PACKAGE_REPLACED);
gmsPackageReplacedFilter.addDataScheme("package");
gmsPackageReplacedFilter.addDataPath(
"com.google.android.gms", PatternMatcher.PATTERN_PREFIX);
context.registerReceiver(receiver, gmsPackageReplacedFilter);
} }
protected void checkCanUseGooglePlayServices() throws AccountManagerDelegateException { protected void checkCanUseGooglePlayServices() throws AccountManagerDelegateException {
......
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