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

Commit c377217d authored by zachh's avatar zachh Committed by Copybara-Service
Browse files

Use application context when fetching shared prefs.

Using non-application contexts incurs extra disk access because shared prefs are cached per context.

Test: manually ejected sim and observed no strict mode violations
PiperOrigin-RevId: 183739285
Change-Id: I9337e226ae1e060478219cf495752ceccf5a31e6
parent f27f1bd0
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -197,14 +197,14 @@ public class OmtpService extends VisualVoicemailService {
  }

  private static void setShuttingDown(Context context, boolean value) {
    PreferenceManager.getDefaultSharedPreferences(context)
    PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext())
        .edit()
        .putBoolean(IS_SHUTTING_DOWN, value)
        .apply();
  }

  private static boolean isShuttingDown(Context context) {
    return PreferenceManager.getDefaultSharedPreferences(context)
    return PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext())
        .getBoolean(IS_SHUTTING_DOWN, false);
  }
}
+1 −1
Original line number Diff line number Diff line
@@ -31,7 +31,7 @@ public class VisualVoicemailPreferences extends PerAccountSharedPreferences {
    super(
        context,
        phoneAccountHandle,
        PreferenceManager.getDefaultSharedPreferences(context),
        PreferenceManager.getDefaultSharedPreferences(context.getApplicationContext()),
        "visual_voicemail_");
  }
}