Fix a typo in AndroidManifest.xml

And some drive-by clean up.

Change-Id: Ic036f8f5bec8064a5d55e0e032ce45e483323b14
Fixes: 78889604
Test: atest
This commit is contained in:
Fan Zhang
2018-05-09 17:33:19 -07:00
parent 9a1d318b37
commit 66156d68e7
5 changed files with 82 additions and 23 deletions

View File

@@ -1114,7 +1114,9 @@
</intent-filter>
</activity>
<activity android:name=".slice.SliceDeepLinkSpringBoard"
<activity
android:name=".slices.SliceDeepLinkSpringBoard"
android:excludeFromRecents="true"
android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.VIEW" />

View File

@@ -50,7 +50,7 @@ public interface DeviceIndexFeatureProvider {
if (!isIndexingEnabled()) return;
if (!force && Objects.equals(
Settings.Secure.getString(context.getContentResolver(), INDEX_VERSION), VERSION)) {
Settings.Secure.getString(context.getContentResolver(), INDEX_VERSION), VERSION)) {
// No need to update.
return;
}
@@ -70,11 +70,10 @@ public interface DeviceIndexFeatureProvider {
Settings.Secure.putString(context.getContentResolver(), INDEX_VERSION, VERSION);
}
static String createDeepLink(String s) {
static Uri createDeepLink(String s) {
return new Uri.Builder().scheme(SETTINGS)
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
.appendQueryParameter(INTENT, s)
.build()
.toString();
.build();
}
}

View File

@@ -17,7 +17,6 @@ package com.android.settings.search;
import static android.app.slice.Slice.HINT_LARGE;
import static android.app.slice.Slice.HINT_TITLE;
import static android.app.slice.SliceItem.FORMAT_TEXT;
import static com.android.settings.search.DeviceIndexFeatureProvider.createDeepLink;
import android.app.job.JobParameters;
@@ -73,16 +72,20 @@ public class DeviceIndexUpdateJobService extends JobService {
@VisibleForTesting
protected void updateIndex(JobParameters params) {
if (DEBUG) Log.d(TAG, "Starting index");
DeviceIndexFeatureProvider indexProvider = FeatureFactory.getFactory(
this).getDeviceIndexFeatureProvider();
SliceManager manager = getSliceManager();
Uri baseUri = new Builder()
if (DEBUG) {
Log.d(TAG, "Starting index");
}
final DeviceIndexFeatureProvider indexProvider = FeatureFactory.getFactory(this)
.getDeviceIndexFeatureProvider();
final SliceManager manager = getSliceManager();
final Uri baseUri = new Builder()
.scheme(ContentResolver.SCHEME_CONTENT)
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
.build();
Collection<Uri> slices = manager.getSliceDescendants(baseUri);
if (DEBUG) Log.d(TAG, "Indexing " + slices.size() + " slices");
final Collection<Uri> slices = manager.getSliceDescendants(baseUri);
if (DEBUG) {
Log.d(TAG, "Indexing " + slices.size() + " slices");
}
for (Uri slice : slices) {
if (!mRunningJob) {
@@ -93,16 +96,20 @@ public class DeviceIndexUpdateJobService extends JobService {
SliceMetadata metaData = getMetadata(loadedSlice);
CharSequence title = findTitle(loadedSlice, metaData);
if (title != null) {
if (DEBUG) Log.d(TAG, "Indexing: " + slice + " " + title + " " + loadedSlice);
indexProvider.index(this, title, slice, Uri.parse(createDeepLink(
if (DEBUG) {
Log.d(TAG, "Indexing: " + slice + " " + title + " " + loadedSlice);
}
indexProvider.index(this, title, slice, createDeepLink(
new Intent(SliceDeepLinkSpringBoard.ACTION_VIEW_SLICE)
.setPackage(getPackageName())
.putExtra(SliceDeepLinkSpringBoard.EXTRA_SLICE, slice.toString())
.toUri(Intent.URI_ANDROID_APP_SCHEME))),
.toUri(Intent.URI_ANDROID_APP_SCHEME)),
metaData.getSliceKeywords());
}
}
if (DEBUG) Log.d(TAG, "Done indexing");
if (DEBUG) {
Log.d(TAG, "Done indexing");
}
jobFinished(params, false);
}

View File

@@ -18,16 +18,12 @@
package com.android.settings.slices;
import static android.content.ContentResolver.SCHEME_CONTENT;
import static com.google.common.truth.Truth.assertThat;
import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;
import android.app.slice.SliceManager;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
@@ -44,13 +40,13 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RuntimeEnvironment;
import androidx.slice.Slice;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import androidx.slice.Slice;
/**
* TODO Investigate using ShadowContentResolver.registerProviderInternal(String, ContentProvider)
*/

View File

@@ -0,0 +1,55 @@
/*
* 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.slices;
import static com.android.settings.search.DeviceIndexFeatureProvider.createDeepLink;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@RunWith(AndroidJUnit4.class)
public class SliceDeepLinkSpringBoardTest {
private Context mContext;
@Before
public void setUp() {
mContext = InstrumentationRegistry.getTargetContext();
}
@Test
public void launcheDeepLinkIntent_shouldNotCrash() {
final Uri springBoardIntentUri = createDeepLink(
new Intent(SliceDeepLinkSpringBoard.ACTION_VIEW_SLICE)
.setPackage(mContext.getPackageName())
.putExtra(SliceDeepLinkSpringBoard.EXTRA_SLICE,
"content://com.android.settings.slices/action/test_slice")
.toUri(Intent.URI_ANDROID_APP_SCHEME));
final Intent deepLinkIntent = new Intent(Intent.ACTION_VIEW)
.setData(springBoardIntentUri)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(deepLinkIntent);
}
}