Search in sources :

Example 1 with TestInformationProvider

use of com.android.launcher3.testing.TestInformationProvider in project android_packages_apps_Launcher3 by AOSPA.

the class LauncherModelHelper method setupDefaultLayoutProvider.

/**
 * Sets up a mock provider to load the provided layout by default, next time the layout loads
 */
public LauncherModelHelper setupDefaultLayoutProvider(LauncherLayoutBuilder builder) throws Exception {
    InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(sandboxContext);
    idp.numRows = idp.numColumns = idp.numDatabaseHotseatIcons = DEFAULT_GRID_SIZE;
    idp.iconBitmapSize = DEFAULT_BITMAP_SIZE;
    UiDevice.getInstance(getInstrumentation()).executeShellCommand("settings put secure launcher3.layout.provider " + TEST_PROVIDER_AUTHORITY);
    ContentProvider cp = new TestInformationProvider() {

        @Override
        public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
            try {
                ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
                AutoCloseOutputStream outputStream = new AutoCloseOutputStream(pipe[1]);
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                builder.build(new OutputStreamWriter(bos));
                outputStream.write(bos.toByteArray());
                outputStream.flush();
                outputStream.close();
                return pipe[0];
            } catch (Exception e) {
                throw new FileNotFoundException(e.getMessage());
            }
        }
    };
    setupProvider(TEST_PROVIDER_AUTHORITY, cp);
    return this;
}
Also used : TestInformationProvider(com.android.launcher3.testing.TestInformationProvider) ContentProvider(android.content.ContentProvider) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) AutoCloseOutputStream(android.os.ParcelFileDescriptor.AutoCloseOutputStream) ParcelFileDescriptor(android.os.ParcelFileDescriptor) FileNotFoundException(java.io.FileNotFoundException) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Uri(android.net.Uri) FileNotFoundException(java.io.FileNotFoundException) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with TestInformationProvider

use of com.android.launcher3.testing.TestInformationProvider in project android_packages_apps_Launcher3 by ProtonAOSP.

the class LauncherModelHelper method setupDefaultLayoutProvider.

/**
 * Sets up a mock provider to load the provided layout by default, next time the layout loads
 */
public LauncherModelHelper setupDefaultLayoutProvider(LauncherLayoutBuilder builder) throws Exception {
    InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(sandboxContext);
    idp.numRows = idp.numColumns = idp.numDatabaseHotseatIcons = DEFAULT_GRID_SIZE;
    idp.iconBitmapSize = DEFAULT_BITMAP_SIZE;
    UiDevice.getInstance(getInstrumentation()).executeShellCommand("settings put secure launcher3.layout.provider " + TEST_PROVIDER_AUTHORITY);
    ContentProvider cp = new TestInformationProvider() {

        @Override
        public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
            try {
                ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
                AutoCloseOutputStream outputStream = new AutoCloseOutputStream(pipe[1]);
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                builder.build(new OutputStreamWriter(bos));
                outputStream.write(bos.toByteArray());
                outputStream.flush();
                outputStream.close();
                return pipe[0];
            } catch (Exception e) {
                throw new FileNotFoundException(e.getMessage());
            }
        }
    };
    setupProvider(TEST_PROVIDER_AUTHORITY, cp);
    return this;
}
Also used : TestInformationProvider(com.android.launcher3.testing.TestInformationProvider) ContentProvider(android.content.ContentProvider) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) AutoCloseOutputStream(android.os.ParcelFileDescriptor.AutoCloseOutputStream) ParcelFileDescriptor(android.os.ParcelFileDescriptor) FileNotFoundException(java.io.FileNotFoundException) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Uri(android.net.Uri) FileNotFoundException(java.io.FileNotFoundException) ExecutionException(java.util.concurrent.ExecutionException)

Example 3 with TestInformationProvider

use of com.android.launcher3.testing.TestInformationProvider in project android_packages_apps_404Launcher by P-404.

the class LauncherModelHelper method setupDefaultLayoutProvider.

/**
 * Sets up a mock provider to load the provided layout by default, next time the layout loads
 */
