Merge "Fix a typo in AndroidManifest.xml" into pi-dev am: 3a9fbac582
am: e50f5effa0
Change-Id: I68689c03344b1987b905b32f95f91d82b5a9e129
This commit is contained in:
@@ -1127,7 +1127,9 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
|
||||||
<activity android:name=".slice.SliceDeepLinkSpringBoard"
|
<activity
|
||||||
|
android:name=".slices.SliceDeepLinkSpringBoard"
|
||||||
|
android:excludeFromRecents="true"
|
||||||
android:theme="@android:style/Theme.NoDisplay">
|
android:theme="@android:style/Theme.NoDisplay">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.VIEW" />
|
<action android:name="android.intent.action.VIEW" />
|
||||||
|
@@ -50,7 +50,7 @@ public interface DeviceIndexFeatureProvider {
|
|||||||
if (!isIndexingEnabled()) return;
|
if (!isIndexingEnabled()) return;
|
||||||
|
|
||||||
if (!force && Objects.equals(
|
if (!force && Objects.equals(
|
||||||
Settings.Secure.getString(context.getContentResolver(), INDEX_VERSION), VERSION)) {
|
Settings.Secure.getString(context.getContentResolver(), INDEX_VERSION), VERSION)) {
|
||||||
// No need to update.
|
// No need to update.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -70,11 +70,10 @@ public interface DeviceIndexFeatureProvider {
|
|||||||
Settings.Secure.putString(context.getContentResolver(), INDEX_VERSION, VERSION);
|
Settings.Secure.putString(context.getContentResolver(), INDEX_VERSION, VERSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
static String createDeepLink(String s) {
|
static Uri createDeepLink(String s) {
|
||||||
return new Uri.Builder().scheme(SETTINGS)
|
return new Uri.Builder().scheme(SETTINGS)
|
||||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||||
.appendQueryParameter(INTENT, s)
|
.appendQueryParameter(INTENT, s)
|
||||||
.build()
|
.build();
|
||||||
.toString();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,6 @@ package com.android.settings.search;
|
|||||||
import static android.app.slice.Slice.HINT_LARGE;
|
import static android.app.slice.Slice.HINT_LARGE;
|
||||||
import static android.app.slice.Slice.HINT_TITLE;
|
import static android.app.slice.Slice.HINT_TITLE;
|
||||||
import static android.app.slice.SliceItem.FORMAT_TEXT;
|
import static android.app.slice.SliceItem.FORMAT_TEXT;
|
||||||
|
|
||||||
import static com.android.settings.search.DeviceIndexFeatureProvider.createDeepLink;
|
import static com.android.settings.search.DeviceIndexFeatureProvider.createDeepLink;
|
||||||
|
|
||||||
import android.app.job.JobParameters;
|
import android.app.job.JobParameters;
|
||||||
@@ -73,16 +72,20 @@ public class DeviceIndexUpdateJobService extends JobService {
|
|||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected void updateIndex(JobParameters params) {
|
protected void updateIndex(JobParameters params) {
|
||||||
if (DEBUG) Log.d(TAG, "Starting index");
|
if (DEBUG) {
|
||||||
DeviceIndexFeatureProvider indexProvider = FeatureFactory.getFactory(
|
Log.d(TAG, "Starting index");
|
||||||
this).getDeviceIndexFeatureProvider();
|
}
|
||||||
SliceManager manager = getSliceManager();
|
final DeviceIndexFeatureProvider indexProvider = FeatureFactory.getFactory(this)
|
||||||
Uri baseUri = new Builder()
|
.getDeviceIndexFeatureProvider();
|
||||||
|
final SliceManager manager = getSliceManager();
|
||||||
|
final Uri baseUri = new Builder()
|
||||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||||
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
.authority(SettingsSliceProvider.SLICE_AUTHORITY)
|
||||||
.build();
|
.build();
|
||||||
Collection<Uri> slices = manager.getSliceDescendants(baseUri);
|
final Collection<Uri> slices = manager.getSliceDescendants(baseUri);
|
||||||
if (DEBUG) Log.d(TAG, "Indexing " + slices.size() + " slices");
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "Indexing " + slices.size() + " slices");
|
||||||
|
}
|
||||||
|
|
||||||
for (Uri slice : slices) {
|
for (Uri slice : slices) {
|
||||||
if (!mRunningJob) {
|
if (!mRunningJob) {
|
||||||
@@ -93,16 +96,20 @@ public class DeviceIndexUpdateJobService extends JobService {
|
|||||||
SliceMetadata metaData = getMetadata(loadedSlice);
|
SliceMetadata metaData = getMetadata(loadedSlice);
|
||||||
CharSequence title = findTitle(loadedSlice, metaData);
|
CharSequence title = findTitle(loadedSlice, metaData);
|
||||||
if (title != null) {
|
if (title != null) {
|
||||||
if (DEBUG) Log.d(TAG, "Indexing: " + slice + " " + title + " " + loadedSlice);
|
if (DEBUG) {
|
||||||
indexProvider.index(this, title, slice, Uri.parse(createDeepLink(
|
Log.d(TAG, "Indexing: " + slice + " " + title + " " + loadedSlice);
|
||||||
|
}
|
||||||
|
indexProvider.index(this, title, slice, createDeepLink(
|
||||||
new Intent(SliceDeepLinkSpringBoard.ACTION_VIEW_SLICE)
|
new Intent(SliceDeepLinkSpringBoard.ACTION_VIEW_SLICE)
|
||||||
.setPackage(getPackageName())
|
.setPackage(getPackageName())
|
||||||
.putExtra(SliceDeepLinkSpringBoard.EXTRA_SLICE, slice.toString())
|
.putExtra(SliceDeepLinkSpringBoard.EXTRA_SLICE, slice.toString())
|
||||||
.toUri(Intent.URI_ANDROID_APP_SCHEME))),
|
.toUri(Intent.URI_ANDROID_APP_SCHEME)),
|
||||||
metaData.getSliceKeywords());
|
metaData.getSliceKeywords());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (DEBUG) Log.d(TAG, "Done indexing");
|
if (DEBUG) {
|
||||||
|
Log.d(TAG, "Done indexing");
|
||||||
|
}
|
||||||
jobFinished(params, false);
|
jobFinished(params, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,16 +18,12 @@
|
|||||||
package com.android.settings.slices;
|
package com.android.settings.slices;
|
||||||
|
|
||||||
import static android.content.ContentResolver.SCHEME_CONTENT;
|
import static android.content.ContentResolver.SCHEME_CONTENT;
|
||||||
|
|
||||||
import static com.google.common.truth.Truth.assertThat;
|
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.mock;
|
||||||
import static org.mockito.Mockito.spy;
|
import static org.mockito.Mockito.spy;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
import android.app.slice.SliceManager;
|
import android.app.slice.SliceManager;
|
||||||
import android.content.ContentResolver;
|
|
||||||
import android.content.ContentValues;
|
import android.content.ContentValues;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
@@ -44,13 +40,13 @@ import org.junit.Test;
|
|||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
|
|
||||||
import androidx.slice.Slice;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import androidx.slice.Slice;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO Investigate using ShadowContentResolver.registerProviderInternal(String, ContentProvider)
|
* TODO Investigate using ShadowContentResolver.registerProviderInternal(String, ContentProvider)
|
||||||
*/
|
*/
|
||||||
|
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user