Add initial version of self check

To be extended and should have better UI :)
This commit is contained in:
mar-v-in 2016-01-02 10:59:49 +01:00
parent 38364b79ee
commit 6e091a0ffa
6 changed files with 223 additions and 23 deletions

View File

@ -327,6 +327,32 @@
</intent-filter>
</activity>
<!-- microG custom UI -->
<activity
android:name="org.microg.gms.ui.SettingsActivity"
android:icon="@mipmap/ic_microg_settings"
android:label="@string/gms_settings_name"
android:theme="@style/SettingsTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="com.google.android.gms.location.settings.LOCATION_HISTORY"/>
<action android:name="com.google.android.location.settings.LOCATION_REPORTING_SETTINGS"/>
<action android:name="com.google.android.gms.location.settings.LOCATION_REPORTING_SETTINGS"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity
android:name="org.microg.gms.ui.SelfCheckActivity"
android:label="@string/self_check_title"
android:theme="@style/SettingsTheme"/>
<!-- Other -->
<service
@ -370,25 +396,6 @@
android:name=".gcm.http.GoogleHttpService"
android:exported="true"/>
<activity
android:name="org.microg.gms.ui.SettingsActivity"
android:icon="@mipmap/ic_microg_settings"
android:label="@string/gms_settings_name"
android:theme="@style/SettingsTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<action android:name="com.google.android.gms.location.settings.LOCATION_HISTORY"/>
<action android:name="com.google.android.location.settings.LOCATION_REPORTING_SETTINGS"/>
<action android:name="com.google.android.gms.location.settings.LOCATION_REPORTING_SETTINGS"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<service
android:name="org.microg.gms.ads.GService"
android:exported="true">

View File

