Creating provider for test gesture dimensions.
Start with answering only whether the provider will answer any other questions. Bug: 123904290 Change-Id: I7b3ba8c7689f937d8bc1d470b00574ab4340130d
This commit is contained in:
parent
f820d5d817
commit
09df0831da
|
@ -12,7 +12,7 @@
|
|||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
java_library_static {
|
||||
android_library {
|
||||
name: "launcher-aosp-tapl",
|
||||
static_libs: [
|
||||
"androidx.annotation_annotation",
|
||||
|
@ -27,5 +27,6 @@ java_library_static {
|
|||
"src/com/android/launcher3/util/SecureSettingsObserver.java",
|
||||
"src/com/android/launcher3/TestProtocol.java",
|
||||
],
|
||||
manifest: "tests/tapl/AndroidManifest.xml",
|
||||
platform_apis: true,
|
||||
}
|
||||
|
|
|
@ -152,6 +152,14 @@
|
|||
android:writePermission="${packageName}.permission.WRITE_SETTINGS"
|
||||
android:readPermission="${packageName}.permission.READ_SETTINGS" />
|
||||
|
||||
<provider
|
||||
android:name="com.android.launcher3.TestInformationProvider"
|
||||
android:authorities="${packageName}.TestInfo"
|
||||
android:readPermission="android.permission.WRITE_SECURE_SETTINGS"
|
||||
android:writePermission="android.permission.WRITE_SECURE_SETTINGS"
|
||||
android:exported="true">
|
||||
</provider>
|
||||
|
||||
<!--
|
||||
The content provider for exposing various launcher grid options.
|
||||
TODO: Enable when all apps columns are correct
|
||||
|
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* Copyright (C) 2019 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.launcher3;
|
||||
|
||||
import android.content.ContentProvider;
|
||||
import android.content.ContentValues;
|
||||
import android.database.Cursor;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
||||
public class TestInformationProvider extends ContentProvider {
|
||||
@Override
|
||||
public boolean onCreate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int update(Uri uri, ContentValues contentValues, String s, String[] strings) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delete(Uri uri, String s, String[] strings) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Uri insert(Uri uri, ContentValues contentValues) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getType(Uri uri) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cursor query(Uri uri, String[] strings, String s, String[] strings1, String s1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bundle call(String method, String arg, Bundle extras) {
|
||||
if (TestProtocol.IS_TEST_INFO_ENABLED.equals(method)) {
|
||||
final Bundle response = new Bundle();
|
||||
response.putBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD,
|
||||
Utilities.IS_RUNNING_IN_TEST_HARNESS);
|
||||
return response;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -30,4 +30,7 @@ public final class TestProtocol {
|
|||
public static final int OVERVIEW_STATE_ORDINAL = 2;
|
||||
public static final int ALL_APPS_STATE_ORDINAL = 3;
|
||||
public static final int BACKGROUND_APP_STATE_ORDINAL = 4;
|
||||
|
||||
public static final String IS_TEST_INFO_ENABLED = "is-test-info-enabled";
|
||||
public static final String TEST_INFO_RESPONSE_FIELD = "response";
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
**
|
||||
** Copyright 2019, 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.
|
||||
*/
|
||||
-->
|
||||
<manifest
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.launcher3.tapl"
|
||||
>
|
||||
|
||||
<uses-permission android:name="android.permission.WRITE_SECURE_SETTINGS"/>
|
||||
</manifest>
|
|
@ -18,10 +18,11 @@ package com.android.launcher3.tapl;
|
|||
|
||||
import static com.android.systemui.shared.system.SettingsCompat.SWIPE_UP_SETTING_NAME;
|
||||
|
||||
import android.app.ActivityManager;
|
||||
import android.app.Instrumentation;
|
||||
import android.app.UiAutomation;
|
||||
import android.content.ContentResolver;
|
||||
import android.graphics.Point;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.os.SystemClock;
|
||||
|
@ -43,6 +44,7 @@ import com.android.quickstep.SwipeUpSetting;
|
|||
|
||||
import org.junit.Assert;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
@ -95,6 +97,7 @@ public final class LauncherInstrumentation {
|
|||
private final UiDevice mDevice;
|
||||
private final Instrumentation mInstrumentation;
|
||||
private int mExpectedRotation = Surface.ROTATION_0;
|
||||
private final Uri mTestProviderUri;
|
||||
|
||||
/**
|
||||
* Constructs the root of TAPL hierarchy. You get all other objects from it.
|
||||
|
@ -103,11 +106,34 @@ public final class LauncherInstrumentation {
|
|||
mInstrumentation = instrumentation;
|
||||
mDevice = UiDevice.getInstance(instrumentation);
|
||||
|
||||
// Launcher should run in test harness so that custom accessibility protocol between
|
||||
// Launcher and TAPL is enabled. In-process tests enable this protocol with a direct call
|
||||
// into Launcher.
|
||||
assertTrue("Device must run in a test harness",
|
||||
TestHelpers.isInLauncherProcess() || ActivityManager.isRunningInTestHarness());
|
||||
final String testPackage = mInstrumentation.getContext().getPackageName();
|
||||
final String targetPackage = mInstrumentation.getTargetContext().getPackageName();
|
||||
|
||||
// Launcher package. As during inproc tests the tested launcher may not be selected as the
|
||||
// current launcher, choosing target package for inproc. For out-of-proc, use the installed
|
||||
// launcher package.
|
||||
final String authorityPackage = testPackage.equals(targetPackage) ?
|
||||
getLauncherPackageName() :
|
||||
targetPackage;
|
||||
|
||||
mTestProviderUri = new Uri.Builder()
|
||||
.scheme(ContentResolver.SCHEME_CONTENT)
|
||||
.authority(authorityPackage + ".TestInfo")
|
||||
.build();
|
||||
|
||||
try {
|
||||
mDevice.executeShellCommand("pm grant " + testPackage +
|
||||
" android.permission.WRITE_SECURE_SETTINGS");
|
||||
} catch (IOException e) {
|
||||
fail(e.toString());
|
||||
}
|
||||
|
||||
// Launcher should run in test harness so that custom test protocols between Launcher and
|
||||
// TAPL are enabled. In-process tests enable this protocol with a direct call into Launcher.
|
||||
final Bundle response = mInstrumentation.getContext().getContentResolver().call(
|
||||
mTestProviderUri, TestProtocol.IS_TEST_INFO_ENABLED, null, null);
|
||||
assertTrue("Launcher is not running in test harness",
|
||||
response.getBoolean(TestProtocol.TEST_INFO_RESPONSE_FIELD, false));
|
||||
}
|
||||
|
||||
void setActiveContainer(VisibleContainer container) {
|
||||
|
|
Loading…
Reference in New Issue