/services/java/com/android/server/am/BroadcastFilter.java

https://github.com/aizuzi/platform_frameworks_base · Java · 74 lines · 48 code · 10 blank · 16 comment · 2 complexity · 9b41ebf310176213045aea76c07cc3db MD5 · raw file

  1. /*
  2. * Copyright (C) 2006 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.android.server.am;
  17. import android.content.IntentFilter;
  18. import android.util.PrintWriterPrinter;
  19. import android.util.Printer;
  20. import java.io.PrintWriter;
  21. final class BroadcastFilter extends IntentFilter {
  22. // Back-pointer to the list this filter is in.
  23. final ReceiverList receiverList;
  24. final String packageName;
  25. final String requiredPermission;
  26. final int owningUid;
  27. final int owningUserId;
  28. BroadcastFilter(IntentFilter _filter, ReceiverList _receiverList,
  29. String _packageName, String _requiredPermission, int _owningUid, int _userId) {
  30. super(_filter);
  31. receiverList = _receiverList;
  32. packageName = _packageName;
  33. requiredPermission = _requiredPermission;
  34. owningUid = _owningUid;
  35. owningUserId = _userId;
  36. }
  37. public void dump(PrintWriter pw, String prefix) {
  38. dumpInReceiverList(pw, new PrintWriterPrinter(pw), prefix);
  39. receiverList.dumpLocal(pw, prefix);
  40. }
  41. public void dumpBrief(PrintWriter pw, String prefix) {
  42. dumpBroadcastFilterState(pw, prefix);
  43. }
  44. public void dumpInReceiverList(PrintWriter pw, Printer pr, String prefix) {
  45. super.dump(pr, prefix);
  46. dumpBroadcastFilterState(pw, prefix);
  47. }
  48. void dumpBroadcastFilterState(PrintWriter pw, String prefix) {
  49. if (requiredPermission != null) {
  50. pw.print(prefix); pw.print("requiredPermission="); pw.println(requiredPermission);
  51. }
  52. }
  53. public String toString() {
  54. StringBuilder sb = new StringBuilder();
  55. sb.append("BroadcastFilter{");
  56. sb.append(Integer.toHexString(System.identityHashCode(this)));
  57. sb.append(" u");
  58. sb.append(owningUserId);
  59. sb.append(' ');
  60. sb.append(receiverList);
  61. sb.append('}');
  62. return sb.toString();
  63. }
  64. }