blob: c631b6e0f9d993df0c30cc43d52a288f48745899 [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
25class BroadcastFilter extends IntentFilter {
26 // 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;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080032
33 BroadcastFilter(IntentFilter _filter, ReceiverList _receiverList,
Dianne Hackborn20e80982012-08-31 19:00:44 -070034 String _packageName, String _requiredPermission, int _owningUid, int _userId) {
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080035 super(_filter);
36 receiverList = _receiverList;
Dianne Hackborn6c418d52011-06-29 14:05:33 -070037 packageName = _packageName;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080038 requiredPermission = _requiredPermission;
Dianne Hackbornb4163a62012-08-02 18:31:26 -070039 owningUid = _owningUid;
Dianne Hackborn20e80982012-08-31 19:00:44 -070040 owningUserId = _userId;
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080041 }
42
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080043 public void dump(PrintWriter pw, String prefix) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -070044 dumpInReceiverList(pw, new PrintWriterPrinter(pw), prefix);
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080045 receiverList.dumpLocal(pw, prefix);
46 }
47
Dianne Hackborn12527f92009-11-11 17:39:50 -080048 public void dumpBrief(PrintWriter pw, String prefix) {
49 dumpBroadcastFilterState(pw, prefix);
50 }
51
Dianne Hackborn1d442e02009-04-20 18:14:05 -070052 public void dumpInReceiverList(PrintWriter pw, Printer pr, String prefix) {
53 super.dump(pr, prefix);
Dianne Hackborn12527f92009-11-11 17:39:50 -080054 dumpBroadcastFilterState(pw, prefix);
55 }
56
57 void dumpBroadcastFilterState(PrintWriter pw, String prefix) {
Dianne Hackborn1d442e02009-04-20 18:14:05 -070058 if (requiredPermission != null) {
59 pw.print(prefix); pw.print("requiredPermission="); pw.println(requiredPermission);
60 }
61 }
62
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080063 public String toString() {
Dianne Hackborn1d442e02009-04-20 18:14:05 -070064 StringBuilder sb = new StringBuilder();
65 sb.append("BroadcastFilter{");
66 sb.append(Integer.toHexString(System.identityHashCode(this)));
Dianne Hackbornb12e1352012-09-26 11:39:20 -070067 sb.append(" u");
68 sb.append(owningUserId);
Dianne Hackborn1d442e02009-04-20 18:14:05 -070069 sb.append(' ');
70 sb.append(receiverList);
71 sb.append('}');
72 return sb.toString();
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080073 }
74}