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

Commit 2a369931 authored by Danesh M's avatar Danesh M Committed by Gerrit Code Review
Browse files

Merge changes Ia2773715,Ic739519c,Ia55364c3,I7405f1e8,I32183d77 into cm-10.2

* changes:
  [1/2] AppOps: Show allowed/ignored counts
  [1/2] AppOps: Add alarm wakeup op
  AppOps: menu options to show/hide user and system apps
  AppOps: Enable App Ops under security setting.
  AppOps: Add more operations in app ops settings.
parents 5d8b5cd6 fade53d0
Loading
Loading
Loading
Loading
+16 −5
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toEndOf="@id/op_icon"
        android:layout_toStartOf="@+id/switchWidget"
        android:layout_toStartOf="@+id/spinnerWidget"
        android:layout_marginTop="2dip"
        android:singleLine="true"
        android:ellipsize="marquee"
@@ -49,16 +49,27 @@
        android:textAlignment="viewStart" />

    <TextView
        android:id="@+id/op_time"
        android:id="@+id/op_counts"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toEndOf="@id/op_icon"
        android:layout_toStartOf="@+id/switchWidget"
        android:layout_toStartOf="@+id/spinnerWidget"
        android:layout_below="@id/op_name"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textAlignment="viewStart" />

    <Switch android:id="@+id/switchWidget"
    <TextView
        android:id="@+id/op_time"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_toEndOf="@id/op_icon"
        android:layout_toStartOf="@+id/spinnerWidget"
        android:layout_below="@id/op_counts"
        android:textAppearance="?android:attr/textAppearanceSmall"
        android:textAlignment="viewStart" />

    <Spinner
        android:id="@+id/spinnerWidget"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentEnd="true"
@@ -66,6 +77,6 @@
        android:layout_marginStart="8dip"
        android:padding="8dip"
        android:focusable="false"
        android:clickable="true" />
        android:entries="@array/app_ops_permissions" />

</RelativeLayout>
+26 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2013 The CyanogenMod 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.
-->

<menu xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:id="@+id/show_user_apps"
          android:title="@string/app_ops_show_user_apps"
          android:checkable="true" />
    <item android:id="@+id/show_system_apps"
          android:title="@string/app_ops_show_system_apps"
          android:checkable="true" />
    <item android:id="@+id/reset_counters"
          android:title="@string/app_ops_reset_counters" />
</menu>
+97 −0
Original line number Diff line number Diff line
@@ -615,4 +615,101 @@
         per-device overlay. Required to build on non-hardware tunable devices -->
    <string-array name="gamma_descriptors" translatable="false">
    </string-array>

    <!-- Performance profiles -->
    <string-array name="perf_profile_entries" translatable="false">
        <item>@string/perf_profile_pwrsv</item>
        <item>@string/perf_profile_bal</item>
        <item>@string/perf_profile_perf</item>
    </string-array>

    <string-array name="perf_profile_values" translatable="false">
        <item>0</item>
        <item>1</item>
        <item>2</item>
    </string-array>

    <!-- App ops, extension of AOSP app_ops_summaries and app_ops_labels -->
    <string-array name="app_ops_summaries_cm">
        <item>coarse location</item>
        <item>fine location</item>
        <item>GPS</item>
        <item>vibrate</item>
        <item>read contacts</item>
        <item>modify contacts</item>
        <item>read call log</item>
        <item>modify call log</item>
        <item>read calendar</item>
        <item>modify calendar</item>
        <item>wi-fi scan</item>
        <item>notification</item>
        <item>cell scan</item>
        <item>call phone</item>
        <item>read SMS</item>
        <item>write SMS</item>
        <item>receive SMS</item>
        <item>receive emergency SMS</item>
        <item>receive MMS</item>
        <item>receive WAP push</item>
        <item>send SMS</item>
        <item>read ICC SMS</item>
        <item>write ICC SMS</item>
        <item>modify settings</item>
        <item>draw on top</item>
        <item>access notifications</item>
        <item>camera</item>
        <item>record audio</item>
        <item>play audio</item>
        <item>read clipboard</item>
        <item>modify clipboard</item>
        <item>@string/app_ops_summaries_wifi_change</item>
        <item>@string/app_ops_summaries_bluetooth_change</item>
        <item>@string/app_ops_summaries_data_change</item>
        <item>@string/app_ops_summaries_alarm_wakeup</item>
    </string-array>

    <string-array name="app_ops_labels_cm">
        <item>Location</item>
        <item>Location</item>
        <item>Location</item>
        <item>Vibrate</item>
        <item>Read contacts</item>
        <item>Modify contacts</item>
        <item>Read call log</item>
        <item>Modify call log</item>
        <item>Read calendar</item>
        <item>Modify calendar</item>
        <item>Location</item>
        <item>Post notification</item>
        <item>Location</item>
        <item>Call phone</item>
        <item>Receive SMS/MMS</item>
        <item>Send SMS/MMS</item>
        <item>Receive SMS/MMS</item>
        <item>Receive SMS/MMS</item>
        <item>Receive SMS/MMS</item>
        <item>Receive SMS/MMS</item>
        <item>Send SMS/MMS</item>
        <item>Receive SMS/MMS</item>
        <item>Send SMS/MMS</item>
        <item>Modify settings</item>
        <item>Draw on top</item>
        <item>Access notifications</item>
        <item>Camera</item>
        <item>Record audio</item>
        <item>Play audio</item>
        <item>Read clipboard</item>
        <item>Modify clipboard</item>
        <item>@string/app_ops_labels_wifi_change</item>
        <item>@string/app_ops_labels_bluetooth_change</item>
        <item>@string/app_ops_labels_data_change</item>
        <item>@string/app_ops_labels_alarm_wakeup</item>
    </string-array>

    <!-- App ops permissions -->
    <string-array name="app_ops_permissions">
        <item>Allowed</item>
        <item>Denied</item>
        <item>Always ask</item>
    </string-array>
