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

Commit 3e5311e0 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 12702769 from 5e57449b to 25Q1-release

Change-Id: Ia568cbc0050386aa5b3a43312a7fd5f14170e9fe
parents 85daee82 5e57449b
Loading
Loading
Loading
Loading
+12 −0
Original line number Original line Diff line number Diff line
@@ -24,3 +24,15 @@ flag {
        purpose: PURPOSE_BUGFIX
        purpose: PURPOSE_BUGFIX
      }
      }
}
}

# OWNER=grantmenke TARGET=25Q2
flag {
    name: "telecom_app_label_proxy_hsum_aware"
    is_exported: true
    namespace: "telecom"
    description: "Support HSUM mode by ensuring AppLableProxy is multiuser aware."
    bug: "321817633"
    metadata {
        purpose: PURPOSE_BUGFIX
      }
}
 No newline at end of file
+29 −7
Original line number Original line Diff line number Diff line
@@ -16,8 +16,11 @@


package com.android.server.telecom;
package com.android.server.telecom;


import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager;
import com.android.server.telecom.flags.FeatureFlags;
import android.os.UserHandle;
import android.telecom.Log;
import android.telecom.Log;


/**
/**
@@ -30,15 +33,34 @@ public interface AppLabelProxy {
    class Util {
    class Util {
        /**
        /**
         * Default impl of getAppLabel.
         * Default impl of getAppLabel.
         * @param pm PackageManager instance
         * @param context Context instance that is not necessarily associated with the correct user.
         * @param userHandle UserHandle instance of the user that is associated with the app.
         * @param packageName package name to look up.
         * @param packageName package name to look up.
         */
         */
        public static CharSequence getAppLabel(PackageManager pm, String packageName) {
        public static CharSequence getAppLabel(Context context, UserHandle userHandle,
                String packageName, FeatureFlags featureFlags) {
            try {
            try {
                if (featureFlags.telecomAppLabelProxyHsumAware()){
                    Context userContext = context.createContextAsUser(userHandle, 0 /* flags */);
                    PackageManager userPackageManager = userContext.getPackageManager();
                    if (userPackageManager == null) {
                        Log.w(LOG_TAG, "Could not determine app label since PackageManager is "
                                + "null. Package name is %s", packageName);
                        return null;
                    }
                    ApplicationInfo info = userPackageManager.getApplicationInfo(packageName, 0);
                    CharSequence result = userPackageManager.getApplicationLabel(info);
                    Log.i(LOG_TAG, "package %s: name is %s for user = %s", packageName, result,
                            userHandle.toString());
                    return result;
                } else {
                    // Legacy code path:
                    PackageManager pm = context.getPackageManager();
                    ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                    ApplicationInfo info = pm.getApplicationInfo(packageName, 0);
                    CharSequence result = pm.getApplicationLabel(info);
                    CharSequence result = pm.getApplicationLabel(info);
                    Log.i(LOG_TAG, "package %s: name is %s", packageName, result);
                    Log.i(LOG_TAG, "package %s: name is %s", packageName, result);
                    return result;
                    return result;
                }
            } catch (PackageManager.NameNotFoundException nnfe) {
            } catch (PackageManager.NameNotFoundException nnfe) {
                Log.w(LOG_TAG, "Could not determine app label. Package name is %s", packageName);
                Log.w(LOG_TAG, "Could not determine app label. Package name is %s", packageName);
            }
            }
@@ -47,5 +69,5 @@ public interface AppLabelProxy {
        }
        }
    }
    }


    CharSequence getAppLabel(String packageName);
    CharSequence getAppLabel(String packageName, UserHandle userHandle);
}
}
+25 −14
Original line number Original line Diff line number Diff line
@@ -800,7 +800,6 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
        if (bluetoothRoute != null) {
        if (bluetoothRoute != null) {
            Log.i(this, "request to route to bluetooth route: %s (active=%b)", bluetoothRoute,
            Log.i(this, "request to route to bluetooth route: %s (active=%b)", bluetoothRoute,
                    mIsActive);
                    mIsActive);
            updateActiveBluetoothDevice(new Pair<>(type, deviceAddress));
            routeTo(mIsActive, bluetoothRoute);
            routeTo(mIsActive, bluetoothRoute);
        } else {
        } else {
            Log.i(this, "request to route to unavailable bluetooth route - type (%s), address (%s)",
            Log.i(this, "request to route to unavailable bluetooth route - type (%s), address (%s)",
@@ -844,10 +843,6 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
            // Fallback to an available route excluding the previously active device.
            // Fallback to an available route excluding the previously active device.
            routeTo(mIsActive, getBaseRoute(true, previouslyActiveDeviceAddress));
            routeTo(mIsActive, getBaseRoute(true, previouslyActiveDeviceAddress));
        }
        }
        // Clear out the active device for the BT audio type.
        if (mFeatureFlags.resolveActiveBtRoutingAndBtTimingIssue()) {
            updateActiveBluetoothDevice(new Pair(type, null));
        }
    }
    }


    private void handleMuteChanged(boolean mute) {
    private void handleMuteChanged(boolean mute) {
@@ -1023,16 +1018,29 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
        // If SCO is once again connected or there's a pending message for BT_AUDIO_CONNECTED, then
        // If SCO is once again connected or there's a pending message for BT_AUDIO_CONNECTED, then
        // we know that the device has reconnected or is in the middle of connecting. Ignore routing
        // we know that the device has reconnected or is in the middle of connecting. Ignore routing
        // out of this BT device.
        // out of this BT device.
        if (mFeatureFlags.resolveActiveBtRoutingAndBtTimingIssue() && areExcludedBtAndDestBtSame
        boolean isExcludedDeviceConnectingOrConnected = areExcludedBtAndDestBtSame
                && (mIsScoAudioConnected || mPendingAudioRoute.getPendingMessages()
                && (mIsScoAudioConnected || mPendingAudioRoute.getPendingMessages()
                .contains(btDevicePendingMsg))) {
                .contains(btDevicePendingMsg));
        // Check if the pending audio route or current route is already different from the route
        // including the BT device that should be excluded from route selection.
        boolean isCurrentOrDestRouteDifferent = btAddressToExclude != null
                && ((mIsPending && !btAddressToExclude.equals(mPendingAudioRoute.getDestRoute()
                .getBluetoothAddress())) || (!mIsPending && !btAddressToExclude.equals(
                        mCurrentRoute.getBluetoothAddress())));
        if (mFeatureFlags.resolveActiveBtRoutingAndBtTimingIssue()) {
            if (isExcludedDeviceConnectingOrConnected) {
                Log.i(this, "BT device with address (%s) is currently connecting/connected. "
                Log.i(this, "BT device with address (%s) is currently connecting/connected. "
                    + "Ignore route switch.");
                        + "Ignoring route switch.", btAddressToExclude);
        } else {
                return;
            } else if (isCurrentOrDestRouteDifferent) {
                Log.i(this, "Current or pending audio route isn't routed to device with address "
                        + "(%s). Ignoring route switch.", btAddressToExclude);
                return;
            }
        }
        routeTo(mIsActive, calculateBaselineRoute(isExplicitUserRequest, includeBluetooth,
        routeTo(mIsActive, calculateBaselineRoute(isExplicitUserRequest, includeBluetooth,
                btAddressToExclude));
                btAddressToExclude));
    }
    }
    }


    private void handleSpeakerOn() {
    private void handleSpeakerOn() {
        if (isPending()) {
        if (isPending()) {
@@ -1441,8 +1449,11 @@ public class CallAudioRouteController implements CallAudioRouteAdapter {
                continue;
                continue;
            }
            }
            // Check if the most recently active device is a watch device.
            // Check if the most recently active device is a watch device.
            if (i == (bluetoothRoutes.size() - 1) && device.equals(mCallAudioState
            boolean isActiveDevice = mActiveBluetoothDevice != null
                    .getActiveBluetoothDevice()) && mBluetoothRouteManager.isWatch(device)) {
                    && device.getAddress().equals(mActiveBluetoothDevice.second);
            if (i == (bluetoothRoutes.size() - 1) && mBluetoothRouteManager.isWatch(device)
                    && (device.equals(mCallAudioState.getActiveBluetoothDevice())
                    || isActiveDevice)) {
                Log.i(this, "getActiveWatchOrNonWatchDeviceRoute: Routing to active watch - %s",
                Log.i(this, "getActiveWatchOrNonWatchDeviceRoute: Routing to active watch - %s",
                        bluetoothRoutes.get(0));
                        bluetoothRoutes.get(0));
                return bluetoothRoutes.get(0);
                return bluetoothRoutes.get(0);
+5 −5
Original line number Original line Diff line number Diff line
@@ -939,8 +939,8 @@ public class CallsManager extends Call.ListenerBase
        String defaultDialerPackageName = telecomManager.getDefaultDialerPackage(userHandle);
        String defaultDialerPackageName = telecomManager.getDefaultDialerPackage(userHandle);
        String userChosenPackageName = getRoleManagerAdapter().
        String userChosenPackageName = getRoleManagerAdapter().
                getDefaultCallScreeningApp(userHandle);
                getDefaultCallScreeningApp(userHandle);
        AppLabelProxy appLabelProxy = packageName -> AppLabelProxy.Util.getAppLabel(
        AppLabelProxy appLabelProxy = (packageName, user) -> AppLabelProxy.Util.getAppLabel(
                mContext.getPackageManager(), packageName);
                mContext, user, packageName, mFeatureFlags);
        ParcelableCallUtils.Converter converter = new ParcelableCallUtils.Converter();
        ParcelableCallUtils.Converter converter = new ParcelableCallUtils.Converter();


        IncomingCallFilterGraph graph = mIncomingCallFilterGraphProvider.createGraph(incomingCall,
        IncomingCallFilterGraph graph = mIncomingCallFilterGraphProvider.createGraph(incomingCall,
@@ -2592,8 +2592,8 @@ public class CallsManager extends Call.ListenerBase
                theCall,
                theCall,
                new AppLabelProxy() {
                new AppLabelProxy() {
                    @Override
                    @Override
                    public CharSequence getAppLabel(String packageName) {
                    public CharSequence getAppLabel(String packageName, UserHandle userHandle) {
                        return Util.getAppLabel(mContext.getPackageManager(), packageName);
                        return Util.getAppLabel(mContext, userHandle, packageName, mFeatureFlags);
                    }
                    }
                }).process();
                }).process();
        future.thenApply( v -> {
        future.thenApply( v -> {
@@ -3214,7 +3214,7 @@ public class CallsManager extends Call.ListenerBase
        }
        }


        CharSequence requestingAppName = AppLabelProxy.Util.getAppLabel(
        CharSequence requestingAppName = AppLabelProxy.Util.getAppLabel(
                mContext.getPackageManager(), requestingPackageName);
                mContext, call.getAssociatedUser(), requestingPackageName, mFeatureFlags);
        if (requestingAppName == null) {
        if (requestingAppName == null) {
            requestingAppName = requestingPackageName;
            requestingAppName = requestingPackageName;
        }
        }
+4 −1
Original line number Original line Diff line number Diff line
@@ -1326,7 +1326,10 @@ public class PhoneAccountRegistrar {


            // Ensure name is correct.
            // Ensure name is correct.
            CharSequence newLabel = mAppLabelProxy.getAppLabel(
            CharSequence newLabel = mAppLabelProxy.getAppLabel(
                    account.getAccountHandle().getComponentName().getPackageName());
                    account.getAccountHandle().getComponentName().getPackageName(),
                    UserUtil.getAssociatedUserForCall(
                            mTelecomFeatureFlags.associatedUserRefactorForWorkProfile(),
                            this, UserHandle.CURRENT, account.getAccountHandle()));


            account = account.toBuilder()
            account = account.toBuilder()
                    .setLabel(newLabel)
                    .setLabel(newLabel)
Loading