Add new permission requirements for Firebase Auth to Self-Check

This commit is contained in:
Marvin W 2020-10-12 21:24:45 +02:00
parent c3bfb63f27
commit 0ee18ae6f7
No known key found for this signature in database
GPG Key ID: 072E9235DB996F2A
11 changed files with 43 additions and 14 deletions

View File

@ -57,12 +57,10 @@ public class PermissionCheckGroup implements SelfCheckGroup {
PackageManager pm = context.getPackageManager();
try {
PermissionInfo info = pm.getPermissionInfo(permission, 0);
PermissionGroupInfo groupInfo = info.group != null ? pm.getPermissionGroupInfo(info.group, 0) : null;
CharSequence permLabel = info.loadLabel(pm);
CharSequence groupLabel = groupInfo != null ? groupInfo.loadLabel(pm) : permLabel;
collector.addResult(context.getString(R.string.self_check_name_permission, permLabel),
context.checkSelfPermission(permission) == PackageManager.PERMISSION_GRANTED ? Positive : Negative,
context.getString(R.string.self_check_resolution_permission, groupLabel),
context.getString(R.string.self_check_resolution_permission),
fragment -> fragment.requestPermissions(new String[]{permission}, 0));
} catch (PackageManager.NameNotFoundException e) {
Log.w(TAG, e);

View File

@ -30,7 +30,7 @@
<string name="self_check_cat_permissions">Erteilte Berechtigungen</string>
<string name="self_check_name_permission">%1$s:</string>
<string name="self_check_resolution_permission">Hier drücken, um die Berechtigung \"%1$s\" zu erteilen. Verweigern einer Berechtigung kann zu Fehlverhalten in anderen Anwendungen führen.</string>
<string name="self_check_resolution_permission">Hier drücken, um die Berechtigung zu erteilen. Verweigern einer Berechtigung kann zu Fehlverhalten in anderen Anwendungen führen.</string>
<string name="about_root_title">microG UI Demo</string>
<string name="about_root_summary">Zusammenfassung</string>

View File

@ -30,7 +30,7 @@
<string name="self_check_cat_permissions">Autorisations accordées</string>
<string name="self_check_name_permission">Autorisation à %1$s :</string>
<string name="self_check_resolution_permission">Touchez ici pour accorder lautorisation %1$s. Des applications peuvent mal se comporter si vous ne le faites pas.</string>
<string name="self_check_resolution_permission">Touchez ici pour accorder lautorisation. Des applications peuvent mal se comporter si vous ne le faites pas.</string>
<string name="about_root_version">Version v0.1.0</string>
<string name="about_root_libraries">Librairies incluses</string>

View File

@ -30,7 +30,7 @@
<string name="self_check_cat_permissions">Autorizzazione concessa</string>
<string name="self_check_name_permission">Autorizzazione a %1$s:</string>
<string name="self_check_resolution_permission">Tocca qui per concedere l\'autorizzazione a %1$s. Negare l\'autorizzazione può comportare il funzionamento anomalo di altre applicazioni.</string>
<string name="self_check_resolution_permission">Tocca qui per concedere l\'autorizzazione. Negare l\'autorizzazione può comportare il funzionamento anomalo di altre applicazioni.</string>
<string name="about_root_title">microG UI Demo</string>
<string name="about_root_summary">Sommario</string>

View File

@ -30,7 +30,7 @@
<string name="self_check_cat_permissions">Udzielono uprawnień</string>
<string name="self_check_name_permission">Uprawnienie do %1$s:</string>
<string name="self_check_resolution_permission">Stuknij, aby udzielić uprawnienia na %1$s. Nieudzielenie uprawnienia może powodować problemy z aplikacjami.</string>
<string name="self_check_resolution_permission">Stuknij, aby udzielić uprawnienia. Nieudzielenie uprawnienia może powodować problemy z aplikacjami.</string>
<string name="about_root_title">Demo microG UI</string>
<string name="about_root_summary">Podsumowanie</string>

View File

@ -30,7 +30,7 @@
<string name="self_check_cat_permissions">Права доступа предоставлены</string>
<string name="self_check_name_permission">Разрешение для %1$s:</string>
<string name="self_check_resolution_permission">Нажмите здесь, чтобы дать разрешение на %1$s. Непредоставление разрешения может привести некорректной работе приложения.</string>
<string name="self_check_resolution_permission">Нажмите здесь, чтобы дать разрешение. Непредоставление разрешения может привести некорректной работе приложения.</string>
<string name="about_root_title">microG UI Demo</string>
<string name="about_root_summary">Сводка</string>

View File

@ -23,6 +23,6 @@
<string name="self_check_cat_permissions">Дозволе одобрене</string>
<string name="self_check_name_permission">Дозволе за %1$s:</string>
<string name="self_check_resolution_permission">Тапните овде да одобрите дозволе за %1$s. Не одобравање дозвола може да резултира чудним понашањем апликација.</string>
<string name="self_check_resolution_permission">Тапните овде да одобрите дозволе. Не одобравање дозвола може да резултира чудним понашањем апликација.</string>
</resources>

View File

@ -30,7 +30,7 @@
<string name="self_check_cat_permissions">Доступ надано</string>
<string name="self_check_name_permission">Доступ до %1$s:</string>
<string name="self_check_resolution_permission">Торкніться, аби надати доступ до %1$s. Без доступу не гарантується робота додатку належним чином.</string>
<string name="self_check_resolution_permission">Торкніться, аби надати доступ. Без доступу не гарантується робота додатку належним чином.</string>
<string name="about_root_title">Демонстрація microG UI</string>
<string name="about_root_summary">Резюме</string>

View File

@ -30,7 +30,7 @@
<string name="self_check_cat_permissions">允許權限</string>
<string name="self_check_name_permission">給 %1$s的權限</string>
<string name="self_check_resolution_permission">按這裡給%1$s權限。不允許權限可能導致程式運作不正常。</string>
<string name="self_check_resolution_permission">按這裡給權限。不允許權限可能導致程式運作不正常。</string>
<string name="about_root_title">microG UI Demo</string>
<string name="about_root_summary">大綱</string>

View File

@ -30,7 +30,7 @@
<string name="self_check_cat_permissions">Permissions granted</string>
<string name="self_check_name_permission">Permission to %1$s:</string>
<string name="self_check_resolution_permission">Touch here to grant permission to %1$s. Not granting the permission can result in misbehaving applications.</string>
<string name="self_check_resolution_permission">Touch here to grant permission. Not granting the permission can result in misbehaving applications.</string>
<string name="about_root_title">microG UI Demo</string>
<string name="about_root_summary">Summary</string>

View File

@ -16,8 +16,15 @@
package org.microg.gms.ui;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.PermissionGroupInfo;
import android.content.pm.PermissionInfo;
import android.net.Uri;
import android.os.Build;
import android.provider.Settings;
import android.util.Log;
import android.view.LayoutInflater;
import androidx.annotation.NonNull;
@ -42,6 +49,8 @@ import static android.Manifest.permission.ACCESS_FINE_LOCATION;
import static android.Manifest.permission.GET_ACCOUNTS;
import static android.Manifest.permission.READ_EXTERNAL_STORAGE;
import static android.Manifest.permission.READ_PHONE_STATE;
import static android.Manifest.permission.READ_SMS;
import static android.Manifest.permission.RECEIVE_SMS;
import static android.Manifest.permission.WRITE_EXTERNAL_STORAGE;
import static android.os.Build.VERSION.SDK_INT;
import static android.os.Build.VERSION_CODES.LOLLIPOP_MR1;
@ -52,7 +61,7 @@ public class SelfCheckFragment extends AbstractSelfCheckFragment {
protected void prepareSelfCheckList(List<SelfCheckGroup> checks) {
checks.add(new RomSpoofSignatureChecks());
checks.add(new InstalledPackagesChecks());
if (SDK_INT > LOLLIPOP_MR1) {
if (SDK_INT >= 23) {
List<String> permissions = new ArrayList<>();
permissions.add(ACCESS_COARSE_LOCATION);
permissions.add(ACCESS_FINE_LOCATION);
@ -63,7 +72,29 @@ public class SelfCheckFragment extends AbstractSelfCheckFragment {
permissions.add(WRITE_EXTERNAL_STORAGE);
permissions.add(GET_ACCOUNTS);
permissions.add(READ_PHONE_STATE);
checks.add(new PermissionCheckGroup(permissions.toArray(new String[0])));
permissions.add(RECEIVE_SMS);
checks.add(new PermissionCheckGroup(permissions.toArray(new String[0])) {
@Override
public void doChecks(Context context, ResultCollector collector) {
super.doChecks(context, collector);
PackageManager pm = context.getPackageManager();
try {
PermissionInfo info = pm.getPermissionInfo("android.permission.SYSTEM_ALERT_WINDOW", 0);
CharSequence permLabel = info.loadLabel(pm);
collector.addResult(
context.getString(org.microg.tools.ui.R.string.self_check_name_permission, permLabel),
Settings.canDrawOverlays(context) ? Result.Positive : Result.Negative,
context.getString(org.microg.tools.ui.R.string.self_check_resolution_permission),
fragment -> {
Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION, Uri.parse("package:" + context.getPackageName()));
startActivityForResult(intent, 42);
}
);
} catch (Exception e) {
Log.w("SelfCheckPerms", e);
}
}
});
}
if (SDK_INT >= Build.VERSION_CODES.M) {
checks.add(new SystemChecks());