Loading AndroidManifest.xml +23 −1 Original line number Diff line number Diff line Loading @@ -255,6 +255,8 @@ android:value="com.android.settings.wifi.WifiSettings" /> <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED" android:value="true" /> <meta-data android:name="android.metadata.SLICE_URI" android:value="content://android.settings.slices/wifi" /> </activity> <activity Loading Loading @@ -1127,6 +1129,17 @@ </intent-filter> </activity> <activity android:name=".slice.SliceDeepLinkSpringBoard" android:theme="@android:style/Theme.NoDisplay"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="settings" android:host="com.android.settings.slices" /> </intent-filter> </activity> <!-- Provide direct entry into manage apps showing running services. This is for compatibility with old shortcuts. --> <activity-alias android:name=".RunningServices" Loading Loading @@ -3261,7 +3274,16 @@ <provider android:name=".slices.SettingsSliceProvider" android:authorities="com.android.settings.slices;android.settings.slices" android:exported="true"> android:exported="true" android:grantUriPermissions="true"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.app.slice.category.SLICE" /> <data android:scheme="settings" android:host="com.android.settings.slices" /> </intent-filter> </provider> <receiver Loading src/com/android/settings/SettingsActivity.java +11 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ import com.android.settings.dashboard.DashboardFeatureProvider; import com.android.settings.dashboard.DashboardSummary; import com.android.settings.development.DevelopmentSettingsDashboardFragment; import com.android.settings.overlay.FeatureFactory; import com.android.settings.search.DeviceIndexFeatureProvider; import com.android.settings.wfd.WifiDisplaySettings; import com.android.settings.widget.SwitchBar; import com.android.settingslib.core.instrumentation.Instrumentable; Loading @@ -72,6 +73,7 @@ import com.android.settingslib.core.instrumentation.SharedPreferencesLogger; import com.android.settingslib.development.DevelopmentSettingsEnabler; import com.android.settingslib.drawer.DashboardCategory; import com.android.settingslib.drawer.SettingsDrawerActivity; import com.android.settingslib.utils.ThreadUtils; import java.util.ArrayList; import java.util.List; Loading Loading @@ -489,6 +491,7 @@ public class SettingsActivity extends SettingsDrawerActivity registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); updateTilesList(); updateDeviceIndex(); } @Override Loading Loading @@ -609,6 +612,14 @@ public class SettingsActivity extends SettingsDrawerActivity }); } private void updateDeviceIndex() { DeviceIndexFeatureProvider indexProvider = FeatureFactory.getFactory( this).getDeviceIndexFeatureProvider(); ThreadUtils.postOnBackgroundThread( () -> indexProvider.updateIndex(SettingsActivity.this, false /* force */)); } private void doUpdateTilesList() { PackageManager pm = getPackageManager(); final UserManager um = UserManager.get(this); Loading src/com/android/settings/overlay/FeatureFactory.java +3 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider; import com.android.settings.fuelgauge.PowerUsageFeatureProvider; import com.android.settings.gestures.AssistGestureFeatureProvider; import com.android.settings.localepicker.LocaleFeatureProvider; import com.android.settings.search.DeviceIndexFeatureProvider; import com.android.settings.search.SearchFeatureProvider; import com.android.settings.security.SecurityFeatureProvider; import com.android.settings.slices.SlicesFeatureProvider; Loading Loading @@ -106,6 +107,8 @@ public abstract class FeatureFactory { public abstract AccountFeatureProvider getAccountFeatureProvider(); public abstract DeviceIndexFeatureProvider getDeviceIndexFeatureProvider(); public static final class FactoryNotFoundException extends RuntimeException { public FactoryNotFoundException(Throwable throwable) { super("Unable to create factory. Did you misconfigure Proguard?", throwable); Loading src/com/android/settings/overlay/FeatureFactoryImpl.java +11 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ import com.android.settings.gestures.AssistGestureFeatureProvider; import com.android.settings.gestures.AssistGestureFeatureProviderImpl; import com.android.settings.localepicker.LocaleFeatureProvider; import com.android.settings.localepicker.LocaleFeatureProviderImpl; import com.android.settings.search.DeviceIndexFeatureProvider; import com.android.settings.search.DeviceIndexFeatureProviderImpl; import com.android.settings.search.SearchFeatureProvider; import com.android.settings.search.SearchFeatureProviderImpl; import com.android.settings.security.SecurityFeatureProvider; Loading Loading @@ -75,6 +77,7 @@ public class FeatureFactoryImpl extends FeatureFactory { private BluetoothFeatureProvider mBluetoothFeatureProvider; private SlicesFeatureProvider mSlicesFeatureProvider; private AccountFeatureProvider mAccountFeatureProvider; private DeviceIndexFeatureProviderImpl mDeviceIndexFeatureProvider; @Override public SupportFeatureProvider getSupportFeatureProvider(Context context) { Loading Loading @@ -208,4 +211,12 @@ public class FeatureFactoryImpl extends FeatureFactory { } return mAccountFeatureProvider; } @Override public DeviceIndexFeatureProvider getDeviceIndexFeatureProvider() { if (mDeviceIndexFeatureProvider == null) { mDeviceIndexFeatureProvider = new DeviceIndexFeatureProviderImpl(); } return mDeviceIndexFeatureProvider; } } src/com/android/settings/search/DeviceIndexFeatureProvider.java 0 → 100644 +89 −0 Original line number Diff line number Diff line /* * 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.search; import static com.android.settings.slices.SliceDeepLinkSpringBoard.INTENT; import static com.android.settings.slices.SliceDeepLinkSpringBoard.SETTINGS; import android.app.slice.SliceManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; import android.provider.Settings; import android.util.Log; import com.android.settings.slices.SettingsSliceProvider; public interface DeviceIndexFeatureProvider { // TODO: Remove this and index all action and intent slices through search index. String[] ACTIONS_TO_INDEX = new String[]{ Settings.ACTION_WIFI_SETTINGS, }; String TAG = "DeviceIndex"; String INDEX_VERSION = "settings:index_version"; // Increment when new items are added to ensure they get pushed to the device index. int VERSION = 1; boolean isIndexingEnabled(); void index(Context context, CharSequence title, Uri sliceUri, Uri launchUri); default void updateIndex(Context context, boolean force) { if (!isIndexingEnabled()) return; if (!force && Settings.Secure.getInt(context.getContentResolver(), INDEX_VERSION, -1) == VERSION) { // No need to update. return; } PackageManager pm = context.getPackageManager(); for (String action : ACTIONS_TO_INDEX) { Intent intent = new Intent(action); intent.setPackage(context.getPackageName()); ResolveInfo activity = pm.resolveActivity(intent, PackageManager.GET_META_DATA); if (activity == null) { Log.e(TAG, "Unable to resolve " + action); continue; } String sliceUri = activity.activityInfo.metaData .getString(SliceManager.SLICE_METADATA_KEY); if (sliceUri != null) { Log.d(TAG, "Intent: " + createDeepLink(intent.toUri(Intent.URI_ANDROID_APP_SCHEME))); index(context, activity.activityInfo.loadLabel(pm), Uri.parse(sliceUri), Uri.parse(createDeepLink(intent.toUri(Intent.URI_ANDROID_APP_SCHEME)))); } else { Log.e(TAG, "No slice uri found for " + activity.activityInfo.name); } } Settings.Secure.putInt(context.getContentResolver(), INDEX_VERSION, VERSION); } static String createDeepLink(String s) { return new Uri.Builder().scheme(SETTINGS) .authority(SettingsSliceProvider.SLICE_AUTHORITY) .appendQueryParameter(INTENT, s) .build() .toString(); } } Loading
AndroidManifest.xml +23 −1 Original line number Diff line number Diff line Loading @@ -255,6 +255,8 @@ android:value="com.android.settings.wifi.WifiSettings" /> <meta-data android:name="com.android.settings.PRIMARY_PROFILE_CONTROLLED" android:value="true" /> <meta-data android:name="android.metadata.SLICE_URI" android:value="content://android.settings.slices/wifi" /> </activity> <activity Loading Loading @@ -1127,6 +1129,17 @@ </intent-filter> </activity> <activity android:name=".slice.SliceDeepLinkSpringBoard" android:theme="@android:style/Theme.NoDisplay"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="settings" android:host="com.android.settings.slices" /> </intent-filter> </activity> <!-- Provide direct entry into manage apps showing running services. This is for compatibility with old shortcuts. --> <activity-alias android:name=".RunningServices" Loading Loading @@ -3261,7 +3274,16 @@ <provider android:name=".slices.SettingsSliceProvider" android:authorities="com.android.settings.slices;android.settings.slices" android:exported="true"> android:exported="true" android:grantUriPermissions="true"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> <category android:name="android.intent.category.BROWSABLE" /> <category android:name="android.app.slice.category.SLICE" /> <data android:scheme="settings" android:host="com.android.settings.slices" /> </intent-filter> </provider> <receiver Loading
src/com/android/settings/SettingsActivity.java +11 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,7 @@ import com.android.settings.dashboard.DashboardFeatureProvider; import com.android.settings.dashboard.DashboardSummary; import com.android.settings.development.DevelopmentSettingsDashboardFragment; import com.android.settings.overlay.FeatureFactory; import com.android.settings.search.DeviceIndexFeatureProvider; import com.android.settings.wfd.WifiDisplaySettings; import com.android.settings.widget.SwitchBar; import com.android.settingslib.core.instrumentation.Instrumentable; Loading @@ -72,6 +73,7 @@ import com.android.settingslib.core.instrumentation.SharedPreferencesLogger; import com.android.settingslib.development.DevelopmentSettingsEnabler; import com.android.settingslib.drawer.DashboardCategory; import com.android.settingslib.drawer.SettingsDrawerActivity; import com.android.settingslib.utils.ThreadUtils; import java.util.ArrayList; import java.util.List; Loading Loading @@ -489,6 +491,7 @@ public class SettingsActivity extends SettingsDrawerActivity registerReceiver(mBatteryInfoReceiver, new IntentFilter(Intent.ACTION_BATTERY_CHANGED)); updateTilesList(); updateDeviceIndex(); } @Override Loading Loading @@ -609,6 +612,14 @@ public class SettingsActivity extends SettingsDrawerActivity }); } private void updateDeviceIndex() { DeviceIndexFeatureProvider indexProvider = FeatureFactory.getFactory( this).getDeviceIndexFeatureProvider(); ThreadUtils.postOnBackgroundThread( () -> indexProvider.updateIndex(SettingsActivity.this, false /* force */)); } private void doUpdateTilesList() { PackageManager pm = getPackageManager(); final UserManager um = UserManager.get(this); Loading
src/com/android/settings/overlay/FeatureFactory.java +3 −0 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import com.android.settings.enterprise.EnterprisePrivacyFeatureProvider; import com.android.settings.fuelgauge.PowerUsageFeatureProvider; import com.android.settings.gestures.AssistGestureFeatureProvider; import com.android.settings.localepicker.LocaleFeatureProvider; import com.android.settings.search.DeviceIndexFeatureProvider; import com.android.settings.search.SearchFeatureProvider; import com.android.settings.security.SecurityFeatureProvider; import com.android.settings.slices.SlicesFeatureProvider; Loading Loading @@ -106,6 +107,8 @@ public abstract class FeatureFactory { public abstract AccountFeatureProvider getAccountFeatureProvider(); public abstract DeviceIndexFeatureProvider getDeviceIndexFeatureProvider(); public static final class FactoryNotFoundException extends RuntimeException { public FactoryNotFoundException(Throwable throwable) { super("Unable to create factory. Did you misconfigure Proguard?", throwable); Loading
src/com/android/settings/overlay/FeatureFactoryImpl.java +11 −0 Original line number Diff line number Diff line Loading @@ -41,6 +41,8 @@ import com.android.settings.gestures.AssistGestureFeatureProvider; import com.android.settings.gestures.AssistGestureFeatureProviderImpl; import com.android.settings.localepicker.LocaleFeatureProvider; import com.android.settings.localepicker.LocaleFeatureProviderImpl; import com.android.settings.search.DeviceIndexFeatureProvider; import com.android.settings.search.DeviceIndexFeatureProviderImpl; import com.android.settings.search.SearchFeatureProvider; import com.android.settings.search.SearchFeatureProviderImpl; import com.android.settings.security.SecurityFeatureProvider; Loading Loading @@ -75,6 +77,7 @@ public class FeatureFactoryImpl extends FeatureFactory { private BluetoothFeatureProvider mBluetoothFeatureProvider; private SlicesFeatureProvider mSlicesFeatureProvider; private AccountFeatureProvider mAccountFeatureProvider; private DeviceIndexFeatureProviderImpl mDeviceIndexFeatureProvider; @Override public SupportFeatureProvider getSupportFeatureProvider(Context context) { Loading Loading @@ -208,4 +211,12 @@ public class FeatureFactoryImpl extends FeatureFactory { } return mAccountFeatureProvider; } @Override public DeviceIndexFeatureProvider getDeviceIndexFeatureProvider() { if (mDeviceIndexFeatureProvider == null) { mDeviceIndexFeatureProvider = new DeviceIndexFeatureProviderImpl(); } return mDeviceIndexFeatureProvider; } }
src/com/android/settings/search/DeviceIndexFeatureProvider.java 0 → 100644 +89 −0 Original line number Diff line number Diff line /* * 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.search; import static com.android.settings.slices.SliceDeepLinkSpringBoard.INTENT; import static com.android.settings.slices.SliceDeepLinkSpringBoard.SETTINGS; import android.app.slice.SliceManager; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.net.Uri; import android.provider.Settings; import android.util.Log; import com.android.settings.slices.SettingsSliceProvider; public interface DeviceIndexFeatureProvider { // TODO: Remove this and index all action and intent slices through search index. String[] ACTIONS_TO_INDEX = new String[]{ Settings.ACTION_WIFI_SETTINGS, }; String TAG = "DeviceIndex"; String INDEX_VERSION = "settings:index_version"; // Increment when new items are added to ensure they get pushed to the device index. int VERSION = 1; boolean isIndexingEnabled(); void index(Context context, CharSequence title, Uri sliceUri, Uri launchUri); default void updateIndex(Context context, boolean force) { if (!isIndexingEnabled()) return; if (!force && Settings.Secure.getInt(context.getContentResolver(), INDEX_VERSION, -1) == VERSION) { // No need to update. return; } PackageManager pm = context.getPackageManager(); for (String action : ACTIONS_TO_INDEX) { Intent intent = new Intent(action); intent.setPackage(context.getPackageName()); ResolveInfo activity = pm.resolveActivity(intent, PackageManager.GET_META_DATA); if (activity == null) { Log.e(TAG, "Unable to resolve " + action); continue; } String sliceUri = activity.activityInfo.metaData .getString(SliceManager.SLICE_METADATA_KEY); if (sliceUri != null) { Log.d(TAG, "Intent: " + createDeepLink(intent.toUri(Intent.URI_ANDROID_APP_SCHEME))); index(context, activity.activityInfo.loadLabel(pm), Uri.parse(sliceUri), Uri.parse(createDeepLink(intent.toUri(Intent.URI_ANDROID_APP_SCHEME)))); } else { Log.e(TAG, "No slice uri found for " + activity.activityInfo.name); } } Settings.Secure.putInt(context.getContentResolver(), INDEX_VERSION, VERSION); } static String createDeepLink(String s) { return new Uri.Builder().scheme(SETTINGS) .authority(SettingsSliceProvider.SLICE_AUTHORITY) .appendQueryParameter(INTENT, s) .build() .toString(); } }