@ -0,0 +1,32 @@
/*
* Copyright 2013-2015 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.gms.ui;
import org.microg.tools.selfcheck.AbstractSelfCheckActivity;
import org.microg.tools.selfcheck.InstalledPackagesChecks;
import org.microg.tools.selfcheck.RomSpoofSignatureChecks;
import org.microg.tools.selfcheck.SelfCheckGroup;
import java.util.List;
public class SelfCheckActivity extends AbstractSelfCheckActivity implements SelfCheckGroup.ResultCollector {
protected void prepareSelfCheckList(List<SelfCheckGroup> checks) {
checks.add(new RomSpoofSignatureChecks());
checks.add(new InstalledPackagesChecks());
}
}

View File

@ -0,0 +1,66 @@
/*
* Copyright 2013-2015 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 org.microg.tools.selfcheck.SelfCheckGroup;
public class InstalledPackagesChecks implements SelfCheckGroup {
@Override
public String getGroupName(Context context) {
return "Installed packages";
}
@Override
public void doChecks(Context context, ResultCollector collector) {
addPackageInstalledAndSignedResult(context, collector, "Play Services (GmsCore)", Constants.GMS_PACKAGE_NAME, Constants.GMS_PACKAGE_SIGNATURE_SHA1);
addPackageInstalledAndSignedResult(context, collector, "Play Store (Phonesky)", "com.android.vending", Constants.GMS_PACKAGE_SIGNATURE_SHA1);
addPackageInstalledResult(context, collector, "Services Framework (GSF)", "com.google.android.gsf");
}
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,
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,
context.getString(R.string.self_check_resolution_app_installed, nicePackageName));
return packageExists;
}
}

View File

@ -0,0 +1,71 @@
/*
* Copyright 2013-2015 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 org.microg.tools.selfcheck.SelfCheckGroup;
public class RomSpoofSignatureChecks implements SelfCheckGroup {
public static final String FAKE_SIGNATURE_PERMISSION = "android.permission.FAKE_PACKAGE_SIGNATURE";
@Override
public String getGroupName(Context context) {
return "ROM spoof signature support";
}
@Override
public void doChecks(Context context, ResultCollector collector) {
if (addRomKnowsFakeSignaturePermission(context, collector)) {
if (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,
context.getString(R.string.self_check_resolution_fake_sig_perm));
return knowsPermission;
}
private boolean addSystemGrantsFakeSignaturePermission(Context context, ResultCollector collector) {
boolean grantsPermission = context.checkCallingOrSelfPermission(FAKE_SIGNATURE_PERMISSION) == PackageManager.PERMISSION_GRANTED;
collector.addResult(context.getString(R.string.self_check_name_perm_granted), grantsPermission,
context.getString(R.string.self_check_resolution_perm_granted));
return grantsPermission;
}
private boolean addSystemSpoofsSignature(Context context, ResultCollector collector) {
boolean spoofsSignature = Constants.GMS_PACKAGE_SIGNATURE_SHA1.equals(PackageUtils.firstSignatureDigest(context, Constants.GMS_PACKAGE_NAME));
collector.addResult(context.getString(R.string.self_check_name_system_spoofs), spoofsSignature,
context.getString(R.string.self_check_resolution_system_spoofs));
return spoofsSignature;
}
}

View File

@ -49,6 +49,21 @@ This can take a couple of minutes."</string>
<string name="pref_auth_trust_google_title">Trust Google for app permissions</string>
<string name="pref_auth_trust_google_summary">When disabled, the user is asked before an apps authorization request is sent to Google. Some applications will fail to use the Google account if this is disabled.</string>
<string name="prefcat_setup">Setup</string>
<string name="self_check_title">microG Self-Check</string>
<string name="self_check_desc">Check if the system is correctly set up to use microG.</string>
<string name="self_check_name_fake_sig_perm">System has signature spoofing support: </string>
<string name="self_check_resolution_fake_sig_perm">You ROM has no native support for signature spoofing. You can still use Xposed or other systems to spoof signature. Please check the documentation on which ROMs do support signature spoofing and how to use microG on ROMs that do not.</string>
<string name="self_check_name_perm_granted">System grants signature spoofing permission: </string>
<string name="self_check_resolution_perm_granted">This is a strong indicator that the ROM does support signature spoofing, but requires further action to activate it. Please check the documentation on which steps might be required.</string>
<string name="self_check_name_system_spoofs">System spoofs signature: </string>
<string name="self_check_resolution_system_spoofs">This is a strong indicator that the ROM does support signature spoofing, but requires further action to activate it. Please check the documentation on which steps might be required.</string>
<string name="self_check_name_app_installed">%1$s installed: </string>
<string name="self_check_resolution_app_installed">Install the application %1$s or a compatible one. Please check the documentation on which applications are compatible.</string>
<string name="self_check_name_correct_sig">%1$s has correct signature: </string>
<string name="self_check_resolution_correct_sig">Either the installed %1$s is not compatible, signature spoofing is not enabled for it or your ROM does not properly support signature spoofing. Please check the documentation on which applications and ROMs are compatible.</string>
<string name="prefcat_services">Background services</string>
<string name="pref_checkin_enable" translatable="false">checkin_enable_service</string>

View File

@ -15,30 +15,39 @@
-->
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
<PreferenceCategory android:title="@string/prefcat_setup">
<Preference
android:summary="@string/self_check_desc"
android:title="@string/self_check_title">
<intent
android:targetClass="org.microg.gms.ui.SelfCheckActivity"
android:targetPackage="com.google.android.gms"/>
</Preference>
</PreferenceCategory>
<PreferenceCategory android:title="@string/prefcat_services">
<CheckBoxPreference
android:defaultValue="false"
android:key="@string/pref_checkin_enable"
android:summary="@string/pref_checkin_enable_summary"
android:title="@string/pref_checkin_enable_title" />
android:title="@string/pref_checkin_enable_title"/>
<CheckBoxPreference
android:defaultValue="false"
android:dependency="@string/pref_checkin_enable"
android:key="@string/pref_gcm_enable_mcs"
android:summary="@string/pref_gcm_enable_mcs_summary"
android:title="@string/pref_gcm_enable_mcs_title" />
android:title="@string/pref_gcm_enable_mcs_title"/>
<EditTextPreference
android:defaultValue="60"
android:dependency="@string/pref_gcm_enable_mcs"
android:key="@string/pref_gcm_heartbeat"
android:summary="@string/pref_gcm_heartbeat_summary"
android:title="@string/pref_gcm_heartbeat_title" />
android:title="@string/pref_gcm_heartbeat_title"/>
</PreferenceCategory>
<PreferenceCategory android:title="@string/prefcat_location_service">
<Preference android:title="@string/nlp_settings_label">
<intent
android:targetClass="org.microg.nlp.ui.SettingsActivity"
android:targetPackage="com.google.android.gms" />
android:targetPackage="com.google.android.gms"/>
</Preference>
</PreferenceCategory>
</PreferenceScreen>