public LauncherModelHelper setupDefaultLayoutProvider(LauncherLayoutBuilder builder) throws Exception {
    InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(sandboxContext);
    idp.numRows = idp.numColumns = idp.numDatabaseHotseatIcons = DEFAULT_GRID_SIZE;
    idp.iconBitmapSize = DEFAULT_BITMAP_SIZE;
    UiDevice.getInstance(getInstrumentation()).executeShellCommand("settings put secure launcher3.layout.provider " + TEST_PROVIDER_AUTHORITY);
    ContentProvider cp = new TestInformationProvider() {

        @Override
        public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
            try {
                ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
                AutoCloseOutputStream outputStream = new AutoCloseOutputStream(pipe[1]);
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                builder.build(new OutputStreamWriter(bos));
                outputStream.write(bos.toByteArray());
                outputStream.flush();
                outputStream.close();
                return pipe[0];
            } catch (Exception e) {
                throw new FileNotFoundException(e.getMessage());
            }
        }
    };
    setupProvider(TEST_PROVIDER_AUTHORITY, cp);
    return this;
}
Also used : TestInformationProvider(com.android.launcher3.testing.TestInformationProvider) ContentProvider(android.content.ContentProvider) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) AutoCloseOutputStream(android.os.ParcelFileDescriptor.AutoCloseOutputStream) ParcelFileDescriptor(android.os.ParcelFileDescriptor) FileNotFoundException(java.io.FileNotFoundException) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Uri(android.net.Uri) FileNotFoundException(java.io.FileNotFoundException) ExecutionException(java.util.concurrent.ExecutionException)

Example 4 with TestInformationProvider

use of com.android.launcher3.testing.TestInformationProvider in project android_packages_apps_Launcher3 by ArrowOS.

the class LauncherModelHelper method setupDefaultLayoutProvider.

/**
 * Sets up a mock provider to load the provided layout by default, next time the layout loads
 */
public LauncherModelHelper setupDefaultLayoutProvider(LauncherLayoutBuilder builder) throws Exception {
    InvariantDeviceProfile idp = InvariantDeviceProfile.INSTANCE.get(sandboxContext);
    idp.numRows = idp.numColumns = idp.numDatabaseHotseatIcons = DEFAULT_GRID_SIZE;
    idp.iconBitmapSize = DEFAULT_BITMAP_SIZE;
    UiDevice.getInstance(getInstrumentation()).executeShellCommand("settings put secure launcher3.layout.provider " + TEST_PROVIDER_AUTHORITY);
    ContentProvider cp = new TestInformationProvider() {

        @Override
        public ParcelFileDescriptor openFile(Uri uri, String mode) throws FileNotFoundException {
            try {
                ParcelFileDescriptor[] pipe = ParcelFileDescriptor.createPipe();
                AutoCloseOutputStream outputStream = new AutoCloseOutputStream(pipe[1]);
                ByteArrayOutputStream bos = new ByteArrayOutputStream();
                builder.build(new OutputStreamWriter(bos));
                outputStream.write(bos.toByteArray());
                outputStream.flush();
                outputStream.close();
                return pipe[0];
            } catch (Exception e) {
                throw new FileNotFoundException(e.getMessage());
            }
        }
    };
    setupProvider(TEST_PROVIDER_AUTHORITY, cp);
    return this;
}
Also used : TestInformationProvider(com.android.launcher3.testing.TestInformationProvider) ContentProvider(android.content.ContentProvider) InvariantDeviceProfile(com.android.launcher3.InvariantDeviceProfile) AutoCloseOutputStream(android.os.ParcelFileDescriptor.AutoCloseOutputStream) ParcelFileDescriptor(android.os.ParcelFileDescriptor) FileNotFoundException(java.io.FileNotFoundException) OutputStreamWriter(java.io.OutputStreamWriter) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Uri(android.net.Uri) FileNotFoundException(java.io.FileNotFoundException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ContentProvider (android.content.ContentProvider)4 Uri (android.net.Uri)4 ParcelFileDescriptor (android.os.ParcelFileDescriptor)4 AutoCloseOutputStream (android.os.ParcelFileDescriptor.AutoCloseOutputStream)4 InvariantDeviceProfile (com.android.launcher3.InvariantDeviceProfile)4 TestInformationProvider (com.android.launcher3.testing.TestInformationProvider)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)4 FileNotFoundException (java.io.FileNotFoundException)4 OutputStreamWriter (java.io.OutputStreamWriter)4 ExecutionException (java.util.concurrent.ExecutionException)4