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

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

Merge "Add system default label for dialer app." into qt-dev

parents 8dea6553 0df767ea
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -715,6 +715,9 @@
    <!-- Summary of a default app when there is no app set [CHAR LIMIT=60] -->
    <string name="default_app_none">None</string>

    <!-- Label for a system default app [CHAR LIMIT=60] -->
    <string name="default_app_system_default">(System default)</string>

    <!-- Label when there are no apps available for a default app [CHAR LIMIT=30] -->
    <string name="default_app_no_apps">No apps</string>

+20 −0
Original line number Diff line number Diff line
@@ -17,11 +17,18 @@
package com.android.packageinstaller.role.model;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.os.UserHandle;
import android.telecom.TelecomManager;
import android.telephony.TelephonyManager;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.preference.Preference;

import com.android.permissioncontroller.R;

import java.util.Objects;

/**
 * Class for behavior of the dialer role.
@@ -39,6 +46,19 @@ public class DialerRoleBehavior implements RoleBehavior {
        return telephonyManager.isVoiceCapable();
    }

    @Override
    public void prepareApplicationPreferenceAsUser(@NonNull Role role,
            @NonNull Preference preference, @NonNull ApplicationInfo applicationInfo,
            @NonNull UserHandle user, @NonNull Context context) {
        TelecomManager telecomManager = context.getSystemService(TelecomManager.class);
        String systemPackageName = telecomManager.getSystemDialerPackage();
        if (Objects.equals(applicationInfo.packageName, systemPackageName)) {
            preference.setSummary(R.string.default_app_system_default);
        } else {
            preference.setSummary(null);
        }
    }

    @Nullable
    @Override
    public CharSequence getConfirmationMessage(@NonNull Role role, @NonNull String packageName,