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

Commit b42de6b6 authored by Martijn Coenen's avatar Martijn Coenen Committed by Android (Google) Code Review
Browse files

Merge "Support Notification bitmap offloading." into main

parents b40cb9b3 10088ca2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -66,3 +66,10 @@ flag {
  description: "This flag controls regrouping after notification classification"
  bug: "372775153"
}

flag {
  name: "notification_bitmap_offloading"
  namespace: "systemui"
  description: "Enables offloading Bitmaps to disk"
  bug: "398153219"
}
+8 −0
Original line number Diff line number Diff line
@@ -9670,6 +9670,14 @@
            android:exported="true">
        </provider>

        <provider
            android:name="com.android.server.bitmapoffload.BitmapOffloadProvider"
            android:authorities="com.android.bitmapoffload"
            android:singleUser="true"
            android:enabled="true"
            android:exported="true">
        </provider>

        <meta-data
            android:name="com.android.server.patch.25239169"
            android:value="true" />
+31 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.server.bitmapoffload;

import android.annotation.IntDef;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

public final class BitmapOffload {
    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = "BITMAP_SOURCE_", value = {
        BITMAP_SOURCE_NOTIFICATIONS,
    })
    public @interface BitmapSource {}
    public static final int BITMAP_SOURCE_NOTIFICATIONS = 0;
}
+49 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.server.bitmapoffload;

import android.annotation.IntDef;
import android.net.Uri;

import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

public final class BitmapOffloadContract {
    public static final String AUTHORITY = "com.android.bitmapoffload";

    public static final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY + "/bitmaps");

    public static final String COLUMN_ID = "_id";
    public static final String COLUMN_SOURCE = "source";
    public static final String COLUMN_FILE_NAME = "filename";
    public static final String COLUMN_FILE_SIZE = "filesize";
    public static final String COLUMN_WIDTH = "width";
    public static final String COLUMN_HEIGHT = "height";
    public static final String COLUMN_OWNER_UID = "owner_uid";
    public static final String COLUMN_STATUS = "status";

    @Retention(RetentionPolicy.SOURCE)
    @IntDef(prefix = "OFFLOAD_STATUS_", value = {
            OFFLOAD_STATUS_PENDING,
            OFFLOAD_STATUS_COMPLETED,
            OFFLOAD_STATUS_FAILED
    })
    public @interface OffloadStatus {}
    public static final int OFFLOAD_STATUS_PENDING = 0;
    public static final int OFFLOAD_STATUS_COMPLETED = 1;
    public static final int OFFLOAD_STATUS_FAILED = 2;
}
+32 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2025 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.server.bitmapoffload;

import android.graphics.Bitmap;
import android.net.Uri;

public abstract class BitmapOffloadInternal {
    public interface PermissionHandler {
        boolean isAllowedToOpen(Uri uri, int callingUid, int owningUid);
    }

    public abstract Uri offloadBitmap(@BitmapOffload.BitmapSource int source, Bitmap bitmap);
    public abstract void registerPermissionHandler(@BitmapOffload.BitmapSource int source,
            PermissionHandler handler);
    public abstract boolean checkPermission(@BitmapOffload.BitmapSource int source, Uri uri,
            int callingUid, int owningUid);
}
Loading