</resources>
+20 −0
Original line number Diff line number Diff line
@@ -124,6 +124,9 @@
    <string name="view_stats_title">View stats</string>
    <string name="anonymous_learn_more">Learn more</string>

    <string name="app_ops_allowed">Allowed</string>
    <string name="app_ops_ignored">Denied</string>

    <!-- Anonymous Statistics - Notification -->
    <string name="anonymous_notification_desc">Enable or Disable CyanogenMod Statistics</string>

@@ -1018,4 +1021,21 @@ two in order to insert additional control points. \'Remove\' deletes the selecte

    <!-- GPS download data over wi-fi only -->
    <string name="gps_download_data_wifi_only">Download GPS assisted data only over Wi-Fi networks</string>

    <!-- App ops -->
    <string name="app_ops_summaries_wifi_change">wifi change</string>
    <string name="app_ops_labels_wifi_change">Wi-Fi change</string>
    <string name="app_ops_summaries_bluetooth_change">bluetooth change</string>
    <string name="app_ops_labels_bluetooth_change">Bluetooth change</string>
    <string name="app_ops_summaries_data_change">data change</string>
    <string name="app_ops_labels_data_change">Data change</string>
    <string name="app_ops_summaries_alarm_wakeup">wake up</string>
    <string name="app_ops_labels_alarm_wakeup">Wake up</string>
    <!-- App ops menu options -->
    <string name="app_ops_show_user_apps">Show user apps</string>
    <string name="app_ops_show_system_apps">Show built-in apps</string>
    <string name="app_ops_reset_counters">Reset allow/deny counters</string>
    <string name="app_ops_reset_confirm_title">Confirm counters reset</string>
    <string name="app_ops_reset_confirm_mesg">Are you sure you wish to reset AppOps counters ?</string>

</resources>
+52 −8
Original line number Diff line number Diff line
@@ -36,10 +36,11 @@ import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.Spinner;
import android.widget.TextView;

import com.android.settings.R;
@@ -61,6 +62,36 @@ public class AppOpsDetails extends Fragment {
    private TextView mAppVersion;
    private LinearLayout mOperationsSection;

    private final int MODE_ALLOWED = 0;
    private final int MODE_IGNORED = 1;
    private final int MODE_ASK     = 2;

    private int modeToPosition(int mode) {
        switch (mode) {
        case AppOpsManager.MODE_ALLOWED:
            return MODE_ALLOWED;
        case AppOpsManager.MODE_IGNORED:
            return MODE_IGNORED;
        case AppOpsManager.MODE_ASK:
            return MODE_ASK;
        };

        return MODE_IGNORED;
    }

    private int positionToMode(int position) {
        switch (position) {
        case MODE_ALLOWED:
            return AppOpsManager.MODE_ALLOWED;
        case MODE_IGNORED:
            return AppOpsManager.MODE_IGNORED;
        case MODE_ASK:
            return AppOpsManager.MODE_ASK;
        };

        return AppOpsManager.MODE_IGNORED;
    }

    // Utility method to set application label and icon.
    private void setAppLabelAndIcon(final PackageInfo pkgInfo) {
        final View appSnippet = mRootView.findViewById(R.id.app_snippet);
@@ -152,18 +183,31 @@ public class AppOpsDetails extends Fragment {
                }
                ((TextView)view.findViewById(R.id.op_name)).setText(
                        entry.getSwitchText(mState));
                ((TextView)view.findViewById(R.id.op_counts)).setText(
                        entry.getCountsText(res));
                ((TextView)view.findViewById(R.id.op_time)).setText(
                        entry.getTimeText(res, true));
                Switch sw = (Switch)view.findViewById(R.id.switchWidget);
                Spinner sw = (Spinner)view.findViewById(R.id.spinnerWidget);
                final int switchOp = AppOpsManager.opToSwitch(firstOp.getOp());
                sw.setChecked(mAppOps.checkOp(switchOp, entry.getPackageOps().getUid(),
                        entry.getPackageOps().getPackageName()) == AppOpsManager.MODE_ALLOWED);
                sw.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() {
                int mode = mAppOps.checkOp(switchOp, entry.getPackageOps().getUid(),
                        entry.getPackageOps().getPackageName());
                sw.setSelection(modeToPosition(mode));
                sw.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() {
                    boolean firstMode = true;

                    @Override
                    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                    public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int position, long id) {
                        if(firstMode) {
                            firstMode = false;
                            return;
                         }
                        mAppOps.setMode(switchOp, entry.getPackageOps().getUid(),
                                entry.getPackageOps().getPackageName(), isChecked
                                ? AppOpsManager.MODE_ALLOWED : AppOpsManager.MODE_IGNORED);
                                entry.getPackageOps().getPackageName(), positionToMode(position));
                    }

                    @Override
                    public void onNothingSelected(AdapterView<?> parentView) {
                        // Do nothing
                    }
                });
            }
Loading