Loading core/java/Android.bp +27 −0 Original line number Diff line number Diff line Loading @@ -464,6 +464,13 @@ filegroup { ], } filegroup { name: "activity_manager_iuidobserver_aidl", srcs: [ "android/app/IUidObserver.aidl", ], } filegroup { name: "activity_manager_runningappprocessinfo_aidl", srcs: [ Loading Loading @@ -765,3 +772,23 @@ java_system_features_srcs { full_class_name: "com.android.internal.pm.RoSystemFeatures", visibility: ["//visibility:private"], } aidl_interface { name: "activitymanager_structured_aidl", unstable: true, srcs: [ "android/app/IActivityManagerStructured.aidl", ":activity_manager_iprocessobserver_aidl", ":activity_manager_iuidobserver_aidl", ":activity_manager_runningappprocessinfo_aidl", ], backend: { java: { // java code is generated through framework-core-sources. enabled: false, }, rust: { enabled: true, }, }, } core/java/android/app/ActivityManager.java +23 −19 Original line number Diff line number Diff line Loading @@ -4137,25 +4137,7 @@ public class ActivityManager { public void writeToParcel(Parcel dest, int flags) { final android.app.RunningAppProcessInfo info = new android.app.RunningAppProcessInfo(); info.processName = TextUtils.emptyIfNull(processName); info.pid = pid; info.uid = uid; info.pkgList = pkgList; info.pkgDeps = pkgDeps; info.flags = this.flags; info.lastTrimLevel = lastTrimLevel; info.importance = importance; info.lru = lru; info.importanceReasonCode = importanceReasonCode; info.importanceReasonPid = importanceReasonPid; info.importanceReasonComponent = importanceReasonComponent != null ? importanceReasonComponent.flattenToString() : null; info.importanceReasonImportance = importanceReasonImportance; info.processState = processState; info.isFocused = isFocused; info.lastActivityTime = lastActivityTime; copyTo(info); info.writeToParcel(dest, flags); } Loading Loading @@ -4199,6 +4181,28 @@ public class ActivityManager { other.lastActivityTime = lastActivityTime; } /** @hide */ public void copyTo(android.app.RunningAppProcessInfo info) { info.processName = TextUtils.emptyIfNull(processName); info.pid = pid; info.uid = uid; info.pkgList = pkgList; info.pkgDeps = pkgDeps; info.flags = this.flags; info.lastTrimLevel = lastTrimLevel; info.importance = importance; info.lru = lru; info.importanceReasonCode = importanceReasonCode; info.importanceReasonPid = importanceReasonPid; info.importanceReasonComponent = importanceReasonComponent != null ? importanceReasonComponent.flattenToString() : null; info.importanceReasonImportance = importanceReasonImportance; info.processState = processState; info.isFocused = isFocused; info.lastActivityTime = lastActivityTime; } public static final @android.annotation.NonNull Creator<RunningAppProcessInfo> CREATOR = new Creator<RunningAppProcessInfo>() { public RunningAppProcessInfo createFromParcel(Parcel source) { Loading core/java/android/app/IActivityManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,8 @@ interface IActivityManager { // Since these transactions are also called from native code, these must be kept in sync with // the ones in frameworks/native/libs/binder/include_activitymanager/binder/ActivityManager.h // TODO(b/419409018): Remove this warning message after migrating all native API users to the // activity_structured service. // =============== Beginning of transactions used on native side as well ====================== ParcelFileDescriptor openContentUri(in String uriString); void registerUidObserver(in IUidObserver observer, int which, int cutpoint, Loading core/java/android/app/IActivityManagerStructured.aidl 0 → 100644 +95 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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 android.app; import android.app.IProcessObserver; import android.app.IUidObserver; import android.app.RunningAppProcessInfo; /** * Structured AIDL version of IActivityManager.aidl. * * At this moment this interface provides a minimum level of support for native processes. * TODO(b/419409018): Migrate the entire interface to the structured AIDL. * * {@hide} */ interface IActivityManagerStructured { ParcelFileDescriptor openContentUri(in String uriString); void registerUidObserver(in IUidObserver observer, int which, int cutpoint, String callingPackage); void unregisterUidObserver(in IUidObserver observer); /** * Registers a UidObserver with a uid filter. * * @param observer The UidObserver implementation to register. * @param which A bitmask of events to observe. See ActivityManager.UID_OBSERVER_*. * @param cutpoint The cutpoint for onUidStateChanged events. When the state crosses this * threshold in either direction, onUidStateChanged will be called. * @param callingPackage The name of the calling package. * @param uids A list of uids to watch. If all uids are to be watched, use * registerUidObserver instead. * @throws RemoteException * @return Returns A binder token identifying the UidObserver registration. */ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS)") IBinder registerUidObserverForUids(in IUidObserver observer, int which, int cutpoint, String callingPackage, in int[] uids); /** * Adds a uid to the list of uids that a UidObserver will receive updates about. * * @param observerToken The binder token identifying the UidObserver registration. * @param callingPackage The name of the calling package. * @param uid The uid to watch. * @throws RemoteException */ void addUidToObserver(in IBinder observerToken, String callingPackage, int uid); /** * Removes a uid from the list of uids that a UidObserver will receive updates about. * * @param observerToken The binder token identifying the UidObserver registration. * @param callingPackage The name of the calling package. * @param uid The uid to stop watching. * @throws RemoteException */ void removeUidFromObserver(in IBinder observerToken, String callingPackage, int uid); boolean isUidActive(int uid, String callingPackage); @JavaPassthrough(annotation= "@android.annotation.RequiresPermission(allOf = {android.Manifest.permission.PACKAGE_USAGE_STATS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}, conditional = true)") int getUidProcessState(int uid, in String callingPackage); int checkPermission(in String permission, int pid, int uid); /** Logs start of an API call to associate with an FGS, used for FGS Type Metrics */ oneway void logFgsApiBegin(int apiType, int appUid, int appPid); /** Logs stop of an API call to associate with an FGS, used for FGS Type Metrics */ oneway void logFgsApiEnd(int apiType, int appUid, int appPid); /** Logs API state change to associate with an FGS, used for FGS Type Metrics */ oneway void logFgsApiStateChanged(int apiType, int state, int appUid, int appPid); @UnsupportedAppUsage void registerProcessObserver(in IProcessObserver observer); @UnsupportedAppUsage void unregisterProcessObserver(in IProcessObserver observer); @UnsupportedAppUsage List<RunningAppProcessInfo> getRunningAppProcesses(); } services/core/java/com/android/server/am/ActivityManagerService.java +6 −0 Original line number Diff line number Diff line Loading @@ -1968,6 +1968,12 @@ public class ActivityManagerService extends IActivityManager.Stub ServiceManager.addService("permission", new PermissionController(this)); ServiceManager.addService("processinfo", new ProcessInfoService(this)); ServiceManager.addService("cacheinfo", new CacheBinder(this)); if (Flags.enableActivityManagerStructuredService()) { ServiceManager.addService( "activity_structured", new ActivityManagerStructured(this), /* allowIsolated= */ true); } ApplicationInfo info = mContext.getPackageManager().getApplicationInfo( "android", STOCK_PM_FLAGS | MATCH_SYSTEM_ONLY); Loading Loading
core/java/Android.bp +27 −0 Original line number Diff line number Diff line Loading @@ -464,6 +464,13 @@ filegroup { ], } filegroup { name: "activity_manager_iuidobserver_aidl", srcs: [ "android/app/IUidObserver.aidl", ], } filegroup { name: "activity_manager_runningappprocessinfo_aidl", srcs: [ Loading Loading @@ -765,3 +772,23 @@ java_system_features_srcs { full_class_name: "com.android.internal.pm.RoSystemFeatures", visibility: ["//visibility:private"], } aidl_interface { name: "activitymanager_structured_aidl", unstable: true, srcs: [ "android/app/IActivityManagerStructured.aidl", ":activity_manager_iprocessobserver_aidl", ":activity_manager_iuidobserver_aidl", ":activity_manager_runningappprocessinfo_aidl", ], backend: { java: { // java code is generated through framework-core-sources. enabled: false, }, rust: { enabled: true, }, }, }
core/java/android/app/ActivityManager.java +23 −19 Original line number Diff line number Diff line Loading @@ -4137,25 +4137,7 @@ public class ActivityManager { public void writeToParcel(Parcel dest, int flags) { final android.app.RunningAppProcessInfo info = new android.app.RunningAppProcessInfo(); info.processName = TextUtils.emptyIfNull(processName); info.pid = pid; info.uid = uid; info.pkgList = pkgList; info.pkgDeps = pkgDeps; info.flags = this.flags; info.lastTrimLevel = lastTrimLevel; info.importance = importance; info.lru = lru; info.importanceReasonCode = importanceReasonCode; info.importanceReasonPid = importanceReasonPid; info.importanceReasonComponent = importanceReasonComponent != null ? importanceReasonComponent.flattenToString() : null; info.importanceReasonImportance = importanceReasonImportance; info.processState = processState; info.isFocused = isFocused; info.lastActivityTime = lastActivityTime; copyTo(info); info.writeToParcel(dest, flags); } Loading Loading @@ -4199,6 +4181,28 @@ public class ActivityManager { other.lastActivityTime = lastActivityTime; } /** @hide */ public void copyTo(android.app.RunningAppProcessInfo info) { info.processName = TextUtils.emptyIfNull(processName); info.pid = pid; info.uid = uid; info.pkgList = pkgList; info.pkgDeps = pkgDeps; info.flags = this.flags; info.lastTrimLevel = lastTrimLevel; info.importance = importance; info.lru = lru; info.importanceReasonCode = importanceReasonCode; info.importanceReasonPid = importanceReasonPid; info.importanceReasonComponent = importanceReasonComponent != null ? importanceReasonComponent.flattenToString() : null; info.importanceReasonImportance = importanceReasonImportance; info.processState = processState; info.isFocused = isFocused; info.lastActivityTime = lastActivityTime; } public static final @android.annotation.NonNull Creator<RunningAppProcessInfo> CREATOR = new Creator<RunningAppProcessInfo>() { public RunningAppProcessInfo createFromParcel(Parcel source) { Loading
core/java/android/app/IActivityManager.aidl +2 −0 Original line number Diff line number Diff line Loading @@ -96,6 +96,8 @@ interface IActivityManager { // Since these transactions are also called from native code, these must be kept in sync with // the ones in frameworks/native/libs/binder/include_activitymanager/binder/ActivityManager.h // TODO(b/419409018): Remove this warning message after migrating all native API users to the // activity_structured service. // =============== Beginning of transactions used on native side as well ====================== ParcelFileDescriptor openContentUri(in String uriString); void registerUidObserver(in IUidObserver observer, int which, int cutpoint, Loading
core/java/android/app/IActivityManagerStructured.aidl 0 → 100644 +95 −0 Original line number Diff line number Diff line /* * Copyright (C) 2025 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 android.app; import android.app.IProcessObserver; import android.app.IUidObserver; import android.app.RunningAppProcessInfo; /** * Structured AIDL version of IActivityManager.aidl. * * At this moment this interface provides a minimum level of support for native processes. * TODO(b/419409018): Migrate the entire interface to the structured AIDL. * * {@hide} */ interface IActivityManagerStructured { ParcelFileDescriptor openContentUri(in String uriString); void registerUidObserver(in IUidObserver observer, int which, int cutpoint, String callingPackage); void unregisterUidObserver(in IUidObserver observer); /** * Registers a UidObserver with a uid filter. * * @param observer The UidObserver implementation to register. * @param which A bitmask of events to observe. See ActivityManager.UID_OBSERVER_*. * @param cutpoint The cutpoint for onUidStateChanged events. When the state crosses this * threshold in either direction, onUidStateChanged will be called. * @param callingPackage The name of the calling package. * @param uids A list of uids to watch. If all uids are to be watched, use * registerUidObserver instead. * @throws RemoteException * @return Returns A binder token identifying the UidObserver registration. */ @JavaPassthrough(annotation="@android.annotation.RequiresPermission(android.Manifest.permission.PACKAGE_USAGE_STATS)") IBinder registerUidObserverForUids(in IUidObserver observer, int which, int cutpoint, String callingPackage, in int[] uids); /** * Adds a uid to the list of uids that a UidObserver will receive updates about. * * @param observerToken The binder token identifying the UidObserver registration. * @param callingPackage The name of the calling package. * @param uid The uid to watch. * @throws RemoteException */ void addUidToObserver(in IBinder observerToken, String callingPackage, int uid); /** * Removes a uid from the list of uids that a UidObserver will receive updates about. * * @param observerToken The binder token identifying the UidObserver registration. * @param callingPackage The name of the calling package. * @param uid The uid to stop watching. * @throws RemoteException */ void removeUidFromObserver(in IBinder observerToken, String callingPackage, int uid); boolean isUidActive(int uid, String callingPackage); @JavaPassthrough(annotation= "@android.annotation.RequiresPermission(allOf = {android.Manifest.permission.PACKAGE_USAGE_STATS, android.Manifest.permission.INTERACT_ACROSS_USERS_FULL}, conditional = true)") int getUidProcessState(int uid, in String callingPackage); int checkPermission(in String permission, int pid, int uid); /** Logs start of an API call to associate with an FGS, used for FGS Type Metrics */ oneway void logFgsApiBegin(int apiType, int appUid, int appPid); /** Logs stop of an API call to associate with an FGS, used for FGS Type Metrics */ oneway void logFgsApiEnd(int apiType, int appUid, int appPid); /** Logs API state change to associate with an FGS, used for FGS Type Metrics */ oneway void logFgsApiStateChanged(int apiType, int state, int appUid, int appPid); @UnsupportedAppUsage void registerProcessObserver(in IProcessObserver observer); @UnsupportedAppUsage void unregisterProcessObserver(in IProcessObserver observer); @UnsupportedAppUsage List<RunningAppProcessInfo> getRunningAppProcesses(); }
services/core/java/com/android/server/am/ActivityManagerService.java +6 −0 Original line number Diff line number Diff line Loading @@ -1968,6 +1968,12 @@ public class ActivityManagerService extends IActivityManager.Stub ServiceManager.addService("permission", new PermissionController(this)); ServiceManager.addService("processinfo", new ProcessInfoService(this)); ServiceManager.addService("cacheinfo", new CacheBinder(this)); if (Flags.enableActivityManagerStructuredService()) { ServiceManager.addService( "activity_structured", new ActivityManagerStructured(this), /* allowIsolated= */ true); } ApplicationInfo info = mContext.getPackageManager().getApplicationInfo( "android", STOCK_PM_FLAGS | MATCH_SYSTEM_ONLY); Loading