Refine WifiTetherSoftApManager and DataSaverBackend to avoid activity leaks
- Declare the service callback as static class and use WeakReference to avoid the callback link being occupied - Use application context instead of fragment context to avoid context being occupied by external modules Bug: 237273138 Test: manual test make RunSettingsRoboTests ROBOTEST_FILTER=TetherSettingsTest make RunSettingsRoboTests ROBOTEST_FILTER=WifiTetherPreferenceControllerTest Change-Id: Icca145b8ef08b9949feafbbd4e761f8d50c99181
This commit is contained in:
@@ -56,8 +56,9 @@ public class WifiTetherPreferenceController extends AbstractPreferenceController
|
||||
WifiTetherSoftApManager mWifiTetherSoftApManager;
|
||||
|
||||
public WifiTetherPreferenceController(Context context, Lifecycle lifecycle) {
|
||||
// TODO(b/246537032):Use fragment context to WifiManager service will caused memory leak
|
||||
this(context, lifecycle,
|
||||
context.getSystemService(WifiManager.class),
|
||||
context.getApplicationContext().getSystemService(WifiManager.class),
|
||||
context.getSystemService(TetheringManager.class),
|
||||
true /* initSoftApManager */,
|
||||
WifiEnterpriseRestrictionUtils.isWifiTetheringAllowed(context));
|
||||
|
Reference in New Issue
Block a user