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

Commit d1ed6027 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Special-case app permission usage strings for platform permission." into qt-dev

parents 459888d8 ae0f96e3
Loading
Loading
Loading
Loading
+68 −2
Original line number Diff line number Diff line
@@ -413,10 +413,76 @@
    <string name="app_permission_header"><xliff:g id="perm" example="location">%1$s</xliff:g> access for this app</string>

    <!-- Summary for showing a single permission access [CHAR LIMIT=60] -->
    <string name="app_permission_footer_usage_summary"><xliff:g id="app" example="Maps">%1$s</xliff:g> accessed your <xliff:g id="perm" example="location">%2$s</xliff:g> <xliff:g id="time" example="2 hours">%3$s</xliff:g> ago</string>
    <string name="app_permission_footer_usage_summary_generic"><xliff:g id="app" example="Maps">%1$s</xliff:g> accessed your <xliff:g id="perm" example="location">%2$s</xliff:g> <xliff:g id="time" example="2 hours">%3$s</xliff:g> ago</string>

    <!-- Summary for showing a single activity recognition permission access [CHAR LIMIT=60] -->
    <string name="app_permission_footer_usage_summary_activity_recognition"><xliff:g id="app" example="Maps">%1$s</xliff:g> accessed your physical activity <xliff:g id="time" example="2 hours">%2$s</xliff:g> ago</string>

    <!-- Summary for showing a single calendar permission access [CHAR LIMIT=60] -->
    <string name="app_permission_footer_usage_summary_calendar"><xliff:g id="app" example="Maps">%1$s</xliff:g> accessed your calendar <xliff:g id="time" example="2 hours">%2$s</xliff:g> ago</string>

    <!-- Summary for showing a single call log permission access [CHAR LIMIT=60] -->
    <string name="app_permission_footer_usage_summary_call_log"><xliff:g id="app" example="Maps">%1$s</xliff:g> accessed your call logs <xliff:g id="time" example="2 hours">%2$s</xliff:g> ago</string>

    <!-- Summary for showing a single camera permission access [CHAR LIMIT=60] -->
    <string name="app_permission_footer_usage_summary_camera"><xliff:g id="app" example="Maps">%1$s</xliff:g> accessed your camera <xliff:g id="time" example="2 hours">%2$s</xliff:g> ago</string>

    <!-- Summary for showing a single contacts permission access [CHAR LIMIT=60] -->
    <string name="app_permission_footer_usage_summary_contacts"><xliff:g id="app" example="Maps">%1$s</xliff:g> accessed your contacts <xliff:g id="time" example="2 hours">%2$s</xliff:g> ago</string>

    <!-- Summary for showing a single location permission access [CHAR LIMIT=60] -->
    <string name="app_permission_footer_usage_summary_location"><xliff:g id="app" example="Maps">%1$s</xliff:g> accessed your location <xliff:g id="time" example="2 hours">%2$s</xliff:g> ago</string>

    <!-- Summary for showing a single microphone permission access [CHAR LIMIT=60] -->
    <string name="app_permission_footer_usage_summary_microphone"><xliff:g id="app" example="Maps">%1$s</xliff:g> accessed your microphone <xliff:g id="time" example="2 hours">%2$s</xliff:g> ago</string>

    <!-- Summary for showing a single phone permission access [CHAR LIMIT=60] -->
    <string name="app_permission_footer_usage_summary_phone"><xliff:g id="app" example="Maps">%1$s</xliff:g> accessed your phone <xliff:g id="time" example="2 hours">%2$s</xliff:g> ago</string>

    <!-- Summary for showing a single sensors permission access [CHAR LIMIT=60] -->
    <string name="app_permission_footer_usage_summary_sensors"><xliff:g id="app" example="Maps">%1$s</xliff:g> accessed your sensors <xliff:g id="time" example="2 hours">%2$s</xliff:g> ago</string>

    <!-- Summary for showing a single SMS permission access [CHAR LIMIT=60] -->
    <string name="app_permission_footer_usage_summary_sms"><xliff:g id="app" example="Maps">%1$s</xliff:g> accessed your SMS <xliff:g id="time" example="2 hours">%2$s</xliff:g> ago</string>

    <!-- Summary for showing a single storage permission access [CHAR LIMIT=60] -->
    <string name="app_permission_footer_usage_summary_storage"><xliff:g id="app" example="Maps">%1$s</xliff:g> accessed your storage <xliff:g id="time" example="2 hours">%2$s</xliff:g> ago</string>

    <!-- Summary for showing a single permission access that has not accessed the permission [CHAR LIMIT=60] -->
    <string name="app_permission_footer_no_usages"><xliff:g id="app" example="Maps">%1$s</xliff:g> has not accessed your <xliff:g id="perm" example="location">%2$s</xliff:g></string>
    <string name="app_permission_footer_no_usages_generic"><xliff:g id="app" example="Maps">%1$s</xliff:g> has not accessed your <xliff:g id="perm" example="location">%2$s</xliff:g></string>

    <!-- Summary for showing a single permission access that has not accessed the activity recognition permission [CHAR LIMIT=60] -->
    <string name="app_permission_footer_no_usages_activity_recognition"><xliff:g id="app" example="Maps">%1$s</xliff:g> has not accessed your physical activity</string>

    <!-- Summary for showing a single permission access that has not accessed the calendar permission [CHAR LIMIT=60] -->
    <string name="app_permission_footer_no_usages_calendar"><xliff:g id="app" example="Maps">%1$s</xliff:g> has not accessed your calendar</string>

    <!-- Summary for showing a single permission access that has not accessed the call log permission [CHAR LIMIT=60] -->
    <string name="app_permission_footer_no_usages_call_log"><xliff:g id="app" example="Maps">%1$s</xliff:g> has not accessed your call logs</string>

    <!-- Summary for showing a single permission access that has not accessed the camera permission [CHAR LIMIT=60] -->
    <string name="app_permission_footer_no_usages_camera"><xliff:g id="app" example="Maps">%1$s</xliff:g> has not accessed your camera</string>

    <!-- Summary for showing a single permission access that has not accessed the contacts permission [CHAR LIMIT=60] -->
    <string name="app_permission_footer_no_usages_contacts"><xliff:g id="app" example="Maps">%1$s</xliff:g> has not accessed your contacts</string>

    <!-- Summary for showing a single permission access that has not accessed the location permission [CHAR LIMIT=60] -->
    <string name="app_permission_footer_no_usages_location"><xliff:g id="app" example="Maps">%1$s</xliff:g> has not accessed your location</string>

    <!-- Summary for showing a single permission access that has not accessed the microphone permission [CHAR LIMIT=60] -->
    <string name="app_permission_footer_no_usages_microphone"><xliff:g id="app" example="Maps">%1$s</xliff:g> has not accessed your microphone</string>

    <!-- Summary for showing a single permission access that has not accessed the phone permission [CHAR LIMIT=60] -->
    <string name="app_permission_footer_no_usages_phone"><xliff:g id="app" example="Maps">%1$s</xliff:g> has not accessed your phone</string>

    <!-- Summary for showing a single permission access that has not accessed the sensors permission [CHAR LIMIT=60] -->
    <string name="app_permission_footer_no_usages_sensors"><xliff:g id="app" example="Maps">%1$s</xliff:g> has not accessed your sensors</string>

    <!-- Summary for showing a single permission access that has not accessed the SMS permission [CHAR LIMIT=60] -->
    <string name="app_permission_footer_no_usages_sms"><xliff:g id="app" example="Maps">%1$s</xliff:g> has not accessed your SMS</string>

    <!-- Summary for showing a single permission access that has not accessed the storage permission [CHAR LIMIT=60] -->
    <string name="app_permission_footer_no_usages_storage"><xliff:g id="app" example="Maps">%1$s</xliff:g> has not accessed your storage</string>

    <!-- Summary for showing that the permission usage data for a permission is not available [CHAR LIMIT=none] -->
    <string name="app_permission_footer_not_available">Last access data is currently not available for this permission</string>
