| 1 |
package android.os; |
| 2 |
|
| 3 |
import android.annotation.NonNull; |
| 4 |
import android.annotation.Nullable; |
| 5 |
import android.annotation.SystemApi; |
| 6 |
import android.annotation.TestApi; |
| 7 |
import android.compat.annotation.UnsupportedAppUsage; |
| 8 |
import android.content.Context; |
| 9 |
import android.provider.Settings; |
| 10 |
import android.provider.Settings.Global; |
| 11 |
import android.util.Log; |
| 12 |
import android.util.proto.ProtoOutputStream; |
| 13 |
|
| 14 |
import com.android.internal.annotations.VisibleForTesting; |
| 15 |
import com.android.internal.util.Preconditions; |
| 16 |
|
| 17 |
import java.util.ArrayList; |
| 18 |
import java.util.Arrays; |
| 19 |
import java.util.List; |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
public class WorkSource implements Parcelable { |
| 27 |
static final String TAG = "WorkSource"; |
| 28 |
static final boolean DEBUG = false; |
| 29 |
|
| 30 |
@UnsupportedAppUsage |
| 31 |
int mNum; |
| 32 |
@UnsupportedAppUsage |
| 33 |
int[] mUids; |
| 34 |
@UnsupportedAppUsage |
| 35 |
String[] mNames; |
| 36 |
|
| 37 |
private ArrayList<WorkChain> mChains; |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 45 |
static final WorkSource sTmpWorkSource = new WorkSource(0); |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 50 |
static WorkSource sNewbWork; |
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 55 |
static WorkSource sGoneWork; |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
public WorkSource() { |
| 61 |
mNum = 0; |
| 62 |
mChains = null; |
| 63 |
} |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
public WorkSource(WorkSource orig) { |
| 70 |
if (orig == null) { |
| 71 |
mNum = 0; |
| 72 |
mChains = null; |
| 73 |
return; |
| 74 |
} |
| 75 |
mNum = orig.mNum; |
| 76 |
if (orig.mUids != null) { |
| 77 |
mUids = orig.mUids.clone(); |
| 78 |
mNames = orig.mNames != null ? orig.mNames.clone() : null; |
| 79 |
} else { |
| 80 |
mUids = null; |
| 81 |
mNames = null; |
| 82 |
} |
| 83 |
|
| 84 |
if (orig.mChains != null) { |
| 85 |
|
| 86 |
mChains = new ArrayList<>(orig.mChains.size()); |
| 87 |
for (WorkChain chain : orig.mChains) { |
| 88 |
mChains.add(new WorkChain(chain)); |
| 89 |
} |
| 90 |
} else { |
| 91 |
mChains = null; |
| 92 |
} |
| 93 |
} |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
@SystemApi |
| 102 |
public WorkSource(int uid) { |
| 103 |
mNum = 1; |
| 104 |
mUids = new int[] { uid, 0 }; |
| 105 |
mNames = null; |
| 106 |
mChains = null; |
| 107 |
} |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
@SystemApi |
| 116 |
public WorkSource(int uid, @NonNull String packageName) { |
| 117 |
Preconditions.checkNotNull(packageName, "packageName can't be null"); |
| 118 |
mNum = 1; |
| 119 |
mUids = new int[] { uid, 0 }; |
| 120 |
mNames = new String[] { packageName, null }; |
| 121 |
mChains = null; |
| 122 |
} |
| 123 |
|
| 124 |
@UnsupportedAppUsage |
| 125 |
WorkSource(Parcel in) { |
| 126 |
mNum = in.readInt(); |
| 127 |
mUids = in.createIntArray(); |
| 128 |
mNames = in.createStringArray(); |
| 129 |
|
| 130 |
int numChains = in.readInt(); |
| 131 |
if (numChains >= 0) { |
| 132 |
mChains = new ArrayList<>(numChains); |
| 133 |
in.readParcelableList(mChains, WorkChain.class.getClassLoader(), android.os.WorkSource.WorkChain.class); |
| 134 |
} else { |
| 135 |
mChains = null; |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
|
| 140 |
|
| 141 |
|
| 142 |
|
| 143 |
|
| 144 |
|
| 145 |
public static boolean isChainedBatteryAttributionEnabled(Context context) { |
| 146 |
return Settings.Global.getInt(context.getContentResolver(), |
| 147 |
Global.CHAINED_BATTERY_ATTRIBUTION_ENABLED, 0) == 1; |
| 148 |
} |
| 149 |
|
| 150 |
|
| 151 |
|
| 152 |
|
| 153 |
|
| 154 |
@SystemApi |
| 155 |
public int size() { |
| 156 |
return mNum; |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
|
| 163 |
@UnsupportedAppUsage |
| 164 |
@Deprecated |
| 165 |
public int get(int index) { |
| 166 |
return getUid(index); |
| 167 |
} |
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
@SystemApi |
| 175 |
public int getUid(int index) { |
| 176 |
return mUids[index]; |
| 177 |
} |
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
public int getAttributionUid() { |
| 187 |
if (isEmpty()) { |
| 188 |
return -1; |
| 189 |
} |
| 190 |
|
| 191 |
return mNum > 0 ? mUids[0] : mChains.get(0).getAttributionUid(); |
| 192 |
} |
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
@UnsupportedAppUsage |
| 199 |
@Deprecated |
| 200 |
public String getName(int index) { |
| 201 |
return getPackageName(index); |
| 202 |
} |
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
@SystemApi |
| 210 |
@Nullable |
| 211 |
public String getPackageName(int index) { |
| 212 |
return mNames != null ? mNames[index] : null; |
| 213 |
} |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
private void clearNames() { |
| 222 |
if (mNames != null) { |
| 223 |
mNames = null; |
| 224 |
|
| 225 |
int destIndex = 1; |
| 226 |
int newNum = mNum; |
| 227 |
for (int sourceIndex = 1; sourceIndex < mNum; sourceIndex++) { |
| 228 |
if (mUids[sourceIndex] == mUids[sourceIndex - 1]) { |
| 229 |
newNum--; |
| 230 |
} else { |
| 231 |
mUids[destIndex] = mUids[sourceIndex]; |
| 232 |
destIndex++; |
| 233 |
} |
| 234 |
} |
| 235 |
mNum = newNum; |
| 236 |
} |
| 237 |
} |
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
public void clear() { |
| 243 |
mNum = 0; |
| 244 |
if (mChains != null) { |
| 245 |
mChains.clear(); |
| 246 |
} |
| 247 |
} |
| 248 |
|
| 249 |
@Override |
| 250 |
public boolean equals(@Nullable Object o) { |
| 251 |
if (o instanceof WorkSource) { |
| 252 |
WorkSource other = (WorkSource) o; |
| 253 |
|
| 254 |
if (diff(other)) { |
| 255 |
return false; |
| 256 |
} |
| 257 |
|
| 258 |
if (mChains != null && !mChains.isEmpty()) { |
| 259 |
return mChains.equals(other.mChains); |
| 260 |
} else { |
| 261 |
return other.mChains == null || other.mChains.isEmpty(); |
| 262 |
} |
| 263 |
} |
| 264 |
|
| 265 |
return false; |
| 266 |
} |
| 267 |
|
| 268 |
@Override |
| 269 |
public int hashCode() { |
| 270 |
int result = 0; |
| 271 |
for (int i = 0; i < mNum; i++) { |
| 272 |
result = ((result << 4) | (result >>> 28)) ^ mUids[i]; |
| 273 |
} |
| 274 |
if (mNames != null) { |
| 275 |
for (int i = 0; i < mNum; i++) { |
| 276 |
result = ((result << 4) | (result >>> 28)) ^ mNames[i].hashCode(); |
| 277 |
} |
| 278 |
} |
| 279 |
|
| 280 |
if (mChains != null) { |
| 281 |
result = ((result << 4) | (result >>> 28)) ^ mChains.hashCode(); |
| 282 |
} |
| 283 |
|
| 284 |
return result; |
| 285 |
} |
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
public boolean diff(WorkSource other) { |
| 295 |
int N = mNum; |
| 296 |
if (N != other.mNum) { |
| 297 |
return true; |
| 298 |
} |
| 299 |
final int[] uids1 = mUids; |
| 300 |
final int[] uids2 = other.mUids; |
| 301 |
final String[] names1 = mNames; |
| 302 |
final String[] names2 = other.mNames; |
| 303 |
for (int i=0; i<N; i++) { |
| 304 |
if (uids1[i] != uids2[i]) { |
| 305 |
return true; |
| 306 |
} |
| 307 |
if (names1 != null && names2 != null && !names1[i].equals(names2[i])) { |
| 308 |
return true; |
| 309 |
} |
| 310 |
} |
| 311 |
return false; |
| 312 |
} |
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
public void set(WorkSource other) { |
| 320 |
if (other == null) { |
| 321 |
mNum = 0; |
| 322 |
if (mChains != null) { |
| 323 |
mChains.clear(); |
| 324 |
} |
| 325 |
return; |
| 326 |
} |
| 327 |
mNum = other.mNum; |
| 328 |
if (other.mUids != null) { |
| 329 |
if (mUids != null && mUids.length >= mNum) { |
| 330 |
System.arraycopy(other.mUids, 0, mUids, 0, mNum); |
| 331 |
} else { |
| 332 |
mUids = other.mUids.clone(); |
| 333 |
} |
| 334 |
if (other.mNames != null) { |
| 335 |
if (mNames != null && mNames.length >= mNum) { |
| 336 |
System.arraycopy(other.mNames, 0, mNames, 0, mNum); |
| 337 |
} else { |
| 338 |
mNames = other.mNames.clone(); |
| 339 |
} |
| 340 |
} else { |
| 341 |
mNames = null; |
| 342 |
} |
| 343 |
} else { |
| 344 |
mUids = null; |
| 345 |
mNames = null; |
| 346 |
} |
| 347 |
|
| 348 |
if (other.mChains != null) { |
| 349 |
if (mChains != null) { |
| 350 |
mChains.clear(); |
| 351 |
} else { |
| 352 |
mChains = new ArrayList<>(other.mChains.size()); |
| 353 |
} |
| 354 |
|
| 355 |
for (WorkChain chain : other.mChains) { |
| 356 |
mChains.add(new WorkChain(chain)); |
| 357 |
} |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
|
| 362 |
public void set(int uid) { |
| 363 |
mNum = 1; |
| 364 |
if (mUids == null) mUids = new int[2]; |
| 365 |
mUids[0] = uid; |
| 366 |
mNames = null; |
| 367 |
if (mChains != null) { |
| 368 |
mChains.clear(); |
| 369 |
} |
| 370 |
} |
| 371 |
|
| 372 |
|
| 373 |
public void set(int uid, String name) { |
| 374 |
if (name == null) { |
| 375 |
throw new NullPointerException("Name can't be null"); |
| 376 |
} |
| 377 |
mNum = 1; |
| 378 |
if (mUids == null) { |
| 379 |
mUids = new int[2]; |
| 380 |
mNames = new String[2]; |
| 381 |
} |
| 382 |
mUids[0] = uid; |
| 383 |
mNames[0] = name; |
| 384 |
if (mChains != null) { |
| 385 |
mChains.clear(); |
| 386 |
} |
| 387 |
} |
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
@Deprecated |
| 401 |
@TestApi |
| 402 |
public WorkSource[] setReturningDiffs(WorkSource other) { |
| 403 |
synchronized (sTmpWorkSource) { |
| 404 |
sNewbWork = null; |
| 405 |
sGoneWork = null; |
| 406 |
updateLocked(other, true, true); |
| 407 |
if (sNewbWork != null || sGoneWork != null) { |
| 408 |
WorkSource[] diffs = new WorkSource[2]; |
| 409 |
diffs[0] = sNewbWork; |
| 410 |
diffs[1] = sGoneWork; |
| 411 |
return diffs; |
| 412 |
} |
| 413 |
return null; |
| 414 |
} |
| 415 |
} |
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
public boolean add(WorkSource other) { |
| 424 |
synchronized (sTmpWorkSource) { |
| 425 |
boolean uidAdded = updateLocked(other, false, false); |
| 426 |
|
| 427 |
boolean chainAdded = false; |
| 428 |
if (other.mChains != null) { |
| 429 |
|
| 430 |
|
| 431 |
if (mChains == null) { |
| 432 |
mChains = new ArrayList<>(other.mChains.size()); |
| 433 |
} |
| 434 |
|
| 435 |
for (WorkChain wc : other.mChains) { |
| 436 |
if (!mChains.contains(wc)) { |
| 437 |
mChains.add(new WorkChain(wc)); |
| 438 |
chainAdded = true; |
| 439 |
} |
| 440 |
} |
| 441 |
} |
| 442 |
|
| 443 |
return uidAdded || chainAdded; |
| 444 |
} |
| 445 |
} |
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
@SystemApi |
| 455 |
@NonNull |
| 456 |
public WorkSource withoutNames() { |
| 457 |
final WorkSource copy = new WorkSource(this); |
| 458 |
copy.clearNames(); |
| 459 |
return copy; |
| 460 |
} |
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
@Deprecated |
| 469 |
@TestApi |
| 470 |
public WorkSource addReturningNewbs(WorkSource other) { |
| 471 |
synchronized (sTmpWorkSource) { |
| 472 |
sNewbWork = null; |
| 473 |
updateLocked(other, false, true); |
| 474 |
return sNewbWork; |
| 475 |
} |
| 476 |
} |
| 477 |
|
| 478 |
|
| 479 |
@UnsupportedAppUsage |
| 480 |
@TestApi |
| 481 |
public boolean add(int uid) { |
| 482 |
if (mNum <= 0) { |
| 483 |
mNames = null; |
| 484 |
insert(0, uid); |
| 485 |
return true; |
| 486 |
} |
| 487 |
if (mNames != null) { |
| 488 |
throw new IllegalArgumentException("Adding without name to named " + this); |
| 489 |
} |
| 490 |
int i = Arrays.binarySearch(mUids, 0, mNum, uid); |
| 491 |
if (DEBUG) Log.d(TAG, "Adding uid " + uid + " to " + this + ": binsearch res = " + i); |
| 492 |
if (i >= 0) { |
| 493 |
return false; |
| 494 |
} |
| 495 |
insert(-i-1, uid); |
| 496 |
return true; |
| 497 |
} |
| 498 |
|
| 499 |
|
| 500 |
@UnsupportedAppUsage |
| 501 |
@TestApi |
| 502 |
public boolean add(int uid, String name) { |
| 503 |
if (mNum <= 0) { |
| 504 |
insert(0, uid, name); |
| 505 |
return true; |
| 506 |
} |
| 507 |
if (mNames == null) { |
| 508 |
throw new IllegalArgumentException("Adding name to unnamed " + this); |
| 509 |
} |
| 510 |
int i; |
| 511 |
for (i=0; i<mNum; i++) { |
| 512 |
if (mUids[i] > uid) { |
| 513 |
break; |
| 514 |
} |
| 515 |
if (mUids[i] == uid) { |
| 516 |
int diff = mNames[i].compareTo(name); |
| 517 |
if (diff > 0) { |
| 518 |
break; |
| 519 |
} |
| 520 |
if (diff == 0) { |
| 521 |
return false; |
| 522 |
} |
| 523 |
} |
| 524 |
} |
| 525 |
insert(i, uid, name); |
| 526 |
return true; |
| 527 |
} |
| 528 |
|
| 529 |
public boolean remove(WorkSource other) { |
| 530 |
if (isEmpty() || other.isEmpty()) { |
| 531 |
return false; |
| 532 |
} |
| 533 |
|
| 534 |
boolean uidRemoved; |
| 535 |
if (mNames == null && other.mNames == null) { |
| 536 |
uidRemoved = removeUids(other); |
| 537 |
} else { |
| 538 |
if (mNames == null) { |
| 539 |
throw new IllegalArgumentException("Other " + other + " has names, but target " |
| 540 |
+ this + " does not"); |
| 541 |
} |
| 542 |
if (other.mNames == null) { |
| 543 |
throw new IllegalArgumentException("Target " + this + " has names, but other " |
| 544 |
+ other + " does not"); |
| 545 |
} |
| 546 |
uidRemoved = removeUidsAndNames(other); |
| 547 |
} |
| 548 |
|
| 549 |
boolean chainRemoved = false; |
| 550 |
if (other.mChains != null && mChains != null) { |
| 551 |
chainRemoved = mChains.removeAll(other.mChains); |
| 552 |
} |
| 553 |
|
| 554 |
return uidRemoved || chainRemoved; |
| 555 |
} |
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
@SystemApi |
| 563 |
public WorkChain createWorkChain() { |
| 564 |
if (mChains == null) { |
| 565 |
mChains = new ArrayList<>(4); |
| 566 |
} |
| 567 |
|
| 568 |
final WorkChain wc = new WorkChain(); |
| 569 |
mChains.add(wc); |
| 570 |
|
| 571 |
return wc; |
| 572 |
} |
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
@SystemApi |
| 581 |
public boolean isEmpty() { |
| 582 |
return mNum == 0 && (mChains == null || mChains.isEmpty()); |
| 583 |
} |
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
@SystemApi |
| 590 |
@Nullable |
| 591 |
public List<WorkChain> getWorkChains() { |
| 592 |
return mChains; |
| 593 |
} |
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
public void transferWorkChains(WorkSource other) { |
| 602 |
if (mChains != null) { |
| 603 |
mChains.clear(); |
| 604 |
} |
| 605 |
|
| 606 |
if (other.mChains == null || other.mChains.isEmpty()) { |
| 607 |
return; |
| 608 |
} |
| 609 |
|
| 610 |
if (mChains == null) { |
| 611 |
mChains = new ArrayList<>(4); |
| 612 |
} |
| 613 |
|
| 614 |
mChains.addAll(other.mChains); |
| 615 |
other.mChains.clear(); |
| 616 |
} |
| 617 |
|
| 618 |
private boolean removeUids(WorkSource other) { |
| 619 |
int N1 = mNum; |
| 620 |
final int[] uids1 = mUids; |
| 621 |
final int N2 = other.mNum; |
| 622 |
final int[] uids2 = other.mUids; |
| 623 |
boolean changed = false; |
| 624 |
int i1 = 0, i2 = 0; |
| 625 |
if (DEBUG) Log.d(TAG, "Remove " + other + " from " + this); |
| 626 |
while (i1 < N1 && i2 < N2) { |
| 627 |
if (DEBUG) Log.d(TAG, "Step: target @ " + i1 + " of " + N1 + ", other @ " + i2 |
| 628 |
+ " of " + N2); |
| 629 |
if (uids2[i2] == uids1[i1]) { |
| 630 |
if (DEBUG) Log.d(TAG, "i1=" + i1 + " i2=" + i2 + " N1=" + N1 |
| 631 |
+ ": remove " + uids1[i1]); |
| 632 |
N1--; |
| 633 |
changed = true; |
| 634 |
if (i1 < N1) System.arraycopy(uids1, i1+1, uids1, i1, N1-i1); |
| 635 |
i2++; |
| 636 |
} else if (uids2[i2] > uids1[i1]) { |
| 637 |
if (DEBUG) Log.d(TAG, "i1=" + i1 + " i2=" + i2 + " N1=" + N1 + ": skip i1"); |
| 638 |
i1++; |
| 639 |
} else { |
| 640 |
if (DEBUG) Log.d(TAG, "i1=" + i1 + " i2=" + i2 + " N1=" + N1 + ": skip i2"); |
| 641 |
i2++; |
| 642 |
} |
| 643 |
} |
| 644 |
|
| 645 |
mNum = N1; |
| 646 |
|
| 647 |
return changed; |
| 648 |
} |
| 649 |
|
| 650 |
private boolean removeUidsAndNames(WorkSource other) { |
| 651 |
int N1 = mNum; |
| 652 |
final int[] uids1 = mUids; |
| 653 |
final String[] names1 = mNames; |
| 654 |
final int N2 = other.mNum; |
| 655 |
final int[] uids2 = other.mUids; |
| 656 |
final String[] names2 = other.mNames; |
| 657 |
boolean changed = false; |
| 658 |
int i1 = 0, i2 = 0; |
| 659 |
if (DEBUG) Log.d(TAG, "Remove " + other + " from " + this); |
| 660 |
while (i1 < N1 && i2 < N2) { |
| 661 |
if (DEBUG) Log.d(TAG, "Step: target @ " + i1 + " of " + N1 + ", other @ " + i2 |
| 662 |
+ " of " + N2 + ": " + uids1[i1] + " " + names1[i1]); |
| 663 |
if (uids2[i2] == uids1[i1] && names2[i2].equals(names1[i1])) { |
| 664 |
if (DEBUG) Log.d(TAG, "i1=" + i1 + " i2=" + i2 + " N1=" + N1 |
| 665 |
+ ": remove " + uids1[i1] + " " + names1[i1]); |
| 666 |
N1--; |
| 667 |
changed = true; |
| 668 |
if (i1 < N1) { |
| 669 |
System.arraycopy(uids1, i1+1, uids1, i1, N1-i1); |
| 670 |
System.arraycopy(names1, i1+1, names1, i1, N1-i1); |
| 671 |
} |
| 672 |
i2++; |
| 673 |
} else if (uids2[i2] > uids1[i1] |
| 674 |
|| (uids2[i2] == uids1[i1] && names2[i2].compareTo(names1[i1]) > 0)) { |
| 675 |
if (DEBUG) Log.d(TAG, "i1=" + i1 + " i2=" + i2 + " N1=" + N1 + ": skip i1"); |
| 676 |
i1++; |
| 677 |
} else { |
| 678 |
if (DEBUG) Log.d(TAG, "i1=" + i1 + " i2=" + i2 + " N1=" + N1 + ": skip i2"); |
| 679 |
i2++; |
| 680 |
} |
| 681 |
} |
| 682 |
|
| 683 |
mNum = N1; |
| 684 |
|
| 685 |
return changed; |
| 686 |
} |
| 687 |
|
| 688 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 689 |
private boolean updateLocked(WorkSource other, boolean set, boolean returnNewbs) { |
| 690 |
if (mNames == null && other.mNames == null) { |
| 691 |
return updateUidsLocked(other, set, returnNewbs); |
| 692 |
} else { |
| 693 |
if (mNum > 0 && mNames == null) { |
| 694 |
throw new IllegalArgumentException("Other " + other + " has names, but target " |
| 695 |
+ this + " does not"); |
| 696 |
} |
| 697 |
if (other.mNum > 0 && other.mNames == null) { |
| 698 |
throw new IllegalArgumentException("Target " + this + " has names, but other " |
| 699 |
+ other + " does not"); |
| 700 |
} |
| 701 |
return updateUidsAndNamesLocked(other, set, returnNewbs); |
| 702 |
} |
| 703 |
} |
| 704 |
|
| 705 |
private static WorkSource addWork(WorkSource cur, int newUid) { |
| 706 |
if (cur == null) { |
| 707 |
return new WorkSource(newUid); |
| 708 |
} |
| 709 |
cur.insert(cur.mNum, newUid); |
| 710 |
return cur; |
| 711 |
} |
| 712 |
|
| 713 |
private boolean updateUidsLocked(WorkSource other, boolean set, boolean returnNewbs) { |
| 714 |
int N1 = mNum; |
| 715 |
int[] uids1 = mUids; |
| 716 |
final int N2 = other.mNum; |
| 717 |
final int[] uids2 = other.mUids; |
| 718 |
boolean changed = false; |
| 719 |
int i1 = 0, i2 = 0; |
| 720 |
if (DEBUG) Log.d(TAG, "Update " + this + " with " + other + " set=" + set |
| 721 |
+ " returnNewbs=" + returnNewbs); |
| 722 |
while (i1 < N1 || i2 < N2) { |
| 723 |
if (DEBUG) Log.d(TAG, "Step: target @ " + i1 + " of " + N1 + ", other @ " + i2 |
| 724 |
+ " of " + N2); |
| 725 |
if (i1 >= N1 || (i2 < N2 && uids2[i2] < uids1[i1])) { |
| 726 |
|
| 727 |
if (DEBUG) Log.d(TAG, "i1=" + i1 + " i2=" + i2 + " N1=" + N1 |
| 728 |
+ ": insert " + uids2[i2]); |
| 729 |
changed = true; |
| 730 |
if (uids1 == null) { |
| 731 |
uids1 = new int[4]; |
| 732 |
uids1[0] = uids2[i2]; |
| 733 |
} else if (N1 >= uids1.length) { |
| 734 |
int[] newuids = new int[(uids1.length*3)/2]; |
| 735 |
if (i1 > 0) System.arraycopy(uids1, 0, newuids, 0, i1); |
| 736 |
if (i1 < N1) System.arraycopy(uids1, i1, newuids, i1+1, N1-i1); |
| 737 |
uids1 = newuids; |
| 738 |
uids1[i1] = uids2[i2]; |
| 739 |
} else { |
| 740 |
if (i1 < N1) System.arraycopy(uids1, i1, uids1, i1+1, N1-i1); |
| 741 |
uids1[i1] = uids2[i2]; |
| 742 |
} |
| 743 |
if (returnNewbs) { |
| 744 |
sNewbWork = addWork(sNewbWork, uids2[i2]); |
| 745 |
} |
| 746 |
N1++; |
| 747 |
i1++; |
| 748 |
i2++; |
| 749 |
} else { |
| 750 |
if (!set) { |
| 751 |
|
| 752 |
if (DEBUG) Log.d(TAG, "i1=" + i1 + " i2=" + i2 + " N1=" + N1 + ": skip"); |
| 753 |
if (i2 < N2 && uids2[i2] == uids1[i1]) { |
| 754 |
i2++; |
| 755 |
} |
| 756 |
i1++; |
| 757 |
} else { |
| 758 |
|
| 759 |
int start = i1; |
| 760 |
while (i1 < N1 && (i2 >= N2 || uids2[i2] > uids1[i1])) { |
| 761 |
if (DEBUG) Log.d(TAG, "i1=" + i1 + " i2=" + i2 + ": remove " + uids1[i1]); |
| 762 |
sGoneWork = addWork(sGoneWork, uids1[i1]); |
| 763 |
i1++; |
| 764 |
} |
| 765 |
if (start < i1) { |
| 766 |
System.arraycopy(uids1, i1, uids1, start, N1-i1); |
| 767 |
N1 -= i1-start; |
| 768 |
i1 = start; |
| 769 |
} |
| 770 |
|
| 771 |
if (i1 < N1 && i2 < N2 && uids2[i2] == uids1[i1]) { |
| 772 |
if (DEBUG) Log.d(TAG, "i1=" + i1 + " i2=" + i2 + " N1=" + N1 + ": skip"); |
| 773 |
i1++; |
| 774 |
i2++; |
| 775 |
} |
| 776 |
} |
| 777 |
} |
| 778 |
} |
| 779 |
|
| 780 |
mNum = N1; |
| 781 |
mUids = uids1; |
| 782 |
|
| 783 |
return changed; |
| 784 |
} |
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
private int compare(WorkSource other, int i1, int i2) { |
| 790 |
final int diff = mUids[i1] - other.mUids[i2]; |
| 791 |
if (diff != 0) { |
| 792 |
return diff; |
| 793 |
} |
| 794 |
return mNames[i1].compareTo(other.mNames[i2]); |
| 795 |
} |
| 796 |
|
| 797 |
private static WorkSource addWork(WorkSource cur, int newUid, String newName) { |
| 798 |
if (cur == null) { |
| 799 |
return new WorkSource(newUid, newName); |
| 800 |
} |
| 801 |
cur.insert(cur.mNum, newUid, newName); |
| 802 |
return cur; |
| 803 |
} |
| 804 |
|
| 805 |
private boolean updateUidsAndNamesLocked(WorkSource other, boolean set, boolean returnNewbs) { |
| 806 |
final int N2 = other.mNum; |
| 807 |
final int[] uids2 = other.mUids; |
| 808 |
String[] names2 = other.mNames; |
| 809 |
boolean changed = false; |
| 810 |
int i1 = 0, i2 = 0; |
| 811 |
if (DEBUG) Log.d(TAG, "Update " + this + " with " + other + " set=" + set |
| 812 |
+ " returnNewbs=" + returnNewbs); |
| 813 |
while (i1 < mNum || i2 < N2) { |
| 814 |
if (DEBUG) Log.d(TAG, "Step: target @ " + i1 + " of " + mNum + ", other @ " + i2 |
| 815 |
+ " of " + N2); |
| 816 |
int diff = -1; |
| 817 |
if (i1 >= mNum || (i2 < N2 && (diff=compare(other, i1, i2)) > 0)) { |
| 818 |
|
| 819 |
changed = true; |
| 820 |
if (DEBUG) Log.d(TAG, "i1=" + i1 + " i2=" + i2 + " N1=" + mNum |
| 821 |
+ ": insert " + uids2[i2] + " " + names2[i2]); |
| 822 |
insert(i1, uids2[i2], names2[i2]); |
| 823 |
if (returnNewbs) { |
| 824 |
sNewbWork = addWork(sNewbWork, uids2[i2], names2[i2]); |
| 825 |
} |
| 826 |
i1++; |
| 827 |
i2++; |
| 828 |
} else { |
| 829 |
if (!set) { |
| 830 |
if (DEBUG) Log.d(TAG, "i1=" + i1 + " i2=" + i2 + " N1=" + mNum + ": skip"); |
| 831 |
if (i2 < N2 && diff == 0) { |
| 832 |
i2++; |
| 833 |
} |
| 834 |
i1++; |
| 835 |
} else { |
| 836 |
|
| 837 |
int start = i1; |
| 838 |
while (diff < 0) { |
| 839 |
if (DEBUG) Log.d(TAG, "i1=" + i1 + " i2=" + i2 + ": remove " + mUids[i1] |
| 840 |
+ " " + mNames[i1]); |
| 841 |
sGoneWork = addWork(sGoneWork, mUids[i1], mNames[i1]); |
| 842 |
i1++; |
| 843 |
if (i1 >= mNum) { |
| 844 |
break; |
| 845 |
} |
| 846 |
diff = i2 < N2 ? compare(other, i1, i2) : -1; |
| 847 |
} |
| 848 |
if (start < i1) { |
| 849 |
System.arraycopy(mUids, i1, mUids, start, mNum-i1); |
| 850 |
System.arraycopy(mNames, i1, mNames, start, mNum-i1); |
| 851 |
mNum -= i1-start; |
| 852 |
i1 = start; |
| 853 |
} |
| 854 |
|
| 855 |
if (i1 < mNum && diff == 0) { |
| 856 |
if (DEBUG) Log.d(TAG, "i1=" + i1 + " i2=" + i2 + " N1=" + mNum + ": skip"); |
| 857 |
i1++; |
| 858 |
i2++; |
| 859 |
} |
| 860 |
} |
| 861 |
} |
| 862 |
} |
| 863 |
|
| 864 |
return changed; |
| 865 |
} |
| 866 |
|
| 867 |
private void insert(int index, int uid) { |
| 868 |
if (DEBUG) Log.d(TAG, "Insert in " + this + " @ " + index + " uid " + uid); |
| 869 |
if (mUids == null) { |
| 870 |
mUids = new int[4]; |
| 871 |
mUids[0] = uid; |
| 872 |
mNum = 1; |
| 873 |
} else if (mNum >= mUids.length) { |
| 874 |
int[] newuids = new int[(mNum*3)/2]; |
| 875 |
if (index > 0) { |
| 876 |
System.arraycopy(mUids, 0, newuids, 0, index); |
| 877 |
} |
| 878 |
if (index < mNum) { |
| 879 |
System.arraycopy(mUids, index, newuids, index+1, mNum-index); |
| 880 |
} |
| 881 |
mUids = newuids; |
| 882 |
mUids[index] = uid; |
| 883 |
mNum++; |
| 884 |
} else { |
| 885 |
if (index < mNum) { |
| 886 |
System.arraycopy(mUids, index, mUids, index+1, mNum-index); |
| 887 |
} |
| 888 |
mUids[index] = uid; |
| 889 |
mNum++; |
| 890 |
} |
| 891 |
} |
| 892 |
|
| 893 |
private void insert(int index, int uid, String name) { |
| 894 |
if (mUids == null) { |
| 895 |
mUids = new int[4]; |
| 896 |
mUids[0] = uid; |
| 897 |
mNames = new String[4]; |
| 898 |
mNames[0] = name; |
| 899 |
mNum = 1; |
| 900 |
} else if (mNum >= mUids.length) { |
| 901 |
int[] newuids = new int[(mNum*3)/2]; |
| 902 |
String[] newnames = new String[(mNum*3)/2]; |
| 903 |
if (index > 0) { |
| 904 |
System.arraycopy(mUids, 0, newuids, 0, index); |
| 905 |
System.arraycopy(mNames, 0, newnames, 0, index); |
| 906 |
} |
| 907 |
if (index < mNum) { |
| 908 |
System.arraycopy(mUids, index, newuids, index+1, mNum-index); |
| 909 |
System.arraycopy(mNames, index, newnames, index+1, mNum-index); |
| 910 |
} |
| 911 |
mUids = newuids; |
| 912 |
mNames = newnames; |
| 913 |
mUids[index] = uid; |
| 914 |
mNames[index] = name; |
| 915 |
mNum++; |
| 916 |
} else { |
| 917 |
if (index < mNum) { |
| 918 |
System.arraycopy(mUids, index, mUids, index+1, mNum-index); |
| 919 |
System.arraycopy(mNames, index, mNames, index+1, mNum-index); |
| 920 |
} |
| 921 |
mUids[index] = uid; |
| 922 |
mNames[index] = name; |
| 923 |
mNum++; |
| 924 |
} |
| 925 |
} |
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
|
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
|
| 941 |
|
| 942 |
|
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
|
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
@SystemApi |
| 958 |
public static final class WorkChain implements Parcelable { |
| 959 |
private int mSize; |
| 960 |
private int[] mUids; |
| 961 |
private String[] mTags; |
| 962 |
|
| 963 |
|
| 964 |
public WorkChain() { |
| 965 |
mSize = 0; |
| 966 |
mUids = new int[4]; |
| 967 |
mTags = new String[4]; |
| 968 |
} |
| 969 |
|
| 970 |
|
| 971 |
@VisibleForTesting |
| 972 |
public WorkChain(WorkChain other) { |
| 973 |
mSize = other.mSize; |
| 974 |
mUids = other.mUids.clone(); |
| 975 |
mTags = other.mTags.clone(); |
| 976 |
} |
| 977 |
|
| 978 |
private WorkChain(Parcel in) { |
| 979 |
mSize = in.readInt(); |
| 980 |
mUids = in.createIntArray(); |
| 981 |
mTags = in.createStringArray(); |
| 982 |
} |
| 983 |
|
| 984 |
|
| 985 |
|
| 986 |
|
| 987 |
|
| 988 |
public WorkChain addNode(int uid, @Nullable String tag) { |
| 989 |
if (mSize == mUids.length) { |
| 990 |
resizeArrays(); |
| 991 |
} |
| 992 |
|
| 993 |
mUids[mSize] = uid; |
| 994 |
mTags[mSize] = tag; |
| 995 |
mSize++; |
| 996 |
|
| 997 |
return this; |
| 998 |
} |
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
|
| 1004 |
public int getAttributionUid() { |
| 1005 |
return mSize > 0 ? mUids[0] : -1; |
| 1006 |
} |
| 1007 |
|
| 1008 |
|
| 1009 |
|
| 1010 |
|
| 1011 |
|
| 1012 |
public String getAttributionTag() { |
| 1013 |
return mTags.length > 0 ? mTags[0] : null; |
| 1014 |
} |
| 1015 |
|
| 1016 |
|
| 1017 |
|
| 1018 |
|
| 1019 |
|
| 1020 |
|
| 1021 |
|
| 1022 |
@VisibleForTesting |
| 1023 |
public int[] getUids() { |
| 1024 |
int[] uids = new int[mSize]; |
| 1025 |
System.arraycopy(mUids, 0, uids, 0, mSize); |
| 1026 |
return uids; |
| 1027 |
} |
| 1028 |
|
| 1029 |
|
| 1030 |
@VisibleForTesting |
| 1031 |
public String[] getTags() { |
| 1032 |
String[] tags = new String[mSize]; |
| 1033 |
System.arraycopy(mTags, 0, tags, 0, mSize); |
| 1034 |
return tags; |
| 1035 |
} |
| 1036 |
|
| 1037 |
|
| 1038 |
@VisibleForTesting |
| 1039 |
public int getSize() { |
| 1040 |
return mSize; |
| 1041 |
} |
| 1042 |
|
| 1043 |
private void resizeArrays() { |
| 1044 |
final int newSize = mSize * 2; |
| 1045 |
int[] uids = new int[newSize]; |
| 1046 |
String[] tags = new String[newSize]; |
| 1047 |
|
| 1048 |
System.arraycopy(mUids, 0, uids, 0, mSize); |
| 1049 |
System.arraycopy(mTags, 0, tags, 0, mSize); |
| 1050 |
|
| 1051 |
mUids = uids; |
| 1052 |
mTags = tags; |
| 1053 |
} |
| 1054 |
|
| 1055 |
@NonNull |
| 1056 |
@Override |
| 1057 |
public String toString() { |
| 1058 |
StringBuilder result = new StringBuilder("WorkChain{"); |
| 1059 |
for (int i = 0; i < mSize; ++i) { |
| 1060 |
if (i != 0) { |
| 1061 |
result.append(", "); |
| 1062 |
} |
| 1063 |
result.append("("); |
| 1064 |
result.append(mUids[i]); |
| 1065 |
if (mTags[i] != null) { |
| 1066 |
result.append(", "); |
| 1067 |
result.append(mTags[i]); |
| 1068 |
} |
| 1069 |
result.append(")"); |
| 1070 |
} |
| 1071 |
|
| 1072 |
result.append("}"); |
| 1073 |
return result.toString(); |
| 1074 |
} |
| 1075 |
|
| 1076 |
@Override |
| 1077 |
public int hashCode() { |
| 1078 |
return (mSize + 31 * Arrays.hashCode(mUids)) * 31 + Arrays.hashCode(mTags); |
| 1079 |
} |
| 1080 |
|
| 1081 |
@Override |
| 1082 |
public boolean equals(@Nullable Object o) { |
| 1083 |
if (o instanceof WorkChain) { |
| 1084 |
WorkChain other = (WorkChain) o; |
| 1085 |
|
| 1086 |
return mSize == other.mSize |
| 1087 |
&& Arrays.equals(mUids, other.mUids) |
| 1088 |
&& Arrays.equals(mTags, other.mTags); |
| 1089 |
} |
| 1090 |
|
| 1091 |
return false; |
| 1092 |
} |
| 1093 |
|
| 1094 |
@Override |
| 1095 |
public int describeContents() { |
| 1096 |
return 0; |
| 1097 |
} |
| 1098 |
|
| 1099 |
@Override |
| 1100 |
public void writeToParcel(Parcel dest, int flags) { |
| 1101 |
dest.writeInt(mSize); |
| 1102 |
dest.writeIntArray(mUids); |
| 1103 |
dest.writeStringArray(mTags); |
| 1104 |
} |
| 1105 |
|
| 1106 |
public static final @android.annotation.NonNull Parcelable.Creator<WorkChain> CREATOR = |
| 1107 |
new Parcelable.Creator<WorkChain>() { |
| 1108 |
public WorkChain createFromParcel(Parcel in) { |
| 1109 |
return new WorkChain(in); |
| 1110 |
} |
| 1111 |
public WorkChain[] newArray(int size) { |
| 1112 |
return new WorkChain[size]; |
| 1113 |
} |
| 1114 |
}; |
| 1115 |
} |
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
|
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
public static ArrayList<WorkChain>[] diffChains(WorkSource oldWs, WorkSource newWs) { |
| 1128 |
ArrayList<WorkChain> newChains = null; |
| 1129 |
ArrayList<WorkChain> goneChains = null; |
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
|
| 1135 |
if (oldWs.mChains != null) { |
| 1136 |
for (int i = 0; i < oldWs.mChains.size(); ++i) { |
| 1137 |
final WorkChain wc = oldWs.mChains.get(i); |
| 1138 |
if (newWs.mChains == null || !newWs.mChains.contains(wc)) { |
| 1139 |
if (goneChains == null) { |
| 1140 |
goneChains = new ArrayList<>(oldWs.mChains.size()); |
| 1141 |
} |
| 1142 |
goneChains.add(wc); |
| 1143 |
} |
| 1144 |
} |
| 1145 |
} |
| 1146 |
|
| 1147 |
if (newWs.mChains != null) { |
| 1148 |
for (int i = 0; i < newWs.mChains.size(); ++i) { |
| 1149 |
final WorkChain wc = newWs.mChains.get(i); |
| 1150 |
if (oldWs.mChains == null || !oldWs.mChains.contains(wc)) { |
| 1151 |
if (newChains == null) { |
| 1152 |
newChains = new ArrayList<>(newWs.mChains.size()); |
| 1153 |
} |
| 1154 |
newChains.add(wc); |
| 1155 |
} |
| 1156 |
} |
| 1157 |
} |
| 1158 |
|
| 1159 |
if (newChains != null || goneChains != null) { |
| 1160 |
return new ArrayList[] { newChains, goneChains }; |
| 1161 |
} |
| 1162 |
|
| 1163 |
return null; |
| 1164 |
} |
| 1165 |
|
| 1166 |
@Override |
| 1167 |
public int describeContents() { |
| 1168 |
return 0; |
| 1169 |
} |
| 1170 |
|
| 1171 |
@Override |
| 1172 |
public void writeToParcel(Parcel dest, int flags) { |
| 1173 |
dest.writeInt(mNum); |
| 1174 |
dest.writeIntArray(mUids); |
| 1175 |
dest.writeStringArray(mNames); |
| 1176 |
|
| 1177 |
if (mChains == null) { |
| 1178 |
dest.writeInt(-1); |
| 1179 |
} else { |
| 1180 |
dest.writeInt(mChains.size()); |
| 1181 |
dest.writeParcelableList(mChains, flags); |
| 1182 |
} |
| 1183 |
} |
| 1184 |
|
| 1185 |
@Override |
| 1186 |
public String toString() { |
| 1187 |
StringBuilder result = new StringBuilder(); |
| 1188 |
result.append("WorkSource{"); |
| 1189 |
for (int i = 0; i < mNum; i++) { |
| 1190 |
if (i != 0) { |
| 1191 |
result.append(", "); |
| 1192 |
} |
| 1193 |
result.append(mUids[i]); |
| 1194 |
if (mNames != null) { |
| 1195 |
result.append(" "); |
| 1196 |
result.append(mNames[i]); |
| 1197 |
} |
| 1198 |
} |
| 1199 |
|
| 1200 |
if (mChains != null) { |
| 1201 |
result.append(" chains="); |
| 1202 |
for (int i = 0; i < mChains.size(); ++i) { |
| 1203 |
if (i != 0) { |
| 1204 |
result.append(", "); |
| 1205 |
} |
| 1206 |
result.append(mChains.get(i)); |
| 1207 |
} |
| 1208 |
} |
| 1209 |
|
| 1210 |
result.append("}"); |
| 1211 |
return result.toString(); |
| 1212 |
} |
| 1213 |
|
| 1214 |
|
| 1215 |
public void dumpDebug(ProtoOutputStream proto, long fieldId) { |
| 1216 |
final long workSourceToken = proto.start(fieldId); |
| 1217 |
for (int i = 0; i < mNum; i++) { |
| 1218 |
final long contentProto = proto.start(WorkSourceProto.WORK_SOURCE_CONTENTS); |
| 1219 |
proto.write(WorkSourceProto.WorkSourceContentProto.UID, mUids[i]); |
| 1220 |
if (mNames != null) { |
| 1221 |
proto.write(WorkSourceProto.WorkSourceContentProto.NAME, mNames[i]); |
| 1222 |
} |
| 1223 |
proto.end(contentProto); |
| 1224 |
} |
| 1225 |
|
| 1226 |
if (mChains != null) { |
| 1227 |
for (int i = 0; i < mChains.size(); i++) { |
| 1228 |
final WorkChain wc = mChains.get(i); |
| 1229 |
final long workChain = proto.start(WorkSourceProto.WORK_CHAINS); |
| 1230 |
|
| 1231 |
final String[] tags = wc.getTags(); |
| 1232 |
final int[] uids = wc.getUids(); |
| 1233 |
for (int j = 0; j < tags.length; j++) { |
| 1234 |
final long contentProto = proto.start(WorkSourceProto.WORK_SOURCE_CONTENTS); |
| 1235 |
proto.write(WorkSourceProto.WorkSourceContentProto.UID, uids[j]); |
| 1236 |
proto.write(WorkSourceProto.WorkSourceContentProto.NAME, tags[j]); |
| 1237 |
proto.end(contentProto); |
| 1238 |
} |
| 1239 |
|
| 1240 |
proto.end(workChain); |
| 1241 |
} |
| 1242 |
} |
| 1243 |
|
| 1244 |
proto.end(workSourceToken); |
| 1245 |
} |
| 1246 |
|
| 1247 |
public static final @android.annotation.NonNull Parcelable.Creator<WorkSource> CREATOR |
| 1248 |
= new Parcelable.Creator<WorkSource>() { |
| 1249 |
public WorkSource createFromParcel(Parcel in) { |
| 1250 |
return new WorkSource(in); |
| 1251 |
} |
| 1252 |
public WorkSource[] newArray(int size) { |
| 1253 |
return new WorkSource[size]; |
| 1254 |
} |
| 1255 |
}; |
| 1256 |
} |