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

Commit 02e50ca2 authored by rambowang's avatar rambowang
Browse files

Update subscription services to support service capabilities

The CL mainly implements the changes below to support data-only service:
- Introduce a new internal field in SubInfoInternal to accommodate
the new service capability bitmasks in telephony.SimInfo table.
- Update SubscriptionDatabaseManager to get/set the db value.
- Modify SubscriptionManagerService to update service capabilities
value when the carrier config value has been overridden.

Bug: 296097429
Test: atest FrameworksTelephonyTests
Test: Basic functionality tests with flag on and off.
Change-Id: I5b91b3ab093e4b816382147790ef7a053f074533
parent c57f6f63
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -13,3 +13,10 @@ flag {
  description: "Enabled flag means subscriptions enforce filtering result base on calling user handle. It marks the telephony completion of user filtering."
  bug: "296076674"
}

flag {
  name: "data_only_cellular_service"
  namespace: "telephony"
  description: "Supports customized cellular service capabilities per subscription."
  bug: "296097429"
}
 No newline at end of file
+25 −3
Original line number Diff line number Diff line
@@ -281,7 +281,10 @@ public class SubscriptionDatabaseManager extends Handler {
                    SubscriptionInfoInternal::getSatelliteAttachEnabledForCarrier),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_IS_NTN,
                    SubscriptionInfoInternal::getOnlyNonTerrestrialNetwork)
                    SubscriptionInfoInternal::getOnlyNonTerrestrialNetwork),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_SERVICE_CAPABILITIES,
                    SubscriptionInfoInternal::getServiceCapabilities)
    );

    /**
@@ -412,7 +415,10 @@ public class SubscriptionDatabaseManager extends Handler {
                    SubscriptionDatabaseManager::setSatelliteAttachEnabledForCarrier),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_IS_NTN,
                    SubscriptionDatabaseManager::setNtn)
                    SubscriptionDatabaseManager::setNtn),
            new AbstractMap.SimpleImmutableEntry<>(
                    SimInfo.COLUMN_SERVICE_CAPABILITIES,
                    SubscriptionDatabaseManager::setServiceCapabilities)
    );

    /**
@@ -2073,6 +2079,19 @@ public class SubscriptionDatabaseManager extends Handler {
        }
    }

    /**
     * Set service capabilities the subscription support.
     * @param subId Subscription id.
     * @param capabilities Service capabilities bitmasks
     */
    public void setServiceCapabilities(int subId, int capabilities) {
        if (!mFeatureFlags.dataOnlyCellularService()) {
            return;
        }
        writeDatabaseAndCacheHelper(subId, SimInfo.COLUMN_SERVICE_CAPABILITIES,
                capabilities, SubscriptionInfoInternal.Builder::setServiceCapabilities);
    }

    /**
     * Reload the database from content provider to the cache. This must be a synchronous operation
     * to prevent cache/database out-of-sync. Callers should be cautious to call this method because
@@ -2302,7 +2321,10 @@ public class SubscriptionDatabaseManager extends Handler {
                        SimInfo.COLUMN_SATELLITE_ENABLED)))
                .setSatelliteAttachEnabledForCarrier(cursor.getInt(
                        cursor.getColumnIndexOrThrow(
                                SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER)));
                                SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER)))
                .setServiceCapabilities(cursor.getInt(
                        cursor.getColumnIndexOrThrow(
                                SimInfo.COLUMN_SERVICE_CAPABILITIES)));
        if (mFeatureFlags.oemEnabledSatelliteFlag()) {
            builder.setOnlyNonTerrestrialNetwork(cursor.getInt(cursor.getColumnIndexOrThrow(
                    SimInfo.COLUMN_IS_NTN)));
+36 −2
Original line number Diff line number Diff line
@@ -468,6 +468,11 @@ public class SubscriptionInfoInternal {
     */
    private final boolean mIsGroupDisabled;

    /**
     * Service capabilities (in the form of bitmask combination) the subscription supports.
     */
    private final int mServiceCapabilities;

    /**
     * Constructor from builder.
     *
@@ -543,6 +548,7 @@ public class SubscriptionInfoInternal {
        // Below are the fields that do not exist in the SimInfo table.
        this.mCardId = builder.mCardId;
        this.mIsGroupDisabled = builder.mIsGroupDisabled;
        this.mServiceCapabilities = builder.mServiceCapabilities;
    }

    /**
@@ -1193,6 +1199,13 @@ public class SubscriptionInfoInternal {
        return !isOpportunistic() || TextUtils.isEmpty(mGroupUuid);
    }

    /**
     * Return the service capabilities bitmasks the subscription supports.
     */
    public int getServiceCapabilities() {
        return mServiceCapabilities;
    }

    /** @return converted {@link SubscriptionInfo}. */
    @NonNull
    public SubscriptionInfo toSubscriptionInfo() {
@@ -1229,6 +1242,8 @@ public class SubscriptionInfoInternal {
                .setPortIndex(mPortIndex)
                .setUsageSetting(mUsageSetting)
                .setOnlyNonTerrestrialNetwork(mIsOnlyNonTerrestrialNetwork == 1)
                .setServiceCapabilities(
                        SubscriptionManager.getServiceCapabilitiesSet(mServiceCapabilities))
                .build();
    }

@@ -1288,6 +1303,7 @@ public class SubscriptionInfoInternal {
                + " satellite_attach_enabled_for_carrier=" + mIsSatelliteAttachEnabledForCarrier
                + " getOnlyNonTerrestrialNetwork=" + mIsOnlyNonTerrestrialNetwork
                + " isGroupDisabled=" + mIsGroupDisabled
                + " serviceCapabilities=" + mServiceCapabilities
                + "]";
    }

@@ -1344,7 +1360,8 @@ public class SubscriptionInfoInternal {
                that.mDeviceToDeviceStatusSharingContacts) && mNumberFromCarrier.equals(
                that.mNumberFromCarrier) && mNumberFromIms.equals(that.mNumberFromIms)
                && mIsSatelliteAttachEnabledForCarrier == that.mIsSatelliteAttachEnabledForCarrier
                && mIsOnlyNonTerrestrialNetwork == that.mIsOnlyNonTerrestrialNetwork;
                && mIsOnlyNonTerrestrialNetwork == that.mIsOnlyNonTerrestrialNetwork
                && mServiceCapabilities == that.mServiceCapabilities;
    }

    @Override
