summaryrefslogtreecommitdiff
path: root/adservices/apk/java
diff options
context:
space:
mode:
Diffstat (limited to 'adservices/apk/java')
-rw-r--r--adservices/apk/java/com/android/adservices/common/AdServicesCommonService.java5
-rw-r--r--adservices/apk/java/com/android/adservices/shell/AdServicesShellCommandService.java57
-rw-r--r--adservices/apk/java/com/android/adservices/ui/UxUtil.java6
-rw-r--r--adservices/apk/java/com/android/adservices/ui/notifications/ConsentNotificationActivity.java12
-rw-r--r--adservices/apk/java/com/android/adservices/ui/notifications/ConsentNotificationTrigger.java66
-rw-r--r--adservices/apk/java/com/android/adservices/ui/settings/activities/AdServicesSettingsMainActivity.java3
6 files changed, 75 insertions, 74 deletions
diff --git a/adservices/apk/java/com/android/adservices/common/AdServicesCommonService.java b/adservices/apk/java/com/android/adservices/common/AdServicesCommonService.java
index 9c99aa982a..f8fb54d8ed 100644
--- a/adservices/apk/java/com/android/adservices/common/AdServicesCommonService.java
+++ b/adservices/apk/java/com/android/adservices/common/AdServicesCommonService.java
@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
+import android.os.Trace;
import androidx.annotation.RequiresApi;
@@ -51,6 +52,8 @@ public class AdServicesCommonService extends Service {
@Override
public void onCreate() {
super.onCreate();
+
+ Trace.beginSection("AdServicesCommonService#Initialization");
if (mAdServicesCommonService == null) {
mAdServicesCommonService =
new AdServicesCommonServiceImpl(
@@ -80,6 +83,7 @@ public class AdServicesCommonService extends Service {
"getting exception when register consumer in AdServicesSyncUtil of "
+ e.getMessage());
}
+ Trace.endSection();
}
@Override
@@ -90,7 +94,6 @@ public class AdServicesCommonService extends Service {
// TODO(b/308009734): STOPSHIP - remove this method once the proper service is available
@Override
protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
- enforceCallingPermission(android.Manifest.permission.DUMP, /* message = */ "dump()");
if (args != null && args.length > 0 && args[0].equals("cmd")) {
boolean enabled = FlagsFactory.getFlags().getAdServicesShellCommandEnabled();
if (!enabled) {
diff --git a/adservices/apk/java/com/android/adservices/shell/AdServicesShellCommandService.java b/adservices/apk/java/com/android/adservices/shell/AdServicesShellCommandService.java
new file mode 100644
index 0000000000..8d07378ca6
--- /dev/null
+++ b/adservices/apk/java/com/android/adservices/shell/AdServicesShellCommandService.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2023 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.adservices.shell;
+
+import android.annotation.Nullable;
+import android.app.Service;
+import android.content.Intent;
+import android.os.IBinder;
+
+import com.android.adservices.LogUtil;
+import com.android.adservices.service.FlagsFactory;
+import com.android.adservices.service.shell.ShellCommandServiceImpl;
+
+import java.util.Objects;
+
+/** Implements a service which runs the shell command in the adservices process. */
+public final class AdServicesShellCommandService extends Service {
+
+ /** The binder service. This field must only be accessed on the main thread. */
+ private ShellCommandServiceImpl mShellCommandService;
+
+ @Override
+ public void onCreate() {
+ if (!FlagsFactory.getFlags().getAdServicesShellCommandEnabled()) {
+ LogUtil.e("Shell command service is not enabled.");
+ return;
+ }
+
+ mShellCommandService = new ShellCommandServiceImpl();
+ }
+
+ @Nullable
+ @Override
+ public IBinder onBind(Intent intent) {
+ if (!FlagsFactory.getFlags().getAdServicesShellCommandEnabled()) {
+ LogUtil.e("Shell command service is not enabled.");
+ return null;
+ }
+ return Objects.requireNonNull(mShellCommandService);
+ }
+
+ // TODO(b/308009734): Implement dump method.
+}
diff --git a/adservices/apk/java/com/android/adservices/ui/UxUtil.java b/adservices/apk/java/com/android/adservices/ui/UxUtil.java
index 035c3d284f..9efc670f31 100644
--- a/adservices/apk/java/com/android/adservices/ui/UxUtil.java
+++ b/adservices/apk/java/com/android/adservices/ui/UxUtil.java
@@ -36,7 +36,11 @@ public class UxUtil {
/** Returns whether the device is an EEA device. */
public static boolean isEeaDevice(FragmentActivity fragmentActivity, Context context) {
return FlagsFactory.getFlags().getConsentNotificationActivityDebugMode()
- ? fragmentActivity.getIntent().getBooleanExtra("isEUDevice", /* default= */ true)
+ ? fragmentActivity
+ .getIntent()
+ .getBooleanExtra(
+ "isEUDevice",
+ /* default= */ UxStatesManager.getInstance(context).isEeaDevice())
: !ConsentManager.getInstance(context).isAdIdEnabled()
|| UxStatesManager.getInstance(context).isEeaDevice();
}
diff --git a/adservices/apk/java/com/android/adservices/ui/notifications/ConsentNotificationActivity.java b/adservices/apk/java/com/android/adservices/ui/notifications/ConsentNotificationActivity.java
index 9492a51881..3455cc7fd8 100644
--- a/adservices/apk/java/com/android/adservices/ui/notifications/ConsentNotificationActivity.java
+++ b/adservices/apk/java/com/android/adservices/ui/notifications/ConsentNotificationActivity.java
@@ -107,11 +107,7 @@ public class ConsentNotificationActivity extends FragmentActivity implements UxS
@Override
public void initGA() {
- if (FlagsFactory.getFlags().getEuNotifFlowChangeEnabled()) {
- setContentView(R.layout.consent_notification_ga_v2_activity);
- } else {
- setContentView(R.layout.consent_notification_ga_activity);
- }
+ setContentView(R.layout.consent_notification_ga_v2_activity);
}
@Override
@@ -131,11 +127,7 @@ public class ConsentNotificationActivity extends FragmentActivity implements UxS
private void initFragment() {
if (FlagsFactory.getFlags().getGaUxFeatureEnabled()) {
- if (FlagsFactory.getFlags().getEuNotifFlowChangeEnabled()) {
- setContentView(R.layout.consent_notification_ga_v2_activity);
- } else {
- setContentView(R.layout.consent_notification_ga_activity);
- }
+ setContentView(R.layout.consent_notification_ga_v2_activity);
} else {
setContentView(R.layout.consent_notification_activity);
}
diff --git a/adservices/apk/java/com/android/adservices/ui/notifications/ConsentNotificationTrigger.java b/adservices/apk/java/com/android/adservices/ui/notifications/ConsentNotificationTrigger.java
index 98230b848a..a11a5a645d 100644
--- a/adservices/apk/java/com/android/adservices/ui/notifications/ConsentNotificationTrigger.java
+++ b/adservices/apk/java/com/android/adservices/ui/notifications/ConsentNotificationTrigger.java
@@ -16,7 +16,6 @@
package com.android.adservices.ui.notifications;
-import static com.android.adservices.service.FlagsConstants.KEY_EU_NOTIF_FLOW_CHANGE_ENABLED;
import static com.android.adservices.service.FlagsConstants.KEY_GA_UX_FEATURE_ENABLED;
import static com.android.adservices.service.FlagsConstants.KEY_NOTIFICATION_DISMISSED_ON_CLICK;
import static com.android.adservices.service.FlagsConstants.KEY_RECORD_MANUAL_INTERACTION_ENABLED;
@@ -37,7 +36,6 @@ import androidx.core.app.NotificationCompat;
import androidx.core.app.NotificationManagerCompat;
import com.android.adservices.api.R;
-import com.android.adservices.service.FlagsFactory;
import com.android.adservices.service.consent.AdServicesApiType;
import com.android.adservices.service.consent.ConsentManager;
import com.android.adservices.service.stats.UiStatsLogger;
@@ -127,12 +125,7 @@ public class ConsentNotificationTrigger {
if (isUxStatesReady(context)) {
switch (UxUtil.getUx(context)) {
case GA_UX:
- if (UxStatesManager.getInstance(context)
- .getFlag(KEY_EU_NOTIF_FLOW_CHANGE_ENABLED)) {
- notification = getGaV2ConsentNotification(context, isEuDevice);
- } else {
- notification = getGaConsentNotification(context, isEuDevice);
- }
+ notification = getGaV2ConsentNotification(context, isEuDevice);
break;
// Both U18_UX and RVC_UX are showing U18 Notification
case U18_UX:
@@ -143,15 +136,11 @@ public class ConsentNotificationTrigger {
notification = getConsentNotification(context, isEuDevice);
break;
default:
- notification = getGaConsentNotification(context, isEuDevice);
+ notification = getGaV2ConsentNotification(context, isEuDevice);
}
} else {
if (gaUxFeatureEnabled) {
- if (FlagsFactory.getFlags().getEuNotifFlowChangeEnabled()) {
- notification = getGaV2ConsentNotification(context, isEuDevice);
- } else {
- notification = getGaConsentNotification(context, isEuDevice);
- }
+ notification = getGaV2ConsentNotification(context, isEuDevice);
} else {
notification = getConsentNotification(context, isEuDevice);
}
@@ -252,54 +241,7 @@ public class ConsentNotificationTrigger {
.setContentIntent(pendingIntent);
return notification.build();
}
-
- /**
- * Returns a {@link NotificationCompat.Builder} which can be used to display consent
- * notification to the user when GaUxFeature flag is enabled.
- *
- * @param context {@link Context} which is used to prepare a {@link NotificationCompat}.
- */
- private static Notification getGaConsentNotification(
- @NonNull Context context, boolean isEuDevice) {
- Intent intent = new Intent(context, ConsentNotificationActivity.class);
-
- PendingIntent pendingIntent =
- PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_IMMUTABLE);
- NotificationCompat.BigTextStyle textStyle =
- new NotificationCompat.BigTextStyle()
- .bigText(
- isEuDevice
- ? context.getString(
- R.string.notificationUI_notification_ga_content_eu)
- : context.getString(
- R.string.notificationUI_notification_ga_content));
- NotificationCompat.Builder notification =
- new NotificationCompat.Builder(context, CHANNEL_ID)
- .setSmallIcon(R.drawable.ic_info_icon)
- .setContentTitle(
- context.getString(
- isEuDevice
- ? R.string.notificationUI_notification_ga_title_eu
- : R.string.notificationUI_notification_ga_title))
- .setContentText(
- context.getString(
- isEuDevice
- ? R.string.notificationUI_notification_ga_content_eu
- : R.string.notificationUI_notification_ga_content))
- .setStyle(textStyle)
- .setPriority(NOTIFICATION_PRIORITY)
- .setAutoCancel(true)
- .setContentIntent(pendingIntent);
-
- if (isEuDevice
- && !UxStatesManager.getInstance(context)
- .getFlag(KEY_NOTIFICATION_DISMISSED_ON_CLICK)) {
- notification.setAutoCancel(false);
- }
-
- return notification.build();
- }
-
+
/**
* Returns a {@link NotificationCompat.Builder} which can be used to display consent
* notification to the user.
diff --git a/adservices/apk/java/com/android/adservices/ui/settings/activities/AdServicesSettingsMainActivity.java b/adservices/apk/java/com/android/adservices/ui/settings/activities/AdServicesSettingsMainActivity.java
index ee90679807..619978aade 100644
--- a/adservices/apk/java/com/android/adservices/ui/settings/activities/AdServicesSettingsMainActivity.java
+++ b/adservices/apk/java/com/android/adservices/ui/settings/activities/AdServicesSettingsMainActivity.java
@@ -19,6 +19,7 @@ import static com.android.adservices.ui.UxUtil.isUxStatesReady;
import android.os.Build;
import android.os.Bundle;
+import android.os.Trace;
import androidx.annotation.RequiresApi;
import androidx.lifecycle.ViewModelProvider;
@@ -58,6 +59,7 @@ public class AdServicesSettingsMainActivity extends AdServicesBaseActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
+ Trace.beginSection("AdServicesSettingsMainActivity#OnCreate");
// Only for main view, we want to use the most up to date OTA strings on the device to
// create the ResourcesLoader.
if (FlagsFactory.getFlags().getUiOtaStringsFeatureEnabled()) {
@@ -70,6 +72,7 @@ public class AdServicesSettingsMainActivity extends AdServicesBaseActivity {
if (!isUxStatesReady(this)) {
initMainFragment();
}
+ Trace.endSection();
}
private void initMainFragment() {