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

Commit 1395dffd authored by Neil Fuller's avatar Neil Fuller Committed by Almaz Mingaleev
Browse files

Make manual suggestions synchronous/return result

Modify the suggestManual...() methods on TimeDetector and
TimeZoneDetector to be synchronous, and have them return true/false to
indicate if the call "succeeded". This is being done before adding more
calls that will be used by apps like SettingsUI; generally all calls
that are user facing and could conceivably fail should return
success/failure information and therefore need to happen synchronously.

Test: atest services/tests/servicestests/src/com/android/server/timedetector/
Test: atest services/tests/servicestests/src/com/android/server/timezonedetector/
Bug: 140712361
Merged-In: I5b6b7fb5af2ffe88392b2ca8d1e8fff2a187521b
Change-Id: I5b6b7fb5af2ffe88392b2ca8d1e8fff2a187521b
parent 1fe717a5
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ import android.app.timedetector.TelephonyTimeSuggestion;
 * {@hide}
 */
interface ITimeDetectorService {
  void suggestManualTime(in ManualTimeSuggestion timeSuggestion);
  boolean suggestManualTime(in ManualTimeSuggestion timeSuggestion);
  void suggestNetworkTime(in NetworkTimeSuggestion timeSuggestion);
  void suggestTelephonyTime(in TelephonyTimeSuggestion timeSuggestion);
}
+6 −2
Original line number Diff line number Diff line
@@ -53,12 +53,16 @@ public interface TimeDetector {
    void suggestTelephonyTime(@NonNull TelephonyTimeSuggestion timeSuggestion);

    /**
     * Suggests the user's manually entered current time to the detector.
     * Suggests the current time, determined from the user's manually entered information, to
     * the detector. Returns {@code false} if the suggestion was invalid, or the device
     * configuration prevented the suggestion being used, {@code true} if the suggestion was
     * accepted. A suggestion that is valid but does not change the time because it matches the
     * current device time is considered accepted.
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.SUGGEST_MANUAL_TIME_AND_ZONE)
    void suggestManualTime(@NonNull ManualTimeSuggestion timeSuggestion);
    boolean suggestManualTime(@NonNull ManualTimeSuggestion timeSuggestion);

    /**
     * Suggests the time according to a network time source like NTP.
+2 −2
Original line number Diff line number Diff line
@@ -52,12 +52,12 @@ public final class TimeDetectorImpl implements TimeDetector {
    }

    @Override
    public void suggestManualTime(@NonNull ManualTimeSuggestion timeSuggestion) {
    public boolean suggestManualTime(@NonNull ManualTimeSuggestion timeSuggestion) {
        if (DEBUG) {
            Log.d(TAG, "suggestManualTime called: " + timeSuggestion);
        }
        try {
            mITimeDetectorService.suggestManualTime(timeSuggestion);
            return mITimeDetectorService.suggestManualTime(timeSuggestion);
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
+1 −1
Original line number Diff line number Diff line
@@ -33,6 +33,6 @@ import android.app.timezonedetector.TelephonyTimeZoneSuggestion;
 * {@hide}
 */
interface ITimeZoneDetectorService {
  void suggestManualTimeZone(in ManualTimeZoneSuggestion timeZoneSuggestion);
  boolean suggestManualTimeZone(in ManualTimeZoneSuggestion timeZoneSuggestion);
  void suggestTelephonyTimeZone(in TelephonyTimeZoneSuggestion timeZoneSuggestion);
}
+6 −3
Original line number Diff line number Diff line
@@ -41,13 +41,16 @@ public interface TimeZoneDetector {
    }

    /**
     * Suggests the current time zone, determined using the user's manually entered information, to
     * the detector. The detector may ignore the signal based on system settings.
     * Suggests the current time zone, determined from the user's manually entered information, to
     * the detector. Returns {@code false} if the suggestion was invalid, or the device
     * configuration prevented the suggestion being used, {@code true} if the suggestion was
     * accepted. A suggestion that is valid but does not change the time zone because it matches
     * the current device time zone is considered accepted.
     *
     * @hide
     */
    @RequiresPermission(android.Manifest.permission.SUGGEST_MANUAL_TIME_AND_ZONE)
    void suggestManualTimeZone(@NonNull ManualTimeZoneSuggestion timeZoneSuggestion);
    boolean suggestManualTimeZone(@NonNull ManualTimeZoneSuggestion timeZoneSuggestion);

    /**
     * Suggests the current time zone, determined using telephony signals, to the detector. The
Loading