Loading services/core/java/com/android/server/input/InputManagerService.java +13 −0 Original line number Diff line number Diff line Loading @@ -2604,6 +2604,19 @@ public class InputManagerService extends IInputManager.Stub mBatteryController.notifyStylusGestureStarted(deviceId, eventTime); } // Native callback. @SuppressWarnings("unused") private int getPackageUid(String pkg) { if (TextUtils.isEmpty(pkg)) { return Process.INVALID_UID; } try { return mContext.getPackageManager().getPackageUid(pkg, 0 /*flags*/); } catch (PackageManager.NameNotFoundException e) { return Process.INVALID_UID; } } /** * Flatten a map into a string list, with value positioned directly next to the * key. Loading services/core/jni/com_android_server_input_InputManagerService.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -143,6 +143,7 @@ static struct { jmethodID getTouchCalibrationForInputDevice; jmethodID notifyDropWindow; jmethodID getParentSurfaceForPointers; jmethodID getPackageUid; } gServiceClassInfo; static struct { Loading Loading @@ -362,6 +363,7 @@ public: void notifyDropWindow(const sp<IBinder>& token, float x, float y) override; void notifyDeviceInteraction(int32_t deviceId, nsecs_t timestamp, const std::set<gui::Uid>& uids) override; gui::Uid getPackageUid(std::string package) override; /* --- PointerControllerPolicyInterface implementation --- */ Loading Loading @@ -1116,6 +1118,21 @@ void NativeInputManager::notifyDeviceInteraction(int32_t deviceId, nsecs_t times mInputManager->getMetricsCollector().notifyDeviceInteraction(deviceId, timestamp, uids); } gui::Uid NativeInputManager::getPackageUid(std::string package) { ATRACE_CALL(); JNIEnv* env = jniEnv(); ScopedLocalFrame localFrame(env); ScopedLocalRef<jstring> javaPackage(env, env->NewStringUTF(package.c_str())); const jint uid = env->CallIntMethod(mServiceObj, gServiceClassInfo.getPackageUid, javaPackage.get()); if (checkAndClearExceptionFromCallback(env, "getPackageUid")) { LOG(FATAL) << __func__ << ": Failed to get UID for package: " << package; } return gui::Uid{static_cast<uint32_t>(uid)}; } void NativeInputManager::notifySensorEvent(int32_t deviceId, InputDeviceSensorType sensorType, InputDeviceSensorAccuracy accuracy, nsecs_t timestamp, const std::vector<float>& values) { Loading Loading @@ -3101,6 +3118,8 @@ int register_android_server_InputManager(JNIEnv* env) { GET_METHOD_ID(gServiceClassInfo.getParentSurfaceForPointers, clazz, "getParentSurfaceForPointers", "(I)J"); GET_METHOD_ID(gServiceClassInfo.getPackageUid, clazz, "getPackageUid", "(Ljava/lang/String;)I"); // InputDevice FIND_CLASS(gInputDeviceClassInfo.clazz, "android/view/InputDevice"); Loading Loading
services/core/java/com/android/server/input/InputManagerService.java +13 −0 Original line number Diff line number Diff line Loading @@ -2604,6 +2604,19 @@ public class InputManagerService extends IInputManager.Stub mBatteryController.notifyStylusGestureStarted(deviceId, eventTime); } // Native callback. @SuppressWarnings("unused") private int getPackageUid(String pkg) { if (TextUtils.isEmpty(pkg)) { return Process.INVALID_UID; } try { return mContext.getPackageManager().getPackageUid(pkg, 0 /*flags*/); } catch (PackageManager.NameNotFoundException e) { return Process.INVALID_UID; } } /** * Flatten a map into a string list, with value positioned directly next to the * key. Loading
services/core/jni/com_android_server_input_InputManagerService.cpp +19 −0 Original line number Diff line number Diff line Loading @@ -143,6 +143,7 @@ static struct { jmethodID getTouchCalibrationForInputDevice; jmethodID notifyDropWindow; jmethodID getParentSurfaceForPointers; jmethodID getPackageUid; } gServiceClassInfo; static struct { Loading Loading @@ -362,6 +363,7 @@ public: void notifyDropWindow(const sp<IBinder>& token, float x, float y) override; void notifyDeviceInteraction(int32_t deviceId, nsecs_t timestamp, const std::set<gui::Uid>& uids) override; gui::Uid getPackageUid(std::string package) override; /* --- PointerControllerPolicyInterface implementation --- */ Loading Loading @@ -1116,6 +1118,21 @@ void NativeInputManager::notifyDeviceInteraction(int32_t deviceId, nsecs_t times mInputManager->getMetricsCollector().notifyDeviceInteraction(deviceId, timestamp, uids); } gui::Uid NativeInputManager::getPackageUid(std::string package) { ATRACE_CALL(); JNIEnv* env = jniEnv(); ScopedLocalFrame localFrame(env); ScopedLocalRef<jstring> javaPackage(env, env->NewStringUTF(package.c_str())); const jint uid = env->CallIntMethod(mServiceObj, gServiceClassInfo.getPackageUid, javaPackage.get()); if (checkAndClearExceptionFromCallback(env, "getPackageUid")) { LOG(FATAL) << __func__ << ": Failed to get UID for package: " << package; } return gui::Uid{static_cast<uint32_t>(uid)}; } void NativeInputManager::notifySensorEvent(int32_t deviceId, InputDeviceSensorType sensorType, InputDeviceSensorAccuracy accuracy, nsecs_t timestamp, const std::vector<float>& values) { Loading Loading @@ -3101,6 +3118,8 @@ int register_android_server_InputManager(JNIEnv* env) { GET_METHOD_ID(gServiceClassInfo.getParentSurfaceForPointers, clazz, "getParentSurfaceForPointers", "(I)J"); GET_METHOD_ID(gServiceClassInfo.getPackageUid, clazz, "getPackageUid", "(Ljava/lang/String;)I"); // InputDevice FIND_CLASS(gInputDeviceClassInfo.clazz, "android/view/InputDevice"); Loading