+90 −16
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@ package com.android.packageinstaller.permission.ui.handheld;

import static java.lang.annotation.RetentionPolicy.SOURCE;

import android.Manifest;
import android.app.ActionBar;
import android.app.Activity;
import android.app.AlertDialog;
@@ -196,22 +197,8 @@ public class AppPermissionFragment extends SettingsWithLargeHeader {
                ((TextView) root.requireViewById(R.id.usage_summary)).setText(
                        context.getString(R.string.app_permission_footer_not_available));
            } else {
                String timeDiffStr = Utils.getRelativeLastUsageString(context,
                        PermissionUsages.loadLastGroupUsage(context, mGroup));
                if (timeDiffStr == null) {
                ((TextView) root.requireViewById(R.id.usage_summary)).setText(
                            context.getString(
                                    R.string.app_permission_footer_no_usages,
                                    appLabel,
                                    mGroup.getLabel().toString().toLowerCase()));
                } else {
                    ((TextView) root.requireViewById(R.id.usage_summary)).setText(
                            context.getString(
                                    R.string.app_permission_footer_usage_summary,
                                    appLabel,
                                    mGroup.getLabel().toString().toLowerCase(),
                                    timeDiffStr));
                }
                        getUsageSummary(context, appLabel));
            }
        } else {
            root.requireViewById(R.id.usage_summary).setVisibility(View.GONE);
@@ -253,6 +240,93 @@ public class AppPermissionFragment extends SettingsWithLargeHeader {
        return root;
    }

    private @NonNull String getUsageSummary(@NonNull Context context, @NonNull String appLabel) {
        String timeDiffStr = Utils.getRelativeLastUsageString(context,
                PermissionUsages.loadLastGroupUsage(context, mGroup));
        int strResId;
        if (timeDiffStr == null) {
            switch (mGroup.getName()) {
                case Manifest.permission_group.ACTIVITY_RECOGNITION:
                    strResId = R.string.app_permission_footer_no_usages_activity_recognition;
                    break;
                case Manifest.permission_group.CALENDAR:
                    strResId = R.string.app_permission_footer_no_usages_calendar;
                    break;
                case Manifest.permission_group.CALL_LOG:
                    strResId = R.string.app_permission_footer_no_usages_call_log;
                    break;
                case Manifest.permission_group.CAMERA:
                    strResId = R.string.app_permission_footer_no_usages_camera;
                    break;
                case Manifest.permission_group.CONTACTS:
                    strResId = R.string.app_permission_footer_no_usages_contacts;
                    break;
                case Manifest.permission_group.LOCATION:
                    strResId = R.string.app_permission_footer_no_usages_location;
                    break;
                case Manifest.permission_group.MICROPHONE:
                    strResId = R.string.app_permission_footer_no_usages_microphone;
                    break;
                case Manifest.permission_group.PHONE:
                    strResId = R.string.app_permission_footer_no_usages_phone;
                    break;
                case Manifest.permission_group.SENSORS:
                    strResId = R.string.app_permission_footer_no_usages_sensors;
                    break;
                case Manifest.permission_group.SMS:
                    strResId = R.string.app_permission_footer_no_usages_sms;
                    break;
                case Manifest.permission_group.STORAGE:
                    strResId = R.string.app_permission_footer_no_usages_storage;
                    break;
                default:
                    return context.getString(R.string.app_permission_footer_no_usages_generic,
                            appLabel, mGroup.getLabel().toString().toLowerCase());
            }
            return context.getString(strResId, appLabel);
        } else {
            switch (mGroup.getName()) {
                case Manifest.permission_group.ACTIVITY_RECOGNITION:
                    strResId = R.string.app_permission_footer_usage_summary_activity_recognition;
                    break;
                case Manifest.permission_group.CALENDAR:
                    strResId = R.string.app_permission_footer_usage_summary_calendar;
                    break;
                case Manifest.permission_group.CALL_LOG:
                    strResId = R.string.app_permission_footer_usage_summary_call_log;
                    break;
                case Manifest.permission_group.CAMERA:
                    strResId = R.string.app_permission_footer_usage_summary_camera;
                    break;
                case Manifest.permission_group.CONTACTS:
                    strResId = R.string.app_permission_footer_usage_summary_contacts;
                    break;
                case Manifest.permission_group.LOCATION:
                    strResId = R.string.app_permission_footer_usage_summary_location;
                    break;
                case Manifest.permission_group.MICROPHONE:
                    strResId = R.string.app_permission_footer_usage_summary_microphone;
                    break;
                case Manifest.permission_group.PHONE:
                    strResId = R.string.app_permission_footer_usage_summary_phone;
                    break;
                case Manifest.permission_group.SENSORS:
                    strResId = R.string.app_permission_footer_usage_summary_sensors;
                    break;
                case Manifest.permission_group.SMS:
                    strResId = R.string.app_permission_footer_usage_summary_sms;
                    break;
                case Manifest.permission_group.STORAGE:
                    strResId = R.string.app_permission_footer_usage_summary_storage;
                    break;
                default:
                    return context.getString(R.string.app_permission_footer_usage_summary_generic,
                            appLabel, mGroup.getLabel().toString().toLowerCase(), timeDiffStr);
            }
            return context.getString(strResId, appLabel, timeDiffStr);
        }
    }

    @Override
    public void onStart() {
        super.onStart();