Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7b3e490d authored by Marvin W.'s avatar Marvin W. 🐿️
Browse files

Add settings and Fix small MCS problems

parent 0e0309df
Loading
Loading
Loading
Loading
+28 −27
Original line number Diff line number Diff line
@@ -24,38 +24,37 @@

    <permission
        android:name="com.google.android.c2dm.permission.RECEIVE"
        android:protectionLevel="dangerous"
        android:label="@string/perm_c2dm_receive_label"
        android:permissionGroup="android.permission-group.NETWORK"
        android:label="@string/perm_c2dm_receive_label" />
        android:protectionLevel="dangerous" />
    <permission
        android:name="com.google.android.c2dm.permission.SEND"
        android:protectionLevel="dangerous"
        android:label="@string/perm_c2dm_send_label" />
        android:label="@string/perm_c2dm_send_label"
        android:protectionLevel="dangerous" />

    <permission-tree
        android:icon="@drawable/proprietary_auth_ic_scope_icon_default"
        android:name="com.google.android.googleapps.permission.GOOGLE_AUTH" />
        android:name="com.google.android.googleapps.permission.GOOGLE_AUTH"
        android:icon="@drawable/proprietary_auth_ic_scope_icon_default" />

    <permission
        android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.local"
        android:protectionLevel="dangerous"
        android:description="@string/permission_service_local_description"
        android:label="@string/permission_service_local_label" />
        android:label="@string/permission_service_local_label"
        android:protectionLevel="dangerous" />
    <permission
        android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.mail"
        android:protectionLevel="dangerous"
        android:description="@string/permission_service_mail_description"
        android:label="@string/permission_service_mail_label" />
        android:label="@string/permission_service_mail_label"
        android:protectionLevel="dangerous" />
    <permission
        android:name="com.google.android.googleapps.permission.GOOGLE_AUTH.writely"
        android:protectionLevel="dangerous"
        android:description="@string/permission_service_writely_description"
        android:label="@string/permission_service_writely_label" />

        android:label="@string/permission_service_writely_label"
        android:protectionLevel="dangerous" />
    <permission
        android:name="org.microg.gms.STATUS_BROADCAST"
        android:protectionLevel="dangerous"
        android:label="@string/perm_status_broadcast_label" />
        android:label="@string/perm_status_broadcast_label"
        android:protectionLevel="dangerous" />

    <uses-permission android:name="android.permission.FAKE_PACKAGE_SIGNATURE" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
@@ -71,7 +70,6 @@
    <uses-permission android:name="com.google.android.c2dm.permission.SEND" />
    <uses-permission android:name="org.microg.gms.STATUS_BROADCAST" />


    <application
        android:icon="@drawable/ic_microg_app"
        android:label="@string/gms_app_name">
@@ -88,7 +86,6 @@
                <action android:name="com.google.android.location.internal.GoogleLocationManagerService.START" />
            </intent-filter>
        </service>

        <service android:name="org.microg.gms.location.ReportingAndroidService">
            <intent-filter>
                <action android:name="com.google.android.location.reporting.service.START" />
@@ -104,12 +101,10 @@
            android:name="org.microg.gms.gservices.GServicesProvider"
            android:authorities="com.google.android.gsf.gservices"
            android:exported="true" />

        <provider
            android:name="org.microg.gms.settings.GoogleSettingsProvider"
            android:authorities="com.google.settings"
            android:exported="true" />

        <provider
            android:name="org.microg.gms.feeds.SubscribedFeedsProvider"
            android:authorities="subscribedfeeds"
@@ -156,12 +151,14 @@
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </service>

        <service
            android:name="org.microg.gms.gcm.McsService"
            android:exported="true" />

        <receiver android:name="org.microg.gms.gcm.TriggerReceiver">
            <intent-filter>
                <action android:name="android.net.conn.CONNECTIVITY_CHANGE" />
            </intent-filter>
            <intent-filter>
                <action android:name="android.provider.Telephony.SECRET_CODE" />

@@ -235,7 +232,6 @@
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity
            android:name="org.microg.gms.auth.login.LoginActivity"
            android:configChanges="keyboardHidden|orientation|screenSize"
@@ -247,7 +243,6 @@
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        <activity
            android:name="org.microg.gms.auth.AskPermissionActivity"
            android:excludeFromRecents="true"
@@ -273,7 +268,6 @@
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </service>

        <service
            android:name="org.microg.gms.icing.LightweightIndexService"
            android:exported="true">
@@ -281,7 +275,6 @@
                <action android:name="com.google.android.gms.icing.LIGHTWEIGHT_INDEX_SERVICE" />
            </intent-filter>
        </service>

        <service
            android:name="org.microg.gms.icing.IndexService"
            android:exported="true">
@@ -289,7 +282,6 @@
                <action android:name="com.google.android.gms.icing.INDEX_SERVICE" />
            </intent-filter>
        </service>

        <service
            android:name=".analytics.service.AnalyticsService"
            android:exported="true">
@@ -297,7 +289,6 @@
                <action android:name="com.google.android.gms.analytics.service.START" />
            </intent-filter>
        </service>

        <service
            android:name="org.microg.gms.playlog.PlayLogService"
            android:exported="true">
