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

Commit 9b1236bc authored by Lars Greiss's avatar Lars Greiss Committed by Michael Bestas
Browse files

Add link to Privacy Guard from app info screen

Based on https://github.com/SlimRoms/packages_apps_Settings/commit/46bb1442aa96aad6890e3ce7b6f3c0466ababf25

JIRA: CYAN-3826
Change-Id: I9591ee7b0ffcce7f2257f988bc2aa5dcf39be4ff
parent 355f8774
Loading
Loading
Loading
Loading
+74 −36
Original line number Diff line number Diff line
@@ -409,15 +409,51 @@
        </LinearLayout>

        <!-- Permissions section -->
        <LinearLayout
        <RelativeLayout
            android:id="@+id/permissions_section"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical">
            <TextView
                style="?android:attr/listSeparatorTextViewStyle"
                android:layout_marginTop="8dip"
                android:text="@string/permissions_label" />
                android:id="@+id/permissions_label"
                android:text="@string/permissions_label"
                android:textAppearance="?android:attr/textAppearanceSmall"
                android:layout_alignParentStart="true"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:paddingTop="6dip" />
            <LinearLayout
                android:id="@+id/permissions_button"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_below="@id/permissions_label"
                android:paddingStart="?android:attr/listPreferredItemPaddingStart"
                android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
                android:paddingTop="4dip"
                android:orientation="horizontal">
                <View
                    android:layout_width="120dip"
                    android:layout_height="0dip"
                    android:layout_weight="0.4" />
                <View
                    android:layout_width="0dip"
                    android:layout_height="0dip"
                    android:visibility="invisible"
                    android:layout_weight="0.2" />
                <Button
                    android:id="@+id/app_ops_button"
                    android:layout_width="120dip"
                    android:layout_height="wrap_content"
                    android:layout_weight="0.4"
                    android:text="@string/app_ops_btn_text" />
            </LinearLayout>
            <LinearLayout
                android:id="@+id/permissions_detail_section"
                android:layout_below="@id/permissions_button"
                android:layout_width="match_parent"
                android:layout_height="match_parent"
                android:orientation="vertical">
                <TextView android:id="@+id/security_settings_billing_desc"
                    android:text="@string/security_settings_billing_desc"
                    android:textColor="@color/security_settings_billing_desc_color"
@@ -430,6 +466,7 @@
                    android:layout_height="wrap_content" />
                <LinearLayout
                    android:id="@+id/security_settings_billing_list"
                    android:layout_below="@id/security_settings_billing_desc"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:orientation="vertical">
@@ -458,6 +495,7 @@
                    android:layout_height="match_parent"
                    android:orientation="vertical"/>
            </LinearLayout>
        </RelativeLayout>
    </LinearLayout>
</ScrollView>
+2 −0
Original line number Diff line number Diff line
@@ -326,6 +326,8 @@
    <string name="privacy_guard_help_text">In this screen you can choose which apps Privacy Guard should be active for by simply tapping on them. Selected apps will not be able to access your personal data such as contacts, messages or call logs. Long pressing an app\'s entry opens its app details screen.\n\nBuilt-in apps are not shown by default but can be revealed by selecting the respective menu option.</string>
    <string name="privacy_guard_manager_show_system_apps">Show built-in apps</string>

    <string name="app_ops_btn_text">Modify</string>

    <!-- Increasing ring tone volume -->
    <string name="increasing_ring_volume_option_title">Increasing ring volume</string>
    <string name="increasing_ring_min_volume_title">Start volume</string>
+39 −1
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@ import com.android.settings.applications.ApplicationsState.AppEntry;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.AlertDialog;
import android.app.AppOpsManager;
import android.app.Dialog;
import android.app.DialogFragment;
import android.app.Fragment;
@@ -83,6 +84,7 @@ import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
import com.android.settings.cyanogenmod.ProtectedAppsReceiver;
@@ -143,8 +145,10 @@ public class InstalledAppDetails extends Fragment
    private Button mClearDataButton;
    private Button mMoveAppButton;
    private CompoundButton mNotificationSwitch;
    private Button mAppOpsButton;

    private PackageMoveObserver mPackageMoveObserver;
    private AppOpsManager mAppOps;

    private final HashSet<String> mHomePackages = new HashSet<String>();

@@ -332,6 +336,16 @@ public class InstalledAppDetails extends Fragment
        }
    }

    private boolean isThisASystemPackage() {
        try {
            PackageInfo sys = mPm.getPackageInfo("android", PackageManager.GET_SIGNATURES);
            return (mPackageInfo != null && mPackageInfo.signatures != null &&
                    sys.signatures[0].equals(mPackageInfo.signatures[0]));
        } catch (PackageManager.NameNotFoundException e) {
            return false;
        }
    }

    private boolean handleDisableable(Button button) {
        boolean disableable = false;
        // Try to prevent the user from bricking their phone
@@ -451,6 +465,19 @@ public class InstalledAppDetails extends Fragment
        }
    }

    private void initAppOpsButton() {
        boolean enabled = true;
        if (isThisASystemPackage()) {
            enabled = false;
        }

        mAppOpsButton.setEnabled(enabled);
        if (enabled) {
            // Register listener
            mAppOpsButton.setOnClickListener(this);
        }
    }

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
@@ -530,6 +557,9 @@ public class InstalledAppDetails extends Fragment
        
        mNotificationSwitch = (CompoundButton) view.findViewById(R.id.notification_switch);

        mAppOps = (AppOpsManager) getActivity().getSystemService(Context.APP_OPS_SERVICE);
        mAppOpsButton = (Button) view.findViewById(R.id.app_ops_button);

        return view;
    }

@@ -866,7 +896,8 @@ public class InstalledAppDetails extends Fragment
        }

        // Security permissions section
        LinearLayout permsView = (LinearLayout) mRootView.findViewById(R.id.permissions_section);
        RelativeLayout permsView = (RelativeLayout) mRootView.findViewById(
                R.id.permissions_section);
        AppSecurityPermissions asp = new AppSecurityPermissions(getActivity(), packageName);
        int premiumSmsPermission = getPremiumSmsPermission(packageName);
        // Premium SMS permission implies the app also has SEND_SMS permission, so the original
@@ -1123,11 +1154,13 @@ public class InstalledAppDetails extends Fragment
            initDataButtons();
            initMoveButton();
            initNotificationButton();
            initAppOpsButton();
        } else {
            mMoveAppButton.setText(R.string.moving);
            mMoveAppButton.setEnabled(false);
            mUninstallButton.setEnabled(false);
            mSpecialDisableButton.setEnabled(false);
            mAppOpsButton.setEnabled(false);
        }
    }

@@ -1490,6 +1523,11 @@ public class InstalledAppDetails extends Fragment
            mMoveInProgress = true;
            refreshButtons();
            mPm.movePackage(mAppEntry.info.packageName, mPackageMoveObserver, moveFlags);
        } else if (v == mAppOpsButton) {
            Intent intent = new Intent(
                    android.provider.Settings.ACTION_APP_OPS_DETAILS_SETTINGS,
                    Uri.parse("package:" + mAppEntry.info.packageName));
            startActivity(intent);
        }
    }