Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
1 /*
2 * Copyright (C) 2012 Mozilla Foundation
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 #ifndef GONKPERMISSION_H
17 #define GONKPERMISSION_H
19 #include <binder/BinderService.h>
20 #include "nsString.h"
21 #include "nsTArray.h"
23 namespace mozilla {
24 class PermissionGrant
25 {
26 public:
27 PermissionGrant(const char* perm, int32_t p) : mPid(p)
28 {
29 mPermission.Assign(perm);
30 }
32 PermissionGrant(const nsACString& permission, int32_t pid) : mPid(pid),
33 mPermission(permission)
34 {
35 }
37 bool operator==(const PermissionGrant& other) const
38 {
39 return (mPid == other.pid() && mPermission.Equals(other.permission()));
40 }
42 int32_t pid() const
43 {
44 return mPid;
45 }
47 const nsACString& permission() const
48 {
49 return mPermission;
50 }
52 private:
53 int32_t mPid;
54 nsCString mPermission;
55 };
57 class PermissionGrant;
59 class GonkPermissionService :
60 public android::BinderService<GonkPermissionService>,
61 public android::BnPermissionController
62 {
63 public:
64 virtual ~GonkPermissionService() {}
65 static GonkPermissionService* GetInstance();
66 static const char *getServiceName() {
67 return "permission";
68 }
70 static void instantiate();
72 virtual android::status_t dump(int fd, const android::Vector<android::String16>& args) {
73 return android::NO_ERROR;
74 }
75 virtual bool checkPermission(const android::String16& permission, int32_t pid,
76 int32_t uid);
78 void addGrantInfo(const char* permission, int32_t pid);
79 private:
80 GonkPermissionService(): android::BnPermissionController() {}
81 nsTArray<PermissionGrant> mGrantArray;
82 };
83 } // namespace mozilla
84 #endif // GONKPERMISSION_H