Merge "Adding a way to communicate user space for AppOp changes." into udc-dev am: a08ca18043

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22934036

Change-Id: I28cc1214b317e6ba011ee4d5422f775d09b5e78e
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Himanshu Gupta
2023-05-10 11:08:18 +00:00
committed by Automerger Merge Worker

View File

@@ -7089,6 +7089,26 @@ public class AppOpsManager {
*/
public interface OnOpChangedListener {
public void onOpChanged(String op, String packageName);
/**
* Implementations can override this method to add handling logic for AppOp changes.
*
* Normally, listeners to AppOp changes work in the same User Space as the App whose Op
* has changed. However, in some case listeners can have a single instance responsible for
* multiple users. (For ex single Media Provider instance in user 0 is responsible for both
* cloned and user 0 spaces). For handling such cases correctly, listeners need to be
* passed userId in addition to PackageName and Op.
* The default impl is to fallback onto {@link #onOpChanged(String, String)
*
* @param op The Op that changed.
* @param packageName Package of the app whose Op changed.
* @param userId User Space of the app whose Op changed.
* @hide
*/
default void onOpChanged(@NonNull String op, @NonNull String packageName, int userId) {
onOpChanged(op, packageName);
}
}
/**
@@ -7785,7 +7805,9 @@ public class AppOpsManager {
((OnOpChangedInternalListener)callback).onOpChanged(op, packageName);
}
if (sAppOpInfos[op].name != null) {
callback.onOpChanged(sAppOpInfos[op].name, packageName);
callback.onOpChanged(sAppOpInfos[op].name, packageName,
UserHandle.getUserId(uid));
}
}
};