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

Commit 1220b04a authored by Ayush Sharma's avatar Ayush Sharma Committed by Android (Google) Code Review
Browse files

Merge "Revert "Construct EnterpriseSpecificIdCalculator only once after the boot phase""

parents 90c2d2f6 422e9b4e
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -13736,8 +13736,6 @@ public class DevicePolicyManager {
     *
     * It is recommended that the Enterprise ID is at least 6 characters long, and no more than
     * 64 characters.
     * This API is supposed to be called only after the boot phase is complete,
     * throws {@link IllegalStateException} if called before boot phase is complete.
     *
     * @param enterpriseId An identifier of the organization this work profile or device is
     *                     enrolled into.
+4 −12
Original line number Diff line number Diff line
@@ -648,7 +648,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    private final DevicePolicyCacheImpl mPolicyCache = new DevicePolicyCacheImpl();
    private final DeviceStateCacheImpl mStateCache = new DeviceStateCacheImpl();
    private EnterpriseSpecificIdCalculator mEsidCalculator;
    /**
     * Contains (package-user) pairs to remove. An entry (p, u) implies that removal of package p
@@ -1474,10 +1473,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
            return new LockPatternUtils(mContext);
        }
        EnterpriseSpecificIdCalculator newEnterpriseSpecificIdCalculator() {
            return new EnterpriseSpecificIdCalculator(mContext);
        }
        boolean storageManagerIsFileBasedEncryptionEnabled() {
            return StorageManager.isFileEncryptedNativeOnly();
        }
@@ -3126,10 +3121,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                factoryResetIfDelayedEarlier();
                ensureDeviceOwnerUserStarted(); // TODO Consider better place to do this.
                // This is constructed here as EnterpriseSpecificIdCalculator depends on telephony
                // and wifi service and these services are only fully available at this stage.
                mEsidCalculator = mInjector.newEnterpriseSpecificIdCalculator();
                break;
        }
    }
@@ -16927,8 +16918,6 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
    @Override
    public void setOrganizationIdForUser(
            @NonNull String callerPackage, @NonNull String organizationId, int userId) {
        Preconditions.checkState(mEsidCalculator != null,
                "setOrganizationIdForUser can't be called before boot phase completion");
        if (!mHasFeature) {
            return;
        }
@@ -16962,7 +16951,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
                            + "be changed");
            final String dpcPackage = owner.info.getPackageName();
            mInjector.binderWithCleanCallingIdentity(() -> {
                final String esid = mEsidCalculator.calculateEnterpriseId(dpcPackage,
                EnterpriseSpecificIdCalculator esidCalculator =
                        new EnterpriseSpecificIdCalculator(mContext);
                final String esid = esidCalculator.calculateEnterpriseId(dpcPackage,
                        organizationId);
                owner.mOrganizationId = organizationId;
                owner.mEnrollmentSpecificId = esid;
+5 −11
Original line number Diff line number Diff line
@@ -51,19 +51,13 @@ class EnterpriseSpecificIdCalculator {

    EnterpriseSpecificIdCalculator(Context context) {
        TelephonyManager telephonyService = context.getSystemService(TelephonyManager.class);
        if (telephonyService != null) {
        Preconditions.checkState(telephonyService != null, "Unable to access telephony service");
        mImei = telephonyService.getImei(0);
        mMeid = telephonyService.getMeid(0);
        } else {
            mImei = "";
            mMeid = "";
        }
        mSerialNumber = Build.getSerial();
        WifiManager wifiManager = context.getSystemService(WifiManager.class);
        String[] macAddresses = null;
        if (wifiManager != null) {
            macAddresses = wifiManager.getFactoryMacAddresses();
        }
        Preconditions.checkState(wifiManager != null, "Unable to access WiFi service");
        final String[] macAddresses = wifiManager.getFactoryMacAddresses();
        if (macAddresses == null || macAddresses.length == 0) {
            mMacAddress = "";
        } else {