fixed R attribute imports

This commit is contained in:
X1nto 2020-07-27 20:46:20 +04:00
parent 08f7eb2e8c
commit 75a93f052e
10 changed files with 2 additions and 218 deletions

View File

@ -1,68 +0,0 @@
/*
* Copyright (C) 2013-2017 microG Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.microg.tools.selfcheck;
import android.content.Context;
import android.content.pm.PackageManager;
import com.google.android.gms.R;
import org.microg.gms.common.Constants;
import org.microg.gms.common.PackageUtils;
import static org.microg.tools.selfcheck.SelfCheckGroup.Result.Negative;
import static org.microg.tools.selfcheck.SelfCheckGroup.Result.Positive;
public class InstalledPackagesChecks implements SelfCheckGroup {
@Override
public String getGroupName(Context context) {
return context.getString(R.string.self_check_cat_gms_packages);
}
@Override
public void doChecks(Context context, ResultCollector collector) {
addPackageInstalledAndSignedResult(context, collector, context.getString(R.string.self_check_pkg_gms), Constants.GMS_PACKAGE_NAME, Constants.GMS_PACKAGE_SIGNATURE_SHA1);
addPackageInstalledAndSignedResult(context, collector, context.getString(R.string.self_check_pkg_vending), "com.android.vending", Constants.GMS_PACKAGE_SIGNATURE_SHA1);
addPackageInstalledResult(context, collector, context.getString(R.string.self_check_pkg_gsf), Constants.GSF_PACKAGE_NAME);
}
private void addPackageInstalledAndSignedResult(Context context, ResultCollector collector, String nicePackageName, String androidPackageName, String signatureHash) {
if (addPackageInstalledResult(context, collector, nicePackageName, androidPackageName)) {
addPackageSignedResult(context, collector, nicePackageName, androidPackageName, signatureHash);
}
}
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));
return hashMatches;
}
private boolean addPackageInstalledResult(Context context, ResultCollector collector, String nicePackageName, String androidPackageName) {
boolean packageExists = true;
try {
context.getPackageManager().getPackageInfo(androidPackageName, 0);
} catch (PackageManager.NameNotFoundException e) {
packageExists = false;
}
collector.addResult(context.getString(R.string.self_check_name_app_installed, nicePackageName), packageExists ? Positive : Negative,
context.getString(R.string.self_check_resolution_app_installed, nicePackageName));
return packageExists;
}
}

View File

@ -1,84 +0,0 @@
/*
* Copyright (C) 2013-2017 microG Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.microg.tools.selfcheck;
import android.content.Context;
import android.content.pm.PackageManager;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
import com.google.android.gms.R;
import org.microg.gms.common.Constants;
import org.microg.gms.common.PackageUtils;
import static android.content.pm.PackageManager.PERMISSION_GRANTED;
import static org.microg.gms.common.Constants.GMS_PACKAGE_SIGNATURE_SHA1;
import static org.microg.tools.selfcheck.SelfCheckGroup.Result.Negative;
import static org.microg.tools.selfcheck.SelfCheckGroup.Result.Positive;
import static org.microg.tools.selfcheck.SelfCheckGroup.Result.Unknown;
public class RomSpoofSignatureChecks implements SelfCheckGroup {
public static final String FAKE_SIGNATURE_PERMISSION = "android.permission.FAKE_PACKAGE_SIGNATURE";
@Override
public String getGroupName(Context context) {
return context.getString(R.string.self_check_cat_fake_sig);
}
@Override
public void doChecks(Context context, ResultCollector collector) {
boolean hasPermission = addRomKnowsFakeSignaturePermission(context, collector);
if (hasPermission) {
addSystemGrantsFakeSignaturePermission(context, collector);
}
addSystemSpoofsSignature(context, collector);
}
private boolean addRomKnowsFakeSignaturePermission(Context context, ResultCollector collector) {
boolean knowsPermission = true;
try {
context.getPackageManager().getPermissionInfo(FAKE_SIGNATURE_PERMISSION, 0);
} catch (PackageManager.NameNotFoundException e) {
knowsPermission = false;
}
collector.addResult(context.getString(R.string.self_check_name_fake_sig_perm), knowsPermission ? Positive : Unknown,
context.getString(R.string.self_check_resolution_fake_sig_perm));
return knowsPermission;
}
private boolean addSystemGrantsFakeSignaturePermission(Context context, ResultCollector collector) {
boolean grantsPermission = ContextCompat.checkSelfPermission(context, FAKE_SIGNATURE_PERMISSION) == PERMISSION_GRANTED;
collector.addResult(context.getString(R.string.self_check_name_perm_granted), grantsPermission ? Positive : Negative,
context.getString(R.string.self_check_resolution_perm_granted), new CheckResolver() {
@Override
public void tryResolve(Fragment fragment) {
fragment.requestPermissions(new String[]{FAKE_SIGNATURE_PERMISSION}, 0);
}
});
return grantsPermission;
}
private boolean addSystemSpoofsSignature(Context context, ResultCollector collector) {
boolean spoofsSignature = GMS_PACKAGE_SIGNATURE_SHA1.equals(PackageUtils.firstSignatureDigest(context, Constants.GMS_PACKAGE_NAME));
collector.addResult(context.getString(R.string.self_check_name_system_spoofs), spoofsSignature ? Positive : Negative,
context.getString(R.string.self_check_resolution_system_spoofs));
return spoofsSignature;
}
}

View File

@ -1,61 +0,0 @@
/*
* Copyright (C) 2013-2017 microG Project Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.microg.tools.selfcheck;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.PowerManager;
import android.provider.Settings;
import androidx.fragment.app.Fragment;
import com.google.android.gms.R;
import static org.microg.tools.selfcheck.SelfCheckGroup.Result.Negative;
import static org.microg.tools.selfcheck.SelfCheckGroup.Result.Positive;
@TargetApi(23)
public class SystemChecks implements SelfCheckGroup, SelfCheckGroup.CheckResolver {
public static final int REQUEST_IGNORE_BATTERY_OPTIMIZATIONS = 417;
@Override
public String getGroupName(Context context) {
return context.getString(R.string.self_check_cat_system);
}
@Override
public void doChecks(Context context, ResultCollector collector) {
isBatterySavingDisabled(context, collector);
}
private void isBatterySavingDisabled(final Context context, ResultCollector collector) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
collector.addResult(context.getString(R.string.self_check_name_battery_optimizations),
pm.isIgnoringBatteryOptimizations(context.getPackageName()) ? Positive : Negative,
context.getString(R.string.self_check_resolution_battery_optimizations), this);
}
@Override
public void tryResolve(Fragment fragment) {
Intent intent = new Intent(Settings.ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
intent.setData(Uri.parse("package:" + fragment.getActivity().getPackageName()));
fragment.startActivityForResult(intent, REQUEST_IGNORE_BATTERY_OPTIMIZATIONS);
}
}

View File

@ -54,7 +54,6 @@
<FrameLayout
android:background="@drawable/circle_shape_background"
android:layout_marginEnd="-3dp"
android:layout_marginRight="-3dp"
android:layout_width="64dp"
android:layout_height="64dp"
android:padding="10dp">
@ -69,13 +68,12 @@
<FrameLayout
android:background="@drawable/circle_shape_background"
android:layout_marginStart="-3dp"
android:layout_marginLeft="-3dp"
android:layout_width="64dp"
android:layout_height="64dp"
android:padding="10dp">
<ImageView
android:src="@mipmap/ic_core_service_app"
android:src="@mipmap/ic_launcher"
android:id="@+id/app_icon"
android:layout_width="match_parent"
android:layout_height="match_parent" />

View File

@ -5,8 +5,7 @@
-->
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
xmlns:app="http://schemas.android.com/apk/res-auto">
<data>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB