mirror of
https://github.com/TeamVanced/VancedMicroG
synced 2025-01-26 18:57:32 +01:00
Self-Check: Add missing permission check, allow to grant FakeStore spoofing perm
Fixes #1178
This commit is contained in:
parent
03237fc86b
commit
04c955e998
@ -63,13 +63,7 @@ public class PermissionCheckGroup implements SelfCheckGroup {
|
||||
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),
|
||||
new SelfCheckGroup.CheckResolver() {
|
||||
|
||||
@Override
|
||||
public void tryResolve(Fragment fragment) {
|
||||
fragment.requestPermissions(new String[]{permission}, 0);
|
||||
}
|
||||
});
|
||||
fragment -> fragment.requestPermissions(new String[]{permission}, 0));
|
||||
} catch (PackageManager.NameNotFoundException e) {
|
||||
Log.w(TAG, e);
|
||||
}
|
||||
|
@ -33,10 +33,14 @@ import org.microg.tools.selfcheck.SystemChecks;
|
||||
import org.microg.tools.ui.AbstractSelfCheckFragment;
|
||||
import org.microg.tools.ui.AbstractSettingsActivity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static android.Manifest.permission.ACCESS_BACKGROUND_LOCATION;
|
||||
import static android.Manifest.permission.ACCESS_COARSE_LOCATION;
|
||||
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.WRITE_EXTERNAL_STORAGE;
|
||||
import static android.os.Build.VERSION.SDK_INT;
|
||||
@ -49,9 +53,19 @@ public class SelfCheckFragment extends AbstractSelfCheckFragment {
|
||||
checks.add(new RomSpoofSignatureChecks());
|
||||
checks.add(new InstalledPackagesChecks());
|
||||
if (SDK_INT > LOLLIPOP_MR1) {
|
||||
checks.add(new PermissionCheckGroup(ACCESS_COARSE_LOCATION, "android.permission.ACCESS_BACKGROUND_LOCATION", WRITE_EXTERNAL_STORAGE, GET_ACCOUNTS, READ_PHONE_STATE));
|
||||
List<String> permissions = new ArrayList<>();
|
||||
permissions.add(ACCESS_COARSE_LOCATION);
|
||||
permissions.add(ACCESS_FINE_LOCATION);
|
||||
if (SDK_INT >= 29) {
|
||||
permissions.add(ACCESS_BACKGROUND_LOCATION);
|
||||
}
|
||||
permissions.add(READ_EXTERNAL_STORAGE);
|
||||
permissions.add(WRITE_EXTERNAL_STORAGE);
|
||||
permissions.add(GET_ACCOUNTS);
|
||||
permissions.add(READ_PHONE_STATE);
|
||||
checks.add(new PermissionCheckGroup(permissions.toArray(new String[0])));
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (SDK_INT >= Build.VERSION_CODES.M) {
|
||||
checks.add(new SystemChecks());
|
||||
}
|
||||
// checks.add(new NlpOsCompatChecks());
|
||||
@ -65,10 +79,8 @@ public class SelfCheckFragment extends AbstractSelfCheckFragment {
|
||||
|
||||
@Override
|
||||
public void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||
if (requestCode == SystemChecks.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS)
|
||||
reset(LayoutInflater.from(getContext()));
|
||||
else
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
reset(LayoutInflater.from(getContext()));
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
}
|
||||
|
||||
public static class AsActivity extends AbstractSettingsActivity {
|
||||
|
@ -16,8 +16,13 @@
|
||||
|
||||
package org.microg.tools.selfcheck;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.google.android.gms.R;
|
||||
|
||||
@ -49,11 +54,25 @@ public class InstalledPackagesChecks implements SelfCheckGroup {
|
||||
|
||||
private boolean addPackageSignedResult(Context context, ResultCollector collector, String nicePackageName, String androidPackageName, String signatureHash) {
|
||||
boolean hashMatches = signatureHash.equals(PackageUtils.firstSignatureDigest(context, androidPackageName));
|
||||
collector.addResult(context.getString(R.string.self_check_name_correct_sig, nicePackageName), hashMatches ? Positive : Negative,
|
||||
context.getString(R.string.self_check_resolution_correct_sig, nicePackageName));
|
||||
collector.addResult(context.getString(R.string.self_check_name_correct_sig, nicePackageName),
|
||||
hashMatches ? Positive : Negative,
|
||||
context.getString(R.string.self_check_resolution_correct_sig, nicePackageName),
|
||||
fragment -> tryGrantFakeSignaturePermissionActivity(fragment, androidPackageName));
|
||||
return hashMatches;
|
||||
}
|
||||
|
||||
private void tryGrantFakeSignaturePermissionActivity(Fragment fragment, String androidPackageName) {
|
||||
ComponentName grantPermissionActivity = new ComponentName(androidPackageName, androidPackageName + ".GrantFakeSignaturePermissionActivity");
|
||||
try {
|
||||
Intent intent = new Intent();
|
||||
intent.setPackage(androidPackageName);
|
||||
intent.setComponent(grantPermissionActivity);
|
||||
fragment.startActivityForResult(intent, 1);
|
||||
} catch (Exception e) {
|
||||
Log.w("SelfCheck", e);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean addPackageInstalledResult(Context context, ResultCollector collector, String nicePackageName, String androidPackageName) {
|
||||
boolean packageExists = true;
|
||||
try {
|
||||
|
Loading…
x
Reference in New Issue
Block a user