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

Commit 7cfd0bca authored by Automerger Merge Worker's avatar Automerger Merge Worker
Browse files

Merge "Remove old implementation of NitzStateMachine" into rvc-dev am: cf4f62c6

Change-Id: I48521304739a80950d792c21aea89a3f1e75546d
parents a0c85e98 cf4f62c6
Loading
Loading
Loading
Loading
+0 −625

File deleted.

Preview size limit exceeded, changes collapsed.

+2 −6
Original line number Original line Diff line number Diff line
@@ -39,7 +39,7 @@ import com.android.internal.telephony.emergency.EmergencyNumberTracker;
import com.android.internal.telephony.imsphone.ImsExternalCallTracker;
import com.android.internal.telephony.imsphone.ImsExternalCallTracker;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhone;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.imsphone.ImsPhoneCallTracker;
import com.android.internal.telephony.nitz.NewNitzStateMachineImpl;
import com.android.internal.telephony.nitz.NitzStateMachineImpl;
import com.android.internal.telephony.uicc.IccCardStatus;
import com.android.internal.telephony.uicc.IccCardStatus;
import com.android.internal.telephony.uicc.UiccCard;
import com.android.internal.telephony.uicc.UiccCard;
import com.android.internal.telephony.uicc.UiccProfile;
import com.android.internal.telephony.uicc.UiccProfile;
@@ -295,11 +295,7 @@ public class TelephonyComponentFactory {
     * Returns a new {@link NitzStateMachine} instance.
     * Returns a new {@link NitzStateMachine} instance.
     */
     */
    public NitzStateMachine makeNitzStateMachine(GsmCdmaPhone phone) {
    public NitzStateMachine makeNitzStateMachine(GsmCdmaPhone phone) {
        if (USE_NEW_NITZ_STATE_MACHINE) {
        return NitzStateMachineImpl.createInstance(phone);
            return NewNitzStateMachineImpl.createInstance(phone);
        } else {
            return new NitzStateMachineImpl(phone);
        }
    }
    }


    public SimActivationTracker makeSimActivationTracker(Phone phone) {
    public SimActivationTracker makeSimActivationTracker(Phone phone) {
+0 −69
Original line number Original line Diff line number Diff line
/*
 * Copyright 2017 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 com.android.internal.telephony;

import android.app.timedetector.TelephonyTimeSuggestion;
import android.app.timedetector.TimeDetector;

/**
 * An interface to various time / time zone detection behaviors that should be centralized into a
 * new service.
 */
public interface TimeServiceHelper {

    /**
     * Callback interface for automatic detection enable/disable changes.
     */
    interface Listener {
        /**
         * Automatic time zone detection has been enabled or disabled.
         */
        void onTimeZoneDetectionChange(boolean enabled);
    }

    /**
     * Sets a listener that will be called when the automatic time / time zone detection setting
     * changes.
     */
    void setListener(Listener listener);

    /**
     * Returns true if the device has an explicit time zone set.
     */
    boolean isTimeZoneSettingInitialized();

    /**
     * Returns true if automatic time zone detection is enabled in settings.
     */
    boolean isTimeZoneDetectionEnabled();

    /**
     * Set the device time zone and send out a sticky broadcast so the system can
     * determine if the timezone was set by the carrier.
     *
     * @param zoneId timezone set by carrier
     */
    void setDeviceTimeZone(String zoneId);

    /**
     * Suggest the time to the {@link TimeDetector}.
     *
     * @param timeSuggestion the suggested time
     */
    void suggestDeviceTime(TelephonyTimeSuggestion timeSuggestion);

}
+0 −102
Original line number Original line Diff line number Diff line
/*
 * Copyright 2019 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 com.android.internal.telephony;

import android.app.AlarmManager;
import android.app.timedetector.TelephonyTimeSuggestion;
import android.app.timedetector.TimeDetector;
import android.content.ContentResolver;
import android.content.Context;
import android.database.ContentObserver;
import android.os.Handler;
import android.os.SystemProperties;
import android.provider.Settings;

/**
 * An interface to various time / time zone detection behaviors that should be centralized into a
 * new service.
 */
public final class TimeServiceHelperImpl implements TimeServiceHelper {

    private static final String TIMEZONE_PROPERTY = "persist.sys.timezone";

    private final Context mContext;
    private final ContentResolver mCr;
    private final TimeDetector mTimeDetector;

    private Listener mListener;

    /** Creates a TimeServiceHelper */
    public TimeServiceHelperImpl(Context context) {
        mContext = context;
        mCr = context.getContentResolver();
        mTimeDetector = context.getSystemService(TimeDetector.class);
    }

    @Override
    public void setListener(Listener listener) {
        if (listener == null) {
            throw new NullPointerException("listener==null");
        }
        if (mListener != null) {
            throw new IllegalStateException("listener already set");
        }
        this.mListener = listener;
        mCr.registerContentObserver(
                Settings.Global.getUriFor(Settings.Global.AUTO_TIME_ZONE), true,
                new ContentObserver(new Handler()) {
                    public void onChange(boolean selfChange) {
                        listener.onTimeZoneDetectionChange(isTimeZoneDetectionEnabled());
                    }
                });
    }

    @Override
    public boolean isTimeZoneSettingInitialized() {
        // timezone.equals("GMT") will be true and only true if the timezone was
        // set to a default value by the system server (when starting, system server
        // sets the persist.sys.timezone to "GMT" if it's not set). "GMT" is not used by
        // any code that sets it explicitly (in case where something sets GMT explicitly,
        // "Etc/GMT" Olsen ID would be used).
        // TODO(b/64056758): Remove "timezone.equals("GMT")" hack when there's a
        // better way of telling if the value has been defaulted.

        String timeZoneId = SystemProperties.get(TIMEZONE_PROPERTY);
        return timeZoneId != null && timeZoneId.length() > 0 && !timeZoneId.equals("GMT");

    }

    @Override
    public boolean isTimeZoneDetectionEnabled() {
        try {
            return Settings.Global.getInt(mCr, Settings.Global.AUTO_TIME_ZONE) > 0;
        } catch (Settings.SettingNotFoundException snfe) {
            return true;
        }
    }

    @Override
    public void setDeviceTimeZone(String zoneId) {
        AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
        alarmManager.setTimeZone(zoneId);
    }

    @Override
    public void suggestDeviceTime(TelephonyTimeSuggestion timeSuggestion) {
        mTimeDetector.suggestTelephonyTime(timeSuggestion);
    }
}
+4 −4
Original line number Original line Diff line number Diff line
@@ -26,7 +26,7 @@ import android.os.TimestampedValue;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.telephony.NitzData;
import com.android.internal.telephony.NitzData;
import com.android.internal.telephony.NitzStateMachine.DeviceState;
import com.android.internal.telephony.NitzStateMachine.DeviceState;
import com.android.internal.telephony.nitz.NewNitzStateMachineImpl.NitzSignalInputFilterPredicate;
import com.android.internal.telephony.nitz.NitzStateMachineImpl.NitzSignalInputFilterPredicate;
import com.android.telephony.Rlog;
import com.android.telephony.Rlog;


import java.util.Arrays;
import java.util.Arrays;
@@ -34,14 +34,14 @@ import java.util.Objects;


/**
/**
 * A factory class for the {@link NitzSignalInputFilterPredicate} instance used by
 * A factory class for the {@link NitzSignalInputFilterPredicate} instance used by
 * {@link NewNitzStateMachineImpl}. This class is exposed for testing and provides access to various
 * {@link NitzStateMachineImpl}. This class is exposed for testing and provides access to various
 * internal components.
 * internal components.
 */
 */
@VisibleForTesting
@VisibleForTesting
public final class NitzSignalInputFilterPredicateFactory {
public final class NitzSignalInputFilterPredicateFactory {


    private static final String LOG_TAG = NewNitzStateMachineImpl.LOG_TAG;
    private static final String LOG_TAG = NitzStateMachineImpl.LOG_TAG;
    private static final boolean DBG = NewNitzStateMachineImpl.DBG;
    private static final boolean DBG = NitzStateMachineImpl.DBG;
    private static final String WAKELOCK_TAG = "NitzSignalInputFilterPredicateFactory";
    private static final String WAKELOCK_TAG = "NitzSignalInputFilterPredicateFactory";


    private NitzSignalInputFilterPredicateFactory() {}
    private NitzSignalInputFilterPredicateFactory() {}
Loading