Skip to content

Commit 6241b53

Browse files
authored
Google 2FA: Optimize 2-step verification function (#2990)
1 parent b6f3dfe commit 6241b53

File tree

13 files changed

+727
-137
lines changed

13 files changed

+727
-137
lines changed

play-services-core-proto/src/main/proto/gnots.proto

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ message FetchByIdentifierResponse {
3030
}
3131

3232
message NotificationList {
33-
repeated NotificationData notifications = 1;
33+
repeated NotificationData notificationDataList = 1;
3434
optional uint64 serverTime = 3;
3535
}
3636

@@ -73,20 +73,20 @@ message NotificationContent {
7373
optional string accountName = 4;
7474
optional string email = 5;
7575
optional string description = 6;
76-
optional string additionalText = 7;
77-
optional string eventType = 8;
78-
optional string errorMessage = 9;
79-
optional bool isDismissible = 10;
80-
optional bool requiresAuth = 11;
81-
optional bool isUserVisible = 12;
82-
optional bool isAutoCancel = 13;
76+
optional string contentDescription = 7;
77+
optional string notificationContentKey = 8;
78+
optional string toastMessage = 9;
79+
optional bool notifDefFlag = 10;
80+
optional bool notifDefVibrateEnabled = 11;
81+
optional bool notifDefSound = 12;
82+
optional bool notifDefVisibilityLevel = 13;
8383
optional ActionButtons buttons = 14;
84-
optional bool isPersistent = 15;
85-
optional string tickerText = 16;
84+
optional bool isLocalOnly = 15;
85+
optional string taskDescriptionLabel = 16;
8686
repeated NotificationButton actionButtons = 17;
8787
optional NotificationChannelInfo channelInfo = 18;
8888
optional string groupKey = 19;
89-
optional string sortKey = 20;
89+
optional string substName = 20;
9090
}
9191

9292
message NotificationChannelInfo {
@@ -163,12 +163,12 @@ message GmsGnotsSetReadStatesResponse {
163163
message DeviceInfo {
164164
optional DensityQualifier densityQualifier = 1;
165165
enum DensityQualifier {
166-
MDPI = 0;
167-
TVDPI = 1;
168-
XHDPI = 2;
169-
XXHDPI = 3;
170-
HDPI = 4;
171-
XXXHDPI = 5;
166+
LDPI = 0;
167+
MDPI = 1;
168+
HDPI = 2;
169+
XHDPI = 3;
170+
TVDPI = 4;
171+
XXHDPI = 5;
172172
}
173173
optional string localeTag = 2;
174174
optional int32 sdkVersion = 3;
Lines changed: 210 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,210 @@
1+
/*
2+
* SPDX-FileCopyrightText: 2023 microG Project Team
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package google.internal.notifications.v1;
7+
8+
service NotificationsApiService {
9+
rpc MultiLoginUpdate(RegistrationRequest) returns (RegistrationResponse);
10+
rpc FetchLatestThreads(FetchLatestThreadsRequest) returns (FetchLatestThreadsResponse);
11+
}
12+
13+
message RegistrationRequest {
14+
optional string chimeGmsClientId = 1;
15+
optional RegistrationPayload registrationPayload = 2;
16+
repeated DeviceRequest devices = 3;
17+
optional RegistrationReason reason = 5;
18+
optional string internalTargetId = 7;
19+
}
20+
21+
message RegistrationPayload {
22+
optional Channel channel = 1;
23+
optional AppRegistrationContainer appRegistrationContainer = 2;
24+
optional string representativeTargetId = 3;
25+
}
26+
27+
enum Channel {
28+
CHANNEL_UNKNOWN = 0;
29+
EMAIL = 1;
30+
APPLE_PUSH = 2;
31+
GCM_DEVICE_PUSH = 3;
32+
SMS = 5;
33+
CUSTOM_ENDPOINT = 6;
34+
WEB_PUSH = 7;
35+
MATCHSTICK = 8 [deprecated = true];
36+
VIRTUAL_INBOX = 10;
37+
IN_APP_TRAY = 11 [deprecated = true];
38+
IN_WEB = 12;
39+
}
40+
41+
message AppRegistrationContainer {
42+
oneof appRegistrationChoice {
43+
AppRegistration appRegistration = 1;
44+
}
45+
}
46+
47+
message AppRegistration {
48+
optional string regId = 1;
49+
optional string packageName = 2;
50+
optional int64 androidId = 3;
51+
optional int64 userSerialNumber = 4;
52+
}
53+
54+
message DeviceRequest {
55+
optional string unused = 1;
56+
optional GmsDeviceContext gmsDeviceContext = 3;
57+
optional int32 ttl = 4;
58+
optional string representativeTargetId = 5;
59+
optional AuthWrapper auth = 6;
60+
optional string id = 7;
61+
}
62+
63+
message GmsDeviceContext {
64+
optional string languageTag = 1;
65+
optional GmsDeviceProfile gmsDeviceProfile = 3;
66+
optional string timeZoneId = 4;
67+
}
68+
69+
message GmsDeviceProfile {
70+
optional float density = 2;
71+
optional string versionName = 3;
72+
optional string release = 4;
73+
optional string id = 5;
74+
optional string model = 6;
75+
optional int32 sdkVersion = 7;
76+
optional string manufacturer = 8;
77+
optional SdkType sdkType = 9;
78+
optional string channelNumber = 10;
79+
optional string deviceModel = 11;
80+
repeated NotificationChannel channels = 12;
81+
repeated NotificationChannelGroup channel_groups = 13;
82+
optional AppBlockState appBlockState = 14;
83+
optional string deviceCountry = 15;
84+
optional FeatureBitmapList featureBitmapList = 16;
85+
optional DeviceType deviceType = 18;
86+
optional string unused = 24;
87+
}
88+
89+
enum SdkType {
90+
SDK_TYPE_UNSPECIFIED = 0;
91+
CUSTOM = 1;
92+
GUNS = 2;
93+
CHIME = 3;
94+
GUNS_GMSCORE = 4;
95+
RAW_FCM_GMSCORE = 5;
96+
}
97+
98+
message NotificationChannel {
99+
optional string channelId = 1;
100+
optional string groupId = 2;
101+
optional NotificationImportance importance = 3;
102+
enum UnknownMessage {
103+
UNSPECIFIED = 0;
104+
TRUE = 1;
105+
FALSE = 2;
106+
}
107+
optional UnknownMessage unknownMessage = 4;
108+
}
109+
110+
enum NotificationImportance {
111+
IMPORTANCE_UNSPECIFIED = 0;
112+
IMPORTANCE_NONE = 1;
113+
IMPORTANCE_DEFAULT = 2;
114+
IMPORTANCE_HIGH = 3;
115+
IMPORTANCE_LOW = 4;
116+
IMPORTANCE_MAX = 5;
117+
IMPORTANCE_MIN = 6;
118+
}
119+
120+
message NotificationChannelGroup {
121+
optional string groupId = 1;
122+
optional ChannelGroupStatus channelGroupStatus = 2;
123+
}
124+
125+
enum ChannelGroupStatus {
126+
CHANNEL_GROUP_UNKNOWN = 0;
127+
CHANNEL_GROUP_ALLOWED = 1;
128+
CHANNEL_GROUP_BANNED = 2;
129+
}
130+
131+
enum AppBlockState {
132+
APP_BLOCK_STATE_UNKNOWN = 0;
133+
ALLOWED = 1;
134+
BANNED = 2;
135+
}
136+
137+
message FeatureBitmapList {
138+
repeated uint64 featureBitmaps = 1;
139+
}
140+
141+
enum DeviceType {
142+
DEVICE_TYPE_DEFAULT = 0;
143+
DEVICE_TYPE_TV = 1;
144+
DEVICE_TYPE_WEARABLE = 2;
145+
DEVICE_TYPE_AUTOMOTIVE = 3;
146+
DEVICE_TYPE_BATTLESTAR = 4;
147+
DEVICE_TYPE_CHROME_OS = 5;
148+
}
149+
150+
message AuthWrapper {
151+
message AuthToken {
152+
optional string authToken = 1;
153+
}
154+
155+
oneof auth {
156+
AuthToken authTokenWrapper = 1;
157+
}
158+
}
159+
160+
enum RegistrationReason {
161+
REGISTRATION_REASON_UNSPECIFIED = 0;
162+
DEVICE_START = 1;
163+
APP_UPDATED = 2;
164+
ACCOUNT_CHANGED = 3;
165+
SERVER_SYNC_INSTRUCTION = 4;
166+
LOCALE_CHANGED = 5;
167+
TIMEZONE_CHANGED = 6;
168+
COLLABORATOR_API_CALL = 7;
169+
GUNS_MIGRATION = 8;
170+
REGISTRATION_ID_CHANGED = 9;
171+
CHANNEL_BLOCK_STATE_CHANGED = 10;
172+
GROWTHKIT_PERIODIC_REGISTRATION = 11;
173+
PERIODIC_REGISTRATION = 12;
174+
GMSCORE_DEBUG = 13;
175+
APP_BLOCK_STATE_CHANGED = 14;
176+
}
177+
178+
message RegistrationResponse {
179+
repeated AccountRegistrationResult registrationResults = 1;
180+
optional string internalTargetId = 2;
181+
}
182+
183+
message AccountRegistrationResult {
184+
optional RegistrationError error = 1;
185+
optional RegistrationPayload payload = 2;
186+
optional string obfuscatedGaiaId = 4;
187+
optional string id = 6;
188+
optional bool success = 7;
189+
}
190+
191+
message RegistrationError {
192+
optional int32 errorCode = 1;
193+
optional string errorMessage = 2;
194+
}
195+
196+
enum RegistrationStatus {
197+
STATUS_UNKNOWN = 0;
198+
STATUS_REGISTERED = 1;
199+
STATUS_PENDING_REGISTRATION = 2;
200+
STATUS_FAILED_REGISTRATION = 3;
201+
STATUS_UNREGISTERED = 4;
202+
STATUS_PENDING_UNREGISTRATION = 5;
203+
STATUS_FAILED_UNREGISTRATION = 6;
204+
}
205+
206+
message FetchLatestThreadsRequest {
207+
}
208+
209+
message FetchLatestThreadsResponse {
210+
}

play-services-core/src/main/java/org/microg/gms/auth/login/LoginActivity.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@
7878
import static org.microg.gms.common.Constants.GMS_PACKAGE_NAME;
7979
import static org.microg.gms.common.Constants.GMS_VERSION_CODE;
8080
import static org.microg.gms.common.Constants.VENDING_PACKAGE_NAME;
81-
import static org.microg.gms.gcm.GcmInGmsServiceKt.ACTION_GCM_REGISTER_ACCOUNT;
82-
import static org.microg.gms.gcm.GcmInGmsServiceKt.KEY_GCM_REGISTER_ACCOUNT_NAME;
81+
import static org.microg.gms.gcm.ExtensionsKt.ACTION_GCM_REGISTER_ACCOUNT;
82+
import static org.microg.gms.gcm.ExtensionsKt.KEY_GCM_REGISTER_ACCOUNT_NAME;
8383

8484
public class LoginActivity extends AssistantActivity {
8585
public static final String TMPL_NEW_ACCOUNT = "new_account";

play-services-core/src/main/java/org/microg/gms/gcm/McsService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282
import static android.os.Build.VERSION.SDK_INT;
8383
import static org.microg.gms.common.PackageUtils.warnIfNotPersistentProcess;
8484
import static org.microg.gms.gcm.GcmConstants.*;
85-
import static org.microg.gms.gcm.GcmInGmsServiceKt.ACTION_GCM_REGISTERED;
85+
import static org.microg.gms.gcm.ExtensionsKt.ACTION_GCM_REGISTERED;
8686
import static org.microg.gms.gcm.McsConstants.*;
8787

8888
@ForegroundServiceInfo(value = "Cloud messaging", resName = "service_name_mcs", resPackage = "com.google.android.gms")

play-services-core/src/main/kotlin/org/microg/gms/accountsettings/ui/MainActivity.kt

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,17 @@ package org.microg.gms.accountsettings.ui
77

88
import android.accounts.Account
99
import android.accounts.AccountManager
10+
import android.content.Intent
1011
import android.graphics.Color
1112
import android.graphics.Typeface
1213
import android.net.Uri
13-
import android.os.Build.VERSION.SDK_INT
1414
import android.os.Bundle
1515
import android.text.TextUtils
1616
import android.util.Log
1717
import android.view.Gravity
1818
import android.view.View
1919
import android.webkit.ValueCallback
20+
import android.webkit.WebChromeClient.FileChooserParams
2021
import android.webkit.WebView
2122
import android.widget.ProgressBar
2223
import android.widget.RelativeLayout
@@ -26,6 +27,7 @@ import android.widget.TextView
2627
import androidx.appcompat.app.AppCompatActivity
2728
import androidx.appcompat.widget.Toolbar
2829
import androidx.core.content.ContextCompat
30+
import androidx.core.graphics.drawable.DrawableCompat
2931
import com.google.android.gms.R
3032
import org.microg.gms.accountsettings.ui.bridge.OcAdvertisingIdBridge
3133
import org.microg.gms.accountsettings.ui.bridge.OcAndroidIdBridge
@@ -46,7 +48,11 @@ import org.microg.gms.accountsettings.ui.bridge.OcUdcBridge
4648
import org.microg.gms.accountsettings.ui.bridge.OcUiBridge
4749
import org.microg.gms.auth.AuthConstants
4850
import org.microg.gms.common.Constants
51+
import org.microg.gms.common.Constants.GMS_PACKAGE_NAME
52+
import org.microg.gms.gcm.ACTION_GCM_NOTIFY_COMPLETE
53+
import org.microg.gms.gcm.EXTRA_NOTIFICATION_ACCOUNT
4954
import org.microg.gms.people.PeopleManager
55+
import org.microg.gms.profile.Build.VERSION.SDK_INT
5056
import org.microg.gms.profile.ProfileManager
5157
import java.util.concurrent.ExecutorService
5258
import java.util.concurrent.Executors
@@ -211,23 +217,26 @@ class MainActivity : AppCompatActivity() {
211217
val titleView = TextView(this).apply {
212218
text = ContextCompat.getString(context, R.string.pref_accounts_title)
213219
textSize = 20f
214-
setTextColor(Color.BLACK)
220+
setTextColor(if(isNightMode()) Color.WHITE else Color.BLACK)
215221
maxLines = 1
216222
ellipsize = TextUtils.TruncateAt.END
217223
setTypeface(Typeface.create("sans-serif", Typeface.NORMAL))
218224
layoutParams = Toolbar.LayoutParams(MATCH_PARENT, WRAP_CONTENT, Gravity.START)
219225
}
220226
val toolbar = Toolbar(this).apply {
221227
id = View.generateViewId()
222-
setBackgroundColor(Color.WHITE)
228+
setBackgroundColor(if(isNightMode()) Color.BLACK else Color.WHITE)
223229
if (SDK_INT >= 21) {
224230
backgroundTintList = null
225231
}
226232
layoutParams = RelativeLayout.LayoutParams(MATCH_PARENT, WRAP_CONTENT).apply {
227233
addRule(RelativeLayout.ALIGN_PARENT_TOP)
228234
}
229-
navigationIcon = ContextCompat.getDrawable(context, R.drawable.ic_arrow_close)
230-
setNavigationOnClickListener { finish() }
235+
val wrappedDrawable = ContextCompat.getDrawable(context, R.drawable.ic_arrow_close)?.let { DrawableCompat.wrap(it) }?.apply {
236+
DrawableCompat.setTint(this, if (isNightMode()) Color.WHITE else Color.BLACK)
237+
}
238+
navigationIcon = wrappedDrawable ?: ContextCompat.getDrawable(context, R.drawable.ic_arrow_close)
239+
setNavigationOnClickListener { finishActivity() }
231240
addView(titleView)
232241
}
233242
val progressBar = ProgressBar(this).apply {
@@ -294,10 +303,14 @@ class MainActivity : AppCompatActivity() {
294303
addJavascriptInterface(OcFilePickerBridge(this@MainActivity, this, executor), OcFilePickerBridge.NAME)
295304
}
296305

297-
fun showImageChooser(targetFilePathCallback: ValueCallback<Array<Uri>>) {
306+
fun showFileChooser(fileChooserParams: FileChooserParams, targetFilePathCallback: ValueCallback<Array<Uri>>): Boolean {
307+
if (SDK_INT < 21) {
308+
return false
309+
}
298310
filePathCallback?.onReceiveValue(null)
299311
filePathCallback = targetFilePathCallback
300-
pickerUtils.launchChooser("*/*")
312+
pickerUtils.launchChooser(fileChooserParams.acceptTypes?.joinToString() ?: "*/*")
313+
return true
301314
}
302315

303316
fun updateLocalAccountAvatar(newAvatarUrl: String?, accountName: String?) {
@@ -308,4 +321,14 @@ class MainActivity : AppCompatActivity() {
308321
PeopleManager.updateOwnerAvatar(this, accountName, newAvatarUrl)
309322
}
310323
}
324+
325+
fun updateVerifyNotification(accountName: String) {
326+
val notificationId = intent.getIntExtra(KEY_NOTIFICATION_ID, -1)
327+
Log.d(TAG, "updateVerifyNotification: notificationId: $notificationId")
328+
if (notificationId == -1) return
329+
Intent(ACTION_GCM_NOTIFY_COMPLETE).apply {
330+
setPackage(GMS_PACKAGE_NAME)
331+
putExtra(EXTRA_NOTIFICATION_ACCOUNT, accountName)
332+
}.let { sendBroadcast(it) }
333+
}
311334
}

0 commit comments

Comments
 (0)