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

Commit 815c6a87 authored by Jeff Sharkey's avatar Jeff Sharkey Committed by Android (Google) Code Review
Browse files

Merge "Offer to cache ContentResolver-related Bundles." into nyc-dev

parents 6ab4498c 8731408b
Loading
Loading
Loading
Loading
+22 −0
Original line number Diff line number Diff line
@@ -2440,6 +2440,28 @@ public abstract class ContentResolver {
        }
    }

    /** {@hide} */
    public void putCache(Uri key, Bundle value) {
        try {
            getContentService().putCache(mContext.getPackageName(), key, value,
                    mContext.getUserId());
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /** {@hide} */
    public Bundle getCache(Uri key) {
        try {
            final Bundle bundle = getContentService().getCache(mContext.getPackageName(), key,
                    mContext.getUserId());
            if (bundle != null) bundle.setClassLoader(mContext.getClassLoader());
            return bundle;
        } catch (RemoteException e) {
            throw e.rethrowFromSystemServer();
        }
    }

    /**
     * Returns sampling percentage for a given duration.
     *
+3 −1
Original line number Diff line number Diff line
@@ -179,6 +179,8 @@ interface IContentService {
            int userId);

    void addStatusChangeListener(int mask, ISyncStatusObserver callback);

    void removeStatusChangeListener(ISyncStatusObserver callback);

    void putCache(in String packageName, in Uri key, in Bundle value, int userId);
    Bundle getCache(in String packageName, in Uri key, int userId);
}
+10 −0
Original line number Diff line number Diff line
@@ -1483,11 +1483,21 @@

    <!-- Allows an application to manage access to documents, usually as part
         of a document picker.
         <p>This permission should <em>only</em> be requested by the platform
         document management app.  This permission cannot be granted to
         third-party apps.
         <p>Protection level: signature
    -->
    <permission android:name="android.permission.MANAGE_DOCUMENTS"
        android:protectionLevel="signature" />

    <!-- @hide Allows an application to cache content.
         <p>Not for use by third-party applications.
         <p>Protection level: signature
    -->
    <permission android:name="android.permission.CACHE_CONTENT"
        android:protectionLevel="signature" />

    <!-- ================================== -->
    <!-- Permissions for screenlock         -->
    <!-- ================================== -->
+8 −0
Original line number Diff line number Diff line
@@ -5,6 +5,8 @@
    <uses-permission android:name="android.permission.MANAGE_DOCUMENTS" />
    <uses-permission android:name="android.permission.REMOVE_TASKS" />
    <uses-permission android:name="android.permission.WAKE_LOCK" />
    <uses-permission android:name="android.permission.CACHE_CONTENT" />
    <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />

    <application
        android:name=".DocumentsApplication"
@@ -105,6 +107,12 @@
            </intent-filter>
        </receiver>

        <receiver android:name=".BootReceiver">
            <intent-filter>
                <action android:name="android.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>

        <service
            android:name=".services.FileOperationService"
            android:exported="false">
+34 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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.documentsui;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

/**
 * Prime {@link RootsCache} when the system is booted.
 */
public class BootReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        // We already spun up our application object before getting here, which
        // kicked off a task to load roots, so this broadcast is finished once
        // that first pass is done.
        DocumentsApplication.getRootsCache(context).setBootCompletedResult(goAsync());
    }
}
Loading