Merge "Update OWNERS for framework lint checks" into main
diff --git a/Android.bp b/Android.bp
index b739c43..5211fe2 100644
--- a/Android.bp
+++ b/Android.bp
@@ -506,6 +506,9 @@
},
lint: {
baseline_filename: "lint-baseline.xml",
+ warning_checks: [
+ "FlaggedApi",
+ ],
},
jarjar_prefix: "com.android.internal.hidden_from_bootclasspath",
}
diff --git a/apex/jobscheduler/service/Android.bp b/apex/jobscheduler/service/Android.bp
index ace56d4..06c7d64 100644
--- a/apex/jobscheduler/service/Android.bp
+++ b/apex/jobscheduler/service/Android.bp
@@ -24,6 +24,7 @@
"app-compat-annotations",
"error_prone_annotations",
"framework",
+ "keepanno-annotations",
"services.core",
"unsupportedappusage",
],
diff --git a/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java b/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java
index 19bc716..613678b 100644
--- a/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java
+++ b/apex/jobscheduler/service/java/com/android/server/usage/AppStandbyController.java
@@ -130,6 +130,8 @@
import com.android.server.LocalServices;
import com.android.server.pm.pkg.AndroidPackage;
import com.android.server.usage.AppIdleHistory.AppUsageHistory;
+import com.android.tools.r8.keepanno.annotations.KeepItemKind;
+import com.android.tools.r8.keepanno.annotations.UsedByReflection;
import libcore.util.EmptyArray;
@@ -588,6 +590,8 @@
}
}
+ // This constructor is reflectively invoked from framework code in AppStandbyInternal.
+ @UsedByReflection(kind = KeepItemKind.CLASS_AND_METHODS)
public AppStandbyController(Context context) {
this(new Injector(context, AppSchedulingModuleThread.get().getLooper()));
}
diff --git a/core/java/android/os/ServiceManagerNative.java b/core/java/android/os/ServiceManagerNative.java
index f2143f6..7b91dd5 100644
--- a/core/java/android/os/ServiceManagerNative.java
+++ b/core/java/android/os/ServiceManagerNative.java
@@ -50,7 +50,7 @@
class ServiceManagerProxy implements IServiceManager {
public ServiceManagerProxy(IBinder remote) {
mRemote = remote;
- mServiceManager = IServiceManager.Stub.asInterface(remote);
+ mServiceManager = IServiceManager.Stub.asInterface(this.getNativeServiceManager());
}
public IBinder asBinder() {
@@ -128,4 +128,6 @@
private IBinder mRemote;
private IServiceManager mServiceManager;
+
+ private native IBinder getNativeServiceManager();
}
diff --git a/core/jni/Android.bp b/core/jni/Android.bp
index 8a230de..ce19965 100644
--- a/core/jni/Android.bp
+++ b/core/jni/Android.bp
@@ -192,6 +192,7 @@
"android_os_PerformanceHintManager.cpp",
"android_os_SELinux.cpp",
"android_os_ServiceManager.cpp",
+ "android_os_ServiceManagerNative.cpp",
"android_os_SharedMemory.cpp",
"android_os_storage_StorageManager.cpp",
"android_os_UEventObserver.cpp",
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index aa63f4f..9111129 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -148,6 +148,7 @@
extern int register_android_os_HwRemoteBinder(JNIEnv *env);
extern int register_android_os_NativeHandle(JNIEnv *env);
extern int register_android_os_ServiceManager(JNIEnv *env);
+extern int register_android_os_ServiceManagerNative(JNIEnv* env);
extern int register_android_os_MessageQueue(JNIEnv* env);
extern int register_android_os_Parcel(JNIEnv* env);
extern int register_android_os_PerformanceHintManager(JNIEnv* env);
@@ -1542,6 +1543,7 @@
REG_JNI(register_android_os_HwRemoteBinder),
REG_JNI(register_android_os_NativeHandle),
REG_JNI(register_android_os_ServiceManager),
+ REG_JNI(register_android_os_ServiceManagerNative),
REG_JNI(register_android_os_storage_StorageManager),
REG_JNI(register_android_service_DataLoaderService),
REG_JNI(register_android_view_DisplayEventReceiver),
diff --git a/core/jni/android_os_ServiceManagerNative.cpp b/core/jni/android_os_ServiceManagerNative.cpp
new file mode 100644
index 0000000..39a3013
--- /dev/null
+++ b/core/jni/android_os_ServiceManagerNative.cpp
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2024 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.
+ */
+#include <binder/IServiceManagerFFI.h>
+#include <jni.h>
+#include <nativehelper/JNIHelp.h>
+
+#include "android_util_Binder.h"
+namespace android {
+
+jobject JNICALL Java_android_os_ServiceManagerProxy_getNativeServiceManager(JNIEnv *env,
+ jobject obj) {
+ sp<IBinder> service = IInterface::asBinder(
+ impl::getJavaServicemanagerImplPrivateDoNotUseExceptInTheOnePlaceItIsUsed());
+ return javaObjectForIBinder(env, service);
+}
+
+// ----------------------------------------------------------------------------
+
+static const JNINativeMethod serviceManagerNativeMethods[] = {
+ /* name, signature, funcPtr */
+ {"getNativeServiceManager", "()Landroid/os/IBinder;",
+ (void *)Java_android_os_ServiceManagerProxy_getNativeServiceManager}};
+
+int register_android_os_ServiceManagerNative(JNIEnv *env) {
+ return jniRegisterNativeMethods(env, "android/os/ServiceManagerProxy",
+ serviceManagerNativeMethods,
+ NELEM(serviceManagerNativeMethods));
+}
+} // namespace android
\ No newline at end of file
diff --git a/location/Android.bp b/location/Android.bp
index 5ba35ac..7f3442c 100644
--- a/location/Android.bp
+++ b/location/Android.bp
@@ -39,6 +39,11 @@
"frameworks/base/core/java",
],
},
+ lint: {
+ warning_checks: [
+ "FlaggedApi",
+ ],
+ },
}
platform_compat_config {
diff --git a/packages/SystemUI/OWNERS b/packages/SystemUI/OWNERS
index 3a5ec92..9374bf4 100644
--- a/packages/SystemUI/OWNERS
+++ b/packages/SystemUI/OWNERS
@@ -8,6 +8,7 @@
acul@google.com
adamcohen@google.com
aioana@google.com
+alexchau@google.com
alexflo@google.com
andonian@google.com
aroederer@google.com
@@ -83,8 +84,10 @@
rahulbanerjee@google.com
roosa@google.com
saff@google.com
+samcackett@google.com
santie@google.com
shanh@google.com
+silvajordan@google.com
snoeberger@google.com
steell@google.com
stevenckng@google.com
@@ -96,6 +99,7 @@
tracyzhou@google.com
tsuji@google.com
twickham@google.com
+uwaisashraf@google.com
vadimt@google.com
valiiftime@google.com
vanjan@google.com
diff --git a/services/Android.bp b/services/Android.bp
index 0fbbd16..a0d3454 100644
--- a/services/Android.bp
+++ b/services/Android.bp
@@ -239,6 +239,7 @@
libs: [
"android.hidl.manager-V1.0-java",
"framework-tethering.stubs.module_lib",
+ "keepanno-annotations",
"service-art.stubs.system_server",
"service-permission.stubs.system_server",
"service-rkp.stubs.system_server",
diff --git a/services/core/Android.bp b/services/core/Android.bp
index 7fb2250..fa323fd 100644
--- a/services/core/Android.bp
+++ b/services/core/Android.bp
@@ -182,6 +182,7 @@
"android.hardware.vibrator-V2-java",
"app-compat-annotations",
"framework-tethering.stubs.module_lib",
+ "keepanno-annotations",
"service-art.stubs.system_server",
"service-permission.stubs.system_server",
"service-rkp.stubs.system_server",
@@ -267,6 +268,9 @@
],
lint: {
baseline_filename: "lint-baseline.xml",
+ warning_checks: [
+ "FlaggedApi",
+ ],
},
}
diff --git a/services/core/java/com/android/server/display/LocalDisplayAdapter.java b/services/core/java/com/android/server/display/LocalDisplayAdapter.java
index 88c24e0..cf4393b 100644
--- a/services/core/java/com/android/server/display/LocalDisplayAdapter.java
+++ b/services/core/java/com/android/server/display/LocalDisplayAdapter.java
@@ -48,6 +48,7 @@
import android.view.SurfaceControl;
import com.android.internal.R;
+import com.android.internal.annotations.KeepForWeakReference;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.display.BrightnessSynchronizer;
import com.android.internal.util.function.pooled.PooledLambda;
@@ -1394,8 +1395,9 @@
}
public static class Injector {
- // Native callback.
+ // Ensure the callback is kept to preserve native weak reference lifecycle semantics.
@SuppressWarnings("unused")
+ @KeepForWeakReference
private ProxyDisplayEventReceiver mReceiver;
public void setDisplayEventListenerLocked(Looper looper, DisplayEventListener listener) {
mReceiver = new ProxyDisplayEventReceiver(looper, listener);
diff --git a/services/core/java/com/android/server/notification/RankingHelper.java b/services/core/java/com/android/server/notification/RankingHelper.java
index 773d10b..478868b 100644
--- a/services/core/java/com/android/server/notification/RankingHelper.java
+++ b/services/core/java/com/android/server/notification/RankingHelper.java
@@ -25,6 +25,10 @@
import android.util.Slog;
import android.util.proto.ProtoOutputStream;
+import com.android.tools.r8.keepanno.annotations.KeepItemKind;
+import com.android.tools.r8.keepanno.annotations.KeepTarget;
+import com.android.tools.r8.keepanno.annotations.UsesReflection;
+
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
@@ -41,7 +45,13 @@
private final Context mContext;
private final RankingHandler mRankingHandler;
-
+ @UsesReflection(
+ value = {
+ @KeepTarget(
+ kind = KeepItemKind.CLASS_AND_MEMBERS,
+ instanceOfClassConstantExclusive = NotificationSignalExtractor.class,
+ methodName = "<init>")
+ })
public RankingHelper(Context context, RankingHandler rankingHandler, RankingConfig config,
ZenModeHelper zenHelper, NotificationUsageStats usageStats, String[] extractorNames) {
mContext = context;
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
index 45ea2db3..2f2512d 100644
--- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -131,6 +131,9 @@
import com.android.server.wallpaper.WallpaperData.BindSource;
import com.android.server.wm.ActivityTaskManagerInternal;
import com.android.server.wm.WindowManagerInternal;
+import com.android.tools.r8.keepanno.annotations.KeepItemKind;
+import com.android.tools.r8.keepanno.annotations.KeepTarget;
+import com.android.tools.r8.keepanno.annotations.UsesReflection;
import org.xmlpull.v1.XmlPullParserException;
@@ -166,6 +169,13 @@
}
@Override
+ @UsesReflection(
+ value = {
+ @KeepTarget(
+ kind = KeepItemKind.CLASS_AND_MEMBERS,
+ instanceOfClassConstantExclusive = IWallpaperManagerService.class,
+ methodName = "<init>")
+ })
public void onStart() {
try {
final Class<? extends IWallpaperManagerService> klass =
diff --git a/services/core/java/com/android/server/wm/DisplayAreaPolicy.java b/services/core/java/com/android/server/wm/DisplayAreaPolicy.java
index c18377d..3a4d02f 100644
--- a/services/core/java/com/android/server/wm/DisplayAreaPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayAreaPolicy.java
@@ -40,6 +40,10 @@
import android.os.Bundle;
import android.text.TextUtils;
+import com.android.tools.r8.keepanno.annotations.KeepItemKind;
+import com.android.tools.r8.keepanno.annotations.KeepTarget;
+import com.android.tools.r8.keepanno.annotations.UsesReflection;
+
import java.util.ArrayList;
import java.util.List;
@@ -179,6 +183,13 @@
/**
* Instantiates the device-specific {@link Provider}.
*/
+ @UsesReflection(
+ value = {
+ @KeepTarget(
+ kind = KeepItemKind.CLASS_AND_MEMBERS,
+ instanceOfClassConstantExclusive = Provider.class,
+ methodName = "<init>")
+ })
static Provider fromResources(Resources res) {
String name = res.getString(
com.android.internal.R.string.config_deviceSpecificDisplayAreaPolicyProvider);
diff --git a/services/proguard.flags b/services/proguard.flags
index a01e7dc..f84eff7 100644
--- a/services/proguard.flags
+++ b/services/proguard.flags
@@ -33,12 +33,6 @@
-keep,allowoptimization,allowaccessmodification class * extends com.android.server.SystemService {
public <methods>;
}
--keep,allowoptimization,allowaccessmodification class * extends com.android.server.devicepolicy.BaseIDevicePolicyManager {
- public <init>(...);
-}
--keep,allowoptimization,allowaccessmodification class com.android.server.wallpaper.WallpaperManagerService {
- public <init>(...);
-}
# Accessed from com.android.compos APEX
-keep,allowoptimization,allowaccessmodification class com.android.internal.art.ArtStatsLog {
@@ -68,13 +62,6 @@
-keep public class android.hidl.manager.** { *; }
-keep public class com.android.server.wm.WindowManagerInternal { *; }
-# Notification extractors
-# TODO(b/210510433): Revisit and consider generating from frameworks/base/core/res/res/values/config.xml.
--keep,allowoptimization,allowaccessmodification public class com.android.server.notification.** implements com.android.server.notification.NotificationSignalExtractor
-
-# OEM provided DisplayAreaPolicy.Provider defined in frameworks/base/core/res/res/values/config.xml.
--keep,allowoptimization,allowaccessmodification class com.android.server.wm.** implements com.android.server.wm.DisplayAreaPolicy$Provider
-
# JNI keep rules
# The global keep rule for native methods allows stripping of such methods if they're unreferenced
# in Java. However, because system_server explicitly registers these methods from native code,
@@ -118,9 +105,6 @@
# Miscellaneous reflection keep rules
# TODO(b/210510433): Revisit and fix with @Keep.
--keep,allowoptimization,allowaccessmodification class com.android.server.usage.AppStandbyController {
- public <init>(...);
-}
-keep,allowoptimization,allowaccessmodification class android.hardware.usb.gadget.** { *; }
# Needed when optimizations enabled