blob: 5f60801aa3830b61e52993f17364929b9982943a [file] [log] [blame]
Mark Salyzyndfa7a072014-02-11 12:29:31 -08001/*
2 * Copyright (C) 2014 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
17#ifndef _LOGD_LOG_WHITE_BLACK_LIST_H__
18#define _LOGD_LOG_WHITE_BLACK_LIST_H__
19
20#include <sys/types.h>
21
22#include <utils/List.h>
23
24#include <LogBufferElement.h>
25
26// White and Blacklist
27
28class Prune {
29 friend class PruneList;
30
31 const uid_t mUid;
32 const pid_t mPid;
33 int cmp(uid_t uid, pid_t pid) const;
34
35public:
36 static const uid_t uid_all = (uid_t) -1;
37 static const pid_t pid_all = (pid_t) -1;
38
39 Prune(uid_t uid, pid_t pid);
40
41 uid_t getUid() const { return mUid; }
42 pid_t getPid() const { return mPid; }
43
44 int cmp(LogBufferElement *e) const { return cmp(e->getUid(), e->getPid()); }
45
46 // *strp is malloc'd, use free to release
47 void format(char **strp);
48};
49
50typedef android::List<Prune *> PruneCollection;
51
52class PruneList {
53 PruneCollection mNaughty;
54 PruneCollection mNice;
55 bool mWorstUidEnabled;
56
57public:
58 PruneList();
59 ~PruneList();
60
61 int init(char *str);
62
63 bool naughty(LogBufferElement *element);
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -070064 bool naughty(void) { return !mNaughty.empty(); }
Mark Salyzyndfa7a072014-02-11 12:29:31 -080065 bool nice(LogBufferElement *element);
Mark Salyzyn97c1c2b2015-03-10 13:51:35 -070066 bool nice(void) { return !mNice.empty(); }
Mark Salyzyndfa7a072014-02-11 12:29:31 -080067 bool worstUidEnabled() const { return mWorstUidEnabled; }
68
69 // *strp is malloc'd, use free to release
70 void format(char **strp);
71};
72
73#endif // _LOGD_LOG_WHITE_BLACK_LIST_H__