Skip to content

Commit 3321044

Browse files
DaVinci9196lucasmz-devmar-v-in
authored
Auth: Support Google 2-step verification (#2866)
Co-authored-by: Lucas <55422065+lucasmz-dev@users.noreply.github.com> Co-authored-by: Marvin W <git@larma.de>
1 parent 398cd1b commit 3321044

20 files changed

Lines changed: 769 additions & 4 deletions

File tree

play-services-base/core/src/main/java/org/microg/gms/auth/AuthResponse.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ public class AuthResponse {
7373
public String auths;
7474
@ResponseField("capabilities")
7575
public String capabilities;
76+
@ResponseField("ExpiresInDurationSec")
77+
public int expiresInDurationSec;
7678

7779
public static AuthResponse parse(String result) {
7880
AuthResponse response = new AuthResponse();
@@ -129,6 +131,7 @@ public String toString() {
129131
if (itMetadata != null) sb.append(", itMetadata='").append(itMetadata).append('\'');
130132
if (resolutionDataBase64 != null) sb.append(", resolutionDataBase64='").append(resolutionDataBase64).append('\'');
131133
if (capabilities != null) sb.append(", capabilitites='").append(capabilities).append('\'');
134+
if (expiresInDurationSec != 0) sb.append(", expiresInDurationSec='").append(expiresInDurationSec).append('\'');
132135
sb.append('}');
133136
return sb.toString();
134137
}

play-services-base/core/src/main/kotlin/org/microg/gms/auth/AuthPrefs.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,10 @@ object AuthPrefs {
3434
}
3535
}
3636

37+
@JvmStatic
38+
fun shouldReceiveTwoStepVerification(context: Context): Boolean {
39+
return SettingsContract.getSettings(context, Auth.getContentUri(context), arrayOf(Auth.TWO_STEP_VERIFICATION)) { c ->
40+
c.getInt(0) != 0
41+
}
42+
}
3743
}

play-services-base/core/src/main/kotlin/org/microg/gms/settings/SettingsContract.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,14 @@ object SettingsContract {
163163
const val VISIBLE = "auth_manager_visible"
164164
const val INCLUDE_ANDROID_ID = "auth_include_android_id"
165165
const val STRIP_DEVICE_NAME = "auth_strip_device_name"
166+
const val TWO_STEP_VERIFICATION = "auth_two_step_verification"
166167

167168
val PROJECTION = arrayOf(
168169
TRUST_GOOGLE,
169170
VISIBLE,
170171
INCLUDE_ANDROID_ID,
171172
STRIP_DEVICE_NAME,
173+
TWO_STEP_VERIFICATION,
172174
)
173175
}
174176

play-services-base/core/src/main/kotlin/org/microg/gms/settings/SettingsProvider.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ class SettingsProvider : ContentProvider() {
212212
Auth.VISIBLE -> getSettingsBoolean(key, false)
213213
Auth.INCLUDE_ANDROID_ID -> getSettingsBoolean(key, true)
214214
Auth.STRIP_DEVICE_NAME -> getSettingsBoolean(key, false)
215+
Auth.TWO_STEP_VERIFICATION -> getSettingsBoolean(key, false)
215216
else -> throw IllegalArgumentException("Unknown key: $key")
216217
}
217218
}
@@ -225,6 +226,7 @@ class SettingsProvider : ContentProvider() {
225226
Auth.VISIBLE -> editor.putBoolean(key, value as Boolean)
226227
Auth.INCLUDE_ANDROID_ID -> editor.putBoolean(key, value as Boolean)
227228
Auth.STRIP_DEVICE_NAME -> editor.putBoolean(key, value as Boolean)
229+
Auth.TWO_STEP_VERIFICATION -> editor.putBoolean(key, value as Boolean)
228230
else -> throw IllegalArgumentException("Unknown key: $key")
229231
}
230232
}

