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

Unverified Commit 6241b534 authored by DaVinci9196's avatar DaVinci9196 Committed by GitHub
Browse files

Google 2FA: Optimize 2-step verification function (#2990)

parent b6f3dfee
Loading
Loading
Loading
Loading
+17 −17
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ message FetchByIdentifierResponse {
}

message NotificationList {
  repeated NotificationData notifications = 1;
  repeated NotificationData notificationDataList = 1;
  optional uint64 serverTime = 3;
}

@@ -73,20 +73,20 @@ message NotificationContent {
  optional string accountName = 4;
  optional string email = 5;
  optional string description = 6;
  optional string additionalText = 7;
  optional string eventType = 8;
  optional string errorMessage = 9;
  optional bool isDismissible = 10;
  optional bool requiresAuth = 11;
  optional bool isUserVisible = 12;
  optional bool isAutoCancel = 13;
  optional string contentDescription = 7;
  optional string notificationContentKey = 8;
  optional string toastMessage = 9;
  optional bool notifDefFlag = 10;
  optional bool notifDefVibrateEnabled = 11;
  optional bool notifDefSound = 12;
  optional bool notifDefVisibilityLevel = 13;
  optional ActionButtons buttons = 14;
  optional bool isPersistent = 15;
  optional string tickerText = 16;
  optional bool isLocalOnly = 15;
  optional string taskDescriptionLabel = 16;
  repeated NotificationButton actionButtons = 17;
  optional NotificationChannelInfo channelInfo = 18;
  optional string groupKey = 19;
  optional string sortKey = 20;
  optional string substName = 20;
}

message NotificationChannelInfo {
@@ -163,12 +163,12 @@ message GmsGnotsSetReadStatesResponse {
message DeviceInfo {
  optional DensityQualifier densityQualifier = 1;
  enum DensityQualifier {
    MDPI = 0;
    TVDPI = 1;
    XHDPI = 2;
    XXHDPI = 3;
    HDPI = 4;
    XXXHDPI = 5;
    LDPI = 0;
    MDPI = 1;
    HDPI = 2;
    XHDPI = 3;
    TVDPI = 4;
    XXHDPI = 5;
  }
  optional string localeTag = 2;
  optional int32 sdkVersion = 3;
+210 −0
Original line number Diff line number Diff line
/*
 * SPDX-FileCopyrightText: 2023 microG Project Team
 * SPDX-License-Identifier: Apache-2.0
 */

package google.internal.notifications.v1;

service NotificationsApiService {
  rpc MultiLoginUpdate(RegistrationRequest) returns (RegistrationResponse);
  rpc FetchLatestThreads(FetchLatestThreadsRequest) returns (FetchLatestThreadsResponse);
}

message RegistrationRequest {
  optional string chimeGmsClientId = 1;
  optional RegistrationPayload registrationPayload = 2;
  repeated DeviceRequest devices = 3;
  optional RegistrationReason reason = 5;
  optional string internalTargetId = 7;
}

message RegistrationPayload {
  optional Channel channel = 1;
  optional AppRegistrationContainer appRegistrationContainer = 2;
  optional string representativeTargetId = 3;
}

enum Channel {
  CHANNEL_UNKNOWN = 0;
  EMAIL = 1;
  APPLE_PUSH = 2;
  GCM_DEVICE_PUSH = 3;
  SMS = 5;
  CUSTOM_ENDPOINT = 6;
  WEB_PUSH = 7;
  MATCHSTICK = 8 [deprecated = true];
  VIRTUAL_INBOX = 10;
  IN_APP_TRAY = 11 [deprecated = true];
  IN_WEB = 12;
}

message AppRegistrationContainer {
    oneof appRegistrationChoice {
      AppRegistration appRegistration = 1;
  }
}

message AppRegistration {
  optional string regId = 1;
  optional string packageName = 2;
  optional int64 androidId = 3;
  optional int64 userSerialNumber = 4;
}

message DeviceRequest {
  optional string unused = 1;
  optional GmsDeviceContext gmsDeviceContext = 3;
  optional int32 ttl = 4;
  optional string representativeTargetId = 5;
  optional AuthWrapper auth = 6;
  optional string id = 7;
}

message GmsDeviceContext {
  optional string languageTag = 1;
  optional GmsDeviceProfile gmsDeviceProfile = 3;
  optional string timeZoneId = 4;
}

message GmsDeviceProfile {
  optional float density = 2;
  optional string versionName = 3;
  optional string release = 4;
  optional string id = 5;
  optional string model = 6;
  optional int32 sdkVersion = 7;
  optional string manufacturer = 8;
  optional SdkType sdkType = 9;
  optional string channelNumber = 10;
  optional string deviceModel = 11;
  repeated NotificationChannel channels = 12;
  repeated NotificationChannelGroup channel_groups = 13;
  optional AppBlockState appBlockState = 14;
  optional string deviceCountry = 15;
  optional FeatureBitmapList featureBitmapList = 16;
  optional DeviceType deviceType = 18;
  optional string unused = 24;
}

enum SdkType {
  SDK_TYPE_UNSPECIFIED = 0;
  CUSTOM = 1;
  GUNS = 2;
  CHIME = 3;
  GUNS_GMSCORE = 4;
  RAW_FCM_GMSCORE = 5;
}

message NotificationChannel {
  optional string channelId = 1;
  optional string groupId = 2;
  optional NotificationImportance importance = 3;
  enum UnknownMessage {
    UNSPECIFIED = 0;
    TRUE = 1;
    FALSE = 2;
  }
  optional UnknownMessage unknownMessage = 4;
}

enum NotificationImportance {
  IMPORTANCE_UNSPECIFIED = 0;
  IMPORTANCE_NONE = 1;
  IMPORTANCE_DEFAULT = 2;
  IMPORTANCE_HIGH = 3;
  IMPORTANCE_LOW = 4;
  IMPORTANCE_MAX = 5;
  IMPORTANCE_MIN = 6;
}

message NotificationChannelGroup {
  optional string groupId = 1;
  optional ChannelGroupStatus channelGroupStatus = 2;
}

enum ChannelGroupStatus {
  CHANNEL_GROUP_UNKNOWN = 0;
  CHANNEL_GROUP_ALLOWED = 1;
  CHANNEL_GROUP_BANNED = 2;
}

enum AppBlockState {
  APP_BLOCK_STATE_UNKNOWN = 0;
  ALLOWED = 1;
  BANNED = 2;
}

message FeatureBitmapList {
  repeated uint64 featureBitmaps = 1;
}

enum DeviceType {
  DEVICE_TYPE_DEFAULT = 0;
  DEVICE_TYPE_TV = 1;
  DEVICE_TYPE_WEARABLE = 2;
  DEVICE_TYPE_AUTOMOTIVE = 3;
  DEVICE_TYPE_BATTLESTAR = 4;
  DEVICE_TYPE_CHROME_OS = 5;
}

message AuthWrapper {
  message AuthToken {
    optional string authToken = 1;
  }

  oneof auth {
    AuthToken authTokenWrapper = 1;
  }
}

enum RegistrationReason {
  REGISTRATION_REASON_UNSPECIFIED = 0;
  DEVICE_START = 1;
  APP_UPDATED = 2;
  ACCOUNT_CHANGED = 3;
  SERVER_SYNC_INSTRUCTION = 4;
  LOCALE_CHANGED = 5;
  TIMEZONE_CHANGED = 6;
  COLLABORATOR_API_CALL = 7;
  GUNS_MIGRATION = 8;
  REGISTRATION_ID_CHANGED = 9;
  CHANNEL_BLOCK_STATE_CHANGED = 10;
  GROWTHKIT_PERIODIC_REGISTRATION = 11;
  PERIODIC_REGISTRATION = 12;
  GMSCORE_DEBUG = 13;
  APP_BLOCK_STATE_CHANGED = 14;
}

message RegistrationResponse {
  repeated AccountRegistrationResult registrationResults = 1;
  optional string internalTargetId = 2;
}

message AccountRegistrationResult {
  optional RegistrationError error = 1;
  optional RegistrationPayload payload = 2;
  optional string obfuscatedGaiaId = 4;
  optional string id = 6;
  optional bool success = 7;
}

message RegistrationError {
  optional int32 errorCode = 1;
  optional string errorMessage = 2;
}

enum RegistrationStatus {
  STATUS_UNKNOWN = 0;
  STATUS_REGISTERED = 1;
  STATUS_PENDING_REGISTRATION = 2;
  STATUS_FAILED_REGISTRATION = 3;
  STATUS_UNREGISTERED = 4;
  STATUS_PENDING_UNREGISTRATION = 5;
  STATUS_FAILED_UNREGISTRATION = 6;
}

message FetchLatestThreadsRequest {
}

message FetchLatestThreadsResponse {
}
+2 −2
Original line number Diff line number Diff line
@@ -78,8 +78,8 @@ import static org.microg.gms.auth.AuthPrefs.isAuthVisible;
import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME;
import static org.microg.gms.common.Constants.GMS_VERSION_CODE;
import static org.microg.gms.common.Constants.VENDING_PACKAGE_NAME;
import static org.microg.gms.gcm.GcmInGmsServiceKt.ACTION_GCM_REGISTER_ACCOUNT;
import static org.microg.gms.gcm.GcmInGmsServiceKt.KEY_GCM_REGISTER_ACCOUNT_NAME;
import static org.microg.gms.gcm.ExtensionsKt.ACTION_GCM_REGISTER_ACCOUNT;
import static org.microg.gms.gcm.ExtensionsKt.KEY_GCM_REGISTER_ACCOUNT_NAME;

public class LoginActivity extends AssistantActivity {
    public static final String TMPL_NEW_ACCOUNT = "new_account";
+1 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ import static android.app.AlarmManager.ELAPSED_REALTIME_WAKEUP;
import static android.os.Build.VERSION.SDK_INT;
import static org.microg.gms.common.PackageUtils.warnIfNotPersistentProcess;
import static org.microg.gms.gcm.GcmConstants.*;
import static org.microg.gms.gcm.GcmInGmsServiceKt.ACTION_GCM_REGISTERED;
import static org.microg.gms.gcm.ExtensionsKt.ACTION_GCM_REGISTERED;
import static org.microg.gms.gcm.McsConstants.*;

@ForegroundServiceInfo(value = "Cloud messaging", resName = "service_name_mcs", resPackage = "com.google.android.gms")
+30 −7
Original line number Diff line number Diff line
@@ -7,16 +7,17 @@ package org.microg.gms.accountsettings.ui

import android.accounts.Account
import android.accounts.AccountManager
import android.content.Intent
import android.graphics.Color
import android.graphics.Typeface
import android.net.Uri
import android.os.Build.VERSION.SDK_INT
import android.os.Bundle
import android.text.TextUtils
import android.util.Log
import android.view.Gravity
import android.view.View
import android.webkit.ValueCallback
import android.webkit.WebChromeClient.FileChooserParams
import android.webkit.WebView
import android.widget.ProgressBar
import android.widget.RelativeLayout
@@ -26,6 +27,7 @@ import android.widget.TextView
import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.widget.Toolbar
import androidx.core.content.ContextCompat
import androidx.core.graphics.drawable.DrawableCompat
import com.google.android.gms.R
import org.microg.gms.accountsettings.ui.bridge.OcAdvertisingIdBridge
import org.microg.gms.accountsettings.ui.bridge.OcAndroidIdBridge
@@ -46,7 +48,11 @@ import org.microg.gms.accountsettings.ui.bridge.OcUdcBridge
import org.microg.gms.accountsettings.ui.bridge.OcUiBridge
import org.microg.gms.auth.AuthConstants
import org.microg.gms.common.Constants
import org.microg.gms.common.Constants.GMS_PACKAGE_NAME
import org.microg.gms.gcm.ACTION_GCM_NOTIFY_COMPLETE
import org.microg.gms.gcm.EXTRA_NOTIFICATION_ACCOUNT
import org.microg.gms.people.PeopleManager
import org.microg.gms.profile.Build.VERSION.SDK_INT
import org.microg.gms.profile.ProfileManager
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
@@ -211,7 +217,7 @@ class MainActivity : AppCompatActivity() {
            val titleView = TextView(this).apply {
                text = ContextCompat.getString(context, R.string.pref_accounts_title)
                textSize = 20f
                setTextColor(Color.BLACK)
                setTextColor(if(isNightMode()) Color.WHITE else Color.BLACK)
                maxLines = 1
                ellipsize = TextUtils.TruncateAt.END
                setTypeface(Typeface.create("sans-serif", Typeface.NORMAL))
@@ -219,15 +225,18 @@ class MainActivity : AppCompatActivity() {
            }
            val toolbar = Toolbar(this).apply {
                id = View.generateViewId()
                setBackgroundColor(Color.WHITE)
                setBackgroundColor(if(isNightMode()) Color.BLACK else Color.WHITE)
                if (SDK_INT >= 21) {
                    backgroundTintList = null
                }
                layoutParams = RelativeLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT).apply {
                    addRule(RelativeLayout.ALIGN_PARENT_TOP)
                }
                navigationIcon = ContextCompat.getDrawable(context, R.drawable.ic_arrow_close)
                setNavigationOnClickListener { finish() }
                val wrappedDrawable = ContextCompat.getDrawable(context, R.drawable.ic_arrow_close)?.let { DrawableCompat.wrap(it) }?.apply {
                    DrawableCompat.setTint(this, if (isNightMode()) Color.WHITE else Color.BLACK)
                }
                navigationIcon = wrappedDrawable ?: ContextCompat.getDrawable(context, R.drawable.ic_arrow_close)
                setNavigationOnClickListener { finishActivity() }
                addView(titleView)
            }
            val progressBar = ProgressBar(this).apply {
@@ -294,10 +303,14 @@ class MainActivity : AppCompatActivity() {
        addJavascriptInterface(OcFilePickerBridge(this@MainActivity, this, executor), OcFilePickerBridge.NAME)
    }

    fun showImageChooser(targetFilePathCallback: ValueCallback<Array<Uri>>) {
    fun showFileChooser(fileChooserParams: FileChooserParams, targetFilePathCallback: ValueCallback<Array<Uri>>): Boolean {
        if (SDK_INT < 21) {
            return false
        }
        filePathCallback?.onReceiveValue(null)
        filePathCallback = targetFilePathCallback
        pickerUtils.launchChooser("*/*")
        pickerUtils.launchChooser(fileChooserParams.acceptTypes?.joinToString() ?: "*/*")
        return true
    }

    fun updateLocalAccountAvatar(newAvatarUrl: String?, accountName: String?) {
@@ -308,4 +321,14 @@ class MainActivity : AppCompatActivity() {
            PeopleManager.updateOwnerAvatar(this, accountName, newAvatarUrl)
        }
    }
    
    fun updateVerifyNotification(accountName: String) {
        val notificationId = intent.getIntExtra(KEY_NOTIFICATION_ID, -1)
        Log.d(TAG, "updateVerifyNotification: notificationId: $notificationId")
        if (notificationId == -1) return
        Intent(ACTION_GCM_NOTIFY_COMPLETE).apply {
            setPackage(GMS_PACKAGE_NAME)
            putExtra(EXTRA_NOTIFICATION_ACCOUNT, accountName)
        }.let { sendBroadcast(it) }
    }
}
 No newline at end of file
Loading