@@ -305,10 +296,20 @@
                <action android:name="com.google.android.gms.playlog.service.START" />
            </intent-filter>
        </service>

        <service
            android:name=".gcm.http.GoogleHttpService"
            android:exported="true" />

        <activity
            android:name="org.microg.gms.ui.SettingsActivity"
            android:icon="@drawable/ic_microg_app"
            android:label="@string/gms_settings_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

    </application>

</manifest>
+2 −2
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ public class AuthManager {

    private static final String TAG = "GmsAuthManager";
    public static final String PERMISSION_TREE_BASE = "com.google.android.googleapps.permission.GOOGLE_AUTH.";
    private static final String PREF_KEY_TRUST_GOOGLE = "auth_manager_trust_google";
    private static final String PREF_AUTH_TRUST_GOOGLE = "auth_manager_trust_google";

    private final Context context;
    private final String accountName;
@@ -165,7 +165,7 @@ public class AuthManager {
    }

    public static boolean isTrustGooglePermitted(Context context) {
        return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(PREF_KEY_TRUST_GOOGLE, true);
        return PreferenceManager.getDefaultSharedPreferences(context).getBoolean(PREF_AUTH_TRUST_GOOGLE, true);
    }

    private boolean isSystemApp() {
+3 −3
Original line number Diff line number Diff line
@@ -16,7 +16,6 @@

package org.microg.gms.gcm;

import android.util.Base64;
import android.util.Log;

import com.squareup.wire.Message;
@@ -92,8 +91,9 @@ public class McsInputStream {
        Log.d(TAG, "Reading from MCS tag=" + mcsTag + " size=" + mcsSize);
        byte[] bytes = new byte[mcsSize];
        int len = 0;
        while ((len += is.read(bytes, len, mcsSize - len)) < mcsSize) ;
        Log.d(TAG, "Reading from MCS: " + Base64.encodeToString(bytes, 0));
        while (len < mcsSize) {
            len += is.read(bytes, len, mcsSize - len);
        }
        Message read = read(mcsTag, bytes, len);
        Log.d(TAG, "Read from MCS: " + read);
        streamId++;
+8 −7
Original line number Diff line number Diff line
@@ -58,13 +58,14 @@ public class McsService extends IntentService {
    public static final String FROM_FIELD = "gcm@android.com";

    public static final int HEARTBEAT_MS = 60000;
    private static AtomicBoolean connected = new AtomicBoolean(false);
    public static final int HEARTBEAT_ALLOWED_OFFSET_MS = 2000;
    private static final AtomicBoolean connecting = new AtomicBoolean(false);
    private static Thread connectionThread;
    private static Thread heartbeatThread;

    private Socket sslSocket;
    private McsInputStream inputStream;
    private McsOutputStream outputStream;
    private Thread connectionThread;
    private Thread heartbeatThread;
    private long lastMsgTime;

    public McsService() {
@@ -73,7 +74,7 @@ public class McsService extends IntentService {

    @Override
    protected void onHandleIntent(Intent intent) {
        if (connected.compareAndSet(false, true)) {
        if (!isConnected()) {
            connectionThread = new Thread(new Runnable() {
                @Override
                public void run() {
@@ -87,7 +88,7 @@ public class McsService extends IntentService {
    }

    public static boolean isConnected() {
        return connected.get();
        return connecting.get() || (connectionThread != null && connectionThread.isAlive());
    }

    private void heartbeatLoop() {
@@ -95,7 +96,7 @@ public class McsService extends IntentService {
            while (!Thread.interrupted()) {
                try {
                    long waitTime;
                    while ((waitTime = lastMsgTime + HEARTBEAT_MS - System.currentTimeMillis()) > 0) {
                    while ((waitTime = lastMsgTime + HEARTBEAT_MS - System.currentTimeMillis()) > HEARTBEAT_ALLOWED_OFFSET_MS) {
                        synchronized (heartbeatThread) {
                            Log.d(TAG, "Waiting for " + waitTime + "ms");
                            heartbeatThread.wait(waitTime);
@@ -123,6 +124,7 @@ public class McsService extends IntentService {
    }

    private void connect() {
        connecting.set(false);
        try {
            Log.d(TAG, "Starting MCS connection...");
            LastCheckinInfo info = LastCheckinInfo.read(this);
@@ -160,7 +162,6 @@ public class McsService extends IntentService {
            heartbeatThread.interrupt();
            heartbeatThread = null;
        }
        connected.set(false);
        Log.d(TAG, "Connection closed");
    }

+11 −3
Original line number Diff line number Diff line
@@ -19,6 +19,8 @@ package org.microg.gms.gcm;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.preference.PreferenceManager;

public class TriggerReceiver extends BroadcastReceiver {
@@ -27,6 +29,11 @@ public class TriggerReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        boolean force = "android.provider.Telephony.SECRET_CODE".equals(intent.getAction());

        ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        NetworkInfo networkInfo = cm.getActiveNetworkInfo();

        if (networkInfo != null && networkInfo.isConnected() || force) {
            if (PreferenceManager.getDefaultSharedPreferences(context).getBoolean(PREF_ENABLE_GCM, false) || force) {
                if (!McsService.isConnected() || force) {
                    context.startService(new Intent(context, McsService.class));
@@ -34,3 +41,4 @@ public class TriggerReceiver extends BroadcastReceiver {
            }
        }
    }
}
Loading