blob: be3558eef86bfcb43497c402854386230a389f04 [file] [log] [blame]
Ricky Waic76a11f2022-01-25 23:04:26 +00001/*
2 * Copyright (C) 2018 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.settings;
18
19import android.app.Activity;
20import android.app.AppOpsManager;
21import android.content.DialogInterface;
22import android.content.Intent;
23import android.os.Bundle;
Ricky Waic76a11f2022-01-25 23:04:26 +000024
25public class ActionDisabledByAppOpsDialog extends Activity
26 implements DialogInterface.OnDismissListener {
27
28 private static final String TAG = "ActionDisabledByAppOpsDialog";
29
30 private ActionDisabledByAppOpsHelper mDialogHelper;
31
32 @Override
33 protected void onCreate(Bundle savedInstanceState) {
34 super.onCreate(savedInstanceState);
35 mDialogHelper = new ActionDisabledByAppOpsHelper(this);
36 mDialogHelper.prepareDialogBuilder()
37 .setOnDismissListener(this)
38 .show();
39 updateAppOps();
40 }
41
42 private void updateAppOps() {
43 final Intent intent = getIntent();
44 final String packageName = intent.getStringExtra(Intent.EXTRA_PACKAGE_NAME);
45 final int uid = intent.getIntExtra(Intent.EXTRA_UID, android.os.Process.INVALID_UID);
46 getSystemService(AppOpsManager.class)
47 .setMode(AppOpsManager.OP_ACCESS_RESTRICTED_SETTINGS,
48 uid,
49 packageName,
50 AppOpsManager.MODE_IGNORED);
51 }
52
53 @Override
54 public void onNewIntent(Intent intent) {
55 super.onNewIntent(intent);
56 mDialogHelper.updateDialog();
57 updateAppOps();
58 }
59
60 @Override
61 public void onDismiss(DialogInterface dialog) {
62 finish();
63 }
64}