Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/passman-android.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWolFi <wolfi@wolfi.es>2022-09-11 18:50:19 +0300
committerWolFi <wolfi@wolfi.es>2022-09-11 18:50:19 +0300
commit844bcef173e9daf253ef6d804b7c1039e50eb8e0 (patch)
treeef722097d3d5bedacbf3225ada5fd157cb8f1b12
parent72ecc2ac6d47e87b5041ed5abf89ed859fedbd33 (diff)
parented25b602611c540c814c4a34c167daf6475cc545 (diff)
Merge branch 'fix-sso-ompatibility2'
-rw-r--r--app/src/main/java/es/wolfi/app/passman/activities/LoginActivity.java29
-rw-r--r--app/src/main/java/es/wolfi/app/passman/fragments/SettingsFragment.java3
-rw-r--r--app/src/main/java/es/wolfi/passman/API/Core.java3
-rw-r--r--app/src/main/java/es/wolfi/utils/SSOUtils.java62
4 files changed, 69 insertions, 28 deletions
diff --git a/app/src/main/java/es/wolfi/app/passman/activities/LoginActivity.java b/app/src/main/java/es/wolfi/app/passman/activities/LoginActivity.java
index a66bbb6..0eeb7ab 100644
--- a/app/src/main/java/es/wolfi/app/passman/activities/LoginActivity.java
+++ b/app/src/main/java/es/wolfi/app/passman/activities/LoginActivity.java
@@ -3,6 +3,7 @@
*
* @copyright Copyright (c) 2016, Sander Brand (brantje@gmail.com)
* @copyright Copyright (c) 2016, Marcos Zuriaga Miguel (wolfi@wolfi.es)
+ * @copyright Copyright (c) 2022, Timo Triebensky (timo@binsky.org)
* @license GNU AGPL version 3 or any later version
* <p>
* This program is free software: you can redistribute it and/or modify
@@ -23,8 +24,6 @@ package es.wolfi.app.passman.activities;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
-import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
@@ -44,7 +43,6 @@ import androidx.appcompat.widget.Toolbar;
import com.koushikdutta.async.future.FutureCallback;
import com.nextcloud.android.sso.AccountImporter;
-import com.nextcloud.android.sso.Constants;
import com.nextcloud.android.sso.exceptions.AccountImportCancelledException;
import com.nextcloud.android.sso.exceptions.AndroidGetAccountsPermissionNotGranted;
import com.nextcloud.android.sso.exceptions.NextcloudFilesAppAccountNotFoundException;
@@ -56,8 +54,6 @@ import com.nextcloud.android.sso.ui.UiExceptionManager;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.Arrays;
-import java.util.List;
import butterknife.BindView;
import butterknife.ButterKnife;
@@ -68,6 +64,7 @@ import es.wolfi.app.passman.SettingValues;
import es.wolfi.app.passman.SingleTon;
import es.wolfi.passman.API.Core;
import es.wolfi.utils.KeyStoreUtils;
+import es.wolfi.utils.SSOUtils;
public class LoginActivity extends AppCompatActivity {
public final static String LOG_TAG = "LoginActivity";
@@ -98,7 +95,7 @@ public class LoginActivity extends AppCompatActivity {
new OfflineStorage(getBaseContext());
- if (!isNextcloudFilesAppInstalled(this)) {
+ if (!SSOUtils.isNextcloudFilesAppInstalled(this)) {
isLegacyOnly = true;
loadLegacyLogin();
}
@@ -188,26 +185,6 @@ public class LoginActivity extends AppCompatActivity {
login_options.setVisibility(View.INVISIBLE);
}
- private static boolean isNextcloudFilesAppInstalled(Context context) {
- List<String> APPS = Arrays.asList(Constants.PACKAGE_NAME_PROD, Constants.PACKAGE_NAME_DEV);
-
- boolean returnValue = false;
- PackageManager pm = context.getPackageManager();
- for (String app : APPS) {
- try {
- PackageInfo pi = pm.getPackageInfo(app, PackageManager.GET_ACTIVITIES);
- // check if Nextcloud Files App version with the required PATCH request fix is installed
- if ((pi.versionCode >= 30180052 && pi.packageName.equals("com.nextcloud.client")) ||
- pi.versionCode >= 20211027 && pi.packageName.equals("com.nextcloud.android.beta")) {
- returnValue = true;
- break;
- }
- } catch (PackageManager.NameNotFoundException ignored) {
- }
- }
- return returnValue;
- }
-
@OnClick(R.id.next)
public void onNextClick() {
Log.e("Login", "begin");
diff --git a/app/src/main/java/es/wolfi/app/passman/fragments/SettingsFragment.java b/app/src/main/java/es/wolfi/app/passman/fragments/SettingsFragment.java
index bb70f43..10a3e92 100644
--- a/app/src/main/java/es/wolfi/app/passman/fragments/SettingsFragment.java
+++ b/app/src/main/java/es/wolfi/app/passman/fragments/SettingsFragment.java
@@ -193,7 +193,8 @@ public class SettingsFragment extends Fragment {
Log.d("SettingsFragment", "Error parsing host from sso account");
}
sso_user_server.setText(String.format("%s@%s", ssoAccount.userId, hostname));
- } catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
+ } catch (java.lang.NoSuchMethodError |
+ NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
manual_server_connection_settings.setVisibility(View.VISIBLE);
sso_settings.removeAllViews();
}
diff --git a/app/src/main/java/es/wolfi/passman/API/Core.java b/app/src/main/java/es/wolfi/passman/API/Core.java
index babf4c2..e136605 100644
--- a/app/src/main/java/es/wolfi/passman/API/Core.java
+++ b/app/src/main/java/es/wolfi/passman/API/Core.java
@@ -96,7 +96,8 @@ public abstract class Core {
try {
Core.ssoAccount = SingleAccountHelper.getCurrentSingleSignOnAccount(c);
- } catch (NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
+ } catch (java.lang.NoSuchMethodError |
+ NextcloudFilesAppAccountNotFoundException | NoCurrentAccountSelectedException e) {
e.printStackTrace();
}
}
diff --git a/app/src/main/java/es/wolfi/utils/SSOUtils.java b/app/src/main/java/es/wolfi/utils/SSOUtils.java
new file mode 100644
index 0000000..1b72248
--- /dev/null
+++ b/app/src/main/java/es/wolfi/utils/SSOUtils.java
@@ -0,0 +1,62 @@
+/**
+ * Passman Android App
+ *
+ * @copyright Copyright (c) 2022, Timo Triebensky (timo@binsky.org)
+ * @license GNU AGPL version 3 or any later version
+ * <p>
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ * <p>
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ * <p>
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package es.wolfi.utils;
+
+import android.content.Context;
+import android.content.pm.PackageInfo;
+import android.content.pm.PackageManager;
+
+import com.nextcloud.android.sso.model.FilesAppType;
+
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Utils for Nextcloud files app based SSO
+ */
+public class SSOUtils {
+
+ /**
+ * Checks whether a supported Nextcloud files app is installed or not.
+ *
+ * @param context Context to get packageManager
+ * @return whether a supported Nextcloud files app is installed or not
+ */
+ public static boolean isNextcloudFilesAppInstalled(Context context) {
+ List<String> APPS = Arrays.asList(FilesAppType.PROD.packageId, FilesAppType.DEV.packageId);
+
+ boolean returnValue = false;
+ PackageManager pm = context.getPackageManager();
+ for (String app : APPS) {
+ try {
+ PackageInfo pi = pm.getPackageInfo(app, PackageManager.GET_ACTIVITIES);
+ // Nextcloud Files app version 30180090 is required by the used SSO library
+ if ((pi.versionCode >= 30180090 && pi.packageName.equals("com.nextcloud.client")) ||
+ pi.versionCode >= 20211118 && pi.packageName.equals("com.nextcloud.android.beta")) {
+ returnValue = true;
+ break;
+ }
+ } catch (PackageManager.NameNotFoundException ignored) {
+ }
+ }
+ return returnValue;
+ }
+}