Skip to content

Commit 2372e1b

Browse files
committed
Migrating dev-preview-main into main
1 parent 8a52cfc commit 2372e1b

File tree

32 files changed

+884
-585
lines changed

32 files changed

+884
-585
lines changed

‎PrivacySandboxKotlin/README.md

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,46 @@ and can follow the commands described in this README as is. For OEMs to use the
1313
flavor, you will need to update the "Preview" part of the commands to "Oems", all other instructions
1414
are the same.
1515

16-
## Running the Sample
16+
## Defining the SDK API
17+
The SDK running in the Privacy Sandbox needs a public API defined with Kotlin interfaces and
18+
annotated with Privacy Sandbox tool annotations. This allows us to generate an SDK provider that
19+
compatible with your custom interfaces. To use it just extend `AbstractSandboxedSdkProviderCompat`,
20+
it will be generated in the same package that defined the `@PrivacySandboxService` interface.
1721

18-
The Privacy Sandbox should have a class which extends `SandboxedSdkProvider`.
19-
This class works as an entry point for the sandbox to interact with the SDK.
20-
The Privacy Sandbox SDK provider library is implemented in the `sdk-implementation` module.
22+
## Running the Sample
23+
The sample contains a working SDK in the `example-sdk` module. The SDK is bundled for release and
24+
app consumption in the `example-sdk-bundle` module, this is where the SDK version, package name and
25+
signing information is defined.
2126

22-
The client app is implemented in the `client-app` module. This app interacts with the SDK running
23-
in the Privacy Sandbox.
27+
The client app is implemented in the `client-app` module. The `existing-sdk` module represents a
28+
modified version of a regular SDK that runs in the app as usual but is also capable of loading and
29+
interacting with the example SDK.
2430

2531
There are two methods for building and installing the SDK. The preferred option is use Android
26-
Studio's UI to handle building and deploying the SDK and launching the client app. However, it is
32+
Studio's UI to handle building and deploying the SDK and launching the client app. However, it is
2733
possible to build the app bundle and install the APK via the command line, then run the client app.
2834

29-
### From the UI
35+
### Setting up your device
36+
You will need to override a few flags to get the Privacy Sandbox enabled on your device. Before
37+
installing the app, run the following commands:
38+
39+
```shell
40+
adb shell device_config put adservices adservice_system_service_enabled false
41+
adb shell device_config put adservices global_kill_switch false
42+
adb shell device_config put adservices disable_sdk_sandbox false
43+
adb shell device_config put adservices sdksandbox_customized_sdk_context_enabled true
44+
```
45+
46+
### Launch sample from the UI
3047
In Android Studio, edit your run configuration as follows:
31-
Edit run configurations > client-app > Deploy > Default APK. Then, under Launch Options,
48+
Edit run configurations > client-app > Deploy > APK from app bundle. Then, under Launch Options,
3249
Launch > Specified Activity > Activity > `com.example.client.MainActivity`
3350