@@ -1366,7 +1383,8 @@ public class SubscriptionInfoInternal {
                mNumberFromCarrier,
                mNumberFromIms, mPortIndex, mUsageSetting, mLastUsedTPMessageReference, mUserId,
                mIsSatelliteEnabled, mCardId, mIsGroupDisabled,
                mIsSatelliteAttachEnabledForCarrier, mIsOnlyNonTerrestrialNetwork);
                mIsSatelliteAttachEnabledForCarrier, mIsOnlyNonTerrestrialNetwork,
                mServiceCapabilities);
        result = 31 * result + Arrays.hashCode(mNativeAccessRules);
        result = 31 * result + Arrays.hashCode(mCarrierConfigAccessRules);
        result = 31 * result + Arrays.hashCode(mRcsConfig);
@@ -1753,6 +1771,11 @@ public class SubscriptionInfoInternal {
         */
        private boolean mIsGroupDisabled;

        /**
         * Service capabilities the subscription supports
         */
        private int mServiceCapabilities;

        /**
         * Default constructor.
         */
@@ -1831,6 +1854,7 @@ public class SubscriptionInfoInternal {
            // Below are the fields that do not exist in the SimInfo table.
            mCardId = info.mCardId;
            mIsGroupDisabled = info.mIsGroupDisabled;
            mServiceCapabilities = info.mServiceCapabilities;
        }

        /**
@@ -2752,6 +2776,16 @@ public class SubscriptionInfoInternal {
            return this;
        }

        /**
         * Set the service capabilities the subscription supports.
         * @param capabilities Cellular service capabilities bitmasks
         * @return The builder
         */
        public Builder setServiceCapabilities(int capabilities) {
            mServiceCapabilities = capabilities;
            return this;
        }

        /**
         * Build the {@link SubscriptionInfoInternal}.
         *
+33 −0
Original line number Diff line number Diff line
@@ -1700,6 +1700,39 @@ public class SubscriptionManagerService extends ISub.Stub {
                            preferredUsageSetting)
                    + " newSetting=" + SubscriptionManager.usageSettingToString(newUsageSetting));
        }

        if (mFeatureFlags.dataOnlyCellularService()) {
            final int[] servicesFromCarrierConfig =
                    config.getIntArray(
                            CarrierConfigManager.KEY_CELLULAR_SERVICE_CAPABILITIES_INT_ARRAY);
            int serviceBitmasks = 0;
            boolean allServicesAreValid = true;
            // Check if all services from carrier config are valid before setting to db
            if (servicesFromCarrierConfig == null) {
                allServicesAreValid = false;
            } else {
                for (int service : servicesFromCarrierConfig) {
                    if (service < SubscriptionManager.SERVICE_CAPABILITY_VOICE
                            || service > SubscriptionManager.SERVICE_CAPABILITY_MAX) {
                        allServicesAreValid = false;
                        break;
                    } else {
                        serviceBitmasks |= SubscriptionManager.serviceCapabilityToBitmask(service);
                    }
                }
            }
            // In case we get invalid service override, fall back to default value.
            // DO NOT throw exception which will crash phone process.
            if (!allServicesAreValid) {
                serviceBitmasks = SubscriptionManager.getAllServiceCapabilityBitmasks();
            }

            if (serviceBitmasks != subInfo.getServiceCapabilities()) {
                log("updateSubscriptionByCarrierConfig: serviceCapabilities updated from "
                        + subInfo.getServiceCapabilities() + " to " + serviceBitmasks);
                mSubscriptionDatabaseManager.setServiceCapabilities(subId, serviceBitmasks);
            }
        }
    }

    /**
+2 −1
Original line number Diff line number Diff line
@@ -131,7 +131,8 @@ public class FakeTelephonyProvider extends MockContentProvider {
                    + Telephony.SimInfo.COLUMN_SATELLITE_ENABLED + " INTEGER DEFAULT 0,"
                    + Telephony.SimInfo.COLUMN_SATELLITE_ATTACH_ENABLED_FOR_CARRIER
                    + " INTEGER DEFAULT 0, "
                    + Telephony.SimInfo.COLUMN_IS_NTN + " INTEGER DEFAULT 0"
                    + Telephony.SimInfo.COLUMN_IS_NTN + " INTEGER DEFAULT 0,"
                    + Telephony.SimInfo.COLUMN_SERVICE_CAPABILITIES + " INTEGER DEFAULT 7"
                    + ");";
        }

Loading