summaryrefslogtreecommitdiffstats
path: root/services/core/java/com/android/server/PermissionDialogReqQueue.java
diff options
context:
space:
mode:
authorShashank Mittal <mittals@codeaurora.org>2014-07-16 12:54:26 -0700
committerRoman Birg <roman@cyngn.com>2015-10-29 11:01:54 -0700
commit646827a4e92ba9d2f32624b9ed80867904f5e6ae (patch)
treead4a8fda0b6f6393e7061563f1e2cf67312b243d /services/core/java/com/android/server/PermissionDialogReqQueue.java
parent20982c69bb11eaa5f754b3769e2ad841c7f513c1 (diff)
downloadframeworks_base-646827a4e92ba9d2f32624b9ed80867904f5e6ae.zip
frameworks_base-646827a4e92ba9d2f32624b9ed80867904f5e6ae.tar.gz
frameworks_base-646827a4e92ba9d2f32624b9ed80867904f5e6ae.tar.bz2
AppOpsService: Add MODE_ASK support to AppOps.
Add support for new mode(MODE_ASK) in AppOpsService to show a permission dialog box to user to confirm user permission before allowing or ignoring that operation. All strict operations (defined in AppOpsManager) are going to be in MODE_ASK by default. Operations will be moved to MODE_ALLOWED or MODE_IGNORED according to user's choice. Change-Id: I1314125a2b8be558e422e4a9eea0ff066c21bf94
Diffstat (limited to 'services/core/java/com/android/server/PermissionDialogReqQueue.java')
-rw-r--r--services/core/java/com/android/server/PermissionDialogReqQueue.java82
1 files changed, 82 insertions, 0 deletions
diff --git a/services/core/java/com/android/server/PermissionDialogReqQueue.java b/services/core/java/com/android/server/PermissionDialogReqQueue.java
new file mode 100644
index 0000000..ee94427
--- /dev/null
+++ b/services/core/java/com/android/server/PermissionDialogReqQueue.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright (c) 2013, The Linux Foundation. All rights reserved.
+ * Not a Contribution.
+ *
+ * Copyright (C) 2006 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.server;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class PermissionDialogReqQueue {
+ public PermissionDialog getDialog() {
+ return mDialog;
+ }
+
+ public void setDialog(PermissionDialog mDialog) {
+ this.mDialog = mDialog;
+ }
+
+ public final static class PermissionDialogReq {
+ public void set(int res) {
+ synchronized (this) {
+ mHasResult = true;
+ mResult = res;
+ notifyAll();
+ }
+ }
+
+ public int get() {
+ synchronized (this) {
+ while (!mHasResult) {
+ try {
+ wait();
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+ return mResult;
+ }
+
+ boolean mHasResult = false;
+ int mResult;
+ }
+
+ private PermissionDialog mDialog;
+ private List<PermissionDialogReq> resultList;
+
+ public PermissionDialogReqQueue() {
+ mDialog = null;
+ resultList = new ArrayList<PermissionDialogReq>();
+ }
+
+ public void register(PermissionDialogReq res) {
+ synchronized (this) {
+ resultList.add(res);
+ }
+ }
+
+ public void notifyAll(int mode) {
+ synchronized (this) {
+ while (resultList.size() != 0) {
+ PermissionDialogReq res = resultList.get(0);
+ res.set(mode);
+ resultList.remove(0);
+ }
+ }
+ }
+}