Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7ae217d0 authored by Shashank Mittal's avatar Shashank Mittal Committed by Steve Kondik
Browse files

AppOps: Prompt to remember user choice in ASK mode

 * Add "remember" option in dialog.

CRs-Fixed: 623369

Change-Id: Ie3b249d3b70709a624ab9c7317f02de44b532de6
parent 93e571c5
Loading
Loading
Loading
Loading
+69 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
** Copyright (c) 2013, The Linux Foundation. All rights reserved.
** Not a Contribution.
**
** Copyright 2012 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.
*/
-->

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/parentPanel"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginLeft="8dip"
    android:layout_marginRight="8dip"
    android:orientation="vertical">

    <TextView android:id="@+id/permission_text"
        style="?android:attr/textAppearanceMedium"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:paddingLeft="20dip"
        android:paddingRight="20dip"
        android:paddingTop="16dip"
        android:paddingBottom="16dip" />

    <TableLayout android:id="@+id/permission_remember_layout"
        android:shrinkColumns="1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:paddingLeft="16dip"
        android:paddingRight="16dip">

        <TableRow
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" >
            <RelativeLayout android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingTop="12dip"
                android:paddingLeft="8dip" >
            <CheckBox android:id="@+id/permission_remember_choice_checkbox"
                android:paddingTop="11dip"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" />
            </RelativeLayout>
            <TextView android:id="@+id/permission_remember_choice_text"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:paddingTop="18dip"
                android:text="@string/permission_remember_choice" />
        </TableRow>

    </TableLayout>

</LinearLayout>
+2 −0
Original line number Diff line number Diff line
@@ -168,4 +168,6 @@

    <string name="privacy_guard_dialog_title">Privacy Guard</string>
    <string name="privacy_guard_dialog_summary"><xliff:g id="app">%1$s</xliff:g> would like to <xliff:g id="op">%2$s</xliff:g>.</string>

    <string name="permission_remember_choice">Remember my choice</string>
</resources>
+5 −0
Original line number Diff line number Diff line
@@ -224,6 +224,10 @@
  <java-symbol type="id" name="pin_confirm_text" />
  <java-symbol type="id" name="pin_error_message" />
  <java-symbol type="id" name="timePickerLayout" />
  <java-symbol type="id" name="permission_text" />
  <java-symbol type="id" name="permission_remember_layout" />
  <java-symbol type="id" name="permission_remember_choice_checkbox" />
  <java-symbol type="id" name="permission_remember_choice_text" />

  <java-symbol type="attr" name="actionModeShareDrawable" />
  <java-symbol type="attr" name="alertDialogCenterButtons" />
@@ -1188,6 +1192,7 @@
  <java-symbol type="layout" name="locale_picker_item" />
  <java-symbol type="layout" name="media_controller" />
  <java-symbol type="layout" name="overlay_display_window" />
  <java-symbol type="layout" name="permission_confirmation_dialog" />
  <java-symbol type="layout" name="preference" />
  <java-symbol type="layout" name="preference_header_item" />
  <java-symbol type="layout" name="preference_list_content" />
+12 −2
Original line number Diff line number Diff line
@@ -39,6 +39,8 @@ class PermissionDialog extends BasePermissionDialog {
    private final AppOpsService mService;
    private final String mPackageName;
    private final int mCode;
    private View  mView;
    private CheckBox mChoice;
    private int mUid;
    final CharSequence[] mOpLabels;
    private Context mContext;
@@ -81,11 +83,19 @@ class PermissionDialog extends BasePermissionDialog {
                | WindowManager.LayoutParams.PRIVATE_FLAG_SHOW_FOR_ALL_USERS;
        getWindow().setAttributes(attrs);

        mView = getLayoutInflater().inflate(
             com.android.internal.R.layout.permission_confirmation_dialog,
             null);
        TextView tv = (TextView) mView.findViewById(
            com.android.internal.R.id.permission_text);
        mChoice = (CheckBox) mView.findViewById(
            com.android.internal.R.id.permission_remember_choice_checkbox);
        String name = getAppName(mPackageName);
        if(name == null)
            name = mPackageName;
        setMessage(mContext.getString(com.android.internal.R.string.privacy_guard_dialog_summary,
        tv.setText(mContext.getString(com.android.internal.R.string.privacy_guard_dialog_summary,
                name, mOpLabels[mCode]));
        setView(mView);

        // After the timeout, pretend the user clicked the quit button
        //mHandler.sendMessageDelayed(
@@ -112,7 +122,7 @@ class PermissionDialog extends BasePermissionDialog {
    private final Handler mHandler = new Handler() {
        public void handleMessage(Message msg) {
            int mode;
            boolean remember = true;
            boolean remember = mChoice.isChecked();
            switch(msg.what) {
                case ACTION_ALLOWED:
                    mode = AppOpsManager.MODE_ALLOWED;