Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e50f5eff authored by Fan Zhang's avatar Fan Zhang Committed by android-build-merger
Browse files

Merge "Fix a typo in AndroidManifest.xml" into pi-dev

am: 3a9fbac5

Change-Id: Ifa4fef188cdcd80ff997575ed593f67c9bb7fe86
parents c93a0dc2 3a9fbac5
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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" />
+3 −4
Original line number Diff line number Diff line
@@ -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();
    }
}
+19 −12
Original line number Diff line number Diff line
@@ -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);
    }

+2 −6
Original line number Diff line number Diff line
@@ -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)
 */
+55 −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.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);
    }
}