Loading services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java +32 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ import android.provider.Settings; import android.service.contentcapture.ActivityEvent.ActivityEventType; import android.service.contentcapture.IDataShareCallback; import android.service.contentcapture.IDataShareReadAdapter; import android.service.voice.VoiceInteractionManagerInternal; import android.util.ArraySet; import android.util.LocalLog; import android.util.Pair; Loading Loading @@ -302,6 +303,37 @@ public final class ContentCaptureManagerService extends || super.isDisabledLocked(userId); } @Override protected void assertCalledByPackageOwner(@NonNull String packageName) { try { super.assertCalledByPackageOwner(packageName); } catch (SecurityException e) { final int callingUid = Binder.getCallingUid(); VoiceInteractionManagerInternal.HotwordDetectionServiceIdentity hotwordDetectionServiceIdentity = LocalServices.getService(VoiceInteractionManagerInternal.class) .getHotwordDetectionServiceIdentity(); if (callingUid != hotwordDetectionServiceIdentity.getIsolatedUid()) { super.assertCalledByPackageOwner(packageName); return; } final String[] packages = getContext() .getPackageManager() .getPackagesForUid(hotwordDetectionServiceIdentity.getOwnerUid()); if (packages != null) { for (String candidate : packages) { if (packageName.equals(candidate)) return; // Found it } } throw e; } } private boolean isDisabledBySettingsLocked(@UserIdInt int userId) { return mDisabledBySettings != null && mDisabledBySettings.get(userId); } Loading services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java +19 −5 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ import android.service.contentcapture.FlushMetrics; import android.service.contentcapture.IContentCaptureServiceCallback; import android.service.contentcapture.IDataShareCallback; import android.service.contentcapture.SnapshotData; import android.service.voice.VoiceInteractionManagerInternal; import android.util.ArrayMap; import android.util.ArraySet; import android.util.Slog; Loading Loading @@ -415,6 +416,18 @@ final class ContentCapturePerUserService } if (callingUid != packageUid && !LocalServices.getService(ActivityManagerInternal.class) .hasRunningActivity(callingUid, packageName)) { VoiceInteractionManagerInternal.HotwordDetectionServiceIdentity hotwordDetectionServiceIdentity = LocalServices.getService(VoiceInteractionManagerInternal.class) .getHotwordDetectionServiceIdentity(); boolean isHotwordDetectionServiceCall = hotwordDetectionServiceIdentity != null && callingUid == hotwordDetectionServiceIdentity.getIsolatedUid() && packageUid == hotwordDetectionServiceIdentity.getOwnerUid(); if (!isHotwordDetectionServiceCall) { final String[] packages = pm.getPackagesForUid(callingUid); final String callingPackage = packages != null ? packages[0] : "uid-" + callingUid; Slog.w(TAG, "App (package=" + callingPackage + ", UID=" + callingUid Loading @@ -423,6 +436,7 @@ final class ContentCapturePerUserService throw new SecurityException("Invalid package: " + packageName); } } } @GuardedBy("mLock") public boolean sendActivityAssistDataLocked(@NonNull IBinder activityToken, Loading services/core/java/com/android/server/infra/AbstractMasterSystemService.java +1 −1 Original line number Diff line number Diff line Loading @@ -744,7 +744,7 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem * * @throws SecurityException when it's not... */ protected final void assertCalledByPackageOwner(@NonNull String packageName) { protected void assertCalledByPackageOwner(@NonNull String packageName) { Objects.requireNonNull(packageName); final int uid = Binder.getCallingUid(); final String[] packages = getContext().getPackageManager().getPackagesForUid(uid); Loading Loading
services/contentcapture/java/com/android/server/contentcapture/ContentCaptureManagerService.java +32 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,7 @@ import android.provider.Settings; import android.service.contentcapture.ActivityEvent.ActivityEventType; import android.service.contentcapture.IDataShareCallback; import android.service.contentcapture.IDataShareReadAdapter; import android.service.voice.VoiceInteractionManagerInternal; import android.util.ArraySet; import android.util.LocalLog; import android.util.Pair; Loading Loading @@ -302,6 +303,37 @@ public final class ContentCaptureManagerService extends || super.isDisabledLocked(userId); } @Override protected void assertCalledByPackageOwner(@NonNull String packageName) { try { super.assertCalledByPackageOwner(packageName); } catch (SecurityException e) { final int callingUid = Binder.getCallingUid(); VoiceInteractionManagerInternal.HotwordDetectionServiceIdentity hotwordDetectionServiceIdentity = LocalServices.getService(VoiceInteractionManagerInternal.class) .getHotwordDetectionServiceIdentity(); if (callingUid != hotwordDetectionServiceIdentity.getIsolatedUid()) { super.assertCalledByPackageOwner(packageName); return; } final String[] packages = getContext() .getPackageManager() .getPackagesForUid(hotwordDetectionServiceIdentity.getOwnerUid()); if (packages != null) { for (String candidate : packages) { if (packageName.equals(candidate)) return; // Found it } } throw e; } } private boolean isDisabledBySettingsLocked(@UserIdInt int userId) { return mDisabledBySettings != null && mDisabledBySettings.get(userId); } Loading
services/contentcapture/java/com/android/server/contentcapture/ContentCapturePerUserService.java +19 −5 Original line number Diff line number Diff line Loading @@ -57,6 +57,7 @@ import android.service.contentcapture.FlushMetrics; import android.service.contentcapture.IContentCaptureServiceCallback; import android.service.contentcapture.IDataShareCallback; import android.service.contentcapture.SnapshotData; import android.service.voice.VoiceInteractionManagerInternal; import android.util.ArrayMap; import android.util.ArraySet; import android.util.Slog; Loading Loading @@ -415,6 +416,18 @@ final class ContentCapturePerUserService } if (callingUid != packageUid && !LocalServices.getService(ActivityManagerInternal.class) .hasRunningActivity(callingUid, packageName)) { VoiceInteractionManagerInternal.HotwordDetectionServiceIdentity hotwordDetectionServiceIdentity = LocalServices.getService(VoiceInteractionManagerInternal.class) .getHotwordDetectionServiceIdentity(); boolean isHotwordDetectionServiceCall = hotwordDetectionServiceIdentity != null && callingUid == hotwordDetectionServiceIdentity.getIsolatedUid() && packageUid == hotwordDetectionServiceIdentity.getOwnerUid(); if (!isHotwordDetectionServiceCall) { final String[] packages = pm.getPackagesForUid(callingUid); final String callingPackage = packages != null ? packages[0] : "uid-" + callingUid; Slog.w(TAG, "App (package=" + callingPackage + ", UID=" + callingUid Loading @@ -423,6 +436,7 @@ final class ContentCapturePerUserService throw new SecurityException("Invalid package: " + packageName); } } } @GuardedBy("mLock") public boolean sendActivityAssistDataLocked(@NonNull IBinder activityToken, Loading
services/core/java/com/android/server/infra/AbstractMasterSystemService.java +1 −1 Original line number Diff line number Diff line Loading @@ -744,7 +744,7 @@ public abstract class AbstractMasterSystemService<M extends AbstractMasterSystem * * @throws SecurityException when it's not... */ protected final void assertCalledByPackageOwner(@NonNull String packageName) { protected void assertCalledByPackageOwner(@NonNull String packageName) { Objects.requireNonNull(packageName); final int uid = Binder.getCallingUid(); final String[] packages = getContext().getPackageManager().getPackagesForUid(uid); Loading