From d6b2eb76915f1bf3de9d3a127d17f8291a378e22 Mon Sep 17 00:00:00 2001 From: Sandro Machado Date: Thu, 29 Oct 2015 23:58:55 +0000 Subject: [PATCH] Add support for new security protocols on older android versions --- build.gradle | 1 + .../ui/activity/FileDisplayActivity.java | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/build.gradle b/build.gradle index a0db0184c09..c90daea5b90 100644 --- a/build.gradle +++ b/build.gradle @@ -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 { diff --git a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java index 240d146fb58..48fdbdc21ba 100644 --- a/src/com/owncloud/android/ui/activity/FileDisplayActivity.java +++ b/src/com/owncloud/android/ui/activity/FileDisplayActivity.java @@ -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; @@ -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); @@ -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(); @@ -1801,4 +1832,5 @@ private void sortByName(boolean ascending) { public void allFilesOption() { browseToRoot(); } + }