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

Commit d80d854a authored by Grace Jia's avatar Grace Jia
Browse files

Implement set D2D sharing status API in SubscriptionController.

Test: cts test
Bug: 163085177
Change-Id: I0263030b03c3f5de845a9565b03fc701c1f581aa
Merged-In: I0263030b03c3f5de845a9565b03fc701c1f581aa
parent b43d5881
Loading
Loading
Loading
Loading
+38 −0
Original line number Diff line number Diff line
@@ -2099,6 +2099,43 @@ public class SubscriptionController extends ISub.Stub {
        }
    }

    /**
     * Set device to device status sharing preference
     * @param sharing the sharing preference to set
     * @param subId
     * @return the number of records updated
     */
    @Override
    public int setDeviceToDeviceStatusSharing(int sharing, int subId) {
        if (DBG) logd("[setDeviceToDeviceStatusSharing]- sharing:" + sharing + " subId:" + subId);

        enforceModifyPhoneState("setDeviceToDeviceStatusSharing");

        // Now that all security checks passes, perform the operation as ourselves.
        final long identity = Binder.clearCallingIdentity();
        try {
            validateSubId(subId);
            if (sharing < 0) {
                if (DBG) logd("[setDeviceToDeviceStatusSharing]- fail");
                return -1;
            }
            ContentValues value = new ContentValues(1);
            value.put(SubscriptionManager.D2D_STATUS_SHARING, sharing);
            if (DBG) logd("[setDeviceToDeviceStatusSharing]- sharing:" + sharing + " set");

            int result = updateDatabase(value, subId, true);

            // Refresh the Cache of Active Subscription Info List
            refreshCachedActiveSubscriptionInfoList();

            notifySubscriptionInfoChanged();

            return result;
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
    }

    public void syncGroupedSetting(int refSubId) {
        logd("syncGroupedSetting");
        try (Cursor cursor = mContext.getContentResolver().query(
@@ -3116,6 +3153,7 @@ public class SubscriptionController extends ISub.Stub {
                        case SubscriptionManager.DATA_ENABLED_OVERRIDE_RULES:
                        case SubscriptionManager.ALLOWED_NETWORK_TYPES:
                        case SubscriptionManager.VOIMS_OPT_IN_STATUS:
                        case SubscriptionManager.D2D_STATUS_SHARING:
                            resultValue = cursor.getString(0);
                            break;
                        default:
+2 −1
Original line number Diff line number Diff line
@@ -115,7 +115,8 @@ public class FakeTelephonyProvider extends MockContentProvider {
                    + Telephony.SimInfo.COLUMN_ALLOWED_NETWORK_TYPES + " BIGINT DEFAULT -1,"
                    + Telephony.SimInfo.COLUMN_IMS_RCS_UCE_ENABLED + " INTEGER DEFAULT 0, "
                    + Telephony.SimInfo.COLUMN_RCS_CONFIG + " BLOB,"
                    + Telephony.SimInfo.COLUMN_ALLOWED_NETWORK_TYPES_FOR_REASONS + " TEXT"
                    + Telephony.SimInfo.COLUMN_ALLOWED_NETWORK_TYPES_FOR_REASONS + " TEXT,"
                    + Telephony.SimInfo.COLUMN_D2D_STATUS_SHARING + " INTEGER DEFAULT 0"
                    + ");";
        }