• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2020 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.server.wm;
18 
19 import android.os.IBinder;
20 
21 import java.util.Collection;
22 
23 /**
24  * Callback to decide activity starts and related operations based on originating tokens.
25  */
26 public interface BackgroundActivityStartCallback {
27     BackgroundActivityStartCallbackResult RESULT_FALSE =
28             new BackgroundActivityStartCallbackResult(false, null);
29     BackgroundActivityStartCallbackResult RESULT_TRUE =
30             new BackgroundActivityStartCallbackResult(true, null);
31 
BackgroundActivityStartCallbackResult( boolean allowed, IBinder token )32     record BackgroundActivityStartCallbackResult(
33             boolean allowed,
34             IBinder token
35     ) {}
36 
37     /**
38      * Returns true if the background activity start originating from {@code tokens} should be
39      * allowed or not.
40      *
41      * Note that if the start was allowed due to a mechanism other than tokens (eg. permission),
42      * this won't be called.
43      *
44      * This will be called holding the WM and local lock, don't do anything costly or invoke AM/WM
45      * methods here directly.
46      */
isActivityStartAllowed(Collection<IBinder> tokens, int uid, String packageName)47     BackgroundActivityStartCallbackResult isActivityStartAllowed(Collection<IBinder> tokens,
48             int uid, String packageName);
49 
50     /**
51      * Returns whether {@code uid} can send {@link android.content.Intent
52      * #ACTION_CLOSE_SYSTEM_DIALOGS}, presumably to start activities, based on the originating
53      * tokens {@code tokens} currently associated with potential activity starts.
54      *
55      * This will be called holding the AM and local lock, don't do anything costly or invoke AM/WM
56      * methods here directly.
57      */
canCloseSystemDialogs(Collection<IBinder> tokens, int uid)58     boolean canCloseSystemDialogs(Collection<IBinder> tokens, int uid);
59 }
60