Only sync adapters with access can see an account - settings

This change ensures that when the user tries to toggle a sync for a
sync adapter that doesn't have access to an account we show UI for
the user to approve the sync.

bug:28163381

Change-Id: I59802df6614572cf0eaf4b72a177beb111b87b34
This commit is contained in:
Svetoslav Ganov
2016-07-11 19:34:21 -07:00
parent 124251d54e
commit 6f9bf1da90
2 changed files with 107 additions and 13 deletions

View File

@@ -36,6 +36,8 @@ public class SyncStateSwitchPreference extends SwitchPreference {
private boolean mFailed = false;
private Account mAccount;
private String mAuthority;
private String mPackageName;
private int mUid;
/**
* A mode for this preference where clicking does a one-time sync instead of
@@ -47,16 +49,21 @@ public class SyncStateSwitchPreference extends SwitchPreference {
super(context, attrs, 0, R.style.SyncSwitchPreference);
mAccount = null;
mAuthority = null;
mPackageName = null;
mUid = 0;
}
public SyncStateSwitchPreference(Context context, Account account, String authority) {
public SyncStateSwitchPreference(Context context, Account account, String authority,
String packageName, int uid) {
super(context, null, 0, R.style.SyncSwitchPreference);
setup(account, authority);
setup(account, authority, packageName, uid);
}
public void setup(Account account, String authority) {
public void setup(Account account, String authority, String packageName, int uid) {
mAccount = account;
mAuthority = authority;
mPackageName = packageName;
mUid = uid;
notifyChanged();
}
@@ -152,4 +159,12 @@ public class SyncStateSwitchPreference extends SwitchPreference {
public String getAuthority() {
return mAuthority;
}
public String getPackageName() {
return mPackageName;
};
public int getUid() {
return mUid;
};
}