Skip to content

Commit 29f0a94

Browse files
author
Android Build Coastguard Worker
committed
Snap for 9432468 from cae4b00 to tm-platform-release
Change-Id: I75d93c1ded31d1904cd328767e12bbeb922f5dc9
2 parents 498b888 + cae4b00 commit 29f0a94

17 files changed

Lines changed: 291 additions & 139 deletions

File tree

core/java/android/accounts/ChooseTypeAndAccountActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ public void run(final AccountManagerFuture<Bundle> accountManagerFuture) {
402402
mExistingAccounts = AccountManager.get(this).getAccountsForPackage(mCallingPackage,
403403
mCallingUid);
404404
intent.setFlags(intent.getFlags() & ~Intent.FLAG_ACTIVITY_NEW_TASK);
405-
startActivityForResult(intent, REQUEST_ADD_ACCOUNT);
405+
startActivityForResult(new Intent(intent), REQUEST_ADD_ACCOUNT);
406406
return;
407407
}
408408
} catch (OperationCanceledException e) {

core/java/android/app/AppOpsManager.java

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9134,8 +9134,9 @@ public int startProxyOpNoThrow(@NonNull String op, int proxiedUid,
91349134
*/
91359135
public int startProxyOpNoThrow(int op, @NonNull AttributionSource attributionSource,
91369136
@Nullable String message, boolean skipProxyOperation) {
9137-
return startProxyOpNoThrow(op, attributionSource, message, skipProxyOperation,
9138-
ATTRIBUTION_FLAGS_NONE, ATTRIBUTION_FLAGS_NONE, ATTRIBUTION_CHAIN_ID_NONE);
9137+
return startProxyOpNoThrow(attributionSource.getToken(), op, attributionSource, message,
9138+
skipProxyOperation, ATTRIBUTION_FLAGS_NONE, ATTRIBUTION_FLAGS_NONE,
9139+
ATTRIBUTION_CHAIN_ID_NONE);
91399140
}
91409141

91419142
/**
@@ -9147,7 +9148,8 @@ public int startProxyOpNoThrow(int op, @NonNull AttributionSource attributionSou
91479148
*
91489149
* @hide
91499150
*/
9150-
public int startProxyOpNoThrow(int op, @NonNull AttributionSource attributionSource,
9151+
public int startProxyOpNoThrow(@NonNull IBinder clientId, int op,
9152+
@NonNull AttributionSource attributionSource,
91519153
@Nullable String message, boolean skipProxyOperation, @AttributionFlags
91529154
int proxyAttributionFlags, @AttributionFlags int proxiedAttributionFlags,
91539155
int attributionChainId) {
@@ -9165,7 +9167,7 @@ public int startProxyOpNoThrow(int op, @NonNull AttributionSource attributionSou
91659167
}
91669168
}
91679169

9168-
SyncNotedAppOp syncOp = mService.startProxyOperation(op,
9170+
SyncNotedAppOp syncOp = mService.startProxyOperation(clientId, op,
91699171
attributionSource, false, collectionMode == COLLECT_ASYNC, message,
91709172
shouldCollectMessage, skipProxyOperation, proxyAttributionFlags,
91719173
proxiedAttributionFlags, attributionChainId);
@@ -9263,9 +9265,10 @@ public void finishOp(IBinder token, int op, int uid, @NonNull String packageName
92639265
*/
92649266
public void finishProxyOp(@NonNull String op, int proxiedUid,
92659267
@NonNull String proxiedPackageName, @Nullable String proxiedAttributionTag) {
9266-
finishProxyOp(op, new AttributionSource(mContext.getAttributionSource(),
9268+
IBinder token = mContext.getAttributionSource().getToken();
9269+
finishProxyOp(token, op, new AttributionSource(mContext.getAttributionSource(),
92679270
new AttributionSource(proxiedUid, proxiedPackageName, proxiedAttributionTag,
9268-
mContext.getAttributionSource().getToken())), /*skipProxyOperation*/ false);
9271+
token)), /*skipProxyOperation*/ false);
92699272
}
92709273

92719274
/**
@@ -9280,10 +9283,11 @@ public void finishProxyOp(@NonNull String op, int proxiedUid,
92809283
*
92819284
* @hide
92829285
*/
9283-
public void finishProxyOp(@NonNull String op, @NonNull AttributionSource attributionSource,
9284-
boolean skipProxyOperation) {
9286+
public void finishProxyOp(@NonNull IBinder clientId, @NonNull String op,
9287+
@NonNull AttributionSource attributionSource, boolean skipProxyOperation) {
92859288
try {
9286-
mService.finishProxyOperation(strOpToOp(op), attributionSource, skipProxyOperation);
9289+
mService.finishProxyOperation(clientId, strOpToOp(op), attributionSource,
9290+
skipProxyOperation);
92879291
} catch (RemoteException e) {
92889292
throw e.rethrowFromSystemServer();
92899293
}

core/java/android/app/AppOpsManagerInternal.java

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@
2626
import android.util.SparseIntArray;
2727

2828
import com.android.internal.app.IAppOpsCallback;
29-
import com.android.internal.util.function.DecFunction;
3029
import com.android.internal.util.function.HeptFunction;
3130
import com.android.internal.util.function.HexFunction;
3231
import com.android.internal.util.function.QuadFunction;
3332
import com.android.internal.util.function.QuintConsumer;
3433
import com.android.internal.util.function.QuintFunction;
35-
import com.android.internal.util.function.TriFunction;
3634
import com.android.internal.util.function.UndecFunction;
3735

3836
/**
@@ -135,6 +133,7 @@ SyncNotedAppOp startOperation(IBinder token, int code, int uid,
135133
/**
136134
* Allows overriding start proxy operation behavior.
137135
*
136+
* @param clientId The client calling start, represented by an IBinder
138137
* @param code The op code to start.
139138
* @param attributionSource The permission identity of the caller.
140139
* @param startIfModeDefault Whether to start the op of the mode is default.
@@ -148,11 +147,12 @@ SyncNotedAppOp startOperation(IBinder token, int code, int uid,
148147
* @param superImpl The super implementation.
149148
* @return The app op note result.
150149
*/
151-
SyncNotedAppOp startProxyOperation(int code, @NonNull AttributionSource attributionSource,
152-
boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message,
153-
boolean shouldCollectMessage, boolean skipProxyOperation, @AttributionFlags
154-
int proxyAttributionFlags, @AttributionFlags int proxiedAttributionFlags,
155-
int attributionChainId, @NonNull DecFunction<Integer, AttributionSource, Boolean,
150+
SyncNotedAppOp startProxyOperation(@NonNull IBinder clientId, int code,
151+
@NonNull AttributionSource attributionSource, boolean startIfModeDefault,
152+
boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
153+
boolean skipProxyOperation, @AttributionFlags int proxyAttributionFlags,
154+
@AttributionFlags int proxiedAttributionFlags, int attributionChainId,
155+
@NonNull UndecFunction<IBinder, Integer, AttributionSource, Boolean,
156156
Boolean, String, Boolean, Boolean, Integer, Integer, Integer,
157157
SyncNotedAppOp> superImpl);
158158

@@ -176,10 +176,15 @@ default void finishOperation(IBinder clientId, int code, int uid, String package
176176
*
177177
* @param code The op code to finish.
178178
* @param attributionSource The permission identity of the caller.
179+
* @param skipProxyOperation Whether to skip the proxy in the proxy/proxied operation
180+
* @param clientId The client calling finishProxyOperation
181+
* @param superImpl The "standard" implementation to potentially call
179182
*/
180-
void finishProxyOperation(int code, @NonNull AttributionSource attributionSource,
183+
void finishProxyOperation(@NonNull IBinder clientId, int code,
184+
@NonNull AttributionSource attributionSource,
181185
boolean skipProxyOperation,
182-
@NonNull TriFunction<Integer, AttributionSource, Boolean, Void> superImpl);
186+
@NonNull QuadFunction<IBinder, Integer, AttributionSource, Boolean,
187+
Void> superImpl);
183188
}
184189

185190
/**

core/java/com/android/internal/app/IAppOpsService.aidl

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,12 @@ interface IAppOpsService {
5858
SyncNotedAppOp noteProxyOperation(int code, in AttributionSource attributionSource,
5959
boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
6060
boolean skipProxyOperation);
61-
SyncNotedAppOp startProxyOperation(int code, in AttributionSource attributionSource,
62-
boolean startIfModeDefault, boolean shouldCollectAsyncNotedOp, String message,
63-
boolean shouldCollectMessage, boolean skipProxyOperation, int proxyAttributionFlags,
64-
int proxiedAttributionFlags, int attributionChainId);
65-
void finishProxyOperation(int code, in AttributionSource attributionSource,
61+
SyncNotedAppOp startProxyOperation(IBinder clientId, int code,
62+
in AttributionSource attributionSource, boolean startIfModeDefault,
63+
boolean shouldCollectAsyncNotedOp, String message, boolean shouldCollectMessage,
64+
boolean skipProxyOperation, int proxyAttributionFlags, int proxiedAttributionFlags,
65+
int attributionChainId);
66+
void finishProxyOperation(IBinder clientId, int code, in AttributionSource attributionSource,
6667
boolean skipProxyOperation);
6768

6869
// Remaining methods are only used in Java.

packages/SystemUI/src/com/android/systemui/qs/HeaderPrivacyIconsController.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import java.util.concurrent.Executor
2626
import javax.inject.Inject
2727
import com.android.systemui.dagger.qualifiers.Background
2828
import com.android.systemui.dagger.qualifiers.Main
29+
import com.android.systemui.statusbar.policy.DeviceProvisionedController
2930

3031
interface ChipVisibilityListener {
3132
fun onChipVisibilityRefreshed(visible: Boolean)
@@ -54,7 +55,8 @@ class HeaderPrivacyIconsController @Inject constructor(
5455
private val activityStarter: ActivityStarter,
5556
private val appOpsController: AppOpsController,
5657
private val broadcastDispatcher: BroadcastDispatcher,
57-
private val safetyCenterManager: SafetyCenterManager
58+
private val safetyCenterManager: SafetyCenterManager,
59+
private val deviceProvisionedController: DeviceProvisionedController
5860
) {
5961

6062
var chipVisibilityListener: ChipVisibilityListener? = null
@@ -134,6 +136,8 @@ class HeaderPrivacyIconsController @Inject constructor(
134136

135137
fun onParentVisible() {
136138
privacyChip.setOnClickListener {
139+
// Do not expand dialog while device is not provisioned
140+
if (!deviceProvisionedController.isDeviceProvisioned) return@setOnClickListener
137141
// If the privacy chip is visible, it means there were some indicators
138142
uiEventLogger.log(PrivacyChipEvent.ONGOING_INDICATORS_CHIP_CLICK)
139143
if (safetyCenterEnabled) {

packages/SystemUI/tests/src/com/android/systemui/qs/HeaderPrivacyIconsControllerTest.kt

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import com.android.systemui.privacy.PrivacyDialogController
1919
import com.android.systemui.privacy.PrivacyItemController
2020
import com.android.systemui.privacy.logging.PrivacyLogger
2121
import com.android.systemui.statusbar.phone.StatusIconContainer
22+
import com.android.systemui.statusbar.policy.DeviceProvisionedController
2223
import com.android.systemui.util.concurrency.FakeExecutor
2324
import com.android.systemui.util.mockito.any
2425
import com.android.systemui.util.mockito.argumentCaptor
@@ -66,6 +67,8 @@ class HeaderPrivacyIconsControllerTest : SysuiTestCase() {
6667
private lateinit var broadcastDispatcher: BroadcastDispatcher
6768
@Mock
6869
private lateinit var safetyCenterManager: SafetyCenterManager
70+
@Mock
71+
private lateinit var deviceProvisionedController: DeviceProvisionedController
6972

7073
private val uiExecutor = FakeExecutor(FakeSystemClock())
7174
private val backgroundExecutor = FakeExecutor(FakeSystemClock())
@@ -80,6 +83,7 @@ class HeaderPrivacyIconsControllerTest : SysuiTestCase() {
8083
whenever(privacyChip.context).thenReturn(context)
8184
whenever(privacyChip.resources).thenReturn(context.resources)
8285
whenever(privacyChip.isAttachedToWindow).thenReturn(true)
86+
whenever(deviceProvisionedController.isDeviceProvisioned).thenReturn(true)
8387

8488
cameraSlotName = context.getString(com.android.internal.R.string.status_bar_camera)
8589
microphoneSlotName = context.getString(com.android.internal.R.string.status_bar_microphone)
@@ -98,7 +102,8 @@ class HeaderPrivacyIconsControllerTest : SysuiTestCase() {
98102
activityStarter,
99103
appOpsController,
100104
broadcastDispatcher,
101-
safetyCenterManager
105+
safetyCenterManager,
106+
deviceProvisionedController
102107
)
103108

104109
backgroundExecutor.runAllReady()
@@ -199,6 +204,18 @@ class HeaderPrivacyIconsControllerTest : SysuiTestCase() {
199204
)
200205
}
201206

207+
@Test
208+
fun testNoDialogWhenDeviceNotProvisioned() {
209+
whenever(deviceProvisionedController.isDeviceProvisioned).thenReturn(false)
210+
controller.onParentVisible()
211+
212+
val captor = argumentCaptor<View.OnClickListener>()
213+
verify(privacyChip).setOnClickListener(capture(captor))
214+
215+
captor.value.onClick(privacyChip)
216+
verify(privacyDialogController, never()).showDialog(any(Context::class.java))
217+
}
218+
202219
private fun setPrivacyController(micCamera: Boolean, location: Boolean) {
203220
whenever(privacyItemController.micCameraAvailable).thenReturn(micCamera)
204221
whenever(privacyItemController.locationAvailable).thenReturn(location)

services/core/java/com/android/server/accounts/AccountManagerService.java

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ public Map<Account, Integer> getAccountsAndVisibilityForPackage(String packageNa
528528
private Map<Account, Integer> getAccountsAndVisibilityForPackage(String packageName,
529529
List<String> accountTypes, Integer callingUid, UserAccounts accounts) {
530530
if (!packageExistsForUser(packageName, accounts.userId)) {
531-
Log.d(TAG, "Package not found " + packageName);
531+
Log.w(TAG, "getAccountsAndVisibilityForPackage#Package not found " + packageName);
532532
return new LinkedHashMap<>();
533533
}
534534

@@ -677,7 +677,7 @@ private Integer resolveAccountVisibility(Account account, @NonNull String packag
677677
restoreCallingIdentity(identityToken);
678678
}
679679
} catch (NameNotFoundException e) {
680-
Log.d(TAG, "Package not found " + e.getMessage());
680+
Log.w(TAG, "resolveAccountVisibility#Package not found " + e.getMessage());
681681
return AccountManager.VISIBILITY_NOT_VISIBLE;
682682
}
683683

@@ -756,7 +756,7 @@ private boolean isPreOApplication(String packageName) {
756756
}
757757
return true;
758758
} catch (NameNotFoundException e) {
759-
Log.d(TAG, "Package not found " + e.getMessage());
759+
Log.w(TAG, "isPreOApplication#Package not found " + e.getMessage());
760760
return true;
761761
}
762762
}
@@ -4063,7 +4063,7 @@ public boolean hasAccountAccess(@NonNull Account account, @NonNull String packa
40634063
int uid = mPackageManager.getPackageUidAsUser(packageName, userId);
40644064
return hasAccountAccess(account, packageName, uid);
40654065
} catch (NameNotFoundException e) {
4066-
Log.d(TAG, "Package not found " + e.getMessage());
4066+
Log.w(TAG, "hasAccountAccess#Package not found " + e.getMessage());
40674067
return false;
40684068
}
40694069
}
@@ -4195,7 +4195,7 @@ public boolean someUserHasAccount(@NonNull final Account account) {
41954195
}
41964196
final long token = Binder.clearCallingIdentity();
41974197
try {
4198-
AccountAndUser[] allAccounts = getAllAccounts();
4198+
AccountAndUser[] allAccounts = getAllAccountsForSystemProcess();
41994199
for (int i = allAccounts.length - 1; i >= 0; i--) {
42004200
if (allAccounts[i].account.equals(account)) {
42014201
return true;
@@ -4345,37 +4345,46 @@ public Account[] getAccounts(int userId, String opPackageName) {
43454345
/**
43464346
* Returns accounts for all running users, ignores visibility values.
43474347
*
4348+
* Should only be called by System process.
43484349
* @hide
43494350
*/
43504351
@NonNull
4351-
public AccountAndUser[] getRunningAccounts() {
4352+
public AccountAndUser[] getRunningAccountsForSystem() {
43524353
final int[] runningUserIds;
43534354
try {
43544355
runningUserIds = ActivityManager.getService().getRunningUserIds();
43554356
} catch (RemoteException e) {
43564357
// Running in system_server; should never happen
43574358
throw new RuntimeException(e);
43584359
}
4359-
return getAccounts(runningUserIds);
4360+
return getAccountsForSystem(runningUserIds);
43604361
}
43614362

43624363
/**
43634364
* Returns accounts for all users, ignores visibility values.
43644365
*
4366+
* Should only be called by system process
4367+
*
43654368
* @hide
43664369
*/
43674370
@NonNull
4368-
public AccountAndUser[] getAllAccounts() {
4371+
public AccountAndUser[] getAllAccountsForSystemProcess() {
43694372
final List<UserInfo> users = getUserManager().getAliveUsers();
43704373
final int[] userIds = new int[users.size()];
43714374
for (int i = 0; i < userIds.length; i++) {
43724375
userIds[i] = users.get(i).id;
43734376
}
4374-
return getAccounts(userIds);
4377+
return getAccountsForSystem(userIds);
43754378
}
43764379

4380+
/**
4381+
* Returns all accounts for the given user, ignores all visibility checks.
4382+
* This should only be called by system process.
4383+
*
4384+
* @hide
4385+
*/
43774386
@NonNull
4378-
private AccountAndUser[] getAccounts(int[] userIds) {
4387+
private AccountAndUser[] getAccountsForSystem(int[] userIds) {
43794388
final ArrayList<AccountAndUser> runningAccounts = Lists.newArrayList();
43804389
for (int userId : userIds) {
43814390
UserAccounts userAccounts = getUserAccounts(userId);
@@ -4384,7 +4393,7 @@ private AccountAndUser[] getAccounts(int[] userIds) {
43844393
userAccounts,
43854394
null /* type */,
43864395
Binder.getCallingUid(),
4387-
null /* packageName */,
4396+
"android"/* packageName */,
43884397
false /* include managed not visible*/);
43894398
for (Account account : accounts) {
43904399
runningAccounts.add(new AccountAndUser(account, userId));
@@ -5355,7 +5364,7 @@ private void dumpUser(UserAccounts userAccounts, FileDescriptor fd, PrintWriter
53555364
}
53565365
} else {
53575366
Account[] accounts = getAccountsFromCache(userAccounts, null /* type */,
5358-
Process.SYSTEM_UID, null /* packageName */, false);
5367+
Process.SYSTEM_UID, "android" /* packageName */, false);
53595368
fout.println("Accounts: " + accounts.length);
53605369
for (Account account : accounts) {
53615370
fout.println(" " + account.toString());
@@ -5550,7 +5559,7 @@ private boolean isPrivileged(int callingUid) {
55505559
return true;
55515560
}
55525561
} catch (PackageManager.NameNotFoundException e) {
5553-
Log.d(TAG, "Package not found " + e.getMessage());
5562+
Log.w(TAG, "isPrivileged#Package not found " + e.getMessage());
55545563
}
55555564
}
55565565
} finally {
@@ -6074,7 +6083,7 @@ private Map<Account, Integer> filterSharedAccounts(UserAccounts userAccounts,
60746083
}
60756084
}
60766085
} catch (NameNotFoundException e) {
6077-
Log.d(TAG, "Package not found " + e.getMessage());
6086+
Log.w(TAG, "filterSharedAccounts#Package not found " + e.getMessage());
60786087
}
60796088
Map<Account, Integer> filtered = new LinkedHashMap<>();
60806089
for (Map.Entry<Account, Integer> entry : unfiltered.entrySet()) {

0 commit comments

Comments
 (0)