Remove injecting developer options into Settings itself

- It can improve performance because we use less injected item
- Also use RestrictedPreference instead just checking restrictions,
  so we follow policy transparency.

Note: Renamed DevelopmentSettingsDashboardActivity to
DevelopmentSettingsActivity,
because DevelopmentSettingsDashboardActivity could in disabled state
even after Settings upgrades, use a new name to prevent this issue.

Bug: 311604902
Test: manual - turn on / off Developer Options
Test: unit test
Change-Id: I17be117ae59e59410687e6d08fd5edd034d0508f
This commit is contained in:
Chaohui Wang
2023-11-24 00:15:17 +08:00
parent c9ccf861c6
commit ee7139a889
9 changed files with 177 additions and 128 deletions

View File

@@ -47,6 +47,7 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.Toast;
import androidx.annotation.VisibleForTesting;
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
@@ -230,6 +231,12 @@ public class DevelopmentSettingsDashboardFragment extends RestrictedDashboardFra
getActivity().finish();
return;
}
Context context = requireContext();
if (!DevelopmentSettingsEnabler.isDevelopmentSettingsEnabled(context)) {
Toast.makeText(context, R.string.dev_settings_disabled_warning, Toast.LENGTH_SHORT)
.show();
finish();
}
}
@Override

View File

@@ -1,32 +0,0 @@
/*
* Copyright (C) 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.settings.development;
import android.app.Activity;
import android.os.Bundle;
import android.widget.Toast;
import com.android.settings.R;
public class DevelopmentSettingsDisabledActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Toast.makeText(this, R.string.dev_settings_disabled_warning, Toast.LENGTH_SHORT).show();
finish();
}
}