3451
Press the run button. Your app should launch and you can proceed to the
3552
[Testing the client](#testing-the-client) section.
3653

3754
### Command Line
38-
Build the APK bundle by running
55+
Build the APK bundle by running
3956

4057
```shell
4158
./gradlew client-app:buildPrivacySandboxSdkApksForPreviewDebug
@@ -54,8 +71,7 @@ Finally, run the client app via Android Studio's UI.
5471
### Testing the client
5572

5673
- Click on the "load SDK" button, a toast should show that SDK loaded successfully.
57-
- Click on the "Request Webview", this should remote render a webview from the
58-
sandbox to be viewed inside the activity.
74+
- Click on the "Show banner view" after the SDK is loaded and a banner rendered by the SDK will be
75+
displayed. If you click it, an Activity customized by the SDK will be launched.
5976

6077
- For more information, please read the [documentation](https://developer.android.com/design-for-safety/privacy-sandbox/guides/sdk-runtime).
61-

‎PrivacySandboxKotlin/build.gradle

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
// Top-level build file where you can add configuration options common to all sub-projects/modules.
22
buildscript {
3-
ext.kotlin_version = '1.6.21'
3+
ext.kotlin_version = '1.9.10'
4+
ext.ksp_version = "$kotlin_version-1.0.13"
5+
ext.privacy_sandbox_activity_version = "1.0.0-alpha01"
6+
ext.privacy_sandbox_sdk_runtime_version = "1.0.0-alpha13"
7+
ext.privacy_sandbox_tools_version = "1.0.0-alpha07"
8+
ext.privacy_sandbox_ui_version = "1.0.0-alpha07"
49
repositories {
510
mavenCentral()
611
}
@@ -9,8 +14,13 @@ buildscript {
914
}
1015
}
1116
plugins {
12-
id 'com.android.application' version '8.3.0-alpha10' apply false
13-
id 'com.android.library' version '8.3.0-alpha10' apply false
17+
id 'com.android.application' version '8.4.0-alpha13' apply false
18+
id 'com.android.library' version '8.4.0-alpha13' apply false
19+
20+
// These two plugins do annotation processing and code generation for the sdk-implementation.
21+
id 'androidx.privacysandbox.library' version '1.0.0-alpha02' apply false
22+
id 'com.google.devtools.ksp' version "$ksp_version" apply false
23+
id 'org.jetbrains.kotlin.jvm' version '1.9.10' apply false
1424
}
1525

1626
task clean(type: Delete) {

‎PrivacySandboxKotlin/client-app/build.gradle

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -14,52 +14,58 @@
1414
* limitations under the License.
1515
*/
1616
plugins {
17-
id 'com.android.application'
17+
id "com.android.application"
1818
}
19-
apply plugin: 'kotlin-android'
19+
apply plugin: "kotlin-android"
20+
2021
android {
21-
compileSdk = 33
22-
compileSdkExtension = 5
22+
23+
privacySandbox {
24+
enable = true
25+
}
26+
2327
defaultConfig {
2428
applicationId "com.example.privacysandbox.client"
25-
minSdkVersion 33
26-
targetSdkVersion 33
29+
minSdkVersion 21
30+
compileSdk 34
31+
compileSdkExtension 10
32+
targetSdkVersion 34
2733
versionCode 2
2834
versionName "1.01"
35+
2936
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
3037
}
31-
flavorDimensions 'androidSdk'
32-
productFlavors {
33-
preview {
34-
dimension 'androidSdk'
35-
}
36-
oem {
37-
dimension 'androidSdk'
38-
minSdkVersion 33
39-
targetSdkVersion 33
40-
}
41-
}
38+
4239
buildTypes {
4340
release {
4441
minifyEnabled false
45-
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
42+
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
4643
}
4744
}
4845
compileOptions {
49-
sourceCompatibility JavaVersion.VERSION_1_8
50-
targetCompatibility JavaVersion.VERSION_1_8
46+
sourceCompatibility JavaVersion.VERSION_17
47+
targetCompatibility JavaVersion.VERSION_17
5148
}
52-
namespace 'com.example.privacysandbox.client'
49+
namespace "com.example.privacysandbox.client"
50+
51+
experimentalProperties["android.privacySandboxSdk.apiGenerator"] =
52+
project.dependencies.create(
53+
"androidx.privacysandbox.tools:tools-apigenerator:$privacy_sandbox_tools_version")
54+
55+
experimentalProperties["android.privacySandboxSdk.apiGenerator.generatedRuntimeDependencies"] = [
56+
project.dependencies.create("org.jetbrains.kotlin:kotlin-stdlib:1.7.20-RC"),
57+
project.dependencies.create("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.0.1"),
58+
project.dependencies.create("androidx.privacysandbox.activity:activity-core:$privacy_sandbox_activity_version"),
59+
project.dependencies.create("androidx.privacysandbox.activity:activity-client:$privacy_sandbox_activity_version"),
60+
project.dependencies.create("androidx.privacysandbox.ui:ui-core:$privacy_sandbox_ui_version"),
61+
project.dependencies.create("androidx.privacysandbox.ui:ui-client:$privacy_sandbox_ui_version"),
62+
]
5363
}
64+
5465
dependencies {
55-
implementation 'androidx.appcompat:appcompat:1.4.1'
56-
implementation 'com.google.android.material:material:1.5.0'
57-
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
58-
implementation project(':example-aidl-library')
59-
implementation project(':example-sdk')
60-
testImplementation 'junit:junit:4.13.2'
61-
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
62-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
63-
implementation "androidx.core:core-ktx:1.7.0"
64-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
65-
}
66+
// Depend on the SDK library that will run inside the app.
67+
implementation project(':existing-sdk')
68+
69+
implementation "androidx.appcompat:appcompat:1.6.1"
70+
implementation "com.google.android.material:material:1.9.0"
71+
}

‎PrivacySandboxKotlin/client-app/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
See the License for the specific language governing permissions and
1212
limitations under the License.
1313
-->
14-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
15-
package="com.example.privacysandbox.client">
14+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
1615

1716
<uses-permission android:name="android.permission.INTERNET"/>
1817
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

0 commit comments

Comments
 (0)