Misc cleanup on AndroidManifest.xml

- Add a few activities to widget list. These are more commonly
  used settings, so adding them to widget list for easier access.
  - Storage
  - System
  - About phone

- Remove useless intent-filters from AndroidManifest.
  - If the intent-filter is just action MAIN and category DEFAULT, it
   doesn't do anything.

Bug: 74806595
Test: visual
Change-Id: I5d80bc6c88f7bf60adabac872e92b72b341b97e6
This commit is contained in:
Fan Zhang
2018-06-21 15:34:43 -07:00
parent 67e501c8d2
commit 2f4355aa66
8 changed files with 207 additions and 199 deletions

View File

@@ -173,8 +173,12 @@ public class DeviceAdminListPreferenceController extends BasePreferenceControlle
final Context prefContext = mPreferenceGroup.getContext();
final int childrenCount = mPreferenceGroup.getPreferenceCount();
for (int i = 0; i < childrenCount; i++) {
SwitchPreference pref = (SwitchPreference) mPreferenceGroup.getPreference(i);
preferenceCache.put(pref.getKey(), pref);
final Preference pref = mPreferenceGroup.getPreference(i);
if (!(pref instanceof SwitchPreference)) {
continue;
}
final SwitchPreference appSwitch = (SwitchPreference) pref;
preferenceCache.put(appSwitch.getKey(), appSwitch);
}
for (DeviceAdminListItem item : mAdmins) {
final String key = item.getKey();

View File

@@ -32,7 +32,7 @@ import android.widget.CompoundButton;
import com.android.internal.app.LocalePicker;
import com.android.internal.app.LocaleStore;
import com.android.settings.R;
import com.android.settings.shortcut.CreateShortcut;
import com.android.settings.shortcut.ShortcutsUpdateTask;
import java.text.NumberFormat;
import java.util.ArrayList;
@@ -294,7 +294,7 @@ class LocaleDragAndDropAdapter
LocalePicker.updateLocales(mLocalesToSetNext);
mLocalesSetLast = mLocalesToSetNext;
new CreateShortcut.ShortcutsUpdateTask(mContext).execute();
new ShortcutsUpdateTask(mContext).execute();
mLocalesToSetNext = null;

View File

@@ -191,37 +191,4 @@ public class CreateShortcut extends LauncherActivity {
return new Intent(Intent.ACTION_MAIN).addCategory("com.android.settings.SHORTCUT");
}
public static class ShortcutsUpdateTask extends AsyncTask<Void, Void, Void> {
private final Context mContext;
public ShortcutsUpdateTask(Context context) {
mContext = context;
}
@Override
public Void doInBackground(Void... params) {
ShortcutManager sm = mContext.getSystemService(ShortcutManager.class);
PackageManager pm = mContext.getPackageManager();
List<ShortcutInfo> updates = new ArrayList<>();
for (ShortcutInfo info : sm.getPinnedShortcuts()) {
if (!info.getId().startsWith(SHORTCUT_ID_PREFIX)) {
continue;
}
ComponentName cn = ComponentName.unflattenFromString(
info.getId().substring(SHORTCUT_ID_PREFIX.length()));
ResolveInfo ri = pm.resolveActivity(getBaseIntent().setComponent(cn), 0);
if (ri == null) {
continue;
}
updates.add(new ShortcutInfo.Builder(mContext, info.getId())
.setShortLabel(ri.loadLabel(pm)).build());
}
if (!updates.isEmpty()) {
sm.updateShortcuts(updates);
}
return null;
}
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (C) 2018 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.shortcut;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.ShortcutInfo;
import android.content.pm.ShortcutManager;
import android.os.AsyncTask;
import java.util.ArrayList;
import java.util.List;
public class ShortcutsUpdateTask extends AsyncTask<Void, Void, Void> {
private final Context mContext;
public ShortcutsUpdateTask(Context context) {
mContext = context;
}
@Override
public Void doInBackground(Void... params) {
ShortcutManager sm = mContext.getSystemService(ShortcutManager.class);
PackageManager pm = mContext.getPackageManager();
List<ShortcutInfo> updates = new ArrayList<>();
for (ShortcutInfo info : sm.getPinnedShortcuts()) {
if (!info.getId().startsWith(CreateShortcut.SHORTCUT_ID_PREFIX)) {
continue;
}
ComponentName cn = ComponentName.unflattenFromString(
info.getId().substring(CreateShortcut.SHORTCUT_ID_PREFIX.length()));
ResolveInfo ri = pm.resolveActivity(CreateShortcut.getBaseIntent().setComponent(cn), 0);
if (ri == null) {
continue;
}
updates.add(new ShortcutInfo.Builder(mContext, info.getId())
.setShortLabel(ri.loadLabel(pm)).build());
}
if (!updates.isEmpty()) {
sm.updateShortcuts(updates);
}
return null;
}
}