Listen Developer option enable state
- When developer option disabled, any page in Developer option should be closed. Bug: 293894425 Test: manual Change-Id: I392b122e885118770be1af2b51c0c7ef92279e1b
This commit is contained in:
@@ -32,7 +32,8 @@ import java.util.List;
|
||||
* Fragment shown when clicking on a paired device in the Wireless
|
||||
* Debugging fragment.
|
||||
*/
|
||||
public class AdbDeviceDetailsFragment extends DashboardFragment {
|
||||
public class AdbDeviceDetailsFragment extends DashboardFragment implements
|
||||
DeveloperOptionAwareMixin {
|
||||
private static final String TAG = "AdbDeviceDetailsFrag";
|
||||
private PairDevice mPairedDevice;
|
||||
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*
|
||||
* Copyright (C) 2024 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.settings.development;
|
||||
|
||||
/** A fragment mixin that should aware the state of developer options */
|
||||
public interface DeveloperOptionAwareMixin {}
|
||||
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2024 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.settings.development;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Application;
|
||||
import android.os.Bundle;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settingslib.development.DevelopmentSettingsEnabler;
|
||||
|
||||
public class DeveloperOptionsActivityLifecycle implements Application.ActivityLifecycleCallbacks {
|
||||
|
||||
private FragmentManager.FragmentLifecycleCallbacks mFragmentCallback =
|
||||
new FragmentManager.FragmentLifecycleCallbacks() {
|
||||
@Override
|
||||
public void onFragmentResumed(@NonNull FragmentManager fm, @NonNull Fragment f) {
|
||||
if (!(f instanceof DeveloperOptionAwareMixin)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Activity activity = f.getActivity();
|
||||
if (activity == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(activity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (fm.getBackStackEntryCount() > 0) {
|
||||
fm.popBackStack();
|
||||
} else {
|
||||
activity.finish();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public DeveloperOptionsActivityLifecycle() {}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
|
||||
if (!(activity instanceof SettingsActivity)) {
|
||||
return;
|
||||
}
|
||||
|
||||
FragmentManager fm = ((SettingsActivity) activity).getSupportFragmentManager();
|
||||
fm.registerFragmentLifecycleCallbacks(mFragmentCallback, /* recursive= */ true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStarted(@NonNull Activity activity) {}
|
||||
|
||||
@Override
|
||||
public void onActivityResumed(@NonNull Activity activity) {}
|
||||
|
||||
@Override
|
||||
public void onActivityPaused(@NonNull Activity activity) {}
|
||||
|
||||
@Override
|
||||
public void onActivityStopped(@NonNull Activity activity) {}
|
||||
|
||||
@Override
|
||||
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {}
|
||||
|
||||
@Override
|
||||
public void onActivityDestroyed(@NonNull Activity activity) {}
|
||||
}
|
||||
@@ -39,7 +39,8 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
public class DevelopmentAppPicker extends DefaultAppPickerFragment {
|
||||
public class DevelopmentAppPicker extends DefaultAppPickerFragment implements
|
||||
DeveloperOptionAwareMixin {
|
||||
public static final String EXTRA_REQUESTING_PERMISSION = "REQUESTING_PERMISSION";
|
||||
public static final String EXTRA_DEBUGGABLE = "DEBUGGABLE";
|
||||
public static final String EXTRA_SELECTING_APP = "SELECTING_APP";
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
@SearchIndexable
|
||||
public class DevelopmentMemtagPage extends DashboardFragment {
|
||||
public class DevelopmentMemtagPage extends DashboardFragment implements DeveloperOptionAwareMixin {
|
||||
private static final String TAG = "DevelopmentMemtagPage";
|
||||
|
||||
@Override
|
||||
|
||||
@@ -216,6 +216,14 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
||||
super.onStart();
|
||||
final ContentResolver cr = getContext().getContentResolver();
|
||||
cr.registerContentObserver(mDevelopEnabled, false, mDeveloperSettingsObserver);
|
||||
|
||||
// Restore UI state based on whether developer options is enabled
|
||||
if (DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(getContext())) {
|
||||
enableDeveloperOptions();
|
||||
handleQsTileLongPressActionIfAny();
|
||||
} else {
|
||||
disableDeveloperOptions();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -272,14 +280,6 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
|
||||
mSwitchBarController = new DevelopmentSwitchBarController(
|
||||
this /* DevelopmentSettings */, mSwitchBar, mIsAvailable,
|
||||
getSettingsLifecycle());
|
||||
|
||||
// Restore UI state based on whether developer options is enabled
|
||||
if (DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(getContext())) {
|
||||
enableDeveloperOptions();
|
||||
handleQsTileLongPressActionIfAny();
|
||||
} else {
|
||||
disableDeveloperOptions();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -61,7 +61,7 @@ import java.util.Map;
|
||||
*/
|
||||
@SearchIndexable
|
||||
public class WirelessDebuggingFragment extends DashboardFragment
|
||||
implements WirelessDebuggingEnabler.OnEnabledListener {
|
||||
implements WirelessDebuggingEnabler.OnEnabledListener, DeveloperOptionAwareMixin {
|
||||
|
||||
private static final String TAG = "WirelessDebuggingFrag";
|
||||
|
||||
|
||||
@@ -22,8 +22,8 @@ import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.development.DeveloperOptionAwareMixin;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.search.Indexable;
|
||||
import com.android.settingslib.development.DevelopmentSettingsEnabler;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
@@ -31,7 +31,8 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@SearchIndexable
|
||||
public class FeatureFlagsDashboard extends DashboardFragment {
|
||||
public class FeatureFlagsDashboard extends DashboardFragment implements
|
||||
DeveloperOptionAwareMixin {
|
||||
|
||||
private static final String TAG = "FeatureFlagsDashboard";
|
||||
|
||||
@@ -50,11 +51,6 @@ public class FeatureFlagsDashboard extends DashboardFragment {
|
||||
return R.xml.feature_flags_settings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttach(Context context) {
|
||||
super.onAttach(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHelpResource() {
|
||||
return 0;
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.os.Bundle;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.development.DeveloperOptionAwareMixin;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.widget.MainSwitchBarController;
|
||||
import com.android.settings.widget.SettingsMainSwitchBar;
|
||||
@@ -33,7 +34,8 @@ import com.android.settingslib.search.SearchIndexable;
|
||||
* Dashboard for Graphics Driver preferences.
|
||||
*/
|
||||
@SearchIndexable
|
||||
public class GraphicsDriverDashboard extends DashboardFragment {
|
||||
public class GraphicsDriverDashboard extends DashboardFragment implements
|
||||
DeveloperOptionAwareMixin {
|
||||
|
||||
private static final String TAG = "GraphicsDriverDashboard";
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.os.SystemProperties;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.development.DeveloperOptionAwareMixin;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.development.DevelopmentSettingsEnabler;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
@@ -35,7 +36,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SearchIndexable
|
||||
public class DevelopmentTileConfigFragment extends DashboardFragment {
|
||||
public class DevelopmentTileConfigFragment extends DashboardFragment implements
|
||||
DeveloperOptionAwareMixin {
|
||||
private static final String TAG = "DevelopmentTileConfig";
|
||||
private static final String QS_TILE_PERF = "develop_qs_tile";
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import android.provider.SearchIndexableResource;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.development.DeveloperOptionAwareMixin;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.development.DevelopmentSettingsEnabler;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
@@ -32,7 +33,8 @@ import java.util.List;
|
||||
* Bluetooth Snoop Logger Filters Dashboard
|
||||
*/
|
||||
@SearchIndexable
|
||||
public class SnoopLoggerFiltersDashboard extends DashboardFragment {
|
||||
public class SnoopLoggerFiltersDashboard extends DashboardFragment implements
|
||||
DeveloperOptionAwareMixin {
|
||||
|
||||
private static final String TAG = "SnoopLoggerFiltersDashboard";
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.development.DeveloperOptionAwareMixin;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.development.DevelopmentSettingsEnabler;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
@@ -29,7 +30,8 @@ import com.android.settingslib.search.SearchIndexable;
|
||||
* Fragment for native transcode settings in Developer options.
|
||||
*/
|
||||
@SearchIndexable
|
||||
public class TranscodeSettingsFragment extends DashboardFragment {
|
||||
public class TranscodeSettingsFragment extends DashboardFragment implements
|
||||
DeveloperOptionAwareMixin {
|
||||
private static final String TAG = "TranscodeSettings";
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.content.Context;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.development.DeveloperOptionAwareMixin;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.development.DevelopmentSettingsEnabler;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
@@ -29,7 +30,8 @@ import com.android.settingslib.search.SearchIndexable;
|
||||
* Fragment for native widevine settings in Developer options.
|
||||
*/
|
||||
@SearchIndexable
|
||||
public class WidevineSettingsFragment extends DashboardFragment {
|
||||
public class WidevineSettingsFragment extends DashboardFragment implements
|
||||
DeveloperOptionAwareMixin {
|
||||
private static final String TAG = "WidevineSettings";
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user