blob: f96b06fa798eeb4c12cea3082eed4365f3b9b8fa [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001/*
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
17package com.android.server.am;
18
19import android.content.IntentFilter;
20import android.util.PrintWriterPrinter;
Dianne Hackborn1d442e02009-04-20 18:14:05 -070021import android.util.Printer;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080022
23import java.io.PrintWriter;
24
Dianne Hackbornbe4e6aa2013-06-07 13:25:29 -070025final class BroadcastFilter extends IntentFilter {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080026 // Back-pointer to the list this filter is in.
27 final ReceiverList receiverList;
Dianne Hackborn6c418d52011-06-29 14:05:33 -070028 final String packageName;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080029 final String requiredPermission;
Dianne Hackbornb4163a62012-08-02 18:31:26 -070030 final int owningUid;
Dianne Hackborn5ac72a22012-08-29 18:32:08 -070031 final int owningUserId;
Chad Brubakerb7e34d52017-02-22 12:36:06 -080032 final boolean instantApp;
Chad Brubaker816c83b2017-03-02 10:27:59 -080033 final boolean visibleToInstantApp;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080034
35 BroadcastFilter(IntentFilter _filter, ReceiverList _receiverList,
Chad Brubakerb7e34d52017-02-22 12:36:06 -080036 String _packageName, String _requiredPermission, int _owningUid, int _userId,
Chad Brubaker816c83b2017-03-02 10:27:59 -080037 boolean _instantApp, boolean _visibleToInstantApp) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038 super(_filter);
39 receiverList = _receiverList;
Dianne Hackborn6c418d52011-06-29 14:05:33 -070040 packageName = _packageName;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041 requiredPermission = _requiredPermission;
Dianne Hackbornb4163a62012-08-02 18:31:26 -070042 owningUid = _owningUid;
Dianne Hackborn20e80982012-08-31 19:00:44 -070043 owningUserId = _userId;
Chad Brubakerb7e34d52017-02-22 12:36:06 -080044 instantApp = _instantApp;
Chad Brubaker816c83b2017-03-02 10:27:59 -080045 visibleToInstantApp = _visibleToInstantApp;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080046 }
47
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080048 public void dump(PrintWriter pw, String prefix) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -070049 dumpInReceiverList(pw, new PrintWriterPrinter(pw), prefix);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080050 receiverList.dumpLocal(pw, prefix);
51 }
52
Dianne Hackborn12527f92009-11-11 17:39:50 -080053 public void dumpBrief(PrintWriter pw, String prefix) {
54 dumpBroadcastFilterState(pw, prefix);
55 }
56
Dianne Hackborn1d442e02009-04-20 18:14:05 -070057 public void dumpInReceiverList(PrintWriter pw, Printer pr, String prefix) {
58 super.dump(pr, prefix);
Dianne Hackborn12527f92009-11-11 17:39:50 -080059 dumpBroadcastFilterState(pw, prefix);
60 }
61
62 void dumpBroadcastFilterState(PrintWriter pw, String prefix) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -070063 if (requiredPermission != null) {
64 pw.print(prefix); pw.print("requiredPermission="); pw.println(requiredPermission);
65 }
66 }
67
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080068 public String toString() {
Dianne Hackborn1d442e02009-04-20 18:14:05 -070069 StringBuilder sb = new StringBuilder();
70 sb.append("BroadcastFilter{");
71 sb.append(Integer.toHexString(System.identityHashCode(this)));
Dianne Hackbornb12e1352012-09-26 11:39:20 -070072 sb.append(" u");
73 sb.append(owningUserId);
Dianne Hackborn1d442e02009-04-20 18:14:05 -070074 sb.append(' ');
75 sb.append(receiverList);
76 sb.append('}');
77 return sb.toString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080078 }
79}