play-services-basement/src/main/java/org/microg/gms/gcm/GcmConstants.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,11 @@ public final class GcmConstants {
7070
public static final String EXTRA_TOPIC = "gcm.topic";
7171
public static final String EXTRA_TTL = "google.ttl";
7272
public static final String EXTRA_UNREGISTERED = "unregistered";
73+
public static final String EXTRA_ACCOUNT_NAME = "a";
74+
public static final String EXTRA_REG_ID = "id";
75+
public static final String EXTRA_AUTHS_TOKEN = "t";
76+
public static final String EXTRA_GCM_BODY = "gcmb";
77+
public static final String EXTRA_GMS_GNOTS_PAYLOAD = "gms.gnots.payload";
7378

7479
public static final String MESSAGE_TYPE_GCM = "gcm";
7580
public static final String MESSAGE_TYPE_DELETED_MESSAGE = "deleted_message";

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

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,39 @@ message Cookie {
5656
optional string discard = 10;
5757
optional string comment = 12;
5858
}
59+
60+
message ItAuthData {
61+
optional bytes auth = 1;
62+
repeated bytes tokens = 2;
63+
optional bytes signature = 3;
64+
}
65+
66+
message ItMetadataData {
67+
message ScopeEntry {
68+
repeated string name = 1;
69+
optional int32 id = 2;
70+
}
71+
repeated ScopeEntry entries = 1;
72+
optional TokenField field = 3;
73+
optional int32 liveTime = 4;
74+
}
75+
76+
message TokenField {
77+
enum FieldType {
78+
UNKNOWN = 0;
79+
SCOPE = 1;
80+
EXPIRATION = 2;
81+
}
82+
repeated FieldType types = 1 [packed = true];
83+
}
84+
85+
message OAuthAuthorization {
86+
repeated int32 scopeIds = 1 [packed = true];
87+
optional int32 effectiveDurationSeconds = 2;
88+
}
89+
90+
message OAuthTokenData {
91+
optional int32 fieldType = 1;
92+
optional bytes authorization = 2;
93+
optional int32 durationMillis = 3;
94+
}
Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
package social.boq.notifications.gmscoreapi;
2+
3+
option java_outer_classname = "GunsGmscoreApiService";
4+
option java_package = "org.microg.gms.gcm";
5+
6+
service GunsGmscoreApiService {
7+
rpc GmsGnotsFetchByIdentifier(FetchByIdentifierRequest) returns (FetchByIdentifierResponse);
8+
rpc GmsGnotsSetReadStates(GmsGnotsSetReadStatesRequest) returns (GmsGnotsSetReadStatesResponse);
9+
}
10+
11+
message FetchByIdentifierRequest {
12+
optional GmsConfig config = 1;
13+
optional NotificationIdentifierList identifiers = 2;
14+
}
15+
16+
message GmsConfig {
17+
message GmsVersionInfo {
18+
optional int32 version = 10;
19+
}
20+
optional GmsVersionInfo versionInfo = 3;
21+
}
22+
23+
message NotificationIdentifierList {
24+
repeated NotificationIdentifier notifications = 1;
25+
optional DeviceInfo deviceInfo = 2;
26+
}
27+
28+
message FetchByIdentifierResponse {
29+
optional NotificationList notifications = 2;
30+
}
31+
32+
message NotificationList {
33+
repeated NotificationData notifications = 1;
34+
optional uint64 serverTime = 3;
35+
}
36+
37+
message NotificationData {
38+
optional UserInfo userInfo = 1;
39+
optional NotificationIdentifier identifier = 2;
40+
optional bool isActive = 3;
41+
optional NotificationContent content = 4;
42+
optional NotificationAction action = 5;
43+
optional DeviceInfo deviceInfo = 6;
44+
optional uint64 createTime = 7;
45+
optional IntentActions intentActions = 8;
46+
optional uint64 expiryTime = 9;
47+
optional BinaryPayload binaryPayload = 10;
48+
}
49+
50+
message IntentActions {
51+
optional IntentPayload primaryPayload = 1;
52+
optional IntentPayload secondaryPayload = 2;
53+
}
54+
55+
message UserInfo {
56+
optional string userId = 1;
57+
}
58+
59+
message NotificationIdentifier {
60+
optional string type = 1;
61+
optional string uniqueId = 2;
62+
optional uint64 timestamp = 3;
63+
optional string source = 4;
64+
optional string registrationId = 5;
65+
optional int64 receivedTime = 6;
66+
optional bytes payload = 7;
67+
}
68+
69+
message NotificationContent {
70+
optional int32 priority = 1;
71+
optional IconInfo icon = 2;
72+
optional string title = 3;
73+
optional string accountName = 4;
74+
optional string email = 5;
75+
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;
83+
optional ActionButtons buttons = 14;
84+
optional bool isPersistent = 15;
85+
optional string tickerText = 16;
86+
repeated NotificationButton actionButtons = 17;
87+
optional NotificationChannelInfo channelInfo = 18;
88+
optional string groupKey = 19;
89+
optional string sortKey = 20;
90+
}
91+
92+
message NotificationChannelInfo {
93+
optional string id = 1;
94+
optional string description = 2;
95+
optional string groupId = 3;
96+
optional string groupName = 4;
97+
optional int32 importance = 5;
98+
optional string name = 6;
99+
}
100+
101+
message IconInfo {
102+
optional string iconUrl = 1;
103+
}
104+
105+
message ActionButtons {
106+
optional string primaryText = 1;
107+
optional string secondaryText = 2;
108+
}
109+
110+
message NotificationButton {
111+
optional string text = 1;
112+
optional NotificationAction action = 2;
113+
optional string icon = 3;
114+
optional bool isEnabled = 4;
115+
optional int32 buttonType = 6;
116+
}
117+
118+
message NotificationAction {
119+
optional ActionMetadata metadata = 1;
120+
optional ActionIntent intent = 2;
121+
}
122+
123+
message ActionMetadata {
124+
optional string actionUrl = 1;
125+
optional bool value = 2;
126+
}
127+
128+
message ActionIntent {
129+
optional IntentPayload intentPayload = 4;
130+
}
131+
132+
message IntentPayload {
133+
optional string className = 1;
134+
optional string action = 2;
135+
optional int32 launchType = 3;
136+
repeated IntentExtra extras = 4;
137+
optional int32 flags = 5;
138+
}
139+
140+
message IntentExtra {
141+
optional string key = 1;
142+
optional string value = 2;
143+
}
144+
145+
message GmsGnotsSetReadStatesRequest {
146+
optional GmsConfig config = 1;
147+
optional ReadStateList readStates = 2;
148+
}
149+
150+
message ReadStateList {
151+
repeated ReadStateItem items = 1;
152+
}
153+
154+
message ReadStateItem {
155+
optional NotificationIdentifier notification = 1;
156+
optional string state = 3;
157+
optional int32 status = 4;
158+
}
159+
160+
message GmsGnotsSetReadStatesResponse {
161+
}
162+
163+
message DeviceInfo {
164+
optional DensityQualifier densityQualifier = 1;
165+
enum DensityQualifier {
166+
MDPI = 0;
167+
TVDPI = 1;
168+
XHDPI = 2;
169+
XXHDPI = 3;
170+
HDPI = 4;
171+
XXXHDPI = 5;
172+
}
173+
optional string localeTag = 2;
174+
optional int32 sdkVersion = 3;
175+
optional float density = 4;
176+
optional string timeZoneId = 5;
177+
repeated NotificationChannelInfo notificationChannels = 6;
178+
}
179+
180+
message BinaryPayload {
181+
required string type = 1;
182+
required bytes data = 2;
183+
}

play-services-core/src/huawei/AndroidManifest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<meta-data
2323
android:name="org.microg.gms.settings.auth_strip_device_name"
2424
android:value="true" />
25+
<meta-data
26+
android:name="org.microg.gms.settings.auth_two_step_verification"
27+
android:value="true" />
2528
<meta-data
2629
android:name="org.microg.gms.settings.droidguard_enabled"
2730
android:value="true" />

play-services-core/src/huaweilh/AndroidManifest.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
<meta-data
2323
android:name="org.microg.gms.settings.auth_strip_device_name"
2424
android:value="true" />
25+
<meta-data
26+
android:name="org.microg.gms.settings.auth_two_step_verification"
27+
android:value="true" />
2528
<meta-data
2629
android:name="org.microg.gms.settings.droidguard_enabled"
2730
android:value="true" />

play-services-core/src/main/AndroidManifest.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,24 @@
337337
android:name="org.microg.gms.gcm.McsService"
338338
android:process=":persistent" />
339339

340+
<service
341+
android:name="org.microg.gms.gcm.GcmInGmsService"
342+
android:exported="false"
343+
android:process=":persistent"/>
344+
345+
<receiver
346+
android:name="org.microg.gms.gcm.GcmRegistrationReceiver"
347+
android:exported="false"
348+
android:process=":persistent">
349+
<intent-filter>
350+
<action android:name="org.microg.gms.gcm.REGISTERED" />
351+
<action android:name="org.microg.gms.gcm.REGISTER_ACCOUNT" />
352+
<action android:name="org.microg.gms.gcm.NOTIFY_COMPLETE" />
353+
354+
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
355+
</intent-filter>
356+
</receiver>
357+
340358
<receiver
341359
android:name="org.microg.gms.gcm.SendReceiver"
342360
android:process=":persistent">

0 commit comments

Comments
 (0)