Skip to content

Commit 0382473

Browse files
committed
DeviceRegistartionFragment: Allow viewing device registartion data shared with remote
Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com> Change-Id: I93666445d14505c0a4289d63caa8054440ef1eef
1 parent 827a8b9 commit 0382473

File tree

4 files changed

+30
-3
lines changed

4 files changed

+30
-3
lines changed

play-services-core/src/main/java/org/microg/gms/checkin/CheckinManager.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ public static synchronized LastCheckinInfo checkin(Context context, boolean forc
4242
return null;
4343
if (!CheckinPreferences.isEnabled(context))
4444
return null;
45-
List<CheckinClient.Account> accounts = new ArrayList<CheckinClient.Account>();
45+
return handleResponse(context, CheckinClient.request(getCheckinRequest(context, info)));
46+
}
47+
48+
public static CheckinRequest getCheckinRequest(Context context, LastCheckinInfo info) throws IOException {
49+
List<CheckinClient.Account> accounts = new ArrayList<>();
4650
AccountManager accountManager = AccountManager.get(context);
4751
String accountType = AuthConstants.DEFAULT_ACCOUNT_TYPE;
4852
for (Account account : accountManager.getAccountsByType(accountType)) {
@@ -55,10 +59,9 @@ public static synchronized LastCheckinInfo checkin(Context context, boolean forc
5559
accounts.add(new CheckinClient.Account(account.name, token));
5660
}
5761
}
58-
CheckinRequest request = CheckinClient.makeRequest(context,
62+
return CheckinClient.makeRequest(context,
5963
new DeviceConfiguration(context), Utils.getDeviceIdentifier(context),
6064
Utils.getPhoneInfo(context), info, Utils.getLocale(context), accounts);
61-
return handleResponse(context, CheckinClient.request(request));
6265
}
6366

6467
private static LastCheckinInfo handleResponse(Context context, CheckinResponse response) {

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ import androidx.preference.Preference
1919
import androidx.preference.PreferenceCategory
2020
import androidx.preference.PreferenceFragmentCompat
2121
import com.google.android.gms.R
22+
import com.google.android.material.dialog.MaterialAlertDialogBuilder
23+
import org.microg.gms.checkin.CheckinManager
2224
import org.microg.gms.checkin.CheckinPreferences
25+
import org.microg.gms.checkin.LastCheckinInfo
2326
import org.microg.gms.checkin.getCheckinServiceInfo
2427
import org.microg.gms.profile.ProfileManager
2528
import org.microg.gms.profile.ProfileManager.PROFILE_AUTO
@@ -94,6 +97,20 @@ class DeviceRegistrationFragment : PreferenceFragmentCompat() {
9497
CheckinPreferences.setEnabled(requireContext(), newStatus)
9598
true
9699
}
100+
101+
findPreference<Preference>("pref_device_registration_data")?.setOnPreferenceClickListener {
102+
val checkInRequest = CheckinManager.getCheckinRequest(
103+
it.context,
104+
LastCheckinInfo.read(it.context)
105+
)
106+
MaterialAlertDialogBuilder(it.context)
107+
.setTitle(R.string.pref_device_registration_data_title)
108+
.setMessage(checkInRequest.toString())
109+
.setPositiveButton(android.R.string.ok) { dialog, _ -> dialog.dismiss() }
110+
.create()
111+
.show()
112+
true
113+
}
97114
}
98115

99116
private fun configureProfilePreference() {

play-services-core/src/main/res/values/strings.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ This can take a couple of minutes."</string>
144144
<string name="pref_checkin_enable_summary">Registers your device to Google services and creates a unique device identifier. microG strips identifying bits other than your Google account name from registration data.</string>
145145
<string name="pref_device_registration_android_id">Android ID</string>
146146

147+
<string name="pref_device_registration_data_title">Device registration data</string>
148+
<string name="pref_device_registration_data_summary">Check data shared with Google servers for device registration</string>
149+
147150
<string name="checkin_not_registered">Not registered</string>
148151
<string name="checkin_last_registration">Last registration: <xliff:g example="Yesterday, 02:20 PM">%1$s</xliff:g></string>
149152
<string name="checkin_enable_switch">Register device</string>

play-services-core/src/main/res/xml/preferences_device_registration.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@
5050
android:title="@string/pref_device_registration_android_id"
5151
tools:summary="1953a59d1c1b7e4b"
5252
app:iconSpaceReserved="false" />
53+
<Preference
54+
android:key="pref_device_registration_data"
55+
android:summary="@string/pref_device_registration_data_summary"
56+
android:title="@string/pref_device_registration_data_title" />
5357
</PreferenceCategory>
5458
<PreferenceCategory android:layout="@layout/preference_category_no_label">
5559
<org.microg.gms.ui.FooterPreference

0 commit comments

Comments
 (0)