Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for new security protocols on older android versions #1226

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ dependencies {
compile project(':owncloud-android-library')
compile 'com.jakewharton:disklrucache:2.0.2'
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services-base:8.1.0'
}

android {
Expand Down
32 changes: 32 additions & 0 deletions src/com/owncloud/android/ui/activity/FileDisplayActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
import android.widget.TextView;
import android.widget.Toast;

import com.google.android.gms.common.GooglePlayServicesNotAvailableException;
import com.google.android.gms.common.GooglePlayServicesRepairableException;
import com.google.android.gms.common.GooglePlayServicesUtil;
import com.google.android.gms.security.ProviderInstaller;
import com.owncloud.android.MainApp;
import com.owncloud.android.R;
import com.owncloud.android.datamodel.FileDataStorageManager;
Expand Down Expand Up @@ -163,6 +167,9 @@ protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); // this calls onAccountChanged() when ownCloud Account
// is valid

// Update security provider to allow TLSv1.2 on devices with Android 16 or higher
updateSecurityProvider();

/// grant that FileObserverService is watching favorite files
if (savedInstanceState == null) {
Intent initObserversIntent = FileObserverService.makeInitIntent(this);
Expand Down Expand Up @@ -287,6 +294,30 @@ protected void onAccountSet(boolean stateWasRecovered) {
}
}

private void updateSecurityProvider() {
try {
ProviderInstaller.installIfNeeded(this);
} catch (GooglePlayServicesRepairableException e) {

// Indicates that Google Play services is out of date, disabled, etc.

// Prompt the user to install/update/enable Google Play services.
GooglePlayServicesUtil.showErrorNotification(
e.getConnectionStatusCode(), this);

Log_OC.e(TAG, "Google Play Services are not updated.");
e.printStackTrace();

return;

} catch (GooglePlayServicesNotAvailableException e) {
Log_OC.e(TAG, "Google Play Services are not available.");
e.printStackTrace();

return;
}
}

private void createMinFragments() {
OCFileListFragment listOfFiles = new OCFileListFragment();
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
Expand Down Expand Up @@ -1801,4 +1832,5 @@ private void sortByName(boolean ascending) {
public void allFilesOption() {
browseToRoot();
}

}