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

Commit dfa4fb62 authored by Thomas Stuart's avatar Thomas Stuart
Browse files

add impl for getRegisteredPhoneAccounts

Bug: 307609763
Test: CTS coverage
Change-Id: I20106896ff1d03160ca1989f7975a1a9a034b2aa
parent 95b246d1
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -29,6 +29,13 @@ flag{
  bug: "310669304"
}

flag{
  name: "get_registered_phone_accounts"
  namespace: "telecom"
  description: "When set, self-managed clients can get their own phone accounts"
  bug: "317132586"
}

flag{
  name: "transactional_video_state"
  namespace: "telecom"
+47 −2
Original line number Diff line number Diff line
@@ -77,7 +77,6 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telecom.ICallControl;
import com.android.internal.telecom.ICallEventCallback;
import com.android.internal.telecom.ITelecomService;
import com.android.internal.telephony.flags.Flags;
import com.android.internal.util.IndentingPrintWriter;
import com.android.server.telecom.components.UserCallIntentProcessorFactory;
import com.android.server.telecom.flags.FeatureFlags;
@@ -602,6 +601,53 @@ public class TelecomServiceImpl {
            }
        }

        @Override
        public ParceledListSlice<PhoneAccount> getRegisteredPhoneAccounts(String callingPackage,
                String callingFeatureId) {
            try {
                Log.startSession("TSI.gRPA", Log.getPackageAbbreviation(callingPackage));
                try {
                    enforceCallingPackage(callingPackage, "getRegisteredPhoneAccounts");
                } catch (SecurityException se) {
                    EventLog.writeEvent(0x534e4554, "307609763", Binder.getCallingUid(),
                            "getRegisteredPhoneAccounts: invalid calling package");
                    throw se;
                }

                boolean hasCrossUserAccess = false;
                try {
                    enforceInAppCrossUserPermission();
                    hasCrossUserAccess = true;
                } catch (SecurityException e) {
                    // pass through
                }

                synchronized (mLock) {
                    final UserHandle callingUserHandle = Binder.getCallingUserHandle();
                    long token = Binder.clearCallingIdentity();
                    try {
                        return new ParceledListSlice<>(
                                mPhoneAccountRegistrar.getPhoneAccounts(
                                        0 /* capabilities */,
                                        0 /* excludedCapabilities */,
                                        null /* UriScheme */,
                                        callingPackage,
                                        true /* includeDisabledAccounts */,
                                        callingUserHandle,
                                        hasCrossUserAccess /* crossUserAccess */,
                                        false /* includeAll */));
                    } catch (Exception e) {
                        Log.e(this, e, "getRegisteredPhoneAccounts");
                        throw e;
                    } finally {
                        Binder.restoreCallingIdentity(token);
                    }
                }
            } finally {
                Log.endSession();
            }
        }

        @Override
        public int getAllPhoneAccountsCount() {
            try {
@@ -3120,7 +3166,6 @@ public class TelecomServiceImpl {
                + " does not meet the requirements to access the phone number");
    }


    private boolean canReadPrivilegedPhoneState(String callingPackage, String message) {
        // The system/default dialer can always read phone state - so that emergency calls will
        // still work.