Skip to content

Commit

Permalink
DeviceRegistartionFragment: Allow viewing device registartion data sh…
Browse files Browse the repository at this point in the history
…ared with remote

Signed-off-by: Aayush Gupta <aayushgupta219@gmail.com>
Change-Id: I93666445d14505c0a4289d63caa8054440ef1eef
  • Loading branch information
theimpulson committed Mar 28, 2024
1 parent 9e2337a commit 835e7a1
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ public static synchronized LastCheckinInfo checkin(Context context, boolean forc
return null;
if (!CheckinPreferences.isEnabled(context))
return null;
List<CheckinClient.Account> accounts = new ArrayList<CheckinClient.Account>();
return handleResponse(context, CheckinClient.request(getCheckinRequest(context, info)));
}

public static CheckinRequest getCheckinRequest(Context context, LastCheckinInfo info) throws IOException {
List<CheckinClient.Account> accounts = new ArrayList<>();
AccountManager accountManager = AccountManager.get(context);
String accountType = AuthConstants.DEFAULT_ACCOUNT_TYPE;
for (Account account : accountManager.getAccountsByType(accountType)) {
Expand All @@ -55,10 +59,9 @@ public static synchronized LastCheckinInfo checkin(Context context, boolean forc
accounts.add(new CheckinClient.Account(account.name, token));
}
}
CheckinRequest request = CheckinClient.makeRequest(context,
return CheckinClient.makeRequest(context,
new DeviceConfiguration(context), Utils.getDeviceIdentifier(context),
Utils.getPhoneInfo(context), info, Utils.getLocale(context), accounts);
return handleResponse(context, CheckinClient.request(request));
}

private static LastCheckinInfo handleResponse(Context context, CheckinResponse response) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import androidx.preference.Preference
import androidx.preference.PreferenceCategory
import androidx.preference.PreferenceFragmentCompat
import com.google.android.gms.R
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import org.microg.gms.checkin.CheckinManager
import org.microg.gms.checkin.CheckinPreferences
import org.microg.gms.checkin.LastCheckinInfo
import org.microg.gms.checkin.getCheckinServiceInfo
import org.microg.gms.profile.ProfileManager
import org.microg.gms.profile.ProfileManager.PROFILE_AUTO
Expand Down Expand Up @@ -94,6 +97,20 @@ class DeviceRegistrationFragment : PreferenceFragmentCompat() {
CheckinPreferences.setEnabled(requireContext(), newStatus)
true
}

findPreference<Preference>("pref_device_registration_data")?.setOnPreferenceClickListener {
val checkInRequest = CheckinManager.getCheckinRequest(
it.context,
LastCheckinInfo.read(it.context)
)
MaterialAlertDialogBuilder(it.context)
.setTitle(R.string.pref_device_registration_data_title)
.setMessage(checkInRequest.toString())
.setPositiveButton(android.R.string.ok) { dialog, _ -> dialog.dismiss() }
.create()
.show()
true
}
}

private fun configureProfilePreference() {
Expand Down
3 changes: 3 additions & 0 deletions play-services-core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ This can take a couple of minutes."</string>
<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>
<string name="pref_device_registration_android_id">Android ID</string>

<string name="pref_device_registration_data_title">Device registration data</string>
<string name="pref_device_registration_data_summary">Check data shared with Google servers for device registration</string>

<string name="checkin_not_registered">Not registered</string>
<string name="checkin_last_registration">Last registration: <xliff:g example="Yesterday, 02:20 PM">%1$s</xliff:g></string>
<string name="checkin_enable_switch">Register device</string>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@
android:key="pref_device_registration_android_id"
android:title="@string/pref_device_registration_android_id"
tools:summary="1953a59d1c1b7e4b" />
<Preference
android:key="pref_device_registration_data"
android:summary="@string/pref_device_registration_data_summary"
android:title="@string/pref_device_registration_data_title" />
</PreferenceCategory>
<PreferenceCategory android:layout="@layout/preference_category_no_label">
<org.microg.gms.ui.TextPreference
Expand Down

0 comments on commit 835e7a1

Please sign in to comment.