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

Commit 4cef64ab authored by Guojing Yuan's avatar Guojing Yuan
Browse files

[Perm Sync] Remove old feature flag

Bug: 193583135

Test: m and CTS
Change-Id: I00f7c63ebb5f3b11b8a5ad2b29b03365c932d05a
parent f997cb4b
Loading
Loading
Loading
Loading
+0 −52
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.companion.utils;

import android.os.Binder;
import android.os.Build;
import android.provider.DeviceConfig;

/**
 * Util class for feature flags
 *
 * @hide
 */
public final class FeatureUtils {

    private static final String NAMESPACE_COMPANION = "companion";

    private static final String PROPERTY_PERM_SYNC_ENABLED = "perm_sync_enabled";

    public static boolean isPermSyncEnabled() {
        // Permissions sync is always enabled in debuggable mode.
        if (Build.isDebuggable()) {
            return true;
        }

        // Clear app identity to read the device config for feature flag.
        final long identity = Binder.clearCallingIdentity();
        try {
            return DeviceConfig.getBoolean(NAMESPACE_COMPANION,
                    PROPERTY_PERM_SYNC_ENABLED, false);
        } finally {
            Binder.restoreCallingIdentity(identity);
        }
    }

    private FeatureUtils() {
    }
}
+0 −10
Original line number Diff line number Diff line
@@ -75,7 +75,6 @@ import android.companion.IOnMessageReceivedListener;
import android.companion.IOnTransportsChangedListener;
import android.companion.ISystemDataTransferCallback;
import android.companion.datatransfer.PermissionSyncRequest;
import android.companion.utils.FeatureUtils;
import android.content.ComponentName;
import android.content.Context;
import android.content.SharedPreferences;
@@ -825,11 +824,6 @@ public class CompanionDeviceManagerService extends SystemService {
        @Override
        public PendingIntent buildPermissionTransferUserConsentIntent(String packageName,
                int userId, int associationId) {
            if (!FeatureUtils.isPermSyncEnabled()) {
                throw new UnsupportedOperationException("Calling"
                        + " buildPermissionTransferUserConsentIntent, but this API is disabled by"
                        + " the system.");
            }
            return mSystemDataTransferProcessor.buildPermissionTransferUserConsentIntent(
                    packageName, userId, associationId);
        }
@@ -837,10 +831,6 @@ public class CompanionDeviceManagerService extends SystemService {
        @Override
        public void startSystemDataTransfer(String packageName, int userId, int associationId,
                ISystemDataTransferCallback callback) {
            if (!FeatureUtils.isPermSyncEnabled()) {
                throw new UnsupportedOperationException("Calling startSystemDataTransfer, but this"
                        + " API is disabled by the system.");
            }
            mSystemDataTransferProcessor.startSystemDataTransfer(packageName, userId,
                    associationId, callback);
        }