use of com.owncloud.android.datamodel.FileDataStorageManager in project android by owncloud.
the class AccountUtils method getServerVersion.
/**
* Access the version of the OC server corresponding to an account SAVED IN THE ACCOUNTMANAGER
*
* @param account ownCloud account
* @return Version of the OC server corresponding to account, according to the data saved
* in the system AccountManager
*/
@Nullable
public static OwnCloudVersion getServerVersion(Account account) {
OwnCloudVersion serverVersion = null;
if (account != null) {
// capabilities are now the preferred source for version info
FileDataStorageManager fileDataStorageManager = new FileDataStorageManager(MainApp.Companion.getAppContext(), account, MainApp.Companion.getAppContext().getContentResolver());
OCCapability capability = fileDataStorageManager.getCapability(account.name);
if (capability != null) {
serverVersion = new OwnCloudVersion(capability.getVersionString());
} else {
// legacy: AccountManager as source of version info
AccountManager accountMgr = AccountManager.get(MainApp.Companion.getAppContext());
String serverVersionStr = accountMgr.getUserData(account, Constants.KEY_OC_VERSION);
if (serverVersionStr != null) {
serverVersion = new OwnCloudVersion(serverVersionStr);
}
}
}
return serverVersion;
}
Aggregations