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

Commit 0df767ea authored by Hai Zhang's avatar Hai Zhang
Browse files

Add system default label for dialer app.

This was the old behavior in Settings.

Bug: 124452117
Test: build
Change-Id: Ib3910cc6c5e040a1aa6a60358240ad4d44c802ca
parent dd8da4b2
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,