Skip to content

Commit

Permalink
Merge branch 'microg:master' into patch-4
Browse files Browse the repository at this point in the history
  • Loading branch information
ale5000-git authored Aug 18, 2023
2 parents b839e88 + 8590f6d commit 7626be9
Show file tree
Hide file tree
Showing 65 changed files with 2,679 additions and 90 deletions.
10 changes: 0 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

buildscript {
ext.cronetVersion = '102.5005.125'
ext.safeParcelVersion = '1.7.1'
ext.wearableVersion = '0.1.1'

ext.kotlinVersion = '1.7.10'
Expand Down Expand Up @@ -108,14 +107,5 @@ subprojects {
mavenCentral()
google()
}
afterEvaluate {
// Temporary hack for Android Studio
if (project.plugins.hasPlugin('com.android.base')) {
dependencies {
compileOnly "org.microg:safe-parcel:$safeParcelVersion"
testCompileOnly "org.microg:safe-parcel:$safeParcelVersion"
}
}
}
}

4 changes: 4 additions & 0 deletions play-services-ads-identifier/core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,8 @@ android {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}

lintOptions {
disable 'MissingTranslation'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,134 @@
package org.microg.gms.ads.identifier

import android.app.Service
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Binder
import android.os.Bundle
import android.os.IBinder
import android.util.Log
import androidx.core.os.bundleOf
import com.google.android.gms.ads.identifier.internal.IAdvertisingIdService
import org.microg.gms.common.PackageUtils
import java.util.UUID

const val TAG = "AdvertisingId"
const val EMPTY_AD_ID = "00000000-0000-0000-0000-000000000000"

class AdvertisingIdService : Service() {
override fun onBind(intent: Intent): IBinder? {
return AdvertisingIdServiceImpl().asBinder()
return AdvertisingIdServiceImpl(this).asBinder()
}
}

class MemoryAdvertisingIdConfiguration(context: Context) : AdvertisingIdConfiguration(context) {
override val adTrackingLimitedPerApp: MutableMap<Int, Boolean> = hashMapOf()
override var adTrackingLimitedGlobally: Boolean = true
override var debugLogging: Boolean = false
override var adId: String = EMPTY_AD_ID
override var debugAdId: String = EMPTY_AD_ID

init {
resetAdvertisingId()
}
}

abstract class AdvertisingIdConfiguration(private val context: Context) {
abstract val adTrackingLimitedPerApp: MutableMap<Int, Boolean>
abstract var adTrackingLimitedGlobally: Boolean
abstract var debugLogging: Boolean
abstract var adId: String
abstract var debugAdId: String

fun isAdTrackingLimitedForApp(uid: Int): Boolean {
if (adTrackingLimitedGlobally) return true
return adTrackingLimitedPerApp[uid] ?: false
}

fun resetAdvertisingId(): String {
adId = UUID.randomUUID().toString()
debugAdId = UUID.randomUUID().toString().dropLast(12) + "10ca1ad1abe1"
return if (debugLogging) debugAdId else adId
}

fun getAdvertisingIdForApp(uid: Int): String {
if (isAdTrackingLimitedForApp(uid)) return EMPTY_AD_ID
try {
val packageNames = context.packageManager.getPackagesForUid(uid) ?: return EMPTY_AD_ID
for (packageName in packageNames) {
val applicationInfo = context.packageManager.getApplicationInfo(packageName, 0)
if (applicationInfo.targetSdkVersion > 33) {
if (context.packageManager.checkPermission("com.google.android.gms.permission.AD_ID", packageName) == PackageManager.PERMISSION_DENIED) {
throw SecurityException("Permission not granted")
}
}
}
} catch (e: Exception) {
Log.w(TAG, "Permission check failed", e)
return EMPTY_AD_ID
}
val adId = if (debugLogging) debugAdId else adId
return adId.ifEmpty { resetAdvertisingId() }
}
}

class AdvertisingIdServiceImpl : IAdvertisingIdService.Stub() {
class AdvertisingIdServiceImpl(private val context: Context) : IAdvertisingIdService.Stub() {
private val configuration = MemoryAdvertisingIdConfiguration(context)

override fun getAdvertisingId(): String {
return "00000000-0000-0000-0000-000000000000"
return configuration.getAdvertisingIdForApp(Binder.getCallingUid())
}

override fun isAdTrackingLimited(ignored: Boolean): Boolean {
return configuration.isAdTrackingLimitedForApp(Binder.getCallingUid())
}

override fun resetAdvertisingId(packageName: String): String {
PackageUtils.checkPackageUid(context, packageName, getCallingUid())
PackageUtils.assertExtendedAccess(context)
return configuration.resetAdvertisingId()
}

override fun setAdTrackingLimitedGlobally(packageName: String, limited: Boolean) {
PackageUtils.checkPackageUid(context, packageName, getCallingUid())
PackageUtils.assertExtendedAccess(context)
configuration.adTrackingLimitedGlobally = limited
}

override fun setDebugLoggingEnabled(packageName: String, enabled: Boolean): String {
PackageUtils.checkPackageUid(context, packageName, getCallingUid())
PackageUtils.assertExtendedAccess(context)
configuration.debugLogging = enabled
return advertisingId
}

override fun isDebugLoggingEnabled(): Boolean {
return configuration.debugLogging
}

override fun isAdTrackingLimitedGlobally(): Boolean {
PackageUtils.assertExtendedAccess(context)
return configuration.adTrackingLimitedGlobally
}

override fun setAdTrackingLimitedForApp(uid: Int, limited: Boolean) {
PackageUtils.assertExtendedAccess(context)
configuration.adTrackingLimitedPerApp[uid] = limited
}

override fun isAdTrackingLimited(defaultHint: Boolean): Boolean {
return true
override fun resetAdTrackingLimitedForApp(uid: Int) {
PackageUtils.assertExtendedAccess(context)
configuration.adTrackingLimitedPerApp.remove(uid)
}

override fun generateAdvertisingId(packageName: String): String {
return advertisingId // Ad tracking limited
override fun getAllAppsLimitedAdTrackingConfiguration(): Bundle {
PackageUtils.assertExtendedAccess(context)
return bundleOf(*configuration.adTrackingLimitedPerApp.map { it.key.toString() to it.value }.toTypedArray())
}

override fun setAdTrackingLimited(packageName: String, limited: Boolean) {
// Ignored, sorry :)
override fun getAdvertisingIdForApp(uid: Int): String {
PackageUtils.assertExtendedAccess(context)
return configuration.getAdvertisingIdForApp(uid)
}
}
11 changes: 11 additions & 0 deletions play-services-ads-identifier/core/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?><!--
~ SPDX-FileCopyrightText: 2023 microG Project Team
~ SPDX-License-Identifier: Apache-2.0
-->

<resources>
<string name="perm_ad_id_label">Advertising ID Permission</string>
<string name="perm_ad_id_description">Allows a publisher app to access a valid advertising ID directly or indirectly.</string>
<string name="perm_ad_id_notification_label">Advertising ID notification</string>
<string name="perm_ad_id_notification_description">Allows an app to receive a notification when the advertising ID or limit ad tracking preference of the user is updated.</string>
</resources>
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
package com.google.android.gms.ads.identifier.internal;

import android.os.Bundle;

interface IAdvertisingIdService {
String getAdvertisingId() = 0;
boolean isAdTrackingLimited(boolean defaultHint) = 1;
String generateAdvertisingId(String packageName) = 2;
void setAdTrackingLimited(String packageName, boolean limited) = 3;
boolean isAdTrackingLimited(boolean ignored) = 1;
String resetAdvertisingId(String packageName) = 2;
void setAdTrackingLimitedGlobally(String packageName, boolean limited) = 3;
String setDebugLoggingEnabled(String packageName, boolean enabled) = 4;
boolean isDebugLoggingEnabled() = 5;
boolean isAdTrackingLimitedGlobally() = 6;
void setAdTrackingLimitedForApp(int uid, boolean limited) = 7;
void resetAdTrackingLimitedForApp(int uid) = 8;
Bundle getAllAppsLimitedAdTrackingConfiguration() = 9; // Map packageName -> Boolean
String getAdvertisingIdForApp(int uid) = 10;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.feedback;

parcelable FeedbackOptions;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.googlehelp;

parcelable GoogleHelp;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.googlehelp;

parcelable InProductHelp;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package com.google.android.gms.googlehelp;

parcelable SupportRequestHelp;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.google.android.gms.googlehelp.internal.common;

import android.graphics.Bitmap;
import android.os.Bundle;
import android.os.IBinder;
import android.os.Parcel;

import com.google.android.gms.googlehelp.GoogleHelp;
import com.google.android.gms.googlehelp.InProductHelp;

interface IGoogleHelpCallbacks {
void onProcessGoogleHelpFinished(in GoogleHelp googleHelp) = 0;
oneway void onSaveAsyncPsdFinished() = 6;
oneway void onSaveAsyncPsbdFinished() = 7;
void onRequestChatSupportSuccess(int chatQueuePosition) = 8;
void onRequestChatSupportFailed() = 9;
void onRequestC2cSupportSuccess() = 10;
void onRequestC2cSupportFailed() = 11;
void onSuggestions(in byte[] suggestions) = 12;
void onNoSuggestions() = 13;
void onEscalationOptions(in byte[] options) = 14;
void onNoEscalationOptions() = 15;
void onProcessInProductHelpFinished(in InProductHelp inProductHelp) = 16;
void onRealtimeSupportStatus(in byte[] status) = 17;
void onNoRealtimeSupportStatus() = 18;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.google.android.gms.googlehelp.internal.common;

import android.graphics.Bitmap;
import android.os.Bundle;

import com.google.android.gms.feedback.FeedbackOptions;
import com.google.android.gms.googlehelp.GoogleHelp;
import com.google.android.gms.googlehelp.InProductHelp;
import com.google.android.gms.googlehelp.SupportRequestHelp;
import com.google.android.gms.googlehelp.internal.common.IGoogleHelpCallbacks;

interface IGoogleHelpService {
void processGoogleHelpAndPip(in GoogleHelp googleHelp, IGoogleHelpCallbacks callbacks) = 0;
void processGoogleHelpAndPipWithBitmap(in GoogleHelp googleHelp, in Bitmap bitmap, IGoogleHelpCallbacks callbacks) = 1;
oneway void saveAsyncHelpPsd(in Bundle bundle, long timestamp, in GoogleHelp googleHelp, IGoogleHelpCallbacks callbacks) = 7;
oneway void saveAsyncFeedbackPsd(in Bundle bundle, long timestamp, in GoogleHelp googleHelp, IGoogleHelpCallbacks callbacks) = 8;
oneway void saveAsyncFeedbackPsbd(in FeedbackOptions options, in Bundle bundle, long timestamp, in GoogleHelp googleHelp, IGoogleHelpCallbacks callbacks) = 9;
oneway void requestChatSupport(in GoogleHelp googleHelp, String phoneNumber, String s2, IGoogleHelpCallbacks callbacks) = 10;
oneway void requestC2cSupport(in GoogleHelp googleHelp, String phoneNumber, String s2, IGoogleHelpCallbacks callbacks) = 11;
oneway void getSuggestions(in GoogleHelp googleHelp, IGoogleHelpCallbacks callbacks) = 12;
oneway void getEscalationOptions(in GoogleHelp googleHelp, IGoogleHelpCallbacks callbacks) = 13;
oneway void requestChatSupportWithSupportRequest(in SupportRequestHelp supportRequestHelp, IGoogleHelpCallbacks callbacks) = 14;
oneway void requestC2cSupportWithSupportRequest(in SupportRequestHelp supportRequestHelp, IGoogleHelpCallbacks callbacks) = 15;
void processInProductHelpAndPip(in InProductHelp inProductHelp, in Bitmap bitmap, IGoogleHelpCallbacks callbacks) = 16;
oneway void getRealtimeSupportStatus(in GoogleHelp googleHelp, IGoogleHelpCallbacks callbacks) = 17;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* SPDX-FileCopyrightText: 2023 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package com.google.android.gms.feedback;

import android.app.ApplicationErrorReport;
import android.graphics.Bitmap;
import org.microg.safeparcel.AutoSafeParcelable;

public class ErrorReport extends AutoSafeParcelable {
@Field(2)
public ApplicationErrorReport applicationErrorReport;
@Field(4)
public int unknownInt4;
@Field(12)
public int unknownInt12;
@Field(24)
public int unknownInt24;
@Field(25)
public int unknownInt25;
@Field(26)
public int unknownInt26;
@Field(27)
public int unknownInt27;
@Field(32)
public boolean unknownBool32;
@Field(33)
public int unknownInt33;
@Field(34)
public int unknownInt34;
@Field(35)
public boolean unknownBool35;
@Field(36)
public String exceptionClassName;
@Field(37)
public String throwFileName;
@Field(38)
public int throwLineNumber;
@Field(39)
public String throwClassName;
@Field(40)
public String throwMethodName;
@Field(41)
public String stackTrace;
@Field(42)
public String exceptionMessage;
@Field(50)
public boolean unknownBool50;
@Field(51)
public String unknownString51;
@Field(52)
public ThemeSettings themeSettings;
@Field(53)
public LogOptions logOptions;
@Field(55)
public boolean unknownBool55;
@Field(58)
public boolean unknownBool58;
@Field(59)
public Bitmap unknownBitmap59;
@Field(60)
public String unknownString60;
@Field(62)
public int unknownInt62;
@Field(63)
public int unknownInt63;
@Field(67)
public boolean unknownBool67;
@Field(68)
public boolean unknownBool68;
public static final Creator<ErrorReport> CREATOR = findCreator(ErrorReport.class);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* SPDX-FileCopyrightText: 2023 microG Project Team
* SPDX-License-Identifier: Apache-2.0
*/

package com.google.android.gms.feedback;

import android.app.ApplicationErrorReport;
import android.graphics.Bitmap;
import android.os.Bundle;
import org.microg.safeparcel.AutoSafeParcelable;

import java.util.List;

public class FeedbackOptions extends AutoSafeParcelable {
@Field(3)
public Bundle unknownBundle3;
@Field(6)
public ApplicationErrorReport applicationErrorReport;
@Field(9)
public String packageName;
@Field(10)
public List<FileTeleporter> files;
@Field(11)
public boolean unknownBool11;
@Field(12)
public ThemeSettings themeSettings;
@Field(13)
public LogOptions logOptions;
@Field(15)
public Bitmap screenshot;
@Field(17)
public boolean unknownBool17;
@Field(18)
public long unknownLong18;
@Field(19)
public boolean unknownBool19;
public static final Creator<FeedbackOptions> CREATOR = findCreator(FeedbackOptions.class);
}
Loading

0 comments on commit 7626be9

Please sign in to comment.